1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
/* -*- c++ -*-
partNode.h A node in a MIME tree.
This file is part of KMail, the KDE mail client.
Copyright (c) 2002,2004 Klar�lvdalens Datakonsult AB
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
KMail is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the TQt library by Trolltech AS, Norway (or with modified versions
of TQt that use the same license as TQt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
TQt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef PARTNODE_H
#define PARTNODE_H
#include "kmmsgpart.h"
#include "kmmsgbase.h"
#include "kmmessage.h"
#include "interfaces/bodypart.h"
#include <mimelib/mimepp.h>
#include <mimelib/body.h>
#include <mimelib/utility.h>
#include <kio/global.h>
#include <kdebug.h>
#include <map>
class KMMimePartTreeItem;
class KMMimePartTree;
class KMReaderWin;
/*
===========================================================================
S T A R T O F T E M P O R A R Y M I M E C O D E
===========================================================================
N O T E : The partNode structure will most likely be replaced by KMime.
It's purpose: Speed optimization for KDE 3. (khz, 28.11.01)
===========================================================================
*/
class partNode
{
partNode();
int calcNodeIdOrFindNode( int& curId, const partNode* calcNode,
int findId, partNode** findNode );
partNode( KMReaderWin * win, DwBodyPart* dwPart,
int explicitType = DwMime::kTypeUnknown,
int explicitSubType = DwMime::kSubtypeUnknown,
bool deleteDwBodyPart = false );
public:
struct AttachmentDisplayInfo
{
TQString label;
TQString icon;
bool displayInHeader;
};
static partNode * fromMessage( const KMMessage * msg, KMReaderWin * win=0 );
partNode( bool deleteDwBodyPart,
DwBodyPart* dwPart );
~partNode();
void dump( int chars=0 ) const;
void buildObjectTree( bool processSiblings=true );
DwBodyPart* dwPart() const {
return mDwPart;
}
void setDwPart( DwBodyPart* part ) {
mDwPart = part;
mMsgPartOk = false;
}
KMMessagePart& msgPart() const {
if( !mMsgPartOk ) {
KMMessage::bodyPart(mDwPart, &mMsgPart);
mMsgPartOk = true;
}
return mMsgPart;
}
const TQCString & encodedBody();
void setType( int type ) {
mType = type;
}
void setSubType( int subType ) {
mSubType = subType;
}
int type() const {
return mType;
}
TQCString typeString() const;
int subType() const {
return mSubType;
}
TQCString subTypeString() const;
bool hasType( int type ) {
return mType == type;
}
bool hasSubType( int subType ) {
return mSubType == subType;
}
void setEncryptionState( KMMsgEncryptionState state ) {
mEncryptionState = state;
}
KMMsgEncryptionState encryptionState() const {
return mEncryptionState;
}
// look at the encryption states of all children and return result
KMMsgEncryptionState overallEncryptionState() const ;
// look at the signature states of all children and return result
KMMsgSignatureState overallSignatureState() const ;
void setSignatureState( KMMsgSignatureState state ) {
mSignatureState = state;
}
KMMsgSignatureState signatureState() const {
return mSignatureState;
}
// path is a hierarchical path to this partNode. It is designed to
// be stable under decryption, where new child nodes are
// added. Treat it as an opaque string.
TQCString path() const;
int nodeId() const; // node ids start at 1 (this is the top level root node)
partNode* findId( int id ); // returns the node which has the given id (or 0, resp.)
partNode* findType( int type, int subType, bool deep=true, bool wide=true );
partNode* findTypeNot( int type, int subType, bool deep=true,
bool wide=true );
partNode* findNodeForDwPart( DwBodyPart* part );
void fillMimePartTree( KMMimePartTreeItem* parentItem,
KMMimePartTree* mimePartTree,
TQString labelDescr = TQString(),
TQString labelCntType = TQString(),
TQString labelEncoding = TQString(),
KIO::filesize_t size=0,
bool revertOrder = false );
void adjustDefaultType( partNode* node );
void setNext( partNode* next ) {
mNext = next;
if( mNext ){
mNext->mRoot = mRoot;
adjustDefaultType( mNext );
}
}
void setFirstChild( partNode* child ) {
mChild = child;
if( mChild ) {
mChild->mRoot = this;
adjustDefaultType( mChild );
}
}
void setProcessed( bool processed, bool recurse ) {
mWasProcessed = processed;
if ( recurse ) {
if( mChild )
mChild->setProcessed( processed, true );
if( mNext )
mNext->setProcessed( processed, true );
}
}
void setMimePartTreeItem( KMMimePartTreeItem* item ) {
mMimePartTreeItem = item;
}
KMMimePartTreeItem* mimePartTreeItem() const {
return mMimePartTreeItem;
}
void setFromAddress( const TQString& address ) {
mFromAddress = address;
}
bool isAttachment() const;
bool isHeuristicalAttachment() const;
/** returns true if this is the first text part of the message this node
is a body part of
*/
bool isFirstTextPart() const;
bool isToltecMessage() const;
/**
* @return true if this node is a child or an encapsulated message
*/
bool isInEncapsulatedMessage() const;
bool hasContentDispositionInline() const;
TQString contentTypeParameter( const char * name ) const;
const TQString& trueFromAddress() const;
const partNode * topLevelParent() const;
partNode * parentNode() const { return mRoot; }
partNode * nextSibling() const { return mNext; }
partNode * firstChild() const { return mChild; }
partNode * next( bool allowChildren=true ) const;
int childCount() const;
int totalChildCount() const;
bool processed() const { return mWasProcessed; }
KMail::Interface::BodyPartMemento * bodyPartMemento( const TQCString & which ) const;
void setBodyPartMemento( const TQCString & which, KMail::Interface::BodyPartMemento * memento );
// A flag to remember if the node was embedded. This is useful for attachment nodes, the reader
// needs to know if they were displayed inline or not.
bool isDisplayedEmbedded() const;
void setDisplayedEmbedded( bool displayedEmbedded );
// Same as above, but this time determines if the node was hidden or not
bool isDisplayedHidden() const;
void setDisplayedHidden( bool displayedHidden );
// Get a href in the form attachment:<nodeId>?place=<place>, used by ObjectTreeParser and
// UrlHandlerManager.
TQString asHREF( const TQString &place ) const;
AttachmentDisplayInfo attachmentDisplayInfo() const;
private:
KMReaderWin * reader() const {
return mReader ? mReader : mRoot ? mRoot->reader() : 0 ;
}
KMail::Interface::BodyPartMemento * internalBodyPartMemento( const TQCString & ) const;
void internalSetBodyPartMemento( const TQCString & which, KMail::Interface::BodyPartMemento * memento );
private:
partNode* mRoot;
partNode* mNext;
partNode* mChild;
bool mWasProcessed; // to be used by parseObjectTree()
private:
DwBodyPart* mDwPart; // may be zero
mutable KMMessagePart mMsgPart; // is valid - even if mDwPart is zero
TQCString mEncodedBody;
TQString mFromAddress;
int mType;
int mSubType;
KMMsgEncryptionState mEncryptionState;
KMMsgSignatureState mSignatureState;
mutable bool mMsgPartOk;
bool mEncodedOk;
bool mDeleteDwBodyPart;
KMMimePartTreeItem* mMimePartTreeItem;
std::map<TQCString,KMail::Interface::BodyPartMemento*> mBodyPartMementoMap;
KMReaderWin * mReader;
bool mDisplayedEmbedded;
bool mDisplayedHidden;
};
#endif
|