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 <qobject.h>
00019 #include <qvaluestack.h>
00020 #include <qstring.h>
00021 #include <qstringlist.h>
00022 #include <qcstring.h>
00023 
00024 #include <kurl.h>
00025 #include <kio/global.h>
00026 
00027 class QTextDecoder;
00028 namespace KIO {
00029   class Job;
00030 }
00031 
00032 namespace KMail {
00033 
00034   class SieveJob : public QObject {
00035     Q_OBJECT
00036   protected:
00037     enum Command { Get, Put, Activate, Deactivate, SearchActive, List, Delete };
00038     SieveJob( const KURL & url, const QString & script,
00039           const QValueStack<Command> & commands,
00040           QObject * parent=0, const char * name=0 );
00041     virtual ~SieveJob();
00042 
00043   public:
00044     enum Existence { DontKnow, Yes, No };
00045 
00050     static SieveJob * put( const KURL & dest, const QString & script,
00051                bool makeActive, bool wasActive );
00052 
00056     static SieveJob * get( const KURL & src );
00057 
00061     static SieveJob * list( const KURL & url );
00062 
00063     static SieveJob * del( const KURL & url );
00064 
00065     static SieveJob * activate( const KURL & url );
00066 
00067     void kill( bool quiet=true );
00068 
00069     const QStringList & sieveCapabilities() const {
00070       return mSieveCapabilities;
00071     }
00072 
00073     bool fileExists() const {
00074       return mFileExists;
00075     }
00076 
00077   signals:
00078     void gotScript( KMail::SieveJob * job, bool success,
00079             const QString & script, bool active );
00080 
00088     void gotList( KMail::SieveJob *job, bool success,
00089                   const QStringList &scriptList, const QString &activeScript );
00090     
00091     void result(  KMail::SieveJob * job, bool success,
00092                   const QString & script, bool active );
00093 
00094     void item( KMail::SieveJob * job, const QString & filename, bool active );
00095 
00096   protected:
00097     void schedule( Command command );
00098 
00099   protected slots:
00100     void slotData( KIO::Job *, const QByteArray & ); // for get
00101     void slotDataReq( KIO::Job *, QByteArray & ); // for put
00102     void slotEntries( KIO::Job *, const KIO::UDSEntryList & ); // for listDir
00103     void slotResult( KIO::Job * ); // for all commands
00104 
00105   protected:
00106     KURL mUrl;
00107     KIO::Job * mJob;
00108     QTextDecoder * mDec;
00109     QString mScript;
00110     QString mActiveScriptName;
00111     Existence mFileExists;
00112     QStringList mSieveCapabilities;
00113     QValueStack<Command> mCommands;
00114 
00115     // List of Sieve scripts on the server, used by @ref list()
00116     QStringList mAvailableScripts;
00117   };
00118 
00119 } // namespace KMail
00120 
00121 #endif // __KMAIL_SIEVE_JOB_H__
00122 
00123 // vim: set noet sts=2 ts=8 sw=2:
00124 
KDE Home | KDE Accessibility Home | Description of Access Keys