kmail

sievejob.h

Go to the documentation of this file.
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     SieveJob( const KURL & url, const QString & script,
00042           const QValueStack<Command> & commands,
00043           bool showProgressInfo,
00044           QObject * 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 QString & 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     void kill( bool quiet=true );
00072 
00073     const QStringList & sieveCapabilities() const {
00074       return mSieveCapabilities;
00075     }
00076 
00077     bool fileExists() const {
00078       return mFileExists;
00079     }
00080 
00081   signals:
00082     void gotScript( KMail::SieveJob * job, bool success,
00083             const QString & script, bool active );
00084 
00092     void gotList( KMail::SieveJob *job, bool success,
00093                   const QStringList &scriptList, const QString &activeScript );
00094 
00095     void result(  KMail::SieveJob * job, bool success,
00096                   const QString & script, bool active );
00097 
00098     void item( KMail::SieveJob * job, const QString & filename, bool active );
00099 
00100   protected:
00101     void schedule( Command command, bool showProgressInfo );
00102 
00103   protected slots:
00104     void slotData( KIO::Job *, const QByteArray & ); // for get
00105     void slotDataReq( KIO::Job *, QByteArray & ); // for put
00106     void slotEntries( KIO::Job *, const KIO::UDSEntryList & ); // for listDir
00107     void slotResult( KIO::Job * ); // for all commands
00108 
00109   protected:
00110     KURL mUrl;
00111     KIO::Job * mJob;
00112     QTextDecoder * mDec;
00113     QString mScript;
00114     QString mActiveScriptName;
00115     Existence mFileExists;
00116     QStringList mSieveCapabilities;
00117     QValueStack<Command> mCommands;
00118     bool mShowProgressInfo;
00119 
00120     // List of Sieve scripts on the server, used by @ref list()
00121     QStringList mAvailableScripts;
00122   };
00123 
00124 } // namespace KMail
00125 
00126 #endif // __KMAIL_SIEVE_JOB_H__
00127 
00128 // vim: set noet sts=2 ts=8 sw=2:
00129