kmail
partNode.hGo to the documentation of this file.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 #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
00056
00057
00058
00059
00060
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
00142 KMMsgEncryptionState overallEncryptionState() const ;
00143
00144
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() const;
00155
00156 partNode* findId( int id );
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 partNode* findNodeForDwPart( DwBodyPart* part );
00164
00165 void fillMimePartTree( KMMimePartTreeItem* parentItem,
00166 KMMimePartTree* mimePartTree,
00167 QString labelDescr = QString::null,
00168 QString labelCntType = QString::null,
00169 QString labelEncoding = QString::null,
00170 KIO::filesize_t size=0,
00171 bool revertOrder = false );
00172
00173 void adjustDefaultType( partNode* node );
00174
00175 void setNext( partNode* next ) {
00176 mNext = next;
00177 if( mNext ){
00178 mNext->mRoot = mRoot;
00179 adjustDefaultType( mNext );
00180 }
00181 }
00182
00183 void setFirstChild( partNode* child ) {
00184 mChild = child;
00185 if( mChild ) {
00186 mChild->mRoot = this;
00187 adjustDefaultType( mChild );
00188 }
00189 }
00190
00191 void setProcessed( bool processed, bool recurse ) {
00192 mWasProcessed = processed;
00193 if ( recurse ) {
00194 if( mChild )
00195 mChild->setProcessed( processed, true );
00196 if( mNext )
00197 mNext->setProcessed( processed, true );
00198 }
00199 }
00200
00201 void setMimePartTreeItem( KMMimePartTreeItem* item ) {
00202 mMimePartTreeItem = item;
00203 }
00204
00205 KMMimePartTreeItem* mimePartTreeItem() {
00206 return mMimePartTreeItem;
00207 }
00208
00209 void setFromAddress( const QString& address ) {
00210 mFromAddress = address;
00211 }
00212
00213 bool isAttachment() const;
00214 bool isHeuristicalAttachment() const;
00218 bool isFirstTextPart() const;
00219
00220 bool hasContentDispositionInline() const;
00221
00222 QString contentTypeParameter( const char * name ) const;
00223
00224 const QString& trueFromAddress() const;
00225
00226 partNode * parentNode() const { return mRoot; }
00227 partNode * nextSibling() const { return mNext; }
00228 partNode * firstChild() const { return mChild; }
00229 partNode * next( bool allowChildren=true ) const;
00230 int childCount() const;
00231 bool processed() const { return mWasProcessed; }
00232
00233 KMail::Interface::BodyPartMemento * bodyPartMemento() const { return mBodyPartMemento; };
00234 void setBodyPartMemento( KMail::Interface::BodyPartMemento * memento ) {
00235 mBodyPartMemento = memento;
00236 };
00237
00238 private:
00239 partNode* mRoot;
00240 partNode* mNext;
00241 partNode* mChild;
00242 bool mWasProcessed;
00243 private:
00244 DwBodyPart* mDwPart;
00245 mutable KMMessagePart mMsgPart;
00246 QCString mEncodedBody;
00247 QString mFromAddress;
00248 int mType;
00249 int mSubType;
00250 KMMsgEncryptionState mEncryptionState;
00251 KMMsgSignatureState mSignatureState;
00252 mutable bool mMsgPartOk;
00253 bool mEncodedOk;
00254 bool mDeleteDwBodyPart;
00255 KMMimePartTreeItem* mMimePartTreeItem;
00256 KMail::Interface::BodyPartMemento * mBodyPartMemento;
00257 };
00258
00259 #endif
|