kmail Library API Documentation

objecttreeparser.h

00001 /* -*- mode: C++; c-file-style: "gnu" -*- 00002 objecttreeparser.h 00003 00004 This file is part of KMail, the KDE mail client. 00005 Copyright (c) 2002-2003 Klarälvdalens Datakonsult AB 00006 Copyright (c) 2003 Marc Mutz <mutz@kde.org> 00007 00008 KMail is free software; you can redistribute it and/or modify it 00009 under the terms of the GNU General Public License, version 2, as 00010 published by the Free Software Foundation. 00011 00012 KMail is distributed in the hope that it will be useful, but 00013 WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 In addition, as a special exception, the copyright holders give 00022 permission to link the code of this program with any edition of 00023 the Qt library by Trolltech AS, Norway (or with modified versions 00024 of Qt that use the same license as Qt), and distribute linked 00025 combinations including the two. You must obey the GNU General 00026 Public License in all respects for all of the code used other than 00027 Qt. If you modify this file, you may extend this exception to 00028 your version of the file, but you are not obligated to do so. If 00029 you do not wish to do so, delete this exception statement from 00030 your version. 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; 00102 ObjectTreeParser( const ObjectTreeParser & other ); 00103 public: 00104 ObjectTreeParser( KMReaderWin * reader=0, CryptPlugWrapper * wrapper=0, 00105 bool showOneMimePart=false, bool keepEncryptions=false, 00106 bool includeSignatures=true, 00107 const KMail::AttachmentStrategy * attachmentStrategy=0, 00108 KMail::HtmlWriter * htmlWriter=0, 00109 KMail::CSSHelper * cssHelper=0 ); 00110 virtual ~ObjectTreeParser(); 00111 00112 QCString rawReplyString() const { return mRawReplyString; } 00113 00116 QString textualContent() const { return mTextualContent; } 00117 00118 QCString textualContentCharset() const { return mTextualContentCharset; } 00119 00120 void setCryptPlugWrapper( CryptPlugWrapper * wrapper ) { 00121 mCryptPlugWrapper = wrapper; 00122 } 00123 CryptPlugWrapper * cryptPlugWrapper() const { 00124 return mCryptPlugWrapper; 00125 } 00126 00127 bool showOnlyOneMimePart() const { return mShowOnlyOneMimePart; } 00128 void setShowOnlyOneMimePart( bool show ) { 00129 mShowOnlyOneMimePart = show; 00130 } 00131 00132 bool keepEncryptions() const { return mKeepEncryptions; } 00133 void setKeepEncryptions( bool keep ) { 00134 mKeepEncryptions = keep; 00135 } 00136 00137 bool includeSignatures() const { return mIncludeSignatures; } 00138 void setIncludeSignatures( bool include ) { 00139 mIncludeSignatures = include; 00140 } 00141 00142 const KMail::AttachmentStrategy * attachmentStrategy() const { 00143 return mAttachmentStrategy; 00144 } 00145 00146 KMail::HtmlWriter * htmlWriter() const { return mHtmlWriter; } 00147 00148 KMail::CSSHelper * cssHelper() const { return mCSSHelper; } 00149 00152 // Function is called internally by "parseMsg(KMMessage* msg)" 00153 // and it will be replaced once KMime is alive. 00154 void parseObjectTree( partNode * node ); 00155 00162 static QString byteArrayToTempFile( KMReaderWin* reader, 00163 const QString& dirExt, 00164 const QString& fileName, 00165 const QByteArray& theBody ); 00166 00167 private: 00170 void stdChildHandling( partNode * child ); 00171 00172 void defaultHandling( partNode * node, ProcessResult & result ); 00173 00179 // Function will be replaced once KMime is alive. 00180 void insertAndParseNewChildNode( partNode & node, 00181 const char * content, 00182 const char * cntDesc, 00183 bool append=false ); 00194 bool writeOpaqueOrMultipartSignedData( partNode * data, 00195 partNode & sign, 00196 const QString & fromAddress, 00197 bool doCheck=true, 00198 QCString * cleartextData=0, 00199 CryptPlug::SignatureMetaData * paramSigMeta=0, 00200 bool hideErrors=false ); 00201 00204 bool okDecryptMIME( partNode& data, 00205 QCString& decryptedData, 00206 bool& signatureFound, 00207 CryptPlug::SignatureMetaData& sigMeta, 00208 bool showWarning, 00209 bool& passphraseError, 00210 QString& aErrorText ); 00211 00212 bool processMailmanMessage( partNode * node ); 00213 00214 public:// (during refactoring) 00215 00216 bool processTextHtmlSubtype( partNode * node, ProcessResult & result ); 00217 bool processTextVCalSubtype( partNode * node, ProcessResult & result ); 00218 bool processTextPlainSubtype( partNode * node, ProcessResult & result ); 00219 00220 bool processMultiPartMixedSubtype( partNode * node, ProcessResult & result ); 00221 bool processMultiPartAlternativeSubtype( partNode * node, ProcessResult & result ); 00222 bool processMultiPartDigestSubtype( partNode * node, ProcessResult & result ); 00223 bool processMultiPartParallelSubtype( partNode * node, ProcessResult & result ); 00224 bool processMultiPartSignedSubtype( partNode * node, ProcessResult & result ); 00225 bool processMultiPartEncryptedSubtype( partNode * node, ProcessResult & result ); 00226 00227 bool processMessageRfc822Subtype( partNode * node, ProcessResult & result ); 00228 00229 bool processApplicationOctetStreamSubtype( partNode * node, ProcessResult & result ); 00230 bool processApplicationPkcs7MimeSubtype( partNode * node, ProcessResult & result ); 00231 bool processApplicationMsTnefSubtype( partNode * node, ProcessResult & result ); 00232 00233 private: 00234 void writeBodyString( const QCString & bodyString, 00235 const QString & fromAddress, 00236 const QTextCodec * codec, 00237 ProcessResult & result ); 00238 00239 void writePartIcon( KMMessagePart * msgPart, int partNumber, bool inlineImage=false ); 00240 00241 QString sigStatusToString( CryptPlugWrapper * cryptPlug, 00242 int status_code, 00243 CryptPlugWrapper::SigStatusFlags statusFlags, 00244 int & frameColor, 00245 bool & showKeyInfos ); 00246 QString writeSigstatHeader( KMail::PartMetaData & part, 00247 CryptPlugWrapper * cryptPlug, 00248 const QString & fromAddress, 00249 const QString & filename = QString::null ); 00250 QString writeSigstatFooter( KMail::PartMetaData & part ); 00251 00252 void writeBodyStr( const QCString & bodyString, 00253 const QTextCodec * aCodec, 00254 const QString & fromAddress, 00255 KMMsgSignatureState & inlineSignatureState, 00256 KMMsgEncryptionState & inlineEncryptionState ); 00257 public: // KMReaderWin still needs this... 00258 void writeBodyStr( const QCString & bodyString, 00259 const QTextCodec * aCodec, 00260 const QString & fromAddress ); 00261 00262 private: 00265 QString quotedHTML(const QString& pos); 00266 00267 const QTextCodec * codecFor( partNode * node ) const; 00268 00269 #ifdef MARCS_DEBUG 00270 void dumpToFile( const char * filename, const char * dataStart, size_t dataLen ); 00271 #else 00272 void dumpToFile( const char *, const char *, size_t ) {} 00273 #endif 00274 00275 private: 00276 KMReaderWin * mReader; 00277 QCString mRawReplyString; 00278 QCString mTextualContentCharset; 00279 QString mTextualContent; 00280 CryptPlugWrapper * mCryptPlugWrapper; 00281 bool mShowOnlyOneMimePart; 00282 bool mKeepEncryptions; 00283 bool mIncludeSignatures; 00284 const KMail::AttachmentStrategy * mAttachmentStrategy; 00285 KMail::HtmlWriter * mHtmlWriter; 00286 KMail::CSSHelper * mCSSHelper; 00287 }; 00288 00289 } // namespace KMail 00290 00291 #endif // _KMAIL_OBJECTTREEPARSER_H_ 00292
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:24 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003