kmail Library API Documentation

imapaccountbase.h

00001 
00024 #ifndef __KMAIL_IMAPACCOUNTBASE_H__
00025 #define __KMAIL_IMAPACCOUNTBASE_H__
00026 
00027 #include <set>
00028 
00029 #include "networkaccount.h"
00030 
00031 #include <qtimer.h>
00032 #include <qguardedptr.h>
00033 #include <kio/global.h>
00034 
00035 class KMAcctMgr;
00036 class KMFolder;
00037 class KConfig/*Base*/;
00038 class KMessage;
00039 class KMMessagePart;
00040 class DwBodyPart;
00041 class DwMessage;
00042 class FolderStorage;
00043 template <typename T> class QValueVector;
00044 
00045 namespace KIO {
00046   class Job;
00047 }
00048 
00049 namespace KPIM {
00050   class ProgressItem;
00051 }
00052 
00053 namespace KMail {
00054 
00055   using KPIM::ProgressItem;
00056   struct ACLListEntry;
00057   struct QuotaInfo;
00058   typedef QValueVector<KMail::ACLListEntry> ACLList;
00059 
00060   class AttachmentStrategy;
00061 
00062   class ImapAccountBase : public KMail::NetworkAccount {
00063     Q_OBJECT
00064   protected:
00065     ImapAccountBase( KMAcctMgr * parent, const QString & name, uint id );
00066   public:
00067     virtual ~ImapAccountBase();
00068 
00070     virtual void init();
00071 
00073     virtual void pseudoAssign( const KMAccount * a );
00074 
00076     QString prefix() const { return mPrefix; }
00077     virtual void setPrefix( const QString & prefix );
00078 
00081     bool autoExpunge() const { return mAutoExpunge; }
00082     virtual void setAutoExpunge( bool expunge );
00083 
00085     bool hiddenFolders() const { return mHiddenFolders; }
00086     virtual void setHiddenFolders( bool show );
00087 
00089     bool onlySubscribedFolders() const { return mOnlySubscribedFolders; }
00090     virtual void setOnlySubscribedFolders( bool show );
00091 
00093     bool onlyLocallySubscribedFolders() const { return mOnlyLocallySubscribedFolders; }
00094     virtual void setOnlyLocallySubscribedFolders( bool show );
00095 
00096 
00098     bool loadOnDemand() const { return mLoadOnDemand; }
00099     virtual void setLoadOnDemand( bool load );
00100 
00102     bool listOnlyOpenFolders() const { return mListOnlyOpenFolders; }
00103     virtual void setListOnlyOpenFolders( bool only );
00104 
00106     virtual KIO::MetaData slaveConfig() const;
00107 
00108     virtual void readConfig( KConfig& config );
00109     virtual void writeConfig( KConfig& config );
00110 
00111     enum ConnectionState { Error = 0, Connected, Connecting };
00112     enum ListType { List, ListSubscribed, ListSubscribedNoCheck };
00119     ConnectionState makeConnection();
00120 
00124     struct jobData
00125     {
00126       // Needed by QMap, don't use
00127       jobData() : url(QString::null), parent(0), total(1), done(0), offset(0), progressItem(0),
00128                   inboxOnly(false), quiet(false), cancellable(false), createInbox(false) {}
00129       // Real constructor
00130       jobData( const QString& _url, KMFolder *_parent = 0,
00131           int _total = 1, int _done = 0, bool _quiet = false,
00132           bool _inboxOnly = false, bool _cancelable = false, bool _createInbox = false )
00133         : url(_url), parent(_parent), total(_total), done(_done), offset(0),
00134           progressItem(0), inboxOnly(_inboxOnly), quiet(_quiet), cancellable(_cancelable),
00135           createInbox(_createInbox) {}
00136 
00137       // Return "url" in a form that can be displayed in HTML (w/o password)
00138       QString htmlURL() const;
00139 
00140       QString path;
00141       QString url;
00142       QByteArray data;
00143       QCString cdata;
00144       QStringList items;
00145       KMFolder *parent;
00146       QPtrList<KMMessage> msgList;
00147       int total, done, offset;
00148       ProgressItem *progressItem;
00149       bool inboxOnly, onlySubscribed, quiet,
00150            cancellable, createInbox;
00151     };
00152 
00153     typedef QMap<KIO::Job *, jobData>::Iterator JobIterator;
00157     void insertJob( KIO::Job* job, const jobData& data ) {
00158       mapJobData.insert( job, data );
00159     }
00163     JobIterator findJob( KIO::Job* job ) { return mapJobData.find( job ); }
00164     JobIterator jobsEnd() { return mapJobData.end(); }
00169     void removeJob( JobIterator& it );
00170 
00171     void removeJob( KIO::Job* job );
00172 
00178     void changeSubscription(bool subscribe, const QString& imapPath);
00179 
00184     bool locallySubscribedTo( const QString& imapPath );
00185 
00190     void changeLocalSubscription( const QString& imapPath, bool subscribe );
00191 
00192 
00198     void getUserRights( KMFolder* folder, const QString& imapPath );
00199 
00205     void getACL( KMFolder* folder, const QString& imapPath );
00206 
00212     void getStorageQuotaInfo( KMFolder* folder, const QString& imapPath );
00213 
00218     void setImapStatus( KMFolder* folder, const QString& path, const QCString& flags );
00219 
00223     void slaveDied() { mSlave = 0; killAllJobs(); }
00224 
00228     void killAllJobs( bool disconnectSlave=false ) = 0;
00229 
00233     virtual void cancelMailCheck();
00234 
00238     void processNewMailSingleFolder(KMFolder* folder);
00239 
00243     void postProcessNewMail();
00244 
00249     bool checkingMail( KMFolder *folder );
00250 
00251     bool checkingMail() { return NetworkAccount::checkingMail(); }
00252 
00256     void handleBodyStructure( QDataStream & stream, KMMessage * msg,
00257                               const AttachmentStrategy *as );
00258 
00262     virtual void setFolder(KMFolder*, bool addAccount = false);
00263 
00268     bool hasACLSupport() const { return mACLSupport; }
00269 
00274     bool hasAnnotationSupport() const { return mAnnotationSupport; }
00275 
00279     void setHasNoAnnotationSupport() { mAnnotationSupport = false; }
00280 
00285     bool hasQuotaSupport() const { return mQuotaSupport; }
00286 
00290     void setHasNoQuotaSupport() { mQuotaSupport = false; }
00291 
00296     bool handleJobError( KIO::Job* job, const QString& context, bool abortSync = false );
00297 
00301     virtual FolderStorage* const rootFolder() const = 0;
00302 
00306     ProgressItem* listDirProgressItem();
00307 
00312     virtual unsigned int folderCount() const;
00313 
00314   private slots:
00319     void slotSubscriptionResult(KIO::Job * job);
00320 
00321   protected slots:
00322     virtual void slotCheckQueuedFolders();
00323 
00325     void slotSchedulerSlaveConnected(KIO::Slave *aSlave);
00327     void slotSchedulerSlaveError(KIO::Slave *aSlave, int, const QString &errorMsg);
00328 
00332     void slotSetStatusResult(KIO::Job * job);
00333 
00335     void slotGetUserRightsResult( KIO::Job* _job );
00336 
00338     void slotGetACLResult( KIO::Job* _job );
00339 
00341     void slotGetStorageQuotaInfoResult( KIO::Job* _job );
00342 
00346     void slotNoopTimeout();
00350     void slotIdleTimeout();
00351 
00355     void slotAbortRequested( ProgressItem* );
00356 
00360     void slotSimpleResult(KIO::Job * job);
00361 
00362   protected:
00363 
00380     virtual bool handleError( int error, const QString &errorMsg, KIO::Job* job, const QString& context, bool abortSync = false );
00381 
00383     bool handlePutError( KIO::Job* job, jobData& jd, KMFolder* folder );
00384 
00385     virtual QString protocol() const;
00386     virtual unsigned short int defaultPort() const;
00387     // ### Hacks
00388     virtual void setPrefixHook() = 0;
00389 
00393     void constructParts( QDataStream & stream, int count, KMMessagePart* parentKMPart,
00394        DwBodyPart * parent, const DwMessage * dwmsg );
00395 
00396     // used for writing the blacklist out to the config file
00397     QStringList locallyBlacklistedFolders() const;
00398     void localBlacklistFromStringList( const QStringList & );
00399 
00400   protected:
00401     QPtrList<QGuardedPtr<KMFolder> > mOpenFolders;
00402     QStringList mSubfolderNames, mSubfolderPaths,
00403         mSubfolderMimeTypes, mSubfolderAttributes;
00404     QMap<KIO::Job *, jobData> mapJobData;
00406     QTimer mIdleTimer;
00408     QTimer mNoopTimer;
00409     QString mPrefix;
00410     int mTotal, mCountUnread, mCountLastUnread;
00411     QMap<QString, int> mUnreadBeforeCheck;
00412     bool mAutoExpunge : 1;
00413     bool mHiddenFolders : 1;
00414     bool mOnlySubscribedFolders : 1;
00415     bool mOnlyLocallySubscribedFolders : 1;
00416     bool mLoadOnDemand : 1;
00417     bool mListOnlyOpenFolders : 1;
00418     bool mProgressEnabled : 1;
00419 
00420     bool mErrorDialogIsActive : 1;
00421     bool mPasswordDialogIsActive : 1;
00422     bool mACLSupport : 1;
00423     bool mAnnotationSupport : 1;
00424     bool mQuotaSupport : 1;
00425     bool mSlaveConnected : 1;
00426     bool mSlaveConnectionError : 1;
00427 
00428     // folders that should be checked for new mails
00429     QValueList<QGuardedPtr<KMFolder> > mMailCheckFolders;
00430     // folders that should be checked after the current check is done
00431     QValueList<QGuardedPtr<KMFolder> > mFoldersQueuedForChecking;
00432     // holds messageparts from the bodystructure
00433     QPtrList<KMMessagePart> mBodyPartList;
00434     // the current message for the bodystructure
00435     KMMessage* mCurrentMsg;
00436 
00437     QGuardedPtr<ProgressItem> mListDirProgressItem;
00438 
00439     std::set<QString> mLocalSubscriptionBlackList;
00440 
00441   signals:
00448     void connectionResult( int errorCode, const QString& errorMsg );
00449 
00454     void subscriptionChanged(const QString& imapPath, bool subscribed);
00455 
00461     void imapStatusChanged( KMFolder*, const QString& imapPath, bool cont );
00462 
00468     void receivedUserRights( KMFolder* folder );
00469 
00477     void receivedACL( KMFolder* folder, KIO::Job* job, const KMail::ACLList& entries );
00478 
00487     void receivedStorageQuotaInfo( KMFolder* folder, KIO::Job* job, const KMail::QuotaInfo& entries );
00488 
00489   };
00490 
00491 
00492 } // namespace KMail
00493 
00494 #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 Thu Aug 23 18:21:11 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003