kmail Library API Documentation

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 #include "kmtopwidget.h" 00009 00010 #include <qlabel.h> 00011 #include <qlistview.h> 00012 00013 #include <qcheckbox.h> 00014 #include <qpushbutton.h> 00015 #include <qclipboard.h> 00016 #include <qpalette.h> 00017 #include <qfont.h> 00018 #include <qptrlist.h> 00019 00020 #include <klineedit.h> 00021 #include <kio/job.h> 00022 #include <kglobalsettings.h> 00023 #include <kdeversion.h> 00024 #include <keditcl.h> 00025 00026 #include <kpgp.h> 00027 00028 #include "kmmsgpart.h" 00029 #include "kmmsgbase.h" 00030 #include "mailcomposerIface.h" 00031 00032 #include "cryptplugwrapper.h" 00033 #include <kabc/addresslineedit.h> 00034 00035 class _StringPair { 00036 public: 00037 QString name; 00038 QString value; 00039 }; 00040 00041 class QCloseEvent; 00042 class QComboBox; 00043 class QFrame; 00044 class QGridLayout; 00045 class QLineEdit; 00046 class QListView; 00047 class QPopupMenu; 00048 class QPushButton; 00049 class QCString; 00050 class KCompletion; 00051 class KEdit; 00052 class KMComposeWin; 00053 class KMFolderComboBox; 00054 class KMMessage; 00055 class KProcess; 00056 class KDirWatch; 00057 class KSelectAction; 00058 class KSpell; 00059 class KSpellConfig; 00060 class KDictSpellingHighlighter; 00061 class KStatusBar; 00062 class KAction; 00063 class KToggleAction; 00064 class KTempFile; 00065 class KToolBar; 00066 class KToggleAction; 00067 class KURL; 00068 class IdentityCombo; 00069 class SpellingFilter; 00070 class CryptPlugWrapperList; 00071 00072 namespace KMail { 00073 class AttachmentListView; 00074 class DictionaryComboBox; 00075 } 00076 00077 typedef QPtrList<KMMessagePart> KMMsgPartList; 00078 00079 00080 //----------------------------------------------------------------------------- 00081 class KMEdit: public KEdit 00082 { 00083 Q_OBJECT 00084 public: 00085 KMEdit(QWidget *parent=0,KMComposeWin* composer=0, 00086 KSpellConfig* spellConfig = 0, 00087 const char *name=0); 00088 virtual ~KMEdit(); 00089 00093 void spellcheck(); 00094 00098 QString brokenText(); 00099 00103 void setUseExternalEditor( bool use ) { mUseExtEditor = use; } 00104 void setExternalEditorPath( const QString & path ) { mExtEditor = path; } 00105 00112 bool checkExternalEditorFinished(); 00113 00114 00116 void contentsDragEnterEvent(QDragEnterEvent *e); 00117 void contentsDragMoveEvent(QDragMoveEvent *e); 00118 void contentsDropEvent(QDropEvent *e); 00119 00120 signals: 00121 void spellcheck_done(int result); 00122 public slots: 00123 void slotAutoSpellCheckingToggled( bool ); 00124 void slotSpellcheck2(KSpell*); 00125 void slotSpellResult(const QString&); 00126 void slotSpellDone(); 00127 void slotExternalEditorDone(KProcess*); 00128 void slotMisspelling(const QString &, const QStringList &, unsigned int); 00129 void slotCorrected (const QString &, const QString &, unsigned int); 00130 void addSuggestion(const QString& text, const QStringList& lst, unsigned int ); 00131 virtual void cut(); 00132 virtual void clear(); 00133 virtual void del(); 00134 protected: 00138 virtual bool eventFilter(QObject*, QEvent*); 00139 virtual void keyPressEvent( QKeyEvent* ); 00140 00141 KMComposeWin* mComposer; 00142 00143 private slots: 00144 void slotExternalEditorTempFileChanged( const QString & fileName ); 00145 00146 private: 00147 void killExternalEditor(); 00148 void initializeAutoSpellChecking( KSpellConfig* autoSpellConfig ); 00149 00150 private: 00151 KSpell *mKSpell; 00152 QMap<QString,QStringList> mReplacements; 00153 SpellingFilter* mSpellingFilter; 00154 KTempFile *mExtEditorTempFile; 00155 KDirWatch *mExtEditorTempFileWatcher; 00156 KProcess *mExtEditorProcess; 00157 bool mUseExtEditor; 00158 QString mExtEditor; 00159 bool mWasModifiedBeforeSpellCheck; 00160 KDictSpellingHighlighter *mSpellChecker; 00161 bool mSpellLineEdit; 00162 }; 00163 00164 00165 //----------------------------------------------------------------------------- 00166 class KMLineEdit : public KABC::AddressLineEdit 00167 { 00168 Q_OBJECT 00169 public: 00170 KMLineEdit(KMComposeWin* composer, bool useCompletion, QWidget *parent = 0, 00171 const char *name = 0); 00172 protected: 00173 // Inherited. Always called by the parent when this widget is created. 00174 virtual void loadAddresses(); 00189 virtual void keyPressEvent(QKeyEvent*); 00190 private: 00191 KMComposeWin* mComposer; 00192 }; 00193 00194 00195 class KMLineEditSpell : public KMLineEdit 00196 { 00197 Q_OBJECT 00198 public: 00199 KMLineEditSpell(KMComposeWin* composer, bool useCompletion, QWidget *parent = 0, 00200 const char *name = 0); 00201 void highLightWord( unsigned int length, unsigned int pos ); 00202 void spellCheckDone( const QString &s ); 00203 void spellCheckerMisspelling( const QString &text, const QStringList &, unsigned int pos); 00204 void spellCheckerCorrected( const QString &old, const QString &corr, unsigned int pos); 00205 }; 00206 00207 00208 //----------------------------------------------------------------------------- 00209 class KMAtmListViewItem : public QObject, public QListViewItem 00210 { 00211 Q_OBJECT 00212 friend class KMComposeWin; 00213 00214 public: 00215 KMAtmListViewItem(QListView * parent); 00216 virtual ~KMAtmListViewItem(); 00217 virtual void paintCell( QPainter * p, const QColorGroup & cg, 00218 int column, int width, int align ); 00219 00220 protected: 00221 void enableCryptoCBs(bool on); 00222 void setEncrypt(bool on); 00223 bool isEncrypt(); 00224 void setSign(bool on); 00225 bool isSign(); 00226 00227 private: 00228 QListView* mListview; 00229 QCheckBox* mCBEncrypt; 00230 QCheckBox* mCBSign; 00231 bool mCBSignEnabled, mCBEncryptEnabled; 00232 }; 00233 00234 00235 class KMHeaders; 00236 00237 //----------------------------------------------------------------------------- 00238 class KMComposeWin : public KMTopLevelWidget, virtual public MailComposerIface 00239 { 00240 Q_OBJECT 00241 friend class KMHeaders; // needed for the digest forward 00242 00243 public: 00244 KMComposeWin( KMMessage* msg=0, uint identity=0 ); 00245 ~KMComposeWin(); 00246 00250 void send(int how); 00251 void addAttachment(KURL url,QString comment); 00252 void addAttachment(const QString &name, 00253 const QCString &cte, 00254 const QByteArray &data, 00255 const QCString &type, 00256 const QCString &subType, 00257 const QCString &paramAttr, 00258 const QString &paramValue, 00259 const QCString &contDisp); 00260 void setBody (QString body); 00261 00265 virtual bool event(QEvent *e); 00266 00270 void readColorConfig(); 00271 00275 void writeConfig(void); 00276 00281 void verifyWordWrapLengthIsAdequate(const QString&); 00282 00287 void setMsg(KMMessage* newMsg, bool mayAutoSign=TRUE, 00288 bool allowDecryption=FALSE, bool isModified=FALSE); 00289 00294 KMMessage* msg(void) const { return mMsg; } 00295 00303 bool applyChanges( bool backgroundMode = false ); 00304 00312 Kpgp::Result composeMessage( QCString pgpUserId, 00313 KMMessage& theMessage, 00314 bool doSign, 00315 bool doEncrypt, 00316 bool ignoreBcc, 00317 QCString& signCertFingerprint ); 00318 00323 inline void setAutoDelete(bool f) { mAutoDeleteMsg = f; } 00324 00329 void setFolder(KMFolder* aFolder) { mFolder = aFolder; } 00330 00334 void setCharset(const QCString& aCharset, bool forceDefault = FALSE); 00335 00341 void setReplyFocus( bool hasMessage = true ); 00342 00347 void setFocusToSubject(); 00348 00349 00355 static QString prettyMimeType( const QString& type ); 00356 QString quotePrefixName() const; 00357 00358 KMLineEditSpell *sujectLineWidget() const { return mEdtSubject;} 00359 public slots: 00363 void slotPrint(); 00364 void slotAttachFile(); 00365 void slotSendNow(); 00366 void slotSendLater(); 00370 bool slotSaveDraft(); 00371 void slotNewComposer(); 00372 void slotNewMailReader(); 00373 void slotClose(); 00374 void slotHelp(); 00375 00376 void slotFind(); 00377 void slotReplace(); 00378 void slotUndo(); 00379 void slotRedo(); 00380 void slotCut(); 00381 void slotCopy(); 00382 void slotPaste(); 00383 void slotPasteAsQuotation(); 00384 void slotAddQuotes(); 00385 void slotRemoveQuotes(); 00386 00387 void slotMarkAll(); 00388 00389 void slotFolderRemoved(KMFolder*); 00390 00397 void slotSetAlwaysSend( bool bAlwaysSend ); 00398 00402 void slotUpdateFont(); 00403 00407 void slotAddrBook(); 00411 void slotInsertFile(); 00412 00413 void slotSetCharset(); 00417 void slotSpellcheck(); 00418 void slotSpellcheckConfig(); 00419 00424 void slotSelectCryptoModule(); 00425 00429 void slotStatusMessage(const QString &message); 00430 void slotEditToolbars(); 00431 void slotUpdateToolbars(); 00432 void slotEditKeys(); 00436 void readConfig(void); 00440 void slotUpdWinTitle(const QString& ); 00441 00446 void slotEncryptToggled(bool); 00447 00451 void slotSignToggled(bool); 00452 00456 void slotWordWrapToggled(bool); 00457 00461 void slotAppendSignature(); 00462 00466 void slotInsertMyPublicKey(); 00467 00471 void slotInsertPublicKey(); 00472 00476 void slotUpdateAttachActions(); 00477 00481 void slotAttachPopupMenu(QListViewItem *, const QPoint &, int); 00482 00487 int currentAttachmentNum(); 00488 00492 void slotAttachView(); 00493 void slotAttachRemove(); 00494 void slotAttachSave(); 00495 void slotAttachProperties(); 00496 00497 00502 void slotAddrBookTo(); 00503 void slotAddrBookFrom(); 00504 void slotAddrBookReplyTo(); 00505 00506 void slotCleanSpace(); 00507 00508 00509 // void slotSpellConfigure(); 00510 void slotSpellcheckDone(int result); 00511 void slotSpellcheckDoneClearStatus(); 00512 00516 void deadLetter(void); 00517 00518 void updateCursorPosition(); 00519 00520 void slotView(); 00521 00525 void focusNextPrevEdit(const QWidget* current, bool next); 00526 00530 void slotIdentityChanged(uint); 00531 00535 void slotAttachFileData(KIO::Job *, const QByteArray &); 00536 void slotAttachFileResult(KIO::Job *); 00537 00538 void addAttach(const KURL url); 00539 00543 void addAttach(const KMMessagePart* msgPart); 00544 00545 signals: 00549 void messageQueuedOrDrafted(); 00550 00551 protected: 00557 void rethinkFields(bool fromslot=false); 00558 00562 void rethinkHeaderLine(int value, int mask, int& row, 00563 const QString& labelStr, QLabel* lbl, 00564 QLineEdit* edt, QPushButton* btn=0); 00565 void rethinkHeaderLine(int value, int mask, int& row, 00566 const QString& labelStr, QLabel* lbl, 00567 QComboBox* cbx, QCheckBox *chk); 00568 00572 void setupActions(); 00573 void setupStatusBar(); 00574 void setupEditor(); 00575 00576 00580 QString subject(void) const { return mEdtSubject->text(); } 00581 QString to(void) const { return mEdtTo->text(); } 00582 QString cc(void) const 00583 { return (mEdtCc->isHidden()) ? QString::null : mEdtCc->text(); } 00584 QString bcc(void) const 00585 { return (mEdtBcc->isHidden()) ? QString::null : mEdtBcc->text(); } 00586 QString from(void) const { return mEdtFrom->text(); } 00587 QString replyTo(void) const { return mEdtReplyTo->text(); } 00588 00594 void setFcc( const QString &idString ); 00595 00599 virtual bool queryClose (); 00603 virtual bool queryExit (); 00604 00608 void viewAttach( int index ); 00609 00613 void removeAttach(const QString &url); 00614 void removeAttach(int idx); 00615 00619 void msgPartToItem(const KMMessagePart* msgPart, KMAtmListViewItem *lvi); 00620 00625 void addrBookSelInto(); 00626 00627 private: 00632 void setEncryption( bool encrypt, bool setByUser = false ); 00633 00638 void setSigning( bool sign, bool setByUser = false ); 00639 00643 bool userForgotAttachment(); 00644 00650 QCString breakLinesAndApplyCodec(); 00651 00657 QByteArray pgpSignedMsg( QCString cText, 00658 StructuringInfoWrapper& structuring, 00659 QCString& signCertFingerprint ); 00660 00666 Kpgp::Result pgpEncryptedMsg( QByteArray & rEncryptedBody, 00667 QCString cText, 00668 StructuringInfoWrapper& structuring, 00669 QCString& encryptCertFingerprints ); 00670 00674 QCString getEncryptionCertificate( const QString& recipient ); 00675 00679 bool checkForEncryptCertificateExpiry( const QString& recipient, 00680 const QCString& certFingerprint ); 00681 00693 bool processStructuringInfo( const QString bugURL, 00694 uint boundaryLevel, 00695 const QString contentDescriptionClear, 00696 const QCString contentTypeClear, 00697 const QCString contentSubtypeClear, 00698 const QCString contentDispClear, 00699 const QCString contentTEncClear, 00700 const QCString& bodytext, 00701 const QString contentDescriptionCiph, 00702 const QByteArray& ciphertext, 00703 const StructuringInfoWrapper& structuring, 00704 KMMessagePart& resultingPart ); 00705 00710 bool encryptFlagOfAttachment(int idx); 00711 00716 bool signFlagOfAttachment(int idx); 00717 00718 00719 Kpgp::Result getEncryptionCertificates( const QStringList& recipients, 00720 QCString& encryptionCertificates ); 00721 00722 Kpgp::Result encryptMessage( KMMessage* msg, 00723 const QStringList& recipients, bool doSign, bool doEncrypt, 00724 const QCString& encodedBody,int previousBoundaryLevel, 00725 const KMMessagePart& oldBodyPart, 00726 bool earlyAddAttachments, bool allAttachmentsAreInBody, 00727 KMMessagePart newBodyPart, 00728 QCString& signCertFingerprint ); 00729 00737 static void decryptOrStripOffCleartextSignature( QCString& ); 00738 00742 QCString pgpProcessedMsg(void); 00743 00747 bool doSend(int sendNow=-1, bool saveInDrafts = false); 00748 00749 protected: 00750 QWidget *mMainWidget; 00751 QComboBox *mTransport; 00752 KMail::DictionaryComboBox *mDictionaryCombo; 00753 IdentityCombo *mIdentity; 00754 KMFolderComboBox *mFcc; 00755 KMLineEdit *mEdtFrom, *mEdtReplyTo, *mEdtTo, *mEdtCc, *mEdtBcc; 00756 KMLineEditSpell *mEdtSubject; 00757 QLabel *mLblIdentity, *mLblTransport, *mLblFcc; 00758 QLabel *mLblFrom, *mLblReplyTo, *mLblTo, *mLblCc, *mLblBcc, *mLblSubject; 00759 QLabel *mDictionaryLabel; 00760 QCheckBox *mBtnIdentity, *mBtnTransport, *mBtnFcc; 00761 QPushButton *mBtnTo, *mBtnCc, *mBtnBcc, /* *mBtnFrom, */ *mBtnReplyTo; 00762 bool mSpellCheckInProgress; 00763 bool mDone; 00764 bool mAtmModified; 00765 00766 KMEdit* mEditor; 00767 QGridLayout* mGrid; 00768 KMMessage *mMsg; 00769 QPtrList<KMMessage> mBccMsgList; 00770 KMail::AttachmentListView* mAtmListView; 00771 int mAtmColEncrypt; 00772 int mAtmColSign; 00773 int mAtmEncryptColWidth; 00774 int mAtmSignColWidth; 00775 QPtrList<QListViewItem> mAtmItemList; 00776 KMMsgPartList mAtmList; 00777 QPopupMenu *mAttachMenu; 00778 int mSaveAsId, mPropertiesId; 00779 bool mAutoSign, mAutoPgpSign, mAutoPgpEncrypt, mAutoDeleteMsg; 00780 bool mAutoRequestMDN; 00781 bool mLastSignActionState, mLastEncryptActionState; 00782 bool mLastIdentityHasOpenPgpKey; 00783 KMFolder *mFolder; 00784 long mShowHeaders; 00785 QString mExtEditor; 00786 bool mUseExtEditor; 00787 QPtrList<_StringPair> mCustHeaders; 00788 bool mConfirmSend; 00789 bool mDisableBreaking; 00790 int mNumHeaders; 00791 int mLineBreak; 00792 int mWordWrap; 00793 short mBtnIdSign, mBtnIdEncrypt; 00794 short mMnuIdUrgent, mMnuIdConfDeliver, mMnuIdConfRead; 00795 QFont mBodyFont, mFixedFont; 00796 // QList<QLineEdit> mEdtList; 00797 QPtrList<QWidget> mEdtList; 00798 QPtrList<KTempFile> mAtmTempList; 00799 QPalette mPalette; 00800 uint mId; 00801 QString mOldSigText; 00802 QStringList mTransportHistory; 00803 QString mBcc; 00804 00805 KAction *mAttachPK, *mAttachMPK, 00806 *mAttachRemoveAction, *mAttachSaveAction, *mAttachPropertiesAction; 00807 00808 KToggleAction *mSignAction, *mEncryptAction, *mRequestMDNAction; 00809 KToggleAction *mUrgentAction, *mAllFieldsAction, *mFromAction; 00810 KToggleAction *mReplyToAction, *mToAction, *mCcAction, *mBccAction; 00811 KToggleAction *mSubjectAction; 00812 KToggleAction *mIdentityAction, *mTransportAction, *mFccAction; 00813 KToggleAction *mWordWrapAction, *mFixedFontAction, *mAutoSpellCheckingAction; 00814 KToggleAction *mDictionaryAction; 00815 00816 KSelectAction *mEncodingAction; 00817 KSelectAction *mCryptoModuleAction; 00818 00819 QCString mCharset; 00820 QCString mDefCharset; 00821 QStringList mCharsets; 00822 bool mAutoCharset; 00823 00824 bool mAlwaysSend; 00825 00826 QStringList mFolderNames; 00827 QValueList<QGuardedPtr<KMFolder> > mFolderList; 00828 00829 private slots: 00830 void slotCompletionModeChanged( KGlobalSettings::Completion ); 00831 void slotConfigChanged(); 00832 00833 private: 00834 QColor mForeColor,mBackColor; 00835 struct atmLoadData 00836 { 00837 KURL url; 00838 QByteArray data; 00839 bool insert; 00840 QCString encoding; 00841 }; 00842 QMap<KIO::Job *, atmLoadData> mMapAtmLoadData; 00843 bool mForceReplyCharset; 00844 00845 QString mErrorProcessingStructuringInfo; 00846 QString mErrorNoCryptPlugAndNoBuildIn; 00847 00855 CryptPlugWrapper* mSelectedCryptPlug; 00856 00857 public: 00858 bool mDebugComposerCrypto; 00859 bool mNeverSign; // use this to completely disable signing and warnings 00860 bool mNeverEncrypt; // use this to completely disable encrypting and warnings 00861 }; 00862 #endif 00863
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003