kmail Library API Documentation

partNode.h

00001 /* -*- c++ -*- 00002 partNode.h A node in a MIME tree. 00003 00004 This file is part of KMail, the KDE mail client. 00005 Copyright (c) 2002 Klarälvdalens Datakonsult AB 00006 00007 KMail is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License, version 2, as 00009 published by the Free Software Foundation. 00010 00011 KMail is distributed in the hope that it will be useful, but 00012 WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 In addition, as a special exception, the copyright holders give 00021 permission to link the code of this program with any edition of 00022 the Qt library by Trolltech AS, Norway (or with modified versions 00023 of Qt that use the same license as Qt), and distribute linked 00024 combinations including the two. You must obey the GNU General 00025 Public License in all respects for all of the code used other than 00026 Qt. If you modify this file, you may extend this exception to 00027 your version of the file, but you are not obligated to do so. If 00028 you do not wish to do so, delete this exception statement from 00029 your version. 00030 */ 00031 00032 #ifndef PARTNODE_H 00033 #define PARTNODE_H 00034 00035 #include "kmmsgpart.h" 00036 #include "kmmsgbase.h" 00037 #include "kmmessage.h" 00038 00039 #include <mimelib/mimepp.h> 00040 #include <mimelib/body.h> 00041 #include <mimelib/utility.h> 00042 00043 #include <kio/global.h> 00044 #include <kdebug.h> 00045 00046 class KMMimePartTreeItem; 00047 class KMMimePartTree; 00048 00049 /* 00050 =========================================================================== 00051 00052 00053 S T A R T O F T E M P O R A R Y M I M E C O D E 00054 00055 00056 =========================================================================== 00057 N O T E : The partNode structure will most likely be replaced by KMime. 00058 It's purpose: Speed optimization for KDE 3. (khz, 28.11.01) 00059 =========================================================================== 00060 */ 00061 class partNode 00062 { 00063 public: 00064 enum CryptoType { CryptoTypeUnknown, 00065 CryptoTypeNone, 00066 CryptoTypeInlinePGP, 00067 CryptoTypeOpenPgpMIME, 00068 CryptoTypeSMIME, 00069 CryptoType3rdParty }; 00070 00071 private: 00072 partNode(); 00073 00074 int calcNodeIdOrFindNode( int& curId, const partNode* calcNode, 00075 int findId, partNode** findNode ); 00076 00077 public: 00078 partNode( DwBodyPart* dwPart, 00079 int explicitType = DwMime::kTypeUnknown, 00080 int explicitSubType = DwMime::kSubtypeUnknown, 00081 bool deleteDwBodyPart = false ); 00082 00083 partNode( bool deleteDwBodyPart, 00084 DwBodyPart* dwPart ); 00085 00086 ~partNode(); 00087 00088 void dump( int chars=0 ) const; 00089 00090 void buildObjectTree( bool processSiblings=true ); 00091 00092 DwBodyPart* dwPart() const { 00093 return mDwPart; 00094 } 00095 00096 void setDwPart( DwBodyPart* part ) { 00097 mDwPart = part; 00098 mMsgPartOk = false; 00099 } 00100 00101 KMMessagePart& msgPart() const { 00102 if( !mMsgPartOk ) { 00103 KMMessage::bodyPart(mDwPart, &mMsgPart); 00104 mMsgPartOk = true; 00105 } 00106 return mMsgPart; 00107 } 00108 00109 const QCString & encodedBody(); 00110 00111 void setType( int type ) { 00112 mType = type; 00113 } 00114 00115 void setSubType( int subType ) { 00116 mSubType = subType; 00117 } 00118 00119 int type() const { 00120 return mType; 00121 } 00122 00123 QCString typeString() const; 00124 00125 int subType() const { 00126 return mSubType; 00127 } 00128 00129 QCString subTypeString() const; 00130 00131 bool hasType( int type ) { 00132 return mType == type; 00133 } 00134 00135 bool hasSubType( int subType ) { 00136 return mSubType == subType; 00137 } 00138 00139 void setCryptoType( CryptoType cryptoType ) { 00140 mCryptoType = cryptoType; 00141 } 00142 00143 CryptoType cryptoType() const { 00144 return mCryptoType; 00145 } 00146 00147 // return first not-unknown and not-none crypto type 00148 // or return none (or unknown, resp.) if no other crypto type set 00149 CryptoType firstCryptoType() const ; 00150 00151 void setEncryptionState( KMMsgEncryptionState state ) { 00152 mEncryptionState = state; 00153 } 00154 KMMsgEncryptionState encryptionState() const { 00155 return mEncryptionState; 00156 } 00157 00158 // look at the encryption states of all children and return result 00159 KMMsgEncryptionState overallEncryptionState() const ; 00160 00161 // look at the signature states of all children and return result 00162 KMMsgSignatureState overallSignatureState() const ; 00163 00164 void setSignatureState( KMMsgSignatureState state ) { 00165 mSignatureState = state; 00166 } 00167 KMMsgSignatureState signatureState() const { 00168 return mSignatureState; 00169 } 00170 00171 int nodeId(); // node ids start at 1 (this is the top level root node) 00172 00173 partNode* findId( int id ); // returns the node which has the given id (or 0, resp.) 00174 00175 partNode* findType( int type, int subType, bool deep=true, bool wide=true ); 00176 00177 partNode* findTypeNot( int type, int subType, bool deep=true, 00178 bool wide=true ); 00179 00180 void fillMimePartTree( KMMimePartTreeItem* parentItem, 00181 KMMimePartTree* mimePartTree, 00182 QString labelDescr = QString::null, 00183 QString labelCntType = QString::null, 00184 QString labelEncoding = QString::null, 00185 KIO::filesize_t size=0, 00186 bool revertOrder = false ); 00187 00188 void adjustDefaultType( partNode* node ); 00189 00190 void setNext( partNode* next ) { 00191 mNext = next; 00192 if( mNext ){ 00193 mNext->mRoot = mRoot; 00194 adjustDefaultType( mNext ); 00195 } 00196 } 00197 00198 void setFirstChild( partNode* child ) { 00199 mChild = child; 00200 if( mChild ) { 00201 mChild->mRoot = this; 00202 adjustDefaultType( mChild ); 00203 } 00204 } 00205 00206 void setProcessed( bool processed, bool recurse ) { 00207 mWasProcessed = processed; 00208 if ( recurse ) { 00209 if( mChild ) 00210 mChild->setProcessed( processed, true ); 00211 if( mNext ) 00212 mNext->setProcessed( processed, true ); 00213 } 00214 } 00215 00216 void setMimePartTreeItem( KMMimePartTreeItem* item ) { 00217 mMimePartTreeItem = item; 00218 } 00219 00220 KMMimePartTreeItem* mimePartTreeItem() { 00221 return mMimePartTreeItem; 00222 } 00223 00224 void setFromAddress( const QString& address ) { 00225 mFromAddress = address; 00226 } 00227 00228 bool isAttachment() const; 00229 00230 bool hasContentDispositionInline() const; 00231 00232 const QString& trueFromAddress() const; 00233 00234 partNode * parentNode() const { return mRoot; } 00235 partNode * nextSibling() const { return mNext; } 00236 partNode * firstChild() const { return mChild; } 00237 bool processed() const { return mWasProcessed; } 00238 00239 private: 00240 partNode* mRoot; 00241 partNode* mNext; 00242 partNode* mChild; 00243 bool mWasProcessed; // to be used by parseObjectTree() 00244 private: 00245 DwBodyPart* mDwPart; // may be zero 00246 mutable KMMessagePart mMsgPart; // is valid - even if mDwPart is zero 00247 QCString mEncodedBody; 00248 QString mFromAddress; 00249 int mType; 00250 int mSubType; 00251 CryptoType mCryptoType; 00252 KMMsgEncryptionState mEncryptionState; 00253 KMMsgSignatureState mSignatureState; 00254 mutable bool mMsgPartOk; 00255 bool mEncodedOk; 00256 bool mDeleteDwBodyPart; 00257 KMMimePartTreeItem* mMimePartTreeItem; 00258 }; 00259 00260 #endif
KDE Logo
This file is part of the documentation for kmail Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:04 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003