4 #include <tqdatetime.h>
5 #include <tqguardedptr.h>
7 #include <tqvaluelist.h>
8 #include <tqvaluevector.h>
11 #include <tdeio/job.h>
12 #include "kmmsgbase.h"
13 #include <mimelib/string.h>
14 #include <tdemacros.h>
16 #include <tdetempfile.h>
21 class KProgressDialog;
35 namespace TDEIO {
class Job; }
43 namespace GpgME {
class Error; }
44 namespace Kleo {
class SpecialJob; }
46 typedef TQMap<int,KMFolder*> KMMenuToFolder;
47 typedef TQMap<partNode*, KMMessage*> PartNodeMessageMap;
49 class TDE_EXPORT KMCommand :
public TQObject
53 friend class LaterDeleterWithCommandCompletion;
56 enum Result { Undefined, OK, Canceled, Failed };
59 KMCommand( TQWidget *parent = 0 );
61 KMCommand( TQWidget *parent,
const TQPtrList<KMMsgBase> &msgList );
63 KMCommand( TQWidget *parent, KMMsgBase *msgBase );
65 KMCommand( TQWidget *parent,
KMMessage *message );
72 void keepFolderOpen(
KMFolder *folder );
84 void slotProgress(
unsigned long done,
unsigned long total );
89 void messagesTransfered( KMCommand::Result result );
92 void completed( KMCommand *command );
96 const TQPtrList<KMMessage> retrievedMsgs()
const;
100 TQWidget *parentWidget()
const;
102 bool deletesItself() {
return mDeletesItself; }
108 void setDeletesItself(
bool deletesItself )
109 { mDeletesItself = deletesItself; }
111 bool emitsCompletedItself() {
return mEmitsCompletedItself; }
118 void setEmitsCompletedItself(
bool emitsCompletedItself )
119 { mEmitsCompletedItself = emitsCompletedItself; }
124 void setResult( Result result )
125 { mResult = result; }
129 virtual Result execute() = 0;
133 void transferSelectedMsgs();
137 virtual void slotStart();
139 void slotPostTransfer( KMCommand::Result result );
143 void slotJobFinished();
145 void slotTransferCancelled();
149 KProgressDialog* mProgressDialog;
151 static int mCountJobs;
154 bool mDeletesItself : 1;
155 bool mEmitsCompletedItself : 1;
158 TQPtrList<KMMessage> mRetrievedMsgs;
159 TQPtrList<KMMsgBase> mMsgList;
160 TQValueList<TQGuardedPtr<KMFolder> > mFolders;
163 class TDE_EXPORT KMMailtoComposeCommand :
public KMCommand
169 KMMailtoComposeCommand(
const KURL &url,
KMMessage *msg=0 );
172 virtual Result execute();
178 class TDE_EXPORT KMMailtoReplyCommand :
public KMCommand
184 KMMailtoReplyCommand( TQWidget *parent,
const KURL &url,
185 KMMessage *msg,
const TQString &selection );
188 virtual Result execute();
194 class TDE_EXPORT KMMailtoForwardCommand :
public KMCommand
200 KMMailtoForwardCommand( TQWidget *parent,
const KURL &url,
204 virtual Result execute();
209 class TDE_EXPORT KMMailtoAddAddrBookCommand :
public KMCommand
215 KMMailtoAddAddrBookCommand(
const KURL &url, TQWidget *parent );
218 virtual Result execute();
223 class TDE_EXPORT KMAddBookmarksCommand :
public KMCommand
229 KMAddBookmarksCommand(
const KURL &url, TQWidget *parent );
232 virtual Result execute();
238 class TDE_EXPORT KMMailtoOpenAddrBookCommand :
public KMCommand
244 KMMailtoOpenAddrBookCommand(
const KURL &url, TQWidget *parent );
247 virtual Result execute();
252 class TDE_EXPORT KMUrlCopyCommand :
public KMCommand
258 KMUrlCopyCommand(
const KURL &url, KMMainWidget *mainWidget = 0 );
261 virtual Result execute();
264 KMMainWidget *mMainWidget;
267 class TDE_EXPORT KMUrlOpenCommand :
public KMCommand
273 KMUrlOpenCommand(
const KURL &url,
KMReaderWin *readerWin );
276 virtual Result execute();
282 class TDE_EXPORT KMUrlSaveCommand :
public KMCommand
288 KMUrlSaveCommand(
const KURL &url, TQWidget *parent );
291 void slotUrlSaveResult( TDEIO::Job *job );
294 virtual Result execute();
299 class TDE_EXPORT KMEditMsgCommand :
public KMCommand
305 KMEditMsgCommand( TQWidget *parent,
KMMessage *msg );
308 virtual Result execute();
311 class TDE_EXPORT KMUseTemplateCommand :
public KMCommand
317 KMUseTemplateCommand( TQWidget *parent,
KMMessage *msg );
320 virtual Result execute();
323 class TDE_EXPORT KMShowMsgSrcCommand :
public KMCommand
329 KMShowMsgSrcCommand( TQWidget *parent,
KMMessage *msg,
331 virtual Result execute();
335 bool mMsgWasComplete;
338 class TDE_EXPORT KMSaveMsgCommand :
public KMCommand
344 KMSaveMsgCommand( TQWidget *parent,
const TQPtrList<KMMsgBase> &msgList );
345 KMSaveMsgCommand( TQWidget *parent,
KMMessage * msg );
349 virtual Result execute();
352 void slotSaveDataReq();
353 void slotSaveResult(TDEIO::Job *job);
355 void slotMessageRetrievedForSaving(
KMMessage *msg);
358 static const int MAX_CHUNK_SIZE = 64*1024;
360 TQValueList<unsigned long> mMsgList;
361 TQValueList<KMMsgBase *> mUngetMsgs;
362 unsigned int mMsgListIndex;
367 TDEIO::TransferJob *mJob;
370 class TDE_EXPORT KMOpenMsgCommand :
public KMCommand
376 KMOpenMsgCommand( TQWidget *parent,
const KURL & url = KURL(),
377 const TQString & encoding = TQString() );
380 virtual Result execute();
383 void slotDataArrived( TDEIO::Job *job,
const TQByteArray & data );
384 void slotResult( TDEIO::Job *job );
387 static const int MAX_CHUNK_SIZE = 64*1024;
390 TDEIO::TransferJob *mJob;
391 const TQString mEncoding;
394 class TDE_EXPORT KMSaveAttachmentsCommand :
public KMCommand
403 KMSaveAttachmentsCommand( TQWidget *parent,
KMMessage *msg );
408 KMSaveAttachmentsCommand( TQWidget *parent,
const TQPtrList<KMMsgBase>& msgs );
417 KMSaveAttachmentsCommand( TQWidget *parent, TQPtrList<partNode> &attachments,
424 virtual Result execute();
425 Result saveItem( partNode *node,
const KURL& url );
428 PartNodeMessageMap mAttachmentMap;
429 bool mImplicitAttachments;
433 class TDE_EXPORT KMReplyToCommand :
public KMCommand
439 KMReplyToCommand( TQWidget *parent,
KMMessage *msg,
440 const TQString &selection = TQString() );
443 virtual Result execute();
449 class TDE_EXPORT KMNoQuoteReplyToCommand :
public KMCommand
455 KMNoQuoteReplyToCommand( TQWidget *parent,
KMMessage *msg );
458 virtual Result execute();
461 class KMReplyListCommand :
public KMCommand
467 KMReplyListCommand( TQWidget *parent,
KMMessage *msg,
468 const TQString &selection = TQString() );
471 virtual Result execute();
477 class TDE_EXPORT KMReplyToAllCommand :
public KMCommand
483 KMReplyToAllCommand( TQWidget *parent,
KMMessage *msg,
484 const TQString &selection = TQString() );
487 virtual Result execute();
493 class TDE_EXPORT KMReplyAuthorCommand :
public KMCommand
499 KMReplyAuthorCommand( TQWidget *parent,
KMMessage *msg,
500 const TQString &selection = TQString() );
503 virtual Result execute();
509 class TDE_EXPORT KMForwardInlineCommand :
public KMCommand
515 KMForwardInlineCommand( TQWidget *parent,
const TQPtrList<KMMsgBase> &msgList,
517 KMForwardInlineCommand( TQWidget *parent,
KMMessage * msg,
521 virtual Result execute();
527 class TDE_EXPORT KMForwardAttachedCommand :
public KMCommand
533 KMForwardAttachedCommand( TQWidget *parent,
const TQPtrList<KMMsgBase> &msgList,
534 uint identity = 0, KMail::Composer *win = 0 );
535 KMForwardAttachedCommand( TQWidget *parent,
KMMessage * msg,
536 uint identity = 0, KMail::Composer *win = 0 );
539 virtual Result execute();
542 TQGuardedPtr<KMail::Composer> mWin;
545 class TDE_EXPORT KMForwardDigestCommand :
public KMCommand
551 KMForwardDigestCommand( TQWidget *parent,
const TQPtrList<KMMsgBase> &msgList,
552 uint identity = 0, KMail::Composer *win = 0 );
553 KMForwardDigestCommand( TQWidget *parent,
KMMessage * msg,
554 uint identity = 0, KMail::Composer *win = 0 );
557 virtual Result execute();
560 TQGuardedPtr<KMail::Composer> mWin;
563 class TDE_EXPORT KMRedirectCommand :
public KMCommand
569 KMRedirectCommand( TQWidget *parent,
KMMessage *msg );
572 virtual Result execute();
575 class TDE_EXPORT KMCustomReplyToCommand :
public KMCommand
581 KMCustomReplyToCommand( TQWidget *parent,
KMMessage *msg,
582 const TQString &selection,
583 const TQString &tmpl );
586 virtual Result execute();
593 class TDE_EXPORT KMCustomReplyAllToCommand :
public KMCommand
599 KMCustomReplyAllToCommand( TQWidget *parent,
KMMessage *msg,
600 const TQString &selection,
601 const TQString &tmpl );
604 virtual Result execute();
611 class TDE_EXPORT KMCustomForwardCommand :
public KMCommand
617 KMCustomForwardCommand( TQWidget *parent,
const TQPtrList<KMMsgBase> &msgList,
618 uint identity,
const TQString &tmpl );
619 KMCustomForwardCommand( TQWidget *parent,
KMMessage * msg,
620 uint identity,
const TQString &tmpl );
623 virtual Result execute();
629 class TDE_EXPORT KMPrintCommand :
public KMCommand
635 KMPrintCommand( TQWidget *parent,
KMMessage *msg,
637 const KMail::HeaderStrategy *headerStrategy = 0,
638 bool htmlOverride =
false,
639 bool htmlLoadExtOverride =
false,
640 bool useFixedFont =
false,
641 const TQString & encoding = TQString() );
643 void setOverrideFont(
const TQFont& );
646 virtual Result execute();
649 const KMail::HeaderStrategy *mHeaderStrategy;
651 bool mHtmlLoadExtOverride;
653 TQFont mOverrideFont;
657 class TDE_EXPORT KMSeStatusCommand :
public KMCommand
664 KMSeStatusCommand( KMMsgStatus status,
const TQValueList<TQ_UINT32> &,
668 virtual Result execute();
671 TQValueList<TQ_UINT32> mSerNums;
672 TQValueList<int> mIds;
676 class TDE_EXPORT KMFilterCommand :
public KMCommand
682 KMFilterCommand(
const TQCString &field,
const TQString &value );
685 virtual Result execute();
692 class TDE_EXPORT KMFilterActionCommand :
public KMCommand
698 KMFilterActionCommand( TQWidget *parent,
699 const TQPtrList<KMMsgBase> &msgList,
703 virtual Result execute();
704 TQValueList<TQ_UINT32> serNumList;
709 class TDE_EXPORT KMMetaFilterActionCommand :
public TQObject
715 KMMetaFilterActionCommand( KMFilter *filter,
KMHeaders *headers,
716 KMMainWidget *main );
724 KMMainWidget *mMainWidget;
727 class TDE_EXPORT FolderShortcutCommand :
public TQObject
733 FolderShortcutCommand( KMMainWidget* mainwidget,
KMFolder *folder );
734 ~FolderShortcutCommand();
741 void setAction( TDEAction* );
744 KMMainWidget *mMainWidget;
750 class TDE_EXPORT KMMailingListFilterCommand :
public KMCommand
756 KMMailingListFilterCommand( TQWidget *parent,
KMMessage *msg );
759 virtual Result execute();
776 static void folderToPopupMenu(
bool move, TQObject *receiver,
777 KMMenuToFolder *aMenuToFolder, TQPopupMenu *menu );
779 static void makeFolderMenu(KMFolderNode* item,
bool move,
780 TQObject *receiver, KMMenuToFolder *aMenuToFolder, TQPopupMenu *menu );
789 KMCopyCommand(
KMFolder* destFolder,
790 const TQPtrList<KMMsgBase> &msgList );
794 void slotJobFinished( KMail::FolderJob *job );
796 void slotFolderComplete( KMFolderImap*,
bool success );
799 virtual Result execute();
802 TQPtrList<KMMsgBase> mMsgList;
803 TQValueList<KMail::FolderJob*> mPendingJobs;
815 KMMoveCommand(
KMFolder* destFolder,
const TQPtrList<KMMsgBase> &msgList );
817 KMMoveCommand(
KMFolder* destFolder, KMMsgBase * msgBase );
818 KMFolder* destFolder()
const {
return mDestFolder; }
821 void slotImapFolderCompleted(KMFolderImap *folder,
bool success);
822 void slotMsgAddedToDestFolder(
KMFolder *folder, TQ_UINT32 serNum);
823 void slotMoveCanceled();
827 KMMoveCommand( TQ_UINT32 sernum );
828 void setDestFolder(
KMFolder* folder ) { mDestFolder = folder; }
829 void addMsg( KMMsgBase *msg ) { mSerNumList.append( msg->getMsgSerNum() ); }
830 TQValueVector<KMFolder*> mOpenedFolders;
833 virtual Result execute();
834 void completeMove( Result result );
837 TQValueList<TQ_UINT32> mSerNumList;
840 TQValueList<TQ_UINT32> mLostBoys;
841 KPIM::ProgressItem *mProgressItem;
842 bool mCompleteWithAddedMsg;
845 class TDE_EXPORT KMDeleteMsgCommand :
public KMMoveCommand
851 KMDeleteMsgCommand(
KMFolder* srcFolder,
const TQPtrList<KMMsgBase> &msgList );
853 KMDeleteMsgCommand( TQ_UINT32 sernum );
860 class TDE_EXPORT KMUrlClickedCommand :
public KMCommand
866 KMUrlClickedCommand(
const KURL &url, uint identity,
867 KMReaderWin *readerWin,
bool mHtmlPref, KMMainWidget *mainWidget = 0 );
870 virtual Result execute();
876 KMMainWidget *mMainWidget;
879 class TDE_EXPORT KMLoadPartsCommand :
public KMCommand
885 KMLoadPartsCommand( TQPtrList<partNode>& parts,
KMMessage* msg );
886 KMLoadPartsCommand( partNode* node,
KMMessage* msg );
887 KMLoadPartsCommand( PartNodeMessageMap& partMap );
890 void slotPartRetrieved(
KMMessage* msg, TQString partSpecifier );
893 void partsRetrieved();
897 virtual void slotStart();
899 virtual Result execute();
902 PartNodeMessageMap mPartMap;
905 class TDE_EXPORT KMResendMessageCommand :
public KMCommand
911 KMResendMessageCommand( TQWidget *parent,
KMMessage *msg=0 );
914 virtual Result execute();
917 class TDE_EXPORT KMMailingListCommand :
public KMCommand
922 KMMailingListCommand( TQWidget *parent,
KMFolder *folder );
924 virtual Result execute();
926 void commandCompleted( KMCommand *command );
928 virtual KURL::List urls()
const =0;
933 class TDE_EXPORT KMMailingListPostCommand :
public KMMailingListCommand
938 KMMailingListPostCommand( TQWidget *parent,
KMFolder *folder );
940 virtual KURL::List urls()
const;
943 class TDE_EXPORT KMMailingListSubscribeCommand :
public KMMailingListCommand
948 KMMailingListSubscribeCommand( TQWidget *parent,
KMFolder *folder );
950 virtual KURL::List urls()
const;
953 class TDE_EXPORT KMMailingListUnsubscribeCommand :
public KMMailingListCommand
958 KMMailingListUnsubscribeCommand( TQWidget *parent,
KMFolder *folder );
960 virtual KURL::List urls()
const;
963 class TDE_EXPORT KMMailingListArchivesCommand :
public KMMailingListCommand
968 KMMailingListArchivesCommand( TQWidget *parent,
KMFolder *folder );
970 virtual KURL::List urls()
const;
973 class TDE_EXPORT KMMailingListHelpCommand :
public KMMailingListCommand
978 KMMailingListHelpCommand( TQWidget *parent,
KMFolder *folder );
980 virtual KURL::List urls()
const;
983 class TDE_EXPORT KMIMChatCommand :
public KMCommand
989 KMIMChatCommand(
const KURL &url,
KMMessage *msg=0 );
998 virtual Result execute();
1004 class TDE_EXPORT KMHandleAttachmentCommand :
public KMCommand
1011 enum AttachmentAction
1029 KMHandleAttachmentCommand( partNode* node,
KMMessage* msg,
int atmId,
1030 const TQString& atmName, AttachmentAction action, KService::Ptr offer, TQWidget* parent );
1034 void showAttachment(
int id,
const TQString& name );
1037 virtual Result execute();
1039 TQString createAtmFileLink()
const;
1042 KService::Ptr getServiceOffer();
1060 void atmProperties();
1063 void atmEncryptWithChiasmus();
1067 virtual void slotStart();
1073 void slotPartComplete();
1075 void slotAtmDecryptWithChiasmusResult(
const GpgME::Error &,
const TQVariant & );
1076 void slotAtmDecryptWithChiasmusUploadResult( TDEIO::Job * );
1083 AttachmentAction mAction;
1084 KService::Ptr mOffer;
1085 Kleo::SpecialJob *mJob;
1101 void storeChangedMessage(
KMMessage* msg );
1102 virtual Result doAttachmentModify() = 0;
1112 void messageStoreResult( KMFolderImap* folder,
bool success );
1113 void messageDeleteResult( KMCommand *cmd );
1116 TQGuardedPtr<KMFolder> mFolder;
1124 KMDeleteAttachmentCommand( partNode *node,
KMMessage *msg, TQWidget *parent );
1125 KMDeleteAttachmentCommand(
int nodeId,
KMMessage *msg, TQWidget *parent );
1126 ~KMDeleteAttachmentCommand();
1129 Result doAttachmentModify();
1138 KMEditAttachmentCommand( partNode *node,
KMMessage *msg, TQWidget *parent );
1139 KMEditAttachmentCommand(
int nodeId,
KMMessage *msg, TQWidget *parent );
1140 ~KMEditAttachmentCommand();
1143 Result doAttachmentModify();
1149 KTempFile mTempFile;
1152 class TDE_EXPORT CreateTodoCommand :
public KMCommand
1157 CreateTodoCommand( TQWidget *parent,
KMMessage *msg );
Base class for commands modifying attachements of existing messages.
Returns a popupmenu containing a hierarchy of folder names.
This class implements a "reader window", that is a window used for reading or viewing messages.
Starts an editor for the given URL and emits an signal when editing has been finished.