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   class MessageSender;
00028 }
00029 namespace KPIM { class ProgressDialog; }
00030 using KMail::MailServiceImpl;
00031 using KMail::UndoStack;
00032 using KMail::JobScheduler;
00033 using KPIM::ProgressDialog;
00034 class KMMsgIndex;
00035 class QLabel;
00036 class KMFolder;
00037 class KMFolderMgr;
00038 class KMAcctMgr;
00039 class KMFilterMgr;
00040 class KMFilterActionDict;
00041 class KMSender;
00042 namespace KPIM {
00043   class Identity;
00044   class IdentityManager;
00045 }
00046 class KMKernel;
00047 class KMMsgDict;
00048 class KProcess;
00049 class KProgressDialog;
00050 class ConfigureDialog;
00051 class KInstance;
00052 class QTimer;
00053 class KProgress;
00054 class KPassivePopup;
00055 class KMMainWin;
00056 class KMainWindow;
00057 class KMailICalIfaceImpl;
00058 class KMReaderWin;
00059 class KSystemTray;
00060 class KMMainWidget;
00061 
00062 class KMKernel : public QObject, virtual public KMailIface
00063 {
00064   Q_OBJECT
00065 
00066 public:
00067   KMKernel (QObject *parent=0, const char *name=0);
00068   ~KMKernel ();
00069 
00072   void checkMail ();
00073   QStringList accounts();
00074   void checkAccount (const QString &account);
00076   int openComposer (const QString &to, const QString &cc, const QString &bcc,
00077                     const QString &subject, const QString &body, int hidden,
00078                     const KURL &messageFile, const KURL::List &attachURLs);
00080   int openComposer (const QString &to, const QString &cc, const QString &bcc,
00081                     const QString &subject, const QString &body, int hidden,
00082                     const KURL &messageFile, const KURL& attachURL)
00083   {
00084     return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List(attachURL));
00085   }
00087   int openComposer (const QString &to, const QString &cc, const QString &bcc,
00088                     const QString &subject, const QString &body, int hidden,
00089                     const KURL &messageFile)
00090   {
00091     return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List());
00092   }
00096   int openComposer (const QString &to, const QString &cc,
00097                     const QString &bcc, const QString &subject,
00098                     const QString &body, int hidden,
00099                     const QString &attachName,
00100                     const QCString &attachCte,
00101                     const QCString &attachData,
00102                     const QCString &attachType,
00103                     const QCString &attachSubType,
00104                     const QCString &attachParamAttr,
00105                     const QString &attachParamValue,
00106                     const QCString &attachContDisp);
00107 
00108   int openComposer (const QString &to, const QString &cc,
00109                     const QString &bcc, const QString &subject,
00110                     const QString &body, int hidden,
00111                     const QString &attachName,
00112                     const QCString &attachCte,
00113                     const QCString &attachData,
00114                     const QCString &attachType,
00115                     const QCString &attachSubType,
00116                     const QCString &attachParamAttr,
00117                     const QString &attachParamValue,
00118                     const QCString &attachContDisp,
00119                     const QCString &attachCharset);
00120 
00121   DCOPRef openComposer(const QString &to, const QString &cc,
00122                        const QString &bcc, const QString &subject,
00123                        const QString &body,bool hidden);
00124 
00126   DCOPRef newMessage();
00127 
00128   int sendCertificate( const QString& to, const QByteArray& certData );
00129 
00130   void openReader() { openReader( false ); }
00131   int dcopAddMessage(const QString & foldername, const QString & messageFile);
00132   int dcopAddMessage(const QString & foldername, const KURL & messageFile);
00133   QStringList folderList() const;
00134   DCOPRef getFolder( const QString& vpath );
00135   void selectFolder( QString folder );
00136   int timeOfLastMessageCountChange() const;
00137   virtual bool showMail( Q_UINT32 serialNumber, QString messageId );
00138   virtual QString getFrom( Q_UINT32 serialNumber );
00139   int viewMessage( const KURL & messageFile );
00140 
00145   void stopNetworkJobs();
00146 
00151   void resumeNetworkJobs();
00152 
00158   static bool askToGoOnline();
00159 
00164   static bool isOffline();
00165 
00168   static KMKernel *self() { return mySelf; }
00169   static KConfig *config();
00170 
00171   void init();
00172   void readConfig();
00173   void cleanupImapFolders();
00174   void testDir(const char *_name);
00175   void recoverDeadLetters(void);
00176   void initFolders(KConfig* cfg);
00177   void closeAllKMailWindows();
00178   void cleanup(void);
00179   void quit();
00180   void transferMail(void);
00181   void ungrabPtrKb(void);
00182   void kmailMsgHandler(QtMsgType aType, const char* aMsg);
00183   bool doSessionManagement();
00184   bool firstInstance() { return the_firstInstance; }
00185   void setFirstInstance(bool value) { the_firstInstance = value; }
00186   void action (bool mailto, bool check, const QString &to, const QString &cc,
00187                const QString &bcc, const QString &subj, const QString &body,
00188            const KURL &messageFile, const KURL::List &attach);
00189   void byteArrayToRemoteFile(const QByteArray&, const KURL&,
00190                  bool overwrite = FALSE);
00191   bool folderIsDraftOrOutbox(const KMFolder *);
00192   bool folderIsTrash(KMFolder *);
00196   bool folderIsSentMailFolder( const KMFolder * );
00200   KMFolder* findFolderById( const QString& idString );
00201 
00202   KInstance *xmlGuiInstance() { return mXmlGuiInstance; }
00203   void setXmlGuiInstance( KInstance *instance ) { mXmlGuiInstance = instance; }
00204 
00205   KMFolder *inboxFolder() { return the_inboxFolder; }
00206   KMFolder *outboxFolder() { return the_outboxFolder; }
00207   KMFolder *sentFolder() { return the_sentFolder; }
00208   KMFolder *trashFolder() { return the_trashFolder; }
00209   KMFolder *draftsFolder() { return the_draftsFolder; }
00210 
00211   KMFolderMgr *folderMgr() { return the_folderMgr; }
00212   KMFolderMgr *imapFolderMgr() { return the_imapFolderMgr; }
00213   KMFolderMgr *dimapFolderMgr() { return the_dimapFolderMgr; }
00214   KMFolderMgr *searchFolderMgr() { return the_searchFolderMgr; }
00215   UndoStack *undoStack() { return the_undoStack; }
00216   KMAcctMgr *acctMgr() { return the_acctMgr; }
00217   KMFilterMgr *filterMgr() { return the_filterMgr; }
00218   KMFilterMgr *popFilterMgr() { return the_popFilterMgr; }
00219   KMFilterActionDict *filterActionDict() { return the_filterActionDict; }
00220   KMail::MessageSender *msgSender();
00221   KMMsgDict *msgDict();
00222   KMMsgIndex *msgIndex();
00223 
00224   KPIM::ThreadWeaver::Weaver *weaver() { return the_weaver; }
00226   KPIM::IdentityManager *identityManager();
00227 
00228   JobScheduler* jobScheduler() { return mJobScheduler; }
00229 
00231   void compactAllFolders();
00233   void expireAllFoldersNow();
00234 
00235   KMailICalIfaceImpl& iCalIface();
00236 
00237   bool firstStart() { return the_firstStart; }
00238   QString previousVersion() { return the_previousVersion; }
00239   bool startingUp() { return the_startingUp; }
00240   void setStartingUp (bool flag) { the_startingUp = flag; }
00241   bool shuttingDown() { return the_shuttingDown; }
00242   void setShuttingDown(bool flag) { the_shuttingDown = flag; }
00243   void serverReady (bool flag) { the_server_is_ready = flag; }
00244 
00248   static QString localDataPath();
00249 
00250 
00255   bool haveSystemTrayApplet();
00256 
00257   bool registerSystemTrayApplet( const KSystemTray* );
00258   bool unregisterSystemTrayApplet( const KSystemTray* );
00259 
00261   bool handleCommandLine( bool noArgsOpensReader );
00262   void emergencyExit( const QString& reason );
00263 
00265   unsigned long getNextMsgSerNum();
00266   QTextCodec *networkCodec() { return netCodec; }
00267 
00269   KMainWindow* mainWin();
00270 
00271   // ### The mContextMenuShown flag is necessary to work around bug# 56693
00272   // ### (kmail freeze with the complete desktop while pinentry-qt appears)
00273   // ### FIXME: Once the encryption support is asynchron this can be removed
00274   // ### again.
00275   void setContextMenuShown( bool flag ) { mContextMenuShown = flag; }
00276   bool contextMenuShown() const { return mContextMenuShown; }
00277 
00282   ::KIMProxy* imProxy();
00283 
00288   bool mailCheckAborted() const;
00292   void enableMailCheck();
00298   void abortMailCheck();
00299 
00300   bool canQueryClose();
00301 
00305   void messageCountChanged();
00306 
00307   KMMainWidget *getKMMainWidget();
00308 
00309 public slots:
00310 
00312   void dumpDeadLetters();
00313 
00315   void slotEmptyTrash();
00316 
00317   void slotShowConfigurationDialog();
00318   void slotRunBackgroundTasks();
00319   void slotConfigChanged();
00320 
00321 protected slots:
00322   void slotDataReq(KIO::Job*,QByteArray&);
00323   void slotResult(KIO::Job*);
00324 
00325 signals:
00326   void configChanged();
00327   void folderRemoved( KMFolder* aFolder );
00328   void onlineStatusChanged( int );
00329 
00330 private:
00331   void openReader( bool onlyCheck );
00332 
00333   KMFolder *the_inboxFolder;
00334   KMFolder *the_outboxFolder;
00335   KMFolder *the_sentFolder;
00336   KMFolder *the_trashFolder;
00337   KMFolder *the_draftsFolder;
00338 
00339   KMFolderMgr *the_folderMgr;
00340   KMFolderMgr *the_imapFolderMgr;
00341   KMFolderMgr *the_dimapFolderMgr;
00342   KMFolderMgr *the_searchFolderMgr;
00343   UndoStack *the_undoStack;
00344   KMAcctMgr *the_acctMgr;
00345   KMFilterMgr *the_filterMgr;
00346   KMFilterMgr *the_popFilterMgr;
00347   KMFilterActionDict *the_filterActionDict;
00348   mutable KPIM::IdentityManager *mIdentityManager;
00349   KMSender *the_msgSender;
00350   KMMsgDict *the_msgDict;
00351   KMMsgIndex *the_msgIndex;
00352   struct putData
00353   {
00354     KURL url;
00355     QByteArray data;
00356     int offset;
00357   };
00358   QMap<KIO::Job *, putData> mPutJobs;
00361   QString the_previousVersion;
00363   bool the_firstStart;
00365   bool the_startingUp;
00367   bool the_shuttingDown;
00369   bool the_server_is_ready;
00371   bool closed_by_user;
00372   bool the_firstInstance;
00373   bool mMailCheckAborted;
00374   static KMKernel *mySelf;
00375   KSharedConfig::Ptr mConfig;
00376   QTextCodec *netCodec;
00377   KInstance* mXmlGuiInstance;
00378   ConfigureDialog *mConfigureDialog;
00379   QTimer *mBackgroundTasksTimer;
00380   KMailICalIfaceImpl* mICalIface;
00381   JobScheduler* mJobScheduler;
00382   // temporary mainwin
00383   KMMainWin *mWin;
00384   MailServiceImpl *mMailService;
00385 
00386   // the time of the last change of the unread or total count of a folder;
00387   // this can be queried via DCOP in order to determine whether the counts
00388   // need to be updated (e.g. in the Summary in Kontact)
00389   int mTimeOfLastMessageCountChange;
00390 
00391   // true if the context menu of KMFolderTree or KMHeaders is shown
00392   // this is necessary to know in order to prevent a dead lock between the
00393   // context menus and the pinentry program
00394   bool mContextMenuShown;
00395 
00396   QValueList<const KSystemTray*> systemTrayApplets;
00397 
00398   /* Weaver */
00399   KPIM::ThreadWeaver::Weaver *the_weaver;
00400   KPIM::ThreadWeaver::WeaverThreadLogger *the_weaverLogger;
00401 };
00402 
00403 #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 Thu Aug 2 09:55:16 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003