kmail Library API Documentation

kmkernel.h

00001 // -*- mode: C++; c-file-style: "gnu" -*-
00002 
00003 #ifndef _KMCONTROL
00004 #define _KMCONTROL
00005 
00006 #include <qobject.h>
00007 #include <qstring.h>
00008 #include <weaver.h>
00009 #include <weaverlogger.h>
00010 
00011 #include <kconfig.h>
00012 #include <kdeversion.h>
00013 #include "kimproxy.h"
00014 
00015 #include "kmailIface.h"
00016 
00017 #define kmkernel KMKernel::self()
00018 #define kmconfig KMKernel::config()
00019 
00020 namespace KIO {
00021   class Job;
00022 }
00023 namespace KMail {
00024   class MailServiceImpl;
00025   class UndoStack;
00026   class JobScheduler;
00027 }
00028 namespace KPIM { class ProgressDialog; }
00029 using KMail::MailServiceImpl;
00030 using KMail::UndoStack;
00031 using KMail::JobScheduler;
00032 using KPIM::ProgressDialog;
00033 class KMMsgIndex;
00034 class QLabel;
00035 class KMFolder;
00036 class KMFolderMgr;
00037 class KMAcctMgr;
00038 class KMFilterMgr;
00039 class KMFilterActionDict;
00040 class KMSender;
00041 namespace KPIM {
00042   class Identity;
00043   class IdentityManager;
00044 }
00045 class KMKernel;
00046 class KMMsgDict;
00047 class KProcess;
00048 class KProgressDialog;
00049 class ConfigureDialog;
00050 class KInstance;
00051 class QTimer;
00052 class KProgress;
00053 class KPassivePopup;
00054 class KMMainWin;
00055 class KMainWindow;
00056 class KMailICalIfaceImpl;
00057 class KMReaderWin;
00058 class KSystemTray;
00059 class KMMainWidget;
00060 
00061 class KMKernel : public QObject, virtual public KMailIface
00062 {
00063   Q_OBJECT
00064 
00065 public:
00066   KMKernel (QObject *parent=0, const char *name=0);
00067   ~KMKernel ();
00068 
00071   void checkMail ();
00072   QStringList accounts();
00073   void checkAccount (const QString &account);
00075   int openComposer (const QString &to, const QString &cc, const QString &bcc,
00076                     const QString &subject, const QString &body, int hidden,
00077                     const KURL &messageFile, const KURL::List &attachURLs);
00079   int openComposer (const QString &to, const QString &cc, const QString &bcc,
00080                     const QString &subject, const QString &body, int hidden,
00081                     const KURL &messageFile, const KURL& attachURL)
00082   {
00083     return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List(attachURL));
00084   }
00086   int openComposer (const QString &to, const QString &cc, const QString &bcc,
00087                     const QString &subject, const QString &body, int hidden,
00088                     const KURL &messageFile)
00089   {
00090     return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List());
00091   }
00095   int openComposer (const QString &to, const QString &cc,
00096                     const QString &bcc, const QString &subject,
00097                     const QString &body, int hidden,
00098                     const QString &attachName,
00099                     const QCString &attachCte,
00100                     const QCString &attachData,
00101                     const QCString &attachType,
00102                     const QCString &attachSubType,
00103                     const QCString &attachParamAttr,
00104                     const QString &attachParamValue,
00105                     const QCString &attachContDisp);
00106 
00107   int openComposer (const QString &to, const QString &cc,
00108                     const QString &bcc, const QString &subject,
00109                     const QString &body, int hidden,
00110                     const QString &attachName,
00111                     const QCString &attachCte,
00112                     const QCString &attachData,
00113                     const QCString &attachType,
00114                     const QCString &attachSubType,
00115                     const QCString &attachParamAttr,
00116                     const QString &attachParamValue,
00117                     const QCString &attachContDisp,
00118                     const QCString &attachCharset);
00119 
00120   DCOPRef openComposer(const QString &to, const QString &cc,
00121                        const QString &bcc, const QString &subject,
00122                        const QString &body,bool hidden);
00123 
00125   DCOPRef newMessage();
00126 
00127   int sendCertificate( const QString& to, const QByteArray& certData );
00128 
00129   void openReader() { openReader( false ); }
00130   int dcopAddMessage(const QString & foldername, const QString & messageFile);
00131   int dcopAddMessage(const QString & foldername, const KURL & messageFile);
00132   QStringList folderList() const;
00133   DCOPRef getFolder( const QString& vpath );
00134   void selectFolder( QString folder );
00135   int timeOfLastMessageCountChange() const;
00136   virtual bool showMail( Q_UINT32 serialNumber, QString messageId );
00137   virtual QString getFrom( Q_UINT32 serialNumber );
00138   int viewMessage( const KURL & messageFile );
00139 
00142   static KMKernel *self() { return mySelf; }
00143   static KConfig *config();
00144 
00145   void init();
00146   void readConfig();
00147   void cleanupImapFolders();
00148   void testDir(const char *_name);
00149   void recoverDeadLetters(void);
00150   void initFolders(KConfig* cfg);
00151   void closeAllKMailWindows();
00152   void cleanup(void);
00153   void quit();
00154   void transferMail(void);
00155   void ungrabPtrKb(void);
00156   void kmailMsgHandler(QtMsgType aType, const char* aMsg);
00157   bool doSessionManagement();
00158   bool firstInstance() { return the_firstInstance; }
00159   void setFirstInstance(bool value) { the_firstInstance = value; }
00160   void action (bool mailto, bool check, const QString &to, const QString &cc,
00161                const QString &bcc, const QString &subj, const QString &body,
00162            const KURL &messageFile, const KURL::List &attach);
00163   void byteArrayToRemoteFile(const QByteArray&, const KURL&,
00164                  bool overwrite = FALSE);
00165   bool folderIsDraftOrOutbox(const KMFolder *);
00166   bool folderIsTrash(KMFolder *);
00170   bool folderIsSentMailFolder( const KMFolder * );
00174   KMFolder* findFolderById( const QString& idString );
00175 
00176   KInstance *xmlGuiInstance() { return mXmlGuiInstance; }
00177   void setXmlGuiInstance( KInstance *instance ) { mXmlGuiInstance = instance; }
00178 
00179   KMFolder *inboxFolder() { return the_inboxFolder; }
00180   KMFolder *outboxFolder() { return the_outboxFolder; }
00181   KMFolder *sentFolder() { return the_sentFolder; }
00182   KMFolder *trashFolder() { return the_trashFolder; }
00183   KMFolder *draftsFolder() { return the_draftsFolder; }
00184 
00185   KMFolderMgr *folderMgr() { return the_folderMgr; }
00186   KMFolderMgr *imapFolderMgr() { return the_imapFolderMgr; }
00187   KMFolderMgr *dimapFolderMgr() { return the_dimapFolderMgr; }
00188   KMFolderMgr *searchFolderMgr() { return the_searchFolderMgr; }
00189   UndoStack *undoStack() { return the_undoStack; }
00190   KMAcctMgr *acctMgr() { return the_acctMgr; }
00191   KMFilterMgr *filterMgr() { return the_filterMgr; }
00192   KMFilterMgr *popFilterMgr() { return the_popFilterMgr; }
00193   KMFilterActionDict *filterActionDict() { return the_filterActionDict; }
00194   KMSender *msgSender() { return the_msgSender; }
00195   KMMsgDict *msgDict();
00196   KMMsgIndex *msgIndex();
00197 
00198   KPIM::ThreadWeaver::Weaver *weaver() { return the_weaver; }
00200   KPIM::IdentityManager *identityManager();
00201 
00202   JobScheduler* jobScheduler() { return mJobScheduler; }
00203 
00205   void compactAllFolders();
00207   void expireAllFoldersNow();
00208 
00209   KMailICalIfaceImpl& iCalIface();
00210 
00211   bool firstStart() { return the_firstStart; }
00212   QString previousVersion() { return the_previousVersion; }
00213   bool startingUp() { return the_startingUp; }
00214   void setStartingUp (bool flag) { the_startingUp = flag; }
00215   bool shuttingDown() { return the_shuttingDown; }
00216   void setShuttingDown(bool flag) { the_shuttingDown = flag; }
00217   void serverReady (bool flag) { the_server_is_ready = flag; }
00218 
00223   bool haveSystemTrayApplet();
00224 
00225   bool registerSystemTrayApplet( const KSystemTray* );
00226   bool unregisterSystemTrayApplet( const KSystemTray* );
00227 
00229   bool handleCommandLine( bool noArgsOpensReader );
00230   void emergencyExit( const QString& reason );
00231 
00233   unsigned long getNextMsgSerNum();
00234   QTextCodec *networkCodec() { return netCodec; }
00235 
00237   KMainWindow* mainWin();
00238 
00239   // ### The mContextMenuShown flag is necessary to work around bug# 56693
00240   // ### (kmail freeze with the complete desktop while pinentry-qt appears)
00241   // ### FIXME: Once the encryption support is asynchron this can be removed
00242   // ### again.
00243   void setContextMenuShown( bool flag ) { mContextMenuShown = flag; }
00244   bool contextMenuShown() const { return mContextMenuShown; }
00245 
00250   ::KIMProxy* imProxy();
00251 
00256   bool mailCheckAborted() const;
00260   void enableMailCheck();
00266   void abortMailCheck();
00267 
00268   bool canQueryClose();
00269 
00273   void messageCountChanged();
00274 
00275 public slots:
00276 
00278   void dumpDeadLetters();
00279 
00285   void slotRequestConfigSync();
00286 
00288   void slotEmptyTrash();
00289 
00290   void slotShowConfigurationDialog();
00291   void slotRunBackgroundTasks();
00292 
00293 protected slots:
00294   void slotDataReq(KIO::Job*,QByteArray&);
00295   void slotResult(KIO::Job*);
00296   void slotConfigChanged();
00297 
00298 signals:
00299   void configChanged();
00300   void folderRemoved( KMFolder* aFolder );
00301 
00302 private:
00303   void openReader( bool onlyCheck );
00304   KMMainWidget *getKMMainWidget();
00305 
00306   KMFolder *the_inboxFolder;
00307   KMFolder *the_outboxFolder;
00308   KMFolder *the_sentFolder;
00309   KMFolder *the_trashFolder;
00310   KMFolder *the_draftsFolder;
00311 
00312   KMFolderMgr *the_folderMgr;
00313   KMFolderMgr *the_imapFolderMgr;
00314   KMFolderMgr *the_dimapFolderMgr;
00315   KMFolderMgr *the_searchFolderMgr;
00316   UndoStack *the_undoStack;
00317   KMAcctMgr *the_acctMgr;
00318   KMFilterMgr *the_filterMgr;
00319   KMFilterMgr *the_popFilterMgr;
00320   KMFilterActionDict *the_filterActionDict;
00321   mutable KPIM::IdentityManager *mIdentityManager;
00322   KMSender *the_msgSender;
00323   KMMsgDict *the_msgDict;
00324   KMMsgIndex *the_msgIndex;
00325   struct putData
00326   {
00327     KURL url;
00328     QByteArray data;
00329     int offset;
00330   };
00331   QMap<KIO::Job *, putData> mPutJobs;
00334   QString the_previousVersion;
00336   bool the_firstStart;
00338   bool the_startingUp;
00340   bool the_shuttingDown;
00342   bool the_server_is_ready;
00344   bool closed_by_user;
00345   bool the_firstInstance;
00346   bool mMailCheckAborted;
00347   static KMKernel *mySelf;
00348   KSharedConfig::Ptr mConfig;
00349   QTextCodec *netCodec;
00350   KInstance* mXmlGuiInstance;
00351   ConfigureDialog *mConfigureDialog;
00352   QTimer *mDeadLetterTimer;
00353   int mDeadLetterInterval;
00354   QTimer *mBackgroundTasksTimer;
00355   KMailICalIfaceImpl* mICalIface;
00356   JobScheduler* mJobScheduler;
00357   // temporary mainwin
00358   KMMainWin *mWin;
00359   MailServiceImpl *mMailService;
00360 
00361   // the time of the last change of the unread or total count of a folder;
00362   // this can be queried via DCOP in order to determine whether the counts
00363   // need to be updated (e.g. in the Summary in Kontact)
00364   int mTimeOfLastMessageCountChange;
00365 
00366   // true if the context menu of KMFolderTree or KMHeaders is shown
00367   // this is necessary to know in order to prevent a dead lock between the
00368   // context menus and the pinentry program
00369   bool mContextMenuShown;
00370 
00371   QValueList<const KSystemTray*> systemTrayApplets;
00372 
00373   /* Weaver */
00374   KPIM::ThreadWeaver::Weaver *the_weaver;
00375   KPIM::ThreadWeaver::WeaverThreadLogger *the_weaverLogger;
00376 };
00377 
00378 #endif
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 Mon Apr 4 06:44:11 2005 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003