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,2004 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 "interfaces/bodypart.h" 00040 00041 #include <mimelib/mimepp.h> 00042 #include <mimelib/body.h> 00043 #include <mimelib/utility.h> 00044 00045 #include <kio/global.h> 00046 #include <kdebug.h> 00047 00048 class KMMimePartTreeItem; 00049 class KMMimePartTree; 00050 00051 /* 00052 =========================================================================== 00053 00054 00055 S T A R T O F T E M P O R A R Y M I M E C O D E 00056 00057 00058 =========================================================================== 00059 N O T E : The partNode structure will most likely be replaced by KMime. 00060 It's purpose: Speed optimization for KDE 3. (khz, 28.11.01) 00061 =========================================================================== 00062 */ 00063 class partNode 00064 { 00065 partNode(); 00066 00067 int calcNodeIdOrFindNode( int& curId, const partNode* calcNode, 00068 int findId, partNode** findNode ); 00069 00070 public: 00071 static partNode * fromMessage( const KMMessage * msg ); 00072 00073 partNode( DwBodyPart* dwPart, 00074 int explicitType = DwMime::kTypeUnknown, 00075 int explicitSubType = DwMime::kSubtypeUnknown, 00076 bool deleteDwBodyPart = false ); 00077 00078 partNode( bool deleteDwBodyPart, 00079 DwBodyPart* dwPart ); 00080 00081 ~partNode(); 00082 00083 void dump( int chars=0 ) const; 00084 00085 void buildObjectTree( bool processSiblings=true ); 00086 00087 DwBodyPart* dwPart() const { 00088 return mDwPart; 00089 } 00090 00091 void setDwPart( DwBodyPart* part ) { 00092 mDwPart = part; 00093 mMsgPartOk = false; 00094 } 00095 00096 KMMessagePart& msgPart() const { 00097 if( !mMsgPartOk ) { 00098 KMMessage::bodyPart(mDwPart, &mMsgPart); 00099 mMsgPartOk = true; 00100 } 00101 return mMsgPart; 00102 } 00103 00104 const QCString & encodedBody(); 00105 00106 void setType( int type ) { 00107 mType = type; 00108 } 00109 00110 void setSubType( int subType ) { 00111 mSubType = subType; 00112 } 00113 00114 int type() const { 00115 return mType; 00116 } 00117 00118 QCString typeString() const; 00119 00120 int subType() const { 00121 return mSubType; 00122 } 00123 00124 QCString subTypeString() const; 00125 00126 bool hasType( int type ) { 00127 return mType == type; 00128 } 00129 00130 bool hasSubType( int subType ) { 00131 return mSubType == subType; 00132 } 00133 00134 void setEncryptionState( KMMsgEncryptionState state ) { 00135 mEncryptionState = state; 00136 } 00137 KMMsgEncryptionState encryptionState() const { 00138 return mEncryptionState; 00139 } 00140 00141 // look at the encryption states of all children and return result 00142 KMMsgEncryptionState overallEncryptionState() const ; 00143 00144 // look at the signature states of all children and return result 00145 KMMsgSignatureState overallSignatureState() const ; 00146 00147 void setSignatureState( KMMsgSignatureState state ) { 00148 mSignatureState = state; 00149 } 00150 KMMsgSignatureState signatureState() const { 00151 return mSignatureState; 00152 } 00153 00154 int nodeId(); // node ids start at 1 (this is the top level root node) 00155 00156 partNode* findId( int id ); // returns the node which has the given id (or 0, resp.) 00157 00158 partNode* findType( int type, int subType, bool deep=true, bool wide=true ); 00159 00160 partNode* findTypeNot( int type, int subType, bool deep=true, 00161 bool wide=true ); 00162 00163 void fillMimePartTree( KMMimePartTreeItem* parentItem, 00164 KMMimePartTree* mimePartTree, 00165 QString labelDescr = QString::null, 00166 QString labelCntType = QString::null, 00167 QString labelEncoding = QString::null, 00168 KIO::filesize_t size=0, 00169 bool revertOrder = false ); 00170 00171 void adjustDefaultType( partNode* node ); 00172 00173 void setNext( partNode* next ) { 00174 mNext = next; 00175 if( mNext ){ 00176 mNext->mRoot = mRoot; 00177 adjustDefaultType( mNext ); 00178 } 00179 } 00180 00181 void setFirstChild( partNode* child ) { 00182 mChild = child; 00183 if( mChild ) { 00184 mChild->mRoot = this; 00185 adjustDefaultType( mChild ); 00186 } 00187 } 00188 00189 void setProcessed( bool processed, bool recurse ) { 00190 mWasProcessed = processed; 00191 if ( recurse ) { 00192 if( mChild ) 00193 mChild->setProcessed( processed, true ); 00194 if( mNext ) 00195 mNext->setProcessed( processed, true ); 00196 } 00197 } 00198 00199 void setMimePartTreeItem( KMMimePartTreeItem* item ) { 00200 mMimePartTreeItem = item; 00201 } 00202 00203 KMMimePartTreeItem* mimePartTreeItem() { 00204 return mMimePartTreeItem; 00205 } 00206 00207 void setFromAddress( const QString& address ) { 00208 mFromAddress = address; 00209 } 00210 00211 bool isAttachment() const; 00212 bool isHeuristicalAttachment() const; 00213 bool isFirstTextPart() const; 00214 00215 bool hasContentDispositionInline() const; 00216 00217 QString contentTypeParameter( const char * name ) const; 00218 00219 const QString& trueFromAddress() const; 00220 00221 partNode * parentNode() const { return mRoot; } 00222 partNode * nextSibling() const { return mNext; } 00223 partNode * firstChild() const { return mChild; } 00224 partNode * next( bool allowChildren=true ) const; 00225 int childCount() const; 00226 bool processed() const { return mWasProcessed; } 00227 00228 KMail::Interface::BodyPartMemento * bodyPartMemento() const { return mBodyPartMemento; }; 00229 void setBodyPartMemento( KMail::Interface::BodyPartMemento * memento ) { 00230 mBodyPartMemento = memento; 00231 }; 00232 00233 private: 00234 partNode* mRoot; 00235 partNode* mNext; 00236 partNode* mChild; 00237 bool mWasProcessed; // to be used by parseObjectTree() 00238 private: 00239 DwBodyPart* mDwPart; // may be zero 00240 mutable KMMessagePart mMsgPart; // is valid - even if mDwPart is zero 00241 QCString mEncodedBody; 00242 QString mFromAddress; 00243 int mType; 00244 int mSubType; 00245 KMMsgEncryptionState mEncryptionState; 00246 KMMsgSignatureState mSignatureState; 00247 mutable bool mMsgPartOk; 00248 bool mEncodedOk; 00249 bool mDeleteDwBodyPart; 00250 KMMimePartTreeItem* mMimePartTreeItem; 00251 KMail::Interface::BodyPartMemento * mBodyPartMemento; 00252 }; 00253 00254 #endif
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 Aug 27 12:52:52 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003