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