00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __KMAIL_SIEVE_JOB_H__
00016 #define __KMAIL_SIEVE_JOB_H__
00017
00018 #include <tqobject.h>
00019 #include <tqvaluestack.h>
00020 #include <tqstring.h>
00021 #include <tqstringlist.h>
00022 #include <tqcstring.h>
00023
00024 #include <kurl.h>
00025 #include <kio/global.h>
00026
00027 class TQTextDecoder;
00028 namespace KIO {
00029 class Job;
00030 }
00031
00032 namespace KMail {
00033
00034 class SieveJob : public TQObject {
00035 Q_OBJECT
00036 protected:
00037 enum Command { Get, Put, Activate, Deactivate, SearchActive, List, Delete };
00038 SieveJob( const KURL & url, const TQString & script,
00039 const TQValueStack<Command> & commands,
00040 TQObject * parent=0, const char * name=0 );
00041 SieveJob( const KURL & url, const TQString & script,
00042 const TQValueStack<Command> & commands,
00043 bool showProgressInfo,
00044 TQObject * parent=0, const char * name=0 );
00045 virtual ~SieveJob();
00046
00047 public:
00048 enum Existence { DontKnow, Yes, No };
00049
00054 static SieveJob * put( const KURL & dest, const TQString & script,
00055 bool makeActive, bool wasActive );
00056
00060 static SieveJob * get( const KURL & src, bool showProgressInfo=true );
00061
00065 static SieveJob * list( const KURL & url );
00066
00067 static SieveJob * del( const KURL & url );
00068
00069 static SieveJob * activate( const KURL & url );
00070
00071 static SieveJob * desactivate( const KURL & url );
00072
00073 void kill( bool quiet=true );
00074
00075 const TQStringList & sieveCapabilities() const {
00076 return mSieveCapabilities;
00077 }
00078
00079 bool fileExists() const {
00080 return mFileExists;
00081 }
00082
00083 signals:
00084 void gotScript( KMail::SieveJob * job, bool success,
00085 const TQString & script, bool active );
00086
00094 void gotList( KMail::SieveJob *job, bool success,
00095 const TQStringList &scriptList, const TQString &activeScript );
00096
00097 void result( KMail::SieveJob * job, bool success,
00098 const TQString & script, bool active );
00099
00100 void item( KMail::SieveJob * job, const TQString & filename, bool active );
00101
00102 protected:
00103 void schedule( Command command, bool showProgressInfo );
00104
00105 protected slots:
00106 void slotData( KIO::Job *, const TQByteArray & );
00107 void slotDataReq( KIO::Job *, TQByteArray & );
00108 void slotEntries( KIO::Job *, const KIO::UDSEntryList & );
00109 void slotResult( KIO::Job * );
00110
00111 protected:
00112 KURL mUrl;
00113 KIO::Job * mJob;
00114 TQTextDecoder * mDec;
00115 TQString mScript;
00116 TQString mActiveScriptName;
00117 Existence mFileExists;
00118 TQStringList mSieveCapabilities;
00119 TQValueStack<Command> mCommands;
00120 bool mShowProgressInfo;
00121
00122
00123 TQStringList mAvailableScripts;
00124 };
00125
00126 }
00127
00128 #endif // __KMAIL_SIEVE_JOB_H__
00129
00130
00131