kmail

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