TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

458 lines
15KB

  1. /*
  2. * maildrop.h -- Declaration of class KMailDrop.
  3. * Generated by newclass on Sat Nov 29 20:07:45 EST 1997.
  4. */
  5. #ifndef SSK_MAILDROP_H
  6. #define SSK_MAILDROP_H
  7. #include<tqobject.h>
  8. #include<tqstring.h>
  9. #include<tqcolor.h>
  10. #include<tqvaluevector.h>
  11. #include <tqptrlist.h>
  12. class Protocol;
  13. class TDEConfigBase;
  14. class TDEConfigGroup;
  15. class KDropCfgDialog;
  16. class TQColor;
  17. class KornMailSubject;
  18. class KornMailId;
  19. template< class T, class R > class TQMap;
  20. /**
  21. * Abstract base class for all mailbox monitors.
  22. * @author Sirtaj Singh Kang (taj@kde.org)
  23. * @version $Id$
  24. */
  25. class KMailDrop : public TQObject
  26. {
  27. Q_OBJECT
  28. public:
  29. enum Style { Plain, Colour, Icon };
  30. private:
  31. TQString _caption;
  32. TQString _clickCmd;
  33. TQString _nMailCmd;
  34. TQString _soundFile;
  35. Style _style;
  36. TQColor _bgColour;
  37. TQColor _fgColour;
  38. TQColor _nbgColour;
  39. TQColor _nfgColour;
  40. TQString _icon;
  41. TQString _nIcon;
  42. int _lastCount;
  43. TQString _realName;
  44. bool _passivePopup;
  45. bool _passiveDate;
  46. public:
  47. static const char *TypeConfigKey;
  48. static const char *CaptionConfigKey;
  49. static const char *ClickConfigKey;
  50. static const char *NewMailConfigKey;
  51. static const char *SoundFileConfigKey;
  52. static const char *DisplayStyleConfigKey;
  53. static const char *NFgColourConfigKey;
  54. static const char *NBgColourConfigKey;
  55. static const char *FgColourConfigKey;
  56. static const char *BgColourConfigKey;
  57. static const char *IconConfigKey;
  58. static const char *NewMailIconConfigKey;
  59. static const char *ResetCounterConfigKey;
  60. static const char *PassivePopupConfigKey;
  61. static const char *PassiveDateConfigKey; //Enabled date in Passive popup
  62. static const char *UseBoxSettingsConfigKey;
  63. static const char *RealNameConfigKey;
  64. /**
  65. * KMailDrop Constructor
  66. */
  67. KMailDrop();
  68. /**
  69. * KMailDrop Destructor
  70. */
  71. virtual ~KMailDrop();
  72. /**
  73. * @return TRUE if the mailbox and its configuration are valid.
  74. */
  75. virtual bool valid() = 0;
  76. /**
  77. * Number of messages in the mailbox at the last count.
  78. * @return The number of messages in the mailbox since last count.
  79. */
  80. int count() {return _lastCount;};
  81. /**
  82. * Recheck the number of letters in this mailbox. Raises the
  83. * changed(int) signal if new mail is found.
  84. *
  85. * Concrete subclasses MUST reimplement this method.
  86. */
  87. virtual void recheck()=0;
  88. /**
  89. * Force a recheck
  90. */
  91. virtual void forceRecheck() { recheck(); }
  92. /**
  93. */
  94. virtual bool startMonitor()=0;
  95. /**
  96. */
  97. virtual bool stopMonitor()=0;
  98. /**
  99. * Check monitor run status.
  100. * @return true if monitor is running.
  101. */
  102. virtual bool running()=0;
  103. /**
  104. * Add a configuration page to the configuration dialog.
  105. * Each reimplementation should first call the inherited implementation,
  106. * then call @ref KDropCfgDialog::addConfigPage with a custom
  107. * @ref KMonitorCfg object.
  108. */
  109. // virtual void addConfigPage( KDropCfgDialog * );
  110. /**
  111. * Returns a newly created KBoxFactory object initialized to
  112. * be equivalent to this object (prototype pattern).
  113. *
  114. * Deletion of the returned object becomes the responsibility of
  115. * the caller.
  116. *
  117. * Subclasses should override this to return objects of their
  118. * own type.
  119. */
  120. virtual KMailDrop *clone() const = 0;
  121. /**
  122. * This function reads the settings which can be used by several
  123. * accounts. These values can be overwritten by the readConfigGroup
  124. * -function.
  125. *
  126. *@param cfg A configuration object with the group already
  127. * set to the configuration for this box
  128. */
  129. virtual void readGeneralConfigGroup( const TDEConfigBase& cfg );
  130. /**
  131. * Read box configuration from a config group. Subclasses that
  132. * reimplement this should call the overridden method.
  133. *
  134. * @param cfg A configuration object with the group already set to
  135. * the configuration for this box.
  136. * @return true if read was successful, false otherwise.
  137. */
  138. virtual bool readConfigGroup( const TDEConfigBase& cfg );
  139. virtual bool readConfigGroup( const TQMap< TQString, TQString > &, const Protocol * ) { return true; }
  140. /**
  141. * Write box configuration to a config group. Subclasses that
  142. * reimplement this should call the overridden method.
  143. *
  144. * @param cfg A configuration object with the group already set to
  145. * the configuration for this box.
  146. * @return true if read was successful, false otherwise.
  147. */
  148. virtual bool writeConfigGroup( TDEConfigBase& cfg ) const;
  149. /**
  150. * Return the type of this monitor, for display and
  151. * configuration purposes. Each concrete subclass should return a
  152. * unique identifier.
  153. */
  154. virtual TQString type() const = 0;
  155. /**
  156. * Return if the maildrop is synchrone (true) or asynchrone (false).
  157. * This way, classes like KornSubjectDlg know if functions like
  158. * readSubject() return a result immediately.
  159. * @param true by a synchrone type; false by an asynchrone (like KKkioDrop) type.
  160. */
  161. virtual bool synchrone() const { return true; }
  162. /**
  163. * Return true if the concrete subclass can read the subjects of
  164. * all new mails. This will enable the "Read Subjects" menu item.
  165. */
  166. virtual bool canReadSubjects() {return false;}
  167. /**
  168. * Read the subjects of all new mails.
  169. * NOTE: the default implementation stops the timer, calls
  170. * doReadSubjects, restarts the time if necessary and updates
  171. * the displayed mail count. Concrete implementations should not
  172. * touch readSubjects() but implement doReadSubjects() instead!
  173. * @param stop: stop flag. If it is set to true during the execution,
  174. * readSubjects shoulkd return as soon as possible. The return value
  175. * is invalid in this case. If stop is 0, readSubjects will not
  176. * terminate before all mail subjects are loaded.
  177. * @return all new mails subjects as a vector.
  178. */
  179. virtual TQValueVector<KornMailSubject> * readSubjects(bool * stop);
  180. /**
  181. * Read the subjects of all new mails. The concrete subclass has
  182. * to implement it, if canReadSubjects() returns true.
  183. * @param stop: stop flag. If it is set to true during the execution,
  184. * readSubjects should return as soon as possible. The return value
  185. * is invalid in this case. If stop is 0, readSubjects will not
  186. * terminate before all mail subjects are loaded.
  187. * @return all new mails subjects as a vector.
  188. */
  189. virtual TQValueVector<KornMailSubject> * doReadSubjects(bool * stop);
  190. /**
  191. * Return true if the concrete subclass can delete individual mails.
  192. * This will enable the "Delete" button in the mail subjects dialog.
  193. */
  194. virtual bool canDeleteMails() {return false;}
  195. /**
  196. * Delete some mails in the mailbox. The concrete subclass has
  197. * to implement it, if canDeleteMails() returns true.
  198. * @param ids list of mail ids to delete. The ids are taken from
  199. * the corresponding KornMailSubject instances returned by a previous
  200. * call to doReadSubjects().
  201. * @param stop: stop flag. If it is set to true during the execution,
  202. * deleteMails() should return as soon as possible. The return value
  203. * is invalid in this case. If stop is 0, deleteMails() will not
  204. * terminate before the mails are deleted.
  205. * @return true, if the mail ids of the remaining mails might have changed.
  206. * The corresponding KornMailSubject instances returned by a previous
  207. * call to doReadSubjects() have to be discarded and readSubjects() must
  208. * be called again to get the correct mail ids. If false is returned,
  209. * the KornMailSubject instances of the remaining mails might be used
  210. * further more.
  211. */
  212. virtual bool deleteMails(TQPtrList<const KornMailId> * ids, bool * stop);
  213. /**
  214. * Return true if the concrete subclass can load individual mails fully.
  215. * This will enable the "Full Message" button in the mail dialog.
  216. */
  217. virtual bool canReadMail() {return false;}
  218. /**
  219. * Load a mail from the mailbox fulle . The concrete subclass has
  220. * to implement it, if deleteMails() returns true.
  221. * @param id id of the mail to load. The id is taken from the corresponding
  222. * KornMailSubject instances returned by a previous call to doReadSubjects().
  223. * @param stop: stop flag. If it is set to true during the execution,
  224. * readMail() should return as soon as possible. The return value
  225. * is invalid in this case. If stop is 0, readMail() will not
  226. * terminate before the mail is loaded.
  227. * @return the fully loaded mail (header and body) or "" on error.
  228. */
  229. virtual TQString readMail(const KornMailId * id, bool * stop);
  230. // data that belongs in every monitor
  231. TQString caption() const { return _caption; }
  232. TQString clickCmd() const { return _clickCmd; }
  233. TQString newMailCmd() const { return _nMailCmd; }
  234. TQString soundFile() const { return _soundFile;}
  235. TQColor bgColour() const { return _bgColour; }
  236. TQColor fgColour() const { return _fgColour; }
  237. TQColor newBgColour() const { return _nbgColour; }
  238. TQColor newFgColour() const { return _nfgColour; }
  239. TQString icon() const { return _icon; }
  240. TQString newIcon() const { return _nIcon; }
  241. Style displayStyle() const { return _style; }
  242. bool passivePopup() const { return _passivePopup; }
  243. bool passiveDate() const { return _passiveDate; }
  244. TQString realName() const { return _realName; }
  245. ;
  246. void setCaption(TQString);
  247. void setClickCmd(TQString);
  248. void setNewMailCmd(TQString);
  249. void setSoundFile(TQString);
  250. void setDisplayStyle(Style);
  251. void setBgColour(TQColor);
  252. void setFgColour(TQColor);
  253. void setNewBgColour(TQColor);
  254. void setNewFgColour(TQColor);
  255. void setIcon(TQString);
  256. void setNewIcon(TQString);
  257. void setResetCounter(int);
  258. void setPassivePopup(bool);
  259. void setPassiveDate(bool);
  260. void setRealName(TQString);
  261. /**
  262. * This is called by the manager when it wishes to delete
  263. * a monitor. Clients should connect to the @ref ::notifyDisconnect
  264. * signal and ensure that the monitor is not accessed after
  265. * the signal has been received.
  266. *
  267. * Reimplementations should call this implementation too.
  268. */
  269. virtual void notifyClients();
  270. public slots:
  271. /**
  272. * Forcibly set the count to zero;
  273. */
  274. virtual void forceCountZero();
  275. /*
  276. * The next slots are used by tdeio; the present at this places
  277. * prevent warnings at runtime.
  278. */
  279. virtual void readSubjectsCanceled() {}
  280. virtual void readMailCanceled() {}
  281. virtual void deleteMailsCanceled() {}
  282. protected slots:
  283. void setCount( int, KMailDrop* );
  284. signals:
  285. /**
  286. * This signal is emitted when the mailbox discovers
  287. * new messages in the maildrop.
  288. */
  289. void changed( int, KMailDrop* );
  290. /**
  291. * This signal is emitted when the valid-status changes.
  292. * @param isValid true then and only then if the box is valid
  293. */
  294. void validChanged( bool isValid );
  295. /**
  296. * This is emitted on configuration change, normally
  297. * on an updateConfig() but
  298. */
  299. void configChanged();
  300. /**
  301. * Clients should connect to this and discontinue use
  302. * after it is emitted.
  303. */
  304. void notifyDisconnect();
  305. /**
  306. * rechecked() is called if an asynchrone maildrop has
  307. * rechecked the availability of email.
  308. */
  309. void rechecked();
  310. /**
  311. * The next signal is emitted when a passive popup could be displayed.
  312. * As argument, there is a KornSubject, which contains a subject and
  313. * some more info that could be used with the popup.
  314. */
  315. void showPassivePopup( TQPtrList< KornMailSubject >*, int, bool, const TQString& realname );
  316. /**
  317. * This signal is emitted when a passive error message should be displayed.
  318. *
  319. * @param error The error message
  320. * @param realName The real name of this object.
  321. */
  322. void showPassivePopup( const TQString& error, const TQString& realname );
  323. /**
  324. * readSubjects() might signal readSubject() if
  325. * an subject is received. This is only useful in
  326. * asynchrone situations.
  327. * @param the subject structure which is read
  328. */
  329. void readSubject( KornMailSubject * );
  330. /**
  331. * readSubjects() might signal readSubjectsTotalSteps() to
  332. * send the expected total number of steps to a possible
  333. * progress bar. See readSubjectsProgress();
  334. * @param totalSteps expected total number of steps.
  335. */
  336. void readSubjectsTotalSteps(int totalSteps);
  337. /**
  338. * readSubjects() might signal readSubjectsProgress() to
  339. * send the current progress in relation to the
  340. * expected total number of steps (see readSubjectsTotalSteps()).
  341. * @param curent progress.
  342. */
  343. void readSubjectsProgress(int progress);
  344. /**
  345. * readSubjects() might signal readSubjectsReady() to
  346. * remove the progress bar in asynchrone situations.
  347. * @param: true if succes, false if cancelled
  348. */
  349. void readSubjectsReady( bool success );
  350. /**
  351. * deleteMails() might signal deleteMailsTotalSteps() to
  352. * send the expected total number of steps to a possible
  353. * progress bar. See deleteMailsProgress();
  354. * @param totalSteps expected total number of steps.
  355. */
  356. void deleteMailsTotalSteps(int totalSteps);
  357. /**
  358. * deleteMails() might signal deleteMailsProgress() to
  359. * send the current progress in relation to the
  360. * expected total number of steps (see deleteMailsTotalSteps()).
  361. * @param curent progress.
  362. */
  363. void deleteMailsProgress(int progress);
  364. /**
  365. * deleteMails() might signal deleteMailsReady() if
  366. * it is not going to do something anyway.
  367. * This could be the case when an email has been succesfully
  368. * removed, or when the deletions failed. This is useful
  369. * in asynchrone situations.
  370. * @param: true if deletion was succesful; elsewise false.
  371. */
  372. void deleteMailsReady( bool );
  373. /**
  374. * readMail() might signal readMailTotalSteps() to
  375. * send the expected total number of steps to a possible
  376. * progress bar. See readMailProgress();
  377. * @param totalSteps expected total number of steps.
  378. */
  379. void readMailTotalSteps(int totalSteps);
  380. /**
  381. * readMail() might signal readMailProgress() to
  382. * send the current progress in relation to the
  383. * expected total number of steps (see readMailTotalSteps()).
  384. * @param curent progress.
  385. */
  386. void readMailProgress(int progress);
  387. /**
  388. * readMail() might signal readMailReady() if
  389. * a email is totally read. This is useful
  390. * in asynchrone situations.
  391. * @param pointer to the full email-message.
  392. */
  393. void readMailReady( TQString* );
  394. };
  395. #endif // SSK_MAILDROP_H