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
00081 struct AttachmentDisplayInfo
00082 {
00083 TQString label;
00084 TQString icon;
00085 bool displayInHeader;
00086 };
00087
00088 static partNode * fromMessage( const KMMessage * msg, KMReaderWin * win=0 );
00089
00090 partNode( bool deleteDwBodyPart,
00091 DwBodyPart* dwPart );
00092
00093 ~partNode();
00094
00095 void dump( int chars=0 ) const;
00096
00097 void buildObjectTree( bool processSiblings=true );
00098
00099 DwBodyPart* dwPart() const {
00100 return mDwPart;
00101 }
00102
00103 void setDwPart( DwBodyPart* part ) {
00104 mDwPart = part;
00105 mMsgPartOk = false;
00106 }
00107
00108 KMMessagePart& msgPart() const {
00109 if( !mMsgPartOk ) {
00110 KMMessage::bodyPart(mDwPart, &mMsgPart);
00111 mMsgPartOk = true;
00112 }
00113 return mMsgPart;
00114 }
00115
00116 const TQCString & encodedBody();
00117
00118 void setType( int type ) {
00119 mType = type;
00120 }
00121
00122 void setSubType( int subType ) {
00123 mSubType = subType;
00124 }
00125
00126 int type() const {
00127 return mType;
00128 }
00129
00130 TQCString typeString() const;
00131
00132 int subType() const {
00133 return mSubType;
00134 }
00135
00136 TQCString subTypeString() const;
00137
00138 bool hasType( int type ) {
00139 return mType == type;
00140 }
00141
00142 bool hasSubType( int subType ) {
00143 return mSubType == subType;
00144 }
00145
00146 void setEncryptionState( KMMsgEncryptionState state ) {
00147 mEncryptionState = state;
00148 }
00149 KMMsgEncryptionState encryptionState() const {
00150 return mEncryptionState;
00151 }
00152
00153
00154 KMMsgEncryptionState overallEncryptionState() const ;
00155
00156
00157 KMMsgSignatureState overallSignatureState() const ;
00158
00159 void setSignatureState( KMMsgSignatureState state ) {
00160 mSignatureState = state;
00161 }
00162 KMMsgSignatureState signatureState() const {
00163 return mSignatureState;
00164 }
00165
00166
00167
00168
00169 TQCString path() const;
00170
00171 int nodeId() const;
00172
00173 partNode* findId( int id );
00174
00175 partNode* findType( int type, int subType, bool deep=true, bool wide=true );
00176
00177 partNode* findTypeNot( int type, int subType, bool deep=true,
00178 bool wide=true );
00179
00180 partNode* findNodeForDwPart( DwBodyPart* part );
00181
00182 void fillMimePartTree( KMMimePartTreeItem* parentItem,
00183 KMMimePartTree* mimePartTree,
00184 TQString labelDescr = TQString(),
00185 TQString labelCntType = TQString(),
00186 TQString labelEncoding = TQString(),
00187 KIO::filesize_t size=0,
00188 bool revertOrder = false );
00189
00190 void adjustDefaultType( partNode* node );
00191
00192 void setNext( partNode* next ) {
00193 mNext = next;
00194 if( mNext ){
00195 mNext->mRoot = mRoot;
00196 adjustDefaultType( mNext );
00197 }
00198 }
00199
00200 void setFirstChild( partNode* child ) {
00201 mChild = child;
00202 if( mChild ) {
00203 mChild->mRoot = this;
00204 adjustDefaultType( mChild );
00205 }
00206 }
00207
00208 void setProcessed( bool processed, bool recurse ) {
00209 mWasProcessed = processed;
00210 if ( recurse ) {
00211 if( mChild )
00212 mChild->setProcessed( processed, true );
00213 if( mNext )
00214 mNext->setProcessed( processed, true );
00215 }
00216 }
00217
00218 void setMimePartTreeItem( KMMimePartTreeItem* item ) {
00219 mMimePartTreeItem = item;
00220 }
00221
00222 KMMimePartTreeItem* mimePartTreeItem() const {
00223 return mMimePartTreeItem;
00224 }
00225
00226 void setFromAddress( const TQString& address ) {
00227 mFromAddress = address;
00228 }
00229
00230 bool isAttachment() const;
00231 bool isHeuristicalAttachment() const;
00235 bool isFirstTextPart() const;
00236
00237 bool isToltecMessage() const;
00238
00242 bool isInEncapsulatedMessage() const;
00243
00244 bool hasContentDispositionInline() const;
00245
00246 TQString contentTypeParameter( const char * name ) const;
00247
00248 const TQString& trueFromAddress() const;
00249
00250 const partNode * topLevelParent() const;
00251 partNode * parentNode() const { return mRoot; }
00252 partNode * nextSibling() const { return mNext; }
00253 partNode * firstChild() const { return mChild; }
00254 partNode * next( bool allowChildren=true ) const;
00255 int childCount() const;
00256 int totalChildCount() const;
00257 bool processed() const { return mWasProcessed; }
00258
00259 KMail::Interface::BodyPartMemento * bodyPartMemento( const TQCString & which ) const;
00260 void setBodyPartMemento( const TQCString & which, KMail::Interface::BodyPartMemento * memento );
00261
00262
00263
00264 bool isDisplayedEmbedded() const;
00265 void setDisplayedEmbedded( bool displayedEmbedded );
00266
00267
00268 bool isDisplayedHidden() const;
00269 void setDisplayedHidden( bool displayedHidden );
00270
00271
00272
00273 TQString asHREF( const TQString &place ) const;
00274
00275 AttachmentDisplayInfo attachmentDisplayInfo() const;
00276
00277 private:
00278 KMReaderWin * reader() const {
00279 return mReader ? mReader : mRoot ? mRoot->reader() : 0 ;
00280 }
00281 KMail::Interface::BodyPartMemento * internalBodyPartMemento( const TQCString & ) const;
00282 void internalSetBodyPartMemento( const TQCString & which, KMail::Interface::BodyPartMemento * memento );
00283
00284 private:
00285 partNode* mRoot;
00286 partNode* mNext;
00287 partNode* mChild;
00288 bool mWasProcessed;
00289 private:
00290 DwBodyPart* mDwPart;
00291 mutable KMMessagePart mMsgPart;
00292 TQCString mEncodedBody;
00293 TQString mFromAddress;
00294 int mType;
00295 int mSubType;
00296 KMMsgEncryptionState mEncryptionState;
00297 KMMsgSignatureState mSignatureState;
00298 mutable bool mMsgPartOk;
00299 bool mEncodedOk;
00300 bool mDeleteDwBodyPart;
00301 KMMimePartTreeItem* mMimePartTreeItem;
00302 std::map<TQCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
00303 KMReaderWin * mReader;
00304 bool mDisplayedEmbedded;
00305 bool mDisplayedHidden;
00306 };
00307
00308 #endif
|