kmail Library API Documentation

messagecomposer.h

00001 
00031 #ifndef MESSAGECOMPOSER_H
00032 #define MESSAGECOMPOSER_H
00033 
00034 #include "kmmsgpart.h"
00035 #include "keyresolver.h"
00036 
00037 #include <qobject.h>
00038 #include <qvaluevector.h>
00039 
00040 #include <mimelib/mediatyp.h>
00041 #include <kleo/cryptobackend.h>
00042 #include <kpgp.h>
00043 
00044 #include <vector>
00045 
00046 class KMMessage;
00047 class KMComposeWin;
00048 class CryptPlugWrapper;
00049 
00050 class MessageComposerJob;
00051 
00052 namespace Kleo {
00053   class KeyResolver;
00054 }
00055 
00056 namespace GpgME {
00057   class Key;
00058 }
00059 
00060 class MessageComposer : public QObject {
00061   Q_OBJECT
00062   friend class MessageComposerJob;
00063   friend class EncryptMessageJob;
00064   friend class SetLastMessageAsUnencryptedVersionOfLastButOne;
00065 
00066 public:
00067   class KeyResolver;
00068 
00069   MessageComposer( KMComposeWin* win, const char* name=0 );
00070   ~MessageComposer();
00071 
00079   void applyChanges( bool disableCrypto );
00080 
00081   QString originalBCC() const { return mBcc; }
00082 
00083   void setDisableBreaking( bool b ) { mDisableBreaking = b; }
00084 
00085   const QValueVector<KMMessage*> & composedMessageList() const {
00086     return mMessageList;
00087   }
00088 
00089 signals:
00090   void done( bool );
00091 
00092 private:
00093   void readFromComposeWin();
00094 
00095   void adjustCryptFlags();
00096 
00097 #ifdef KLEO_CHIASMUS
00098   bool encryptWithChiasmus( const Kleo::CryptoBackend::Protocol * chiasmus,
00099                             const QByteArray& body,
00100                             QByteArray& resultData );
00101   void chiasmusEncryptAllAttachments();
00102   void composeChiasmusMessage( KMMessage& theMessage, Kleo::CryptoMessageFormat format );
00103 #endif
00104 
00105   // This is the composeMessage method
00106   void composeMessage();
00107   // And these two are the parts that should be run after job completions
00108   void createUnencryptedMessageVersion();
00109 
00117   void composeMessage( KMMessage& theMessage,
00118                        bool doSign, bool doEncrypt,
00119                Kleo::CryptoMessageFormat format );
00120   void continueComposeMessage( KMMessage& theMessage, bool doSign,
00121                                bool doEncrypt,
00122                    Kleo::CryptoMessageFormat format );
00123 
00127   void composeInlineOpenPGPMessage( KMMessage& theMessage,
00128                                     bool doSign, bool doEncrypt );
00129 
00134   QCString breakLinesAndApplyCodec();
00136   QCString bodyText();
00137 
00142   void pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat f );
00147   Kpgp::Result pgpEncryptedMsg( QByteArray& rEncryptedBody,
00148                                 const QCString & cText,
00149                                 const std::vector<GpgME::Key> & encryptionKeys,
00150                 Kleo::CryptoMessageFormat f );
00151 
00156   Kpgp::Result pgpSignedAndEncryptedMsg( QByteArray& rEncryptedBody,
00157                      const QCString & cText,
00158                      const std::vector<GpgME::Key> & signingKeys,
00159                      const std::vector<GpgME::Key> & encryptionKeys,
00160                      Kleo::CryptoMessageFormat f );
00161 
00165   bool checkForEncryptCertificateExpiry( const QString& recipient,
00166                                          const QCString& certFingerprint );
00167 
00179   bool processStructuringInfo( const QString bugURL,
00180                                const QString contentDescriptionClear,
00181                                const QCString contentTypeClear,
00182                                const QCString contentSubtypeClear,
00183                                const QCString contentDispClear,
00184                                const QCString contentTEncClear,
00185                                const QCString& bodytext,
00186                                const QString contentDescriptionCiph,
00187                                const QByteArray& ciphertext,
00188                                KMMessagePart& resultingPart,
00189                    bool signing, Kleo::CryptoMessageFormat format );
00190 
00191   void encryptMessage( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00192                        bool doSign, bool doEncrypt,
00193                        KMMessagePart newBodyPart,
00194                Kleo::CryptoMessageFormat format );
00195 
00196   void addBodyAndAttachments( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00197                               bool doSign, bool doEncrypt,
00198                               const KMMessagePart& ourFineBodyPart,
00199                               Kleo::CryptoMessageFormat format );
00200 
00201 private slots:
00202   void slotDoNextJob();
00203 
00204 private:
00205   void doNextJob();
00206 
00207   int encryptionPossible( const QStringList & recipients, bool openPGP );
00208   bool determineWhetherToSign( bool doSignCompletely );
00209   bool determineWhetherToEncrypt( bool doEncryptCompletely );
00210   void markAllAttachmentsForSigning( bool sign );
00211   void markAllAttachmentsForEncryption( bool enc );
00212 
00213   KMComposeWin* mComposeWin;
00214   MessageComposerJob * mCurrentJob;
00215   KMMessage* mReferenceMessage;
00216   QValueVector<KMMessage*> mMessageList;
00217 
00218   Kleo::KeyResolver * mKeyResolver;
00219 
00220   QCString mSignCertFingerprint;
00221 
00222   struct Attachment {
00223     Attachment( KMMessagePart * p=0, bool s=false, bool e=false )
00224       : part( p ), sign( s ), encrypt( e ) {}
00225     KMMessagePart * part;
00226     bool sign;
00227     bool encrypt;
00228   };
00229   QValueVector<Attachment> mAttachments;
00230 
00231   QString mPGPSigningKey, mSMIMESigningKey;
00232   bool mUseOpportunisticEncryption;
00233   bool mSignBody, mEncryptBody;
00234   bool mSigningRequested, mEncryptionRequested;
00235   bool mDoSign, mDoEncrypt;
00236   unsigned int mAllowedCryptoMessageFormats;
00237   bool mDisableCrypto;
00238   bool mDisableBreaking;
00239   QString mBcc;
00240   QStringList mTo, mCc, mBccList;
00241   bool mDebugComposerCrypto;
00242   bool mAutoCharset;
00243   QCString mCharset;
00244   bool mRc; // Set this to false, if something fails during the processes
00245   bool mHoldJobs; // Don't run the next job yet
00246 
00247   // These are the variables of the big composeMessage(X,Y,Z) message
00248   KMMessagePart* mNewBodyPart;
00249   QByteArray mSignature;
00250 
00251   QCString mEncodedBody; // Only needed if signing and/or encrypting
00252   bool mEarlyAddAttachments, mAllAttachmentsAreInBody;
00253   KMMessagePart mOldBodyPart;
00254   int mPreviousBoundaryLevel;
00255 
00256   // The boundary is saved for later addition into mp/a body
00257   DwString  mSaveBoundary;
00258 
00259   QValueList<MessageComposerJob*> mJobs;
00260 #ifdef KLEO_CHIASMUS
00261   bool mEncryptWithChiasmus;
00262   bool mEncryptBodyWithChiasmus;
00263   QString mChiasmusKey;
00264   QString mChiasmusOptions;
00265 #endif
00266 };
00267 
00268 #endif /* MESSAGECOMPOSER_H */
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 2 09:55:23 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003