• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kmail

  • sources
  • kde-4.12
  • kdepim
  • kmail
kmcommands.h
Go to the documentation of this file.
1 // -*- mode: C++; c-file-style: "gnu" -*-
2 
3 #ifndef KMCommands_h
4 #define KMCommands_h
5 
6 #include "kmail_export.h"
7 #include "messagecomposer/helper/messagefactory.h"
8 #include "messagelist/core/view.h"
9 #include "search/searchpattern.h"
10 
11 #include <akonadi/kmime/messagestatus.h>
12 #include <kio/job.h>
13 #include <kmime/kmime_message.h>
14 
15 #include <QPointer>
16 #include <QList>
17 #include <akonadi/item.h>
18 #include <akonadi/itemfetchscope.h>
19 #include <akonadi/collection.h>
20 
21 using Akonadi::MessageStatus;
22 
23 class KProgressDialog;
24 class KMMainWidget;
25 
26 template <typename T> class QSharedPointer;
27 
28 namespace MessageViewer {
29 class HeaderStyle;
30 class HeaderStrategy;
31 class AttachmentStrategy;
32 }
33 
34 namespace KIO { class Job; }
35 namespace KMail {
36 class Composer;
37 }
38 namespace GpgME { class Error; }
39 namespace Kleo { class SpecialJob; }
40 
41 typedef QMap<KMime::Content*, Akonadi::Item> PartNodeMessageMap;
43 
44 class KMAIL_EXPORT KMCommand : public QObject
45 {
46  Q_OBJECT
47 
48 public:
49  enum Result { Undefined, OK, Canceled, Failed };
50 
51  // Trival constructor, don't retrieve any messages
52  explicit KMCommand( QWidget *parent = 0 );
53  KMCommand( QWidget *parent, const Akonadi::Item & );
54  // Retrieve all messages in msgList when start is called.
55  KMCommand( QWidget *parent, const QList<Akonadi::Item> &msgList );
56  // Retrieve the single message msgBase when start is called.
57  virtual ~KMCommand();
58 
59 
63  Result result() const;
64 
65 public slots:
66  // Retrieve messages then calls execute
67  void start();
68 
69 signals:
70 
72  void messagesTransfered( KMCommand::Result result );
73 
75  void completed( KMCommand *command );
76 
77 protected:
79  Akonadi::ItemFetchScope& fetchScope() { return mFetchScope; }
80 
81  // Returns list of messages retrieved
82  const QList<Akonadi::Item> retrievedMsgs() const;
83  // Returns the single message retrieved
84  Akonadi::Item retrievedMessage() const;
85  // Returns the parent widget
86  QWidget *parentWidget() const;
87 
88  bool deletesItself() const { return mDeletesItself; }
94  void setDeletesItself( bool deletesItself )
95  { mDeletesItself = deletesItself; }
96 
97  bool emitsCompletedItself() const { return mEmitsCompletedItself; }
104  void setEmitsCompletedItself( bool emitsCompletedItself )
105  { mEmitsCompletedItself = emitsCompletedItself; }
106 
110  void setResult( Result result )
111  { mResult = result; }
112 
113 private:
114  // execute should be implemented by derived classes
115  virtual Result execute() = 0;
116 
119  void transferSelectedMsgs();
120 
121 private slots:
122  void slotPostTransfer( KMCommand::Result result );
124  void slotMsgTransfered(const Akonadi::Item::List& msgs);
126  void slotJobFinished();
128  void slotTransferCancelled();
129 
130 protected:
131  QList<Akonadi::Item> mRetrievedMsgs;
132 
133 private:
134  // ProgressDialog for transferring messages
135  QWeakPointer<KProgressDialog> mProgressDialog;
136  //Currently only one async command allowed at a time
137  static int mCountJobs;
138  int mCountMsgs;
139  Result mResult;
140  bool mDeletesItself : 1;
141  bool mEmitsCompletedItself : 1;
142 
143  QWidget *mParent;
144  QList<Akonadi::Item> mMsgList;
145  Akonadi::ItemFetchScope mFetchScope;
146 };
147 
148 class KMAIL_EXPORT KMMailtoComposeCommand : public KMCommand
149 {
150  Q_OBJECT
151 
152 public:
153  explicit KMMailtoComposeCommand( const KUrl &url, const Akonadi::Item &msg=Akonadi::Item() );
154 
155 private:
156  virtual Result execute();
157 
158  KUrl mUrl;
159  Akonadi::Item mMessage;
160 };
161 
162 class KMAIL_EXPORT KMMailtoReplyCommand : public KMCommand
163 {
164  Q_OBJECT
165 
166 public:
167  KMMailtoReplyCommand( QWidget *parent, const KUrl &url,
168  const Akonadi::Item &msg, const QString &selection );
169 
170 private:
171  virtual Result execute();
172 
173  KUrl mUrl;
174  QString mSelection;
175 };
176 
177 class KMAIL_EXPORT KMMailtoForwardCommand : public KMCommand
178 {
179  Q_OBJECT
180 
181 public:
182  KMMailtoForwardCommand( QWidget *parent, const KUrl &url,const Akonadi::Item& msg );
183 
184 private:
185  virtual Result execute();
186 
187  KUrl mUrl;
188 };
189 
190 class KMAIL_EXPORT KMAddBookmarksCommand : public KMCommand
191 {
192  Q_OBJECT
193 
194 public:
195  KMAddBookmarksCommand( const KUrl &url, QWidget *parent );
196 
197 private:
198  virtual Result execute();
199 
200  KUrl mUrl;
201 };
202 
203 class KMAIL_EXPORT KMUrlSaveCommand : public KMCommand
204 {
205  Q_OBJECT
206 
207 public:
208  KMUrlSaveCommand( const KUrl &url, QWidget *parent );
209 
210 private slots:
211  void slotUrlSaveResult( KJob *job );
212 
213 private:
214  virtual Result execute();
215 
216  KUrl mUrl;
217 };
218 
219 class KMAIL_EXPORT KMEditItemCommand : public KMCommand
220 {
221  Q_OBJECT
222 
223 public:
224  explicit KMEditItemCommand( QWidget *parent, const Akonadi::Item &msg, bool deleteFromSource = true );
225  ~KMEditItemCommand();
226 private slots:
227  void slotDeleteItem( KJob *job );
228 private:
229  virtual Result execute();
230  bool mDeleteFromSource;
231 };
232 
233 class KMAIL_EXPORT KMEditMessageCommand : public KMCommand
234 {
235  Q_OBJECT
236 
237 public:
238  explicit KMEditMessageCommand( QWidget *parent, const KMime::Message::Ptr& msg );
239 private:
240  virtual Result execute();
241  KMime::Message::Ptr mMessage;
242 };
243 
244 class KMAIL_EXPORT KMUseTemplateCommand : public KMCommand
245 {
246  Q_OBJECT
247 
248 public:
249  KMUseTemplateCommand( QWidget *parent, const Akonadi::Item &msg );
250 
251 private:
252  virtual Result execute();
253 };
254 
255 class KMAIL_EXPORT KMSaveMsgCommand : public KMCommand
256 {
257  Q_OBJECT
258 
259 public:
260  KMSaveMsgCommand( QWidget *parent, const QList<Akonadi::Item> &msgList );
261 
262 private:
263  virtual Result execute();
264 
265 };
266 
267 class KMAIL_EXPORT KMOpenMsgCommand : public KMCommand
268 {
269  Q_OBJECT
270 
271 public:
272  explicit KMOpenMsgCommand(QWidget *parent, const KUrl & url = KUrl(),
273  const QString & encoding = QString() , KMMainWidget *main = 0);
274 
275 private:
276  virtual Result execute();
277 
278 private slots:
279  void slotDataArrived( KIO::Job *job, const QByteArray & data );
280  void slotResult( KJob *job );
281 
282 private:
283  void doesNotContainMessage();
284  static const int MAX_CHUNK_SIZE = 64*1024;
285  KUrl mUrl;
286  QString mMsgString;
287  KIO::TransferJob *mJob;
288  const QString mEncoding;
289  KMMainWidget *mMainWidget;
290 };
291 
292 class KMAIL_EXPORT KMSaveAttachmentsCommand : public KMCommand
293 {
294  Q_OBJECT
295 public:
300  KMSaveAttachmentsCommand( QWidget *parent, const Akonadi::Item &msg );
305  KMSaveAttachmentsCommand( QWidget *parent, const QList<Akonadi::Item>& msgs );
306 
307 private:
308  virtual Result execute();
309 };
310 
311 
312 class KMAIL_EXPORT KMReplyCommand : public KMCommand
313 {
314  Q_OBJECT
315 public:
316  KMReplyCommand( QWidget *parent, const Akonadi::Item &msg,
317  MessageComposer::ReplyStrategy replyStrategy,
318  const QString &selection = QString(), bool noquote = false, const QString & templateName = QString());
319 private:
320  virtual Result execute();
321 
322 private:
323  QString mSelection;
324  QString mTemplate;
325  MessageComposer::ReplyStrategy m_replyStrategy;
326  bool mNoQuote;
327 };
328 
329 class KMAIL_EXPORT KMForwardCommand : public KMCommand
330 {
331  Q_OBJECT
332 
333 public:
334  KMForwardCommand( QWidget *parent, const QList<Akonadi::Item> &msgList,
335  uint identity = 0, const QString& templateName = QString() );
336  KMForwardCommand( QWidget *parent, const Akonadi::Item& msg,
337  uint identity = 0, const QString& templateName =QString());
338 
339 private:
340  KMCommand::Result createComposer(const Akonadi::Item& item);
341  virtual Result execute();
342 
343 private:
344  uint mIdentity;
345  QString mTemplate;
346 };
347 
348 class KMAIL_EXPORT KMForwardAttachedCommand : public KMCommand
349 {
350  Q_OBJECT
351 
352 public:
353  KMForwardAttachedCommand( QWidget *parent, const QList<Akonadi::Item> &msgList,
354  uint identity = 0, KMail::Composer *win = 0 );
355  KMForwardAttachedCommand( QWidget *parent, const Akonadi::Item & msg,
356  uint identity = 0, KMail::Composer *win = 0 );
357 
358 private:
359  virtual Result execute();
360 
361  uint mIdentity;
362  QPointer<KMail::Composer> mWin;
363 };
364 
365 class KMAIL_EXPORT KMRedirectCommand : public KMCommand
366 {
367  Q_OBJECT
368 
369 public:
370  KMRedirectCommand( QWidget *parent, const Akonadi::Item &msg );
371  KMRedirectCommand( QWidget *parent, const QList<Akonadi::Item> &msgList );
372 
373 private:
374  virtual Result execute();
375 };
376 
377 class KMAIL_EXPORT KMPrintCommand : public KMCommand
378 {
379  Q_OBJECT
380 
381 public:
382  KMPrintCommand( QWidget *parent, const Akonadi::Item &msg,
383  MessageViewer::HeaderStyle *headerStyle = 0,
384  MessageViewer::HeaderStrategy *headerStrategy = 0,
385  bool htmlOverride = false,
386  bool htmlLoadExtOverride = false,
387  bool useFixedFont = false,
388  const QString & encoding = QString() );
389 
390  void setOverrideFont( const QFont& );
391  void setAttachmentStrategy( const MessageViewer::AttachmentStrategy *strategy );
392  void setPrintPreview( bool preview );
393 
394 private:
395  virtual Result execute();
396 
397  MessageViewer::HeaderStyle *mHeaderStyle;
398  MessageViewer::HeaderStrategy *mHeaderStrategy;
399  const MessageViewer::AttachmentStrategy *mAttachmentStrategy;
400  QFont mOverrideFont;
401  QString mEncoding;
402  bool mHtmlOverride;
403  bool mHtmlLoadExtOverride;
404  bool mUseFixedFont;
405  bool mPrintPreview;
406 };
407 
408 class KMAIL_EXPORT KMSetStatusCommand : public KMCommand
409 {
410  Q_OBJECT
411 
412 public:
413  // Serial numbers
414  KMSetStatusCommand( const MessageStatus& status, const Akonadi::Item::List &items,
415  bool invert=false );
416 
417 protected slots:
418  void slotModifyItemDone( KJob * job );
419 
420 private:
421  virtual Result execute();
422  MessageStatus mStatus;
423  bool mInvertMark;
424 };
425 
429 class KMAIL_EXPORT KMSetTagCommand : public KMCommand
430 {
431  Q_OBJECT
432 
433 public:
434  enum SetTagMode { AddIfNotExisting, Toggle, CleanExistingAndAddNew };
435 
436  KMSetTagCommand( const QList<QString> &tagLabel, const QList<Akonadi::Item> &item,
437  SetTagMode mode=AddIfNotExisting );
438 
439 private:
440  virtual Result execute();
441 
442  QList<QString> mTagLabel;
443  QList<Akonadi::Item> mItem;
444  SetTagMode mMode;
445 };
446 
447 /* This command is used to apply a single filter (AKA ad-hoc filter)
448  to a set of messages */
449 class KMAIL_EXPORT KMFilterActionCommand : public KMCommand
450 {
451  Q_OBJECT
452 
453 public:
454  KMFilterActionCommand(QWidget *parent,
455  const QVector<qlonglong> &msgListId, const QString &filterId);
456 
457 private:
458  virtual Result execute();
459  QVector<qlonglong> mMsgListId;
460  QString mFilterId;
461 };
462 
463 
464 class KMAIL_EXPORT KMMetaFilterActionCommand : public QObject
465 {
466  Q_OBJECT
467 
468 public:
469  KMMetaFilterActionCommand( const QString &filterId, KMMainWidget *main );
470 
471 public slots:
472  void start();
473 
474 private:
475  QString mFilterId;
476  KMMainWidget *mMainWidget;
477 };
478 
479 
480 class KMAIL_EXPORT KMMailingListFilterCommand : public KMCommand
481 {
482  Q_OBJECT
483 
484 public:
485  KMMailingListFilterCommand( QWidget *parent, const Akonadi::Item &msg );
486 
487 private:
488  virtual Result execute();
489 };
490 
491 
492 class KMAIL_EXPORT KMCopyCommand : public KMCommand
493 {
494  Q_OBJECT
495 
496 public:
497  KMCopyCommand( const Akonadi::Collection &destFolder, const QList<Akonadi::Item> &msgList );
498  KMCopyCommand( const Akonadi::Collection& destFolder, const Akonadi::Item &msg );
499 
500 protected slots:
501  void slotCopyResult( KJob * job );
502 private:
503  virtual Result execute();
504 
505  Akonadi::Collection mDestFolder;
506 };
507 
508 namespace KPIM {
509 class ProgressItem;
510 }
511 class KMAIL_EXPORT KMMoveCommand : public KMCommand
512 {
513  Q_OBJECT
514 
515 public:
516  KMMoveCommand( const Akonadi::Collection& destFolder, const QList<Akonadi::Item> &msgList, MessageList::Core::MessageItemSetReference ref );
517  KMMoveCommand( const Akonadi::Collection& destFolder, const Akonadi::Item & msg, MessageList::Core::MessageItemSetReference ref = MessageList::Core::MessageItemSetReference() );
518  Akonadi::Collection destFolder() const { return mDestFolder; }
519 
520  MessageList::Core::MessageItemSetReference refSet() const { return mRef; }
521 
522 public slots:
523  void slotMoveCanceled();
524  void slotMoveResult( KJob * job );
525 protected:
526  void setDestFolder( const Akonadi::Collection& folder ) { mDestFolder = folder; }
527 
528 signals:
529  void moveDone( KMMoveCommand* );
530 
531 private:
532  virtual Result execute();
533  void completeMove( Result result );
534 
535  Akonadi::Collection mDestFolder;
536  KPIM::ProgressItem *mProgressItem;
537  MessageList::Core::MessageItemSetReference mRef;
538 };
539 
540 class KMAIL_EXPORT KMTrashMsgCommand : public KMMoveCommand
541 {
542  Q_OBJECT
543 
544 public:
545  KMTrashMsgCommand( const Akonadi::Collection& srcFolder, const QList<Akonadi::Item> &msgList,MessageList::Core::MessageItemSetReference ref );
546  KMTrashMsgCommand( const Akonadi::Collection& srcFolder, const Akonadi::Item& msg,MessageList::Core::MessageItemSetReference ref );
547 
548 private:
549  static Akonadi::Collection findTrashFolder( const Akonadi::Collection& srcFolder );
550 
551 };
552 
553 class KMAIL_EXPORT KMResendMessageCommand : public KMCommand
554 {
555  Q_OBJECT
556 
557 public:
558  explicit KMResendMessageCommand( QWidget *parent, const Akonadi::Item & msg= Akonadi::Item() );
559 
560 private:
561  virtual Result execute();
562 };
563 
564 class KMAIL_EXPORT KMShareImageCommand : public KMCommand
565 {
566  Q_OBJECT
567 
568 public:
569  explicit KMShareImageCommand(const KUrl &url, QWidget *parent);
570 
571 private:
572  virtual Result execute();
573  KUrl mUrl;
574 };
575 
576 
577 #endif /*KMCommands_h*/
KMReplyCommand
Definition: kmcommands.h:312
QSharedPointer
Definition: collectionmailinglistpage.h:34
KMCommand::deletesItself
bool deletesItself() const
Definition: kmcommands.h:88
KMAddBookmarksCommand
Definition: kmcommands.h:190
KMMailtoComposeCommand
Definition: kmcommands.h:148
kmail_export.h
KMTrashMsgCommand
Definition: kmcommands.h:540
KMMailtoReplyCommand
Definition: kmcommands.h:162
KMUseTemplateCommand
Definition: kmcommands.h:244
KMSetTagCommand
This command is used to set or toggle a tag for a list of messages.
Definition: kmcommands.h:429
QWidget
KMMailingListFilterCommand
Definition: kmcommands.h:480
KMMoveCommand
Definition: kmcommands.h:511
KMFilterActionCommand
Definition: kmcommands.h:449
KMCommand::setResult
void setResult(Result result)
Use this to set the result of the command.
Definition: kmcommands.h:110
QObject
KMail::Composer
Definition: composer.h:37
KMMoveCommand::destFolder
Akonadi::Collection destFolder() const
Definition: kmcommands.h:518
KMMoveCommand::setDestFolder
void setDestFolder(const Akonadi::Collection &folder)
Definition: kmcommands.h:526
KMSetTagCommand::Toggle
Definition: kmcommands.h:434
KMMetaFilterActionCommand
Definition: kmcommands.h:464
KMSaveAttachmentsCommand
Definition: kmcommands.h:292
KMCommand
Small helper structure which encapsulates the KMMessage created when creating a reply, and.
Definition: kmcommands.h:44
PartNodeMessageMap
QMap< KMime::Content *, Akonadi::Item > PartNodeMessageMap
Definition: kmcommands.h:41
KMCommand::setDeletesItself
void setDeletesItself(bool deletesItself)
Specify whether the subclass takes care of the deletion of the object.
Definition: kmcommands.h:94
KMMoveCommand::refSet
MessageList::Core::MessageItemSetReference refSet() const
Definition: kmcommands.h:520
KMCommand::setEmitsCompletedItself
void setEmitsCompletedItself(bool emitsCompletedItself)
Specify whether the subclass takes care of emitting the completed() signal.
Definition: kmcommands.h:104
KMMailtoForwardCommand
Definition: kmcommands.h:177
KMMainWidget
Definition: kmmainwidget.h:83
KMForwardAttachedCommand
Definition: kmcommands.h:348
KMOpenMsgCommand
Definition: kmcommands.h:267
KMUrlSaveCommand
Definition: kmcommands.h:203
KMForwardCommand
Definition: kmcommands.h:329
KMAIL_EXPORT
#define KMAIL_EXPORT
Definition: kmail_export.h:35
KMCommand::emitsCompletedItself
bool emitsCompletedItself() const
Definition: kmcommands.h:97
KMCommand::Undefined
Definition: kmcommands.h:49
KMSetStatusCommand
Definition: kmcommands.h:408
KMCommand::fetchScope
Akonadi::ItemFetchScope & fetchScope()
Allows to configure how much data should be retrieved of the messages.
Definition: kmcommands.h:79
KPIM::ProgressItem
KMPrintCommand
Definition: kmcommands.h:377
KMEditItemCommand
Definition: kmcommands.h:219
main
int main(int argc, char *argv[])
Definition: main.cpp:97
KMSaveMsgCommand
Definition: kmcommands.h:255
KMSetTagCommand::SetTagMode
SetTagMode
Definition: kmcommands.h:434
KMResendMessageCommand
Definition: kmcommands.h:553
KMRedirectCommand
Definition: kmcommands.h:365
KMCommand::Result
Result
Definition: kmcommands.h:49
KJob
QMap
Definition: kmmainwidget.h:58
KMShareImageCommand
Definition: kmcommands.h:564
KMCopyCommand
Definition: kmcommands.h:492
QList< Akonadi::Item >
KMCommand::mRetrievedMsgs
QList< Akonadi::Item > mRetrievedMsgs
Definition: kmcommands.h:131
KMEditMessageCommand
Definition: kmcommands.h:233
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal