5
#include "networkaccount.h"
11
class KMPopFilterCnfrmDlg;
25
/** The namespace where all classes of KMail can be found in. */
28
* KMail account for pop mail account
30
class PopAccount: public NetworkAccount {
34
virtual ~PopAccount();
35
virtual void init(void);
37
virtual KIO::MetaData slaveConfig() const;
40
* Reimplemented from KMAccount
42
virtual void cancelMailCheck();
44
/** A weak assignment operator */
45
virtual void pseudoAssign( const KMAccount * a );
47
virtual QString protocol() const;
48
virtual unsigned short int defaultPort() const;
51
* Sending of several commands at once
53
bool usePipelining(void) const { return mUsePipelining; }
54
virtual void setUsePipelining(bool);
57
* Shall messages be left on the server upon retreival (true)
60
bool leaveOnServer(void) const { return mLeaveOnServer; }
61
virtual void setLeaveOnServer(bool);
64
* If value is positive, leave mail on the server for so many days.
66
int leaveOnServerDays(void) const { return mLeaveOnServerDays; }
67
virtual void setLeaveOnServerDays(int);
70
* If value is positive, leave so many messages on the server.
72
int leaveOnServerCount(void) const { return mLeaveOnServerCount; }
73
virtual void setLeaveOnServerCount(int);
76
* If value is positive, leave so many MBs on the server.
78
int leaveOnServerSize(void) const { return mLeaveOnServerSize; }
79
virtual void setLeaveOnServerSize(int);
82
* Shall messages be filter on the server (true)
85
bool filterOnServer(void) const { return mFilterOnServer; }
86
virtual void setFilterOnServer(bool);
89
* Size of messages which should be check on the
90
* pop server before download
92
unsigned int filterOnServerCheckSize(void) const { return mFilterOnServerCheckSize; }
93
virtual void setFilterOnServerCheckSize(unsigned int);
98
virtual void readConfig(KConfigGroup&);
99
virtual void writeConfig(KConfigGroup&);
100
virtual void processNewMail(bool _interactive);
102
virtual void killAllJobs( bool disconnectSlave=false ); // NOOP currently
105
enum Stage { Idle, List, Uidl, Head, Retr, Dele, Quit };
106
friend class ::AccountManager;
107
PopAccount(AccountManager* owner, const QString& accountName, uint id);
110
* Start a KIO Job to get a list of messages on the pop server
115
* Connect up the standard signals/slots for the KIO Jobs
120
* Process any queued messages
122
void processRemainingQueuedMessages();
125
* Save the list of seen uids for this user/server
131
int mLeaveOnServerDays;
132
int mLeaveOnServerCount;
133
int mLeaveOnServerSize;
135
bool mFilterOnServer;
136
unsigned int mFilterOnServerCheckSize;
139
// Map of ID's vs. sizes of messages which should be downloaded; use QMap because the order needs to be
141
QMap<QByteArray, int> mMsgsPendingDownload;
143
KMPopFilterCnfrmDlg *mPopFilterConfirmationDialog;
144
QList<KMPopHeaders *> mHeadersOnServer;
148
QSet<QByteArray> mHeaderDeleteUids;
149
QSet<QByteArray> mHeaderDownUids;
150
QSet<QByteArray> mHeaderLaterUids;
152
QList<QByteArray> idsOfMsgs; //used for ids and for count
153
QHash<QByteArray, QByteArray> mUidForIdMap; // maps message ID (i.e. index on the server) to UID
154
QHash<QByteArray, int> mUidsOfSeenMsgsDict; // set of UIDs of previously seen messages (for fast lookup)
155
QHash<QByteArray, int> mUidsOfNextSeenMsgsDict; // set of UIDs of seen messages (for the next check)
156
QVector<int> mTimeOfSeenMsgsVector; // list of times of previously seen messages
157
QHash<QByteArray, int> mTimeOfNextSeenMsgsMap; // map of uid to times of seen messages
158
QHash<QByteArray, int> mSizeOfNextSeenMsgsDict;
159
QSet<QByteArray> idsOfMsgsToDelete;
161
// All IDs that we'll delete in any case, even if we have "leave on server"
162
// checked. This is only used when the server issues an invalid UIDL response
163
// and we can't map a UID to the ID. See bug 127696.
164
QSet<QByteArray> idsOfForcedDeletes;
166
int indexOfCurrentMsg;
168
QQueue<KMMessage*> msgsAwaitingProcessing;
169
QQueue<QByteArray> msgIdsAwaitingProcessing;
170
QQueue<QByteArray> msgUidsAwaitingProcessing;
172
QByteArray curMsgData;
173
QDataStream *curMsgStrm;
177
QTimer processMsgsTimer;
179
int numMsgs, numBytes, numBytesToRead, numBytesRead, numMsgBytesRead;
187
* Messages are downloaded in the background and then once every x seconds
188
* a batch of messages are processed. Messages are processed in batches to
189
* reduce flicker (multiple refreshes of the qlistview of messages headers
190
* in a single second causes flicker) when using a fast pop server such as
193
* Processing a message means applying KMAccount::processNewMsg to it and
194
* adding its UID to the list of seen UIDs
196
void slotProcessPendingMsgs();
199
* If there are more messages to be downloaded then start a new kio job
200
* to get the message whose id is at the head of the queue
202
void slotGetNextMsg();
205
* A messages has been retrieved successfully. The next data belongs to the
208
void slotMsgRetrieved(KJob*, const QString &, const QString &);
211
* New data has arrived append it to the end of the current message
213
void slotData( KIO::Job*, const QByteArray &);
216
* Finished downloading the current kio job, either due to an error
217
* or because the job has been canceled or because the complete message
218
* has been downloaded
220
void slotResult( KJob* );
223
* Cleans up after a user cancels the current job
228
* Kills the job if still stage == List
230
void slotAbortRequested();
233
* Called when a job is finished. Basically a finite state machine for
234
* cycling through the Idle, List, Uidl, Retr, Quit stages
236
void slotJobFinished();
239
* Slave error handling
241
void slotSlaveError(KIO::Slave *, int, const QString &);
244
* If there are more headers to be downloaded then start a new kio job
245
* to get the next header
247
void slotGetNextHdr();
252
#endif // POPACCOUNT_H