kmail

kmaccount.h
1 /*
2  * kmail: KDE mail client
3  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 #ifndef kmaccount_h
21 #define kmaccount_h
22 
23 #include <tdeprocess.h>
24 #include <kaccount.h>
25 
26 #include <tqstring.h>
27 #include <tqguardedptr.h>
28 #include <tqvaluelist.h>
29 #include <tqmap.h>
30 
31 #include "kmmessage.h"
32 class TQTimer;
33 
34 class KMFolder;
35 class KMAcctFolder;
36 class TDEConfig;
37 class KMFolderJob;
38 class KMFolderCachedImap;
39 class AccountsPageReceivingTab;
40 namespace KMail {
41  class FolderJob;
42  class AccountManager;
43 }
45 namespace KPIM { class ProgressItem; }
46 using KMail::FolderJob;
47 using KPIM::ProgressItem;
48 
49 class KMAccount;
50 typedef TQValueList< ::KMAccount* > AccountList;
51 
52 class KMPrecommand : public TQObject
53 {
54  TQ_OBJECT
55 
56 
57 public:
58  KMPrecommand(const TQString &precommand, TQObject *parent = 0);
59  virtual ~KMPrecommand();
60  bool start();
61 
62 protected slots:
63  void precommandExited(TDEProcess *);
64 
65 signals:
66  void finished(bool);
67 
68 protected:
69  TDEProcess mPrecommandProcess;
70  TQString mPrecommand;
71 };
72 
73 
74 class KMAccount: public TQObject, public KAccount
75 {
76  TQ_OBJECT
77 
78  friend class KMail::AccountManager;
79  friend class ::KMail::FolderJob;
80  friend class ::AccountsPageReceivingTab; // part of the config dialog
81  friend class ::KMFolderCachedImap; /* HACK for processNewMSg() */
82 
83 public:
84  virtual ~KMAccount();
85 
86  enum CheckStatus { CheckOK, CheckIgnored, CheckCanceled, CheckAborted,
87  CheckError };
88 
90  static const int DefaultCheckInterval = 5;
91 
95  virtual TQString type() const { return TQString(); }
96 
100  virtual void setName(const TQString&);
101 
105  virtual TQString name() const { return KAccount::name(); }
106 
110  virtual void clearPasswd();
111 
115  virtual void init();
116 
120  virtual void pseudoAssign(const KMAccount * a );
121 
125  KMFolder* folder(void) const { return ((KMFolder*)((KMAcctFolder*)mFolder)); }
126  virtual void setFolder(KMFolder*, bool addAccount = false);
127 
131  TQString trash() const { return mTrash; }
132  virtual void setTrash(const TQString& aTrash) { mTrash = aTrash; }
133 
139  virtual void processNewMail(bool interactive) = 0;
140 
146  virtual void readConfig(TDEConfig& config);
147  void readTimerConfig();
148 
153  virtual void writeConfig(TDEConfig& config);
154 
159  virtual void setCheckInterval(int aInterval);
160  int checkInterval() const;
161 
165  inline int defaultCheckInterval(void) const { return DefaultCheckInterval; }
166 
170  void deleteFolderJobs();
171 
175  virtual void ignoreJobsForMessage( KMMessage* );
180  virtual void setCheckExclude(bool aExclude);
181  bool checkExclude(void) const { return mExclude; }
182 
186  const TQString& precommand(void) const { return mPrecommand; }
187  virtual void setPrecommand(const TQString &cmd) { mPrecommand = cmd; }
188 
195  bool runPrecommand(const TQString &precommand);
196 
201  static TQString encryptStr(const TQString& inStr);
202  static TQString decryptStr(const TQString& inStr) { return encryptStr(inStr); }
203 
204  static TQString importPassword(const TQString &);
205 
207  bool hasInbox() const { return mHasInbox; }
208  virtual void setHasInbox( bool has ) { mHasInbox = has; }
209 
213  virtual void invalidateIMAPFolders();
214 
221  virtual bool mailCheckCanProceed() const { return true; }
222 
226  bool checkingMail() { return mCheckingMail; }
227  virtual void setCheckingMail( bool checking ) { mCheckingMail = checking; }
228 
234  void checkDone( bool newMail, CheckStatus status );
235 
241  virtual void cancelMailCheck() {}
242 
247  ProgressItem *mailCheckProgressItem() const {
248  return mMailCheckProgressItem;
249  }
250 
254  void setIdentityId(uint identityId ) { mIdentityId = identityId; }
255  uint identityId() const{ return mIdentityId; }
256 
257 signals:
263  virtual void finishedCheck( bool newMail, CheckStatus status );
264 
269  virtual void newMailsProcessed( const TQMap<TQString, int> & newInFolder );
270 
271 protected slots:
272  virtual void mailCheck();
273  virtual void sendReceipts();
274  virtual void precommandExited(bool);
275 
276 protected:
277  KMAccount( AccountManager* owner, const TQString& accountName, uint id);
278 
284  virtual bool processNewMsg(KMMessage* msg);
285 
292  virtual void sendReceipt(KMMessage* msg);
293 
297  virtual void installTimer();
298  virtual void deinstallTimer();
299 
306  void addToNewInFolder( TQString folderId, int num );
307 
308 protected:
309  TQString mPrecommand;
310  TQString mTrash;
311  AccountManager* mOwner;
312  TQGuardedPtr<KMAcctFolder> mFolder;
313  TQTimer *mTimer;
314  int mInterval; // this is a switch and a scalar at the same time. If it is 0,
315  // interval mail checking is turned off and the interval spinbox proposes a
316  // default value. If it is non-null, it is the count of minutes between two
317  // automated mail checks. This means that as soon as you disable interval
318  // mail checking, the value in the spin box returns to a default value.
319  bool mExclude;
320  bool mCheckingMail : 1;
321  bool mPrecommandSuccess;
322  TQValueList<KMMessage*> mReceipts;
323  TQPtrList<FolderJob> mJobList;
324  bool mHasInbox : 1;
325  TQGuardedPtr<ProgressItem> mMailCheckProgressItem;
326  uint mIdentityId;
327 private:
331  virtual void setName( const char *name ) { TQObject::setName( name ); }
332 
333 private:
334  // for detailed (per folder) new mail notification
335  TQMap<TQString, int> mNewInFolder;
336 };
337 
338 #endif /*kmaccount_h*/
Simple wrapper class that contains the kmail account handling stuff that is usually not required outs...
Definition: kmacctfolder.h:35
Mail folder.
Definition: kmfolder.h:69
This is a Mime Message.
Definition: kmmessage.h:68
The account manager is responsible for creating accounts of various types via the factory method crea...
void readConfig(void)
Completely reload accounts from config.
void writeConfig(bool withSync=true)
Write accounts to config.
void cancelMailCheck()
Called on exit (KMMainWin::queryExit)
void invalidateIMAPFolders()
Delete all IMAP folders and resync them.
folderdiaquotatab.h
Definition: aboutdata.cpp:40