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 bool isComposing() const { return mComposer != 0; }
00167
00168 private:
00173 KMMessage* msg() const { return mMsg; }
00174
00175 public:
00179 void setAutoSaveFilename( const QString & filename );
00180
00181 private:
00185 bool isModified() const;
00186
00190 void setModified( bool modified );
00191
00192 public:
00197 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00198
00203 void setAutoDeleteWindow( bool f );
00204
00205 public:
00210 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00211 public:
00215 void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00216
00217 public:
00223 void setReplyFocus( bool hasMessage = true );
00224
00229 void setFocusToSubject();
00230
00231 private:
00235 bool inlineSigningEncryptionSelected();
00236
00242 static QString prettyMimeType( const QString& type );
00243 QString quotePrefixName() const;
00244
00245 private:
00246 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00247 void setSubjectTextWasSpellChecked( bool _spell ) {
00248 mSubjectTextWasSpellChecked = _spell;
00249 }
00250 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00251
00252 void paste( QClipboard::Mode mode );
00253
00254 public:
00256 void setSigningAndEncryptionDisabled( bool v )
00257 {
00258 mSigningAndEncryptionExplicitlyDisabled = v;
00259 }
00260
00261 private slots:
00262 void polish();
00266 void slotPrint();
00267 void slotAttachFile();
00268 void slotInsertRecentFile(const KURL&);
00269 void slotAttachedFile(const KURL&);
00270 public slots:
00271 void slotSendNow();
00272 private slots:
00273 void slotSendNowVia( int item );
00274 void slotSendLater();
00275 void slotSendLaterVia( int item );
00276
00277 void getTransportMenu();
00278
00282 void slotSaveDraft();
00283 void slotSaveTemplate();
00284 void slotNewComposer();
00285 void slotNewMailReader();
00286 void slotClose();
00287 void slotHelp();
00288
00289 void slotFind();
00290 void slotSearchAgain();
00291 void slotReplace();
00292 void slotUndo();
00293 void slotRedo();
00294 void slotCut();
00295 void slotCopy();
00296 void slotPasteClipboard();
00297 void slotPasteClipboardAsQuotation();
00298 void slotPasteClipboardAsAttachment();
00299 void slotAddQuotes();
00300 void slotRemoveQuotes();
00301 void slotAttachPNGImageData(const QByteArray &image);
00302
00303 void slotMarkAll();
00304
00305 void slotFolderRemoved(KMFolder*);
00306
00307 void slotEditDone( KMail::EditorWatcher* watcher );
00308
00309 public slots:
00316 void slotSetAlwaysSend( bool bAlwaysSend );
00317 private slots:
00321 void slotUpdateFont();
00322
00326 void slotAddrBook();
00330 void slotInsertFile();
00331
00332 void slotSetCharset();
00336 void slotSpellcheck();
00337 void slotSpellcheckConfig();
00338 void slotSubjectTextSpellChecked();
00339
00344 void slotSelectCryptoModule( bool init = false );
00345
00349 void slotStatusMessage(const QString &message);
00350 void slotEditToolbars();
00351 void slotUpdateToolbars();
00352 void slotEditKeys();
00356 void readConfig( bool reload = false );
00360 void slotUpdWinTitle(const QString& );
00361
00366 void slotEncryptToggled(bool);
00367
00371 void slotSignToggled(bool);
00372
00373 public slots:
00377 void slotWordWrapToggled(bool);
00378
00379 private slots:
00383 void slotAppendSignature();
00384
00388 void slotPrependSignature();
00389
00393 void slotInsertSignatureAtCursor();
00394
00398 void slotInsertMyPublicKey();
00399
00403 void slotInsertPublicKey();
00404
00408 void slotUpdateAttachActions();
00409
00413 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00414
00419 int currentAttachmentNum();
00420
00424 void slotAttachOpen();
00425 void slotAttachView();
00426 void slotAttachRemove();
00427 void slotAttachSave();
00428 void slotAttachProperties();
00429 void slotAttachOpenWith();
00430 void slotAttachEdit();
00431 void slotAttachEditWith();
00432 void slotAttachmentDragStarted();
00433
00438 void slotAddrBookTo();
00439 void slotAddrBookFrom();
00440 void slotAddrBookReplyTo();
00441
00442 void slotCleanSpace();
00443
00444 void slotToggleMarkup();
00445 void toggleMarkup(bool markup);
00446 void htmlToolBarVisibilityChanged( bool visible );
00447
00448
00449 void slotSpellcheckDone(int result);
00450 void slotSpellcheckDoneClearStatus();
00451
00452 public slots:
00453 void autoSaveMessage();
00454
00455 private slots:
00456 void updateCursorPosition();
00457
00458 void slotView();
00459
00463 void slotIdentityChanged(uint);
00464
00468 void slotAttachFileData(KIO::Job *, const QByteArray &);
00469 void slotAttachFileResult(KIO::Job *);
00470
00471 void slotListAction(const QString &);
00472 void slotFontAction(const QString &);
00473 void slotSizeAction(int);
00474 void slotAlignLeft();
00475 void slotAlignCenter();
00476 void slotAlignRight();
00477 void slotTextBold();
00478 void slotTextItalic();
00479 void slotTextUnder();
00480 void slotFormatReset();
00481 void slotTextColor();
00482 void fontChanged( const QFont & );
00483 void alignmentChanged( int );
00484
00485 public:
00486 bool addAttach(const KURL url);
00487
00488 public:
00492 void addAttach(const KMMessagePart* msgPart);
00493
00494 private:
00495 const KPIM::Identity & identity() const;
00496 uint identityUid() const;
00497 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00498 bool encryptToSelf() const;
00499
00500 signals:
00501 void applyChangesDone( bool );
00502 void attachmentAdded( const KURL&, bool success );
00503
00504 private:
00512 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00513
00519 void rethinkFields(bool fromslot=false);
00520
00524 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00525
00530 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00531 const QString &aLabelStr, QLabel* aLbl,
00532 QLineEdit* aEdt, QPushButton* aBtn = 0,
00533 const QString &toolTip = QString::null,
00534 const QString &whatsThis = QString::null );
00535
00536 void rethinkHeaderLine( int value, int mask, int& row,
00537 const QString& labelStr, QLabel* lbl,
00538 QComboBox* cbx, QCheckBox *chk );
00539
00543 void setupActions();
00544 void setupStatusBar();
00545 void setupEditor();
00546
00547
00551 QString subject() const;
00552 QString to() const;
00553 QString cc() const;
00554 QString bcc() const;
00555 QString from() const;
00556 QString replyTo() const;
00557
00563 void setFcc( const QString &idString );
00564
00568 virtual bool queryClose ();
00572 virtual bool queryExit ();
00573
00577 void openAttach( int index, bool with );
00578
00582 void viewAttach( int index );
00583
00587 void editAttach( int index, bool openWith );
00588
00592 void removeAttach(const QString &url);
00593 void removeAttach(int idx);
00594
00598 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00599 bool loadDefaults = true );
00600
00605 void addrBookSelInto();
00606
00607 void addrBookSelIntoOld();
00608 void addrBookSelIntoNew();
00609
00610 private:
00615 void setEncryption( bool encrypt, bool setByUser = false );
00616
00621 void setSigning( bool sign, bool setByUser = false );
00622
00626 bool userForgotAttachment();
00627
00632 bool encryptFlagOfAttachment(int idx);
00633
00638 bool signFlagOfAttachment(int idx);
00639
00640
00648 static void decryptOrStripOffCleartextSignature( QCString& );
00649
00653 bool saveDraftOrTemplate( const QString &folderName, KMMessage *msg );
00654
00658 enum SaveIn { None, Drafts, Templates };
00659 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
00660 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
00661
00665 int autoSaveInterval() const;
00666
00670 void initAutoSave();
00671
00676 void updateAutoSave();
00677
00681 void cleanupAutoSave();
00682
00688 static bool validateAddresses( QWidget * parent, const QString & addresses );
00689
00696 void setTransport( const QString & transport );
00697
00702 void insertSignature( bool append = true, int pos = 0 );
00703 private slots:
00707 void compressAttach(int idx);
00708 void uncompressAttach(int idx);
00709 void editorFocusChanged(bool gained);
00710 void recipientEditorSizeHintChanged();
00711 void setMaximumHeaderSize();
00712
00713 private:
00714 QWidget *mMainWidget;
00715 QComboBox *mTransport;
00716 KMail::DictionaryComboBox *mDictionaryCombo;
00717 KPIM::IdentityCombo *mIdentity;
00718 KMFolderComboBox *mFcc;
00719 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00720 KMLineEditSpell *mEdtSubject;
00721 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00722 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00723 QLabel *mDictionaryLabel;
00724 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00725 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00726 bool mSpellCheckInProgress;
00727 bool mDone;
00728 bool mAtmModified;
00729
00730 KMEdit* mEditor;
00731 QGridLayout* mGrid;
00732 KMMessage *mMsg;
00733 QValueVector<KMMessage*> mComposedMessages;
00734 KMail::AttachmentListView* mAtmListView;
00735 int mAtmColEncrypt;
00736 int mAtmColSign;
00737 int mAtmColCompress;
00738 int mAtmEncryptColWidth;
00739 int mAtmSignColWidth;
00740 int mAtmCompressColWidth;
00741 QPtrList<QListViewItem> mAtmItemList;
00742 QPtrList<KMMessagePart> mAtmList;
00743 QPopupMenu *mAttachMenu;
00744 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
00745 bool mAutoDeleteMsg;
00746 bool mSigningAndEncryptionExplicitlyDisabled;
00747 bool mLastSignActionState, mLastEncryptActionState;
00748 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00749 KMFolder *mFolder;
00750 long mShowHeaders;
00751 bool mConfirmSend;
00752 bool mDisableBreaking;
00753 int mNumHeaders;
00754 bool mUseHTMLEditor;
00755 bool mHtmlMarkup;
00756 QFont mBodyFont, mFixedFont;
00757 QPtrList<KTempFile> mAtmTempList;
00758 QPalette mPalette;
00759 uint mId;
00760 QString mOldSigText;
00761
00762 KAction *mAttachPK, *mAttachMPK,
00763 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00764 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00765 KRecentFilesAction *mRecentAction;
00766
00767 KAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
00768
00769 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00770 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00771 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00772 KToggleAction *mSubjectAction;
00773 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00774 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00775 KToggleAction *mDictionaryAction, *mSnippetAction;
00776
00777 KSelectAction *listAction;
00778 KFontAction *fontAction;
00779 KFontSizeAction *fontSizeAction;
00780 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00781 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00782 KToggleAction *plainTextAction, *markupAction;
00783 KAction *actionFormatColor, *actionFormatReset;
00784 KAction *mHtmlToolbar;
00785
00786 KSelectAction *mEncodingAction;
00787 KSelectAction *mCryptoModuleAction;
00788
00789 QCString mCharset;
00790 QCString mDefCharset;
00791 QStringList mCharsets;
00792 bool mAutoCharset;
00793
00794 bool mAlwaysSend;
00795
00796 QStringList mFolderNames;
00797 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00798 QMap<KIO::Job*, KURL> mAttachJobs;
00799 KURL::List mAttachFilesPending;
00800 int mAttachFilesSend;
00801
00802 private:
00803
00804 void startPublicKeyExport();
00805 bool canSignEncryptAttachments() const {
00806 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00807 }
00808
00809 bool mSubjectTextWasSpellChecked;
00810
00811 QString addQuotesToText( const QString &inputText );
00812 QString removeQuotesFromText( const QString &inputText );
00813
00814 int calcColumnWidth(int which, long allShowing, int width);
00815
00816 private slots:
00817 void slotCompletionModeChanged( KGlobalSettings::Completion );
00818 void slotConfigChanged();
00819
00820 void slotComposerDone( bool );
00821
00822 void slotContinueDoSend( bool );
00823 void slotContinuePrint( bool );
00824 void slotContinueAutoSave();
00825
00826 void slotEncryptChiasmusToggled( bool );
00827
00832 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00833
00837 void slotAutoSpellCheckingToggled(bool);
00838
00842 void slotUpdateSignatureActions();
00843
00847 void slotUpdateSignatureAndEncrypionStateIndicators();
00848 private:
00849 QColor mForeColor,mBackColor;
00850 QFont mSaveFont;
00851 QSplitter *mHeadersToEditorSplitter;
00852 QWidget* mHeadersArea;
00853 QSplitter *mSplitter;
00854 QSplitter *mSnippetSplitter;
00855 struct atmLoadData
00856 {
00857 KURL url;
00858 QByteArray data;
00859 bool insert;
00860 QCString encoding;
00861 };
00862 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00863
00864
00865 KMail::MessageSender::SendMethod mSendMethod;
00866 KMComposeWin::SaveIn mSaveIn;
00867
00868 KToggleAction *mEncryptChiasmusAction;
00869 bool mEncryptWithChiasmus;
00870
00871
00872
00873 MessageComposer* mComposer;
00874
00875
00876 bool mMessageWasModified;
00877
00878
00879 QString mFingerprint;
00880
00881
00882 KTempDir *mTempDir;
00883
00884 bool mClassicalRecipients;
00885
00886 RecipientsEditor *mRecipientsEditor;
00887 int mLabelWidth;
00888
00889 QTimer *mAutoSaveTimer;
00890 QString mAutoSaveFilename;
00891 int mLastAutoSaveErrno;
00892
00893 QPopupMenu *mActNowMenu;
00894 QPopupMenu *mActLaterMenu;
00895
00896 QMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
00897 QMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
00898
00899 QLabel *mSignatureStateIndicator;
00900 QLabel *mEncryptionStateIndicator;
00901
00902 SnippetWidget *mSnippetWidget;
00903 std::set<KTempDir*> mTempDirs;
00904
00912 bool mPreserveUserCursorPosition;
00913
00914 bool mPreventFccOverwrite;
00915 };
00916
00917 #endif
00918