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, bool _firstMessage = false);
00151   void closeAllKMailWindows();
00152   void cleanup(void);
00153   void quit();
00154   void transferMail(void);
00155   bool transferMailToPointMail(void);
00156 
00157   void ungrabPtrKb(void);
00158   void kmailMsgHandler(QtMsgType aType, const char* aMsg);
00159   bool doSessionManagement();
00160   bool firstInstance() { return the_firstInstance; }
00161   void setFirstInstance(bool value) { the_firstInstance = value; }
00162   void action (bool mailto, bool check, const QString &to, const QString &cc,
00163                const QString &bcc, const QString &subj, const QString &body,
00164            const KURL &messageFile, const KURL::List &attach);
00165   void byteArrayToRemoteFile(const QByteArray&, const KURL&,
00166                  bool overwrite = FALSE);
00167   bool folderIsDraftOrOutbox(const KMFolder *);
00168   bool folderIsTrash(KMFolder *);
00172   bool folderIsSentMailFolder( const KMFolder * );
00176   KMFolder* findFolderById( const QString& idString );
00177 
00178   KInstance *xmlGuiInstance() { return mXmlGuiInstance; }
00179   void setXmlGuiInstance( KInstance *instance ) { mXmlGuiInstance = instance; }
00180 
00181   KMFolder *inboxFolder() { return the_inboxFolder; }
00182   KMFolder *outboxFolder() { return the_outboxFolder; }
00183   KMFolder *sentFolder() { return the_sentFolder; }
00184   KMFolder *trashFolder() { return the_trashFolder; }
00185   KMFolder *draftsFolder() { return the_draftsFolder; }
00186 
00187   KMFolderMgr *folderMgr() { return the_folderMgr; }
00188   KMFolderMgr *imapFolderMgr() { return the_imapFolderMgr; }
00189   KMFolderMgr *dimapFolderMgr() { return the_dimapFolderMgr; }
00190   KMFolderMgr *searchFolderMgr() { return the_searchFolderMgr; }
00191   UndoStack *undoStack() { return the_undoStack; }
00192   KMAcctMgr *acctMgr() { return the_acctMgr; }
00193   KMFilterMgr *filterMgr() { return the_filterMgr; }
00194   KMFilterMgr *popFilterMgr() { return the_popFilterMgr; }
00195   KMFilterActionDict *filterActionDict() { return the_filterActionDict; }
00196   KMSender *msgSender() { return the_msgSender; }
00197   KMMsgDict *msgDict();
00198   KMMsgIndex *msgIndex();
00199 
00200   KPIM::ThreadWeaver::Weaver *weaver() { return the_weaver; }
00202   KPIM::IdentityManager *identityManager();
00203 
00204   JobScheduler* jobScheduler() { return mJobScheduler; }
00205 
00207   void compactAllFolders();
00209   void expireAllFoldersNow();
00210 
00211   KMailICalIfaceImpl& iCalIface();
00212 
00213   bool firstStart() { return the_firstStart; }
00214   QString previousVersion() { return the_previousVersion; }
00215   bool startingUp() { return the_startingUp; }
00216   void setStartingUp (bool flag) { the_startingUp = flag; }
00217   bool shuttingDown() { return the_shuttingDown; }
00218   void setShuttingDown(bool flag) { the_shuttingDown = flag; }
00219   void serverReady (bool flag) { the_server_is_ready = flag; }
00220 
00225   bool haveSystemTrayApplet();
00226 
00227   bool registerSystemTrayApplet( const KSystemTray* );
00228   bool unregisterSystemTrayApplet( const KSystemTray* );
00229 
00231   bool handleCommandLine( bool noArgsOpensReader );
00232   void emergencyExit( const QString& reason );
00233 
00235   unsigned long getNextMsgSerNum();
00236   QTextCodec *networkCodec() { return netCodec; }
00237 
00239   KMainWindow* mainWin();
00240 
00241   // ### The mContextMenuShown flag is necessary to work around bug# 56693
00242   // ### (kmail freeze with the complete desktop while pinentry-qt appears)
00243   // ### FIXME: Once the encryption support is asynchron this can be removed
00244   // ### again.
00245   void setContextMenuShown( bool flag ) { mContextMenuShown = flag; }
00246   bool contextMenuShown() const { return mContextMenuShown; }
00247 
00252   ::KIMProxy* imProxy();
00253 
00258   bool mailCheckAborted() const;
00262   void enableMailCheck();
00268   void abortMailCheck();
00269 
00270   bool canQueryClose();
00271 
00275   void messageCountChanged();
00276 
00277 public slots:
00278 
00280   void dumpDeadLetters();
00281 
00287   void slotRequestConfigSync();
00288 
00290   void slotEmptyTrash();
00291 
00292   void slotShowConfigurationDialog();
00293   void slotRunBackgroundTasks();
00294 
00295 protected slots:
00296   void slotDataReq(KIO::Job*,QByteArray&);
00297   void slotResult(KIO::Job*);
00298   void slotConfigChanged();
00299 
00300 signals:
00301   void configChanged();
00302   void folderRemoved( KMFolder* aFolder );
00303 
00304 private:
00305   void openReader( bool onlyCheck );
00306   KMMainWidget *getKMMainWidget();
00307 
00308   KMFolder *the_inboxFolder;
00309   KMFolder *the_outboxFolder;
00310   KMFolder *the_sentFolder;
00311   KMFolder *the_trashFolder;
00312   KMFolder *the_draftsFolder;
00313 
00314   KMFolderMgr *the_folderMgr;
00315   KMFolderMgr *the_imapFolderMgr;
00316   KMFolderMgr *the_dimapFolderMgr;
00317   KMFolderMgr *the_searchFolderMgr;
00318   UndoStack *the_undoStack;
00319   KMAcctMgr *the_acctMgr;
00320   KMFilterMgr *the_filterMgr;
00321   KMFilterMgr *the_popFilterMgr;
00322   KMFilterActionDict *the_filterActionDict;
00323   mutable KPIM::IdentityManager *mIdentityManager;
00324   KMSender *the_msgSender;
00325   KMMsgDict *the_msgDict;
00326   KMMsgIndex *the_msgIndex;
00327   struct putData
00328   {
00329     KURL url;
00330     QByteArray data;
00331     int offset;
00332   };
00333   QMap<KIO::Job *, putData> mPutJobs;
00336   QString the_previousVersion;
00338   bool the_firstStart;
00340   bool the_startingUp;
00342   bool the_shuttingDown;
00344   bool the_server_is_ready;
00346   bool closed_by_user;
00347   bool the_firstInstance;
00348   bool mMailCheckAborted;
00349   static KMKernel *mySelf;
00350   KSharedConfig::Ptr mConfig;
00351   QTextCodec *netCodec;
00352   KInstance* mXmlGuiInstance;
00353   ConfigureDialog *mConfigureDialog;
00354   QTimer *mDeadLetterTimer;
00355   int mDeadLetterInterval;
00356   QTimer *mBackgroundTasksTimer;
00357   KMailICalIfaceImpl* mICalIface;
00358   JobScheduler* mJobScheduler;
00359   // temporary mainwin
00360   KMMainWin *mWin;
00361   MailServiceImpl *mMailService;
00362 
00363   // the time of the last change of the unread or total count of a folder;
00364   // this can be queried via DCOP in order to determine whether the counts
00365   // need to be updated (e.g. in the Summary in Kontact)
00366   int mTimeOfLastMessageCountChange;
00367 
00368   // true if the context menu of KMFolderTree or KMHeaders is shown
00369   // this is necessary to know in order to prevent a dead lock between the
00370   // context menus and the pinentry program
00371   bool mContextMenuShown;
00372 
00373   QValueList<const KSystemTray*> systemTrayApplets;
00374 
00375   /* Weaver */
00376   KPIM::ThreadWeaver::Weaver *the_weaver;
00377   KPIM::ThreadWeaver::WeaverThreadLogger *the_weaverLogger;
00378   QString firstMessage();
00379 };
00380 
00381 #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 Wed Mar 23 22:43:49 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003