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