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 <qlabel.h>
00018 #include <qlistview.h>
00019
00020 #include <qcheckbox.h>
00021 #include <qpushbutton.h>
00022 #include <qclipboard.h>
00023 #include <qpalette.h>
00024 #include <qfont.h>
00025 #include <qptrlist.h>
00026 #include <qvaluevector.h>
00027 #include <qsplitter.h>
00028
00029 #include <kio/job.h>
00030 #include <kglobalsettings.h>
00031 #include <kdeversion.h>
00032 #include <keditcl.h>
00033 #include <ktempdir.h>
00034
00035 #include "mailcomposerIface.h"
00036
00037 #include <libkdepim/addresseelineedit.h>
00038 #include <mimelib/mediatyp.h>
00039
00040 #include <kleo/enum.h>
00041
00042 class QCloseEvent;
00043 class QComboBox;
00044 class QFrame;
00045 class QGridLayout;
00046 class QListView;
00047 class QPopupMenu;
00048 class QPushButton;
00049 class QCString;
00050 class KCompletion;
00051 class KMEdit;
00052 class KMComposeWin;
00053 class KMFolderComboBox;
00054 class KMFolder;
00055 class KMMessage;
00056 class KMMessagePart;
00057 class KProcess;
00058 class KDirWatch;
00059 class KSelectAction;
00060 class KFontAction;
00061 class KFontSizeAction;
00062 class KSelectAction;
00063 class KStatusBar;
00064 class KAction;
00065 class KToggleAction;
00066 class KTempFile;
00067 class KToolBar;
00068 class KToggleAction;
00069 class KSelectColorAction;
00070 class KURL;
00071 class KRecentFilesAction;
00072 class SpellingFilter;
00073 class MessageComposer;
00074 class RecipientsEditor;
00075 class KMLineEdit;
00076 class KMLineEditSpell;
00077 class KMAtmListViewItem;
00078
00079 namespace KPIM {
00080 class IdentityCombo;
00081 class Identity;
00082 }
00083
00084 namespace KMail {
00085 class AttachmentListView;
00086 class DictionaryComboBox;
00087 }
00088
00089 namespace GpgME {
00090 class Error;
00091 }
00092
00093
00094 class KMComposeWin : public KMail::Composer, virtual public MailComposerIface
00095 {
00096 Q_OBJECT
00097 friend class ::KMEdit;
00098 friend class ::MessageComposer;
00099
00100 private:
00101 KMComposeWin( KMMessage* msg=0, uint identity=0 );
00102 ~KMComposeWin();
00103 public:
00104 static Composer * create( KMMessage * msg = 0, uint identity = 0 );
00105
00106 MailComposerIface * asMailComposerIFace() { return this; }
00107 const MailComposerIface * asMailComposerIFace() const { return this; }
00108
00109 public:
00113 void send(int how);
00114 void addAttachment(KURL url,QString comment);
00115 void addAttachment(const QString &name,
00116 const QCString &cte,
00117 const QByteArray &data,
00118 const QCString &type,
00119 const QCString &subType,
00120 const QCString ¶mAttr,
00121 const QString ¶mValue,
00122 const QCString &contDisp);
00123 public:
00124 void setBody (QString body);
00125
00126 private:
00130 virtual bool event(QEvent *e);
00131
00135 void readColorConfig();
00136
00140 void writeConfig(void);
00141
00146 void verifyWordWrapLengthIsAdequate(const QString&);
00147
00148 public:
00153 void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
00154 bool allowDecryption=FALSE, bool isModified=FALSE);
00155
00156 private:
00161 KMMessage* msg() const { return mMsg; }
00162
00163 public:
00167 void setAutoSaveFilename( const QString & filename );
00168
00169 private:
00173 bool isModified() const;
00174
00178 void setModified( bool modified );
00179
00180 public:
00185 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00186
00191 void setAutoDeleteWindow( bool f );
00192
00193 public:
00198 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00199 public:
00203 void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00204
00205 public:
00211 void setReplyFocus( bool hasMessage = true );
00212
00217 void setFocusToSubject();
00218
00219 private:
00223 bool inlineSigningEncryptionSelected();
00224
00230 static QString prettyMimeType( const QString& type );
00231 QString quotePrefixName() const;
00232
00233 private:
00234 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00235 void setSubjectTextWasSpellChecked( bool _spell ) {
00236 mSubjectTextWasSpellChecked = _spell;
00237 }
00238 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00239
00240
00241 public:
00243 void setSigningAndEncryptionDisabled( bool v )
00244 {
00245 mSigningAndEncryptionExplicitlyDisabled = v;
00246 }
00247
00248 private slots:
00249 void polish();
00253 void slotPrint();
00254 void slotAttachFile();
00255 void slotInsertRecentFile(const KURL&);
00256 public slots:
00257 void slotSendNow();
00258 private slots:
00259 void slotSendNowVia( int item );
00260 void slotSendLater();
00261 void slotSendLaterVia( int item );
00262
00263 void getTransportMenu();
00264
00268 void slotSaveDraft();
00269 void slotSaveTemplate();
00270 void slotNewComposer();
00271 void slotNewMailReader();
00272 void slotClose();
00273 void slotHelp();
00274
00275 void slotFind();
00276 void slotSearchAgain();
00277 void slotReplace();
00278 void slotUndo();
00279 void slotRedo();
00280 void slotCut();
00281 void slotCopy();
00282 void slotPaste();
00283 void slotPasteAsQuotation();
00284 void slotPasteAsAttachment();
00285 void slotAddQuotes();
00286 void slotRemoveQuotes();
00287
00288 void slotMarkAll();
00289
00290 void slotFolderRemoved(KMFolder*);
00291
00292 public slots:
00299 void slotSetAlwaysSend( bool bAlwaysSend );
00300 private slots:
00304 void slotUpdateFont();
00305
00309 void slotAddrBook();
00313 void slotInsertFile();
00314
00315 void slotSetCharset();
00319 void slotSpellcheck();
00320 void slotSpellcheckConfig();
00321 void slotSubjectTextSpellChecked();
00322
00327 void slotSelectCryptoModule( bool init = false );
00328
00332 void slotStatusMessage(const QString &message);
00333 void slotEditToolbars();
00334 void slotUpdateToolbars();
00335 void slotEditKeys();
00339 void readConfig(void);
00343 void slotUpdWinTitle(const QString& );
00344
00349 void slotEncryptToggled(bool);
00350
00354 void slotSignToggled(bool);
00355
00356 public slots:
00360 void slotWordWrapToggled(bool);
00361
00362 private slots:
00366 void slotAppendSignature();
00367
00371 void slotInsertMyPublicKey();
00372
00376 void slotInsertPublicKey();
00377
00381 void slotUpdateAttachActions();
00382
00386 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00387
00392 int currentAttachmentNum();
00393
00397 void slotAttachOpen();
00398 void slotAttachView();
00399 void slotAttachRemove();
00400 void slotAttachSave();
00401 void slotAttachProperties();
00402 void slotAttachOpenWith();
00403
00408 void slotAddrBookTo();
00409 void slotAddrBookFrom();
00410 void slotAddrBookReplyTo();
00411
00412 void slotCleanSpace();
00413
00414 void slotToggleMarkup();
00415 void toggleMarkup(bool markup);
00416 void htmlToolBarVisibilityChanged( bool visible );
00417
00418
00419 void slotSpellcheckDone(int result);
00420 void slotSpellcheckDoneClearStatus();
00421
00422 public slots:
00423 void autoSaveMessage();
00424
00425 private slots:
00426 void updateCursorPosition();
00427
00428 void slotView();
00429
00433 void slotIdentityChanged(uint);
00434
00438 void slotAttachFileData(KIO::Job *, const QByteArray &);
00439 void slotAttachFileResult(KIO::Job *);
00440
00441 void slotListAction(const QString &);
00442 void slotFontAction(const QString &);
00443 void slotSizeAction(int);
00444 void slotAlignLeft();
00445 void slotAlignCenter();
00446 void slotAlignRight();
00447 void slotTextBold();
00448 void slotTextItalic();
00449 void slotTextUnder();
00450 void slotFormatReset();
00451 void slotTextColor();
00452 void fontChanged( const QFont & );
00453 void alignmentChanged( int );
00454
00455 public:
00456 void addAttach(const KURL url);
00457
00458 public:
00462 void addAttach(const KMMessagePart* msgPart);
00463
00464 private:
00468 void addImageFromClipboard();
00469
00470 private:
00471 const KPIM::Identity & identity() const;
00472 uint identityUid() const;
00473 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00474 bool encryptToSelf() const;
00475
00476 signals:
00477 void applyChangesDone( bool );
00478
00479 private:
00487 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00488
00494 void rethinkFields(bool fromslot=false);
00495
00499 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00500
00505 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00506 const QString &aLabelStr, QLabel* aLbl,
00507 QLineEdit* aEdt, QPushButton* aBtn = 0,
00508 const QString &toolTip = QString::null,
00509 const QString &whatsThis = QString::null );
00510
00511 void rethinkHeaderLine( int value, int mask, int& row,
00512 const QString& labelStr, QLabel* lbl,
00513 QComboBox* cbx, QCheckBox *chk );
00514
00518 void setupActions();
00519 void setupStatusBar();
00520 void setupEditor();
00521
00522
00526 QString subject() const;
00527 QString to() const;
00528 QString cc() const;
00529 QString bcc() const;
00530 QString from() const;
00531 QString replyTo() const;
00532
00538 void setFcc( const QString &idString );
00539
00543 virtual bool queryClose ();
00547 virtual bool queryExit ();
00548
00552 void openAttach( int index, bool with );
00553
00557 void viewAttach( int index );
00558
00562 void removeAttach(const QString &url);
00563 void removeAttach(int idx);
00564
00568 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00569 bool loadDefaults = true );
00570
00575 void addrBookSelInto();
00576
00577 void addrBookSelIntoOld();
00578 void addrBookSelIntoNew();
00579
00580 private:
00585 void setEncryption( bool encrypt, bool setByUser = false );
00586
00591 void setSigning( bool sign, bool setByUser = false );
00592
00596 bool userForgotAttachment();
00597
00602 bool encryptFlagOfAttachment(int idx);
00603
00608 bool signFlagOfAttachment(int idx);
00609
00610
00618 static void decryptOrStripOffCleartextSignature( QCString& );
00619
00623 bool saveDraftOrTemplate( const QString &folderName, KMMessage *msg );
00624
00628 enum SaveIn { None, Drafts, Templates };
00629 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
00630 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
00631
00635 int autoSaveInterval() const;
00636
00640 void initAutoSave();
00641
00646 void updateAutoSave();
00647
00651 void cleanupAutoSave();
00652
00658 static bool validateAddresses( QWidget * parent, const QString & addresses );
00659
00666 void setTransport( const QString & transport );
00667
00668 private slots:
00672 void compressAttach(int idx);
00673 void uncompressAttach(int idx);
00674 void editorFocusChanged(bool gained);
00675
00676 private:
00677 QWidget *mMainWidget;
00678 QComboBox *mTransport;
00679 KMail::DictionaryComboBox *mDictionaryCombo;
00680 KPIM::IdentityCombo *mIdentity;
00681 KMFolderComboBox *mFcc;
00682 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00683 KMLineEditSpell *mEdtSubject;
00684 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00685 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00686 QLabel *mDictionaryLabel;
00687 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00688 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00689 bool mSpellCheckInProgress;
00690 bool mDone;
00691 bool mAtmModified;
00692
00693 KMEdit* mEditor;
00694 QGridLayout* mGrid;
00695 KMMessage *mMsg;
00696 QValueVector<KMMessage*> mComposedMessages;
00697 KMail::AttachmentListView* mAtmListView;
00698 int mAtmColEncrypt;
00699 int mAtmColSign;
00700 int mAtmColCompress;
00701 int mAtmEncryptColWidth;
00702 int mAtmSignColWidth;
00703 int mAtmCompressColWidth;
00704 QPtrList<QListViewItem> mAtmItemList;
00705 QPtrList<KMMessagePart> mAtmList;
00706 QPopupMenu *mAttachMenu;
00707 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId;
00708 bool mAutoDeleteMsg;
00709 bool mSigningAndEncryptionExplicitlyDisabled;
00710 bool mLastSignActionState, mLastEncryptActionState;
00711 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00712 KMFolder *mFolder;
00713 long mShowHeaders;
00714 bool mConfirmSend;
00715 bool mDisableBreaking;
00716 int mNumHeaders;
00717 bool mUseHTMLEditor;
00718 bool mHtmlMarkup;
00719 QFont mBodyFont, mFixedFont;
00720 QPtrList<KTempFile> mAtmTempList;
00721 QPalette mPalette;
00722 uint mId;
00723 QString mOldSigText;
00724
00725 KAction *mAttachPK, *mAttachMPK,
00726 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00727 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00728 KRecentFilesAction *mRecentAction;
00729
00730 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00731 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00732 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00733 KToggleAction *mSubjectAction;
00734 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00735 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00736 KToggleAction *mDictionaryAction;
00737
00738 KSelectAction *listAction;
00739 KFontAction *fontAction;
00740 KFontSizeAction *fontSizeAction;
00741 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00742 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00743 KToggleAction *plainTextAction, *markupAction;
00744 KAction *actionFormatColor, *actionFormatReset;
00745 KAction *mHtmlToolbar;
00746
00747 KSelectAction *mEncodingAction;
00748 KSelectAction *mCryptoModuleAction;
00749
00750 QCString mCharset;
00751 QCString mDefCharset;
00752 QStringList mCharsets;
00753 bool mAutoCharset;
00754
00755 bool mAlwaysSend;
00756
00757 QStringList mFolderNames;
00758 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00759
00760 private:
00761
00762 void startPublicKeyExport();
00763 bool canSignEncryptAttachments() const {
00764 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00765 }
00766
00767 bool mSubjectTextWasSpellChecked;
00768
00769 QString addQuotesToText( const QString &inputText );
00770 QString removeQuotesFromText( const QString &inputText );
00771
00772 int calcColumnWidth(int which, long allShowing, int width);
00773
00774 private slots:
00775 void slotCompletionModeChanged( KGlobalSettings::Completion );
00776 void slotConfigChanged();
00777
00778 void slotComposerDone( bool );
00779
00780 void slotContinueDoSend( bool );
00781 void slotContinuePrint( bool );
00782 void slotContinueAutoSave( bool );
00783
00784 void slotEncryptChiasmusToggled( bool );
00785
00790 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00791
00795 void slotAutoSpellCheckingToggled(bool);
00796
00797 private:
00798 QColor mForeColor,mBackColor;
00799 QFont mSaveFont;
00800 QSplitter *mSplitter;
00801 struct atmLoadData
00802 {
00803 KURL url;
00804 QByteArray data;
00805 bool insert;
00806 QCString encoding;
00807 };
00808 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00809
00810
00811 KMail::MessageSender::SendMethod mSendMethod;
00812 KMComposeWin::SaveIn mSaveIn;
00813
00814 KToggleAction *mEncryptChiasmusAction;
00815 bool mEncryptWithChiasmus;
00816
00817
00818
00819 MessageComposer* mComposer;
00820
00821
00822 bool mMessageWasModified;
00823
00824
00825 QString mFingerprint;
00826
00827
00828 KTempDir *mTempDir;
00829
00830 bool mClassicalRecipients;
00831
00832 RecipientsEditor *mRecipientsEditor;
00833 int mLabelWidth;
00834
00835 QTimer *mAutoSaveTimer;
00836 QString mAutoSaveFilename;
00837 int mLastAutoSaveErrno;
00838
00839 QPopupMenu *mActNowMenu;
00840 QPopupMenu *mActLaterMenu;
00841 };
00842
00843 #endif
00844