33 #ifndef _KMAIL_OBJECTTREEPARSER_H_
34 #define _KMAIL_OBJECTTREEPARSER_H_
36 #include "kmmsgbase.h"
38 #include <tqcstring.h>
40 #include <kleo/cryptobackend.h>
41 #include <gpgmepp/verificationresult.h>
57 class AttachmentStrategy;
64 ProcessResult( KMMsgSignatureState inlineSignatureState = KMMsgNotSigned,
65 KMMsgEncryptionState inlineEncryptionState = KMMsgNotEncrypted,
66 bool neverDisplayInline =
false,
67 bool isImage =
false )
68 : mInlineSignatureState( inlineSignatureState ),
69 mInlineEncryptionState( inlineEncryptionState ),
70 mNeverDisplayInline( neverDisplayInline ),
71 mIsImage( isImage ) {}
73 KMMsgSignatureState inlineSignatureState()
const {
74 return mInlineSignatureState;
76 void setInlineSignatureState( KMMsgSignatureState state ) {
77 mInlineSignatureState = state;
80 KMMsgEncryptionState inlineEncryptionState()
const {
81 return mInlineEncryptionState;
83 void setInlineEncryptionState( KMMsgEncryptionState state ) {
84 mInlineEncryptionState = state;
87 bool neverDisplayInline()
const {
return mNeverDisplayInline; }
88 void setNeverDisplayInline(
bool display ) {
89 mNeverDisplayInline = display;
92 bool isImage()
const {
return mIsImage; }
93 void setIsImage(
bool image ) {
97 void adjustCryptoStatesOfNode( partNode * node )
const;
100 KMMsgSignatureState mInlineSignatureState;
101 KMMsgEncryptionState mInlineEncryptionState;
102 bool mNeverDisplayInline : 1;
106 class ObjectTreeParser {
107 class CryptoProtocolSaver;
109 ObjectTreeParser(
const ObjectTreeParser & other );
111 ObjectTreeParser(
KMReaderWin * reader=0,
const Kleo::CryptoBackend::Protocol * protocol=0,
112 bool showOneMimePart=
false,
bool keepEncryptions=
false,
113 bool includeSignatures=
true,
114 const KMail::AttachmentStrategy * attachmentStrategy=0,
116 KMail::CSSHelper * cssHelper=0 );
117 virtual ~ObjectTreeParser();
119 void setAllowAsync(
bool allow ) { assert( !mHasPendingAsyncJobs ); mAllowAsync = allow; }
120 bool allowAsync()
const {
return mAllowAsync; }
122 bool hasPendingAsyncJobs()
const {
return mHasPendingAsyncJobs; }
124 TQCString rawReplyString()
const {
return mRawReplyString; }
128 TQString textualContent()
const {
return mTextualContent; }
130 TQCString textualContentCharset()
const {
return mTextualContentCharset; }
132 void setCryptoProtocol(
const Kleo::CryptoBackend::Protocol * protocol ) {
133 mCryptoProtocol = protocol;
135 const Kleo::CryptoBackend::Protocol* cryptoProtocol()
const {
136 return mCryptoProtocol;
139 bool showOnlyOneMimePart()
const {
return mShowOnlyOneMimePart; }
140 void setShowOnlyOneMimePart(
bool show ) {
141 mShowOnlyOneMimePart = show;
144 bool keepEncryptions()
const {
return mKeepEncryptions; }
145 void setKeepEncryptions(
bool keep ) {
146 mKeepEncryptions = keep;
149 bool includeSignatures()
const {
return mIncludeSignatures; }
150 void setIncludeSignatures(
bool include ) {
151 mIncludeSignatures = include;
156 void setShowRawToltecMail(
bool showRawToltecMail ) { mShowRawToltecMail = showRawToltecMail; }
157 bool showRawToltecMail()
const {
return mShowRawToltecMail; }
161 static TQString defaultToltecReplacementText();
163 const KMail::AttachmentStrategy * attachmentStrategy()
const {
164 return mAttachmentStrategy;
169 KMail::CSSHelper * cssHelper()
const {
return mCSSHelper; }
175 void parseObjectTree( partNode * node );
180 void stdChildHandling( partNode * child );
182 void defaultHandling( partNode * node, ProcessResult & result );
197 void insertAndParseNewChildNode( partNode & node,
198 const char * content,
199 const char * cntDesc,
201 bool addToTextualContent =
true );
212 bool writeOpaqueOrMultipartSignedData( partNode * data,
214 const TQString & fromAddress,
216 TQCString * cleartextData=0,
217 const std::vector<GpgME::Signature> & paramSignatures = std::vector<GpgME::Signature>(),
218 bool hideErrors=
false );
222 void writeDeferredDecryptionBlock();
226 void writeDecryptionInProgressBlock();
230 bool okDecryptMIME( partNode& data,
231 TQCString& decryptedData,
232 bool& signatureFound,
233 std::vector<GpgME::Signature> &signatures,
235 bool& passphraseError,
236 bool& actuallyEncrypted,
237 bool& decryptionStarted,
238 TQString& aErrorText,
239 GpgME::Error & auditLogError,
240 TQString& auditLog );
242 bool processMailmanMessage( partNode * node );
253 bool processToltecMail( partNode * node );
259 static bool containsExternalReferences(
const TQCString & str );
263 bool processTextHtmlSubtype( partNode * node, ProcessResult & result );
264 bool processTextPlainSubtype( partNode * node, ProcessResult & result );
266 bool processMultiPartMixedSubtype( partNode * node, ProcessResult & result );
267 bool processMultiPartAlternativeSubtype( partNode * node, ProcessResult & result );
268 bool processMultiPartDigestSubtype( partNode * node, ProcessResult & result );
269 bool processMultiPartParallelSubtype( partNode * node, ProcessResult & result );
270 bool processMultiPartSignedSubtype( partNode * node, ProcessResult & result );
271 bool processMultiPartEncryptedSubtype( partNode * node, ProcessResult & result );
273 bool processMessageRfc822Subtype( partNode * node, ProcessResult & result );
275 bool processApplicationOctetStreamSubtype( partNode * node, ProcessResult & result );
276 bool processApplicationPkcs7MimeSubtype( partNode * node, ProcessResult & result );
277 bool processApplicationChiasmusTextSubtype( partNode * node, ProcessResult & result );
278 bool processApplicationMsTnefSubtype( partNode *node, ProcessResult &result );
281 bool decryptChiasmus(
const TQByteArray& data, TQByteArray& bodyDecoded, TQString& errorText );
282 void writeBodyString(
const TQCString & bodyString,
283 const TQString & fromAddress,
284 const TQTextCodec * codec,
285 ProcessResult & result,
bool decorate );
287 void writePartIcon( KMMessagePart * msgPart,
int partNumber,
bool inlineImage=
false );
289 TQString sigStatusToString(
const Kleo::CryptoBackend::Protocol * cryptProto,
291 GpgME::Signature::Summary summary,
293 bool & showKeyInfos );
294 TQString writeSigstatHeader( KMail::PartMetaData & part,
295 const Kleo::CryptoBackend::Protocol * cryptProto,
296 const TQString & fromAddress,
297 partNode *node = 0 );
298 TQString writeSigstatFooter( KMail::PartMetaData & part );
303 void writeAttachmentMarkHeader( partNode *node );
304 void writeAttachmentMarkFooter();
306 void writeBodyStr(
const TQCString & bodyString,
307 const TQTextCodec * aCodec,
308 const TQString & fromAddress,
309 KMMsgSignatureState & inlineSignatureState,
310 KMMsgEncryptionState & inlineEncryptionState,
313 void writeBodyStr(
const TQCString & bodyString,
314 const TQTextCodec * aCodec,
315 const TQString & fromAddress );
320 TQString quotedHTML(
const TQString& pos,
bool decorate);
322 const TQTextCodec * codecFor( partNode * node )
const;
325 void dumpToFile(
const char * filename,
const char * dataStart,
size_t dataLen );
327 void dumpToFile(
const char *,
const char *,
size_t ) {}
332 TQCString mRawReplyString;
333 TQCString mTextualContentCharset;
334 TQString mTextualContent;
335 const Kleo::CryptoBackend::Protocol * mCryptoProtocol;
336 bool mShowOnlyOneMimePart;
337 bool mKeepEncryptions;
338 bool mIncludeSignatures;
339 bool mHasPendingAsyncJobs;
341 bool mShowRawToltecMail;
342 const KMail::AttachmentStrategy * mAttachmentStrategy;
344 KMail::CSSHelper * mCSSHelper;
346 TQString mCollapseIcon;
347 TQString mExpandIcon;
This class implements a "reader window", that is a window used for reading or viewing messages.
An interface to HTML sinks.