00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
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 class EncryptMessageJob;
00052 class SetLastMessageAsUnencryptedVersionOfLastButOne;
00053
00054 namespace Kleo {
00055 class KeyResolver;
00056 }
00057
00058 namespace GpgME {
00059 class Key;
00060 }
00061
00062 namespace KPIM {
00063 class Identity;
00064 }
00065
00066 class MessageComposer : public QObject {
00067 Q_OBJECT
00068 friend class ::MessageComposerJob;
00069 friend class ::EncryptMessageJob;
00070 friend class ::SetLastMessageAsUnencryptedVersionOfLastButOne;
00071
00072 public:
00073 class KeyResolver;
00074
00075 MessageComposer( KMComposeWin* win, const char* name=0 );
00076 ~MessageComposer();
00077
00085 void applyChanges( bool disableCrypto );
00086
00087 QString originalBCC() const { return mBcc; }
00088
00089 void setDisableBreaking( bool b ) { mDisableBreaking = b; }
00090
00091 const QValueVector<KMMessage*> & composedMessageList() const {
00092 return mMessageList;
00093 }
00094
00095 signals:
00096 void done( bool );
00097
00098 private:
00099 void readFromComposeWin();
00100
00101 void adjustCryptFlags();
00102
00103 bool encryptWithChiasmus( const Kleo::CryptoBackend::Protocol * chiasmus,
00104 const QByteArray& body,
00105 QByteArray& resultData );
00106 void chiasmusEncryptAllAttachments();
00107 void composeChiasmusMessage( KMMessage& theMessage, Kleo::CryptoMessageFormat format );
00108
00109
00110 void composeMessage();
00111
00112 void createUnencryptedMessageVersion();
00113
00121 void composeMessage( KMMessage& theMessage,
00122 bool doSign, bool doEncrypt,
00123 Kleo::CryptoMessageFormat format );
00124 void continueComposeMessage( KMMessage& theMessage, bool doSign,
00125 bool doEncrypt,
00126 Kleo::CryptoMessageFormat format );
00127
00131 void composeInlineOpenPGPMessage( KMMessage& theMessage,
00132 bool doSign, bool doEncrypt );
00133
00138 QCString breakLinesAndApplyCodec();
00140 QCString bodyText();
00141
00146 QCString plainTextFromMarkup( const QString& markupText );
00147
00152 void pgpSignedMsg( const QCString & cText, Kleo::CryptoMessageFormat f );
00157 Kpgp::Result pgpEncryptedMsg( QByteArray& rEncryptedBody,
00158 const QCString & cText,
00159 const std::vector<GpgME::Key> & encryptionKeys,
00160 Kleo::CryptoMessageFormat f );
00161
00166 Kpgp::Result pgpSignedAndEncryptedMsg( QByteArray& rEncryptedBody,
00167 const QCString & cText,
00168 const std::vector<GpgME::Key> & signingKeys,
00169 const std::vector<GpgME::Key> & encryptionKeys,
00170 Kleo::CryptoMessageFormat f );
00171
00175 bool checkForEncryptCertificateExpiry( const QString& recipient,
00176 const QCString& certFingerprint );
00177
00189 bool processStructuringInfo( const QString bugURL,
00190 const QString contentDescriptionClear,
00191 const QCString contentTypeClear,
00192 const QCString contentSubtypeClear,
00193 const QCString contentDispClear,
00194 const QCString contentTEncClear,
00195 const QCString& bodytext,
00196 const QString contentDescriptionCiph,
00197 const QByteArray& ciphertext,
00198 KMMessagePart& resultingPart,
00199 bool signing, Kleo::CryptoMessageFormat format );
00200
00201 void encryptMessage( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00202 bool doSign, bool doEncrypt,
00203 KMMessagePart newBodyPart,
00204 Kleo::CryptoMessageFormat format );
00205
00206 void addBodyAndAttachments( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00207 bool doSign, bool doEncrypt,
00208 const KMMessagePart& ourFineBodyPart,
00209 Kleo::CryptoMessageFormat format );
00210
00211 private slots:
00212 void slotDoNextJob();
00213
00214 private:
00215 void doNextJob();
00216
00217 int encryptionPossible( const QStringList & recipients, bool openPGP );
00218 bool determineWhetherToSign( bool doSignCompletely );
00219 bool determineWhetherToEncrypt( bool doEncryptCompletely );
00220 void markAllAttachmentsForSigning( bool sign );
00221 void markAllAttachmentsForEncryption( bool enc );
00222
00223 KMComposeWin* mComposeWin;
00224 MessageComposerJob * mCurrentJob;
00225 KMMessage* mReferenceMessage;
00226 QValueVector<KMMessage*> mMessageList;
00227
00228 Kleo::KeyResolver * mKeyResolver;
00229
00230 QCString mSignCertFingerprint;
00231
00232 struct Attachment {
00233 Attachment( KMMessagePart * p=0, bool s=false, bool e=false )
00234 : part( p ), sign( s ), encrypt( e ) {}
00235 KMMessagePart * part;
00236 bool sign;
00237 bool encrypt;
00238 };
00239 QValueVector<Attachment> mAttachments;
00240
00241 QString mPGPSigningKey, mSMIMESigningKey;
00242 bool mUseOpportunisticEncryption;
00243 bool mSignBody, mEncryptBody;
00244 bool mSigningRequested, mEncryptionRequested;
00245 bool mDoSign, mDoEncrypt;
00246 unsigned int mAllowedCryptoMessageFormats;
00247 bool mDisableCrypto;
00248 bool mDisableBreaking;
00249 QString mBcc;
00250 QStringList mTo, mCc, mBccList;
00251 bool mDebugComposerCrypto;
00252 bool mAutoCharset;
00253 QCString mCharset;
00254 bool mIsRichText;
00255 uint mIdentityUid;
00256 bool mRc;
00257 bool mHoldJobs;
00258
00259 QCString mText;
00260 unsigned int mLineBreakColumn;
00261
00262
00263 KMMessagePart* mNewBodyPart;
00264 QByteArray mSignature;
00265
00266 QCString mEncodedBody;
00267 bool mEarlyAddAttachments, mAllAttachmentsAreInBody;
00268 KMMessagePart mOldBodyPart;
00269 int mPreviousBoundaryLevel;
00270
00271
00272 DwString mSaveBoundary;
00273
00274 QValueList<MessageComposerJob*> mJobs;
00275 bool mEncryptWithChiasmus;
00276 };
00277
00278 #endif