kmail
partNode.h
Go 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 #include <QByteArray>
00048
00049 class KMMimePartTreeItem;
00050 class KMMimePartTree;
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 class partNode
00065 {
00066 partNode();
00067
00068 int calcNodeIdOrFindNode( int& curId, const partNode* calcNode,
00069 int findId, partNode** findNode );
00070
00071 public:
00072 static partNode * fromMessage( const KMMessage * msg );
00073
00074 explicit partNode( DwBodyPart* dwPart,
00075 int explicitType = DwMime::kTypeUnknown,
00076 int explicitSubType = DwMime::kSubtypeUnknown,
00077 bool deleteDwBodyPart = false );
00078
00079 partNode( bool deleteDwBodyPart,
00080 DwBodyPart* dwPart );
00081
00082 ~partNode();
00083
00084 void dump( int chars=0 ) const;
00085
00086 void buildObjectTree( bool processSiblings=true );
00087
00088 DwBodyPart* dwPart() const {
00089 return mDwPart;
00090 }
00091
00092 void setDwPart( DwBodyPart* part ) {
00093 mDwPart = part;
00094 mMsgPartOk = false;
00095 }
00096
00097 KMMessagePart& msgPart() const {
00098 if( !mMsgPartOk ) {
00099 KMMessage::bodyPart(mDwPart, &mMsgPart);
00100 mMsgPartOk = true;
00101 }
00102 return mMsgPart;
00103 }
00104
00105 const QByteArray & encodedBody();
00106
00107 void setType( int type ) {
00108 mType = type;
00109 }
00110
00111 void setSubType( int subType ) {
00112 mSubType = subType;
00113 }
00114
00115 int type() const {
00116 return mType;
00117 }
00118
00119 QByteArray typeString() const;
00120
00121 int subType() const {
00122 return mSubType;
00123 }
00124
00125 QByteArray subTypeString() const;
00126
00127 bool hasType( int type ) {
00128 return mType == type;
00129 }
00130
00131 bool hasSubType( int subType ) {
00132 return mSubType == subType;
00133 }
00134
00135 void setEncryptionState( KMMsgEncryptionState state ) {
00136 mEncryptionState = state;
00137 }
00138 KMMsgEncryptionState encryptionState() const {
00139 return mEncryptionState;
00140 }
00141
00142
00143 KMMsgEncryptionState overallEncryptionState() const ;
00144
00145
00146 KMMsgSignatureState overallSignatureState() const ;
00147
00148 void setSignatureState( KMMsgSignatureState state ) {
00149 mSignatureState = state;
00150 }
00151 KMMsgSignatureState signatureState() const {
00152 return mSignatureState;
00153 }
00154
00155 int nodeId() const;
00156
00157 partNode* findId( int id );
00158
00159 partNode* findType( int type, int subType, bool deep=true, bool wide=true );
00160
00161 partNode* findTypeNot( int type, int subType, bool deep=true,
00162 bool wide=true );
00163
00164 partNode* findNodeForDwPart( DwBodyPart* part );
00165
00166 void fillMimePartTree( KMMimePartTreeItem* parentItem,
00167 KMMimePartTree* mimePartTree,
00168 const QString &labelDescr = QString(),
00169 const QString &labelCntType = QString(),
00170 const QString &labelEncoding = QString(),
00171 KIO::filesize_t size=0,
00172 bool revertOrder = false );
00173
00174 void adjustDefaultType( partNode* node );
00175
00176 void setNext( partNode* next ) {
00177 mNext = next;
00178 if( mNext ){
00179 mNext->mRoot = mRoot;
00180 adjustDefaultType( mNext );
00181 }
00182 }
00183
00184 void setFirstChild( partNode* child ) {
00185 mChild = child;
00186 if( mChild ) {
00187 mChild->mRoot = this;
00188 adjustDefaultType( mChild );
00189 }
00190 }
00191
00192 void setProcessed( bool processed, bool recurse ) {
00193 mWasProcessed = processed;
00194 if ( recurse ) {
00195 if( mChild )
00196 mChild->setProcessed( processed, true );
00197 if( mNext )
00198 mNext->setProcessed( processed, true );
00199 }
00200 }
00201
00202 void setMimePartTreeItem( KMMimePartTreeItem* item ) {
00203 mMimePartTreeItem = item;
00204 }
00205
00206 KMMimePartTreeItem* mimePartTreeItem() {
00207 return mMimePartTreeItem;
00208 }
00209
00210 void setFromAddress( const QString& address ) {
00211 mFromAddress = address;
00212 }
00213
00214 bool isAttachment() const;
00215 bool isHeuristicalAttachment() const;
00219 bool isFirstTextPart() const;
00220
00221 bool hasContentDispositionInline() const;
00222
00223 QString contentTypeParameter( const char * name ) const;
00224
00225 const QString& trueFromAddress() const;
00226
00227 partNode * parentNode() const { return mRoot; }
00228 partNode * nextSibling() const { return mNext; }
00229 partNode * firstChild() const { return mChild; }
00230 partNode * next( bool allowChildren=true ) const;
00231 int childCount() const;
00232 bool processed() const { return mWasProcessed; }
00233
00234 KMail::Interface::BodyPartMemento * bodyPartMemento() const { return mBodyPartMemento; }
00235 void setBodyPartMemento( KMail::Interface::BodyPartMemento * memento ) {
00236 mBodyPartMemento = memento;
00237 }
00238
00239 private:
00240 partNode* mRoot;
00241 partNode* mNext;
00242 partNode* mChild;
00243 bool mWasProcessed;
00244 private:
00245 DwBodyPart* mDwPart;
00246 mutable KMMessagePart mMsgPart;
00247 QByteArray mEncodedBody;
00248 QString mFromAddress;
00249 int mType;
00250 int mSubType;
00251 KMMsgEncryptionState mEncryptionState;
00252 KMMsgSignatureState mSignatureState;
00253 mutable bool mMsgPartOk;
00254 bool mEncodedOk;
00255 bool mDeleteDwBodyPart;
00256 KMMimePartTreeItem* mMimePartTreeItem;
00257 KMail::Interface::BodyPartMemento * mBodyPartMemento;
00258 };
00259
00260 #endif