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
00166 bool isComposing() const { return mComposer != 0; }
00167
00168 private:
00173 KMMessage* msg() const { return mMsg; }
00174
00175 public:
00179 void setAutoSaveFilename( const QString & filename );
00180
00181 private:
00185 bool isModified() const;
00186
00190 void setModified( bool modified );
00191
00192 public:
00197 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00198
00203 void setAutoDeleteWindow( bool f );
00204
00205 public:
00210 void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00211 public:
00215 void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00216
00217 public:
00223 void setReplyFocus( bool hasMessage = true );
00224
00229 void setFocusToSubject();
00230
00231 private:
00235 bool inlineSigningEncryptionSelected();
00236
00242 static QString prettyMimeType( const QString& type );
00243 QString quotePrefixName() const;
00244
00245 private:
00246 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;}
00247 void setSubjectTextWasSpellChecked( bool _spell ) {
00248 mSubjectTextWasSpellChecked = _spell;
00249 }
00250 bool subjectTextWasSpellChecked() const { return mSubjectTextWasSpellChecked; }
00251
00252 void paste( QClipboard::Mode mode );
00253
00254 public:
00256 void setSigningAndEncryptionDisabled( bool v )
00257 {
00258 mSigningAndEncryptionExplicitlyDisabled = v;
00259 }
00260
00261 private slots:
00262 void polish();
00266 void slotPrint();
00267 void slotAttachFile();
00268 void slotInsertRecentFile(const KURL&);
00269 void slotAttachedFile(const KURL&);
00270 public slots:
00271 void slotSendNow();
00272 private slots:
00273 void slotSendNowVia( int item );
00274 void slotSendLater();
00275 void slotSendLaterVia( int item );
00276
00277 void getTransportMenu();
00278
00282 void slotSaveDraft();
00283 void slotSaveTemplate();
00284 void slotNewComposer();
00285 void slotNewMailReader();
00286 void slotClose();
00287 void slotHelp();
00288
00289 void slotFind();
00290 void slotSearchAgain();
00291 void slotReplace();
00292 void slotUndo();
00293 void slotRedo();
00294 void slotCut();
00295 void slotCopy();
00296 void slotPasteClipboard();
00297 void slotPasteClipboardAsQuotation();
00298 void slotPasteClipboardAsAttachment();
00299 void slotAddQuotes();
00300 void slotRemoveQuotes();
00301 void slotAttachPNGImageData(const QByteArray &image);
00302
00303 void slotMarkAll();
00304
00305 void slotFolderRemoved(KMFolder*);
00306
00307 void slotEditDone( KMail::EditorWatcher* watcher );
00308
00309 public slots:
00316 void slotSetAlwaysSend( bool bAlwaysSend );
00317 private slots:
00321 void slotUpdateFont();
00322
00326 void slotAddrBook();
00330 void slotInsertFile();
00331
00332 void slotSetCharset();
00336 void slotSpellcheck();
00337 void slotSpellcheckConfig();
00338 void slotSubjectTextSpellChecked();
00339
00344 void slotSelectCryptoModule( bool init = false );
00345
00349 void slotStatusMessage(const QString &message);
00350 void slotEditToolbars();
00351 void slotUpdateToolbars();
00352 void slotEditKeys();
00356 void readConfig( bool reload = false );
00360 void slotUpdWinTitle(const QString& );
00361
00366 void slotEncryptToggled(bool);
00367
00371 void slotSignToggled(bool);
00372
00373 public slots:
00377 void slotWordWrapToggled(bool);
00378
00379 private slots:
00383 void slotAppendSignature();
00384
00388 void slotPrependSignature();
00389
00393 void slotInsertSignatureAtCursor();
00394
00398 void slotInsertMyPublicKey();
00399
00403 void slotInsertPublicKey();
00404
00408 void slotUpdateAttachActions();
00409
00413 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int);
00414
00419 int currentAttachmentNum();
00420
00424 void slotAttachOpen();
00425 void slotAttachView();
00426 void slotAttachRemove();
00427 void slotAttachSave();
00428 void slotAttachProperties();
00429 void slotAttachOpenWith();
00430 void slotAttachEdit();
00431 void slotAttachEditWith();
00432 void slotAttachmentDragStarted();
00433
00438 void slotAddrBookTo();
00439 void slotAddrBookFrom();
00440 void slotAddrBookReplyTo();
00441
00442 void slotCleanSpace();
00443
00444 void slotToggleMarkup();
00445 void toggleMarkup(bool markup);
00446 void htmlToolBarVisibilityChanged( bool visible );
00447
00448
00449 void slotSpellcheckDone(int result);
00450 void slotSpellcheckDoneClearStatus();
00451
00452 public slots:
00453 void autoSaveMessage();
00454
00455 private slots:
00456 void updateCursorPosition();
00457
00458 void slotView();
00459
00463 void slotIdentityChanged(uint);
00464
00468 void slotAttachFileData(KIO::Job *, const QByteArray &);
00469 void slotAttachFileResult(KIO::Job *);
00470
00471 void slotListAction(const QString &);
00472 void slotFontAction(const QString &);
00473 void slotSizeAction(int);
00474 void slotAlignLeft();
00475 void slotAlignCenter();
00476 void slotAlignRight();
00477 void slotTextBold();
00478 void slotTextItalic();
00479 void slotTextUnder();
00480 void slotFormatReset();
00481 void slotTextColor();
00482 void fontChanged( const QFont & );
00483 void alignmentChanged( int );
00484
00485 public:
00486 bool addAttach(const KURL url);
00487
00488 public:
00492 void addAttach(const KMMessagePart* msgPart);
00493
00494 private:
00495 const KPIM::Identity & identity() const;
00496 uint identityUid() const;
00497 Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00498 bool encryptToSelf() const;
00499
00500 signals:
00501 void applyChangesDone( bool );
00502 void attachmentAdded( const KURL&, bool success );
00503
00504 private:
00512 void applyChanges( bool dontSignNorEncrypt, bool dontDisable=false );
00513
00519 void rethinkFields(bool fromslot=false);
00520
00524 QWidget *connectFocusMoving( QWidget *prev, QWidget *next );
00525
00530 void rethinkHeaderLine( int aValue, int aMask, int& aRow,
00531 const QString &aLabelStr, QLabel* aLbl,
00532 QLineEdit* aEdt, QPushButton* aBtn = 0,
00533 const QString &toolTip = QString::null,
00534 const QString &whatsThis = QString::null );
00535
00536 void rethinkHeaderLine( int value, int mask, int& row,
00537 const QString& labelStr, QLabel* lbl,
00538 QComboBox* cbx, QCheckBox *chk );
00539
00544 bool checkRecipientNumber() const;
00545
00546
00547 bool checkTransport() const;
00548
00552 void setupActions();
00553 void setupStatusBar();
00554 void setupEditor();
00555
00556
00560 QString subject() const;
00561 QString to() const;
00562 QString cc() const;
00563 QString bcc() const;
00564 QString from() const;
00565 QString replyTo() const;
00566
00572 void setFcc( const QString &idString );
00573
00577 virtual bool queryClose ();
00581 virtual bool queryExit ();
00582
00586 void openAttach( int index, bool with );
00587
00591 void viewAttach( int index );
00592
00596 void editAttach( int index, bool openWith );
00597
00601 void removeAttach(const QString &url);
00602 void removeAttach(int idx);
00603
00607 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi,
00608 bool loadDefaults = true );
00609
00614 void addrBookSelInto();
00615
00616 void addrBookSelIntoOld();
00617 void addrBookSelIntoNew();
00618
00619 private:
00624 void setEncryption( bool encrypt, bool setByUser = false );
00625
00630 void setSigning( bool sign, bool setByUser = false );
00631
00635 bool userForgotAttachment();
00636
00641 bool encryptFlagOfAttachment(int idx);
00642
00647 bool signFlagOfAttachment(int idx);
00648
00649
00657 static void decryptOrStripOffCleartextSignature( QCString& );
00658
00662 bool saveDraftOrTemplate( const QString &folderName, KMMessage *msg );
00663
00667 enum SaveIn { None, Drafts, Templates };
00668 void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault,
00669 KMComposeWin::SaveIn saveIn = KMComposeWin::None );
00670
00674 int autoSaveInterval() const;
00675
00679 void initAutoSave();
00680
00685 void updateAutoSave();
00686
00690 void cleanupAutoSave();
00691
00697 static bool validateAddresses( QWidget * parent, const QString & addresses );
00698
00705 void setTransport( const QString & transport );
00706
00711 void insertSignature( bool append = true, int pos = 0 );
00712 private slots:
00716 void compressAttach(int idx);
00717 void uncompressAttach(int idx);
00718 void editorFocusChanged(bool gained);
00719 void recipientEditorSizeHintChanged();
00720 void setMaximumHeaderSize();
00721
00722 private:
00723 QWidget *mMainWidget;
00724 QComboBox *mTransport;
00725 KMail::DictionaryComboBox *mDictionaryCombo;
00726 KPIM::IdentityCombo *mIdentity;
00727 KMFolderComboBox *mFcc;
00728 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00729 KMLineEditSpell *mEdtSubject;
00730 QLabel *mLblIdentity, *mLblTransport, *mLblFcc;
00731 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00732 QLabel *mDictionaryLabel;
00733 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00734 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, *mBtnReplyTo;
00735 bool mSpellCheckInProgress;
00736 bool mDone;
00737 bool mAtmModified;
00738
00739 KMEdit* mEditor;
00740 QGridLayout* mGrid;
00741 KMMessage *mMsg;
00742 QValueVector<KMMessage*> mComposedMessages;
00743 KMail::AttachmentListView* mAtmListView;
00744 int mAtmColEncrypt;
00745 int mAtmColSign;
00746 int mAtmColCompress;
00747 int mAtmEncryptColWidth;
00748 int mAtmSignColWidth;
00749 int mAtmCompressColWidth;
00750 QPtrList<QListViewItem> mAtmItemList;
00751 QPtrList<KMMessagePart> mAtmList;
00752 QPopupMenu *mAttachMenu;
00753 int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId, mEditId, mEditWithId;
00754 bool mAutoDeleteMsg;
00755 bool mSigningAndEncryptionExplicitlyDisabled;
00756 bool mLastSignActionState, mLastEncryptActionState;
00757 bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00758 KMFolder *mFolder;
00759 long mShowHeaders;
00760 bool mConfirmSend;
00761 bool mDisableBreaking;
00762 int mNumHeaders;
00763 bool mUseHTMLEditor;
00764 bool mHtmlMarkup;
00765 QFont mBodyFont, mFixedFont;
00766 QPtrList<KTempFile> mAtmTempList;
00767 QPalette mPalette;
00768 uint mId;
00769 QString mOldSigText;
00770
00771 KAction *mAttachPK, *mAttachMPK,
00772 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00773 *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00774 KRecentFilesAction *mRecentAction;
00775
00776 KAction *mAppendSignatureAction, *mPrependSignatureAction, *mInsertSignatureAction;
00777
00778 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00779 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00780 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00781 KToggleAction *mSubjectAction;
00782 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00783 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00784 KToggleAction *mDictionaryAction, *mSnippetAction;
00785
00786 KSelectAction *listAction;
00787 KFontAction *fontAction;
00788 KFontSizeAction *fontSizeAction;
00789 KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00790 KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00791 KToggleAction *plainTextAction, *markupAction;
00792 KAction *actionFormatColor, *actionFormatReset;
00793 KAction *mHtmlToolbar;
00794
00795 KSelectAction *mEncodingAction;
00796 KSelectAction *mCryptoModuleAction;
00797
00798 QCString mCharset;
00799 QCString mDefCharset;
00800 QStringList mCharsets;
00801 bool mAutoCharset;
00802
00803 bool mAlwaysSend;
00804
00805 QStringList mFolderNames;
00806 QValueList<QGuardedPtr<KMFolder> > mFolderList;
00807 QMap<KIO::Job*, KURL> mAttachJobs;
00808 KURL::List mAttachFilesPending;
00809 int mAttachFilesSend;
00810
00811 private:
00812
00813 void startPublicKeyExport();
00814 bool canSignEncryptAttachments() const {
00815 return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00816 }
00817
00818 bool mSubjectTextWasSpellChecked;
00819
00820 QString addQuotesToText( const QString &inputText );
00821 QString removeQuotesFromText( const QString &inputText );
00822
00823 int calcColumnWidth(int which, long allShowing, int width);
00824
00825 private slots:
00826 void slotCompletionModeChanged( KGlobalSettings::Completion );
00827 void slotConfigChanged();
00828
00829 void slotComposerDone( bool );
00830
00831 void slotContinueDoSend( bool );
00832 void slotContinuePrint( bool );
00833 void slotContinueAutoSave();
00834
00835 void slotEncryptChiasmusToggled( bool );
00836
00841 void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00842
00846 void slotAutoSpellCheckingToggled(bool);
00847
00851 void slotUpdateSignatureActions();
00852
00856 void slotUpdateSignatureAndEncrypionStateIndicators();
00857 private:
00858 QColor mForeColor,mBackColor;
00859 QFont mSaveFont;
00860 QSplitter *mHeadersToEditorSplitter;
00861 QWidget* mHeadersArea;
00862 QSplitter *mSplitter;
00863 QSplitter *mSnippetSplitter;
00864 struct atmLoadData
00865 {
00866 KURL url;
00867 QByteArray data;
00868 bool insert;
00869 QCString encoding;
00870 };
00871 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00872
00873
00874 KMail::MessageSender::SendMethod mSendMethod;
00875 KMComposeWin::SaveIn mSaveIn;
00876
00877 KToggleAction *mEncryptChiasmusAction;
00878 bool mEncryptWithChiasmus;
00879
00880
00881
00882 MessageComposer* mComposer;
00883
00884
00885 bool mMessageWasModified;
00886
00887
00888 QString mFingerprint;
00889
00890
00891 KTempDir *mTempDir;
00892
00893 bool mClassicalRecipients;
00894
00895 RecipientsEditor *mRecipientsEditor;
00896 int mLabelWidth;
00897
00898 QTimer *mAutoSaveTimer;
00899 QString mAutoSaveFilename;
00900 int mLastAutoSaveErrno;
00901
00902 QPopupMenu *mActNowMenu;
00903 QPopupMenu *mActLaterMenu;
00904
00905 QMap<KMail::EditorWatcher*, KMMessagePart*> mEditorMap;
00906 QMap<KMail::EditorWatcher*, KTempFile*> mEditorTempFiles;
00907
00908 QLabel *mSignatureStateIndicator;
00909 QLabel *mEncryptionStateIndicator;
00910
00911 SnippetWidget *mSnippetWidget;
00912 std::set<KTempDir*> mTempDirs;
00913
00921 bool mPreserveUserCursorPosition;
00922
00923 bool mPreventFccOverwrite;
00924 };
00925
00926 #endif
00927