resourcefile.h

00001 /*
00002     This file is part of libkabc.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KABC_RESOURCEFILE_H
00022 #define KABC_RESOURCEFILE_H
00023 
00024 #include <kconfig.h>
00025 #include <kdirwatch.h>
00026 
00027 #include <sys/types.h>
00028 
00029 #include <kabc/resource.h>
00030 
00031 namespace KABC {
00032 
00033 class FormatPlugin;
00034 class ResourceConfigWidget;
00035 class Lock;
00036 
00040 class KABC_EXPORT ResourceFile : public Resource
00041 {
00042   Q_OBJECT
00043 
00044   public:
00050     ResourceFile( const KConfig *cfg );
00051 
00055     ResourceFile( const QString &fileName, const QString &formatName = "vcard" );
00056 
00060     ~ResourceFile();
00061 
00065     virtual void writeConfig( KConfig *cfg );
00066 
00071     virtual bool doOpen();
00072 
00076     virtual void doClose();
00077 
00081     virtual Ticket *requestSaveTicket();
00082 
00083     virtual void releaseSaveTicket( Ticket* );
00084 
00089     virtual bool load();
00090 
00091     virtual bool asyncLoad();
00092 
00099     virtual bool save( Ticket *ticket );
00100 
00101     virtual bool asyncSave( Ticket *ticket );
00102 
00106     void setFileName( const QString & );
00107 
00111     QString fileName() const;
00112 
00116     void setFormat( const QString &name );
00117 
00121     QString format() const;
00122 
00127     virtual void removeAddressee( const Addressee& addr );
00128 
00129   private slots:
00130     void emitLoadingFinished();
00131     void emitLoadingError();
00132     void emitSavingFinished();
00133     void emitSavingError();
00134 
00135   protected slots:
00136     void fileChanged();
00137 
00138   protected:
00139     void init( const QString &fileName, const QString &format );
00140 
00141     bool lock( const QString &fileName );
00142     void unlock( const QString &fileName );
00143 
00144   private:
00145     QString mFileName;
00146     QString mFormatName;
00147 
00148     FormatPlugin *mFormat;
00149 
00150     Lock *mLock;
00151 
00152     KDirWatch mDirWatch;
00153 
00154     bool mAsynchronous;
00155 
00156     class ResourceFilePrivate;
00157     ResourceFilePrivate *d;
00158 };
00159 
00160 }
00161 
00162 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys