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() const {
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 isToltecMessage() const;
00230
00231 bool hasContentDispositionInline() const;
00232
00233 QString contentTypeParameter( const char * name ) const;
00234
00235 const QString& trueFromAddress() const;
00236
00237 const partNode * topLevelParent() const;
00238 partNode * parentNode() const { return mRoot; }
00239 partNode * nextSibling() const { return mNext; }
00240 partNode * firstChild() const { return mChild; }
00241 partNode * next( bool allowChildren=true ) const;
00242 int childCount() const;
00243 int totalChildCount() const;
00244 bool processed() const { return mWasProcessed; }
00245
00246 KMail::Interface::BodyPartMemento * bodyPartMemento( const QCString & which ) const;
00247 void setBodyPartMemento( const QCString & which, KMail::Interface::BodyPartMemento * memento );
00248
00249
00250
00251 bool isDisplayedEmbedded() const;
00252 void setDisplayedEmbedded( bool displayedEmbedded );
00253
00254
00255
00256 QString asHREF( const QString &place ) const;
00257
00258 private:
00259 KMReaderWin * reader() const {
00260 return mReader ? mReader : mRoot ? mRoot->reader() : 0 ;
00261 }
00262 KMail::Interface::BodyPartMemento * internalBodyPartMemento( const QCString & ) const;
00263 void internalSetBodyPartMemento( const QCString & which, KMail::Interface::BodyPartMemento * memento );
00264
00265 private:
00266 partNode* mRoot;
00267 partNode* mNext;
00268 partNode* mChild;
00269 bool mWasProcessed;
00270 private:
00271 DwBodyPart* mDwPart;
00272 mutable KMMessagePart mMsgPart;
00273 QCString mEncodedBody;
00274 QString mFromAddress;
00275 int mType;
00276 int mSubType;
00277 KMMsgEncryptionState mEncryptionState;
00278 KMMsgSignatureState mSignatureState;
00279 mutable bool mMsgPartOk;
00280 bool mEncodedOk;
00281 bool mDeleteDwBodyPart;
00282 KMMimePartTreeItem* mMimePartTreeItem;
00283 std::map<QCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00284 KMReaderWin * mReader;
00285 bool mDisplayedEmbedded;
00286 };
00287
00288 #endif
|