kmail

sievejob.h

00001 /*  -*- c++ -*-
00002     sievejob.h
00003 
00004     KMail, the KDE mail client.
00005     Copyright (c) 2002 Marc Mutz <mutz@kde.org>
00006 
00007     This program is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU General Public License,
00009     version 2.0, as published by the Free Software Foundation.
00010     You should have received a copy of the GNU General Public License
00011     along with this program; if not, write to the Free Software Foundation,
00012     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
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 <tdeio/global.h>
00026 
00027 class TQTextDecoder;
00028 namespace TDEIO {
00029   class Job;
00030 }
00031 
00032 namespace KMail {
00033 
00034   class SieveJob : public TQObject {
00035     Q_OBJECT
00036   
00037   protected:
00038     enum Command { Get, Put, Activate, Deactivate, SearchActive, List, Delete };
00039     SieveJob( const KURL & url, const TQString & script,
00040           const TQValueStack<Command> & commands,
00041           TQObject * parent=0, const char * name=0 );
00042     SieveJob( const KURL & url, const TQString & script,
00043           const TQValueStack<Command> & commands,
00044           bool showProgressInfo,
00045           TQObject * parent=0, const char * name=0 );
00046     virtual ~SieveJob();
00047 
00048   public:
00049     enum Existence { DontKnow, Yes, No };
00050 
00055     static SieveJob * put( const KURL & dest, const TQString & script,
00056                bool makeActive, bool wasActive );
00057 
00061     static SieveJob * get( const KURL & src, bool showProgressInfo=true );
00062 
00066     static SieveJob * list( const KURL & url );
00067 
00068     static SieveJob * del( const KURL & url );
00069 
00070     static SieveJob * activate( const KURL & url );
00071 
00072     static SieveJob * desactivate( const KURL & url );
00073 
00074     void kill( bool quiet=true );
00075 
00076     const TQStringList & sieveCapabilities() const {
00077       return mSieveCapabilities;
00078     }
00079 
00080     bool fileExists() const {
00081       return mFileExists;
00082     }
00083 
00084   signals:
00085     void gotScript( KMail::SieveJob * job, bool success,
00086             const TQString & script, bool active );
00087 
00095     void gotList( KMail::SieveJob *job, bool success,
00096                   const TQStringList &scriptList, const TQString &activeScript );
00097 
00098     void result(  KMail::SieveJob * job, bool success,
00099                   const TQString & script, bool active );
00100 
00101     void item( KMail::SieveJob * job, const TQString & filename, bool active );
00102 
00103   protected:
00104     void schedule( Command command, bool showProgressInfo );
00105 
00106   protected slots:
00107     void slotData( TDEIO::Job *, const TQByteArray & ); // for get
00108     void slotDataReq( TDEIO::Job *, TQByteArray & ); // for put
00109     void slotEntries( TDEIO::Job *, const TDEIO::UDSEntryList & ); // for listDir
00110     void slotResult( TDEIO::Job * ); // for all commands
00111 
00112   protected:
00113     KURL mUrl;
00114     TDEIO::Job * mJob;
00115     TQTextDecoder * mDec;
00116     TQString mScript;
00117     TQString mActiveScriptName;
00118     Existence mFileExists;
00119     TQStringList mSieveCapabilities;
00120     TQValueStack<Command> mCommands;
00121     bool mShowProgressInfo;
00122 
00123     // List of Sieve scripts on the server, used by @ref list()
00124     TQStringList mAvailableScripts;
00125   };
00126 
00127 } // namespace KMail
00128 
00129 #endif // __KMAIL_SIEVE_JOB_H__
00130 
00131 // vim: set noet sts=2 ts=8 sw=2:
00132