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 <qlabel.h>
00020 #include <qlistview.h>
00021
00022 #include <qcheckbox.h>
00023 #include <qpushbutton.h>
00024 #include <qclipboard.h>
00025 #include <qpalette.h>
00026 #include <qfont.h>
00027 #include <qptrlist.h>
00028 #include <qvaluevector.h>
00029 #include <qsplitter.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
00039 #include <libkdepim/addresseelineedit.h>
00040 #include <mimelib/mediatyp.h>
00041
00042 #include <kleo/enum.h>
00043
00044 class QCloseEvent;
00045 class QComboBox;
00046 class QFrame;
00047 class QGridLayout;
00048 class QListView;
00049 class QPopupMenu;
00050 class QPushButton;
00051 class QCString;
00052 class KCompletion;
00053 class KMEdit;
00054 class KMComposeWin;
00055 class KMFolderComboBox;
00056 class KMFolder;
00057 class KMMessage;
00058 class KMMessagePart;
00059 class KProcess;
00060 class KDirWatch;
00061 class KSelectAction;
00062 class KFontAction;
00063 class KFontSizeAction;
00064 class KSelectAction;
00065 class KStatusBar;
00066 class KAction;
00067 class KToggleAction;
00068 class KTempFile;
00069 class KToolBar;
00070 class KToggleAction;
00071 class KSelectColorAction;
00072 class KURL;
00073 class KRecentFilesAction;
00074 class SpellingFilter;
00075 class MessageComposer;
00076 class RecipientsEditor;
00077 class KMLineEdit;
00078 class KMLineEditSpell;
00079 class KMAtmListViewItem;
00080 class SnippetWidget;
00081
00082 namespace KPIM {
00083 class IdentityCombo;
00084 class Identity;
00085 }
00086
00087 namespace KMail {
00088 class AttachmentListView;
00089 class DictionaryComboBox;
00090 class EditorWatcher;
00091 }
00092
00093 namespace GpgME {
00094 class Error;
00095 }
00096
00097
00098 class KMComposeWin : public KMail::Composer, virtual public MailComposerIface
00099 {
00100 Q_OBJECT
00101 friend class ::KMEdit;
00102 friend class ::MessageComposer;
00103
00104 private:
00105 KMComposeWin( KMMessage* msg=0, uint identity=0 );
00106 ~KMComposeWin();
00107 public:
00108 static Composer * create( KMMessage * msg = 0, uint identity = 0 );
00109
00110 MailComposerIface * asMailComposerIFace() { return this; }
00111 const MailComposerIface * asMailComposerIFace() const { return this; }
00112
00113 public:
00117 void send(int how);
00118 void addAttachmentsAndSend(const KURL::List &urls, const QString &comment, int how);
00119 void addAttachment(KURL url,QString comment);
00120 void addAttachment(const QString &name,
00121 const QCString &cte,
00122 const QByteArray &data,
00123 const QCString &type,
00124 const QCString &subType,
00125 const QCString ¶mAttr,
00126 const QString ¶mValue,
00127 const QCString &contDisp);
00128 public:
00129 void setBody (QString body);
00130
00131 private:
00135 virtual bool event(QEvent *e);
00136
00140 void readColorConfig();
00141
00145 void writeConfig(void);
00146
00151 void verifyWordWrapLengthIsAdequate(const QString&);
00152
00153 public:
00158 void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
00159 bool allowDecryption=FALSE, bool isModified=FALSE);
00160
00161 void disableWordWrap();
00162
00166 void disableRecipientNumberCheck();
00167
00171 void disableForgottenAttachmentsCheck();
00172
00182 void ignoreStickyFields();
00183
00187 bool isComposing() const { return mComposer != 0; }
00188
00189 private:
00194 KMMessage* msg() const { return mMsg; }
00195
00196 public:
00200 void setAutoSaveFilename( const QString & filename );
00201
00202 private:
00206 bool isModified() const;
00207
00211 void setModified( bool modified );
00212
00213 public:
00218 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00219
00224 void setAutoDeleteWindow( bool f );
00225
00226 public:
00231 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00232 public:
00236 void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00237
00238 public:
00244 void setReplyFocus( bool hasMessage = true );
00245
00250 void setFocusToSubject();
00251
00252 private:
00256 bool inlineSigningEncryptionSelected();
00257
00263 static QString prettyMimeType( const QString& type );
00264 QString quotePrefixName() const;
00265
00266 private:
00267 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00268 void setSubjectTextWasSpellChecked( bool _spell ) {
00269 mSubjectTextWasSpellChecked = _spell;
00270 }
00271 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00272
00273 void paste( QClipboard::Mode mode );
00274
00275 public:
00277 void setSigningAndEncryptionDisabled( bool v )
00278 {
00279 mSigningAndEncryptionExplicitlyDisabled = v;
00280 }
00281
00282 private slots:
00283 void polish();
00287 void slotPrint();
00288 void slotAttachFile();
00289 void slotInsertRecentFile(const KURL&);
00290 void slotAttachedFile(const KURL&);
00291 public slots:
00292 void slotSendNow();
00293 private slots:
00294 void slotSendNowVia( int item );
00295 void slotSendLater();
00296 void slotSendLaterVia( int item );
00297
00298 void getTransportMenu();
00299
00303 void slotSaveDraft();
00304 void slotSaveTemplate();
00305 void slotNewComposer();
00306 void slotNewMailReader();
00307 void slotClose();
00308 void slotHelp();
00309
00310 void slotFind();
00311 void slotSearchAgain();
00312 void slotReplace();
00313 void slotUndo();
00314 void slotRedo();
00315 void slotCut();
00316 void slotCopy();
00317 void slotPasteClipboard();
00318 void slotPasteClipboardAsQuotation();
00319 void slotPasteClipboardAsAttachment();
00320 void slotAddQuotes();
00321 void slotRemoveQuotes();
00322 void slotAttachPNGImageData(const QByteArray &image);
00323
00324 void slotMarkAll();
00325
00326 void slotFolderRemoved(KMFolder*);
00327
00328 void slotEditDone( KMail::EditorWatcher* watcher );
00329
00330 public slots:
00337 void slotSetAlwaysSend( bool bAlwaysSend );
00338 private slots:
00342 void slotUpdateFont();
00343
00347 void slotAddrBook();
00351 void slotInsertFile();
00352
00353 void slotSetCharset();
00357 void slotSpellcheck();
00358 void slotSpellcheckConfig();
00359 void slotSubjectTextSpellChecked();
00360
00365 void slotSelectCryptoModule( bool init = false );
00366
00370 void slotStatusMessage(const QString &message);
00371 void slotEditToolbars();
00372 void slotUpdateToolbars();
00373 void slotEditKeys();
00377 void readConfig( bool reload = false );
00381 void slotUpdWinTitle(const QString& );
00382
00387 void slotEncryptToggled(bool);
00388
00392 void slotSignToggled(bool);
00393
00394 public slots:
00398 void slotWordWrapToggled(bool);
00399
00400 private slots:
00404 void slotAppendSignature();
00405
00409 void slotPrependSignature();
00410
00414 void slotInsertSignatureAtCursor();
00415
00419 void slotInsertMyPublicKey();
00420
00424 void slotInsertPublicKey();
00425
00429 void slotUpdateAttachActions();
00430
00434 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00435
00440 int currentAttachmentNum();
00441
00445 void slotAttachOpen();
00446 void slotAttachView();
00447 void slotAttachRemove();
00448 void slotAttachSave();
00449 void slotAttachProperties();
00450 void slotAttachOpenWith();
00451 void slotAttachEdit();
00452 void slotAttachEditWith();
00453 void slotAttachmentDragStarted();
00454
00459 void slotAddrBookTo();
00460 void slotAddrBookFrom();
00461 void slotAddrBookReplyTo();
00462
00463 void slotCleanSpace();
00464
00465 void slotToggleMarkup();
00466 void toggleMarkup(bool markup);
00467 void htmlToolBarVisibilityChanged( bool visible );
00468
00469
00470 void slotSpellcheckDone(int result);
00471 void slotSpellcheckDoneClearStatus();
00472
00473 public slots:
00474 void autoSaveMessage();
00475
00476 private slots:
00477 void updateCursorPosition();
00478
00479 void slotView();
00480
00484 void slotIdentityChanged(uint);
00485
00489 void slotAttachFileData(KIO::Job *, const QByteArray &);
00490 void slotAttachFileResult(KIO::Job *);
00491
00492 void slotListAction(const QString &);
00493 void slotFontAction(const QString &);
00494 void slotSizeAction(int);
00495 void slotAlignLeft();
00496 void slotAlignCenter();
00497 void slotAlignRight();
00498 void slotTextBold();
00499 void slotTextItalic();
00500 void slotTextUnder();
00501 void slotFormatReset();
00502 void slotTextColor();
00503 void fontChanged( const QFont & );
00504 void alignmentChanged( int );
00505
00506 public:
00507 bool addAttach(const KURL url);
00508
00509 public:
00513 void addAttach(const KMMessagePart* msgPart);
00514
00515 private:
00516 const KPIM::Identity & identity() const;
00517 uint identityUid() const;
00518 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00519 bool encryptToSelf() const;
00520
00521 signals:
00522 void applyChangesDone( bool );
00523 void attachmentAdded( const KURL&, bool success );
00524
00525 private:
00533 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00534
00540 void rethinkFields(bool fromslot=false);
00541
00545 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00546
00551 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00552 const QString &aLabelStr, QLabel* aLbl,
00553 QLineEdit* aEdt, QPushButton* aBtn = 0,
00554 const QString &toolTip = QString::null,
00555 const QString &whatsThis = QString::null );
00556
00557 void rethinkHeaderLine( int value, int mask, int& row,
00558 const QString& labelStr, QLabel* lbl,
00559 QComboBox* cbx, QCheckBox *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 QString subject() const;
00582 QString to() const;
00583 QString cc() const;
00584 QString bcc() const;
00585 QString from() const;
00586 QString replyTo() const;
00587
00593 void setFcc( const QString &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 QString &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( QCString& );
00679
00683 bool saveDraftOrTemplate( const QString &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( QWidget * parent, const QString & addresses );
00719
00726 void setTransport( const QString & transport );
00727
00728 enum SignaturePlacement { Append, Prepend, AtCursor };
00729
00734 void insertSignature( SignaturePlacement placement = Append, int pos = 0 );
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 QWidget *mMainWidget;
00747 QComboBox *mTransport;
00748 KMail::DictionaryComboBox *mDictionaryCombo;
00749 KPIM::IdentityCombo *mIdentity;
00750 KMFolderComboBox *mFcc;
00751 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00752 KMLineEditSpell *mEdtSubject;
00753 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00754 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00755 QLabel *mDictionaryLabel;
00756 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00757 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00758 bool mSpellCheckInProgress;
00759 bool mDone;
00760 bool mAtmModified;
00761
00762 KMEdit* mEditor;
00763 QGridLayout* mGrid;
00764 KMMessage *mMsg;
00765 QValueVector<KMMessage*> mComposedMessages;
00766 KMail::AttachmentListView* mAtmListView;
00767 int mAtmColEncrypt;
00768 int mAtmColSign;
00769 int mAtmColCompress;
00770 int mAtmEncryptColWidth;
00771 int mAtmSignColWidth;
00772 int mAtmCompressColWidth;
00773 QPtrList<QListViewItem> mAtmItemList;
00774 QPtrList<KMMessagePart> mAtmList;
00775 QPopupMenu *mAttachMenu;
00776 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
00777 bool mAutoDeleteMsg;
00778 bool mSigningAndEncryptionExplicitlyDisabled;
00779 bool mLastSignActionState, mLastEncryptActionState;
00780 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00781 KMFolder *mFolder;
00782 long mShowHeaders;
00783 bool mConfirmSend;
00784 bool mDisableBreaking;
00785 int mNumHeaders;
00786 bool mUseHTMLEditor;
00787 bool mHtmlMarkup;
00788 QFont mBodyFont, mFixedFont;
00789 QPtrList<KTempFile> mAtmTempList;
00790 QPalette mPalette;
00791 uint mId;
00792 QString mOldSigText;
00793
00794 KAction *mAttachPK, *mAttachMPK,
00795 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00796 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00797 KRecentFilesAction *mRecentAction;
00798
00799 KAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
00800
00801 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00802 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00803 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00804 KToggleAction *mSubjectAction;
00805 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00806 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00807 KToggleAction *mDictionaryAction, *mSnippetAction;
00808
00809 KSelectAction *listAction;
00810 KFontAction *fontAction;
00811 KFontSizeAction *fontSizeAction;
00812 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00813 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00814 KToggleAction *plainTextAction, *markupAction;
00815 KAction *actionFormatColor, *actionFormatReset;
00816 KAction *mHtmlToolbar;
00817
00818 KSelectAction *mEncodingAction;
00819 KSelectAction *mCryptoModuleAction;
00820
00821 QCString mCharset;
00822 QCString mDefCharset;
00823 QStringList mCharsets;
00824 bool mAutoCharset;
00825
00826 bool mAlwaysSend;
00827
00828 QStringList mFolderNames;
00829 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00830 QMap<KIO::Job*, KURL> mAttachJobs;
00831 KURL::List mAttachFilesPending;
00832 int mAttachFilesSend;
00833
00834 private:
00835
00836 void startPublicKeyExport();
00837 bool canSignEncryptAttachments() const {
00838 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00839 }
00840
00841 bool mSubjectTextWasSpellChecked;
00842
00843 QString addQuotesToText( const QString &inputText );
00844 QString removeQuotesFromText( const QString &inputText );
00845
00846 int calcColumnWidth(int which, long allShowing, int width);
00847
00848 private slots:
00849 void slotCompletionModeChanged( KGlobalSettings::Completion );
00850 void slotConfigChanged();
00851
00852 void slotComposerDone( bool );
00853
00854 void slotContinueDoSend( bool );
00855 void slotContinuePrint( bool );
00856 void slotContinueAutoSave();
00857
00858 void slotEncryptChiasmusToggled( bool );
00859
00864 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00865
00869 void slotAutoSpellCheckingToggled(bool);
00870
00874 void slotUpdateSignatureActions();
00875
00879 void slotUpdateSignatureAndEncrypionStateIndicators();
00880 private:
00881 QColor mForeColor,mBackColor;
00882 QFont mSaveFont;
00883 QSplitter *mHeadersToEditorSplitter;
00884 QWidget* mHeadersArea;
00885 QSplitter *mSplitter;
00886 QSplitter *mSnippetSplitter;
00887 struct atmLoadData
00888 {
00889 KURL url;
00890 QByteArray data;
00891 bool insert;
00892 QCString encoding;
00893 };
00894 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00895
00896
00897 KMail::MessageSender::SendMethod mSendMethod;
00898 KMComposeWin::SaveIn mSaveIn;
00899
00900 KToggleAction *mEncryptChiasmusAction;
00901 bool mEncryptWithChiasmus;
00902
00903
00904
00905 MessageComposer* mComposer;
00906
00907
00908 bool mMessageWasModified;
00909
00910
00911 QString mFingerprint;
00912
00913
00914 KTempDir *mTempDir;
00915
00916 bool mClassicalRecipients;
00917
00918 RecipientsEditor *mRecipientsEditor;
00919 int mLabelWidth;
00920
00921 QTimer *mAutoSaveTimer;
00922 QString mAutoSaveFilename;
00923 int mLastAutoSaveErrno;
00924
00925 QPopupMenu *mActNowMenu;
00926 QPopupMenu *mActLaterMenu;
00927
00928 QMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
00929 QMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
00930
00931 QLabel *mSignatureStateIndicator;
00932 QLabel *mEncryptionStateIndicator;
00933
00934 SnippetWidget *mSnippetWidget;
00935 std::set<KTempDir*> mTempDirs;
00936
00944 bool mPreserveUserCursorPosition;
00945
00946 bool mPreventFccOverwrite;
00947 bool mCheckForRecipients;
00948 bool mCheckForForgottenAttachments;
00949 bool mIgnoreStickyFields;
00950 };
00951
00952 #endif
00953