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 <tdeversion.h>
34#include <keditcl.h>
35#include <ktempdir.h>
36
37#include "mailcomposerIface.h"
38#include "accountmanager.h"
39
40#include <libtdepim/addresseelineedit.h>
41#include <mimelib/mediatyp.h>
42
43#include <kleo/enum.h>
44
45class TQCloseEvent;
46class TQComboBox;
47class TQFrame;
48class TQGridLayout;
49class TQListView;
50class TQPopupMenu;
51class TQPushButton;
52class TQCString;
53class TDECompletion;
54class KMEdit;
55class KMComposeWin;
56class KMFolderComboBox;
57class KMFolder;
58class KMMessage;
59class KMMessagePart;
60class TDEProcess;
61class KDirWatch;
62class TDESelectAction;
63class TDEFontAction;
64class TDEFontSizeAction;
65class TDESelectAction;
66class KStatusBar;
67class TDEAction;
68class TDEToggleAction;
69class KTempFile;
70class TDEToolBar;
71class TDEToggleAction;
72class TDESelectColorAction;
73class KURL;
74class TDERecentFilesAction;
75class SpellingFilter;
76class MessageComposer;
77class RecipientsEditor;
78class KMLineEdit;
79class KMLineEditSpell;
80class KMAtmListViewItem;
81class SnippetWidget;
82
83namespace KPIM {
84 class IdentityCombo;
85 class Identity;
86}
87
88namespace KMail {
89 class AttachmentListView;
90 class DictionaryComboBox;
91 class EditorWatcher;
92}
93
94namespace GpgME {
95 class Error;
96}
97
98//-----------------------------------------------------------------------------
99class KMComposeWin : public KMail::Composer, public MailComposerIface
100{
101 TQ_OBJECT
102
103 friend class ::KMEdit;
104 friend class ::MessageComposer;
105
106private: // mailserviceimpl, kmkernel, kmcommands, callback, kmmainwidget
107 KMComposeWin( KMMessage* msg=0, uint identity=0 );
108 ~KMComposeWin();
109public:
110 static Composer * create( KMMessage * msg = 0, uint identity = 0 );
111
112 MailComposerIface * asMailComposerIFace() { return this; }
113 const MailComposerIface * asMailComposerIFace() const { return this; }
114
115public: // mailserviceimpl
119 void send(int how);
120 void addAttachmentsAndSend(const KURL::List &urls, const TQString &comment, int how);
121 void addAttachment(KURL url,TQString comment);
122 void addAttachment(const TQString &name,
123 const TQCString &cte,
124 const TQByteArray &data,
125 const TQCString &type,
126 const TQCString &subType,
127 const TQCString &paramAttr,
128 const TQString &paramValue,
129 const TQCString &contDisp);
130public: // kmcommand
131 void setBody (TQString body);
132
133private:
137 virtual bool event(TQEvent *e);
138
142 void readColorConfig();
143
147 void writeConfig(void);
148
153 void verifyWordWrapLengthIsAdequate(const TQString&);
154
155public: // kmkernel, kmcommands, callback
160 void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
161 bool allowDecryption=FALSE, bool isModified=FALSE);
162
163 void disableWordWrap();
164
168 void disableRecipientNumberCheck();
169
173 void disableForgottenAttachmentsCheck();
174
184 void ignoreStickyFields();
185
189 bool isComposing() const { return mComposer != 0; }
190
191private: // kmedit
196 KMMessage* msg() const { return mMsg; }
197
198public: // kmkernel
202 void setAutoSaveFilename( const TQString & filename );
203
204private:
208 bool isModified() const;
209
213 void setModified( bool modified );
214
215public: // kmkernel, callback
220 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
221
226 void setAutoDeleteWindow( bool f );
227
228public: // kmcommand
233 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
234public: // kmkernel, kmcommand, mailserviceimpl
238 void setCharset(const TQCString& aCharset, bool forceDefault = FALSE);
239
240public: // kmcommand
246 void setReplyFocus( bool hasMessage = true );
247
252 void setFocusToSubject();
253
254private:
258 bool inlineSigningEncryptionSelected();
259
265 static TQString prettyMimeType( const TQString& type );
266 TQString quotePrefixName() const;
267
268private: // kmedit:
269 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
270 void setSubjectTextWasSpellChecked( bool _spell ) {
271 mSubjectTextWasSpellChecked = _spell;
272 }
273 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
274
275 void paste( TQClipboard::Mode mode );
276
277public: // callback
279 void setSigningAndEncryptionDisabled( bool v )
280 {
281 mSigningAndEncryptionExplicitlyDisabled = v;
282 }
283
284private slots:
285 void polish();
289 void slotPrint();
290 void slotAttachFile();
291 void slotInsertRecentFile(const KURL&);
292 void slotAttachedFile(const KURL&);
293public slots: // kmkernel, callback
294 void slotSendNow();
295private slots:
296 void slotSendNowVia( int item );
297 void slotSendLater();
298 void slotSendLaterVia( int item );
299
300 void getTransportMenu();
301
305 void slotSaveDraft();
306 void slotSaveTemplate();
307 void slotNewComposer();
308 void slotNewMailReader();
309 void slotClose();
310 void slotHelp();
311
312 void slotFind();
313 void slotSearchAgain();
314 void slotReplace();
315 void slotUndo();
316 void slotRedo();
317 void slotCut();
318 void slotCopy();
319 void slotPasteClipboard();
320 void slotPasteClipboardAsQuotation();
321 void slotPasteClipboardAsAttachment();
322 void slotAddQuotes();
323 void slotRemoveQuotes();
324 void slotAttachPNGImageData(const TQByteArray &image);
325
326 void slotMarkAll();
327
328 void slotFolderRemoved(KMFolder*);
329
330 void slotEditDone( KMail::EditorWatcher* watcher );
331
332public slots: // kmkernel
339 void slotSetAlwaysSend( bool bAlwaysSend );
340private slots:
344 void slotUpdateFont();
345
349 void slotAddrBook();
353 void slotInsertFile();
354
355 void slotSetCharset();
359 void slotSpellcheck();
360 void slotSpellcheckConfig();
361 void slotSubjectTextSpellChecked();
362
367 void slotSelectCryptoModule( bool init = false );
368
372 void slotStatusMessage(const TQString &message);
373 void slotEditToolbars();
374 void slotUpdateToolbars();
375 void slotEditKeys();
379 void readConfig( bool reload = false );
383 void slotUpdWinTitle(const TQString& );
384
389 void slotEncryptToggled(bool);
390
394 void slotSignToggled(bool);
395
396public slots: // kmkernel, callback
400 void slotWordWrapToggled(bool);
401
402private slots:
406 void slotAppendSignature();
407
411 void slotPrependSignature();
412
416 void slotInsertSignatureAtCursor();
417
421 void slotInsertMyPublicKey();
422
426 void slotInsertPublicKey();
427
431 void slotUpdateAttachActions();
432
436 void slotAttachPopupMenu(TQListViewItem *, const TQPoint &, int);
437
442 int currentAttachmentNum();
443
447 void slotAttachOpen();
448 void slotAttachView();
449 void slotAttachRemove();
450 void slotAttachSave();
451 void slotAttachProperties();
452 void slotAttachOpenWith();
453 void slotAttachEdit();
454 void slotAttachEditWith();
455 void slotAttachmentDragStarted();
456
461 void slotAddrBookTo();
462 void slotAddrBookFrom();
463 void slotAddrBookReplyTo();
464
465 void slotCleanSpace();
466
467 void slotToggleMarkup();
468 void toggleMarkup(bool markup);
469 void htmlToolBarVisibilityChanged( bool visible );
470
471// void slotSpellConfigure();
472 void slotSpellcheckDone(int result);
473 void slotSpellcheckDoneClearStatus();
474
475public slots: // kmkernel
476 void autoSaveMessage();
477
478private slots:
479 void updateCursorPosition();
480
481 void slotView();
482
486 void slotIdentityChanged(uint);
487
491 void slotAttachFileData(TDEIO::Job *, const TQByteArray &);
492 void slotAttachFileResult(TDEIO::Job *);
493
494 void slotListAction(const TQString &);
495 void slotFontAction(const TQString &);
496 void slotSizeAction(int);
497 void slotAlignLeft();
498 void slotAlignCenter();
499 void slotAlignRight();
500 void slotTextBold();
501 void slotTextItalic();
502 void slotTextUnder();
503 void slotFormatReset();
504 void slotTextColor();
505 void fontChanged( const TQFont & );
506 void alignmentChanged( int );
507
508public: // kmkernel, attachmentlistview
509 bool addAttach(const KURL url);
510
511public: // kmcommand
515 void addAttach(const KMMessagePart* msgPart);
516
517private:
518 const KPIM::Identity & identity() const;
519 uint identityUid() const;
520 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
521 bool encryptToSelf() const;
522
523signals:
524 void applyChangesDone( bool );
525 void attachmentAdded( const KURL&, bool success );
526
527private:
535 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
536
542 void rethinkFields(bool fromslot=false);
543
547 TQWidget *connectFocusMoving( TQWidget *prev, TQWidget *next );
548
553 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
554 TQLabel* aLbl,
555 TQLineEdit* aEdt, TQPushButton* aBtn = 0,
556 const TQString &toolTip = TQString(),
557 const TQString &whatsThis = TQString() );
558
559 void rethinkHeaderLine( int value, int mask, int& row,
560 TQLabel* lbl, TQComboBox* cbx, TQCheckBox *chk );
561
566 bool checkRecipientNumber() const;
567
568
569 bool checkTransport() const;
570
574 void setupActions();
575 void setupStatusBar();
576 void setupEditor();
577
578
582 TQString subject() const;
583 TQString to() const;
584 TQString cc() const;
585 TQString bcc() const;
586 TQString from() const;
587 TQString replyTo() const;
588
594 void setFcc( const TQString &idString );
595
599 virtual bool queryClose ();
603 virtual bool queryExit ();
604
608 void openAttach( int index, bool with );
609
613 void viewAttach( int index );
614
618 void editAttach( int index, bool openWith );
619
623 void removeAttach(const TQString &url);
624 void removeAttach(int idx);
625
629 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
630 bool loadDefaults = true );
631
636 void addrBookSelInto();
637
638 void addrBookSelIntoOld();
639 void addrBookSelIntoNew();
640
641private:
646 void setEncryption( bool encrypt, bool setByUser = false );
647
652 void setSigning( bool sign, bool setByUser = false );
653
657 bool userForgotAttachment();
658
663 bool encryptFlagOfAttachment(int idx);
664
669 bool signFlagOfAttachment(int idx);
670
671
679 static void decryptOrStripOffCleartextSignature( TQCString& );
680
684 bool saveDraftOrTemplate( const TQString &folderName, KMMessage *msg );
685
689 enum SaveIn { None, Drafts, Templates };
690 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
691 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
692
696 int autoSaveInterval() const;
697
701 void initAutoSave();
702
707 void updateAutoSave();
708
712 void cleanupAutoSave();
713
719 static bool validateAddresses( TQWidget * parent, const TQString & addresses );
720
727 void setTransport( const TQString & transport );
728
729 enum SignaturePlacement { Append, Prepend, AtCursor };
730
735 void insertSignature( SignaturePlacement placement = Append );
736private slots:
740 void compressAttach(int idx);
741 void uncompressAttach(int idx);
742 void editorFocusChanged(bool gained);
743 void recipientEditorSizeHintChanged();
744 void setMaximumHeaderSize();
745
746private:
747 TQWidget *mMainWidget;
748 TQComboBox *mTransport;
749 KMail::DictionaryComboBox *mDictionaryCombo;
750 KPIM::IdentityCombo *mIdentity;
751 KMFolderComboBox *mFcc;
752 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
753 KMLineEditSpell *mEdtSubject;
754 TQLabel *mLblIdentity, *mLblTransport, *mLblFcc;
755 TQLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
756 TQLabel *mDictionaryLabel;
757 TQCheckBox *mBtnIdentity, *mBtnDictionary, *mBtnTransport, *mBtnFcc;
758 TQPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo;
759 bool mSpellCheckInProgress;
760 bool mDone;
761 bool mAtmModified;
762 TQListViewItem *mAtmSelectNew;
763
764 KMEdit* mEditor;
765 TQGridLayout* mGrid;
766 KMMessage *mMsg;
767 TQValueVector<KMMessage*> mComposedMessages;
768 KMail::AttachmentListView* mAtmListView;
769 int mAtmColEncrypt;
770 int mAtmColSign;
771 int mAtmColCompress;
772 int mAtmEncryptColWidth;
773 int mAtmSignColWidth;
774 int mAtmCompressColWidth;
775 TQPtrList<TQListViewItem> mAtmItemList;
776 TQPtrList<KMMessagePart> mAtmList;
777 TQPopupMenu *mAttachMenu;
778 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
779 bool mAutoDeleteMsg;
780 bool mSigningAndEncryptionExplicitlyDisabled;
781 bool mLastSignActionState, mLastEncryptActionState;
782 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
783 KMFolder *mFolder;
784 long mShowHeaders;
785 bool mConfirmSend;
786 bool mDisableBreaking; // Move
787 int mNumHeaders;
788 bool mUseHTMLEditor;
789 bool mHtmlMarkup;
790 TQFont mBodyFont, mFixedFont;
791 TQPtrList<KTempFile> mAtmTempList;
792 TQPalette mPalette;
793 uint mId;
794 TQString mOldSigText;
795
796 TDEAction *mAttachPK, *mAttachMPK,
797 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
798 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
799 TDERecentFilesAction *mRecentAction;
800
801 TDEAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
802
803 TDEToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
804 TDEToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
805 TDEToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
806 TDEToggleAction *mSubjectAction;
807 TDEToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
808 TDEToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
809 TDEToggleAction *mDictionaryAction, *mSnippetAction;
810
811 TDESelectAction *listAction;
812 TDEFontAction *fontAction;
813 TDEFontSizeAction *fontSizeAction;
814 TDEToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
815 TDEToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
816 TDEToggleAction *plainTextAction, *markupAction;
817 TDEAction *actionFormatColor, *actionFormatReset;
818 TDEAction *mHtmlToolbar;
819
820 TDESelectAction *mEncodingAction;
821 TDESelectAction *mCryptoModuleAction;
822
823 TQCString mCharset;
824 TQCString mDefCharset;
825 TQStringList mCharsets;
826 bool mAutoCharset;
827
828 bool mAlwaysSend;
829
830 TQStringList mFolderNames;
831 TQValueList<TQGuardedPtr<KMFolder> > mFolderList;
832 TQMap<TDEIO::Job*, KURL> mAttachJobs;
833 KURL::List mAttachFilesPending;
834 int mAttachFilesSend;
835
836private:
837 // helper method for slotInsert(My)PublicKey()
838 void startPublicKeyExport();
839 bool canSignEncryptAttachments() const {
840 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
841 }
842
843 bool mSubjectTextWasSpellChecked;
844
845 TQString addQuotesToText( const TQString &inputText );
846 TQString removeQuotesFromText( const TQString &inputText );
847 // helper method for rethinkFields
848 int calcColumnWidth(int which, long allShowing, int width);
849
850private slots:
851 void slotCompletionModeChanged( TDEGlobalSettings::Completion );
852 void slotConfigChanged();
853
854 void slotComposerDone( bool );
855
856 void slotContinueDoSend( bool );
857 void slotContinuePrint( bool );
858 void slotContinueAutoSave();
859
860 void slotEncryptChiasmusToggled( bool );
861
866 void slotPublicKeyExportResult( const GpgME::Error & err, const TQByteArray & keydata );
867
871 void slotAutoSpellCheckingToggled(bool);
872
876 void slotUpdateSignatureActions();
877
881 void slotUpdateSignatureAndEncrypionStateIndicators();
882private:
883 TQColor mForeColor,mBackColor;
884 TQFont mSaveFont;
885 TQSplitter *mHeadersToEditorSplitter;
886 TQWidget* mHeadersArea;
887 TQSplitter *mSplitter;
888 TQSplitter *mSnippetSplitter;
889 struct atmLoadData
890 {
891 KURL url;
892 TQByteArray data;
893 bool insert;
894 TQCString encoding;
895 };
896 TQMap<TDEIO::Job *, atmLoadData> mMapAtmLoadData;
897
898 // These are for passing on methods over the applyChanges calls
899 KMail::MessageSender::SendMethod mSendMethod;
900 KMComposeWin::SaveIn mSaveIn;
901
902 TDEToggleAction *mEncryptChiasmusAction;
903 bool mEncryptWithChiasmus;
904
905 // This is the temporary object that constructs the message out of the
906 // window
907 MessageComposer* mComposer;
908
909 // Temp var for slotPrint:
910 bool mMessageWasModified;
911
912 // Temp var for slotInsert(My)PublicKey():
913 TQString mFingerprint;
914
915 // Temp ptr for saving image from clipboard
916 KTempDir *mTempDir;
917
918 bool mClassicalRecipients;
919
920 RecipientsEditor *mRecipientsEditor;
921 int mLabelWidth;
922
923 TQTimer *mAutoSaveTimer;
924 TQString mAutoSaveFilename;
925 int mLastAutoSaveErrno; // holds the errno of the last try to autosave
926
927 TQPopupMenu *mActNowMenu;
928 TQPopupMenu *mActLaterMenu;
929
930 TQMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
931 TQMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
932
933 TQLabel *mSignatureStateIndicator;
934 TQLabel *mEncryptionStateIndicator;
935
936 SnippetWidget *mSnippetWidget;
937 std::set<KTempDir*> mTempDirs;
938
946 bool mPreserveUserCursorPosition;
947
948 bool mPreventFccOverwrite;
949 bool mCheckForRecipients;
950 bool mCheckForForgottenAttachments;
951 bool mIgnoreStickyFields;
952};
953
954#endif
955
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