krop's commit fixes my problem in a better way, reverting
[kdepim.git] / kmail / sievejob.h
blob99638273ef38594500c96ac58966976ebccd4365
1 /* -*- c++ -*-
2 sievejob.h
4 KMail, the KDE mail client.
5 Copyright (c) 2002 Marc Mutz <mutz@kde.org>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License,
9 version 2.0, as published by the Free Software Foundation.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 #ifndef __KMAIL_SIEVE_JOB_H__
16 #define __KMAIL_SIEVE_JOB_H__
18 #include <QObject>
19 #include <QStack>
20 #include <QString>
21 #include <QStringList>
23 #include <kurl.h>
24 #include <kio/global.h>
25 #include <kio/udsentry.h>
27 class QTextDecoder;
28 namespace KIO {
29 class Job;
32 class KJob;
33 namespace KMail {
35 class SieveJob : public QObject {
36 Q_OBJECT
37 protected:
38 enum Command { Get, Put, Activate, Deactivate, SearchActive, List, Delete };
39 SieveJob( const KUrl & url, const QString & script,
40 const QStack<Command> & commands,
41 QObject * parent=0, const char * name=0 );
42 virtual ~SieveJob();
44 public:
45 enum Existence { DontKnow, Yes, No };
47 /**
48 * Store a Sieve script. If @param makeActive is set, also mark the
49 * script active
51 static SieveJob * put( const KUrl & dest, const QString & script,
52 bool makeActive, bool wasActive );
54 /**
55 * Get a specific Sieve script
57 static SieveJob * get( const KUrl & src );
59 /**
60 * List all available scripts
62 static SieveJob * list( const KUrl & url );
64 static SieveJob * del( const KUrl & url );
66 static SieveJob * activate( const KUrl & url );
68 static SieveJob * desactivate( const KUrl & url );
70 void kill( KJob::KillVerbosity verbosity = KJob::Quietly );
72 void setInteractive( bool interactive );
74 const QStringList & sieveCapabilities() const {
75 return mSieveCapabilities;
78 bool fileExists() const {
79 return mFileExists;
82 signals:
83 void gotScript( KMail::SieveJob * job, bool success,
84 const QString & script, bool active );
86 /**
87 * We got the list of available scripts
89 * @param scriptList is the list of script filenames
90 * @param activeScript lists the filename of the active script, or an
91 * empty string if no script is active.
93 void gotList( KMail::SieveJob *job, bool success,
94 const QStringList &scriptList, const QString &activeScript );
96 void result( KMail::SieveJob * job, bool success,
97 const QString & script, bool active );
99 void item( KMail::SieveJob * job, const QString & filename, bool active );
101 protected:
102 void schedule( Command command );
104 protected slots:
105 void slotData( KIO::Job *, const QByteArray & ); // for get
106 void slotDataReq( KIO::Job *, QByteArray & ); // for put
107 void slotEntries( KIO::Job *, const KIO::UDSEntryList & ); // for listDir
108 void slotResult( KJob * ); // for all commands
110 protected:
111 KUrl mUrl;
112 KIO::Job * mJob;
113 QTextDecoder * mDec;
114 QString mScript;
115 QString mActiveScriptName;
116 Existence mFileExists;
117 QStringList mSieveCapabilities;
118 QStack<Command> mCommands;
120 // List of Sieve scripts on the server, used by @ref list()
121 QStringList mAvailableScripts;
124 } // namespace KMail
126 #endif // __KMAIL_SIEVE_JOB_H__
128 // vim: set noet sts=2 ts=8 sw=2: