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 <kpgp.h>
00042 
00043 #include <vector>
00044 
00045 class KMMessage;
00046 class KMComposeWin;
00047 class CryptPlugWrapper;
00048 
00049 class MessageComposerJob;
00050 
00051 namespace Kleo {
00052   class KeyResolver;
00053 }
00054 
00055 namespace GpgME {
00056   class Key;
00057 }
00058 
00059 class MessageComposer : public QObject {
00060   Q_OBJECT
00061   friend class MessageComposerJob;
00062   friend class EncryptMessageJob;
00063   friend class SetLastMessageAsUnencryptedVersionOfLastButOne;
00064 
00065 public:
00066   class KeyResolver;
00067 
00068   MessageComposer( KMComposeWin* win, const char* name=0 );
00069   ~MessageComposer();
00070 
00078   void applyChanges( bool disableCrypto );
00079 
00080   QString originalBCC() const { return mBcc; }
00081 
00082   void setDisableBreaking( bool b ) { mDisableBreaking = b; }
00083 
00084   const QValueVector<KMMessage*> & composedMessageList() const {
00085     return mMessageList;
00086   }
00087 
00088 signals:
00089   void done( bool );
00090 
00091 private:
00092   void readFromComposeWin();
00093 
00094   void adjustCryptFlags();
00095 
00096   // This is the composeMessage method
00097   void composeMessage();
00098   // And these two are the parts that should be run after job completions
00099   void createUnencryptedMessageVersion();
00100 
00108   void composeMessage( KMMessage& theMessage,
00109                        bool doSign, bool doEncrypt,
00110                Kleo::CryptoMessageFormat format );
00111   void continueComposeMessage( KMMessage& theMessage, bool doSign,
00112                                bool doEncrypt,
00113                    Kleo::CryptoMessageFormat format );
00114 
00118   void composeInlineOpenPGPMessage( KMMessage& theMessage,
00119                                     bool doSign, bool doEncrypt );
00120 
00125   QCString breakLinesAndApplyCodec();
00127   QCString bodyText();
00128 
00133   void pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat f );
00138   Kpgp::Result pgpEncryptedMsg( QByteArray& rEncryptedBody,
00139                                 const QCString & cText,
00140                                 const std::vector<GpgME::Key> & encryptionKeys,
00141                 Kleo::CryptoMessageFormat f );
00142 
00147   Kpgp::Result pgpSignedAndEncryptedMsg( QByteArray& rEncryptedBody,
00148                      const QCString & cText,
00149                      const std::vector<GpgME::Key> & signingKeys,
00150                      const std::vector<GpgME::Key> & encryptionKeys,
00151                      Kleo::CryptoMessageFormat f );
00152 
00156   bool checkForEncryptCertificateExpiry( const QString& recipient,
00157                                          const QCString& certFingerprint );
00158 
00170   bool processStructuringInfo( const QString bugURL,
00171                                const QString contentDescriptionClear,
00172                                const QCString contentTypeClear,
00173                                const QCString contentSubtypeClear,
00174                                const QCString contentDispClear,
00175                                const QCString contentTEncClear,
00176                                const QCString& bodytext,
00177                                const QString contentDescriptionCiph,
00178                                const QByteArray& ciphertext,
00179                                KMMessagePart& resultingPart,
00180                    bool signing, Kleo::CryptoMessageFormat format );
00181 
00182   void encryptMessage( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00183                        bool doSign, bool doEncrypt,
00184                        KMMessagePart newBodyPart,
00185                Kleo::CryptoMessageFormat format );
00186 
00187   void addBodyAndAttachments( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00188                               bool doSign, bool doEncrypt,
00189                               const KMMessagePart& ourFineBodyPart,
00190                               Kleo::CryptoMessageFormat format );
00191 
00192 private slots:
00193   void slotDoNextJob();
00194 
00195 private:
00196   void doNextJob();
00197 
00198   int encryptionPossible( const QStringList & recipients, bool openPGP );
00199   bool determineWhetherToSign( bool doSignCompletely );
00200   bool determineWhetherToEncrypt( bool doEncryptCompletely );
00201   void markAllAttachmentsForSigning( bool sign );
00202   void markAllAttachmentsForEncryption( bool enc );
00203 
00204   KMComposeWin* mComposeWin;
00205   MessageComposerJob * mCurrentJob;
00206   KMMessage* mReferenceMessage;
00207   QValueVector<KMMessage*> mMessageList;
00208 
00209   Kleo::KeyResolver * mKeyResolver;
00210 
00211   QCString mSignCertFingerprint;
00212 
00213   struct Attachment {
00214     Attachment( KMMessagePart * p=0, bool s=false, bool e=false )
00215       : part( p ), sign( s ), encrypt( e ) {}
00216     KMMessagePart * part;
00217     bool sign;
00218     bool encrypt;
00219   };
00220   QValueVector<Attachment> mAttachments;
00221 
00222   QString mPGPSigningKey, mSMIMESigningKey;
00223   bool mUseOpportunisticEncryption;
00224   bool mSignBody, mEncryptBody;
00225   bool mSigningRequested, mEncryptionRequested;
00226   bool mDoSign, mDoEncrypt;
00227   unsigned int mAllowedCryptoMessageFormats;
00228   bool mDisableCrypto;
00229   bool mDisableBreaking;
00230   QString mBcc;
00231   QStringList mTo, mCc, mBccList;
00232   bool mDebugComposerCrypto;
00233   bool mAutoCharset;
00234   QCString mCharset;
00235   bool mRc; // Set this to false, if something fails during the processes
00236   bool mHoldJobs; // Don't run the next job yet
00237 
00238   // These are the variables of the big composeMessage(X,Y,Z) message
00239   KMMessagePart* mNewBodyPart;
00240   QByteArray mSignature;
00241 
00242   QCString mEncodedBody; // Only needed if signing and/or encrypting
00243   bool mEarlyAddAttachments, mAllAttachmentsAreInBody;
00244   KMMessagePart mOldBodyPart;
00245   int mPreviousBoundaryLevel;
00246 
00247   // The boundary is saved for later addition into mp/a body
00248   DwString  mSaveBoundary;
00249 
00250   QValueList<MessageComposerJob*> mJobs;
00251 };
00252 
00253 #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 Mon Apr 4 04:48:29 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003