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
00032
00033 #ifndef _KMAIL_OBJECTTREEPARSER_H_
00034 #define _KMAIL_OBJECTTREEPARSER_H_
00035
00036 #include "kmmsgbase.h"
00037
00038 #include <cryptplugwrapper.h>
00039 #include <qcstring.h>
00040
00041 class KMReaderWin;
00042 class KMMessagePart;
00043 class QString;
00044 class QWidget;
00045 class partNode;
00046
00047 namespace KMail {
00048
00049 class AttachmentStrategy;
00050 class HtmlWriter;
00051 class PartMetaData;
00052 class CSSHelper;
00053
00054 class ProcessResult {
00055 public:
00056 ProcessResult( KMMsgSignatureState inlineSignatureState = KMMsgNotSigned,
00057 KMMsgEncryptionState inlineEncryptionState = KMMsgNotEncrypted,
00058 bool neverDisplayInline = false,
00059 bool isImage = false )
00060 : mInlineSignatureState( inlineSignatureState ),
00061 mInlineEncryptionState( inlineEncryptionState ),
00062 mNeverDisplayInline( neverDisplayInline ),
00063 mIsImage( isImage ) {}
00064
00065 KMMsgSignatureState inlineSignatureState() const {
00066 return mInlineSignatureState;
00067 }
00068 void setInlineSignatureState( KMMsgSignatureState state ) {
00069 mInlineSignatureState = state;
00070 }
00071
00072 KMMsgEncryptionState inlineEncryptionState() const {
00073 return mInlineEncryptionState;
00074 }
00075 void setInlineEncryptionState( KMMsgEncryptionState state ) {
00076 mInlineEncryptionState = state;
00077 }
00078
00079 bool neverDisplayInline() const { return mNeverDisplayInline; }
00080 void setNeverDisplayInline( bool display ) {
00081 mNeverDisplayInline = display;
00082 }
00083
00084 bool isImage() const { return mIsImage; }
00085 void setIsImage( bool image ) {
00086 mIsImage = image;
00087 }
00088
00089 void adjustCryptoStatesOfNode( partNode * node ) const;
00090
00091 private:
00092 KMMsgSignatureState mInlineSignatureState;
00093 KMMsgEncryptionState mInlineEncryptionState;
00094 bool mNeverDisplayInline : 1;
00095 bool mIsImage : 1;
00096 };
00097
00098 class ObjectTreeParser {
00099 class CryptPlugWrapperSaver;
00101 ObjectTreeParser( const ObjectTreeParser & other );
00102 public:
00103 ObjectTreeParser( KMReaderWin * reader=0, CryptPlugWrapper * wrapper=0,
00104 bool showOneMimePart=false, bool keepEncryptions=false,
00105 bool includeSignatures=true,
00106 const KMail::AttachmentStrategy * attachmentStrategy=0,
00107 KMail::HtmlWriter * htmlWriter=0,
00108 KMail::CSSHelper * cssHelper=0 );
00109 virtual ~ObjectTreeParser();
00110
00111 QCString rawReplyString() const { return mRawReplyString; }
00112
00115 QString textualContent() const { return mTextualContent; }
00116
00117 QCString textualContentCharset() const { return mTextualContentCharset; }
00118
00119 void setCryptPlugWrapper( CryptPlugWrapper * wrapper ) {
00120 mCryptPlugWrapper = wrapper;
00121 }
00122 CryptPlugWrapper * cryptPlugWrapper() const {
00123 return mCryptPlugWrapper;
00124 }
00125
00126 bool showOnlyOneMimePart() const { return mShowOnlyOneMimePart; }
00127 void setShowOnlyOneMimePart( bool show ) {
00128 mShowOnlyOneMimePart = show;
00129 }
00130
00131 bool keepEncryptions() const { return mKeepEncryptions; }
00132 void setKeepEncryptions( bool keep ) {
00133 mKeepEncryptions = keep;
00134 }
00135
00136 bool includeSignatures() const { return mIncludeSignatures; }
00137 void setIncludeSignatures( bool include ) {
00138 mIncludeSignatures = include;
00139 }
00140
00141 const KMail::AttachmentStrategy * attachmentStrategy() const {
00142 return mAttachmentStrategy;
00143 }
00144
00145 KMail::HtmlWriter * htmlWriter() const { return mHtmlWriter; }
00146
00147 KMail::CSSHelper * cssHelper() const { return mCSSHelper; }
00148
00151
00152
00153 void parseObjectTree( partNode * node );
00154
00155 private:
00158 void stdChildHandling( partNode * child );
00159
00160 void defaultHandling( partNode * node, ProcessResult & result );
00161
00167
00168 void insertAndParseNewChildNode( partNode & node,
00169 const char * content,
00170 const char * cntDesc,
00171 bool append=false );
00182 bool writeOpaqueOrMultipartSignedData( partNode * data,
00183 partNode & sign,
00184 const QString & fromAddress,
00185 bool doCheck=true,
00186 QCString * cleartextData=0,
00187 CryptPlug::SignatureMetaData * paramSigMeta=0,
00188 bool hideErrors=false );
00189
00192 bool okDecryptMIME( partNode& data,
00193 QCString& decryptedData,
00194 bool& signatureFound,
00195 CryptPlug::SignatureMetaData& sigMeta,
00196 bool showWarning,
00197 bool& passphraseError,
00198 QString& aErrorText );
00199
00200 bool processMailmanMessage( partNode * node );
00201
00206 static bool containsExternalReferences( const QCString & str );
00207
00208 public:
00209
00210 bool processTextHtmlSubtype( partNode * node, ProcessResult & result );
00211 bool processTextPlainSubtype( partNode * node, ProcessResult & result );
00212
00213 bool processMultiPartMixedSubtype( partNode * node, ProcessResult & result );
00214 bool processMultiPartAlternativeSubtype( partNode * node, ProcessResult & result );
00215 bool processMultiPartDigestSubtype( partNode * node, ProcessResult & result );
00216 bool processMultiPartParallelSubtype( partNode * node, ProcessResult & result );
00217 bool processMultiPartSignedSubtype( partNode * node, ProcessResult & result );
00218 bool processMultiPartEncryptedSubtype( partNode * node, ProcessResult & result );
00219
00220 bool processMessageRfc822Subtype( partNode * node, ProcessResult & result );
00221
00222 bool processApplicationOctetStreamSubtype( partNode * node, ProcessResult & result );
00223 bool processApplicationPkcs7MimeSubtype( partNode * node, ProcessResult & result );
00224 bool processApplicationChiasmusTextSubtype( partNode * node, ProcessResult & result );
00225 bool processApplicationMsTnefSubtype( partNode *node, ProcessResult &result );
00226
00227 private:
00228 bool decryptChiasmus( const QByteArray& data, QByteArray& bodyDecoded, QString& errorText );
00229 void writeBodyString( const QCString & bodyString,
00230 const QString & fromAddress,
00231 const QTextCodec * codec,
00232 ProcessResult & result, bool decorate );
00233
00234 void writePartIcon( KMMessagePart * msgPart, int partNumber, bool inlineImage=false );
00235
00236 QString sigStatusToString( CryptPlugWrapper * cryptPlug,
00237 int status_code,
00238 CryptPlugWrapper::SigStatusFlags statusFlags,
00239 int & frameColor,
00240 bool & showKeyInfos );
00241 QString writeSigstatHeader( KMail::PartMetaData & part,
00242 CryptPlugWrapper * cryptPlug,
00243 const QString & fromAddress,
00244 const QString & filename = QString::null );
00245 QString writeSigstatFooter( KMail::PartMetaData & part );
00246
00247 void writeBodyStr( const QCString & bodyString,
00248 const QTextCodec * aCodec,
00249 const QString & fromAddress,
00250 KMMsgSignatureState & inlineSignatureState,
00251 KMMsgEncryptionState & inlineEncryptionState,
00252 bool decorate );
00253 public:
00254 void writeBodyStr( const QCString & bodyString,
00255 const QTextCodec * aCodec,
00256 const QString & fromAddress );
00257
00258 private:
00261 QString quotedHTML(const QString& pos, bool decorate);
00262
00263 const QTextCodec * codecFor( partNode * node ) const;
00264
00265 #ifdef MARCS_DEBUG
00266 void dumpToFile( const char * filename, const char * dataStart, size_t dataLen );
00267 #else
00268 void dumpToFile( const char *, const char *, size_t ) {}
00269 #endif
00270
00271 private:
00272 KMReaderWin * mReader;
00273 QCString mRawReplyString;
00274 QCString mTextualContentCharset;
00275 QString mTextualContent;
00276 CryptPlugWrapper * mCryptPlugWrapper;
00277 bool mShowOnlyOneMimePart;
00278 bool mKeepEncryptions;
00279 bool mIncludeSignatures;
00280 const KMail::AttachmentStrategy * mAttachmentStrategy;
00281 KMail::HtmlWriter * mHtmlWriter;
00282 KMail::CSSHelper * mCSSHelper;
00283
00284 QString mCollapseIcon;
00285 QString mExpandIcon;
00286 };
00287
00288 }
00289
00290 #endif // _KMAIL_OBJECTTREEPARSER_H_
00291