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 addAttachmentsAndSend(const KURL::List &urls, const QString &comment, int how);
00115 void addAttachment(KURL url,QString comment);
00116 void addAttachment(const QString &name,
00117 const QCString &cte,
00118 const QByteArray &data,
00119 const QCString &type,
00120 const QCString &subType,
00121 const QCString ¶mAttr,
00122 const QString ¶mValue,
00123 const QCString &contDisp);
00124 public:
00125 void setBody (QString body);
00126
00127 private:
00131 virtual bool event(QEvent *e);
00132
00136 void readColorConfig();
00137
00141 void writeConfig(void);
00142
00147 void verifyWordWrapLengthIsAdequate(const QString&);
00148
00149 public:
00154 void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
00155 bool allowDecryption=FALSE, bool isModified=FALSE);
00156
00157 private:
00162 KMMessage* msg() const { return mMsg; }
00163
00164 public:
00168 void setAutoSaveFilename( const QString & filename );
00169
00170 private:
00174 bool isModified() const;
00175
00179 void setModified( bool modified );
00180
00181 public:
00186 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00187
00192 void setAutoDeleteWindow( bool f );
00193
00194 public:
00199 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00200 public:
00204 void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00205
00206 public:
00212 void setReplyFocus( bool hasMessage = true );
00213
00218 void setFocusToSubject();
00219
00220 private:
00224 bool inlineSigningEncryptionSelected();
00225
00231 static QString prettyMimeType( const QString& type );
00232 QString quotePrefixName() const;
00233
00234 private:
00235 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00236 void setSubjectTextWasSpellChecked( bool _spell ) {
00237 mSubjectTextWasSpellChecked = _spell;
00238 }
00239 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00240
00241
00242 public:
00244 void setSigningAndEncryptionDisabled( bool v )
00245 {
00246 mSigningAndEncryptionExplicitlyDisabled = v;
00247 }
00248
00249 private slots:
00250 void polish();
00254 void slotPrint();
00255 void slotAttachFile();
00256 void slotInsertRecentFile(const KURL&);
00257 void slotAttachedFile(const KURL&);
00258 public slots:
00259 void slotSendNow();
00260 private slots:
00261 void slotSendNowVia( int item );
00262 void slotSendLater();
00263 void slotSendLaterVia( int item );
00264
00265 void getTransportMenu();
00266
00270 void slotSaveDraft();
00271 void slotSaveTemplate();
00272 void slotNewComposer();
00273 void slotNewMailReader();
00274 void slotClose();
00275 void slotHelp();
00276
00277 void slotFind();
00278 void slotSearchAgain();
00279 void slotReplace();
00280 void slotUndo();
00281 void slotRedo();
00282 void slotCut();
00283 void slotCopy();
00284 void slotPaste();
00285 void slotPasteAsQuotation();
00286 void slotPasteAsAttachment();
00287 void slotAddQuotes();
00288 void slotRemoveQuotes();
00289 void slotAttachPNGImageData(const QByteArray &image);
00290
00291 void slotMarkAll();
00292
00293 void slotFolderRemoved(KMFolder*);
00294
00295 public slots:
00302 void slotSetAlwaysSend( bool bAlwaysSend );
00303 private slots:
00307 void slotUpdateFont();
00308
00312 void slotAddrBook();
00316 void slotInsertFile();
00317
00318 void slotSetCharset();
00322 void slotSpellcheck();
00323 void slotSpellcheckConfig();
00324 void slotSubjectTextSpellChecked();
00325
00330 void slotSelectCryptoModule( bool init = false );
00331
00335 void slotStatusMessage(const QString &message);
00336 void slotEditToolbars();
00337 void slotUpdateToolbars();
00338 void slotEditKeys();
00342 void readConfig(void);
00346 void slotUpdWinTitle(const QString& );
00347
00352 void slotEncryptToggled(bool);
00353
00357 void slotSignToggled(bool);
00358
00359 public slots:
00363 void slotWordWrapToggled(bool);
00364
00365 private slots:
00369 void slotAppendSignature();
00370
00374 void slotInsertMyPublicKey();
00375
00379 void slotInsertPublicKey();
00380
00384 void slotUpdateAttachActions();
00385
00389 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00390
00395 int currentAttachmentNum();
00396
00400 void slotAttachOpen();
00401 void slotAttachView();
00402 void slotAttachRemove();
00403 void slotAttachSave();
00404 void slotAttachProperties();
00405 void slotAttachOpenWith();
00406
00411 void slotAddrBookTo();
00412 void slotAddrBookFrom();
00413 void slotAddrBookReplyTo();
00414
00415 void slotCleanSpace();
00416
00417 void slotToggleMarkup();
00418 void toggleMarkup(bool markup);
00419 void htmlToolBarVisibilityChanged( bool visible );
00420
00421
00422 void slotSpellcheckDone(int result);
00423 void slotSpellcheckDoneClearStatus();
00424
00425 public slots:
00426 void autoSaveMessage();
00427
00428 private slots:
00429 void updateCursorPosition();
00430
00431 void slotView();
00432
00436 void slotIdentityChanged(uint);
00437
00441 void slotAttachFileData(KIO::Job *, const QByteArray &);
00442 void slotAttachFileResult(KIO::Job *);
00443
00444 void slotListAction(const QString &);
00445 void slotFontAction(const QString &);
00446 void slotSizeAction(int);
00447 void slotAlignLeft();
00448 void slotAlignCenter();
00449 void slotAlignRight();
00450 void slotTextBold();
00451 void slotTextItalic();
00452 void slotTextUnder();
00453 void slotFormatReset();
00454 void slotTextColor();
00455 void fontChanged( const QFont & );
00456 void alignmentChanged( int );
00457
00458 public:
00459 bool addAttach(const KURL url);
00460
00461 public:
00465 void addAttach(const KMMessagePart* msgPart);
00466
00467 private:
00468 const KPIM::Identity & identity() const;
00469 uint identityUid() const;
00470 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00471 bool encryptToSelf() const;
00472
00473 signals:
00474 void applyChangesDone( bool );
00475 void attachmentAdded( const KURL&, bool success );
00476
00477 private:
00485 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00486
00492 void rethinkFields(bool fromslot=false);
00493
00497 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00498
00503 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00504 const QString &aLabelStr, QLabel* aLbl,
00505 QLineEdit* aEdt, QPushButton* aBtn = 0,
00506 const QString &toolTip = QString::null,
00507 const QString &whatsThis = QString::null );
00508
00509 void rethinkHeaderLine( int value, int mask, int& row,
00510 const QString& labelStr, QLabel* lbl,
00511 QComboBox* cbx, QCheckBox *chk );
00512
00516 void setupActions();
00517 void setupStatusBar();
00518 void setupEditor();
00519
00520
00524 QString subject() const;
00525 QString to() const;
00526 QString cc() const;
00527 QString bcc() const;
00528 QString from() const;
00529 QString replyTo() const;
00530
00536 void setFcc( const QString &idString );
00537
00541 virtual bool queryClose ();
00545 virtual bool queryExit ();
00546
00550 void openAttach( int index, bool with );
00551
00555 void viewAttach( int index );
00556
00560 void removeAttach(const QString &url);
00561 void removeAttach(int idx);
00562
00566 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00567 bool loadDefaults = true );
00568
00573 void addrBookSelInto();
00574
00575 void addrBookSelIntoOld();
00576 void addrBookSelIntoNew();
00577
00578 private:
00583 void setEncryption( bool encrypt, bool setByUser = false );
00584
00589 void setSigning( bool sign, bool setByUser = false );
00590
00594 bool userForgotAttachment();
00595
00600 bool encryptFlagOfAttachment(int idx);
00601
00606 bool signFlagOfAttachment(int idx);
00607
00608
00616 static void decryptOrStripOffCleartextSignature( QCString& );
00617
00621 bool saveDraftOrTemplate( const QString &folderName, KMMessage *msg );
00622
00626 enum SaveIn { None, Drafts, Templates };
00627 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
00628 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
00629
00633 int autoSaveInterval() const;
00634
00638 void initAutoSave();
00639
00644 void updateAutoSave();
00645
00649 void cleanupAutoSave();
00650
00656 static bool validateAddresses( QWidget * parent, const QString & addresses );
00657
00664 void setTransport( const QString & transport );
00665
00666 private slots:
00670 void compressAttach(int idx);
00671 void uncompressAttach(int idx);
00672 void editorFocusChanged(bool gained);
00673
00674 private:
00675 QWidget *mMainWidget;
00676 QComboBox *mTransport;
00677 KMail::DictionaryComboBox *mDictionaryCombo;
00678 KPIM::IdentityCombo *mIdentity;
00679 KMFolderComboBox *mFcc;
00680 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00681 KMLineEditSpell *mEdtSubject;
00682 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00683 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00684 QLabel *mDictionaryLabel;
00685 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00686 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00687 bool mSpellCheckInProgress;
00688 bool mDone;
00689 bool mAtmModified;
00690
00691 KMEdit* mEditor;
00692 QGridLayout* mGrid;
00693 KMMessage *mMsg;
00694 QValueVector<KMMessage*> mComposedMessages;
00695 KMail::AttachmentListView* mAtmListView;
00696 int mAtmColEncrypt;
00697 int mAtmColSign;
00698 int mAtmColCompress;
00699 int mAtmEncryptColWidth;
00700 int mAtmSignColWidth;
00701 int mAtmCompressColWidth;
00702 QPtrList<QListViewItem> mAtmItemList;
00703 QPtrList<KMMessagePart> mAtmList;
00704 QPopupMenu *mAttachMenu;
00705 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId;
00706 bool mAutoDeleteMsg;
00707 bool mSigningAndEncryptionExplicitlyDisabled;
00708 bool mLastSignActionState, mLastEncryptActionState;
00709 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00710 KMFolder *mFolder;
00711 long mShowHeaders;
00712 bool mConfirmSend;
00713 bool mDisableBreaking;
00714 int mNumHeaders;
00715 bool mUseHTMLEditor;
00716 bool mHtmlMarkup;
00717 QFont mBodyFont, mFixedFont;
00718 QPtrList<KTempFile> mAtmTempList;
00719 QPalette mPalette;
00720 uint mId;
00721 QString mOldSigText;
00722
00723 KAction *mAttachPK, *mAttachMPK,
00724 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00725 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00726 KRecentFilesAction *mRecentAction;
00727
00728 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00729 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00730 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00731 KToggleAction *mSubjectAction;
00732 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00733 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00734 KToggleAction *mDictionaryAction;
00735
00736 KSelectAction *listAction;
00737 KFontAction *fontAction;
00738 KFontSizeAction *fontSizeAction;
00739 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00740 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00741 KToggleAction *plainTextAction, *markupAction;
00742 KAction *actionFormatColor, *actionFormatReset;
00743 KAction *mHtmlToolbar;
00744
00745 KSelectAction *mEncodingAction;
00746 KSelectAction *mCryptoModuleAction;
00747
00748 QCString mCharset;
00749 QCString mDefCharset;
00750 QStringList mCharsets;
00751 bool mAutoCharset;
00752
00753 bool mAlwaysSend;
00754
00755 QStringList mFolderNames;
00756 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00757 QMap<KIO::Job*, KURL> mAttachJobs;
00758 KURL::List mAttachFilesPending;
00759 int mAttachFilesSend;
00760
00761 private:
00762
00763 void startPublicKeyExport();
00764 bool canSignEncryptAttachments() const {
00765 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00766 }
00767
00768 bool mSubjectTextWasSpellChecked;
00769
00770 QString addQuotesToText( const QString &inputText );
00771 QString removeQuotesFromText( const QString &inputText );
00772
00773 int calcColumnWidth(int which, long allShowing, int width);
00774
00775 private slots:
00776 void slotCompletionModeChanged( KGlobalSettings::Completion );
00777 void slotConfigChanged();
00778
00779 void slotComposerDone( bool );
00780
00781 void slotContinueDoSend( bool );
00782 void slotContinuePrint( bool );
00783 void slotContinueAutoSave();
00784
00785 void slotEncryptChiasmusToggled( bool );
00786
00791 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00792
00796 void slotAutoSpellCheckingToggled(bool);
00797
00798 private:
00799 QColor mForeColor,mBackColor;
00800 QFont mSaveFont;
00801 QSplitter *mSplitter;
00802 struct atmLoadData
00803 {
00804 KURL url;
00805 QByteArray data;
00806 bool insert;
00807 QCString encoding;
00808 };
00809 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00810
00811
00812 KMail::MessageSender::SendMethod mSendMethod;
00813 KMComposeWin::SaveIn mSaveIn;
00814
00815 KToggleAction *mEncryptChiasmusAction;
00816 bool mEncryptWithChiasmus;
00817
00818
00819
00820 MessageComposer* mComposer;
00821
00822
00823 bool mMessageWasModified;
00824
00825
00826 QString mFingerprint;
00827
00828
00829 KTempDir *mTempDir;
00830
00831 bool mClassicalRecipients;
00832
00833 RecipientsEditor *mRecipientsEditor;
00834 int mLabelWidth;
00835
00836 QTimer *mAutoSaveTimer;
00837 QString mAutoSaveFilename;
00838 int mLastAutoSaveErrno;
00839
00840 QPopupMenu *mActNowMenu;
00841 QPopupMenu *mActLaterMenu;
00842
00850 bool mPreserveUserCursorPosition;
00851 };
00852
00853 #endif
00854