resourcenet.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KABC_RESOURCENET_H
00022 #define KABC_RESOURCENET_H
00023
00024 #include <kconfig.h>
00025
00026 #include <sys/types.h>
00027
00028 #include <kabc/resource.h>
00029
00030 class QFile;
00031 class QTimer;
00032 class KTempFile;
00033
00034 namespace KIO {
00035 class Job;
00036 }
00037
00038 namespace KABC {
00039
00040 class FormatPlugin;
00041
00045 class KABC_EXPORT ResourceNet : public Resource
00046 {
00047 Q_OBJECT
00048
00049 public:
00050 ResourceNet( const KConfig* );
00051 ResourceNet( const KURL &url, const QString &format );
00052 ~ResourceNet();
00053
00054 virtual void writeConfig( KConfig* );
00055
00056 virtual bool doOpen();
00057 virtual void doClose();
00058
00059 virtual Ticket *requestSaveTicket();
00060 virtual void releaseSaveTicket( Ticket* );
00061
00062 virtual bool load();
00063 virtual bool asyncLoad();
00064 virtual bool save( Ticket* ticket );
00065 virtual bool asyncSave( Ticket* ticket );
00066
00070 void setUrl( const KURL & );
00071
00075 KURL url() const;
00076
00080 void setFormat( const QString &name );
00081
00085 QString format() const;
00086
00087 protected:
00088 void init( const KURL &url, const QString &format );
00089
00090 private slots:
00091 void downloadFinished( KIO::Job* );
00092 void uploadFinished( KIO::Job* );
00093 void signalError();
00094
00095 private:
00096 bool clearAndLoad( QFile *file );
00097 void saveToFile( QFile *file );
00098 bool hasTempFile() const { return mTempFile != 0; }
00099 void abortAsyncLoading();
00100 void abortAsyncSaving();
00101 bool createLocalTempFile();
00102 void deleteLocalTempFile();
00103 void deleteStaleTempFile();
00104
00105 FormatPlugin *mFormat;
00106 QString mFormatName;
00107
00108 KURL mUrl;
00109 KTempFile *mTempFile;
00110
00111 class ResourceNetPrivate;
00112 ResourceNetPrivate *d;
00113 };
00114
00115 }
00116
00117 #endif
|