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 bool isComposing() const { return mComposer != 0; }
00172
00173 private:
00178 KMMessage* msg() const { return mMsg; }
00179
00180 public:
00184 void setAutoSaveFilename( const QString & filename );
00185
00186 private:
00190 bool isModified() const;
00191
00195 void setModified( bool modified );
00196
00197 public:
00202 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00203
00208 void setAutoDeleteWindow( bool f );
00209
00210 public:
00215 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00216 public:
00220 void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00221
00222 public:
00228 void setReplyFocus( bool hasMessage = true );
00229
00234 void setFocusToSubject();
00235
00236 private:
00240 bool inlineSigningEncryptionSelected();
00241
00247 static QString prettyMimeType( const QString& type );
00248 QString quotePrefixName() const;
00249
00250 private:
00251 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00252 void setSubjectTextWasSpellChecked( bool _spell ) {
00253 mSubjectTextWasSpellChecked = _spell;
00254 }
00255 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00256
00257 void paste( QClipboard::Mode mode );
00258
00259 public:
00261 void setSigningAndEncryptionDisabled( bool v )
00262 {
00263 mSigningAndEncryptionExplicitlyDisabled = v;
00264 }
00265
00266 private slots:
00267 void polish();
00271 void slotPrint();
00272 void slotAttachFile();
00273 void slotInsertRecentFile(const KURL&);
00274 void slotAttachedFile(const KURL&);
00275 public slots:
00276 void slotSendNow();
00277 private slots:
00278 void slotSendNowVia( int item );
00279 void slotSendLater();
00280 void slotSendLaterVia( int item );
00281
00282 void getTransportMenu();
00283
00287 void slotSaveDraft();
00288 void slotSaveTemplate();
00289 void slotNewComposer();
00290 void slotNewMailReader();
00291 void slotClose();
00292 void slotHelp();
00293
00294 void slotFind();
00295 void slotSearchAgain();
00296 void slotReplace();
00297 void slotUndo();
00298 void slotRedo();
00299 void slotCut();
00300 void slotCopy();
00301 void slotPasteClipboard();
00302 void slotPasteClipboardAsQuotation();
00303 void slotPasteClipboardAsAttachment();
00304 void slotAddQuotes();
00305 void slotRemoveQuotes();
00306 void slotAttachPNGImageData(const QByteArray &image);
00307
00308 void slotMarkAll();
00309
00310 void slotFolderRemoved(KMFolder*);
00311
00312 void slotEditDone( KMail::EditorWatcher* watcher );
00313
00314 public slots:
00321 void slotSetAlwaysSend( bool bAlwaysSend );
00322 private slots:
00326 void slotUpdateFont();
00327
00331 void slotAddrBook();
00335 void slotInsertFile();
00336
00337 void slotSetCharset();
00341 void slotSpellcheck();
00342 void slotSpellcheckConfig();
00343 void slotSubjectTextSpellChecked();
00344
00349 void slotSelectCryptoModule( bool init = false );
00350
00354 void slotStatusMessage(const QString &message);
00355 void slotEditToolbars();
00356 void slotUpdateToolbars();
00357 void slotEditKeys();
00361 void readConfig( bool reload = false );
00365 void slotUpdWinTitle(const QString& );
00366
00371 void slotEncryptToggled(bool);
00372
00376 void slotSignToggled(bool);
00377
00378 public slots:
00382 void slotWordWrapToggled(bool);
00383
00384 private slots:
00388 void slotAppendSignature();
00389
00393 void slotPrependSignature();
00394
00398 void slotInsertSignatureAtCursor();
00399
00403 void slotInsertMyPublicKey();
00404
00408 void slotInsertPublicKey();
00409
00413 void slotUpdateAttachActions();
00414
00418 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00419
00424 int currentAttachmentNum();
00425
00429 void slotAttachOpen();
00430 void slotAttachView();
00431 void slotAttachRemove();
00432 void slotAttachSave();
00433 void slotAttachProperties();
00434 void slotAttachOpenWith();
00435 void slotAttachEdit();
00436 void slotAttachEditWith();
00437 void slotAttachmentDragStarted();
00438
00443 void slotAddrBookTo();
00444 void slotAddrBookFrom();
00445 void slotAddrBookReplyTo();
00446
00447 void slotCleanSpace();
00448
00449 void slotToggleMarkup();
00450 void toggleMarkup(bool markup);
00451 void htmlToolBarVisibilityChanged( bool visible );
00452
00453
00454 void slotSpellcheckDone(int result);
00455 void slotSpellcheckDoneClearStatus();
00456
00457 public slots:
00458 void autoSaveMessage();
00459
00460 private slots:
00461 void updateCursorPosition();
00462
00463 void slotView();
00464
00468 void slotIdentityChanged(uint);
00469
00473 void slotAttachFileData(KIO::Job *, const QByteArray &);
00474 void slotAttachFileResult(KIO::Job *);
00475
00476 void slotListAction(const QString &);
00477 void slotFontAction(const QString &);
00478 void slotSizeAction(int);
00479 void slotAlignLeft();
00480 void slotAlignCenter();
00481 void slotAlignRight();
00482 void slotTextBold();
00483 void slotTextItalic();
00484 void slotTextUnder();
00485 void slotFormatReset();
00486 void slotTextColor();
00487 void fontChanged( const QFont & );
00488 void alignmentChanged( int );
00489
00490 public:
00491 bool addAttach(const KURL url);
00492
00493 public:
00497 void addAttach(const KMMessagePart* msgPart);
00498
00499 private:
00500 const KPIM::Identity & identity() const;
00501 uint identityUid() const;
00502 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00503 bool encryptToSelf() const;
00504
00505 signals:
00506 void applyChangesDone( bool );
00507 void attachmentAdded( const KURL&, bool success );
00508
00509 private:
00517 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00518
00524 void rethinkFields(bool fromslot=false);
00525
00529 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00530
00535 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00536 const QString &aLabelStr, QLabel* aLbl,
00537 QLineEdit* aEdt, QPushButton* aBtn = 0,
00538 const QString &toolTip = QString::null,
00539 const QString &whatsThis = QString::null );
00540
00541 void rethinkHeaderLine( int value, int mask, int& row,
00542 const QString& labelStr, QLabel* lbl,
00543 QComboBox* cbx, QCheckBox *chk );
00544
00549 bool checkRecipientNumber() const;
00550
00551
00552 bool checkTransport() const;
00553
00557 void setupActions();
00558 void setupStatusBar();
00559 void setupEditor();
00560
00561
00565 QString subject() const;
00566 QString to() const;
00567 QString cc() const;
00568 QString bcc() const;
00569 QString from() const;
00570 QString replyTo() const;
00571
00577 void setFcc( const QString &idString );
00578
00582 virtual bool queryClose ();
00586 virtual bool queryExit ();
00587
00591 void openAttach( int index, bool with );
00592
00596 void viewAttach( int index );
00597
00601 void editAttach( int index, bool openWith );
00602
00606 void removeAttach(const QString &url);
00607 void removeAttach(int idx);
00608
00612 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00613 bool loadDefaults = true );
00614
00619 void addrBookSelInto();
00620
00621 void addrBookSelIntoOld();
00622 void addrBookSelIntoNew();
00623
00624 private:
00629 void setEncryption( bool encrypt, bool setByUser = false );
00630
00635 void setSigning( bool sign, bool setByUser = false );
00636
00640 bool userForgotAttachment();
00641
00646 bool encryptFlagOfAttachment(int idx);
00647
00652 bool signFlagOfAttachment(int idx);
00653
00654
00662 static void decryptOrStripOffCleartextSignature( QCString& );
00663
00667 bool saveDraftOrTemplate( const QString &folderName, KMMessage *msg );
00668
00672 enum SaveIn { None, Drafts, Templates };
00673 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
00674 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
00675
00679 int autoSaveInterval() const;
00680
00684 void initAutoSave();
00685
00690 void updateAutoSave();
00691
00695 void cleanupAutoSave();
00696
00702 static bool validateAddresses( QWidget * parent, const QString & addresses );
00703
00710 void setTransport( const QString & transport );
00711
00716 void insertSignature( bool append = true, int pos = 0 );
00717 private slots:
00721 void compressAttach(int idx);
00722 void uncompressAttach(int idx);
00723 void editorFocusChanged(bool gained);
00724 void recipientEditorSizeHintChanged();
00725 void setMaximumHeaderSize();
00726
00727 private:
00728 QWidget *mMainWidget;
00729 QComboBox *mTransport;
00730 KMail::DictionaryComboBox *mDictionaryCombo;
00731 KPIM::IdentityCombo *mIdentity;
00732 KMFolderComboBox *mFcc;
00733 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00734 KMLineEditSpell *mEdtSubject;
00735 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00736 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00737 QLabel *mDictionaryLabel;
00738 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00739 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00740 bool mSpellCheckInProgress;
00741 bool mDone;
00742 bool mAtmModified;
00743
00744 KMEdit* mEditor;
00745 QGridLayout* mGrid;
00746 KMMessage *mMsg;
00747 QValueVector<KMMessage*> mComposedMessages;
00748 KMail::AttachmentListView* mAtmListView;
00749 int mAtmColEncrypt;
00750 int mAtmColSign;
00751 int mAtmColCompress;
00752 int mAtmEncryptColWidth;
00753 int mAtmSignColWidth;
00754 int mAtmCompressColWidth;
00755 QPtrList<QListViewItem> mAtmItemList;
00756 QPtrList<KMMessagePart> mAtmList;
00757 QPopupMenu *mAttachMenu;
00758 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
00759 bool mAutoDeleteMsg;
00760 bool mSigningAndEncryptionExplicitlyDisabled;
00761 bool mLastSignActionState, mLastEncryptActionState;
00762 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00763 KMFolder *mFolder;
00764 long mShowHeaders;
00765 bool mConfirmSend;
00766 bool mDisableBreaking;
00767 int mNumHeaders;
00768 bool mUseHTMLEditor;
00769 bool mHtmlMarkup;
00770 QFont mBodyFont, mFixedFont;
00771 QPtrList<KTempFile> mAtmTempList;
00772 QPalette mPalette;
00773 uint mId;
00774 QString mOldSigText;
00775
00776 KAction *mAttachPK, *mAttachMPK,
00777 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00778 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00779 KRecentFilesAction *mRecentAction;
00780
00781 KAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
00782
00783 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00784 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00785 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00786 KToggleAction *mSubjectAction;
00787 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00788 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00789 KToggleAction *mDictionaryAction, *mSnippetAction;
00790
00791 KSelectAction *listAction;
00792 KFontAction *fontAction;
00793 KFontSizeAction *fontSizeAction;
00794 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00795 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00796 KToggleAction *plainTextAction, *markupAction;
00797 KAction *actionFormatColor, *actionFormatReset;
00798 KAction *mHtmlToolbar;
00799
00800 KSelectAction *mEncodingAction;
00801 KSelectAction *mCryptoModuleAction;
00802
00803 QCString mCharset;
00804 QCString mDefCharset;
00805 QStringList mCharsets;
00806 bool mAutoCharset;
00807
00808 bool mAlwaysSend;
00809
00810 QStringList mFolderNames;
00811 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00812 QMap<KIO::Job*, KURL> mAttachJobs;
00813 KURL::List mAttachFilesPending;
00814 int mAttachFilesSend;
00815
00816 private:
00817
00818 void startPublicKeyExport();
00819 bool canSignEncryptAttachments() const {
00820 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00821 }
00822
00823 bool mSubjectTextWasSpellChecked;
00824
00825 QString addQuotesToText( const QString &inputText );
00826 QString removeQuotesFromText( const QString &inputText );
00827
00828 int calcColumnWidth(int which, long allShowing, int width);
00829
00830 private slots:
00831 void slotCompletionModeChanged( KGlobalSettings::Completion );
00832 void slotConfigChanged();
00833
00834 void slotComposerDone( bool );
00835
00836 void slotContinueDoSend( bool );
00837 void slotContinuePrint( bool );
00838 void slotContinueAutoSave();
00839
00840 void slotEncryptChiasmusToggled( bool );
00841
00846 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00847
00851 void slotAutoSpellCheckingToggled(bool);
00852
00856 void slotUpdateSignatureActions();
00857
00861 void slotUpdateSignatureAndEncrypionStateIndicators();
00862 private:
00863 QColor mForeColor,mBackColor;
00864 QFont mSaveFont;
00865 QSplitter *mHeadersToEditorSplitter;
00866 QWidget* mHeadersArea;
00867 QSplitter *mSplitter;
00868 QSplitter *mSnippetSplitter;
00869 struct atmLoadData
00870 {
00871 KURL url;
00872 QByteArray data;
00873 bool insert;
00874 QCString encoding;
00875 };
00876 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00877
00878
00879 KMail::MessageSender::SendMethod mSendMethod;
00880 KMComposeWin::SaveIn mSaveIn;
00881
00882 KToggleAction *mEncryptChiasmusAction;
00883 bool mEncryptWithChiasmus;
00884
00885
00886
00887 MessageComposer* mComposer;
00888
00889
00890 bool mMessageWasModified;
00891
00892
00893 QString mFingerprint;
00894
00895
00896 KTempDir *mTempDir;
00897
00898 bool mClassicalRecipients;
00899
00900 RecipientsEditor *mRecipientsEditor;
00901 int mLabelWidth;
00902
00903 QTimer *mAutoSaveTimer;
00904 QString mAutoSaveFilename;
00905 int mLastAutoSaveErrno;
00906
00907 QPopupMenu *mActNowMenu;
00908 QPopupMenu *mActLaterMenu;
00909
00910 QMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
00911 QMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
00912
00913 QLabel *mSignatureStateIndicator;
00914 QLabel *mEncryptionStateIndicator;
00915
00916 SnippetWidget *mSnippetWidget;
00917 std::set<KTempDir*> mTempDirs;
00918
00926 bool mPreserveUserCursorPosition;
00927
00928 bool mPreventFccOverwrite;
00929 bool mCheckForRecipients;
00930 };
00931
00932 #endif
00933