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

kmail

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

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