00001
00002
00003
00004
00005 #ifndef __KMComposeWin
00006 #define __KMComposeWin
00007
00008 #ifndef KDE_USE_FINAL
00009 # ifndef REALLY_WANT_KMCOMPOSEWIN_H
00010 # error Do not include kmcomposewin.h anymore. Include composer.h instead.
00011 # endif
00012 #endif
00013
00014 #include "composer.h"
00015 #include "messagesender.h"
00016
00017 #include <set>
00018
00019 #include <tqlabel.h>
00020 #include <tqlistview.h>
00021
00022 #include <tqcheckbox.h>
00023 #include <tqpushbutton.h>
00024 #include <tqclipboard.h>
00025 #include <tqpalette.h>
00026 #include <tqfont.h>
00027 #include <tqptrlist.h>
00028 #include <tqvaluevector.h>
00029 #include <tqsplitter.h>
00030
00031 #include <kio/job.h>
00032 #include <kglobalsettings.h>
00033 #include <kdeversion.h>
00034 #include <keditcl.h>
00035 #include <ktempdir.h>
00036
00037 #include "mailcomposerIface.h"
00038 #include "accountmanager.h"
00039
00040 #include <libkdepim/addresseelineedit.h>
00041 #include <mimelib/mediatyp.h>
00042
00043 #include <kleo/enum.h>
00044
00045 class TQCloseEvent;
00046 class TQComboBox;
00047 class TQFrame;
00048 class TQGridLayout;
00049 class TQListView;
00050 class TQPopupMenu;
00051 class TQPushButton;
00052 class TQCString;
00053 class KCompletion;
00054 class KMEdit;
00055 class KMComposeWin;
00056 class KMFolderComboBox;
00057 class KMFolder;
00058 class KMMessage;
00059 class KMMessagePart;
00060 class KProcess;
00061 class KDirWatch;
00062 class KSelectAction;
00063 class KFontAction;
00064 class KFontSizeAction;
00065 class KSelectAction;
00066 class KStatusBar;
00067 class KAction;
00068 class KToggleAction;
00069 class KTempFile;
00070 class KToolBar;
00071 class KToggleAction;
00072 class KSelectColorAction;
00073 class KURL;
00074 class KRecentFilesAction;
00075 class SpellingFilter;
00076 class MessageComposer;
00077 class RecipientsEditor;
00078 class KMLineEdit;
00079 class KMLineEditSpell;
00080 class KMAtmListViewItem;
00081 class SnippetWidget;
00082
00083 namespace KPIM {
00084 class IdentityCombo;
00085 class Identity;
00086 }
00087
00088 namespace KMail {
00089 class AttachmentListView;
00090 class DictionaryComboBox;
00091 class EditorWatcher;
00092 }
00093
00094 namespace GpgME {
00095 class Error;
00096 }
00097
00098
00099 class KMComposeWin : public KMail::Composer, public MailComposerIface
00100 {
00101 Q_OBJECT
00102 friend class ::KMEdit;
00103 friend class ::MessageComposer;
00104
00105 private:
00106 KMComposeWin( KMMessage* msg=0, uint identity=0 );
00107 ~KMComposeWin();
00108 public:
00109 static Composer * create( KMMessage * msg = 0, uint identity = 0 );
00110
00111 MailComposerIface * asMailComposerIFace() { return this; }
00112 const MailComposerIface * asMailComposerIFace() const { return this; }
00113
00114 public:
00118 void send(int how);
00119 void addAttachmentsAndSend(const KURL::List &urls, const TQString &comment, int how);
00120 void addAttachment(KURL url,TQString comment);
00121 void addAttachment(const TQString &name,
00122 const TQCString &cte,
00123 const TQByteArray &data,
00124 const TQCString &type,
00125 const TQCString &subType,
00126 const TQCString ¶mAttr,
00127 const TQString ¶mValue,
00128 const TQCString &contDisp);
00129 public:
00130 void setBody (TQString body);
00131
00132 private:
00136 virtual bool event(TQEvent *e);
00137
00141 void readColorConfig();
00142
00146 void writeConfig(void);
00147
00152 void verifyWordWrapLengthIsAdequate(const TQString&);
00153
00154 public:
00159 void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
00160 bool allowDecryption=FALSE, bool isModified=FALSE);
00161
00162 void disableWordWrap();
00163
00167 void disableRecipientNumberCheck();
00168
00172 void disableForgottenAttachmentsCheck();
00173
00183 void ignoreStickyFields();
00184
00188 bool isComposing() const { return mComposer != 0; }
00189
00190 private:
00195 KMMessage* msg() const { return mMsg; }
00196
00197 public:
00201 void setAutoSaveFilename( const TQString & filename );
00202
00203 private:
00207 bool isModified() const;
00208
00212 void setModified( bool modified );
00213
00214 public:
00219 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00220
00225 void setAutoDeleteWindow( bool f );
00226
00227 public:
00232 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00233 public:
00237 void setCharset(const TQCString& aCharset, bool forceDefault = FALSE);
00238
00239 public:
00245 void setReplyFocus( bool hasMessage = true );
00246
00251 void setFocusToSubject();
00252
00253 private:
00257 bool inlineSigningEncryptionSelected();
00258
00264 static TQString prettyMimeType( const TQString& type );
00265 TQString quotePrefixName() const;
00266
00267 private:
00268 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00269 void setSubjectTextWasSpellChecked( bool _spell ) {
00270 mSubjectTextWasSpellChecked = _spell;
00271 }
00272 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00273
00274 void paste( QClipboard::Mode mode );
00275
00276 public:
00278 void setSigningAndEncryptionDisabled( bool v )
00279 {
00280 mSigningAndEncryptionExplicitlyDisabled = v;
00281 }
00282
00283 private slots:
00284 void polish();
00288 void slotPrint();
00289 void slotAttachFile();
00290 void slotInsertRecentFile(const KURL&);
00291 void slotAttachedFile(const KURL&);
00292 public slots:
00293 void slotSendNow();
00294 private slots:
00295 void slotSendNowVia( int item );
00296 void slotSendLater();
00297 void slotSendLaterVia( int item );
00298
00299 void getTransportMenu();
00300
00304 void slotSaveDraft();
00305 void slotSaveTemplate();
00306 void slotNewComposer();
00307 void slotNewMailReader();
00308 void slotClose();
00309 void slotHelp();
00310
00311 void slotFind();
00312 void slotSearchAgain();
00313 void slotReplace();
00314 void slotUndo();
00315 void slotRedo();
00316 void slotCut();
00317 void slotCopy();
00318 void slotPasteClipboard();
00319 void slotPasteClipboardAsQuotation();
00320 void slotPasteClipboardAsAttachment();
00321 void slotAddQuotes();
00322 void slotRemoveQuotes();
00323 void slotAttachPNGImageData(const TQByteArray &image);
00324
00325 void slotMarkAll();
00326
00327 void slotFolderRemoved(KMFolder*);
00328
00329 void slotEditDone( KMail::EditorWatcher* watcher );
00330
00331 public slots:
00338 void slotSetAlwaysSend( bool bAlwaysSend );
00339 private slots:
00343 void slotUpdateFont();
00344
00348 void slotAddrBook();
00352 void slotInsertFile();
00353
00354 void slotSetCharset();
00358 void slotSpellcheck();
00359 void slotSpellcheckConfig();
00360 void slotSubjectTextSpellChecked();
00361
00366 void slotSelectCryptoModule( bool init = false );
00367
00371 void slotStatusMessage(const TQString &message);
00372 void slotEditToolbars();
00373 void slotUpdateToolbars();
00374 void slotEditKeys();
00378 void readConfig( bool reload = false );
00382 void slotUpdWinTitle(const TQString& );
00383
00388 void slotEncryptToggled(bool);
00389
00393 void slotSignToggled(bool);
00394
00395 public slots:
00399 void slotWordWrapToggled(bool);
00400
00401 private slots:
00405 void slotAppendSignature();
00406
00410 void slotPrependSignature();
00411
00415 void slotInsertSignatureAtCursor();
00416
00420 void slotInsertMyPublicKey();
00421
00425 void slotInsertPublicKey();
00426
00430 void slotUpdateAttachActions();
00431
00435 void slotAttachPopupMenu(TQListViewItem *, const TQPoint &, int);
00436
00441 int currentAttachmentNum();
00442
00446 void slotAttachOpen();
00447 void slotAttachView();
00448 void slotAttachRemove();
00449 void slotAttachSave();
00450 void slotAttachProperties();
00451 void slotAttachOpenWith();
00452 void slotAttachEdit();
00453 void slotAttachEditWith();
00454 void slotAttachmentDragStarted();
00455
00460 void slotAddrBookTo();
00461 void slotAddrBookFrom();
00462 void slotAddrBookReplyTo();
00463
00464 void slotCleanSpace();
00465
00466 void slotToggleMarkup();
00467 void toggleMarkup(bool markup);
00468 void htmlToolBarVisibilityChanged( bool visible );
00469
00470
00471 void slotSpellcheckDone(int result);
00472 void slotSpellcheckDoneClearStatus();
00473
00474 public slots:
00475 void autoSaveMessage();
00476
00477 private slots:
00478 void updateCursorPosition();
00479
00480 void slotView();
00481
00485 void slotIdentityChanged(uint);
00486
00490 void slotAttachFileData(KIO::Job *, const TQByteArray &);
00491 void slotAttachFileResult(KIO::Job *);
00492
00493 void slotListAction(const TQString &);
00494 void slotFontAction(const TQString &);
00495 void slotSizeAction(int);
00496 void slotAlignLeft();
00497 void slotAlignCenter();
00498 void slotAlignRight();
00499 void slotTextBold();
00500 void slotTextItalic();
00501 void slotTextUnder();
00502 void slotFormatReset();
00503 void slotTextColor();
00504 void fontChanged( const TQFont & );
00505 void alignmentChanged( int );
00506
00507 public:
00508 bool addAttach(const KURL url);
00509
00510 public:
00514 void addAttach(const KMMessagePart* msgPart);
00515
00516 private:
00517 const KPIM::Identity & identity() const;
00518 uint identityUid() const;
00519 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00520 bool encryptToSelf() const;
00521
00522 signals:
00523 void applyChangesDone( bool );
00524 void attachmentAdded( const KURL&, bool success );
00525
00526 private:
00534 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00535
00541 void rethinkFields(bool fromslot=false);
00542
00546 TQWidget *connectFocusMoving( TQWidget *prev, TQWidget *next );
00547
00552 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00553 TQLabel* aLbl,
00554 TQLineEdit* aEdt, TQPushButton* aBtn = 0,
00555 const TQString &toolTip = TQString::null,
00556 const TQString &whatsThis = TQString::null );
00557
00558 void rethinkHeaderLine( int value, int mask, int& row,
00559 TQLabel* lbl, TQComboBox* cbx, TQCheckBox *chk );
00560
00565 bool checkRecipientNumber() const;
00566
00567
00568 bool checkTransport() const;
00569
00573 void setupActions();
00574 void setupStatusBar();
00575 void setupEditor();
00576
00577
00581 TQString subject() const;
00582 TQString to() const;
00583 TQString cc() const;
00584 TQString bcc() const;
00585 TQString from() const;
00586 TQString replyTo() const;
00587
00593 void setFcc( const TQString &idString );
00594
00598 virtual bool queryClose ();
00602 virtual bool queryExit ();
00603
00607 void openAttach( int index, bool with );
00608
00612 void viewAttach( int index );
00613
00617 void editAttach( int index, bool openWith );
00618
00622 void removeAttach(const TQString &url);
00623 void removeAttach(int idx);
00624
00628 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00629 bool loadDefaults = true );
00630
00635 void addrBookSelInto();
00636
00637 void addrBookSelIntoOld();
00638 void addrBookSelIntoNew();
00639
00640 private:
00645 void setEncryption( bool encrypt, bool setByUser = false );
00646
00651 void setSigning( bool sign, bool setByUser = false );
00652
00656 bool userForgotAttachment();
00657
00662 bool encryptFlagOfAttachment(int idx);
00663
00668 bool signFlagOfAttachment(int idx);
00669
00670
00678 static void decryptOrStripOffCleartextSignature( TQCString& );
00679
00683 bool saveDraftOrTemplate( const TQString &folderName, KMMessage *msg );
00684
00688 enum SaveIn { None, Drafts, Templates };
00689 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
00690 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
00691
00695 int autoSaveInterval() const;
00696
00700 void initAutoSave();
00701
00706 void updateAutoSave();
00707
00711 void cleanupAutoSave();
00712
00718 static bool validateAddresses( TQWidget * parent, const TQString & addresses );
00719
00726 void setTransport( const TQString & transport );
00727
00728 enum SignaturePlacement { Append, Prepend, AtCursor };
00729
00734 void insertSignature( SignaturePlacement placement = Append );
00735 private slots:
00739 void compressAttach(int idx);
00740 void uncompressAttach(int idx);
00741 void editorFocusChanged(bool gained);
00742 void recipientEditorSizeHintChanged();
00743 void setMaximumHeaderSize();
00744
00745 private:
00746 TQWidget *mMainWidget;
00747 TQComboBox *mTransport;
00748 KMail::DictionaryComboBox *mDictionaryCombo;
00749 KPIM::IdentityCombo *mIdentity;
00750 KMFolderComboBox *mFcc;
00751 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00752 KMLineEditSpell *mEdtSubject;
00753 TQLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00754 TQLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00755 TQLabel *mDictionaryLabel;
00756 TQCheckBox *mBtnIdentity, *mBtnDictionary, *mBtnTransport, *mBtnFcc;
00757 TQPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00758 bool mSpellCheckInProgress;
00759 bool mDone;
00760 bool mAtmModified;
00761 TQListViewItem *mAtmSelectNew;
00762
00763 KMEdit* mEditor;
00764 TQGridLayout* mGrid;
00765 KMMessage *mMsg;
00766 TQValueVector<KMMessage*> mComposedMessages;
00767 KMail::AttachmentListView* mAtmListView;
00768 int mAtmColEncrypt;
00769 int mAtmColSign;
00770 int mAtmColCompress;
00771 int mAtmEncryptColWidth;
00772 int mAtmSignColWidth;
00773 int mAtmCompressColWidth;
00774 TQPtrList<TQListViewItem> mAtmItemList;
00775 TQPtrList<KMMessagePart> mAtmList;
00776 TQPopupMenu *mAttachMenu;
00777 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
00778 bool mAutoDeleteMsg;
00779 bool mSigningAndEncryptionExplicitlyDisabled;
00780 bool mLastSignActionState, mLastEncryptActionState;
00781 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00782 KMFolder *mFolder;
00783 long mShowHeaders;
00784 bool mConfirmSend;
00785 bool mDisableBreaking;
00786 int mNumHeaders;
00787 bool mUseHTMLEditor;
00788 bool mHtmlMarkup;
00789 TQFont mBodyFont, mFixedFont;
00790 TQPtrList<KTempFile> mAtmTempList;
00791 TQPalette mPalette;
00792 uint mId;
00793 TQString mOldSigText;
00794
00795 KAction *mAttachPK, *mAttachMPK,
00796 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00797 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00798 KRecentFilesAction *mRecentAction;
00799
00800 KAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
00801
00802 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00803 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00804 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00805 KToggleAction *mSubjectAction;
00806 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00807 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00808 KToggleAction *mDictionaryAction, *mSnippetAction;
00809
00810 KSelectAction *listAction;
00811 KFontAction *fontAction;
00812 KFontSizeAction *fontSizeAction;
00813 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00814 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00815 KToggleAction *plainTextAction, *markupAction;
00816 KAction *actionFormatColor, *actionFormatReset;
00817 KAction *mHtmlToolbar;
00818
00819 KSelectAction *mEncodingAction;
00820 KSelectAction *mCryptoModuleAction;
00821
00822 TQCString mCharset;
00823 TQCString mDefCharset;
00824 TQStringList mCharsets;
00825 bool mAutoCharset;
00826
00827 bool mAlwaysSend;
00828
00829 TQStringList mFolderNames;
00830 TQValueList<TQGuardedPtr<KMFolder> > mFolderList;
00831 TQMap<KIO::Job*, KURL> mAttachJobs;
00832 KURL::List mAttachFilesPending;
00833 int mAttachFilesSend;
00834
00835 private:
00836
00837 void startPublicKeyExport();
00838 bool canSignEncryptAttachments() const {
00839 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00840 }
00841
00842 bool mSubjectTextWasSpellChecked;
00843
00844 TQString addQuotesToText( const TQString &inputText );
00845 TQString removeQuotesFromText( const TQString &inputText );
00846
00847 int calcColumnWidth(int which, long allShowing, int width);
00848
00849 private slots:
00850 void slotCompletionModeChanged( KGlobalSettings::Completion );
00851 void slotConfigChanged();
00852
00853 void slotComposerDone( bool );
00854
00855 void slotContinueDoSend( bool );
00856 void slotContinuePrint( bool );
00857 void slotContinueAutoSave();
00858
00859 void slotEncryptChiasmusToggled( bool );
00860
00865 void slotPublicKeyExportResult( const GpgME::Error & err, const TQByteArray & keydata );
00866
00870 void slotAutoSpellCheckingToggled(bool);
00871
00875 void slotUpdateSignatureActions();
00876
00880 void slotUpdateSignatureAndEncrypionStateIndicators();
00881 private:
00882 TQColor mForeColor,mBackColor;
00883 TQFont mSaveFont;
00884 TQSplitter *mHeadersToEditorSplitter;
00885 TQWidget* mHeadersArea;
00886 TQSplitter *mSplitter;
00887 TQSplitter *mSnippetSplitter;
00888 struct atmLoadData
00889 {
00890 KURL url;
00891 TQByteArray data;
00892 bool insert;
00893 TQCString encoding;
00894 };
00895 TQMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00896
00897
00898 KMail::MessageSender::SendMethod mSendMethod;
00899 KMComposeWin::SaveIn mSaveIn;
00900
00901 KToggleAction *mEncryptChiasmusAction;
00902 bool mEncryptWithChiasmus;
00903
00904
00905
00906 MessageComposer* mComposer;
00907
00908
00909 bool mMessageWasModified;
00910
00911
00912 TQString mFingerprint;
00913
00914
00915 KTempDir *mTempDir;
00916
00917 bool mClassicalRecipients;
00918
00919 RecipientsEditor *mRecipientsEditor;
00920 int mLabelWidth;
00921
00922 TQTimer *mAutoSaveTimer;
00923 TQString mAutoSaveFilename;
00924 int mLastAutoSaveErrno;
00925
00926 TQPopupMenu *mActNowMenu;
00927 TQPopupMenu *mActLaterMenu;
00928
00929 TQMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
00930 TQMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
00931
00932 TQLabel *mSignatureStateIndicator;
00933 TQLabel *mEncryptionStateIndicator;
00934
00935 SnippetWidget *mSnippetWidget;
00936 std::set<KTempDir*> mTempDirs;
00937
00945 bool mPreserveUserCursorPosition;
00946
00947 bool mPreventFccOverwrite;
00948 bool mCheckForRecipients;
00949 bool mCheckForForgottenAttachments;
00950 bool mIgnoreStickyFields;
00951 };
00952
00953 #endif
00954