00001
00002
00003
00004
00005
#ifndef kmaccount_h
00006
#define kmaccount_h
00007
00008
#include <kprocess.h>
00009
#include <kaccount.h>
00010
00011
#include <qtimer.h>
00012
#include <qsignal.h>
00013
#include <qstring.h>
00014
#include <qptrlist.h>
00015
#include <qvaluelist.h>
00016
#include <qguardedptr.h>
00017
00018
class KMAcctMgr;
00019
class KMFolder;
00020
class KMAcctFolder;
00021
class KConfig;
00022
class KMMessage;
00023
class KMFolderJob;
00024
namespace KMail {
class FolderJob; }
00025
using KMail::FolderJob;
00026
00027
class KMPrecommand :
public QObject
00028 {
00029 Q_OBJECT
00030
00031
public:
00032 KMPrecommand(
const QString &precommand, QObject *parent = 0);
00033
virtual ~KMPrecommand();
00034
bool start();
00035
00036
protected slots:
00037
void precommandExited(KProcess *);
00038
00039 signals:
00040
void finished(
bool);
00041
00042
protected:
00043 KProcess mPrecommandProcess;
00044 QString mPrecommand;
00045 };
00046
00047
00048
class KMAccount:
public QObject,
public KAccount
00049 {
00050 Q_OBJECT
00051
friend class KMAcctMgr;
00052
friend class FolderJob;
00053
friend class KMFolderCachedImap;
00054
00055
public:
00056
virtual ~KMAccount();
00057
00059
static const int DefaultCheckInterval = 5;
00060
00064
virtual QString type()
const {
return QString::null; }
00065
00069 QString name(
void)
const {
return mName; }
00070
virtual void setName(
const QString&);
00071
00075
virtual void clearPasswd();
00076
00080
virtual void init();
00081
00085
virtual void pseudoAssign(
const KMAccount * a );
00086
00090
KMFolder* folder(
void)
const {
return ((
KMFolder*)((
KMAcctFolder*)mFolder)); }
00091
virtual void setFolder(
KMFolder*,
bool addAccount =
false);
00092
00096 QString trash()
const {
return mTrash; }
00097
virtual void setTrash(
const QString& aTrash) { mTrash = aTrash; }
00098
00104
virtual void processNewMail(
bool interactive) = 0;
00105
00111
virtual void readConfig(KConfig& config);
00112
00117
virtual void writeConfig(KConfig& config);
00118
00123
virtual void setCheckInterval(
int aInterval);
00124
int checkInterval(
void)
const {
return mInterval; }
00125
00129
inline int defaultCheckInterval(
void)
const {
return DefaultCheckInterval; }
00130
00134
void deleteFolderJobs();
00135
00139
virtual void ignoreJobsForMessage( KMMessage* );
00144
virtual void setCheckExclude(
bool aExclude);
00145
bool checkExclude(
void)
const {
return mExclude; }
00146
00150
virtual void setResource(
bool aResource);
00151
bool resource(
void)
const {
return mResource; }
00152
00156
const QString& precommand(
void)
const {
return mPrecommand; }
00157
virtual void setPrecommand(
const QString &cmd) { mPrecommand = cmd; }
00158
00165
bool runPrecommand(
const QString &precommand);
00166
00171
static QString encryptStr(
const QString& inStr);
00172
static QString decryptStr(
const QString& inStr) {
return encryptStr(inStr); }
00173
00174
static QString importPassword(
const QString &);
00175
00177
bool hasInbox()
const {
return mHasInbox; }
00178
virtual void setHasInbox(
bool has ) { mHasInbox = has; }
00179
00183
virtual void invalidateIMAPFolders();
00184
00185
00186
void addInterval(
const QPair<QDateTime,QDateTime>& );
00187 QValueList<QPair<QDateTime, QDateTime> > intervals() const;
00188
void clearIntervals();
00189
void clearOldIntervals();
00190
void setIntervals( const QValueList<QPair<QDateTime, QDateTime> >& );
00191
00195
bool checkingMail() {
return mCheckingMail; }
00196
void setCheckingMail(
bool checking ) { mCheckingMail = checking; }
00197
00201
void checkDone(
bool newmails,
int newmailCount );
00202
00203 signals:
00204
virtual void finishedCheck(
bool newMail);
00205
virtual void newMailsProcessed(
int numberOfNewMails);
00206
00207
protected slots:
00208
virtual void mailCheck();
00209
virtual void sendReceipts();
00210
virtual void precommandExited(
bool);
00211
00212
protected:
00213 KMAccount(KMAcctMgr* owner,
const QString& accountName);
00214
00220
virtual bool processNewMsg(KMMessage* msg);
00221
00228
virtual void sendReceipt(KMMessage* msg);
00229
00233
virtual void installTimer();
00234
virtual void deinstallTimer();
00235
00236
protected:
00237 QString mName;
00238 QString mPrecommand;
00239 QString mTrash;
00240 KMAcctMgr* mOwner;
00241 QGuardedPtr<KMAcctFolder> mFolder;
00242 QTimer *mTimer, mReceiptTimer;
00243
int mInterval;
00244
bool mResource;
00245
bool mExclude;
00246
bool mCheckingMail : 1;
00247
bool mPrecommandSuccess;
00248 QValueList<KMMessage*> mReceipts;
00249 QPtrList<FolderJob> mJobList;
00250
bool mHasInbox : 1;
00251
00252
00253 QValueList<QPair<QDateTime, QDateTime> > mIntervals;
00254
00255
private:
00259
virtual void setName(
const char *name ) { QObject::setName( name ); }
00260 };
00261
00262
class KMAcctList:
public QPtrList<KMAccount>
00263 {
00264
public:
00265
virtual ~KMAcctList() {}
00267
short _dummy;
00268 };
00269
00270
#endif