kmail

kmkernel.h
1 // -*- mode: C++; c-file-style: "gnu" -*-
2 
3 #ifndef _KMCONTROL
4 #define _KMCONTROL
5 
6 #include <tqobject.h>
7 #include <tqstring.h>
8 #include <tqguardedptr.h>
9 #include <weaver.h>
10 #include <weaverlogger.h>
11 
12 #include <kdemacros.h>
13 #include <tdeconfig.h>
14 #include <tdeversion.h>
15 #include <tdeimproxy.h>
16 #include <tdepimmacros.h>
17 
18 #ifdef __TDE_HAVE_TDEHWLIB
19 # include <tdenetworkconnections.h>
20 #else
21 namespace TDENetworkConnectionStatus {
22  enum TDENetworkConnectionStatus {
23  };
24 }
25 #endif
26 
27 #include "kmailIface.h"
28 #include "kmmsgbase.h"
29 #include "globalsettings.h"
30 
31 #define kmkernel KMKernel::self()
32 #define kmconfig KMKernel::config()
33 
34 namespace TDEIO {
35  class Job;
36 }
37 namespace TDEWallet {
38  class Wallet;
39 }
40 
45 namespace KMail {
46  class MailServiceImpl;
47  class UndoStack;
48  class JobScheduler;
49  class MessageSender;
50  class AccountManager;
51 }
52 namespace KPIM { class ProgressDialog; }
53 using KMail::MailServiceImpl;
55 using KMail::UndoStack;
57 using KPIM::ProgressDialog;
58 class KMMsgIndex;
59 class TQLabel;
60 class KMFolder;
61 class KMFolderMgr;
62 class KMFilterMgr;
63 class KMFilterActionDict;
64 class KMSender;
65 namespace KPIM {
66  class Identity;
67  class IdentityManager;
68 }
69 class KMKernel;
70 class TDEProcess;
71 class KProgressDialog;
72 class TDEInstance;
73 class TQTimer;
74 class KProgress;
75 class KPassivePopup;
76 class KMMainWin;
77 class TDEMainWindow;
78 class KMailICalIfaceImpl;
79 class KMReaderWin;
80 class KSystemTray;
81 class KMMainWidget;
82 class ConfigureDialog;
83 
93 class KDE_EXPORT KMKernel : public TQObject, virtual public KMailIface
94 {
95  Q_OBJECT
96 
97 
98 public:
99  KMKernel (TQObject *parent=0, const char *name=0);
100  ~KMKernel ();
101 
104  void checkMail ();
105  TQStringList accounts();
106  void checkAccount (const TQString &account);
108  int openComposer (const TQString &to, const TQString &cc, const TQString &bcc,
109  const TQString &subject, const TQString &body, int hidden,
110  const KURL &messageFile, const KURL::List &attachURLs,
111  const QCStringList &customHeaders);
113  int openComposer (const TQString &to, const TQString &cc, const TQString &bcc,
114  const TQString &subject, const TQString &body, int hidden,
115  const KURL &messageFile, const KURL::List &attachURLs)
116  {
117  QCStringList noCustomHeaders;
118  return openComposer(to, cc, bcc, subject, body, hidden, messageFile, attachURLs, noCustomHeaders);
119  }
121  int openComposer (const TQString &to, const TQString &cc, const TQString &bcc,
122  const TQString &subject, const TQString &body, int hidden,
123  const KURL &messageFile, const KURL& attachURL)
124  {
125  return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List(attachURL));
126  }
128  int openComposer (const TQString &to, const TQString &cc, const TQString &bcc,
129  const TQString &subject, const TQString &body, int hidden,
130  const KURL &messageFile)
131  {
132  return openComposer(to, cc, bcc, subject, body, hidden, messageFile, KURL::List());
133  }
137  int openComposer (const TQString &to, const TQString &cc,
138  const TQString &bcc, const TQString &subject,
139  const TQString &body, int hidden,
140  const TQString &attachName,
141  const TQCString &attachCte,
142  const TQCString &attachData,
143  const TQCString &attachType,
144  const TQCString &attachSubType,
145  const TQCString &attachParamAttr,
146  const TQString &attachParamValue,
147  const TQCString &attachContDisp);
148 
152  int openComposer (const TQString &to, const TQString &cc,
153  const TQString &bcc, const TQString &subject,
154  const TQString &body, int hidden,
155  const TQString &attachName,
156  const TQCString &attachCte,
157  const TQCString &attachData,
158  const TQCString &attachType,
159  const TQCString &attachSubType,
160  const TQCString &attachParamAttr,
161  const TQString &attachParamValue,
162  const TQCString &attachContDisp,
163  const TQCString &attachCharset);
164 
165  int openComposer (const TQString &to, const TQString &cc,
166  const TQString &bcc, const TQString &subject,
167  const TQString &body, int hidden,
168  const TQString &attachName,
169  const TQCString &attachCte,
170  const TQCString &attachData,
171  const TQCString &attachType,
172  const TQCString &attachSubType,
173  const TQCString &attachParamAttr,
174  const TQString &attachParamValue,
175  const TQCString &attachContDisp,
176  const TQCString &attachCharset,
177  unsigned int identity);
178 
179  DCOPRef openComposer(const TQString &to, const TQString &cc,
180  const TQString &bcc, const TQString &subject,
181  const TQString &body,bool hidden);
182 
185  void setDefaultTransport( const TQString & transport );
186 
188  DCOPRef newMessage(const TQString &to,
189  const TQString &cc,
190  const TQString &bcc,
191  bool hidden,
192  bool useFolderId,
193  const KURL &messageFile,
194  const KURL &attachURL);
195 
196  int sendCertificate( const TQString& to, const TQByteArray& certData );
197 
198  void openReader() { openReader( false ); }
199 
200  int dcopAddMessage(const TQString & foldername, const TQString & messagefile,
201  const TQString & MsgStatusFlags = TQString());
202  int dcopAddMessage(const TQString & foldername, const KURL & messagefile,
203  const TQString & MsgStatusFlags = TQString());
204  void dcopResetAddMessage();
206  int dcopAddMessage_fastImport(const TQString & foldername, const TQString & messagefile,
207  const TQString & MsgStatusFlags = TQString());
208  int dcopAddMessage_fastImport(const TQString & foldername, const KURL & messagefile,
209  const TQString & MsgStatusFlags = TQString());
210  void showImportArchiveDialog();
211 
212  TQStringList folderList() const;
213  DCOPRef getFolder( const TQString& vpath );
214  void selectFolder( TQString folder );
215  int timeOfLastMessageCountChange() const;
216  virtual bool showMail( TQ_UINT32 serialNumber, TQString messageId );
217  virtual TQString getFrom( TQ_UINT32 serialNumber );
218  virtual TQString debugScheduler();
219  virtual TQString debugSernum( TQ_UINT32 serialNumber );
220  int viewMessage( const KURL & messageFile );
221 
226  virtual void pauseBackgroundJobs();
227 
232  virtual void resumeBackgroundJobs();
233 
238  void stopNetworkJobs();
239 
244  void resumeNetworkJobs();
245 
251  static bool askToGoOnline();
252 
257  static bool isOffline();
258 
261  static KMKernel *self() { return mySelf; }
262  static TDEConfig *config();
263 
264  void init();
265  void readConfig();
266  void cleanupImapFolders();
267  void recreateCorruptIndexFiles();
268  void testDir(const char *_name);
269  void recoverDeadLetters();
270  void initFolders(TDEConfig* cfg);
271  void closeAllKMailWindows();
272  void cleanup(void);
273  void quit();
279  bool transferMail( TQString & destinationDir );
280  void ungrabPtrKb(void);
281  void kmailMsgHandler(TQtMsgType aType, const char* aMsg);
282  bool doSessionManagement();
283  bool firstInstance() { return the_firstInstance; }
284  void setFirstInstance(bool value) { the_firstInstance = value; }
285  void action (bool mailto, bool check, const TQString &to, const TQString &cc,
286  const TQString &bcc, const TQString &subj, const TQString &body,
287  const KURL &messageFile, const KURL::List &attach,
288  const QCStringList &customHeaders);
289  void byteArrayToRemoteFile(const TQByteArray&, const KURL&,
290  bool overwrite = FALSE);
291  bool folderIsDraftOrOutbox( const KMFolder * );
292  bool folderIsDrafts( const KMFolder * );
293  bool folderIsTemplates( const KMFolder * );
294  bool folderIsTrash( KMFolder * );
298  bool folderIsSentMailFolder( const KMFolder * );
302  KMFolder* findFolderById( const TQString& idString );
303 
304  TDEInstance *xmlGuiInstance() { return mXmlGuiInstance; }
305  void setXmlGuiInstance( TDEInstance *instance ) { mXmlGuiInstance = instance; }
306 
307  KMFolder *inboxFolder() { return the_inboxFolder; }
308  KMFolder *outboxFolder() { return the_outboxFolder; }
309  KMFolder *sentFolder() { return the_sentFolder; }
310  KMFolder *trashFolder() { return the_trashFolder; }
311  KMFolder *draftsFolder() { return the_draftsFolder; }
312  KMFolder *templatesFolder() { return the_templatesFolder; }
313 
314  KMFolderMgr *folderMgr() { return the_folderMgr; }
315  KMFolderMgr *imapFolderMgr() { return the_imapFolderMgr; }
316  KMFolderMgr *dimapFolderMgr() { return the_dimapFolderMgr; }
317  KMFolderMgr *searchFolderMgr() { return the_searchFolderMgr; }
318  UndoStack *undoStack() { return the_undoStack; }
319  AccountManager *acctMgr() { return the_acctMgr; }
320  KMFilterMgr *filterMgr() { return the_filterMgr; }
321  KMFilterMgr *popFilterMgr() { return the_popFilterMgr; }
322  KMFilterActionDict *filterActionDict() { return the_filterActionDict; }
323  KMail::MessageSender *msgSender();
324  KMMsgIndex *msgIndex();
325 
326  KPIM::ThreadWeaver::Weaver *weaver() { return the_weaver; }
328  KPIM::IdentityManager *identityManager();
329 
330  JobScheduler* jobScheduler() { return mJobScheduler; }
331 
333  void compactAllFolders();
335  void expireAllFoldersNow();
336 
337  KMailICalIfaceImpl& iCalIface();
338 
339  bool firstStart() { return the_firstStart; }
340  TQString previousVersion() { return the_previousVersion; }
341  bool startingUp() { return the_startingUp; }
342  void setStartingUp (bool flag) { the_startingUp = flag; }
343  bool shuttingDown() { return the_shuttingDown; }
344  void setShuttingDown(bool flag) { the_shuttingDown = flag; }
345  void serverReady (bool flag) { the_server_is_ready = flag; }
346 
350  static TQString localDataPath();
351 
356  bool haveSystemTrayApplet();
357 
358  bool registerSystemTrayApplet( const KSystemTray* );
359  bool unregisterSystemTrayApplet( const KSystemTray* );
360 
362  bool handleCommandLine( bool noArgsOpensReader );
363  void emergencyExit( const TQString& reason );
364 
366  unsigned long getNextMsgSerNum();
367  TQTextCodec *networkCodec() { return netCodec; }
368 
370  TDEMainWindow* mainWin();
371 
372  // ### The mContextMenuShown flag is necessary to work around bug# 56693
373  // ### (kmail freeze with the complete desktop while pinentry-qt appears)
374  // ### FIXME: Once the encryption support is asynchron this can be removed
375  // ### again.
376  void setContextMenuShown( bool flag ) { mContextMenuShown = flag; }
377  bool contextMenuShown() const { return mContextMenuShown; }
378 
383  ::KIMProxy* imProxy();
384 
389  bool mailCheckAborted() const;
393  void enableMailCheck();
399  void abortMailCheck();
400 
401  bool canQueryClose();
402 
406  void messageCountChanged();
407 
409  TDEWallet::Wallet *wallet();
410 
412  KMMainWidget *getKMMainWidget();
413 
415  TQValueList< TQGuardedPtr<KMFolder> > allFolders();
416 
417  void raise();
418 
419  void loadProfile( const TQString& path );
420 
421  void saveToProfile( const TQString& path ) const;
422 
423  bool isCodecAsciiCompatible( const TQTextCodec *codec );
424 public slots:
425 
427  void dumpDeadLetters();
428 
434  void slotRequestConfigSync();
435 
437  void slotEmptyTrash();
438 
439  void slotShowConfigurationDialog();
440  void slotRunBackgroundTasks();
441 
442  void slotConfigChanged();
443 
444 protected slots:
445  void slotDataReq(TDEIO::Job*,TQByteArray&);
446  void slotResult(TDEIO::Job*);
447  void slotNetworkStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString);
448 
449 signals:
450  void configChanged();
451  void folderRemoved( KMFolder* aFolder );
452  void onlineStatusChanged( GlobalSettings::EnumNetworkState::type );
453 
454 private:
455  void openReader( bool onlyCheck );
456  KMMsgStatus strToStatus(const TQString &flags);
457  bool networkStateConnected();
458  KMFolder *currentFolder();
459 
460  KMFolder *the_inboxFolder;
461  KMFolder *the_outboxFolder;
462  KMFolder *the_sentFolder;
463  KMFolder *the_trashFolder;
464  KMFolder *the_draftsFolder;
465  KMFolder *the_templatesFolder;
466 
467  KMFolderMgr *the_folderMgr;
468  KMFolderMgr *the_imapFolderMgr;
469  KMFolderMgr *the_dimapFolderMgr;
470  KMFolderMgr *the_searchFolderMgr;
471  UndoStack *the_undoStack;
472  AccountManager *the_acctMgr;
473  KMFilterMgr *the_filterMgr;
474  KMFilterMgr *the_popFilterMgr;
475  KMFilterActionDict *the_filterActionDict;
476  mutable KPIM::IdentityManager *mIdentityManager;
477  KMSender *the_msgSender;
478  KMMsgIndex *the_msgIndex;
479  struct putData
480  {
481  KURL url;
482  TQByteArray data;
483  int offset;
484  };
485  TQMap<TDEIO::Job *, putData> mPutJobs;
488  TQString the_previousVersion;
490  bool the_firstStart;
492  bool the_startingUp;
494  bool the_shuttingDown;
496  bool the_server_is_ready;
498  bool closed_by_user;
499  bool the_firstInstance;
500  bool mMailCheckAborted;
501  static KMKernel *mySelf;
502  TDESharedConfig::Ptr mConfig;
503  TQTextCodec *netCodec;
504  TDEInstance* mXmlGuiInstance;
505  ConfigureDialog *mConfigureDialog;
506 
507  TQTimer *mBackgroundTasksTimer;
508  KMailICalIfaceImpl* mICalIface;
509  JobScheduler* mJobScheduler;
510  // temporary mainwin
511  KMMainWin *mWin;
512  MailServiceImpl *mMailService;
513 
514  // the time of the last change of the unread or total count of a folder;
515  // this can be queried via DCOP in order to determine whether the counts
516  // need to be updated (e.g. in the Summary in Kontact)
517  int mTimeOfLastMessageCountChange;
518 
519  // true if the context menu of KMFolderTree or KMHeaders is shown
520  // this is necessary to know in order to prevent a dead lock between the
521  // context menus and the pinentry program
522  bool mContextMenuShown;
523 
524  TQValueList<const KSystemTray*> systemTrayApplets;
525  TQValueList<const TQTextCodec*> mNonAsciiCompatibleCodecs;
526 
527  /* Weaver */
528  KPIM::ThreadWeaver::Weaver *the_weaver;
529  KPIM::ThreadWeaver::WeaverThreadLogger *the_weaverLogger;
530 
531  TDEWallet::Wallet *mWallet;
532 
533  // variables used by dcopAddMessage()
534  TQStringList mAddMessageMsgIds;
535  TQString mAddMessageLastFolder;
536  KMFolder *mAddMsgCurrentFolder;
537 
538 #ifdef __TDE_HAVE_TDEHWLIB
539  TDEGlobalNetworkManager *mNetworkManager;
540 #endif
541 };
542 
543 #endif
checkMail wont show reader but will check mail.
Definition: kmailIface.h:17
The unique JobScheduler instance (owned by kmkernel) implements "background processing" of folder ope...
Definition: jobscheduler.h:96
virtual void stopNetworkJobs()=0
Stop all network related jobs and enter offline mode.
virtual int sendCertificate(const TQString &to, const TQByteArray &certData)=0
Send a certificate request to the CA specified in to.
int openComposer(const TQString &to, const TQString &cc, const TQString &bcc, const TQString &subject, const TQString &body, int hidden, const KURL &messageFile, const KURL::List &attachURLs)
For backward compatibility.
Definition: kmkernel.h:113
int openComposer(const TQString &to, const TQString &cc, const TQString &bcc, const TQString &subject, const TQString &body, int hidden, const KURL &messageFile)
For backward compatibility.
Definition: kmkernel.h:128
virtual bool showMail(TQ_UINT32 serialNumber, TQString messageId)=0
Shows the specified message in a separate message window.
virtual int dcopAddMessage(const TQString &foldername, const TQString &messagefile, const TQString &MsgStatusFlags=TQString())=0
The implementation of the interface.
virtual int dcopAddMessage_fastImport(const TQString &foldername, const TQString &messagefile, const TQString &MsgStatusFlags=TQString())=0
Does essentially the same as dcopAddMessage except that it doesn't reject duplicate messages.
Dictionary that contains a list of all registered filter actions with their creation functions.
virtual void dcopResetAddMessage()=0
Clears the list of added message ids which is used to filter out duplicates.
virtual void setDefaultTransport(const TQString &transport)=0
Set the KMail Default transport.
virtual void resumeNetworkJobs()=0
Resume all network related jobs and enter online mode.
The account manager is responsible for creating accounts of various types via the factory method crea...
Central point of coordination in KMail.
Definition: kmkernel.h:93
folderdiaquotatab.h
Definition: aboutdata.cpp:40
This class implements a "reader window", that is a window used for reading or viewing messages.
Definition: kmreaderwin.h:76
int openComposer(const TQString &to, const TQString &cc, const TQString &bcc, const TQString &subject, const TQString &body, int hidden, const KURL &messageFile, const KURL &attachURL)
For backward compatibility.
Definition: kmkernel.h:121
Mail folder.
Definition: kmfolder.h:68
virtual void resumeBackgroundJobs()=0
Resume compaction/expiry, and allow launching new ones.
virtual void pauseBackgroundJobs()=0
Abort any running compaction/expiry, and don't launch any new ones until resumeBackgroundJobs() is ca...
virtual TQString getFrom(TQ_UINT32 serialNumber)=0
DCOP-enabled for use in kaddressbook drop.
virtual bool handleCommandLine(bool noArgsOpensReader)=0
DCOP-enabled for KMailUniqueAppHandler in the kontact plugin.