kmail

kmcomposewin.h
1/*
2 * KMComposeWin Header File
3 * Author: Markus Wuebben <markus.wuebben@kde.org>
4 */
5#ifndef __KMComposeWin
6#define __KMComposeWin
7
8#ifndef KDE_USE_FINAL
9# ifndef REALLY_WANT_KMCOMPOSEWIN_H
10# error Do not include kmcomposewin.h anymore. Include composer.h instead.
11# endif
12#endif
13
14#include "composer.h"
15#include "messagesender.h"
16
17#include <set>
18
19#include <tqlabel.h>
20#include <tqlistview.h>
21
22#include <tqcheckbox.h>
23#include <tqpushbutton.h>
24#include <tqclipboard.h>
25#include <tqpalette.h>
26#include <tqfont.h>
27#include <tqptrlist.h>
28#include <tqvaluevector.h>
29#include <tqsplitter.h>
30
31#include <tdeio/job.h>
32#include <tdeglobalsettings.h>
33#include <keditcl.h>
34#include <ktempdir.h>
35
36#include "mailcomposerIface.h"
37#include "accountmanager.h"
38
39#include <libtdepim/addresseelineedit.h>
40#include <mimelib/mediatyp.h>
41
42#include <kleo/enum.h>
43
44class TQCloseEvent;
45class TQComboBox;
46class TQFrame;
47class TQGridLayout;
48class TQListView;
49class TQPopupMenu;
50class TQPushButton;
51class TQCString;
52class TDECompletion;
53class KMEdit;
54class KMComposeWin;
55class KMFolderComboBox;
56class KMFolder;
57class KMMessage;
58class KMMessagePart;
59class TDEProcess;
60class KDirWatch;
61class TDESelectAction;
62class TDEFontAction;
63class TDEFontSizeAction;
64class TDESelectAction;
65class KStatusBar;
66class TDEAction;
67class TDEToggleAction;
68class KTempFile;
69class TDEToolBar;
70class TDEToggleAction;
71class TDESelectColorAction;
72class KURL;
73class TDERecentFilesAction;
74class SpellingFilter;
75class MessageComposer;
76class RecipientsEditor;
77class KMLineEdit;
78class KMLineEditSpell;
79class KMAtmListViewItem;
80class SnippetWidget;
81
82namespace KPIM {
83 class IdentityCombo;
84 class Identity;
85}
86
87namespace KMail {
88 class AttachmentListView;
89 class DictionaryComboBox;
90 class EditorWatcher;
91}
92
93namespace GpgME {
94 class Error;
95}
96
97//-----------------------------------------------------------------------------
98class KMComposeWin : public KMail::Composer, public MailComposerIface
99{
100 TQ_OBJECT
101
102 friend class ::KMEdit;
103 friend class ::MessageComposer;
104
105private: // mailserviceimpl, kmkernel, kmcommands, callback, kmmainwidget
106 KMComposeWin( KMMessage* msg=0, uint identity=0 );
107 ~KMComposeWin();
108public:
109 static Composer * create( KMMessage * msg = 0, uint identity = 0 );
110
111 MailComposerIface * asMailComposerIFace() { return this; }
112 const MailComposerIface * asMailComposerIFace() const { return this; }
113
114public: // mailserviceimpl
118 void send(int how);
119 void addAttachmentsAndSend(const KURL::List &urls, const TQString &comment, int how);
120 void addAttachment(KURL url,TQString comment);
121 void addAttachment(const TQString &name,
122 const TQCString &cte,
123 const TQByteArray &data,
124 const TQCString &type,
125 const TQCString &subType,
126 const TQCString &paramAttr,
127 const TQString &paramValue,
128 const TQCString &contDisp);
129public: // kmcommand
130 void setBody (TQString body);
131
132private:
136 virtual bool event(TQEvent *e);
137
141 void readColorConfig();
142
146 void writeConfig(void);
147
152 void verifyWordWrapLengthIsAdequate(const TQString&);
153
154public: // kmkernel, kmcommands, callback
159 void setMsg(KMMessage* newMsg, bool mayAutoSign=true,
160 bool allowDecryption=false, bool isModified=false);
161
162 void disableWordWrap();
163
167 void disableRecipientNumberCheck();
168
172 void disableForgottenAttachmentsCheck();
173
183 void ignoreStickyFields();
184
188 bool isComposing() const { return mComposer != 0; }
189
190private: // kmedit
195 KMMessage* msg() const { return mMsg; }
196
197public: // kmkernel
201 void setAutoSaveFilename( const TQString & filename );
202
203private:
207 bool isModified() const;
208
212 void setModified( bool modified );
213
214public: // kmkernel, callback
219 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
220
225 void setAutoDeleteWindow( bool f );
226
227public: // kmcommand
232 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
233public: // kmkernel, kmcommand, mailserviceimpl
237 void setCharset(const TQCString& aCharset, bool forceDefault = false);
238
239public: // kmcommand
245 void setReplyFocus( bool hasMessage = true );
246
251 void setFocusToSubject();
252
253private:
257 bool inlineSigningEncryptionSelected();
258
264 static TQString prettyMimeType( const TQString& type );
265 TQString quotePrefixName() const;
266
267private: // kmedit:
268 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
269 void setSubjectTextWasSpellChecked( bool _spell ) {
270 mSubjectTextWasSpellChecked = _spell;
271 }
272 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
273
274 void paste( TQClipboard::Mode mode );
275
276public: // callback
278 void setSigningAndEncryptionDisabled( bool v )
279 {
280 mSigningAndEncryptionExplicitlyDisabled = v;
281 }
282
283private slots:
284 void polish();
288 void slotPrint();
289 void slotAttachFile();
290 void slotInsertRecentFile(const KURL&);
291 void slotAttachedFile(const KURL&);
292public slots: // kmkernel, callback
293 void slotSendNow();
294private slots:
295 void slotSendNowVia( int item );
296 void slotSendLater();
297 void slotSendLaterVia( int item );
298
299 void getTransportMenu();
300
304 void slotSaveDraft();
305 void slotSaveTemplate();
306 void slotNewComposer();
307 void slotNewMailReader();
308 void slotClose();
309 void slotHelp();
310
311 void slotFind();
312 void slotSearchAgain();
313 void slotReplace();
314 void slotUndo();
315 void slotRedo();
316 void slotCut();
317 void slotCopy();
318 void slotPasteClipboard();
319 void slotPasteClipboardAsQuotation();
320 void slotPasteClipboardAsAttachment();
321 void slotAddQuotes();
322 void slotRemoveQuotes();
323 void slotAttachPNGImageData(const TQByteArray &image);
324
325 void slotMarkAll();
326
327 void slotFolderRemoved(KMFolder*);
328
329 void slotEditDone( KMail::EditorWatcher* watcher );
330
331public slots: // kmkernel
338 void slotSetAlwaysSend( bool bAlwaysSend );
339private slots:
343 void slotUpdateFont();
344
348 void slotAddrBook();
352 void slotInsertFile();
353
354 void slotSetCharset();
358 void slotSpellcheck();
359 void slotSpellcheckConfig();
360 void slotSubjectTextSpellChecked();
361
366 void slotSelectCryptoModule( bool init = false );
367
371 void slotStatusMessage(const TQString &message);
372 void slotEditToolbars();
373 void slotUpdateToolbars();
374 void slotEditKeys();
378 void readConfig( bool reload = false );
382 void slotUpdWinTitle(const TQString& );
383
388 void slotEncryptToggled(bool);
389
393 void slotSignToggled(bool);
394
395public slots: // kmkernel, callback
399 void slotWordWrapToggled(bool);
400
401private slots:
405 void slotAppendSignature();
406
410 void slotPrependSignature();
411
415 void slotInsertSignatureAtCursor();
416
420 void slotInsertMyPublicKey();
421
425 void slotInsertPublicKey();
426
430 void slotUpdateAttachActions();
431
435 void slotAttachPopupMenu(TQListViewItem *, const TQPoint &, int);
436
441 int currentAttachmentNum();
442
446 void slotAttachOpen();
447 void slotAttachView();
448 void slotAttachRemove();
449 void slotAttachSave();
450 void slotAttachProperties();
451 void slotAttachOpenWith();
452 void slotAttachEdit();
453 void slotAttachEditWith();
454 void slotAttachmentDragStarted();
455
460 void slotAddrBookTo();
461 void slotAddrBookFrom();
462 void slotAddrBookReplyTo();
463
464 void slotCleanSpace();
465
466 void slotToggleMarkup();
467 void toggleMarkup(bool markup);
468 void htmlToolBarVisibilityChanged( bool visible );
469
470// void slotSpellConfigure();
471 void slotSpellcheckDone(int result);
472 void slotSpellcheckDoneClearStatus();
473
474public slots: // kmkernel
475 void autoSaveMessage();
476
477private slots:
478 void updateCursorPosition();
479
480 void slotView();
481
485 void slotIdentityChanged(uint);
486
490 void slotAttachFileData(TDEIO::Job *, const TQByteArray &);
491 void slotAttachFileResult(TDEIO::Job *);
492
493 void slotListAction(const TQString &);
494 void slotFontAction(const TQString &);
495 void slotSizeAction(int);
496 void slotAlignLeft();
497 void slotAlignCenter();
498 void slotAlignRight();
499 void slotTextBold();
500 void slotTextItalic();
501 void slotTextUnder();
502 void slotFormatReset();
503 void slotTextColor();
504 void fontChanged( const TQFont & );
505 void alignmentChanged( int );
506
507public: // kmkernel, attachmentlistview
508 bool addAttach(const KURL url);
509
510public: // kmcommand
514 void addAttach(const KMMessagePart* msgPart);
515
516private:
517 const KPIM::Identity & identity() const;
518 uint identityUid() const;
519 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
520 bool encryptToSelf() const;
521
522signals:
523 void applyChangesDone( bool );
524 void attachmentAdded( const KURL&, bool success );
525
526private:
534 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
535
541 void rethinkFields(bool fromslot=false);
542
546 TQWidget *connectFocusMoving( TQWidget *prev, TQWidget *next );
547
552 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
553 TQLabel* aLbl,
554 TQLineEdit* aEdt, TQPushButton* aBtn = 0,
555 const TQString &toolTip = TQString(),
556 const TQString &whatsThis = TQString() );
557
558 void rethinkHeaderLine( int value, int mask, int& row,
559 TQLabel* lbl, TQComboBox* cbx, TQCheckBox *chk );
560
565 bool checkRecipientNumber() const;
566
567
568 bool checkTransport() const;
569
573 void setupActions();
574 void setupStatusBar();
575 void setupEditor();
576
577
581 TQString subject() const;
582 TQString to() const;
583 TQString cc() const;
584 TQString bcc() const;
585 TQString from() const;
586 TQString replyTo() const;
587
593 void setFcc( const TQString &idString );
594
598 virtual bool queryClose ();
602 virtual bool queryExit ();
603
607 void openAttach( int index, bool with );
608
612 void viewAttach( int index );
613
617 void editAttach( int index, bool openWith );
618
622 void removeAttach(const TQString &url);
623 void removeAttach(int idx);
624
628 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
629 bool loadDefaults = true );
630
635 void addrBookSelInto();
636
637 void addrBookSelIntoOld();
638 void addrBookSelIntoNew();
639
640private:
645 void setEncryption( bool encrypt, bool setByUser = false );
646
651 void setSigning( bool sign, bool setByUser = false );
652
656 bool userForgotAttachment();
657
662 bool encryptFlagOfAttachment(int idx);
663
668 bool signFlagOfAttachment(int idx);
669
670
678 static void decryptOrStripOffCleartextSignature( TQCString& );
679
683 bool saveDraftOrTemplate( const TQString &folderName, KMMessage *msg );
684
688 enum SaveIn { None, Drafts, Templates };
689 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
690 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
691
695 int autoSaveInterval() const;
696
700 void initAutoSave();
701
706 void updateAutoSave();
707
711 void cleanupAutoSave();
712
718 static bool validateAddresses( TQWidget * parent, const TQString & addresses );
719
726 void setTransport( const TQString & transport );
727
728 enum SignaturePlacement { Append, Prepend, AtCursor };
729
734 void insertSignature( SignaturePlacement placement = Append );
735private slots:
739 void compressAttach(int idx);
740 void uncompressAttach(int idx);
741 void editorFocusChanged(bool gained);
742 void recipientEditorSizeHintChanged();
743 void setMaximumHeaderSize();
744
745private:
746 TQWidget *mMainWidget;
747 TQComboBox *mTransport;
748 KMail::DictionaryComboBox *mDictionaryCombo;
749 KPIM::IdentityCombo *mIdentity;
750 KMFolderComboBox *mFcc;
751 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
752 KMLineEditSpell *mEdtSubject;
753 TQLabel *mLblIdentity, *mLblTransport, *mLblFcc;
754 TQLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
755 TQLabel *mDictionaryLabel;
756 TQCheckBox *mBtnIdentity, *mBtnDictionary, *mBtnTransport, *mBtnFcc;
757 TQPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo;
758 bool mSpellCheckInProgress;
759 bool mDone;
760 bool mAtmModified;
761 TQListViewItem *mAtmSelectNew;
762
763 KMEdit* mEditor;
764 TQGridLayout* mGrid;
765 KMMessage *mMsg;
766 TQValueVector<KMMessage*> mComposedMessages;
767 KMail::AttachmentListView* mAtmListView;
768 int mAtmColEncrypt;
769 int mAtmColSign;
770 int mAtmColCompress;
771 int mAtmEncryptColWidth;
772 int mAtmSignColWidth;
773 int mAtmCompressColWidth;
774 TQPtrList<TQListViewItem> mAtmItemList;
775 TQPtrList<KMMessagePart> mAtmList;
776 TQPopupMenu *mAttachMenu;
777 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
778 bool mAutoDeleteMsg;
779 bool mSigningAndEncryptionExplicitlyDisabled;
780 bool mLastSignActionState, mLastEncryptActionState;
781 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
782 KMFolder *mFolder;
783 long mShowHeaders;
784 bool mConfirmSend;
785 bool mDisableBreaking; // Move
786 int mNumHeaders;
787 bool mUseHTMLEditor;
788 bool mHtmlMarkup;
789 TQFont mBodyFont, mFixedFont;
790 TQPtrList<KTempFile> mAtmTempList;
791 TQPalette mPalette;
792 uint mId;
793 TQString mOldSigText;
794
795 TDEAction *mAttachPK, *mAttachMPK,
796 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
797 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
798 TDERecentFilesAction *mRecentAction;
799
800 TDEAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
801
802 TDEToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
803 TDEToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
804 TDEToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
805 TDEToggleAction *mSubjectAction;
806 TDEToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
807 TDEToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
808 TDEToggleAction *mDictionaryAction, *mSnippetAction;
809
810 TDESelectAction *listAction;
811 TDEFontAction *fontAction;
812 TDEFontSizeAction *fontSizeAction;
813 TDEToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
814 TDEToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
815 TDEToggleAction *plainTextAction, *markupAction;
816 TDEAction *actionFormatColor, *actionFormatReset;
817 TDEAction *mHtmlToolbar;
818
819 TDESelectAction *mEncodingAction;
820 TDESelectAction *mCryptoModuleAction;
821
822 TQCString mCharset;
823 TQCString mDefCharset;
824 TQStringList mCharsets;
825 bool mAutoCharset;
826
827 bool mAlwaysSend;
828
829 TQStringList mFolderNames;
830 TQValueList<TQGuardedPtr<KMFolder> > mFolderList;
831 TQMap<TDEIO::Job*, KURL> mAttachJobs;
832 KURL::List mAttachFilesPending;
833 int mAttachFilesSend;
834
835private:
836 // helper method for slotInsert(My)PublicKey()
837 void startPublicKeyExport();
838 bool canSignEncryptAttachments() const {
839 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
840 }
841
842 bool mSubjectTextWasSpellChecked;
843
844 TQString addQuotesToText( const TQString &inputText );
845 TQString removeQuotesFromText( const TQString &inputText );
846 // helper method for rethinkFields
847 int calcColumnWidth(int which, long allShowing, int width);
848
849private slots:
850 void slotCompletionModeChanged( TDEGlobalSettings::Completion );
851 void slotConfigChanged();
852
853 void slotComposerDone( bool );
854
855 void slotContinueDoSend( bool );
856 void slotContinuePrint( bool );
857 void slotContinueAutoSave();
858
859 void slotEncryptChiasmusToggled( bool );
860
865 void slotPublicKeyExportResult( const GpgME::Error & err, const TQByteArray & keydata );
866
870 void slotAutoSpellCheckingToggled(bool);
871
875 void slotUpdateSignatureActions();
876
880 void slotUpdateSignatureAndEncrypionStateIndicators();
881private:
882 TQColor mForeColor,mBackColor;
883 TQFont mSaveFont;
884 TQSplitter *mHeadersToEditorSplitter;
885 TQWidget* mHeadersArea;
886 TQSplitter *mSplitter;
887 TQSplitter *mSnippetSplitter;
888 struct atmLoadData
889 {
890 KURL url;
891 TQByteArray data;
892 bool insert;
893 TQCString encoding;
894 };
895 TQMap<TDEIO::Job *, atmLoadData> mMapAtmLoadData;
896
897 // These are for passing on methods over the applyChanges calls
898 KMail::MessageSender::SendMethod mSendMethod;
899 KMComposeWin::SaveIn mSaveIn;
900
901 TDEToggleAction *mEncryptChiasmusAction;
902 bool mEncryptWithChiasmus;
903
904 // This is the temporary object that constructs the message out of the
905 // window
906 MessageComposer* mComposer;
907
908 // Temp var for slotPrint:
909 bool mMessageWasModified;
910
911 // Temp var for slotInsert(My)PublicKey():
912 TQString mFingerprint;
913
914 // Temp ptr for saving image from clipboard
915 KTempDir *mTempDir;
916
917 bool mClassicalRecipients;
918
919 RecipientsEditor *mRecipientsEditor;
920 int mLabelWidth;
921
922 TQTimer *mAutoSaveTimer;
923 TQString mAutoSaveFilename;
924 int mLastAutoSaveErrno; // holds the errno of the last try to autosave
925
926 TQPopupMenu *mActNowMenu;
927 TQPopupMenu *mActLaterMenu;
928
929 TQMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
930 TQMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
931
932 TQLabel *mSignatureStateIndicator;
933 TQLabel *mEncryptionStateIndicator;
934
935 SnippetWidget *mSnippetWidget;
936 std::set<KTempDir*> mTempDirs;
937
945 bool mPreserveUserCursorPosition;
946
947 bool mPreventFccOverwrite;
948 bool mCheckForRecipients;
949 bool mCheckForForgottenAttachments;
950 bool mIgnoreStickyFields;
951};
952
953#endif
954
Mail folder.
Definition: kmfolder.h:69
This is a Mime Message.
Definition: kmmessage.h:68
A combo box for selecting the dictionary used for spell checking.
Starts an editor for the given URL and emits an signal when editing has been finished.
Definition: editorwatcher.h:39
DCOP interface for mail composer window.
virtual void setBody(TQString body)=0
Set message body.
virtual void addAttachment(KURL url, TQString comment)=0
Add url as attachment with a user-defined comment.
virtual void send(int how)=0
Send message.
This is the widget which gets added to the right TreeToolView.
Definition: snippetwidget.h:46
folderdiaquotatab.h
Definition: aboutdata.cpp:40