kmail

kmcomposewin.h

00001 /* -*- mode: C++; c-file-style: "gnu" -*-
00002  * KMComposeWin Header File
00003  * Author: Markus Wuebben <markus.wuebben@kde.org>
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: // mailserviceimpl, kmkernel, kmcommands, callback, kmmainwidget
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: // mailserviceimpl
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 &paramAttr,
00121                     const QString &paramValue,
00122                     const QCString &contDisp);
00123 public: // kmcommand
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: // kmkernel, kmcommands, callback
00153    void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE,
00154            bool allowDecryption=FALSE, bool isModified=FALSE);
00155 
00156 private: // kmedit
00161    KMMessage* msg() const { return mMsg; }
00162 
00163 public: // kmkernel
00167   void setAutoSaveFilename( const QString & filename );
00168 
00169 private:
00173   bool isModified() const;
00174 
00178   void setModified( bool modified );
00179 
00180 public: // kmkernel, callback
00185    inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; }
00186 
00191   void setAutoDeleteWindow( bool f );
00192 
00193 public: // kmcommand
00198    void setFolder(KMFolder* aFolder) { mFolder = aFolder; }
00199 public: // kmkernel, kmcommand, mailserviceimpl
00203    void setCharset(const QCString& aCharset, bool forceDefault = FALSE);
00204 
00205 public: // kmcommand
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: // kmedit:
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: // callback
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: // kmkernel, callback
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: // kmkernel
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: // kmkernel, callback
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   void slotAttachOpenWith();
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 //  void slotSpellConfigure();
00418   void slotSpellcheckDone(int result);
00419   void slotSpellcheckDoneClearStatus();
00420 
00421 public slots: // kmkernel
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: // kmkernel, attachmentlistview
00455   void addAttach(const KURL url);
00456 
00457 public: // kmcommand
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, bool with );
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 
00658   void setTransport( const QString & transport );
00659 
00660 private slots:
00664     void compressAttach(int idx);
00665     void uncompressAttach(int idx);
00666     void editorFocusChanged(bool gained);
00667 
00668 private:
00669   QWidget   *mMainWidget;
00670   QComboBox *mTransport;
00671   KMail::DictionaryComboBox *mDictionaryCombo;
00672   KPIM::IdentityCombo    *mIdentity;
00673   KMFolderComboBox *mFcc;
00674   KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00675   KMLineEditSpell *mEdtSubject;
00676   QLabel    *mLblIdentity, *mLblTransport, *mLblFcc;
00677   QLabel    *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00678   QLabel    *mDictionaryLabel;
00679   QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00680   QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo;
00681   bool mSpellCheckInProgress;
00682   bool mDone;
00683   bool mAtmModified;
00684 
00685   KMEdit* mEditor;
00686   QGridLayout* mGrid;
00687   KMMessage *mMsg;
00688   QValueVector<KMMessage*> mComposedMessages;
00689   KMail::AttachmentListView* mAtmListView;
00690   int mAtmColEncrypt;
00691   int mAtmColSign;
00692   int mAtmColCompress;
00693   int mAtmEncryptColWidth;
00694   int mAtmSignColWidth;
00695   int mAtmCompressColWidth;
00696   QPtrList<QListViewItem> mAtmItemList;
00697   QPtrList<KMMessagePart> mAtmList;
00698   QPopupMenu *mAttachMenu;
00699   int mOpenId, mOpenWithId, mViewId, mRemoveId, mSaveAsId, mPropertiesId;
00700   bool mAutoDeleteMsg;
00701   bool mSigningAndEncryptionExplicitlyDisabled;
00702   bool mLastSignActionState, mLastEncryptActionState;
00703   bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00704   KMFolder *mFolder;
00705   long mShowHeaders;
00706   bool mConfirmSend;
00707   bool mDisableBreaking; // Move
00708   int mNumHeaders;
00709   bool mUseHTMLEditor;
00710   bool mHtmlMarkup;
00711   QFont mBodyFont, mFixedFont;
00712   QPtrList<KTempFile> mAtmTempList;
00713   QPalette mPalette;
00714   uint mId;
00715   QString mOldSigText;
00716 
00717   KAction *mAttachPK, *mAttachMPK,
00718           *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00719           *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00720   KRecentFilesAction *mRecentAction;
00721 
00722   KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00723   KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00724   KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00725   KToggleAction *mSubjectAction;
00726   KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00727   KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00728   KToggleAction *mDictionaryAction;
00729 
00730   KSelectAction *listAction;
00731   KFontAction *fontAction;
00732   KFontSizeAction *fontSizeAction;
00733   KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00734   KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00735   KToggleAction *plainTextAction, *markupAction;
00736   KAction *actionFormatColor, *actionFormatReset;
00737   KAction *mHtmlToolbar;
00738 
00739   KSelectAction *mEncodingAction;
00740   KSelectAction *mCryptoModuleAction;
00741 
00742   QCString mCharset;
00743   QCString mDefCharset;
00744   QStringList mCharsets;
00745   bool mAutoCharset;
00746 
00747   bool mAlwaysSend;
00748 
00749   QStringList mFolderNames;
00750   QValueList<QGuardedPtr<KMFolder> > mFolderList;
00751 
00752 private:
00753   // helper method for slotInsert(My)PublicKey()
00754   void startPublicKeyExport();
00755   bool canSignEncryptAttachments() const {
00756     return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00757   }
00758 
00759   bool mSubjectTextWasSpellChecked;
00760 
00761   QString addQuotesToText( const QString &inputText );
00762   QString removeQuotesFromText( const QString &inputText );
00763   // helper method for rethinkFields
00764   int calcColumnWidth(int which, long allShowing, int width);
00765 
00766 private slots:
00767   void slotCompletionModeChanged( KGlobalSettings::Completion );
00768   void slotConfigChanged();
00769 
00770   void slotComposerDone( bool );
00771 
00772   void slotContinueDoSend( bool );
00773   void slotContinuePrint( bool );
00774   void slotContinueAutoSave( bool );
00775 
00776   void slotEncryptChiasmusToggled( bool );
00777 
00782   void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00783 
00787   void slotAutoSpellCheckingToggled(bool);
00788 
00789 private:
00790   QColor mForeColor,mBackColor;
00791   QFont mSaveFont;
00792   QSplitter *mSplitter;
00793   struct atmLoadData
00794   {
00795     KURL url;
00796     QByteArray data;
00797     bool insert;
00798     QCString encoding;
00799   };
00800   QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00801 
00802   // These are for passing on methods over the applyChanges calls
00803   KMail::MessageSender::SendMethod mSendMethod;
00804   bool mSaveInDrafts;
00805 
00806   KToggleAction *mEncryptChiasmusAction;
00807   bool mEncryptWithChiasmus;
00808 
00809   // This is the temporary object that constructs the message out of the
00810   // window
00811   MessageComposer* mComposer;
00812 
00813   // Temp var for slotPrint:
00814   bool mMessageWasModified;
00815 
00816   // Temp var for slotInsert(My)PublicKey():
00817   QString mFingerprint;
00818 
00819   // Temp ptr for saving image from clipboard
00820   KTempDir *mTempDir;
00821 
00822   bool mClassicalRecipients;
00823 
00824   RecipientsEditor *mRecipientsEditor;
00825   int mLabelWidth;
00826 
00827   QTimer *mAutoSaveTimer;
00828   QString mAutoSaveFilename;
00829   int mLastAutoSaveErrno; // holds the errno of the last try to autosave
00830 
00831   QPopupMenu *mActNowMenu;
00832   QPopupMenu *mActLaterMenu;
00833 };
00834 
00835 #endif
00836 
KDE Home | KDE Accessibility Home | Description of Access Keys