kcmshell renamed to kcmshell4 to fix co-installability between kdelibs3 and kdebase4...
[kdepim.git] / kmail / sievejob.h
blob07300fe1c13d3c5c95ba6540448fbb213c1d2e20
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 void kill( KJob::KillVerbosity verbosity = KJob::Quietly );
70 const QStringList & sieveCapabilities() const {
71 return mSieveCapabilities;
74 bool fileExists() const {
75 return mFileExists;
78 signals:
79 void gotScript( KMail::SieveJob * job, bool success,
80 const QString & script, bool active );
82 /**
83 * We got the list of available scripts
85 * @param scriptList is the list of script filenames
86 * @param activeScript lists the filename of the active script, or an
87 * empty string if no script is active.
89 void gotList( KMail::SieveJob *job, bool success,
90 const QStringList &scriptList, const QString &activeScript );
92 void result( KMail::SieveJob * job, bool success,
93 const QString & script, bool active );
95 void item( KMail::SieveJob * job, const QString & filename, bool active );
97 protected:
98 void schedule( Command command );
100 protected slots:
101 void slotData( KIO::Job *, const QByteArray & ); // for get
102 void slotDataReq( KIO::Job *, QByteArray & ); // for put
103 void slotEntries( KIO::Job *, const KIO::UDSEntryList & ); // for listDir
104 void slotResult( KJob * ); // for all commands
106 protected:
107 KUrl mUrl;
108 KIO::Job * mJob;
109 QTextDecoder * mDec;
110 QString mScript;
111 QString mActiveScriptName;
112 Existence mFileExists;
113 QStringList mSieveCapabilities;
114 QStack<Command> mCommands;
116 // List of Sieve scripts on the server, used by @ref list()
117 QStringList mAvailableScripts;
120 } // namespace KMail
122 #endif // __KMAIL_SIEVE_JOB_H__
124 // vim: set noet sts=2 ts=8 sw=2: