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 class SnippetWidget;
00079
00080 namespace KPIM {
00081 class IdentityCombo;
00082 class Identity;
00083 }
00084
00085 namespace KMail {
00086 class AttachmentListView;
00087 class DictionaryComboBox;
00088 class EditorWatcher;
00089 }
00090
00091 namespace GpgME {
00092 class Error;
00093 }
00094
00095
00096 class KMComposeWin : public KMail::Composer, virtual public MailComposerIface
00097 {
00098 Q_OBJECT
00099 friend class ::KMEdit;
00100 friend class ::MessageComposer;
00101
00102 private:
00103 KMComposeWin( KMMessage* msg=0, uint identity=0 );
00104 ~KMComposeWin();
00105 public:
00106 static Composer * create( KMMessage * msg = 0, uint identity = 0 );
00107
00108 MailComposerIface * asMailComposerIFace() { return this; }
00109 const MailComposerIface * asMailComposerIFace() const { return this; }
00110
00111 public:
00115 void send(int how);
00116 void addAttachmentsAndSend(const KURL::List &urls, const QString &comment, int how);
00117 void addAttachment(KURL url,QString comment);
00118 void addAttachment(const QString &name,
00119 const QCString &cte,
00120 const QByteArray &data,
00121 const QCString &type,
00122 const QCString &subType,
00123 const QCString ¶mAttr,
00124 const QString ¶mValue,
00125 const QCString &contDisp);
00126 public:
00127 void setBody (QString body);
00128
00129 private:
00133 virtual bool event(QEvent *e);
00134
00138 void readColorConfig();
00139
00143 void writeConfig(void);
00144
00149 void verifyWordWrapLengthIsAdequate(const QString&);
00150
00151 public:
00156 void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
00157 bool allowDecryption=FALSE, bool isModified=FALSE);
00158
00159 private:
00164 KMMessage* msg() const { return mMsg; }
00165
00166 public:
00170 void setAutoSaveFilename( const QString & filename );
00171
00172 private:
00176 bool isModified() const;
00177
00181 void setModified( bool modified );
00182
00183 public:
00188 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00189
00194 void setAutoDeleteWindow( bool f );
00195
00196 public:
00201 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00202 public:
00206 void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00207
00208 public:
00214 void setReplyFocus( bool hasMessage = true );
00215
00220 void setFocusToSubject();
00221
00222 private:
00226 bool inlineSigningEncryptionSelected();
00227
00233 static QString prettyMimeType( const QString& type );
00234 QString quotePrefixName() const;
00235
00236 private:
00237 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00238 void setSubjectTextWasSpellChecked( bool _spell ) {
00239 mSubjectTextWasSpellChecked = _spell;
00240 }
00241 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00242
00243 void paste( QClipboard::Mode mode );
00244
00245 public:
00247 void setSigningAndEncryptionDisabled( bool v )
00248 {
00249 mSigningAndEncryptionExplicitlyDisabled = v;
00250 }
00251
00252 private slots:
00253 void polish();
00257 void slotPrint();
00258 void slotAttachFile();
00259 void slotInsertRecentFile(const KURL&);
00260 void slotAttachedFile(const KURL&);
00261 public slots:
00262 void slotSendNow();
00263 private slots:
00264 void slotSendNowVia( int item );
00265 void slotSendLater();
00266 void slotSendLaterVia( int item );
00267
00268 void getTransportMenu();
00269
00273 void slotSaveDraft();
00274 void slotSaveTemplate();
00275 void slotNewComposer();
00276 void slotNewMailReader();
00277 void slotClose();
00278 void slotHelp();
00279
00280 void slotFind();
00281 void slotSearchAgain();
00282 void slotReplace();
00283 void slotUndo();
00284 void slotRedo();
00285 void slotCut();
00286 void slotCopy();
00287 void slotPasteClipboard();
00288 void slotPasteClipboardAsQuotation();
00289 void slotPasteClipboardAsAttachment();
00290 void slotAddQuotes();
00291 void slotRemoveQuotes();
00292 void slotAttachPNGImageData(const QByteArray &image);
00293
00294 void slotMarkAll();
00295
00296 void slotFolderRemoved(KMFolder*);
00297
00298 void slotEditDone( KMail::EditorWatcher* watcher );
00299
00300 public slots:
00307 void slotSetAlwaysSend( bool bAlwaysSend );
00308 private slots:
00312 void slotUpdateFont();
00313
00317 void slotAddrBook();
00321 void slotInsertFile();
00322
00323 void slotSetCharset();
00327 void slotSpellcheck();
00328 void slotSpellcheckConfig();
00329 void slotSubjectTextSpellChecked();
00330
00335 void slotSelectCryptoModule( bool init = false );
00336
00340 void slotStatusMessage(const QString &message);
00341 void slotEditToolbars();
00342 void slotUpdateToolbars();
00343 void slotEditKeys();
00347 void readConfig(void);
00351 void slotUpdWinTitle(const QString& );
00352
00357 void slotEncryptToggled(bool);
00358
00362 void slotSignToggled(bool);
00363
00364 public slots:
00368 void slotWordWrapToggled(bool);
00369
00370 private slots:
00374 void slotAppendSignature();
00375
00379 void slotPrependSignature();
00380
00384 void slotInsertSignatureAtCursor();
00385
00389 void slotInsertMyPublicKey();
00390
00394 void slotInsertPublicKey();
00395
00399 void slotUpdateAttachActions();
00400
00404 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00405
00410 int currentAttachmentNum();
00411
00415 void slotAttachOpen();
00416 void slotAttachView();
00417 void slotAttachRemove();
00418 void slotAttachSave();
00419 void slotAttachProperties();
00420 void slotAttachOpenWith();
00421 void slotAttachEdit();
00422 void slotAttachEditWith();
00423
00428 void slotAddrBookTo();
00429 void slotAddrBookFrom();
00430 void slotAddrBookReplyTo();
00431
00432 void slotCleanSpace();
00433
00434 void slotToggleMarkup();
00435 void toggleMarkup(bool markup);
00436 void htmlToolBarVisibilityChanged( bool visible );
00437
00438
00439 void slotSpellcheckDone(int result);
00440 void slotSpellcheckDoneClearStatus();
00441
00442 public slots:
00443 void autoSaveMessage();
00444
00445 private slots:
00446 void updateCursorPosition();
00447
00448 void slotView();
00449
00453 void slotIdentityChanged(uint);
00454
00458 void slotAttachFileData(KIO::Job *, const QByteArray &);
00459 void slotAttachFileResult(KIO::Job *);
00460
00461 void slotListAction(const QString &);
00462 void slotFontAction(const QString &);
00463 void slotSizeAction(int);
00464 void slotAlignLeft();
00465 void slotAlignCenter();
00466 void slotAlignRight();
00467 void slotTextBold();
00468 void slotTextItalic();
00469 void slotTextUnder();
00470 void slotFormatReset();
00471 void slotTextColor();
00472 void fontChanged( const QFont & );
00473 void alignmentChanged( int );
00474
00475 public:
00476 bool addAttach(const KURL url);
00477
00478 public:
00482 void addAttach(const KMMessagePart* msgPart);
00483
00484 private:
00485 const KPIM::Identity & identity() const;
00486 uint identityUid() const;
00487 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00488 bool encryptToSelf() const;
00489
00490 signals:
00491 void applyChangesDone( bool );
00492 void attachmentAdded( const KURL&, bool success );
00493
00494 private:
00502 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00503
00509 void rethinkFields(bool fromslot=false);
00510
00514 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00515
00520 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00521 const QString &aLabelStr, QLabel* aLbl,
00522 QLineEdit* aEdt, QPushButton* aBtn = 0,
00523 const QString &toolTip = QString::null,
00524 const QString &whatsThis = QString::null );
00525
00526 void rethinkHeaderLine( int value, int mask, int& row,
00527 const QString& labelStr, QLabel* lbl,
00528 QComboBox* cbx, QCheckBox *chk );
00529
00533 void setupActions();
00534 void setupStatusBar();
00535 void setupEditor();
00536
00537
00541 QString subject() const;
00542 QString to() const;
00543 QString cc() const;
00544 QString bcc() const;
00545 QString from() const;
00546 QString replyTo() const;
00547
00553 void setFcc( const QString &idString );
00554
00558 virtual bool queryClose ();
00562 virtual bool queryExit ();
00563
00567 void openAttach( int index, bool with );
00568
00572 void viewAttach( int index );
00573
00577 void editAttach( int index, bool openWith );
00578
00582 void removeAttach(const QString &url);
00583 void removeAttach(int idx);
00584
00588 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00589 bool loadDefaults = true );
00590
00595 void addrBookSelInto();
00596
00597 void addrBookSelIntoOld();
00598 void addrBookSelIntoNew();
00599
00600 private:
00605 void setEncryption( bool encrypt, bool setByUser = false );
00606
00611 void setSigning( bool sign, bool setByUser = false );
00612
00616 bool userForgotAttachment();
00617
00622 bool encryptFlagOfAttachment(int idx);
00623
00628 bool signFlagOfAttachment(int idx);
00629
00630
00638 static void decryptOrStripOffCleartextSignature( QCString& );
00639
00643 bool saveDraftOrTemplate( const QString &folderName, KMMessage *msg );
00644
00648 enum SaveIn { None, Drafts, Templates };
00649 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
00650 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
00651
00655 int autoSaveInterval() const;
00656
00660 void initAutoSave();
00661
00666 void updateAutoSave();
00667
00671 void cleanupAutoSave();
00672
00678 static bool validateAddresses( QWidget * parent, const QString & addresses );
00679
00686 void setTransport( const QString & transport );
00687
00692 void insertSignature( bool append = true, int pos = 0 );
00693 private slots:
00697 void compressAttach(int idx);
00698 void uncompressAttach(int idx);
00699 void editorFocusChanged(bool gained);
00700
00701 private:
00702 QWidget *mMainWidget;
00703 QComboBox *mTransport;
00704 KMail::DictionaryComboBox *mDictionaryCombo;
00705 KPIM::IdentityCombo *mIdentity;
00706 KMFolderComboBox *mFcc;
00707 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00708 KMLineEditSpell *mEdtSubject;
00709 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00710 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00711 QLabel *mDictionaryLabel;
00712 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00713 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00714 bool mSpellCheckInProgress;
00715 bool mDone;
00716 bool mAtmModified;
00717
00718 KMEdit* mEditor;
00719 QGridLayout* mGrid;
00720 KMMessage *mMsg;
00721 QValueVector<KMMessage*> mComposedMessages;
00722 KMail::AttachmentListView* mAtmListView;
00723 int mAtmColEncrypt;
00724 int mAtmColSign;
00725 int mAtmColCompress;
00726 int mAtmEncryptColWidth;
00727 int mAtmSignColWidth;
00728 int mAtmCompressColWidth;
00729 QPtrList<QListViewItem> mAtmItemList;
00730 QPtrList<KMMessagePart> mAtmList;
00731 QPopupMenu *mAttachMenu;
00732 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
00733 bool mAutoDeleteMsg;
00734 bool mSigningAndEncryptionExplicitlyDisabled;
00735 bool mLastSignActionState, mLastEncryptActionState;
00736 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00737 KMFolder *mFolder;
00738 long mShowHeaders;
00739 bool mConfirmSend;
00740 bool mDisableBreaking;
00741 int mNumHeaders;
00742 bool mUseHTMLEditor;
00743 bool mHtmlMarkup;
00744 QFont mBodyFont, mFixedFont;
00745 QPtrList<KTempFile> mAtmTempList;
00746 QPalette mPalette;
00747 uint mId;
00748 QString mOldSigText;
00749
00750 KAction *mAttachPK, *mAttachMPK,
00751 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00752 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00753 KRecentFilesAction *mRecentAction;
00754
00755 KAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
00756
00757 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00758 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00759 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00760 KToggleAction *mSubjectAction;
00761 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00762 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00763 KToggleAction *mDictionaryAction, *mSnippetAction;
00764
00765 KSelectAction *listAction;
00766 KFontAction *fontAction;
00767 KFontSizeAction *fontSizeAction;
00768 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00769 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00770 KToggleAction *plainTextAction, *markupAction;
00771 KAction *actionFormatColor, *actionFormatReset;
00772 KAction *mHtmlToolbar;
00773
00774 KSelectAction *mEncodingAction;
00775 KSelectAction *mCryptoModuleAction;
00776
00777 QCString mCharset;
00778 QCString mDefCharset;
00779 QStringList mCharsets;
00780 bool mAutoCharset;
00781
00782 bool mAlwaysSend;
00783
00784 QStringList mFolderNames;
00785 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00786 QMap<KIO::Job*, KURL> mAttachJobs;
00787 KURL::List mAttachFilesPending;
00788 int mAttachFilesSend;
00789
00790 private:
00791
00792 void startPublicKeyExport();
00793 bool canSignEncryptAttachments() const {
00794 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00795 }
00796
00797 bool mSubjectTextWasSpellChecked;
00798
00799 QString addQuotesToText( const QString &inputText );
00800 QString removeQuotesFromText( const QString &inputText );
00801
00802 int calcColumnWidth(int which, long allShowing, int width);
00803
00804 private slots:
00805 void slotCompletionModeChanged( KGlobalSettings::Completion );
00806 void slotConfigChanged();
00807
00808 void slotComposerDone( bool );
00809
00810 void slotContinueDoSend( bool );
00811 void slotContinuePrint( bool );
00812 void slotContinueAutoSave( bool );
00813
00814 void slotEncryptChiasmusToggled( bool );
00815
00820 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00821
00825 void slotAutoSpellCheckingToggled(bool);
00826
00830 void slotUpdateSignatureActions();
00831
00835 void slotUpdateSignatureAndEncrypionStateIndicators();
00836 private:
00837 QColor mForeColor,mBackColor;
00838 QFont mSaveFont;
00839 QSplitter *mSplitter;
00840 QSplitter *mSnippetSplitter;
00841 struct atmLoadData
00842 {
00843 KURL url;
00844 QByteArray data;
00845 bool insert;
00846 QCString encoding;
00847 };
00848 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00849
00850
00851 KMail::MessageSender::SendMethod mSendMethod;
00852 KMComposeWin::SaveIn mSaveIn;
00853
00854 KToggleAction *mEncryptChiasmusAction;
00855 bool mEncryptWithChiasmus;
00856
00857
00858
00859 MessageComposer* mComposer;
00860
00861
00862 bool mMessageWasModified;
00863
00864
00865 QString mFingerprint;
00866
00867
00868 KTempDir *mTempDir;
00869
00870 bool mClassicalRecipients;
00871
00872 RecipientsEditor *mRecipientsEditor;
00873 int mLabelWidth;
00874
00875 QTimer *mAutoSaveTimer;
00876 QString mAutoSaveFilename;
00877 int mLastAutoSaveErrno;
00878
00879 QPopupMenu *mActNowMenu;
00880 QPopupMenu *mActLaterMenu;
00881
00882 QMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
00883 QMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
00884
00885 QLabel *mSignatureStateIndicator;
00886 QLabel *mEncryptionStateIndicator;
00887
00888 SnippetWidget *mSnippetWidget;
00889 };
00890
00891 #endif
00892