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 slotNewComposer();
00270 void slotNewMailReader();
00271 void slotClose();
00272 void slotHelp();
00273
00274 void slotFind();
00275 void slotSearchAgain();
00276 void slotReplace();
00277 void slotUndo();
00278 void slotRedo();
00279 void slotCut();
00280 void slotCopy();
00281 void slotPaste();
00282 void slotPasteAsQuotation();
00283 void slotPasteAsAttachment();
00284 void slotAddQuotes();
00285 void slotRemoveQuotes();
00286
00287 void slotMarkAll();
00288
00289 void slotFolderRemoved(KMFolder*);
00290
00291 public slots:
00298 void slotSetAlwaysSend( bool bAlwaysSend );
00299 private slots:
00303 void slotUpdateFont();
00304
00308 void slotAddrBook();
00312 void slotInsertFile();
00313
00314 void slotSetCharset();
00318 void slotSpellcheck();
00319 void slotSpellcheckConfig();
00320 void slotSubjectTextSpellChecked();
00321
00326 void slotSelectCryptoModule( bool init = false );
00327
00331 void slotStatusMessage(const QString &message);
00332 void slotEditToolbars();
00333 void slotUpdateToolbars();
00334 void slotEditKeys();
00338 void readConfig(void);
00342 void slotUpdWinTitle(const QString& );
00343
00348 void slotEncryptToggled(bool);
00349
00353 void slotSignToggled(bool);
00354
00355 public slots:
00359 void slotWordWrapToggled(bool);
00360
00361 private slots:
00365 void slotAppendSignature();
00366
00370 void slotInsertMyPublicKey();
00371
00375 void slotInsertPublicKey();
00376
00380 void slotUpdateAttachActions();
00381
00385 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00386
00391 int currentAttachmentNum();
00392
00396 void slotAttachOpen();
00397 void slotAttachView();
00398 void slotAttachRemove();
00399 void slotAttachSave();
00400 void slotAttachProperties();
00401
00402
00407 void slotAddrBookTo();
00408 void slotAddrBookFrom();
00409 void slotAddrBookReplyTo();
00410
00411 void slotCleanSpace();
00412
00413 void slotToggleMarkup();
00414 void toggleMarkup(bool markup);
00415 void htmlToolBarVisibilityChanged( bool visible );
00416
00417
00418 void slotSpellcheckDone(int result);
00419 void slotSpellcheckDoneClearStatus();
00420
00421 public slots:
00422 void autoSaveMessage();
00423
00424 private slots:
00425 void updateCursorPosition();
00426
00427 void slotView();
00428
00432 void slotIdentityChanged(uint);
00433
00437 void slotAttachFileData(KIO::Job *, const QByteArray &);
00438 void slotAttachFileResult(KIO::Job *);
00439
00440 void slotListAction(const QString &);
00441 void slotFontAction(const QString &);
00442 void slotSizeAction(int);
00443 void slotAlignLeft();
00444 void slotAlignCenter();
00445 void slotAlignRight();
00446 void slotTextBold();
00447 void slotTextItalic();
00448 void slotTextUnder();
00449 void slotFormatReset();
00450 void slotTextColor();
00451 void fontChanged( const QFont & );
00452 void alignmentChanged( int );
00453
00454 public:
00455 void addAttach(const KURL url);
00456
00457 public:
00461 void addAttach(const KMMessagePart* msgPart);
00462
00463 private:
00467 void addImageFromClipboard();
00468
00469 private:
00470 const KPIM::Identity & identity() const;
00471 uint identityUid() const;
00472 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00473 bool encryptToSelf() const;
00474
00475 signals:
00476 void applyChangesDone( bool );
00477
00478 private:
00486 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00487
00493 void rethinkFields(bool fromslot=false);
00494
00498 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00499
00504 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00505 const QString &aLabelStr, QLabel* aLbl,
00506 QLineEdit* aEdt, QPushButton* aBtn = 0,
00507 const QString &toolTip = QString::null,
00508 const QString &whatsThis = QString::null );
00509
00510 void rethinkHeaderLine( int value, int mask, int& row,
00511 const QString& labelStr, QLabel* lbl,
00512 QComboBox* cbx, QCheckBox *chk );
00513
00517 void setupActions();
00518 void setupStatusBar();
00519 void setupEditor();
00520
00521
00525 QString subject() const;
00526 QString to() const;
00527 QString cc() const;
00528 QString bcc() const;
00529 QString from() const;
00530 QString replyTo() const;
00531
00537 void setFcc( const QString &idString );
00538
00542 virtual bool queryClose ();
00546 virtual bool queryExit ();
00547
00551 void openAttach( int index );
00552
00556 void viewAttach( int index );
00557
00561 void removeAttach(const QString &url);
00562 void removeAttach(int idx);
00563
00567 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00568 bool loadDefaults = true );
00569
00574 void addrBookSelInto();
00575
00576 void addrBookSelIntoOld();
00577 void addrBookSelIntoNew();
00578
00579 private:
00584 void setEncryption( bool encrypt, bool setByUser = false );
00585
00590 void setSigning( bool sign, bool setByUser = false );
00591
00595 bool userForgotAttachment();
00596
00601 bool encryptFlagOfAttachment(int idx);
00602
00607 bool signFlagOfAttachment(int idx);
00608
00609
00617 static void decryptOrStripOffCleartextSignature( QCString& );
00618
00622 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault, bool saveInDrafts = false);
00623
00627 int autoSaveInterval() const;
00628
00632 void initAutoSave();
00633
00638 void updateAutoSave();
00639
00643 void cleanupAutoSave();
00644
00650 static bool validateAddresses( QWidget * parent, const QString & addresses );
00651
00652 private slots:
00656 void compressAttach(int idx);
00657 void uncompressAttach(int idx);
00658 void editorFocusChanged(bool gained);
00659
00660 private:
00661 QWidget *mMainWidget;
00662 QComboBox *mTransport;
00663 KMail::DictionaryComboBox *mDictionaryCombo;
00664 KPIM::IdentityCombo *mIdentity;
00665 KMFolderComboBox *mFcc;
00666 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00667 KMLineEditSpell *mEdtSubject;
00668 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00669 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00670 QLabel *mDictionaryLabel;
00671 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00672 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00673 bool mSpellCheckInProgress;
00674 bool mDone;
00675 bool mAtmModified;
00676
00677 KMEdit* mEditor;
00678 QGridLayout* mGrid;
00679 KMMessage *mMsg;
00680 QValueVector<KMMessage*> mComposedMessages;
00681 KMail::AttachmentListView* mAtmListView;
00682 int mAtmColEncrypt;
00683 int mAtmColSign;
00684 int mAtmColCompress;
00685 int mAtmEncryptColWidth;
00686 int mAtmSignColWidth;
00687 int mAtmCompressColWidth;
00688 QPtrList<QListViewItem> mAtmItemList;
00689 QPtrList<KMMessagePart> mAtmList;
00690 QPopupMenu *mAttachMenu;
00691 int mOpenId, mViewId, mRemoveId, mSaveAsId, mPropertiesId;
00692 bool mAutoDeleteMsg;
00693 bool mSigningAndEncryptionExplicitlyDisabled;
00694 bool mLastSignActionState, mLastEncryptActionState;
00695 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00696 KMFolder *mFolder;
00697 long mShowHeaders;
00698 bool mConfirmSend;
00699 bool mDisableBreaking;
00700 int mNumHeaders;
00701 bool mUseHTMLEditor;
00702 bool mHtmlMarkup;
00703 QFont mBodyFont, mFixedFont;
00704 QPtrList<KTempFile> mAtmTempList;
00705 QPalette mPalette;
00706 uint mId;
00707 QString mOldSigText;
00708
00709 KAction *mAttachPK, *mAttachMPK,
00710 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00711 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00712 KRecentFilesAction *mRecentAction;
00713
00714 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00715 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00716 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00717 KToggleAction *mSubjectAction;
00718 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00719 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00720 KToggleAction *mDictionaryAction;
00721
00722 KSelectAction *listAction;
00723 KFontAction *fontAction;
00724 KFontSizeAction *fontSizeAction;
00725 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00726 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00727 KToggleAction *plainTextAction, *markupAction;
00728 KAction *actionFormatColor, *actionFormatReset;
00729 KAction *mHtmlToolbar;
00730
00731 KSelectAction *mEncodingAction;
00732 KSelectAction *mCryptoModuleAction;
00733
00734 QCString mCharset;
00735 QCString mDefCharset;
00736 QStringList mCharsets;
00737 bool mAutoCharset;
00738
00739 bool mAlwaysSend;
00740
00741 QStringList mFolderNames;
00742 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00743
00744 private:
00745
00746 void startPublicKeyExport();
00747 bool canSignEncryptAttachments() const {
00748 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00749 }
00750
00751 bool mSubjectTextWasSpellChecked;
00752
00753 QString addQuotesToText( const QString &inputText );
00754 QString removeQuotesFromText( const QString &inputText );
00755
00756 int calcColumnWidth(int which, long allShowing, int width);
00757
00758 private slots:
00759 void slotCompletionModeChanged( KGlobalSettings::Completion );
00760 void slotConfigChanged();
00761
00762 void slotComposerDone( bool );
00763
00764 void slotContinueDoSend( bool );
00765 void slotContinuePrint( bool );
00766 void slotContinueAutoSave( bool );
00767
00768 void slotEncryptChiasmusToggled( bool );
00769
00774 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00775
00779 void slotAutoSpellCheckingToggled(bool);
00780
00781 private:
00782 QColor mForeColor,mBackColor;
00783 QFont mSaveFont;
00784 QSplitter *mSplitter;
00785 struct atmLoadData
00786 {
00787 KURL url;
00788 QByteArray data;
00789 bool insert;
00790 QCString encoding;
00791 };
00792 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00793
00794
00795 KMail::MessageSender::SendMethod mSendMethod;
00796 bool mSaveInDrafts;
00797
00798 KToggleAction *mEncryptChiasmusAction;
00799 bool mEncryptWithChiasmus;
00800
00801
00802
00803 MessageComposer* mComposer;
00804
00805
00806 bool mMessageWasModified;
00807
00808
00809 QString mFingerprint;
00810
00811
00812 KTempDir *mTempDir;
00813
00814 bool mClassicalRecipients;
00815
00816 RecipientsEditor *mRecipientsEditor;
00817 int mLabelWidth;
00818
00819 QTimer *mAutoSaveTimer;
00820 QString mAutoSaveFilename;
00821 int mLastAutoSaveErrno;
00822
00823 QPopupMenu *mActNowMenu;
00824 QPopupMenu *mActLaterMenu;
00825 };
00826
00827 #endif
00828