00001
00002
00003 #ifndef _KMCONTROL
00004 #define _KMCONTROL
00005
00006 #include <qobject.h>
00007 #include <qstring.h>
00008 #include <qguardedptr.h>
00009 #include <weaver.h>
00010 #include <weaverlogger.h>
00011
00012 #include <kconfig.h>
00013 #include <kdeversion.h>
00014 #include <kimproxy.h>
00015 #include <kdepimmacros.h>
00016
00017 #include "kmailIface.h"
00018 #include "kmmsgbase.h"
00019
00020 #define kmkernel KMKernel::self()
00021 #define kmconfig KMKernel::config()
00022
00023 namespace KIO {
00024 class Job;
00025 }
00026 namespace KWallet {
00027 class Wallet;
00028 }
00029
00034 namespace KMail {
00035 class MailServiceImpl;
00036 class UndoStack;
00037 class JobScheduler;
00038 class MessageSender;
00039 class AccountManager;
00040 }
00041 namespace KPIM { class ProgressDialog; }
00042 using KMail::MailServiceImpl;
00043 using KMail::AccountManager;
00044 using KMail::UndoStack;
00045 using KMail::JobScheduler;
00046 using KPIM::ProgressDialog;
00047 class KMMsgIndex;
00048 class QLabel;
00049 class KMFolder;
00050 class KMFolderMgr;
00051 class KMFilterMgr;
00052 class KMFilterActionDict;
00053 class KMSender;
00054 namespace KPIM {
00055 class Identity;
00056 class IdentityManager;
00057 }
00058 class KMKernel;
00059 class KProcess;
00060 class KProgressDialog;
00061 class KInstance;
00062 class QTimer;
00063 class KProgress;
00064 class KPassivePopup;
00065 class KMMainWin;
00066 class KMainWindow;
00067 class KMailICalIfaceImpl;
00068 class KMReaderWin;
00069 class KSystemTray;
00070 class KMMainWidget;
00071 class ConfigureDialog;
00072
00082 class KDE_EXPORT KMKernel : public QObject, virtual public KMailIface
00083 {
00084 Q_OBJECT
00085
00086 public:
00087 KMKernel (QObject *parent=0, const char *name=0);
00088 ~KMKernel ();
00089
00092 void checkMail ();
00093 QStringList accounts();
00094 void checkAccount (const QString &account);
00096 int openComposer (const QString &to, const QString &cc, const QString &bcc,
00097 const QString &subject, const QString &body, int hidden,
00098 const KURL &messageFile, const KURL::List &attachURLs);
00100 int openComposer (const QString &to, const QString &cc, const QString &bcc,
00101 const QString &subject, const QString &body, int hidden,
00102 const KURL &messageFile, const KURL& attachURL)
00103 {
00104 return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List(attachURL));
00105 }
00107 int openComposer (const QString &to, const QString &cc, const QString &bcc,
00108 const QString &subject, const QString &body, int hidden,
00109 const KURL &messageFile)
00110 {
00111 return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List());
00112 }
00116 int openComposer (const QString &to, const QString &cc,
00117 const QString &bcc, const QString &subject,
00118 const QString &body, int hidden,
00119 const QString &attachName,
00120 const QCString &attachCte,
00121 const QCString &attachData,
00122 const QCString &attachType,
00123 const QCString &attachSubType,
00124 const QCString &attachParamAttr,
00125 const QString &attachParamValue,
00126 const QCString &attachContDisp);
00127
00128 int openComposer (const QString &to, const QString &cc,
00129 const QString &bcc, const QString &subject,
00130 const QString &body, int hidden,
00131 const QString &attachName,
00132 const QCString &attachCte,
00133 const QCString &attachData,
00134 const QCString &attachType,
00135 const QCString &attachSubType,
00136 const QCString &attachParamAttr,
00137 const QString &attachParamValue,
00138 const QCString &attachContDisp,
00139 const QCString &attachCharset);
00140
00141 DCOPRef openComposer(const QString &to, const QString &cc,
00142 const QString &bcc, const QString &subject,
00143 const QString &body,bool hidden);
00144
00147 void setDefaultTransport( const QString & transport );
00148
00150 DCOPRef newMessage(const QString &to,
00151 const QString &cc,
00152 const QString &bcc,
00153 bool hidden,
00154 bool useFolderId,
00155 const KURL &messageFile,
00156 const KURL &attachURL);
00157
00158 int sendCertificate( const QString& to, const QByteArray& certData );
00159
00160 void openReader() { openReader( false ); }
00161
00162 int dcopAddMessage(const QString & foldername, const QString & messagefile,
00163 const QString & MsgStatusFlags = QString());
00164 int dcopAddMessage(const QString & foldername, const KURL & messagefile,
00165 const QString & MsgStatusFlags = QString());
00166 void dcopResetAddMessage();
00168 int dcopAddMessage_fastImport(const QString & foldername, const QString & messagefile,
00169 const QString & MsgStatusFlags = QString());
00170 int dcopAddMessage_fastImport(const QString & foldername, const KURL & messagefile,
00171 const QString & MsgStatusFlags = QString());
00172
00173 QStringList folderList() const;
00174 DCOPRef getFolder( const QString& vpath );
00175 void selectFolder( QString folder );
00176 int timeOfLastMessageCountChange() const;
00177 virtual bool showMail( Q_UINT32 serialNumber, QString messageId );
00178 virtual QString getFrom( Q_UINT32 serialNumber );
00179 virtual QString debugScheduler();
00180 virtual QString debugSernum( Q_UINT32 serialNumber );
00181 int viewMessage( const KURL & messageFile );
00182
00187 virtual void pauseBackgroundJobs();
00188
00193 virtual void resumeBackgroundJobs();
00194
00199 void stopNetworkJobs();
00200
00205 void resumeNetworkJobs();
00206
00212 static bool askToGoOnline();
00213
00218 static bool isOffline();
00219
00222 static KMKernel *self() { return mySelf; }
00223 static KConfig *config();
00224
00225 void init();
00226 void readConfig();
00227 void cleanupImapFolders();
00228 void testDir(const char *_name);
00229 void recoverDeadLetters();
00230 void initFolders(KConfig* cfg);
00231 void closeAllKMailWindows();
00232 void cleanup(void);
00233 void quit();
00239 bool transferMail( QString & destinationDir );
00240 void ungrabPtrKb(void);
00241 void kmailMsgHandler(QtMsgType aType, const char* aMsg);
00242 bool doSessionManagement();
00243 bool firstInstance() { return the_firstInstance; }
00244 void setFirstInstance(bool value) { the_firstInstance = value; }
00245 void action (bool mailto, bool check, const QString &to, const QString &cc,
00246 const QString &bcc, const QString &subj, const QString &body,
00247 const KURL &messageFile, const KURL::List &attach);
00248 void byteArrayToRemoteFile(const QByteArray&, const KURL&,
00249 bool overwrite = FALSE);
00250 bool folderIsDraftOrOutbox(const KMFolder *);
00251 bool folderIsDrafts(const KMFolder *);
00252 bool folderIsTrash(KMFolder *);
00256 bool folderIsSentMailFolder( const KMFolder * );
00260 KMFolder* findFolderById( const QString& idString );
00261
00262 KInstance *xmlGuiInstance() { return mXmlGuiInstance; }
00263 void setXmlGuiInstance( KInstance *instance ) { mXmlGuiInstance = instance; }
00264
00265 KMFolder *inboxFolder() { return the_inboxFolder; }
00266 KMFolder *outboxFolder() { return the_outboxFolder; }
00267 KMFolder *sentFolder() { return the_sentFolder; }
00268 KMFolder *trashFolder() { return the_trashFolder; }
00269 KMFolder *draftsFolder() { return the_draftsFolder; }
00270
00271 KMFolderMgr *folderMgr() { return the_folderMgr; }
00272 KMFolderMgr *imapFolderMgr() { return the_imapFolderMgr; }
00273 KMFolderMgr *dimapFolderMgr() { return the_dimapFolderMgr; }
00274 KMFolderMgr *searchFolderMgr() { return the_searchFolderMgr; }
00275 UndoStack *undoStack() { return the_undoStack; }
00276 AccountManager *acctMgr() { return the_acctMgr; }
00277 KMFilterMgr *filterMgr() { return the_filterMgr; }
00278 KMFilterMgr *popFilterMgr() { return the_popFilterMgr; }
00279 KMFilterActionDict *filterActionDict() { return the_filterActionDict; }
00280 KMail::MessageSender *msgSender();
00281 KMMsgIndex *msgIndex();
00282
00283 KPIM::ThreadWeaver::Weaver *weaver() { return the_weaver; }
00285 KPIM::IdentityManager *identityManager();
00286
00287 JobScheduler* jobScheduler() { return mJobScheduler; }
00288
00290 void compactAllFolders();
00292 void expireAllFoldersNow();
00293
00294 KMailICalIfaceImpl& iCalIface();
00295
00296 bool firstStart() { return the_firstStart; }
00297 QString previousVersion() { return the_previousVersion; }
00298 bool startingUp() { return the_startingUp; }
00299 void setStartingUp (bool flag) { the_startingUp = flag; }
00300 bool shuttingDown() { return the_shuttingDown; }
00301 void setShuttingDown(bool flag) { the_shuttingDown = flag; }
00302 void serverReady (bool flag) { the_server_is_ready = flag; }
00303
00307 static QString localDataPath();
00308
00313 bool haveSystemTrayApplet();
00314
00315 bool registerSystemTrayApplet( const KSystemTray* );
00316 bool unregisterSystemTrayApplet( const KSystemTray* );
00317
00319 bool handleCommandLine( bool noArgsOpensReader );
00320 void emergencyExit( const QString& reason );
00321
00323 unsigned long getNextMsgSerNum();
00324 QTextCodec *networkCodec() { return netCodec; }
00325
00327 KMainWindow* mainWin();
00328
00329
00330
00331
00332
00333 void setContextMenuShown( bool flag ) { mContextMenuShown = flag; }
00334 bool contextMenuShown() const { return mContextMenuShown; }
00335
00340 ::KIMProxy* imProxy();
00341
00346 bool mailCheckAborted() const;
00350 void enableMailCheck();
00356 void abortMailCheck();
00357
00358 bool canQueryClose();
00359
00363 void messageCountChanged();
00364
00366 KWallet::Wallet *wallet();
00367
00369 KMMainWidget *getKMMainWidget();
00370
00372 QValueList< QGuardedPtr<KMFolder> > allFolders();
00373
00374 void raise();
00375
00376 public slots:
00377
00379 void dumpDeadLetters();
00380
00386 void slotRequestConfigSync();
00387
00389 void slotEmptyTrash();
00390
00391 void slotShowConfigurationDialog();
00392 void slotRunBackgroundTasks();
00393
00394 void slotConfigChanged();
00395
00396 protected slots:
00397 void slotDataReq(KIO::Job*,QByteArray&);
00398 void slotResult(KIO::Job*);
00399
00400 signals:
00401 void configChanged();
00402 void folderRemoved( KMFolder* aFolder );
00403
00404 private:
00405 void openReader( bool onlyCheck );
00406 KMMsgStatus strToStatus(const QString &flags);
00407 KMFolder *currentFolder();
00408
00409 KMFolder *the_inboxFolder;
00410 KMFolder *the_outboxFolder;
00411 KMFolder *the_sentFolder;
00412 KMFolder *the_trashFolder;
00413 KMFolder *the_draftsFolder;
00414
00415 KMFolderMgr *the_folderMgr;
00416 KMFolderMgr *the_imapFolderMgr;
00417 KMFolderMgr *the_dimapFolderMgr;
00418 KMFolderMgr *the_searchFolderMgr;
00419 UndoStack *the_undoStack;
00420 AccountManager *the_acctMgr;
00421 KMFilterMgr *the_filterMgr;
00422 KMFilterMgr *the_popFilterMgr;
00423 KMFilterActionDict *the_filterActionDict;
00424 mutable KPIM::IdentityManager *mIdentityManager;
00425 KMSender *the_msgSender;
00426 KMMsgIndex *the_msgIndex;
00427 struct putData
00428 {
00429 KURL url;
00430 QByteArray data;
00431 int offset;
00432 };
00433 QMap<KIO::Job *, putData> mPutJobs;
00436 QString the_previousVersion;
00438 bool the_firstStart;
00440 bool the_startingUp;
00442 bool the_shuttingDown;
00444 bool the_server_is_ready;
00446 bool closed_by_user;
00447 bool the_firstInstance;
00448 bool mMailCheckAborted;
00449 static KMKernel *mySelf;
00450 KSharedConfig::Ptr mConfig;
00451 QTextCodec *netCodec;
00452 KInstance* mXmlGuiInstance;
00453 ConfigureDialog *mConfigureDialog;
00454
00455 QTimer *mBackgroundTasksTimer;
00456 KMailICalIfaceImpl* mICalIface;
00457 JobScheduler* mJobScheduler;
00458
00459 KMMainWin *mWin;
00460 MailServiceImpl *mMailService;
00461
00462
00463
00464
00465 int mTimeOfLastMessageCountChange;
00466
00467
00468
00469
00470 bool mContextMenuShown;
00471
00472 QValueList<const KSystemTray*> systemTrayApplets;
00473
00474
00475 KPIM::ThreadWeaver::Weaver *the_weaver;
00476 KPIM::ThreadWeaver::WeaverThreadLogger *the_weaverLogger;
00477
00478 KWallet::Wallet *mWallet;
00479
00480
00481 QStringList mAddMessageMsgIds;
00482 QString mAddMessageLastFolder;
00483 KMFolder *mAddMsgCurrentFolder;
00484 };
00485
00486 #endif