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 <tqobject.h>
00038 #include <tqvaluevector.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
00049 class MessageComposerJob;
00050 class EncryptMessageJob;
00051 class SetLastMessageAsUnencryptedVersionOfLastButOne;
00052
00053 namespace Kleo {
00054 class KeyResolver;
00055 }
00056
00057 namespace GpgME {
00058 class Key;
00059 }
00060
00061 namespace KPIM {
00062 class Identity;
00063 }
00064
00065 class MessageComposer : public TQObject {
00066 Q_OBJECT
00067
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 TQString originalBCC() const { return mBcc; }
00088
00089 void setDisableBreaking( bool b ) { mDisableBreaking = b; }
00090
00091 const TQValueVector<KMMessage*> & composedMessageList() const {
00092 return mMessageList;
00093 }
00094
00095 bool isPerformingSignOperation() const { return mPerformingSignOperation; }
00096 signals:
00097 void done( bool );
00098
00099 private:
00100 void readFromComposeWin();
00101
00102 void adjustCryptFlags();
00103
00104 bool encryptWithChiasmus( const Kleo::CryptoBackend::Protocol * chiasmus,
00105 const TQByteArray& body,
00106 TQByteArray& resultData );
00107 void chiasmusEncryptAllAttachments();
00108 void composeChiasmusMessage( KMMessage& theMessage, Kleo::CryptoMessageFormat format );
00109
00110
00111 void composeMessage();
00112
00113 void createUnencryptedMessageVersion();
00114
00122 void composeMessage( KMMessage& theMessage,
00123 bool doSign, bool doEncrypt,
00124 Kleo::CryptoMessageFormat format );
00125 void continueComposeMessage( KMMessage& theMessage, bool doSign,
00126 bool doEncrypt,
00127 Kleo::CryptoMessageFormat format );
00128
00132 void composeInlineOpenPGPMessage( KMMessage& theMessage,
00133 bool doSign, bool doEncrypt );
00134
00139 TQByteArray breakLinesAndApplyCodec();
00140
00145 TQCString plainTextFromMarkup( const TQString& markupText );
00146
00151 void pgpSignedMsg( const TQByteArray& cText, Kleo::CryptoMessageFormat f );
00156 Kpgp::Result pgpEncryptedMsg( TQByteArray& rEncryptedBody,
00157 const TQByteArray& cText,
00158 const std::vector<GpgME::Key> & encryptionKeys,
00159 Kleo::CryptoMessageFormat f );
00160
00165 Kpgp::Result pgpSignedAndEncryptedMsg( TQByteArray& rEncryptedBody,
00166 const TQByteArray& cText,
00167 const std::vector<GpgME::Key> & signingKeys,
00168 const std::vector<GpgME::Key> & encryptionKeys,
00169 Kleo::CryptoMessageFormat f );
00170
00174 bool checkForEncryptCertificateExpiry( const TQString& recipient,
00175 const TQCString& certFingerprint );
00176
00188 bool processStructuringInfo( const TQString bugURL,
00189 const TQString contentDescriptionClear,
00190 const TQCString contentTypeClear,
00191 const TQCString contentSubtypeClear,
00192 const TQCString contentDispClear,
00193 const TQCString contentTEncClear,
00194 const TQByteArray& bodytext,
00195 const TQString contentDescriptionCiph,
00196 const TQByteArray& ciphertext,
00197 KMMessagePart& resultingPart,
00198 bool signing, Kleo::CryptoMessageFormat format );
00199
00200 void encryptMessage( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00201 bool doSign, bool doEncrypt,
00202 KMMessagePart newBodyPart,
00203 Kleo::CryptoMessageFormat format );
00204
00205 void addBodyAndAttachments( KMMessage* msg, const Kleo::KeyResolver::SplitInfo & si,
00206 bool doSign, bool doEncrypt,
00207 const KMMessagePart& ourFineBodyPart,
00208 Kleo::CryptoMessageFormat format );
00209
00210 private slots:
00211 void slotDoNextJob();
00212
00213 private:
00214 void doNextJob();
00215 void emitDone( bool ok );
00216
00217 int encryptionPossible( const TQStringList & 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 TQValueVector<KMMessage*> mMessageList;
00227
00228 Kleo::KeyResolver * mKeyResolver;
00229
00230 TQCString 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 TQValueVector<Attachment> mAttachments;
00240
00241 TQString 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 TQString mBcc;
00250 TQStringList mTo, mCc, mBccList;
00251 bool mDebugComposerCrypto;
00252 bool mAutoCharset;
00253 TQCString mCharset;
00254 bool mIsRichText;
00255 uint mIdentityUid;
00256 bool mRc;
00257 bool mHoldJobs;
00258
00259 TQByteArray mText;
00260 unsigned int mLineBreakColumn;
00261
00262
00263 KMMessagePart* mNewBodyPart;
00264 TQByteArray mSignature;
00265
00266 TQByteArray mEncodedBody;
00267 bool mEarlyAddAttachments, mAllAttachmentsAreInBody;
00268 KMMessagePart mOldBodyPart;
00269 int mPreviousBoundaryLevel;
00270
00271
00272 DwString mSaveBoundary;
00273 TQCString mMultipartMixedBoundary;
00274
00275 TQValueList<MessageComposerJob*> mJobs;
00276 bool mEncryptWithChiasmus;
00277 bool mPerformingSignOperation;
00278 };
00279
00280 #endif