• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

imapaccountbase.h

Go to the documentation of this file.
00001 /* -*- c++ -*-
00002  * imapaccountbase.h
00003  *
00004  * Copyright (c) 2000-2002 Michael Haeckel <haeckel@kde.org>
00005  * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
00006  *
00007  * This file is based on work on pop3 and imap account implementations
00008  * by Don Sanders <sanders@kde.org> and Michael Haeckel <haeckel@kde.org>
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; version 2 of the License
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License along
00020  *  with this program; if not, write to the Free Software Foundation, Inc.,
00021  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00022  */
00023 
00024 #ifndef __KMAIL_IMAPACCOUNTBASE_H__
00025 #define __KMAIL_IMAPACCOUNTBASE_H__
00026 
00027 #include <set>
00028 
00029 #include "networkaccount.h"
00030 
00031 #include <kio/global.h>
00032 
00033 #include <QList>
00034 #include <QPointer>
00035 #include <QTimer>
00036 
00037 #include <QByteArray>
00038 
00039 class AccountManager;
00040 class KMFolder;
00041 class KConfigGroup;
00042 class KMMessagePart;
00043 class DwBodyPart;
00044 class DwMessage;
00045 class FolderStorage;
00046 template <typename T> class QVector;
00047 
00048 namespace KIO {
00049   class Job;
00050 }
00051 
00052 namespace KPIM {
00053   class ProgressItem;
00054 }
00055 
00056 namespace KMail {
00057   struct ACLListEntry;
00058   class QuotaInfo;
00059   typedef QVector<KMail::ACLListEntry> ACLList;
00060 
00061   class AttachmentStrategy;
00062 
00063   class ImapAccountBase : public KMail::NetworkAccount {
00064     Q_OBJECT
00065   protected:
00066     ImapAccountBase( AccountManager * parent, const QString & name, uint id );
00067   public:
00068     virtual ~ImapAccountBase();
00069 
00071     virtual void init();
00072 
00074     virtual void pseudoAssign( const KMAccount * a );
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 onlyLocallySubscribedFolders() const { return mOnlyLocallySubscribedFolders; }
00091     virtual void setOnlyLocallySubscribedFolders( bool show );
00092 
00093 
00095     bool loadOnDemand() const { return mLoadOnDemand; }
00096     virtual void setLoadOnDemand( bool load );
00097 
00099     bool listOnlyOpenFolders() const { return mListOnlyOpenFolders; }
00100     virtual void setListOnlyOpenFolders( bool only );
00101 
00103     virtual KIO::MetaData slaveConfig() const;
00104 
00105     virtual void readConfig( KConfigGroup& config );
00106     virtual void writeConfig( KConfigGroup& config );
00107 
00111     enum ConnectionState { Error = 0, Connected, Connecting };
00112 
00113     // possible list types
00114     enum ListType {
00115       List,
00116       ListSubscribed,
00117       ListSubscribedNoCheck,
00118       ListFolderOnly,
00119       ListFolderOnlySubscribed
00120     };
00121 
00128     ConnectionState makeConnection();
00129 
00130     // namespace defines
00131     enum imapNamespace { PersonalNS=0, OtherUsersNS=1, SharedNS=2 };
00132 
00133     // map a namespace type to a list of namespaces
00134     typedef QMap<imapNamespace, QStringList> nsMap;
00135 
00136     // map a namespace to a delimiter
00137     typedef QMap<QString, QString> namespaceDelim;
00138 
00139     // map a namespace type to a map with the namespace and the delimiter
00140     typedef QMap<imapNamespace, namespaceDelim> nsDelimMap;
00141 
00145     struct jobData
00146     {
00147       // Needed by QMap, don't use
00148       jobData() : parent(0), current(0), total(1), done(0), offset(0), progressItem(0),
00149                   onlySubscribed(false), quiet(false), cancellable(false) {}
00150       // Real constructor
00151       jobData( const QString& _url, KMFolder *_parent = 0,
00152           int _total = 1, int _done = 0, bool _quiet = false,
00153           bool _cancelable = false )
00154         : url(_url), parent(_parent), current(0), total(_total), done(_done), offset(0),
00155           progressItem(0), quiet(_quiet), cancellable(_cancelable) {}
00156 
00157       QString path;
00158       QString url;
00159       QString curNamespace;
00160       QByteArray data;
00161       QByteArray cdata;
00162       QStringList items;
00163       KMFolder *parent, *current;
00164       QList<KMMessage*> msgList;
00165       int total, done, offset;
00166       KPIM::ProgressItem *progressItem;
00167       bool onlySubscribed : 1, quiet : 1, cancellable : 1;
00168     };
00169 
00170     typedef QMap<KJob *, jobData>::Iterator JobIterator;
00174     void insertJob( KJob* job, const jobData& data ) {
00175       mapJobData.insert( job, data );
00176     }
00180     JobIterator findJob( KJob* job ) { return mapJobData.find( job ); }
00181     JobIterator jobsEnd() { return mapJobData.end(); }
00186     void removeJob( JobIterator& it );
00187 
00188     void removeJob( KIO::Job* job );
00189 
00195     void changeSubscription(bool subscribe, const QString& imapPath);
00196 
00201     bool locallySubscribedTo( const QString& imapPath );
00202 
00207     void changeLocalSubscription( const QString& imapPath, bool subscribe );
00208 
00209 
00215     void getUserRights( KMFolder* folder, const QString& imapPath );
00216 
00222     void getACL( KMFolder* folder, const QString& imapPath );
00223 
00229     void getStorageQuotaInfo( KMFolder* folder, const QString& imapPath );
00230 
00235     void setImapStatus( KMFolder* folder, const QString& path, const QByteArray& flags );
00236 
00241     void setImapSeenStatus( KMFolder* folder, const QString& path, bool seen );
00242 
00246     void slaveDied() { mSlave = 0; killAllJobs(); }
00247 
00251     void killAllJobs( bool disconnectSlave=false ) = 0;
00252 
00256     virtual void cancelMailCheck();
00257 
00261     void processNewMailSingleFolder(KMFolder* folder);
00262 
00266     bool checkingSingleFolder() { return mCheckingSingleFolder; }
00267 
00272     void postProcessNewMail( bool setStatusMsg = true );
00273 
00278     bool checkingMail( KMFolder *folder );
00279 
00280     bool checkingMail() { return NetworkAccount::checkingMail(); }
00281 
00285     void handleBodyStructure( QDataStream & stream, KMMessage * msg,
00286                               const AttachmentStrategy *as );
00287 
00291     virtual void setFolder(KMFolder*, bool addAccount = false);
00292 
00297     bool hasACLSupport() const { return mACLSupport; }
00298 
00303     bool hasAnnotationSupport() const { return mAnnotationSupport; }
00304 
00308     void setHasNoAnnotationSupport() { mAnnotationSupport = false; }
00309 
00314     bool hasQuotaSupport() const { return mQuotaSupport; }
00315 
00319     void setHasNoQuotaSupport() { mQuotaSupport = false; }
00320 
00325     bool handleJobError( KIO::Job* job, const QString& context, bool abortSync = false );
00326 
00330     virtual FolderStorage* rootFolder() const = 0;
00331 
00335     KPIM::ProgressItem* listDirProgressItem();
00336 
00341     virtual unsigned int folderCount() const;
00342 
00346     nsMap namespaces() const { return mNamespaces; }
00347 
00351     virtual void setNamespaces( nsMap map )
00352     { mNamespaces = map; }
00353 
00358     nsDelimMap namespacesWithDelimiter();
00359 
00363      QString namespaceForFolder( FolderStorage* );
00364 
00368      QString addPathToNamespace( const QString& ns );
00369 
00373      QString delimiterForNamespace( const QString& prefix );
00374 
00378      QString delimiterForFolder( FolderStorage* );
00379 
00383      namespaceDelim namespaceToDelimiter() const
00384      { return mNamespaceToDelimiter; }
00385 
00389      void setNamespaceToDelimiter( namespaceDelim map )
00390      { mNamespaceToDelimiter = map; }
00391 
00395      bool isNamespaceFolder( QString& name );
00396 
00400      bool hasCapability( const QString& capa ) {
00401       return mCapabilities.contains( capa ); }
00402 
00408      QString createImapPath( FolderStorage* parent, const QString& folderName );
00409 
00413      QString createImapPath( const QString& parent, const QString& folderName );
00414 
00415 
00416   public slots:
00421     void getNamespaces();
00422 
00423   private slots:
00428     void slotSubscriptionResult(KJob * job);
00429 
00430   protected slots:
00431     virtual void slotCheckQueuedFolders();
00432 
00434     void slotSchedulerSlaveConnected(KIO::Slave *aSlave);
00436     void slotSchedulerSlaveError(KIO::Slave *aSlave, int, const QString &errorMsg);
00437 
00441     void slotSetStatusResult(KJob * job);
00442 
00444     void slotGetUserRightsResult( KJob* _job );
00445 
00447     void slotGetACLResult( KJob* _job );
00448 
00450     void slotGetStorageQuotaInfoResult( KJob* _job );
00451 
00455     void slotNoopTimeout();
00459     void slotIdleTimeout();
00460 
00464     void slotAbortRequested( KPIM::ProgressItem* );
00465 
00469     void slotSimpleResult(KJob * job);
00470 
00472     void slotNamespaceResult( KJob*, const QString& str,const QString & );
00473 
00477     void slotSaveNamespaces( const ImapAccountBase::nsDelimMap& map );
00478 
00482     void slotCapabilitiesResult( KJob*, const QString& result,const QString & );
00483 
00484   protected:
00485 
00502     virtual bool handleError( int error, const QString &errorMsg, KIO::Job* job, const QString& context, bool abortSync = false );
00503 
00505     bool handlePutError( KIO::Job* job, jobData& jd, KMFolder* folder );
00506 
00507     virtual QString protocol() const;
00508     virtual unsigned short int defaultPort() const;
00509 
00513     void constructParts( QDataStream & stream, int count, KMMessagePart* parentKMPart,
00514        DwBodyPart * parent, const DwMessage * dwmsg );
00515 
00517     void migratePrefix();
00518 
00519     // used for writing the blacklist out to the config file
00520     QStringList locallyBlacklistedFolders() const;
00521     void localBlacklistFromStringList( const QStringList & );
00522     QString prettifyQuotaError( const QString& _error, KIO::Job * job );
00523 
00524   protected:
00525     QList<QPointer<KMFolder>* > mOpenFolders;
00526     QStringList mSubfolderNames, mSubfolderPaths,
00527         mSubfolderMimeTypes, mSubfolderAttributes;
00528     QMap<KJob *, jobData> mapJobData;
00530     QTimer mIdleTimer;
00532     QTimer mNoopTimer;
00533     int mTotal, mCountUnread, mCountLastUnread;
00534     QMap<QString, int> mUnreadBeforeCheck;
00535     bool mAutoExpunge : 1;
00536     bool mHiddenFolders : 1;
00537     bool mOnlySubscribedFolders : 1;
00538     bool mOnlyLocallySubscribedFolders : 1;
00539     bool mLoadOnDemand : 1;
00540     bool mListOnlyOpenFolders : 1;
00541     bool mProgressEnabled : 1;
00542 
00543     bool mErrorDialogIsActive : 1;
00544     bool mPasswordDialogIsActive : 1;
00545     bool mPasswordEnteredAndEmpty : 1;
00546     bool mACLSupport : 1;
00547     bool mAnnotationSupport : 1;
00548     bool mQuotaSupport : 1;
00549     bool mSlaveConnected : 1;
00550     bool mSlaveConnectionError : 1;
00551     bool mCheckingSingleFolder : 1;
00552 
00553     // folders that should be checked for new mails
00554     QList<QPointer<KMFolder> > mMailCheckFolders;
00555     // folders that should be checked after the current check is done
00556     QList<QPointer<KMFolder> > mFoldersQueuedForChecking;
00557     // holds messageparts from the bodystructure
00558     QList<KMMessagePart*> mBodyPartList;
00559     // the current message for the bodystructure
00560     KMMessage* mCurrentMsg;
00561 
00562     QPointer<KPIM::ProgressItem> mListDirProgressItem;
00563 
00564     // our namespaces in the form section=namespaceList
00565     nsMap mNamespaces;
00566 
00567     // namespace - delimiter map
00568     namespaceDelim mNamespaceToDelimiter;
00569 
00570     // old prefix for migration
00571     QString mOldPrefix;
00572 
00573     // capabilities
00574     QStringList mCapabilities;
00575 
00576     std::set<QString> mLocalSubscriptionBlackList;
00577 
00578   signals:
00585     void connectionResult( int errorCode, const QString& errorMsg );
00586 
00591     void subscriptionChanged(const QString& imapPath, bool subscribed);
00592 
00598     void imapStatusChanged( KMFolder*, const QString& imapPath, bool cont );
00599 
00605     void receivedUserRights( KMFolder* folder );
00606 
00614     void receivedACL( KMFolder* folder, KIO::Job* job, const KMail::ACLList& entries );
00615 
00624     void receivedStorageQuotaInfo( KMFolder* folder, KIO::Job* job, const KMail::QuotaInfo& entries );
00625 
00629     void namespacesFetched( const ImapAccountBase::nsDelimMap& );
00630 
00634     void namespacesFetched();
00635   };
00636 
00637 
00638 } // namespace KMail
00639 
00640 #endif // __KMAIL_IMAPACCOUNTBASE_H__

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal