kmail Library API Documentation

imapaccountbase.h

00001 
00024 #ifndef __KMAIL_IMAPACCOUNTBASE_H__
00025 #define __KMAIL_IMAPACCOUNTBASE_H__
00026 
00027 #include "networkaccount.h"
00028 
00029 #include <qtimer.h>
00030 #include <qguardedptr.h>
00031 #include <kio/global.h>
00032 
00033 class KMAcctMgr;
00034 class KMFolder;
00035 class KConfig/*Base*/;
00036 class KMessage;
00037 class KMMessagePart;
00038 class DwBodyPart;
00039 class DwMessage;
00040 class FolderStorage;
00041 template <typename T> class QValueVector;
00042 
00043 namespace KIO {
00044   class Job;
00045 }
00046 
00047 namespace KPIM {
00048   class ProgressItem;
00049 }
00050 
00051 namespace KMail {
00052 
00053   using KPIM::ProgressItem;
00054   struct ACLListEntry;
00055   typedef QValueVector<KMail::ACLListEntry> ACLList;
00056 
00057   class AttachmentStrategy;
00058 
00059   class ImapAccountBase : public KMail::NetworkAccount {
00060     Q_OBJECT
00061   protected:
00062     ImapAccountBase( KMAcctMgr * parent, const QString & name, uint id );
00063   public:
00064     virtual ~ImapAccountBase();
00065 
00067     virtual void init();
00068 
00070     virtual void pseudoAssign( const KMAccount * a );
00071 
00073     QString prefix() const { return mPrefix; }
00074     virtual void setPrefix( const QString & prefix );
00075 
00078     bool autoExpunge() const { return mAutoExpunge; }
00079     virtual void setAutoExpunge( bool expunge );
00080 
00082     bool hiddenFolders() const { return mHiddenFolders; }
00083     virtual void setHiddenFolders( bool show );
00084 
00086     bool onlySubscribedFolders() const { return mOnlySubscribedFolders; }
00087     virtual void setOnlySubscribedFolders( bool show );
00088 
00090     bool loadOnDemand() const { return mLoadOnDemand; }
00091     virtual void setLoadOnDemand( bool load );
00092 
00094     bool listOnlyOpenFolders() const { return mListOnlyOpenFolders; }
00095     virtual void setListOnlyOpenFolders( bool only );
00096 
00098     virtual KIO::MetaData slaveConfig() const;
00099 
00100     virtual void readConfig( KConfig& config );
00101     virtual void writeConfig( KConfig& config );
00102 
00103     enum ConnectionState { Error = 0, Connected, Connecting };
00104     enum ListType { List, ListSubscribed, ListSubscribedNoCheck };
00111     ConnectionState makeConnection();
00112 
00116     struct jobData
00117     {
00118       // Needed by QMap, don't use
00119       jobData() : url(QString::null), parent(0), total(1), done(0), offset(0), progressItem(0),
00120                   inboxOnly(false), quiet(false), cancellable(false), createInbox(false) {}
00121       // Real constructor
00122       jobData( const QString& _url, KMFolder *_parent = 0,
00123           int _total = 1, int _done = 0, bool _quiet = false,
00124           bool _inboxOnly = false, bool _cancelable = false, bool _createInbox = false )
00125         : url(_url), parent(_parent), total(_total), done(_done), offset(0),
00126           progressItem(0), inboxOnly(_inboxOnly), quiet(_quiet), cancellable(_cancelable),
00127           createInbox(_createInbox) {}
00128 
00129       // Return "url" in a form that can be displayed in HTML (w/o password)
00130       QString htmlURL() const;
00131 
00132       QString path;
00133       QString url;
00134       QByteArray data;
00135       QCString cdata;
00136       QStringList items;
00137       KMFolder *parent;
00138       QPtrList<KMMessage> msgList;
00139       int total, done, offset;
00140       ProgressItem *progressItem;
00141       bool inboxOnly, onlySubscribed, quiet,
00142            cancellable, createInbox;
00143     };
00144 
00145     typedef QMap<KIO::Job *, jobData>::Iterator JobIterator;
00149     void insertJob( KIO::Job* job, const jobData& data ) {
00150       mapJobData.insert( job, data );
00151     }
00155     JobIterator findJob( KIO::Job* job ) { return mapJobData.find( job ); }
00156     JobIterator jobsEnd() { return mapJobData.end(); }
00161     void removeJob( JobIterator& it );
00162 
00163     // for KMImapJob::ignoreJobsForMessage...
00164     void removeJob( KIO::Job* job ) {
00165       mapJobData.remove( job );
00166     }
00167 
00173     void changeSubscription(bool subscribe, QString imapPath);
00174 
00180     void getUserRights( KMFolder* folder, const QString& imapPath );
00181 
00187     void getACL( KMFolder* folder, const QString& imapPath );
00188 
00193     void setImapStatus( KMFolder* folder, const QString& path, const QCString& flags );
00194 
00198     void slaveDied() { mSlave = 0; killAllJobs(); }
00199 
00203     void killAllJobs( bool disconnectSlave=false ) = 0;
00204 
00208     virtual void cancelMailCheck();
00209 
00213     void processNewMailSingleFolder(KMFolder* folder);
00214 
00218     void postProcessNewMail();
00219 
00224     bool checkingMail( KMFolder *folder );
00225 
00226     bool checkingMail() { return NetworkAccount::checkingMail(); }
00227 
00231     void handleBodyStructure( QDataStream & stream, KMMessage * msg,
00232                               const AttachmentStrategy *as );
00233 
00237     virtual void setFolder(KMFolder*, bool addAccount = false);
00238 
00243     bool hasACLSupport() const { return mACLSupport; }
00244 
00249     bool handleJobError( KIO::Job* job, const QString& context, bool abortSync = false );
00250 
00254     virtual FolderStorage* const rootFolder() const = 0;
00255 
00259     ProgressItem* listDirProgressItem();
00260 
00265     virtual unsigned int folderCount() const;
00266 
00267   private slots:
00272     void slotSubscriptionResult(KIO::Job * job);
00273 
00274   protected slots:
00275     virtual void slotCheckQueuedFolders();
00276 
00278     void slotSchedulerSlaveConnected(KIO::Slave *aSlave);
00280     void slotSchedulerSlaveError(KIO::Slave *aSlave, int, const QString &errorMsg);
00281 
00285     void slotSetStatusResult(KIO::Job * job);
00286 
00288     void slotGetUserRightsResult( KIO::Job* _job );
00289 
00291     void slotGetACLResult( KIO::Job* _job );
00292 
00296     void slotNoopTimeout();
00300     void slotIdleTimeout();
00301 
00305     void slotAbortRequested( ProgressItem* );
00306 
00310     void slotSimpleResult(KIO::Job * job);
00311 
00312   protected:
00313 
00330     virtual bool handleError( int error, const QString &errorMsg, KIO::Job* job, const QString& context, bool abortSync = false );
00331 
00333     bool handlePutError( KIO::Job* job, jobData& jd, KMFolder* folder );
00334 
00335     virtual QString protocol() const;
00336     virtual unsigned short int defaultPort() const;
00337     // ### Hacks
00338     virtual void setPrefixHook() = 0;
00339 
00343     void constructParts( QDataStream & stream, int count, KMMessagePart* parentKMPart,
00344        DwBodyPart * parent, const DwMessage * dwmsg );
00345 
00346   protected:
00347     QPtrList<QGuardedPtr<KMFolder> > mOpenFolders;
00348     QStringList mSubfolderNames, mSubfolderPaths,
00349         mSubfolderMimeTypes, mSubfolderAttributes;
00350     QMap<KIO::Job *, jobData> mapJobData;
00352     QTimer mIdleTimer;
00354     QTimer mNoopTimer;
00355     QString mPrefix;
00356     int mTotal, mCountUnread, mCountLastUnread;
00357     QMap<QString, int> mUnreadBeforeCheck;
00358     bool mAutoExpunge : 1;
00359     bool mHiddenFolders : 1;
00360     bool mOnlySubscribedFolders : 1;
00361     bool mLoadOnDemand : 1;
00362     bool mListOnlyOpenFolders : 1;
00363     bool mProgressEnabled : 1;
00364 
00365     bool mErrorDialogIsActive : 1;
00366     bool mPasswordDialogIsActive : 1;
00367     bool mACLSupport : 1;
00368     bool mSlaveConnected : 1;
00369     bool mSlaveConnectionError : 1;
00370 
00371     // folders that should be checked for new mails
00372     QValueList<QGuardedPtr<KMFolder> > mMailCheckFolders;
00373         // folders that should be checked after the current check is done
00374     QValueList<QGuardedPtr<KMFolder> > mFoldersQueuedForChecking;
00375     // holds messageparts from the bodystructure
00376     QPtrList<KMMessagePart> mBodyPartList;
00377     // the current message for the bodystructure
00378     KMMessage* mCurrentMsg;
00379 
00380     QGuardedPtr<ProgressItem> mListDirProgressItem;
00381 
00382   signals:
00389     void connectionResult( int errorCode, const QString& errorMsg );
00390 
00395     void subscriptionChanged(const QString& imapPath, bool subscribed);
00396 
00402     void imapStatusChanged( KMFolder*, const QString& imapPath, bool cont );
00403 
00409     void receivedUserRights( KMFolder* folder );
00410 
00418     void receivedACL( KMFolder* folder, KIO::Job* job, const KMail::ACLList& entries );
00419   };
00420 
00421 
00422 } // namespace KMail
00423 
00424 #endif // __KMAIL_IMAPACCOUNTBASE_H__
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 22:43:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003