kmail

popaccount.h

00001 // -*- c++ -*-
00002 #ifndef KMAcctExpPop_h
00003 #define KMAcctExpPop_h
00004 
00005 #include "networkaccount.h"
00006 
00007 #include <qvaluelist.h>
00008 #include <qstringlist.h>
00009 #include <qvaluevector.h>
00010 #include <qtimer.h>
00011 #include <qdict.h>
00012 
00013 class KMPopHeaders;
00014 class KMMessage;
00015 class QDataStream;
00016 namespace KIO {
00017   class MetaData;
00018   class Slave;
00019   class SimpleJob;
00020   class Job;
00021 }
00022 
00024 namespace KMail {
00028 class PopAccount: public NetworkAccount {
00029   Q_OBJECT
00030 
00031 public:
00032   virtual ~PopAccount();
00033   virtual void init(void);
00034 
00035   virtual KIO::MetaData slaveConfig() const;
00036 
00038   virtual void pseudoAssign( const KMAccount * a );
00039 
00040   virtual QString protocol() const;
00041   virtual unsigned short int defaultPort() const;
00042 
00046   bool usePipelining(void) const { return mUsePipelining; }
00047   virtual void setUsePipelining(bool);
00048  
00053   bool leaveOnServer(void) const { return mLeaveOnServer; }
00054   virtual void setLeaveOnServer(bool);
00055 
00059   int leaveOnServerDays(void) const { return mLeaveOnServerDays; }
00060   virtual void setLeaveOnServerDays(int);
00061 
00065   int leaveOnServerCount(void) const { return mLeaveOnServerCount; }
00066   virtual void setLeaveOnServerCount(int);
00067 
00071   int leaveOnServerSize(void) const { return mLeaveOnServerSize; }
00072   virtual void setLeaveOnServerSize(int);
00073 
00078   bool filterOnServer(void) const { return mFilterOnServer; }
00079   virtual void setFilterOnServer(bool);
00080 
00085   unsigned int filterOnServerCheckSize(void) const { return mFilterOnServerCheckSize; }
00086   virtual void setFilterOnServerCheckSize(unsigned int);
00087 
00091   virtual QString type(void) const;
00092   virtual void readConfig(KConfig&);
00093   virtual void writeConfig(KConfig&);
00094   virtual void processNewMail(bool _interactive);
00095 
00096   virtual void killAllJobs( bool disconnectSlave=false ); // NOOP currently
00097 
00098 protected:
00099   enum Stage { Idle, List, Uidl, Head, Retr, Dele, Quit };
00100   friend class ::AccountManager;
00101   PopAccount(AccountManager* owner, const QString& accountName, uint id);
00102 
00106   void startJob();
00107 
00111   void connectJob();
00112 
00116   void processRemainingQueuedMessages();
00117 
00121   void saveUidList();
00122 
00123   bool    mUsePipelining;
00124   bool    mLeaveOnServer;
00125   int     mLeaveOnServerDays;
00126   int     mLeaveOnServerCount;
00127   int     mLeaveOnServerSize;
00128   bool    gotMsgs;
00129   bool    mFilterOnServer;
00130   unsigned int mFilterOnServerCheckSize;
00131 
00132   KIO::SimpleJob *job;
00133   //Map of ID's vs. sizes of messages which should be downloaded
00134   QMap<QString, int> mMsgsPendingDownload;
00135 
00136   QPtrList<KMPopHeaders> headersOnServer;
00137   QPtrListIterator<KMPopHeaders> headerIt;
00138   bool headers;
00139 
00140   QMap<QString, bool> mHeaderDeleteUids;
00141   QMap<QString, bool> mHeaderDownUids;
00142   QMap<QString, bool> mHeaderLaterUids;
00143 
00144   QStringList idsOfMsgs; //used for ids and for count
00145   QValueList<int> lensOfMsgs;
00146   QMap<QString, QString> mUidForIdMap; // maps message ID (i.e. index on the server) to UID
00147   QDict<int> mUidsOfSeenMsgsDict; // set of UIDs of previously seen messages (for fast lookup)
00148   QDict<int> mUidsOfNextSeenMsgsDict; // set of UIDs of seen messages (for the next check)
00149   QValueVector<int> mTimeOfSeenMsgsVector; // list of times of previously seen messages
00150   QMap<QString, int> mTimeOfNextSeenMsgsMap; // map of uid to times of seen messages
00151   QDict<int> mSizeOfNextSeenMsgsDict;
00152   QStringList idsOfMsgsToDelete;
00153   int indexOfCurrentMsg;
00154 
00155   QValueList<KMMessage*> msgsAwaitingProcessing;
00156   QStringList msgIdsAwaitingProcessing;
00157   QStringList msgUidsAwaitingProcessing;
00158 
00159   QByteArray curMsgData;
00160   QDataStream *curMsgStrm;
00161 
00162   int curMsgLen;
00163   int stage;
00164   QTimer processMsgsTimer;
00165   int processingDelay;
00166   int numMsgs, numBytes, numBytesToRead, numBytesRead, numMsgBytesRead;
00167   bool interactive;
00168   bool mProcessing;
00169   bool mUidlFinished;
00170   int dataCounter;
00171 
00172 protected slots:
00183   void slotProcessPendingMsgs();
00184 
00189   void slotGetNextMsg();
00190 
00195   void slotMsgRetrieved(KIO::Job*, const QString &);
00196 
00200   void slotData( KIO::Job*, const QByteArray &);
00201 
00207   void slotResult( KIO::Job* );
00208 
00212   void slotCancel();
00213 
00217   void slotAbortRequested();
00218 
00223   void slotJobFinished();
00224 
00228   void slotSlaveError(KIO::Slave *, int, const QString &);
00229 
00234   void slotGetNextHdr();
00235 };
00236 
00237 } // namespace KMail
00238 
00239 
00240 
00241 #endif /*KMAcctExpPop_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys