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 
00402 
00407   void slotAddrBookTo();
00408   void slotAddrBookFrom();
00409   void slotAddrBookReplyTo();
00410 
00411   void slotCleanSpace();
00412 
00413   void slotToggleMarkup();
00414   void toggleMarkup(bool markup);
00415 
00416 //  void slotSpellConfigure();
00417   void slotSpellcheckDone(int result);
00418   void slotSpellcheckDoneClearStatus();
00419 
00420 public slots: // kmkernel
00421   void autoSaveMessage();
00422 
00423 private slots:
00424   void updateCursorPosition();
00425 
00426   void slotView();
00427 
00431   void slotIdentityChanged(uint);
00432 
00436   void slotAttachFileData(KIO::Job *, const QByteArray &);
00437   void slotAttachFileResult(KIO::Job *);
00438 
00439   void slotListAction(const QString &);
00440   void slotFontAction(const QString &);
00441   void slotSizeAction(int);
00442   void slotAlignLeft();
00443   void slotAlignCenter();
00444   void slotAlignRight();
00445   void slotTextBold();
00446   void slotTextItalic();
00447   void slotTextUnder();
00448   void slotFormatReset();
00449   void slotTextColor();
00450   void fontChanged( const QFont & );
00451   void alignmentChanged( int );
00452 
00453 public: // kmkernel, attachmentlistview
00454   void addAttach(const KURL url);
00455 
00456 public: // kmcommand
00460   void addAttach(const KMMessagePart* msgPart);
00461 
00462 private:
00466   void addImageFromClipboard();
00467 
00468 private:
00469   const KPIM::Identity & identity() const;
00470   uint identityUid() const;
00471   Kleo::CryptoMessageFormat cryptoMessageFormat() const;
00472   bool encryptToSelf() const;
00473 
00474 signals:
00475   void applyChangesDone( bool );
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 );
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   void doSend( KMail::MessageSender::SendMethod method=KMail::MessageSender::SendDefault, bool saveInDrafts = false);
00622 
00626   int autoSaveInterval() const;
00627 
00631   void initAutoSave();
00632 
00637   void updateAutoSave();
00638 
00642   void cleanupAutoSave();
00643 
00649   static bool validateAddresses( QWidget * parent, const QString & addresses );
00650 
00651 private slots:
00655     void compressAttach(int idx);
00656     void uncompressAttach(int idx);
00657     void editorFocusChanged(bool gained);
00658 
00659 private:
00660   QWidget   *mMainWidget;
00661   QComboBox *mTransport;
00662   KMail::DictionaryComboBox *mDictionaryCombo;
00663   KPIM::IdentityCombo    *mIdentity;
00664   KMFolderComboBox *mFcc;
00665   KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc;
00666   KMLineEditSpell *mEdtSubject;
00667   QLabel    *mLblIdentity, *mLblTransport, *mLblFcc;
00668   QLabel    *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject;
00669   QLabel    *mDictionaryLabel;
00670   QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc;
00671   QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo;
00672   bool mSpellCheckInProgress;
00673   bool mDone;
00674   bool mAtmModified;
00675 
00676   KMEdit* mEditor;
00677   QGridLayout* mGrid;
00678   KMMessage *mMsg;
00679   QValueVector<KMMessage*> mComposedMessages;
00680   KMail::AttachmentListView* mAtmListView;
00681   int mAtmColEncrypt;
00682   int mAtmColSign;
00683   int mAtmColCompress;
00684   int mAtmEncryptColWidth;
00685   int mAtmSignColWidth;
00686   int mAtmCompressColWidth;
00687   QPtrList<QListViewItem> mAtmItemList;
00688   QPtrList<KMMessagePart> mAtmList;
00689   QPopupMenu *mAttachMenu;
00690   int mOpenId, mViewId, mRemoveId, mSaveAsId, mPropertiesId;
00691   bool mAutoDeleteMsg;
00692   bool mSigningAndEncryptionExplicitlyDisabled;
00693   bool mLastSignActionState, mLastEncryptActionState;
00694   bool mLastIdentityHasSigningKey, mLastIdentityHasEncryptionKey;
00695   KMFolder *mFolder;
00696   long mShowHeaders;
00697   bool mConfirmSend;
00698   bool mDisableBreaking; // Move
00699   int mNumHeaders;
00700   bool mUseHTMLEditor;
00701   bool mHtmlMarkup;
00702   QFont mBodyFont, mFixedFont;
00703   QPtrList<KTempFile> mAtmTempList;
00704   QPalette mPalette;
00705   uint mId;
00706   QString mOldSigText;
00707 
00708   KAction *mAttachPK, *mAttachMPK,
00709           *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction,
00710           *mPasteQuotation, *mAddQuoteChars, *mRemQuoteChars;
00711   KRecentFilesAction *mRecentAction;
00712 
00713   KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction;
00714   KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction;
00715   KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction;
00716   KToggleAction *mSubjectAction;
00717   KToggleAction *mIdentityAction, *mTransportAction, *mFccAction;
00718   KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction;
00719   KToggleAction *mDictionaryAction;
00720 
00721   KSelectAction *listAction;
00722   KFontAction *fontAction;
00723   KFontSizeAction *fontSizeAction;
00724   KToggleAction *alignLeftAction, *alignCenterAction, *alignRightAction;
00725   KToggleAction *textBoldAction, *textItalicAction, *textUnderAction;
00726   KToggleAction *plainTextAction, *markupAction;
00727   KAction *actionFormatColor, *actionFormatReset;
00728   KAction *mHtmlToolbar;
00729 
00730   KSelectAction *mEncodingAction;
00731   KSelectAction *mCryptoModuleAction;
00732 
00733   QCString mCharset;
00734   QCString mDefCharset;
00735   QStringList mCharsets;
00736   bool mAutoCharset;
00737 
00738   bool mAlwaysSend;
00739 
00740   QStringList mFolderNames;
00741   QValueList<QGuardedPtr<KMFolder> > mFolderList;
00742 
00743 private:
00744   // helper method for slotInsert(My)PublicKey()
00745   void startPublicKeyExport();
00746   bool canSignEncryptAttachments() const {
00747     return cryptoMessageFormat() != Kleo::InlineOpenPGPFormat;
00748   }
00749 
00750   bool mSubjectTextWasSpellChecked;
00751 
00752   QString addQuotesToText(const QString &inputText);
00753   // helper method for rethinkFields
00754   int calcColumnWidth(int which, long allShowing, int width);
00755 
00756 private slots:
00757   void slotCompletionModeChanged( KGlobalSettings::Completion );
00758   void slotConfigChanged();
00759 
00760   void slotComposerDone( bool );
00761 
00762   void slotContinueDoSend( bool );
00763   void slotContinuePrint( bool );
00764   void slotContinueAutoSave( bool );
00765   
00766   void slotEncryptChiasmusToggled( bool );
00767 
00772   void slotPublicKeyExportResult( const GpgME::Error & err, const QByteArray & keydata );
00773 
00777   void slotAutoSpellCheckingToggled(bool);
00778 
00779 private:
00780   QColor mForeColor,mBackColor;
00781   QFont mSaveFont;
00782   QSplitter *mSplitter;
00783   struct atmLoadData
00784   {
00785     KURL url;
00786     QByteArray data;
00787     bool insert;
00788     QCString encoding;
00789   };
00790   QMap<KIO::Job *, atmLoadData> mMapAtmLoadData;
00791 
00792   // These are for passing on methods over the applyChanges calls
00793   KMail::MessageSender::SendMethod mSendMethod;
00794   bool mSaveInDrafts;
00795 
00796   KToggleAction *mEncryptChiasmusAction;
00797   bool mEncryptWithChiasmus;
00798 
00799   // This is the temporary object that constructs the message out of the
00800   // window
00801   MessageComposer* mComposer;
00802 
00803   // Temp var for slotPrint:
00804   bool mMessageWasModified;
00805 
00806   // Temp var for slotInsert(My)PublicKey():
00807   QString mFingerprint;
00808 
00809   // Temp ptr for saving image from clipboard
00810   KTempDir *mTempDir;
00811 
00812   bool mClassicalRecipients;
00813 
00814   RecipientsEditor *mRecipientsEditor;
00815   int mLabelWidth;
00816 
00817   QTimer *mAutoSaveTimer;
00818   QString mAutoSaveFilename;
00819   int mLastAutoSaveErrno; // holds the errno of the last try to autosave
00820 
00821   QPopupMenu *mActNowMenu;
00822   QPopupMenu *mActLaterMenu;
00823 };
00824 
00825 #endif
00826 
KDE Home | KDE Accessibility Home | Description of Access Keys