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 <kio/global.h>
00031 
00032 class KMAcctMgr;
00033 class KMFolder;
00034 class KConfig/*Base*/;
00035 class KMessage;
00036 class KMMessagePart;
00037 class DwBodyPart;
00038 class DwMessage;
00039 
00040 namespace KIO {
00041   class Job;
00042 }
00043 
00044 namespace KMail {
00045 
00046 class AttachmentStrategy;
00047 
00048   class ImapAccountBase : public KMail::NetworkAccount {
00049     Q_OBJECT
00050   protected:
00051     ImapAccountBase( KMAcctMgr * parent, const QString & name );
00052   public:
00053     virtual ~ImapAccountBase();
00054 
00056     virtual void init();
00057 
00059     virtual void pseudoAssign( const KMAccount * a );
00060 
00061 
00063     QString prefix() const { return mPrefix; }
00064     virtual void setPrefix( const QString & prefix );
00065 
00068     bool autoExpunge() const { return mAutoExpunge; }
00069     virtual void setAutoExpunge( bool expunge );
00070 
00072     bool hiddenFolders() const { return mHiddenFolders; }
00073     virtual void setHiddenFolders( bool show );
00074 
00076     bool onlySubscribedFolders() const { return mOnlySubscribedFolders; }
00077     virtual void setOnlySubscribedFolders( bool show );
00078 
00080     bool loadOnDemand() const { return mLoadOnDemand; }
00081     virtual void setLoadOnDemand( bool load );
00082 
00084     virtual KIO::MetaData slaveConfig() const;
00085 
00086     virtual void readConfig( /*const*/ KConfig/*Base*/ & config );
00087     virtual void writeConfig( KConfig/*Base*/ & config ) /*const*/;
00088 
00089     enum ConnectionState { Error = 0, Connected, Connecting };
00096     ConnectionState makeConnection();
00097 
00101     struct jobData
00102     {
00103       // Needed by QMap, don't use
00104       jobData() : url(QString::null), parent(0), total(1), done(0), offset(0), inboxOnly(false), quiet(false) {}
00105       // Real constructor
00106       jobData( const QString& _url, KMFolder *_parent = 0,
00107           int _total = 1, int _done = 0, bool _quiet = false, bool _inboxOnly = false )
00108         : url(_url), parent(_parent), total(_total), done(_done), offset(0),
00109       inboxOnly(_inboxOnly), quiet(_quiet)
00110       {}
00111       // Return "url" in a form that can be displayed in HTML (w/o password)
00112       QString htmlURL() const;
00113 
00114       QString path;
00115       QString url;
00116       QByteArray data;
00117       QCString cdata;
00118       QStringList items;
00119       KMFolder *parent;
00120       QPtrList<KMMessage> msgList;
00121       int total, done, offset;
00122       bool inboxOnly, quiet, onlySubscribed;
00123     };
00124 
00125     typedef QMap<KIO::Job *, jobData>::Iterator JobIterator;
00129     void insertJob( KIO::Job* job, const jobData& data ) {
00130       mapJobData.insert( job, data );
00131       displayProgress();
00132     }
00136     JobIterator findJob( KIO::Job* job ) { return mapJobData.find( job ); }
00137     JobIterator jobsEnd() { return mapJobData.end(); }
00142     void removeJob( JobIterator& it ) {
00143       mapJobData.remove( it );
00144       displayProgress();
00145     }
00146     // for KMImapJob::ignoreJobsForMessage...
00147     void removeJob( KIO::Job* job ) {
00148       mapJobData.remove( job );
00149       displayProgress();
00150     }
00151 
00158     void listDirectory(QString path, bool onlySubscribed,
00159         bool secondStep = FALSE, KMFolder* parent = NULL, bool reset = false);
00160 
00164     virtual void listDirectory() = 0;
00165 
00170     void changeSubscription(bool subscribe, QString imapPath);
00171 
00175     void slaveDied() { mSlave = 0; killAllJobs(); }
00176 
00180     void killAllJobs( bool disconnectSlave=false ) = 0;
00181 
00185     void processNewMailSingleFolder(KMFolder* folder);
00186 
00190     bool createInbox() { return mCreateInbox; }
00191     void setCreateInbox( bool create ) { mCreateInbox = create; }
00192 
00196     void handleBodyStructure( QDataStream & stream, KMMessage * msg,
00197                               const AttachmentStrategy *as );
00198 
00199   public slots:
00204     void slotListEntries(KIO::Job * job, const KIO::UDSEntryList & uds);
00205 
00210     void slotListResult(KIO::Job * job);
00211 
00216     void slotSubscriptionResult(KIO::Job * job);
00217 
00221     virtual void displayProgress();
00222 
00226     void slotSlaveError(KIO::Slave *aSlave, int, const QString &errorMsg);
00227 
00228   protected slots:
00233     virtual void postProcessNewMail( KMFolder * );
00234     void slotCheckQueuedFolders();
00235 
00236     void slotSchedulerSlaveConnected(KIO::Slave *aSlave);
00237     void slotSchedulerSlaveError(KIO::Slave *aSlave, int, const QString &errorMsg);
00238 
00239   protected:
00240     virtual QString protocol() const;
00241     virtual unsigned short int defaultPort() const;
00242     // ### Hacks
00243     virtual void setPrefixHook() = 0;
00244 
00248     void constructParts( QDataStream & stream, int count, KMMessagePart* parentKMPart,
00249        DwBodyPart * parent, const DwMessage * dwmsg );
00250 
00251   protected:
00252     QPtrList<QGuardedPtr<KMFolder> > mOpenFolders;
00253     QStringList mSubfolderNames, mSubfolderPaths,
00254         mSubfolderMimeTypes;
00255     QMap<KIO::Job *, jobData> mapJobData;
00256     QTimer mIdleTimer;
00257     QString mPrefix;
00258     int mTotal, mCountUnread, mCountLastUnread, mCountRemainChecks;
00259     bool mAutoExpunge : 1;
00260     bool mHiddenFolders : 1;
00261     bool mOnlySubscribedFolders : 1;
00262     bool mLoadOnDemand : 1;
00263     bool mProgressEnabled : 1;
00264 
00265     bool mIdle : 1;
00266     bool mErrorDialogIsActive : 1;
00267     bool mPasswordDialogIsActive : 1;
00268     // folders that should be checked for new mails
00269     QValueList<QGuardedPtr<KMFolder> > mMailCheckFolders;
00270         // folders that should be checked after the current check is done
00271     QValueList<QGuardedPtr<KMFolder> > mFoldersQueuedForChecking;
00272     bool mCreateInbox;
00273     // holds messageparts from the bodystructure
00274     QPtrList<KMMessagePart> mBodyPartList;
00275     // the current message for the bodystructure
00276     KMMessage* mCurrentMsg;
00277 
00278   signals:
00284     void connectionResult( int errorCode );
00285 
00289     void receivedFolders(QStringList, QStringList,
00290         QStringList, const ImapAccountBase::jobData &);
00291 
00295     void subscriptionChanged(QString imapPath, bool subscribed);
00296 
00297   };
00298 
00299 
00300 } // namespace KMail
00301 
00302 #endif // __KMAIL_IMAPACCOUNTBASE_H__
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:37:19 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003