• 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.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  This file is part of KMail, the KDE mail client.
3  Copyright (c) 2002 Don Sanders <sanders@kde.org>
4  Copyright (c) 2013 Laurent Montel <montel@kde.org>
5 
6  KMail is free software; you can redistribute it and/or modify it
7  under the terms of the GNU General Public License, version 2, as
8  published by the Free Software Foundation.
9 
10  KMail is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  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 //
21 // This file implements various "command" classes. These command classes
22 // are based on the command design pattern.
23 //
24 // Historically various operations were implemented as slots of KMMainWin.
25 // This proved inadequate as KMail has multiple top level windows
26 // (KMMainWin, KMReaderMainWin, SearchWindow, KMComposeWin) that may
27 // benefit from using these operations. It is desirable that these
28 // classes can operate without depending on or altering the state of
29 // a KMMainWin, in fact it is possible no KMMainWin object even exists.
30 //
31 // Now these operations have been rewritten as KMCommand based classes,
32 // making them independent of KMMainWin.
33 //
34 // The base command class KMCommand is async, which is a difference
35 // from the conventional command pattern. As normal derived classes implement
36 // the execute method, but client classes call start() instead of
37 // calling execute() directly. start() initiates async operations,
38 // and on completion of these operations calls execute() and then deletes
39 // the command. (So the client must not construct commands on the stack).
40 //
41 // The type of async operation supported by KMCommand is retrieval
42 // of messages from an IMAP server.
43 
44 #include "kmcommands.h"
45 
46 #include <Nepomuk2/Tag>
47 #include <nepomuk2/resource.h>
48 
49 #include "widgets/collectionpane.h"
50 #include "kernel/mailkernel.h"
51 #include "util/mailutil.h"
52 
53 #include <unistd.h> // link()
54 #include <kprogressdialog.h>
55 #include <kpimutils/email.h>
56 #include <kdbusservicestarter.h>
57 #include <kdebug.h>
58 #include <kfiledialog.h>
59 #include <klocale.h>
60 #include <kmessagebox.h>
61 #include <kbookmarkmanager.h>
62 #include <kstandarddirs.h>
63 #include <ktemporaryfile.h>
64 // KIO headers
65 #include <kio/job.h>
66 #include <kio/jobuidelegate.h>
67 #include <kio/netaccess.h>
68 
69 #include <kmime/kmime_message.h>
70 
71 #include <kpimidentities/identitymanager.h>
72 #include <akonadi/itemmodifyjob.h>
73 #include <akonadi/itemfetchjob.h>
74 
75 
76 #include "foldercollection.h"
77 
78 #include "messagecore/misc/mailinglist.h"
79 #include "editor/composer.h"
80 #include "mailcommon/filter/filteraction.h"
81 #include "mailcommon/filter/filtermanager.h"
82 #include "mailcommon/filter/mailfilter.h"
83 #include "mailcommon/widgets/redirectdialog.h"
84 #include "kmmainwidget.h"
85 #include "undostack.h"
86 #ifndef QT_NO_CURSOR
87 #include "messageviewer/utils/kcursorsaver.h"
88 #endif
89 #include "messageviewer/viewer/objecttreeparser.h"
90 #include "messageviewer/viewer/csshelper.h"
91 #include "messageviewer/utils/util.h"
92 #include "messageviewer/viewer/mailsourceviewer.h"
93 #include "messageviewer/viewer/viewer.h"
94 #include "messageviewer/header/headerstrategy.h"
95 #include "messageviewer/header/headerstyle.h"
96 #include "kmreadermainwin.h"
97 #include "secondarywindow.h"
98 using KMail::SecondaryWindow;
99 #include "util.h"
100 #include "misc/broadcaststatus.h"
101 #include "settings/globalsettings.h"
102 #include "utils/stringutil.h"
103 #include "messageviewer/utils/autoqpointer.h"
104 #include "messageviewer/settings/globalsettings.h"
105 #include "messagecore/settings/globalsettings.h"
106 
107 #include <kpimutils/kfileio.h>
108 
109 #include <akonadi/itemmovejob.h>
110 #include <akonadi/itemcopyjob.h>
111 #include <akonadi/itemdeletejob.h>
112 #include <mailtransport/transportattribute.h>
113 #include <mailtransport/sentbehaviourattribute.h>
114 
115 #include <messagelist/pane.h>
116 
117 #include <mailtransport/transportmanager.h>
118 using MailTransport::TransportManager;
119 
120 
121 #include "messageviewer/viewer/nodehelper.h"
122 #include "messageviewer/viewer/objecttreeemptysource.h"
123 
124 #include "messagecore/utils/stringutil.h"
125 #include "messagecore/helpers/messagehelpers.h"
126 
127 #include "messagecomposer/sender/messagesender.h"
128 #include "messagecomposer/helper/messagehelper.h"
129 #include "messagecomposer/settings/messagecomposersettings.h"
130 #include "messagecomposer/helper/messagefactory.h"
131 using MessageComposer::MessageFactory;
132 
133 
134 #include "progresswidget/progressmanager.h"
135 using KPIM::ProgressManager;
136 using KPIM::ProgressItem;
137 #include <kmime/kmime_mdn.h>
138 using namespace KMime;
139 
140 #include "kleo/cryptobackend.h"
141 #include "kleo/cryptobackendfactory.h"
142 
143 #include <gpgme++/error.h>
144 
145 #include <QDBusConnection>
146 #include <QByteArray>
147 #include <QApplication>
148 #include <QList>
149 
150 #include <boost/bind.hpp>
151 #include <algorithm>
152 #include <memory>
153 
154 
155 using namespace MailCommon;
156 
158 static KMail::Composer::TemplateContext replyContext( MessageFactory::MessageReply reply )
159 {
160  if ( reply.replyAll )
161  return KMail::Composer::ReplyToAll;
162  else
163  return KMail::Composer::Reply;
164 }
165 
167 static void showJobError( KJob* job )
168 {
169  assert(job);
170  // we can be called from the KJob::kill, where we are no longer a KIO::Job
171  // so better safe than sorry
172  KIO::Job* kiojob = dynamic_cast<KIO::Job*>(job);
173  if( kiojob && kiojob->ui() )
174  kiojob->ui()->showErrorMessage();
175  else
176  kWarning() << "There is no GUI delegate set for a kjob, and it failed with error:" << job->errorString();
177 }
178 
179 KMCommand::KMCommand( QWidget *parent )
180  : mCountMsgs(0), mResult( Undefined ), mDeletesItself( false ),
181  mEmitsCompletedItself( false ), mParent( parent )
182 {
183 }
184 
185 KMCommand::KMCommand( QWidget *parent, const Akonadi::Item &msg )
186  : mCountMsgs(0), mResult( Undefined ), mDeletesItself( false ),
187  mEmitsCompletedItself( false ), mParent( parent )
188 {
189  if ( msg.isValid() || msg.hasPayload<KMime::Message::Ptr>() ) {
190  mMsgList.append( msg );
191  }
192 }
193 
194 KMCommand::KMCommand( QWidget *parent, const QList<Akonadi::Item> &msgList )
195  : mCountMsgs(0), mResult( Undefined ), mDeletesItself( false ),
196  mEmitsCompletedItself( false ), mParent( parent )
197 {
198  mMsgList = msgList;
199 }
200 
201 
202 
203 KMCommand::~KMCommand()
204 {
205 }
206 
207 KMCommand::Result KMCommand::result() const
208 {
209  if ( mResult == Undefined ) {
210  kDebug() << "mResult is Undefined";
211  }
212  return mResult;
213 }
214 
215 const QList<Akonadi::Item> KMCommand::retrievedMsgs() const
216 {
217  return mRetrievedMsgs;
218 }
219 
220 Akonadi::Item KMCommand::retrievedMessage() const
221 {
222  if ( mRetrievedMsgs.isEmpty() )
223  return Akonadi::Item();
224  return *(mRetrievedMsgs.begin());
225 }
226 
227 QWidget *KMCommand::parentWidget() const
228 {
229  return mParent;
230 }
231 
232 int KMCommand::mCountJobs = 0;
233 
234 void KMCommand::start()
235 {
236  connect( this, SIGNAL(messagesTransfered(KMCommand::Result)),
237  this, SLOT(slotPostTransfer(KMCommand::Result)) );
238 
239  if ( mMsgList.isEmpty() ) {
240  emit messagesTransfered( OK );
241  return;
242  }
243 
244  // Special case of operating on message that isn't in a folder
245  const Akonadi::Item mb = mMsgList.first();
246  if ( ( mMsgList.count() == 1 ) && MessageCore::Util::isStandaloneMessage( mb ) ) {
247  mRetrievedMsgs.append(mMsgList.takeFirst());
248  emit messagesTransfered( OK );
249  return;
250  }
251 
252  // we can only retrieve items with a valid id
253  foreach ( const Akonadi::Item &item, mMsgList ) {
254  if ( !item.isValid() ) {
255  emit messagesTransfered( Failed );
256  return;
257  }
258  }
259 
260  // transfer the selected messages first
261  transferSelectedMsgs();
262 }
263 
264 void KMCommand::slotPostTransfer( KMCommand::Result result )
265 {
266  disconnect( this, SIGNAL(messagesTransfered(KMCommand::Result)),
267  this, SLOT(slotPostTransfer(KMCommand::Result)) );
268  if ( result == OK ) {
269  result = execute();
270  }
271  mResult = result;
272  if ( !emitsCompletedItself() )
273  emit completed( this );
274  if ( !deletesItself() )
275  deleteLater();
276 }
277 
278 void KMCommand::transferSelectedMsgs()
279 {
280  // make sure no other transfer is active
281  if (KMCommand::mCountJobs > 0) {
282  emit messagesTransfered( Failed );
283  return;
284  }
285 
286  bool complete = true;
287  KMCommand::mCountJobs = 0;
288  mCountMsgs = 0;
289  mRetrievedMsgs.clear();
290  mCountMsgs = mMsgList.count();
291  uint totalSize = 0;
292  // the KProgressDialog for the user-feedback. Only enable it if it's needed.
293  // For some commands like KMSetStatusCommand it's not needed. Note, that
294  // for some reason the KProgressDialog eats the MouseReleaseEvent (if a
295  // command is executed after the MousePressEvent), cf. bug #71761.
296  if ( mCountMsgs > 0 ) {
297  mProgressDialog = new KProgressDialog(mParent,
298  i18n("Please wait"),
299  i18np("Please wait while the message is transferred",
300  "Please wait while the %1 messages are transferred", mMsgList.count()));
301  mProgressDialog.data()->setModal(true);
302  mProgressDialog.data()->setMinimumDuration(1000);
303  }
304 
305  // TODO once the message list is based on ETM and we get the more advanced caching we need to make that check a bit more clever
306  if ( !mFetchScope.isEmpty() ) {
307  complete = false;
308  KMCommand::mCountJobs++;
309  Akonadi::ItemFetchJob *fetch = new Akonadi::ItemFetchJob( mMsgList, this );
310  mFetchScope.fetchAttribute< MessageCore::MDNStateAttribute >();
311  fetch->setFetchScope( mFetchScope );
312  connect( fetch, SIGNAL(itemsReceived(Akonadi::Item::List)), SLOT(slotMsgTransfered(Akonadi::Item::List)) );
313  connect( fetch, SIGNAL(result(KJob*)), SLOT(slotJobFinished()) );
314  } else {
315  // no need to fetch anything
316  if ( !mMsgList.isEmpty() )
317  mRetrievedMsgs = mMsgList;
318  }
319 
320  if ( complete ) {
321  delete mProgressDialog.data();
322  mProgressDialog.clear();
323  emit messagesTransfered( OK );
324  } else {
325  // wait for the transfer and tell the progressBar the necessary steps
326  if ( mProgressDialog.data() ) {
327  connect(mProgressDialog.data(), SIGNAL(cancelClicked()),
328  this, SLOT(slotTransferCancelled()));
329  mProgressDialog.data()->progressBar()->setMaximum(totalSize);
330  }
331  }
332 }
333 
334 void KMCommand::slotMsgTransfered(const Akonadi::Item::List& msgs)
335 {
336  if ( mProgressDialog.data() && mProgressDialog.data()->wasCancelled() ) {
337  emit messagesTransfered( Canceled );
338  return;
339  }
340  // save the complete messages
341  mRetrievedMsgs.append( msgs );
342 }
343 
344 void KMCommand::slotJobFinished()
345 {
346  // the job is finished (with / without error)
347  KMCommand::mCountJobs--;
348 
349  if ( mProgressDialog.data() && mProgressDialog.data()->wasCancelled() ) return;
350 
351  if ( mCountMsgs > mRetrievedMsgs.count() )
352  {
353  // the message wasn't retrieved before => error
354  if ( mProgressDialog.data() )
355  mProgressDialog.data()->hide();
356  slotTransferCancelled();
357  return;
358  }
359  // update the progressbar
360  if ( mProgressDialog.data() ) {
361  mProgressDialog.data()->setLabelText(i18np("Please wait while the message is transferred",
362  "Please wait while the %1 messages are transferred", KMCommand::mCountJobs));
363  }
364  if (KMCommand::mCountJobs == 0)
365  {
366  // all done
367  delete mProgressDialog.data();
368  mProgressDialog.clear();
369  emit messagesTransfered( OK );
370  }
371 }
372 
373 void KMCommand::slotTransferCancelled()
374 {
375  KMCommand::mCountJobs = 0;
376  mCountMsgs = 0;
377  mRetrievedMsgs.clear();
378  emit messagesTransfered( Canceled );
379 }
380 
381 
382 KMMailtoComposeCommand::KMMailtoComposeCommand( const KUrl &url,
383  const Akonadi::Item &msg )
384  :mUrl( url ), mMessage( msg )
385 {
386 }
387 
388 KMCommand::Result KMMailtoComposeCommand::execute()
389 {
390  KMime::Message::Ptr msg( new KMime::Message );
391  uint id = 0;
392 
393  if ( mMessage.isValid() && mMessage.parentCollection().isValid() ) {
394  QSharedPointer<FolderCollection> fd = FolderCollection::forCollection( mMessage.parentCollection(), false );
395  id = fd->identity();
396  }
397 
398  MessageHelper::initHeader( msg, KMKernel::self()->identityManager(),id );
399  msg->contentType()->setCharset("utf-8");
400  msg->to()->fromUnicodeString( KPIMUtils::decodeMailtoUrl( mUrl ), "utf-8" );
401 
402  KMail::Composer * win = KMail::makeComposer( msg, false, false,KMail::Composer::New, id );
403  win->setFocusToSubject();
404  win->show();
405  return OK;
406 }
407 
408 
409 KMMailtoReplyCommand::KMMailtoReplyCommand( QWidget *parent,
410  const KUrl &url, const Akonadi::Item &msg, const QString &selection )
411  :KMCommand( parent, msg ), mUrl( url ), mSelection( selection )
412 {
413  fetchScope().fetchFullPayload( true );
414  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
415 }
416 
417 KMCommand::Result KMMailtoReplyCommand::execute()
418 {
419  Akonadi::Item item = retrievedMessage();
420  KMime::Message::Ptr msg = MessageCore::Util::message( item );
421  if ( !msg )
422  return Failed;
423  MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
424  factory.setIdentityManager( KMKernel::self()->identityManager() );
425  factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
426  factory.setMailingListAddresses( KMail::Util::mailingListsFromMessage( item ) );
427  factory.putRepliesInSameFolder( KMail::Util::putRepliesInSameFolder( item ) );
428  factory.setReplyStrategy( MessageComposer::ReplyNone );
429  factory.setSelection( mSelection );
430  KMime::Message::Ptr rmsg = factory.createReply().msg;
431  rmsg->to()->fromUnicodeString( KPIMUtils::decodeMailtoUrl( mUrl ), "utf-8" ); //TODO Check the UTF-8
432  bool lastEncrypt = false;
433  bool lastSign = false;
434  KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
435 
436  KMail::Composer * win = KMail::makeComposer( rmsg, lastSign, lastEncrypt, KMail::Composer::Reply, 0, mSelection );
437  win->setFocusToEditor();
438  win->show();
439 
440  return OK;
441 }
442 
443 
444 KMMailtoForwardCommand::KMMailtoForwardCommand( QWidget *parent,
445  const KUrl &url, const Akonadi::Item &msg )
446  :KMCommand( parent, msg ), mUrl( url )
447 {
448  fetchScope().fetchFullPayload( true );
449  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
450 }
451 
452 KMCommand::Result KMMailtoForwardCommand::execute()
453 {
454  //TODO : consider factoring createForward into this method.
455  Akonadi::Item item = retrievedMessage();
456  KMime::Message::Ptr msg = MessageCore::Util::message( item );
457  if ( !msg )
458  return Failed;
459  MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
460  factory.setIdentityManager( KMKernel::self()->identityManager() );
461  factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
462  KMime::Message::Ptr fmsg = factory.createForward();
463  fmsg->to()->fromUnicodeString( KPIMUtils::decodeMailtoUrl( mUrl ).toLower(), "utf-8" ); //TODO check the utf-8
464  bool lastEncrypt = false;
465  bool lastSign = false;
466  KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
467 
468  KMail::Composer * win = KMail::makeComposer( fmsg, lastSign, lastEncrypt, KMail::Composer::Forward );
469  win->show();
470 
471  return OK;
472 }
473 
474 
475 KMAddBookmarksCommand::KMAddBookmarksCommand( const KUrl &url, QWidget *parent )
476  : KMCommand( parent ), mUrl( url )
477 {
478 }
479 
480 KMCommand::Result KMAddBookmarksCommand::execute()
481 {
482  const QString filename = KStandardDirs::locateLocal( "data", QString::fromLatin1("konqueror/bookmarks.xml") );
483  KBookmarkManager *bookManager = KBookmarkManager::managerForFile( filename, QLatin1String("konqueror") );
484  KBookmarkGroup group = bookManager->root();
485  group.addBookmark( mUrl.path(), KUrl( mUrl ) );
486  if( bookManager->save() ) {
487  bookManager->emitChanged( group );
488  }
489 
490  return OK;
491 }
492 
493 KMUrlSaveCommand::KMUrlSaveCommand( const KUrl &url, QWidget *parent )
494  : KMCommand( parent ), mUrl( url )
495 {
496 }
497 
498 KMCommand::Result KMUrlSaveCommand::execute()
499 {
500  if ( mUrl.isEmpty() )
501  return OK;
502  const KUrl saveUrl = KFileDialog::getSaveUrl(mUrl.fileName(), QString(),
503  parentWidget() );
504  if ( saveUrl.isEmpty() )
505  return Canceled;
506  if ( KIO::NetAccess::exists( saveUrl, KIO::NetAccess::DestinationSide, parentWidget() ) )
507  {
508  if (KMessageBox::warningContinueCancel(0,
509  i18nc("@info", "File <filename>%1</filename> exists.<nl/>Do you want to replace it?",
510  saveUrl.pathOrUrl()), i18n("Save to File"), KGuiItem(i18n("&Replace")))
511  != KMessageBox::Continue)
512  return Canceled;
513  }
514  KIO::Job *job = KIO::file_copy(mUrl, saveUrl, -1, KIO::Overwrite);
515  connect(job, SIGNAL(result(KJob*)), SLOT(slotUrlSaveResult(KJob*)));
516  setEmitsCompletedItself( true );
517  return OK;
518 }
519 
520 void KMUrlSaveCommand::slotUrlSaveResult( KJob *job )
521 {
522  if ( job->error() ) {
523  showJobError(job);
524  setResult( Failed );
525  emit completed( this );
526  }
527  else {
528  setResult( OK );
529  emit completed( this );
530  }
531 }
532 
533 KMEditMessageCommand::KMEditMessageCommand( QWidget *parent, const KMime::Message::Ptr& msg )
534  :KMCommand( parent ), mMessage( msg )
535 {
536 }
537 
538 KMCommand::Result KMEditMessageCommand::execute()
539 {
540  if ( !mMessage )
541  return Failed;
542 
543  KMail::Composer *win = KMail::makeComposer();
544  bool lastEncrypt = false;
545  bool lastSign = false;
546  KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, mMessage);
547  win->setMessage( mMessage, lastSign, lastEncrypt, false, false );
548  win->show();
549  win->setModified( true );
550  return OK;
551 }
552 
553 
554 KMEditItemCommand::KMEditItemCommand( QWidget *parent, const Akonadi::Item&msg, bool deleteFromSource )
555  :KMCommand( parent, msg )
556  , mDeleteFromSource( deleteFromSource )
557 {
558  fetchScope().fetchFullPayload( true );
559  fetchScope().fetchAttribute<MailTransport::TransportAttribute>();
560  fetchScope().fetchAttribute<MailTransport::SentBehaviourAttribute>();
561  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
562 }
563 
564 KMEditItemCommand::~KMEditItemCommand()
565 {
566 }
567 
568 
569 KMCommand::Result KMEditItemCommand::execute()
570 {
571  Akonadi::Item item = retrievedMessage();
572  if (!item.isValid() || !item.parentCollection().isValid() ) {
573  return Failed;
574  }
575  KMime::Message::Ptr msg = MessageCore::Util::message( item );
576  if ( !msg ) {
577  return Failed;
578  }
579 
580  if ( mDeleteFromSource ) {
581  setDeletesItself( true );
582  Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob( item );
583  connect( job, SIGNAL(result(KJob*)), this, SLOT(slotDeleteItem(KJob*)) );
584  }
585  KMail::Composer *win = KMail::makeComposer();
586  bool lastEncrypt = false;
587  bool lastSign = false;
588  KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
589  win->setMessage( msg, lastSign, lastEncrypt, false, true );
590 
591  win->setFolder( item.parentCollection() );
592 
593  const MailTransport::TransportAttribute *transportAttribute = item.attribute<MailTransport::TransportAttribute>();
594  if ( transportAttribute ) {
595  win->setCurrentTransport( transportAttribute->transportId() );
596  } else {
597  int transportId = msg->headerByType( "X-KMail-Transport" ) ? msg->headerByType( "X-KMail-Transport" )->asUnicodeString().toInt() : -1;
598  if(transportId!=-1) {
599  win->setCurrentTransport( transportId );
600  }
601  }
602 
603 
604  if(msg->headerByType( "Reply-To" )) {
605  const QString replyTo = msg->headerByType( "Reply-To" )->asUnicodeString();
606  win->setCurrentReplyTo(replyTo);
607  }
608 
609  const MailTransport::SentBehaviourAttribute *sentAttribute = item.attribute<MailTransport::SentBehaviourAttribute>();
610  if ( sentAttribute && ( sentAttribute->sentBehaviour() == MailTransport::SentBehaviourAttribute::MoveToCollection ) )
611  win->setFcc( QString::number( sentAttribute->moveToCollection().id() ) );
612  win->show();
613  if ( mDeleteFromSource )
614  win->setModified( true );
615 
616  return OK;
617 }
618 
619 void KMEditItemCommand::slotDeleteItem( KJob *job )
620 {
621  if ( job->error() ) {
622  showJobError(job);
623  setResult( Failed );
624  emit completed( this );
625  }
626  else {
627  setResult( OK );
628  emit completed( this );
629  }
630  deleteLater( );
631 }
632 
633 KMUseTemplateCommand::KMUseTemplateCommand( QWidget *parent, const Akonadi::Item &msg )
634  :KMCommand( parent, msg )
635 {
636  fetchScope().fetchFullPayload( true );
637  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
638 }
639 
640 KMCommand::Result KMUseTemplateCommand::execute()
641 {
642  Akonadi::Item item = retrievedMessage();
643  if ( !item.isValid()
644  || !item.parentCollection().isValid() ||
645  !CommonKernel->folderIsTemplates( item.parentCollection() )
646  ) {
647  return Failed;
648  }
649  KMime::Message::Ptr msg = MessageCore::Util::message( item );
650  if ( !msg )
651  return Failed;
652 
653  KMime::Message::Ptr newMsg(new KMime::Message);
654  newMsg->setContent( msg->encodedContent() );
655  newMsg->parse();
656  // these fields need to be regenerated for the new message
657  newMsg->removeHeader("Date");
658  newMsg->removeHeader("Message-ID");
659 
660  KMail::Composer *win = KMail::makeComposer();
661 
662  win->setMessage( newMsg, false, false, false, true );
663  win->show();
664  return OK;
665 }
666 
667 KMSaveMsgCommand::KMSaveMsgCommand( QWidget *parent, const QList<Akonadi::Item> &msgList )
668  : KMCommand( parent, msgList )
669 {
670  if ( msgList.empty() )
671  return;
672 
673  fetchScope().fetchFullPayload( true ); // ### unless we call the corresponding KMCommand ctor, this has no effect
674 }
675 
676 KMCommand::Result KMSaveMsgCommand::execute()
677 {
678  if ( !MessageViewer::Util::saveMessageInMbox( retrievedMsgs(), parentWidget()) )
679  return Failed;
680  return OK;
681 }
682 
683 //-----------------------------------------------------------------------------
684 
685 KMOpenMsgCommand::KMOpenMsgCommand( QWidget *parent, const KUrl & url,
686  const QString & encoding, KMMainWidget *main )
687  : KMCommand( parent ),
688  mUrl( url ),
689  mJob( 0 ),
690  mEncoding( encoding ),
691  mMainWidget( main )
692 {
693 }
694 
695 KMCommand::Result KMOpenMsgCommand::execute()
696 {
697  if ( mUrl.isEmpty() ) {
698  mUrl = KFileDialog::getOpenUrl( KUrl( QLatin1String("kfiledialog:///OpenMessage") ),
699  QLatin1String("message/rfc822 application/mbox"),
700  parentWidget(), i18n("Open Message") );
701  }
702  if ( mUrl.isEmpty() ) {
703  return Canceled;
704  }
705 
706  if(mMainWidget) {
707  mMainWidget->addRecentFile(mUrl);
708  }
709 
710  setDeletesItself( true );
711  mJob = KIO::get( mUrl, KIO::NoReload, KIO::HideProgressInfo );
712  connect( mJob, SIGNAL(data(KIO::Job*,QByteArray)),
713  this, SLOT(slotDataArrived(KIO::Job*,QByteArray)) );
714  connect( mJob, SIGNAL(result(KJob*)),
715  SLOT(slotResult(KJob*)) );
716  setEmitsCompletedItself( true );
717  return OK;
718 }
719 
720 void KMOpenMsgCommand::slotDataArrived( KIO::Job *, const QByteArray & data )
721 {
722  if ( data.isEmpty() )
723  return;
724 
725  mMsgString.append( QString::fromLatin1(data.data()) );
726 }
727 
728 void KMOpenMsgCommand::doesNotContainMessage()
729 {
730  KMessageBox::sorry( parentWidget(),
731  i18n( "The file does not contain a message." ) );
732  setResult( Failed );
733  emit completed( this );
734  // Emulate closing of a secondary window so that KMail exits in case it
735  // was started with the --view command line option. Otherwise an
736  // invisible KMail would keep running.
737  SecondaryWindow *win = new SecondaryWindow();
738  win->close();
739  win->deleteLater();
740  deleteLater();
741 
742 }
743 
744 void KMOpenMsgCommand::slotResult( KJob *job )
745 {
746  if ( job->error() ) {
747  // handle errors
748  showJobError(job);
749  setResult( Failed );
750  emit completed( this );
751  }
752  else {
753  int startOfMessage = 0;
754  if ( mMsgString.startsWith( QLatin1String( "From " ) ) ) {
755  startOfMessage = mMsgString.indexOf( QLatin1Char('\n') );
756  if ( startOfMessage == -1 ) {
757  doesNotContainMessage();
758  return;
759  }
760  startOfMessage += 1; // the message starts after the '\n'
761  }
762  // check for multiple messages in the file
763  bool multipleMessages = true;
764  int endOfMessage = mMsgString.indexOf( QLatin1String("\nFrom ") );
765  if ( endOfMessage == -1 ) {
766  endOfMessage = mMsgString.length();
767  multipleMessages = false;
768  }
769  KMime::Message *msg = new KMime::Message;
770  msg->setContent( KMime::CRLFtoLF( mMsgString.mid( startOfMessage,endOfMessage - startOfMessage ).toUtf8() ) );
771  msg->parse();
772  if ( !msg->hasContent() ) {
773  delete msg; msg = 0;
774  doesNotContainMessage();
775  return;
776  }
777  KMReaderMainWin *win = new KMReaderMainWin();
778  KMime::Message::Ptr mMsg( msg );
779  win->showMessage( mEncoding, mMsg );
780  win->show();
781  if ( multipleMessages )
782  KMessageBox::information( win,
783  i18n( "The file contains multiple messages. "
784  "Only the first message is shown." ) );
785  setResult( OK );
786  emit completed( this );
787  }
788  deleteLater();
789 }
790 
791 //-----------------------------------------------------------------------------
792 KMReplyCommand::KMReplyCommand( QWidget *parent, const Akonadi::Item &msg, MessageComposer::ReplyStrategy replyStrategy,
793  const QString &selection, bool noquote, const QString& templateName )
794  : KMCommand( parent, msg ),
795  mSelection( selection ),
796  mTemplate( templateName ),
797  m_replyStrategy( replyStrategy ),
798  mNoQuote(noquote)
799 
800 {
801  if ( !noquote )
802  fetchScope().fetchFullPayload( true );
803 
804  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
805 }
806 
807 KMCommand::Result KMReplyCommand::execute()
808 {
809 #ifndef QT_NO_CURSOR
810  MessageViewer::KCursorSaver busy( MessageViewer::KBusyPtr::busy() );
811 #endif
812  Akonadi::Item item = retrievedMessage();
813  KMime::Message::Ptr msg = MessageCore::Util::message( item );
814  if ( !msg )
815  return Failed;
816 
817  MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
818  factory.setIdentityManager( KMKernel::self()->identityManager() );
819  factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
820  factory.setMailingListAddresses( KMail::Util::mailingListsFromMessage( item ) );
821  factory.putRepliesInSameFolder( KMail::Util::putRepliesInSameFolder( item ) );
822  factory.setReplyStrategy( m_replyStrategy );
823  factory.setSelection( mSelection );
824  if ( !mTemplate.isEmpty() )
825  factory.setTemplate( mTemplate );
826  if(mNoQuote) {
827  factory.setQuote(false);
828  }
829  bool lastEncrypt = false;
830  bool lastSign = false;
831  KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
832 
833  MessageFactory::MessageReply reply = factory.createReply();
834  KMail::Composer * win = KMail::makeComposer( KMime::Message::Ptr( reply.msg ), lastSign, lastEncrypt, replyContext( reply ), 0,
835  mSelection,mTemplate );
836  win->setFocusToEditor();
837  win->show();
838 
839  return OK;
840 }
841 
842 
843 KMForwardCommand::KMForwardCommand( QWidget *parent,
844  const QList<Akonadi::Item> &msgList, uint identity,const QString& templateName )
845  : KMCommand( parent, msgList ),
846  mIdentity( identity ),
847  mTemplate( templateName )
848 {
849  fetchScope().fetchFullPayload( true );
850  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
851 }
852 
853 KMForwardCommand::KMForwardCommand( QWidget *parent, const Akonadi::Item &msg,
854  uint identity, const QString& templateName )
855  : KMCommand( parent, msg ),
856  mIdentity( identity ),
857  mTemplate( templateName )
858 {
859  fetchScope().fetchFullPayload( true );
860  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
861 }
862 
863 KMCommand::Result KMForwardCommand::createComposer(const Akonadi::Item& item)
864 {
865  KMime::Message::Ptr msg = MessageCore::Util::message( item );
866  if ( !msg )
867  return Failed;
868 #ifndef QT_NO_CURSOR
869  MessageViewer::KCursorSaver busy( MessageViewer::KBusyPtr::busy() );
870 #endif
871  MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
872  factory.setIdentityManager( KMKernel::self()->identityManager() );
873  factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
874  if ( !mTemplate.isEmpty() )
875  factory.setTemplate( mTemplate );
876  KMime::Message::Ptr fwdMsg = factory.createForward();
877 
878  uint id = msg->headerByType( "X-KMail-Identity" ) ? msg->headerByType("X-KMail-Identity")->asUnicodeString().trimmed().toUInt() : 0;
879  kDebug() << "mail" << msg->encodedContent();
880  bool lastEncrypt = false;
881  bool lastSign = false;
882  KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
883 
884  if ( id == 0 )
885  id = mIdentity;
886  {
887  KMail::Composer * win = KMail::makeComposer( fwdMsg, lastSign, lastEncrypt, KMail::Composer::Forward, id,QString(), mTemplate );
888  win->show();
889  }
890  return OK;
891 }
892 
893 KMCommand::Result KMForwardCommand::execute()
894 {
895  QList<Akonadi::Item> msgList = retrievedMsgs();
896 
897  if (msgList.count() >= 2) {
898  // ask if they want a mime digest forward
899 
900  int answer = KMessageBox::questionYesNoCancel(
901  parentWidget(),
902  i18n("Do you want to forward the selected messages as "
903  "attachments in one message (as a MIME digest) or as "
904  "individual messages?"), QString(),
905  KGuiItem(i18n("Send As Digest")),
906  KGuiItem(i18n("Send Individually")) );
907 
908  if ( answer == KMessageBox::Yes ) {
909  Akonadi::Item firstItem( msgList.first() );
910  MessageFactory factory( KMime::Message::Ptr( new KMime::Message ), firstItem.id(), MailCommon::Util::updatedCollection(firstItem.parentCollection()) );
911  factory.setIdentityManager( KMKernel::self()->identityManager() );
912  factory.setFolderIdentity( MailCommon::Util::folderIdentity( firstItem ) );
913 
914  QPair< KMime::Message::Ptr, KMime::Content* > fwdMsg = factory.createForwardDigestMIME(msgList );
915  KMail::Composer * win = KMail::makeComposer( fwdMsg.first, false, false, KMail::Composer::Forward, mIdentity );
916  win->addAttach( fwdMsg.second );
917  win->show();
918  return OK;
919  } else if ( answer == KMessageBox::No ) {// NO MIME DIGEST, Multiple forward
920  QList<Akonadi::Item>::const_iterator it;
921  QList<Akonadi::Item>::const_iterator end( msgList.constEnd() );
922 
923  for ( it = msgList.constBegin(); it != end; ++it ) {
924  if ( createComposer( *it ) == Failed )
925  return Failed;
926  }
927  return OK;
928  } else {
929  // user cancelled
930  return OK;
931  }
932  }
933 
934  // forward a single message at most.
935  Akonadi::Item item = msgList.first();
936  if ( createComposer( item ) == Failed )
937  return Failed;
938  return OK;
939 }
940 
941 
942 KMForwardAttachedCommand::KMForwardAttachedCommand( QWidget *parent,
943  const QList<Akonadi::Item> &msgList, uint identity, KMail::Composer *win )
944  : KMCommand( parent, msgList ), mIdentity( identity ),
945  mWin( QPointer<KMail::Composer>( win ))
946 {
947  fetchScope().fetchFullPayload( true );
948  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
949 }
950 
951 KMForwardAttachedCommand::KMForwardAttachedCommand( QWidget *parent,
952  const Akonadi::Item & msg, uint identity, KMail::Composer *win )
953  : KMCommand( parent, msg ), mIdentity( identity ),
954  mWin( QPointer< KMail::Composer >( win ))
955 {
956  fetchScope().fetchFullPayload( true );
957  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
958 }
959 
960 KMCommand::Result KMForwardAttachedCommand::execute()
961 {
962  QList<Akonadi::Item> msgList = retrievedMsgs();
963  Akonadi::Item firstItem( msgList.first() );
964  MessageFactory factory( KMime::Message::Ptr( new KMime::Message ), firstItem.id(), MailCommon::Util::updatedCollection(firstItem.parentCollection()) );
965  factory.setIdentityManager( KMKernel::self()->identityManager() );
966  factory.setFolderIdentity( MailCommon::Util::folderIdentity( firstItem ) );
967 
968  QPair< KMime::Message::Ptr, QList< KMime::Content* > > fwdMsg = factory.createAttachedForward( msgList );
969  if ( !mWin ) {
970  mWin = KMail::makeComposer( fwdMsg.first, false, false, KMail::Composer::Forward, mIdentity );
971  }
972  foreach( KMime::Content* attach, fwdMsg.second ) {
973  mWin->addAttach( attach );
974  }
975  mWin->show();
976  return OK;
977 }
978 
979 KMRedirectCommand::KMRedirectCommand( QWidget *parent,
980  const QList<Akonadi::Item> &msgList )
981  : KMCommand( parent, msgList )
982 {
983  fetchScope().fetchFullPayload( true );
984  fetchScope().fetchAttribute<MailTransport::SentBehaviourAttribute>();
985  fetchScope().fetchAttribute<MailTransport::TransportAttribute>();
986 
987  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
988 }
989 
990 KMRedirectCommand::KMRedirectCommand( QWidget *parent,
991  const Akonadi::Item &msg )
992  : KMCommand( parent, msg )
993 {
994  fetchScope().fetchFullPayload( true );
995  fetchScope().fetchAttribute<MailTransport::SentBehaviourAttribute>();
996  fetchScope().fetchAttribute<MailTransport::TransportAttribute>();
997 
998  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
999 }
1000 
1001 KMCommand::Result KMRedirectCommand::execute()
1002 {
1003  const MailCommon::RedirectDialog::SendMode sendMode = MessageComposer::MessageComposerSettings::self()->sendImmediate()
1004  ? MailCommon::RedirectDialog::SendNow
1005  : MailCommon::RedirectDialog::SendLater;
1006 
1007  MessageViewer::AutoQPointer<MailCommon::RedirectDialog> dlg( new MailCommon::RedirectDialog( sendMode, parentWidget() ) );
1008  dlg->setObjectName( QLatin1String("redirect") );
1009  if ( dlg->exec() == QDialog::Rejected || !dlg ) {
1010  return Failed;
1011  }
1012  if ( !TransportManager::self()->showTransportCreationDialog( parentWidget(), TransportManager::IfNoTransportExists ) )
1013  return Failed;
1014 
1015  //TODO use sendlateragent here too.
1016  const MessageComposer::MessageSender::SendMethod method = (dlg->sendMode() == MailCommon::RedirectDialog::SendNow)
1017  ? MessageComposer::MessageSender::SendImmediate
1018  : MessageComposer::MessageSender::SendLater;
1019 
1020  const int identity = dlg->identity();
1021  int transportId = dlg->transportId();
1022  const QString to = dlg->to();
1023  foreach( const Akonadi::Item &item, retrievedMsgs() ) {
1024  const KMime::Message::Ptr msg = MessageCore::Util::message( item );
1025  if ( !msg )
1026  return Failed;
1027 
1028  MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
1029  factory.setIdentityManager( KMKernel::self()->identityManager() );
1030  factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
1031 
1032  if(transportId == -1) {
1033  const MailTransport::TransportAttribute *transportAttribute = item.attribute<MailTransport::TransportAttribute>();
1034  if ( transportAttribute ) {
1035  transportId = transportAttribute->transportId();
1036  const MailTransport::Transport *transport = MailTransport::TransportManager::self()->transportById( transportId );
1037  if ( !transport ) {
1038  transportId = -1;
1039  }
1040  }
1041  }
1042 
1043  const MailTransport::SentBehaviourAttribute *sentAttribute = item.attribute<MailTransport::SentBehaviourAttribute>();
1044  QString fcc;
1045  if ( sentAttribute && ( sentAttribute->sentBehaviour() == MailTransport::SentBehaviourAttribute::MoveToCollection ) )
1046  fcc = QString::number( sentAttribute->moveToCollection().id() );
1047 
1048  const KMime::Message::Ptr newMsg = factory.createRedirect( to, transportId, fcc, identity );
1049  if ( !newMsg )
1050  return Failed;
1051 
1052  MessageStatus status;
1053  status.setStatusFromFlags( item.flags() );
1054  if ( !status.isRead() )
1055  FilterAction::sendMDN( item, KMime::MDN::Dispatched );
1056 
1057 
1058  if ( !kmkernel->msgSender()->send( newMsg, method ) ) {
1059  kDebug() << "KMRedirectCommand: could not redirect message (sending failed)";
1060  return Failed; // error: couldn't send
1061  }
1062  }
1063 
1064  return OK;
1065 }
1066 
1067 
1068 KMPrintCommand::KMPrintCommand( QWidget *parent, const Akonadi::Item &msg,
1069  MessageViewer::HeaderStyle *headerStyle,
1070  MessageViewer::HeaderStrategy *headerStrategy,
1071  bool htmlOverride, bool htmlLoadExtOverride,
1072  bool useFixedFont, const QString & encoding )
1073  : KMCommand( parent, msg ),
1074  mHeaderStyle( headerStyle ), mHeaderStrategy( headerStrategy ),
1075  mAttachmentStrategy( 0 ),
1076  mEncoding( encoding ),
1077  mHtmlOverride( htmlOverride ),
1078  mHtmlLoadExtOverride( htmlLoadExtOverride ),
1079  mUseFixedFont( useFixedFont ),
1080  mPrintPreview(false)
1081 {
1082  fetchScope().fetchFullPayload( true );
1083  if ( MessageCore::GlobalSettings::useDefaultFonts() )
1084  mOverrideFont = KGlobalSettings::generalFont();
1085  else {
1086  mOverrideFont = MessageCore::GlobalSettings::self()->printFont();
1087  }
1088 }
1089 
1090 
1091 void KMPrintCommand::setOverrideFont( const QFont& font )
1092 {
1093  mOverrideFont = font;
1094 }
1095 
1096 void KMPrintCommand::setAttachmentStrategy( const MessageViewer::AttachmentStrategy *strategy )
1097 {
1098  mAttachmentStrategy = strategy;
1099 }
1100 
1101 void KMPrintCommand::setPrintPreview( bool preview )
1102 {
1103  mPrintPreview = preview;
1104 }
1105 
1106 KMCommand::Result KMPrintCommand::execute()
1107 {
1108  // the window will be deleted after printout is performed, in KMReaderWin::slotPrintMsg()
1109  KMReaderWin *printerWin = new KMReaderWin( 0, kmkernel->mainWin(), 0, 0 );
1110  printerWin->setPrinting( true );
1111  printerWin->readConfig();
1112  if ( mHeaderStyle != 0 && mHeaderStrategy != 0 )
1113  printerWin->setHeaderStyleAndStrategy( mHeaderStyle, mHeaderStrategy );
1114  printerWin->setHtmlOverride( mHtmlOverride );
1115  printerWin->setHtmlLoadExtOverride( mHtmlLoadExtOverride );
1116  printerWin->setUseFixedFont( mUseFixedFont );
1117  printerWin->setOverrideEncoding( mEncoding );
1118  printerWin->cssHelper()->setPrintFont( mOverrideFont );
1119  printerWin->setDecryptMessageOverwrite( true );
1120  if ( mAttachmentStrategy != 0 )
1121  printerWin->setAttachmentStrategy( mAttachmentStrategy );
1122  if(mPrintPreview)
1123  printerWin->viewer()->printPreviewMessage( retrievedMessage() );
1124  else
1125  printerWin->viewer()->printMessage(retrievedMessage());
1126  return OK;
1127 }
1128 
1129 
1130 KMSetStatusCommand::KMSetStatusCommand( const MessageStatus& status,
1131  const Akonadi::Item::List &items, bool invert )
1132  : KMCommand( 0, items ), mStatus( status ), mInvertMark( invert )
1133 {
1134  setDeletesItself(true);
1135 }
1136 
1137 KMCommand::Result KMSetStatusCommand::execute()
1138 {
1139  bool parentStatus = false;
1140  // Toggle actions on threads toggle the whole thread
1141  // depending on the state of the parent.
1142  if ( mInvertMark ) {
1143  const Akonadi::Item first = retrievedMsgs().first();
1144  MessageStatus pStatus;
1145  pStatus.setStatusFromFlags( first.flags() );
1146  if ( pStatus & mStatus )
1147  parentStatus = true;
1148  else
1149  parentStatus = false;
1150  }
1151 
1152  Akonadi::Item::List itemsToModify;
1153  foreach( const Akonadi::Item &it, retrievedMsgs() ) {
1154  if ( mInvertMark ) {
1155  //kDebug()<<" item ::"<<tmpItem;
1156  if ( it.isValid() ) {
1157  bool myStatus;
1158  MessageStatus itemStatus;
1159  itemStatus.setStatusFromFlags( it.flags() );
1160  if ( itemStatus & mStatus )
1161  myStatus = true;
1162  else
1163  myStatus = false;
1164  if ( myStatus != parentStatus )
1165  continue;
1166  }
1167  }
1168  Akonadi::Item item( it );
1169  const Akonadi::Item::Flag flag = *(mStatus.statusFlags().begin());
1170  if ( mInvertMark ) {
1171  if ( item.hasFlag( flag ) ) {
1172  item.clearFlag( flag );
1173  itemsToModify.push_back( item );
1174  } else {
1175  item.setFlag( flag );
1176  itemsToModify.push_back( item );
1177  }
1178  } else {
1179  if ( !item.hasFlag( flag ) ) {
1180  item.setFlag( flag );
1181  itemsToModify.push_back( item );
1182  }
1183  }
1184  }
1185 
1186  if ( itemsToModify.isEmpty() ) {
1187  slotModifyItemDone( 0 ); // pretend we did something
1188  } else {
1189  Akonadi::ItemModifyJob *modifyJob = new Akonadi::ItemModifyJob( itemsToModify, this );
1190  modifyJob->disableRevisionCheck();
1191  modifyJob->setIgnorePayload( true );
1192  connect( modifyJob, SIGNAL(result(KJob*)), this, SLOT(slotModifyItemDone(KJob*)) );
1193  }
1194  return OK;
1195 }
1196 
1197 void KMSetStatusCommand::slotModifyItemDone( KJob * job )
1198 {
1199  if ( job && job->error() ) {
1200  kWarning() << " Error trying to set item status:" << job->errorText();
1201  }
1202  deleteLater();
1203 }
1204 
1205 KMSetTagCommand::KMSetTagCommand( const QList<QString> &tagLabel, const QList<Akonadi::Item> &item,
1206  SetTagMode mode )
1207  : mTagLabel( tagLabel )
1208  , mItem( item )
1209  , mMode( mode )
1210 {
1211 }
1212 
1213 KMCommand::Result KMSetTagCommand::execute()
1214 {
1215  QStringList tagSelectedlst;
1216  Q_FOREACH( const Akonadi::Item& item, mItem ) {
1217  Nepomuk2::Resource n_resource( item.url() );
1218  QList<Nepomuk2::Tag> n_tag_list;
1219  if ( mMode != CleanExistingAndAddNew ){
1220  n_tag_list = n_resource.tags();
1221  }
1222 
1223  Q_FOREACH( const QString &tagLabel, mTagLabel ) {
1224  const Nepomuk2::Tag n_tag( tagLabel );
1225  const QString tagUri(n_tag.uri().toString());
1226  if ( mMode == CleanExistingAndAddNew ) {
1227  n_resource.addTag( n_tag );
1228  if(!tagSelectedlst.contains(tagUri))
1229  tagSelectedlst<<tagUri;
1230  } else {
1231  const int tagPosition = n_tag_list.indexOf( tagLabel );
1232  if ( tagPosition == -1 ) {
1233  n_resource.addTag( n_tag );
1234  if(!tagSelectedlst.contains(tagUri))
1235  tagSelectedlst<<tagUri;
1236  } else if ( mMode == Toggle ) {
1237  const int numberOfTag( n_tag_list.count() );
1238  for (int i = 0; i < numberOfTag; ++i ) {
1239  if ( n_tag_list[i].uri() == tagLabel ) {
1240  n_tag_list.removeAt( i );
1241  break;
1242  }
1243  }
1244  n_resource.setTags( n_tag_list );
1245  }
1246  }
1247  }
1248  }
1249 
1250  if(!tagSelectedlst.isEmpty()) {
1251  KConfigGroup tag( KMKernel::self()->config(), "MessageListView" );
1252  const QString oldTagList = tag.readEntry("TagSelected");
1253  QStringList lst = oldTagList.split(QLatin1String(","));
1254  Q_FOREACH(const QString& str,tagSelectedlst ) {
1255  if(!lst.contains(str)) {
1256  lst.append(str);
1257  }
1258  }
1259  tag.writeEntry("TagSelected",lst);
1260  KMKernel::self()->updatePaneTagComboBox();
1261  }
1262 
1263  return OK;
1264 }
1265 
1266 KMFilterActionCommand::KMFilterActionCommand( QWidget *parent,
1267  const QVector<qlonglong> &msgListId,
1268  const QString &filterId)
1269  : KMCommand( parent ), mMsgListId(msgListId), mFilterId( filterId )
1270 {
1271 }
1272 
1273 KMCommand::Result KMFilterActionCommand::execute()
1274 {
1275 #ifndef QT_NO_CURSOR
1276  MessageViewer::KCursorSaver busy( MessageViewer::KBusyPtr::busy() );
1277 #endif
1278  int msgCount = 0;
1279  const int msgCountToFilter = mMsgListId.count();
1280  ProgressItem* progressItem =
1281  ProgressManager::createProgressItem (
1282  QLatin1String("filter")+ProgressManager::getUniqueID(),
1283  i18n( "Filtering messages" ) );
1284  progressItem->setTotalItems( msgCountToFilter );
1285 
1286  foreach ( const qlonglong &id, mMsgListId ) {
1287  int diff = msgCountToFilter - ++msgCount;
1288  if ( diff < 10 || !( msgCount % 10 ) || msgCount <= 10 ) {
1289  progressItem->updateProgress();
1290  const QString statusMsg = i18n( "Filtering message %1 of %2",
1291  msgCount, msgCountToFilter );
1292  KPIM::BroadcastStatus::instance()->setStatusMsg( statusMsg );
1293  qApp->processEvents( QEventLoop::ExcludeUserInputEvents, 50 );
1294  }
1295 
1296 
1297  MailCommon::FilterManager::instance()->filter( Akonadi::Item(id), mFilterId, QString() );
1298  progressItem->incCompletedItems();
1299  }
1300 
1301  progressItem->setComplete();
1302  progressItem = 0;
1303  return OK;
1304 }
1305 
1306 
1307 KMMetaFilterActionCommand::KMMetaFilterActionCommand( const QString &filterId,
1308  KMMainWidget *main )
1309  : QObject( main ),
1310  mFilterId( filterId ), mMainWidget( main )
1311 {
1312 }
1313 
1314 void KMMetaFilterActionCommand::start()
1315 {
1316  KMCommand *filterCommand = new KMFilterActionCommand(
1317  mMainWidget, mMainWidget->messageListPane()->selectionAsMessageItemListId() , mFilterId);
1318  filterCommand->start();
1319 }
1320 
1321 
1322 KMMailingListFilterCommand::KMMailingListFilterCommand( QWidget *parent,
1323  const Akonadi::Item &msg )
1324  : KMCommand( parent, msg )
1325 {
1326 }
1327 
1328 KMCommand::Result KMMailingListFilterCommand::execute()
1329 {
1330  QByteArray name;
1331  QString value;
1332  Akonadi::Item item = retrievedMessage();
1333  KMime::Message::Ptr msg = MessageCore::Util::message( item );
1334  if ( !msg )
1335  return Failed;
1336  if ( !MailingList::name( msg, name, value ).isEmpty() ) {
1337  FilterIf->openFilterDialog( false );
1338  FilterIf->createFilter( name, value );
1339  return OK;
1340  } else {
1341  return Failed;
1342  }
1343 }
1344 
1345 KMCopyCommand::KMCopyCommand( const Akonadi::Collection& destFolder,
1346  const QList<Akonadi::Item> &msgList)
1347  :KMCommand( 0, msgList ), mDestFolder( destFolder )
1348 {
1349 }
1350 
1351 KMCopyCommand::KMCopyCommand( const Akonadi::Collection& destFolder, const Akonadi::Item& msg)
1352  :KMCommand( 0,msg ), mDestFolder( destFolder )
1353 {
1354 }
1355 
1356 KMCommand::Result KMCopyCommand::execute()
1357 {
1358  setDeletesItself( true );
1359 
1360  QList<Akonadi::Item> listItem = retrievedMsgs();
1361  Akonadi::ItemCopyJob *job = new Akonadi::ItemCopyJob( listItem, Akonadi::Collection(mDestFolder.id()),this );
1362  connect( job, SIGNAL(result(KJob*)), this, SLOT(slotCopyResult(KJob*)) );
1363 
1364  return OK;
1365 }
1366 
1367 void KMCopyCommand::slotCopyResult( KJob * job )
1368 {
1369  if ( job->error() ) {
1370  // handle errors
1371  showJobError(job);
1372  setResult( Failed );
1373  }
1374  deleteLater();
1375 }
1376 
1377 KMMoveCommand::KMMoveCommand( const Akonadi::Collection& destFolder,
1378  const QList<Akonadi::Item> &msgList,
1379  MessageList::Core::MessageItemSetReference ref)
1380  : KMCommand( 0, msgList ), mDestFolder( destFolder ), mProgressItem( 0 ), mRef( ref )
1381 {
1382  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
1383 }
1384 
1385 KMMoveCommand::KMMoveCommand( const Akonadi::Collection& destFolder,
1386  const Akonadi::Item& msg ,
1387  MessageList::Core::MessageItemSetReference ref)
1388  : KMCommand( 0, msg ), mDestFolder( destFolder ), mProgressItem( 0 ), mRef( ref )
1389 {
1390  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
1391 }
1392 
1393 void KMMoveCommand::slotMoveResult( KJob * job )
1394 {
1395  if ( job->error() ) {
1396  // handle errors
1397  showJobError(job);
1398  completeMove( Failed );
1399  }
1400  else
1401  completeMove( OK );
1402 }
1403 
1404 KMCommand::Result KMMoveCommand::execute()
1405 {
1406 #ifndef QT_NO_CURSOR
1407  MessageViewer::KCursorSaver busy( MessageViewer::KBusyPtr::busy() );
1408 #endif
1409  setEmitsCompletedItself( true );
1410  setDeletesItself( true );
1411  if ( mDestFolder.isValid() ) {
1412  Akonadi::ItemMoveJob *job = new Akonadi::ItemMoveJob( retrievedMsgs(), mDestFolder, this );
1413  connect( job, SIGNAL(result(KJob*)), this, SLOT(slotMoveResult(KJob*)) );
1414 
1415  // group by source folder for undo
1416  Akonadi::Item::List items = retrievedMsgs();
1417  std::sort( items.begin(), items.end(), boost::bind( &Akonadi::Item::storageCollectionId, _1 ) <
1418  boost::bind( &Akonadi::Item::storageCollectionId, _2 ) );
1419  Akonadi::Collection parent;
1420  int undoId = -1;
1421  foreach ( const Akonadi::Item &item, items ) {
1422  if ( item.storageCollectionId() <= 0 )
1423  continue;
1424  if ( parent.id() != item.storageCollectionId() ) {
1425  parent = Akonadi::Collection( item.storageCollectionId() );
1426  undoId = kmkernel->undoStack()->newUndoAction( parent, mDestFolder );
1427  }
1428  kmkernel->undoStack()->addMsgToAction( undoId, item );
1429  }
1430  } else {
1431  const QList<Akonadi::Item> retrievedList = retrievedMsgs();
1432  if ( !retrievedList.isEmpty() ) {
1433  Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob( retrievedList, this );
1434  connect( job, SIGNAL(result(KJob*)), this, SLOT(slotMoveResult(KJob*)) );
1435  }
1436  }
1437 
1438  // TODO set SSL state according to source and destfolder connection?
1439  Q_ASSERT( !mProgressItem );
1440  mProgressItem =
1441  ProgressManager::createProgressItem (QLatin1String("move")+ProgressManager::getUniqueID(),
1442  mDestFolder.isValid() ? i18n( "Moving messages" ) : i18n( "Deleting messages" ) );
1443  mProgressItem->setUsesBusyIndicator( true );
1444  connect( mProgressItem, SIGNAL(progressItemCanceled(KPIM::ProgressItem*)),
1445  this, SLOT(slotMoveCanceled()) );
1446  return OK;
1447 }
1448 
1449 
1450 
1451 void KMMoveCommand::completeMove( Result result )
1452 {
1453  if ( mProgressItem ) {
1454  mProgressItem->setComplete();
1455  mProgressItem = 0;
1456  }
1457  setResult( result );
1458  emit moveDone(this);
1459  emit completed( this );
1460  deleteLater();
1461 }
1462 
1463 void KMMoveCommand::slotMoveCanceled()
1464 {
1465  completeMove( Canceled );
1466 }
1467 
1468 // srcFolder doesn't make much sense for searchFolders
1469 KMTrashMsgCommand::KMTrashMsgCommand( const Akonadi::Collection& srcFolder,
1470  const QList<Akonadi::Item> &msgList,MessageList::Core::MessageItemSetReference ref )
1471  :KMMoveCommand( findTrashFolder( srcFolder ), msgList, ref)
1472 {
1473 }
1474 
1475 KMTrashMsgCommand::KMTrashMsgCommand( const Akonadi::Collection& srcFolder, const Akonadi::Item & msg,MessageList::Core::MessageItemSetReference ref )
1476  :KMMoveCommand( findTrashFolder( srcFolder ), msg, ref)
1477 {
1478 }
1479 
1480 
1481 Akonadi::Collection KMTrashMsgCommand::findTrashFolder( const Akonadi::Collection& folder )
1482 {
1483  Akonadi::Collection col = CommonKernel->trashCollectionFromResource( folder );
1484  if ( !col.isValid() ) {
1485  col = CommonKernel->trashCollectionFolder();
1486  }
1487  if ( folder != col )
1488  return col;
1489  return Akonadi::Collection();
1490 }
1491 
1492 KMSaveAttachmentsCommand::KMSaveAttachmentsCommand( QWidget *parent, const Akonadi::Item& msg )
1493  : KMCommand( parent, msg )
1494 {
1495  fetchScope().fetchFullPayload( true );
1496 }
1497 
1498 KMSaveAttachmentsCommand::KMSaveAttachmentsCommand( QWidget *parent, const QList<Akonadi::Item>& msgs )
1499  : KMCommand( parent, msgs )
1500 {
1501  fetchScope().fetchFullPayload( true );
1502 }
1503 
1504 KMCommand::Result KMSaveAttachmentsCommand::execute()
1505 {
1506  QList<KMime::Content*> contentsToSave;
1507  foreach( const Akonadi::Item &item, retrievedMsgs() ) {
1508  if ( item.hasPayload<KMime::Message::Ptr>() ) {
1509  contentsToSave += MessageViewer::Util::extractAttachments( item.payload<KMime::Message::Ptr>().get() );
1510  } else {
1511  kWarning() << "Retrieved item has no payload? Ignoring for saving the attachments";
1512  }
1513  }
1514  if ( MessageViewer::Util::saveAttachments( contentsToSave, parentWidget() ) )
1515  return OK;
1516  return Failed;
1517 }
1518 
1519 KMResendMessageCommand::KMResendMessageCommand( QWidget *parent,
1520  const Akonadi::Item &msg )
1521  :KMCommand( parent, msg )
1522 {
1523  fetchScope().fetchFullPayload( true );
1524  fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
1525 }
1526 
1527 KMCommand::Result KMResendMessageCommand::execute()
1528 {
1529  Akonadi::Item item = retrievedMessage();
1530  KMime::Message::Ptr msg = MessageCore::Util::message( item );
1531  if ( !msg )
1532  return Failed;
1533 
1534  MessageFactory factory( msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()) );
1535  factory.setIdentityManager( KMKernel::self()->identityManager() );
1536  factory.setFolderIdentity( MailCommon::Util::folderIdentity( item ) );
1537  KMime::Message::Ptr newMsg = factory.createResend();
1538  newMsg->contentType()->setCharset( MessageViewer::NodeHelper::charset( msg.get() ) );
1539 
1540  KMail::Composer * win = KMail::makeComposer();
1541  if(msg->headerByType( "Reply-To" )) {
1542  const QString replyTo = msg->headerByType( "Reply-To" )->asUnicodeString();
1543  win->setCurrentReplyTo(replyTo);
1544  }
1545  bool lastEncrypt = false;
1546  bool lastSign = false;
1547  KMail::Util::lastEncryptAndSignState(lastEncrypt, lastSign, msg);
1548  win->setMessage( newMsg, lastSign, lastEncrypt, false, true );
1549 
1550  win->show();
1551 
1552  return OK;
1553 }
1554 
1555 
1556 KMShareImageCommand::KMShareImageCommand(const KUrl &url, QWidget *parent)
1557  : KMCommand( parent ),
1558  mUrl(url)
1559 {
1560 }
1561 
1562 KMCommand::Result KMShareImageCommand::execute()
1563 {
1564  KMime::Message::Ptr msg( new KMime::Message );
1565  uint id = 0;
1566 
1567  MessageHelper::initHeader( msg, KMKernel::self()->identityManager(),id );
1568  msg->contentType()->setCharset("utf-8");
1569 
1570  KMail::Composer * win = KMail::makeComposer(msg, false, false,KMail::Composer::New, id);
1571  win->setFocusToSubject();
1572  win->addAttachment(mUrl, i18n("Image"));
1573  win->show();
1574  return OK;
1575 }
1576 
1577 #include "kmcommands.moc"
KMCommand::parentWidget
QWidget * parentWidget() const
Definition: kmcommands.cpp:227
KMCommand::messagesTransfered
void messagesTransfered(KMCommand::Result result)
KMail::Composer::setFocusToSubject
virtual void setFocusToSubject()=0
Sets the focus to the subject line edit.
KMMoveCommand::moveDone
void moveDone(KMMoveCommand *)
KMForwardCommand::KMForwardCommand
KMForwardCommand(QWidget *parent, const QList< Akonadi::Item > &msgList, uint identity=0, const QString &templateName=QString())
Definition: kmcommands.cpp:843
globalsettings.h
KMMailtoForwardCommand::KMMailtoForwardCommand
KMMailtoForwardCommand(QWidget *parent, const KUrl &url, const Akonadi::Item &msg)
Definition: kmcommands.cpp:444
QSharedPointer
Definition: collectionmailinglistpage.h:34
KMCommand::deletesItself
bool deletesItself() const
Definition: kmcommands.h:88
KMReaderMainWin::showMessage
void showMessage(const QString &encoding, const Akonadi::Item &msg, const Akonadi::Collection &parentCollection=Akonadi::Collection())
take ownership of and show
Definition: kmreadermainwin.cpp:137
kmmainwidget.h
KMCommand::retrievedMessage
Akonadi::Item retrievedMessage() const
Definition: kmcommands.cpp:220
KMOpenMsgCommand::KMOpenMsgCommand
KMOpenMsgCommand(QWidget *parent, const KUrl &url=KUrl(), const QString &encoding=QString(), KMMainWidget *main=0)
Definition: kmcommands.cpp:685
KMReaderWin
This class implements a "reader window", that is a window used for reading or viewing messages...
Definition: kmreaderwin.h:50
KPIM::BroadcastStatus::instance
static BroadcastStatus * instance()
KMReaderWin::viewer
MessageViewer::Viewer * viewer()
Definition: kmreaderwin.h:131
KMCommand::KMCommand
KMCommand(QWidget *parent=0)
Definition: kmcommands.cpp:179
KMUseTemplateCommand::KMUseTemplateCommand
KMUseTemplateCommand(QWidget *parent, const Akonadi::Item &msg)
Definition: kmcommands.cpp:633
KMail::Util::putRepliesInSameFolder
Akonadi::Item::Id putRepliesInSameFolder(const Akonadi::Item &item)
Whether or not the mail item has the keep-reply-in-folder attribute set.
Definition: util.cpp:77
QWidget
KMMoveCommand::slotMoveCanceled
void slotMoveCanceled()
Definition: kmcommands.cpp:1463
KMMainWidget::messageListPane
CollectionPane * messageListPane() const
Access to the header list pane.
Definition: kmmainwidget.h:116
KMMoveCommand
Definition: kmcommands.h:511
KMPrintCommand::setOverrideFont
void setOverrideFont(const QFont &)
Definition: kmcommands.cpp:1091
KPIM::ProgressItem::updateProgress
void updateProgress()
KMail::Composer::setMessage
virtual void setMessage(const KMime::Message::Ptr &newMsg, bool lastSignState=false, bool lastEncryptState=false, bool mayAutoSign=true, bool allowDecryption=false, bool isModified=false)=0
Set the message the composer shall work with.
KMFilterActionCommand
Definition: kmcommands.h:449
KMCommand::setResult
void setResult(Result result)
Use this to set the result of the command.
Definition: kmcommands.h:110
KMMetaFilterActionCommand::start
void start()
Definition: kmcommands.cpp:1314
undostack.h
KMReaderWin::setHeaderStyleAndStrategy
void setHeaderStyleAndStrategy(MessageViewer::HeaderStyle *style, MessageViewer::HeaderStrategy *strategy)
Set the header style and strategy.
Definition: kmreaderwin.cpp:271
KPIM::ProgressItem::incCompletedItems
void incCompletedItems(unsigned int v=1)
KMFilterActionCommand::KMFilterActionCommand
KMFilterActionCommand(QWidget *parent, const QVector< qlonglong > &msgListId, const QString &filterId)
Definition: kmcommands.cpp:1266
KMMoveCommand::slotMoveResult
void slotMoveResult(KJob *job)
Definition: kmcommands.cpp:1393
QObject
KMail::Composer::Forward
Definition: composer.h:44
KMail::Composer
Definition: composer.h:37
KMKernel::self
static KMKernel * self()
normal control stuff
Definition: kmkernel.cpp:1451
KMCommand::result
Result result() const
Returns the result of the command.
Definition: kmcommands.cpp:207
KMail::Util::mailingListsFromMessage
KMime::Types::Mailbox::List mailingListsFromMessage(const Akonadi::Item &item)
Returns any mailing list post addresses set on the parent collection (the mail folder) of the item...
Definition: util.cpp:62
KMReaderWin::setOverrideEncoding
void setOverrideEncoding(const QString &encoding)
Set the override character encoding.
Definition: kmreaderwin.cpp:276
KMSaveAttachmentsCommand::KMSaveAttachmentsCommand
KMSaveAttachmentsCommand(QWidget *parent, const Akonadi::Item &msg)
Use this to save all attachments of the given message.
Definition: kmcommands.cpp:1492
KPIM::BroadcastStatus::setStatusMsg
void setStatusMsg(const QString &message)
KMail::Composer::ReplyToAll
Definition: composer.h:44
KMMetaFilterActionCommand::KMMetaFilterActionCommand
KMMetaFilterActionCommand(const QString &filterId, KMMainWidget *main)
Definition: kmcommands.cpp:1307
KMEditItemCommand::~KMEditItemCommand
~KMEditItemCommand()
Definition: kmcommands.cpp:564
KMail::Composer::setFcc
virtual void setFcc(const QString &idString)=0
KMSetTagCommand::Toggle
Definition: kmcommands.h:434
KMReaderWin::setPrinting
virtual void setPrinting(bool enable)
Definition: kmreaderwin.cpp:641
KMReaderWin::cssHelper
MessageViewer::CSSHelper * cssHelper() const
Definition: kmreaderwin.cpp:559
KMKernel::updatePaneTagComboBox
void updatePaneTagComboBox()
Definition: kmkernel.cpp:1971
KMail::Composer::addAttachment
virtual void addAttachment(const KUrl &url, const QString &comment)=0
KMMailtoReplyCommand::KMMailtoReplyCommand
KMMailtoReplyCommand(QWidget *parent, const KUrl &url, const Akonadi::Item &msg, const QString &selection)
Definition: kmcommands.cpp:409
KMPrintCommand::KMPrintCommand
KMPrintCommand(QWidget *parent, const Akonadi::Item &msg, MessageViewer::HeaderStyle *headerStyle=0, MessageViewer::HeaderStrategy *headerStrategy=0, bool htmlOverride=false, bool htmlLoadExtOverride=false, bool useFixedFont=false, const QString &encoding=QString())
Definition: kmcommands.cpp:1068
KMMoveCommand::KMMoveCommand
KMMoveCommand(const Akonadi::Collection &destFolder, const QList< Akonadi::Item > &msgList, MessageList::Core::MessageItemSetReference ref)
Definition: kmcommands.cpp:1377
KMail::Composer::addAttach
virtual void addAttach(KMime::Content *msgPart)=0
Add an attachment to the list.
KMCommand
Small helper structure which encapsulates the KMMessage created when creating a reply, and.
Definition: kmcommands.h:44
KMail::Composer::setFolder
virtual void setFolder(const Akonadi::Collection &)=0
If this folder is set, the original message is inserted back after canceling.
KMReaderWin::setDecryptMessageOverwrite
void setDecryptMessageOverwrite(bool overwrite=true)
Enforce message decryption.
Definition: kmreaderwin.cpp:568
KPIM::ProgressManager
secondarywindow.h
KMCommand::setDeletesItself
void setDeletesItself(bool deletesItself)
Specify whether the subclass takes care of the deletion of the object.
Definition: kmcommands.h:94
KMail::SecondaryWindow
Window class for secondary KMail window like the composer window and the separate message window...
Definition: secondarywindow.h:44
replyContext
static KMail::Composer::TemplateContext replyContext(MessageFactory::MessageReply reply)
Small helper function to get the composer context from a reply.
Definition: kmcommands.cpp:158
KMReplyCommand::KMReplyCommand
KMReplyCommand(QWidget *parent, const Akonadi::Item &msg, MessageComposer::ReplyStrategy replyStrategy, const QString &selection=QString(), bool noquote=false, const QString &templateName=QString())
Definition: kmcommands.cpp:792
KMCommand::Canceled
Definition: kmcommands.h:49
KMShareImageCommand::KMShareImageCommand
KMShareImageCommand(const KUrl &url, QWidget *parent)
Definition: kmcommands.cpp:1556
KMSetStatusCommand::slotModifyItemDone
void slotModifyItemDone(KJob *job)
Definition: kmcommands.cpp:1197
KPIM::ProgressItem::setComplete
void setComplete()
progressmanager.h
collectionpane.h
KMCommand::start
void start()
Definition: kmcommands.cpp:234
KMReaderWin::setAttachmentStrategy
void setAttachmentStrategy(const MessageViewer::AttachmentStrategy *strategy)
Definition: kmreaderwin.cpp:267
KMCommand::setEmitsCompletedItself
void setEmitsCompletedItself(bool emitsCompletedItself)
Specify whether the subclass takes care of emitting the completed() signal.
Definition: kmcommands.h:104
KMReaderWin::setHtmlOverride
void setHtmlOverride(bool override)
Definition: kmreaderwin.cpp:449
showJobError
static void showJobError(KJob *job)
Helper to sanely show an error message for a job.
Definition: kmcommands.cpp:167
to
QString to() const
KMReaderWin::setHtmlLoadExtOverride
void setHtmlLoadExtOverride(bool override)
Definition: kmreaderwin.cpp:460
KMTrashMsgCommand::KMTrashMsgCommand
KMTrashMsgCommand(const Akonadi::Collection &srcFolder, const QList< Akonadi::Item > &msgList, MessageList::Core::MessageItemSetReference ref)
Definition: kmcommands.cpp:1469
KMUrlSaveCommand::KMUrlSaveCommand
KMUrlSaveCommand(const KUrl &url, QWidget *parent)
Definition: kmcommands.cpp:493
KMEditMessageCommand::KMEditMessageCommand
KMEditMessageCommand(QWidget *parent, const KMime::Message::Ptr &msg)
Definition: kmcommands.cpp:533
KMCommand::retrievedMsgs
const QList< Akonadi::Item > retrievedMsgs() const
Definition: kmcommands.cpp:215
KMail::Composer::setModified
virtual void setModified(bool modified)=0
KMMainWidget
Definition: kmmainwidget.h:83
KMRedirectCommand::KMRedirectCommand
KMRedirectCommand(QWidget *parent, const Akonadi::Item &msg)
Definition: kmcommands.cpp:990
KMail::Composer::setCurrentReplyTo
virtual void setCurrentReplyTo(const QString &replyTo)=0
util.h
kmkernel
#define kmkernel
Definition: kmkernel.h:22
KMCopyCommand::slotCopyResult
void slotCopyResult(KJob *job)
Definition: kmcommands.cpp:1367
KMCommand::OK
Definition: kmcommands.h:49
KMCommand::completed
void completed(KMCommand *command)
Emitted when the command has completed.
KMPrintCommand::setAttachmentStrategy
void setAttachmentStrategy(const MessageViewer::AttachmentStrategy *strategy)
Definition: kmcommands.cpp:1096
KMail::Composer::Reply
Definition: composer.h:44
KMResendMessageCommand::KMResendMessageCommand
KMResendMessageCommand(QWidget *parent, const Akonadi::Item &msg=Akonadi::Item())
Definition: kmcommands.cpp:1519
KMSetTagCommand::CleanExistingAndAddNew
Definition: kmcommands.h:434
KMForwardAttachedCommand::KMForwardAttachedCommand
KMForwardAttachedCommand(QWidget *parent, const QList< Akonadi::Item > &msgList, uint identity=0, KMail::Composer *win=0)
Definition: kmcommands.cpp:942
KMAddBookmarksCommand::KMAddBookmarksCommand
KMAddBookmarksCommand(const KUrl &url, QWidget *parent)
Definition: kmcommands.cpp:475
KPIM::ProgressItem::setUsesBusyIndicator
void setUsesBusyIndicator(bool useBusyIndicator)
KMSetStatusCommand::KMSetStatusCommand
KMSetStatusCommand(const MessageStatus &status, const Akonadi::Item::List &items, bool invert=false)
Definition: kmcommands.cpp:1130
KMCommand::emitsCompletedItself
bool emitsCompletedItself() const
Definition: kmcommands.h:97
KMMailtoComposeCommand::KMMailtoComposeCommand
KMMailtoComposeCommand(const KUrl &url, const Akonadi::Item &msg=Akonadi::Item())
Definition: kmcommands.cpp:382
KMPrintCommand::setPrintPreview
void setPrintPreview(bool preview)
Definition: kmcommands.cpp:1101
KMail::Composer::TemplateContext
TemplateContext
Definition: composer.h:44
KMCommand::Undefined
Definition: kmcommands.h:49
KMail::Composer::setCurrentTransport
virtual void setCurrentTransport(int transportId)=0
KMCommand::fetchScope
Akonadi::ItemFetchScope & fetchScope()
Allows to configure how much data should be retrieved of the messages.
Definition: kmcommands.h:79
composer.h
KPIM::ProgressItem
KMReaderMainWin
Definition: kmreadermainwin.h:32
KMSetTagCommand::KMSetTagCommand
KMSetTagCommand(const QList< QString > &tagLabel, const QList< Akonadi::Item > &item, SetTagMode mode=AddIfNotExisting)
Definition: kmcommands.cpp:1205
KMCommand::Failed
Definition: kmcommands.h:49
KMail::Util::lastEncryptAndSignState
void lastEncryptAndSignState(bool &lastEncrypt, bool &lastSign, const KMime::Message::Ptr &msg)
Definition: util.cpp:200
KMCopyCommand::KMCopyCommand
KMCopyCommand(const Akonadi::Collection &destFolder, const QList< Akonadi::Item > &msgList)
Definition: kmcommands.cpp:1345
KMail::Composer::setFocusToEditor
virtual void setFocusToEditor()=0
Sets the focus to the edit-widget and the cursor below the "On ... you wrote" line when hasMessage is...
KPIM::ProgressItem::setTotalItems
void setTotalItems(unsigned int v)
KMCommand::~KMCommand
virtual ~KMCommand()
Definition: kmcommands.cpp:203
KMMainWidget::addRecentFile
void addRecentFile(const KUrl &mUrl)
Definition: kmmainwidget.cpp:4854
KMail::Composer::New
Definition: composer.h:44
kmreadermainwin.h
kmcommands.h
main
int main(int argc, char *argv[])
Definition: main.cpp:97
KMSetTagCommand::SetTagMode
SetTagMode
Definition: kmcommands.h:434
broadcaststatus.h
KMReaderWin::setUseFixedFont
void setUseFixedFont(bool useFixedFont)
Definition: kmreaderwin.cpp:245
KMCommand::Result
Result
Definition: kmcommands.h:49
KJob
KMSaveMsgCommand::KMSaveMsgCommand
KMSaveMsgCommand(QWidget *parent, const QList< Akonadi::Item > &msgList)
Definition: kmcommands.cpp:667
QList< Akonadi::Item >
KMCommand::mRetrievedMsgs
QList< Akonadi::Item > mRetrievedMsgs
Definition: kmcommands.h:131
KMEditItemCommand::KMEditItemCommand
KMEditItemCommand(QWidget *parent, const Akonadi::Item &msg, bool deleteFromSource=true)
Definition: kmcommands.cpp:554
KMMailingListFilterCommand::KMMailingListFilterCommand
KMMailingListFilterCommand(QWidget *parent, const Akonadi::Item &msg)
Definition: kmcommands.cpp:1322
KMReaderWin::readConfig
void readConfig()
Read settings from app's config file.
Definition: kmreaderwin.cpp:262
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