|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __CIMAPBODYSTRUCTURE_H__ |
|
17 #define __CIMAPBODYSTRUCTURE_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 class CImapEnvelope; |
|
22 |
|
23 /** |
|
24 Represents an IMAP body structure as a tree. |
|
25 |
|
26 The iEmbeddedBodyStructureList allows body structure to contain embedded body structures, |
|
27 as is required for multi-part and message/rfc822 type bodystructures. |
|
28 |
|
29 iEmbeddedBodyStructureList owns the bodystructure objects it points to, and a CImapFetchResponse |
|
30 object owns the root CImapBodyStructure that represents the entire body structure tree. |
|
31 |
|
32 Consequentl, destroying the root CImapBodyStructure owned by CImapFetchResponse will cause the entire |
|
33 tree of CImapBodyStructure objects to be destroyed. |
|
34 |
|
35 |
|
36 This class provides a set of TPtrC8 items each of which will be set to point at the correct |
|
37 part of the incoming message during parsing. |
|
38 |
|
39 This class does not own the data that it points to. So the TPtrC8 items will only be valid |
|
40 while the HBufC8 buffer they are pointing to is valid. |
|
41 |
|
42 Consequently, this class should be used in conjunction with a valid HBufC8 object. |
|
43 This object is owned by CImapFetchResponse, which also owns the root CImapBodyStructure object. |
|
44 |
|
45 The following is a visual guide to bodystructures. |
|
46 A formal definition of bodystructure can be found in Section 9 of RFC 3501. |
|
47 The second line of each category below indicates "extension data". |
|
48 |
|
49 bodyTypeMpart |
|
50 ((-body-)(-body-)(-body-) "MIXED" |
|
51 (n1 v1 n2 v2) (dispname (n1 v1 n2 v2)) extLang extLocation xExt1...) |
|
52 |
|
53 bodyTypeText: all TEXT types |
|
54 ("TEXT" "PLAIN" (n1 v1 n2 v2) id "description" "encoding" "size" lines |
|
55 extMD5 (dispname (n1 v1 n2 v2)) extLang extLocation xExt1...) |
|
56 |
|
57 bodyTypeMsg: only MESSAGE/RFC822 |
|
58 ("MESSAGE" "RFC822" (n1 v1 n2 v2) "id" "description" "encoding" "size" (-envelope-) (-body-) lines |
|
59 extMD5 (dispname (n1 v1 n2 v2)) extLang extLocation xExt1...) |
|
60 |
|
61 bodyTypeBasic: all other forms of bodyType1part |
|
62 ("OTHER" "SUB" (n1 v1 n2 v2) "id" "description" "encoding" "size" |
|
63 extMD5 (dispname (n1 v1 n2 v2)) extLang extLocation xExt1...) |
|
64 |
|
65 ---------------- |
|
66 envelope |
|
67 (date subject from (sender1 sender2) (replyTo1 replyTo2) (to1 to2) (cc1 cc2) (bcc1 bcc2) inReplyTo MessageId) |
|
68 |
|
69 @internalTechnology |
|
70 @prototype |
|
71 */ |
|
72 class CImapBodyStructure : public CBase |
|
73 { |
|
74 public: |
|
75 |
|
76 /** |
|
77 The type of this bodystructure. |
|
78 RFC3501 defines four bodystructure types. |
|
79 For each type, a different set of CImapBodyStructure fields will be valid. |
|
80 */ |
|
81 enum TBodyStructureType |
|
82 { |
|
83 /** |
|
84 This is the default type for a bodystructure. It is the type given to all |
|
85 bodystructures that are not rfc822, text or multipart. Typically, this will |
|
86 be used for attachments. |
|
87 It has no embedded bodystructures, no envelope and BodyLines value. All other fields are valid. |
|
88 In RFC3501, this is "body-type-basic" |
|
89 */ |
|
90 ETypeBasic, |
|
91 /** |
|
92 A message with MIME type and subtype "MESSAGE/RFC822", representing a MIME |
|
93 header for an embedded message. |
|
94 All CImapBodyStructure fields are valid, including the envelope. |
|
95 There will be exactly one embedded bodystructure. |
|
96 In RFC3501, this is "body-type-msg" |
|
97 */ |
|
98 ETypeMessageRfc822, |
|
99 /** |
|
100 This is a message whose MIME type is "TEXT" together with and MIME subtype. |
|
101 This represents a text message. |
|
102 It has no embedded bodystructures and no envelope. All other fields are valid. |
|
103 In RFC3501, this is "body-type-text" |
|
104 */ |
|
105 ETypeText, |
|
106 /** |
|
107 This is a multipart message, with one or more embedded bodystructures. |
|
108 It has no envelope, and none of the following fields are valid: |
|
109 > BodyId |
|
110 > BodyDescription |
|
111 > BodyEncoding |
|
112 > BodySizeOctets |
|
113 > BodyLines |
|
114 All other fields are valid |
|
115 In RFC3501, this is "body-type-mpart" |
|
116 */ |
|
117 ETypeMultipart |
|
118 }; |
|
119 |
|
120 /** |
|
121 Maps an attribute name to a value |
|
122 @internalTechnology |
|
123 @prototype |
|
124 */ |
|
125 struct TAttributeValuePair |
|
126 { |
|
127 TPtrC8 iAttribute; |
|
128 TPtrC8 iValue; |
|
129 }; |
|
130 |
|
131 /** |
|
132 An array of pointers to CImapBodyStructure structure objects. |
|
133 */ |
|
134 typedef RPointerArray<CImapBodyStructure> RBodyStructureList; |
|
135 /** |
|
136 An array of attribute-value pairs. |
|
137 */ |
|
138 typedef RArray<TAttributeValuePair> RAttributeValuePairList; |
|
139 /** |
|
140 An array of 8-bit pointer-descriptors. |
|
141 */ |
|
142 typedef RArray<TPtrC8> RArrayTPtrC8; |
|
143 |
|
144 IMPORT_C TBodyStructureType BodyStructureType() const; |
|
145 IMPORT_C const RBodyStructureList EmbeddedBodyStructureList() const; |
|
146 |
|
147 IMPORT_C const TDesC8& Type() const; |
|
148 IMPORT_C const TDesC8& SubType() const; |
|
149 |
|
150 IMPORT_C const RAttributeValuePairList& ParameterList() const; |
|
151 |
|
152 IMPORT_C const TDesC8& BodyId() const; |
|
153 IMPORT_C const TDesC8& BodyDescription() const; |
|
154 IMPORT_C const TDesC8& BodyEncoding() const; |
|
155 IMPORT_C const TDesC8& BodySizeOctets() const; |
|
156 IMPORT_C const TDesC8& BodyLines() const; |
|
157 |
|
158 IMPORT_C const TDesC8& ExtMD5() const; |
|
159 IMPORT_C const TDesC8& ExtDispositionName() const; |
|
160 IMPORT_C const RAttributeValuePairList& ExtDispositionParameterList() const; |
|
161 IMPORT_C const RArrayTPtrC8& ExtLanguageList() const; |
|
162 IMPORT_C const TDesC8& ExtLocation() const; |
|
163 |
|
164 IMPORT_C CImapEnvelope& GetRfc822EnvelopeStructureL(); |
|
165 |
|
166 static CImapBodyStructure* NewL(); |
|
167 ~CImapBodyStructure(); |
|
168 |
|
169 void SetBodyStructureType(TBodyStructureType aBodyStructureType); |
|
170 void AppendEmbeddedBodyStructureL(const CImapBodyStructure& aBodyStructure); |
|
171 |
|
172 void SetType(const TDesC8& aType); |
|
173 void SetSubType(const TDesC8& aSubType); |
|
174 |
|
175 void AppendParameterListL(const TAttributeValuePair& aAttributeValuePair); |
|
176 |
|
177 void SetBodyId(const TDesC8& aBodyId); |
|
178 void SetBodyDescription(const TDesC8& aBodyDescription); |
|
179 void SetBodyEncoding(const TDesC8& aBodyEncoding); |
|
180 void SetBodySizeOctets(const TDesC8& aBodySizeOctets); |
|
181 void SetBodyLines(const TDesC8& aBodyLines); |
|
182 |
|
183 void SetExtMD5(const TDesC8& aExtMD5); |
|
184 void SetExtDispositionName(const TDesC8& aExtDispositionName); |
|
185 void AppendExtDispositionParameterListL(const TAttributeValuePair& aAttributeValuePair); |
|
186 void AppendExtLanguageListL(const TDesC8& aExtLanguage); |
|
187 void SetExtLocation(const TDesC8& aExtLocation); |
|
188 |
|
189 private: |
|
190 CImapBodyStructure(); |
|
191 |
|
192 private: |
|
193 /** |
|
194 The type of this bodystructure. |
|
195 It can be a Basic, Text, Message/Rfc822 or Multipart bodystructure. |
|
196 Each type is defined in section 9 of RFC3501. |
|
197 */ |
|
198 TBodyStructureType iBodyStructureType; |
|
199 |
|
200 /** |
|
201 For Multipart bodystructures, pointers to CBodyStructure objects representing each of the sub-parts is stored in the array |
|
202 For MESSAGE/RFC822, a single pointer to a single CBodyStructure object representing the embedded sub-part is store in the array. |
|
203 For Basic and Text bodystructures, this array will be empty. |
|
204 This pointer array takes ownership of the objects it points to. |
|
205 */ |
|
206 RBodyStructureList iEmbeddedBodyStructureList; |
|
207 |
|
208 /** |
|
209 The MIME type for this message part |
|
210 When body-type-mpart detected, this is set to "MULTIPART" |
|
211 */ |
|
212 TPtrC8 iType; |
|
213 /** |
|
214 The MIME sub-type for this message part |
|
215 */ |
|
216 TPtrC8 iSubType; |
|
217 |
|
218 /** |
|
219 A list of parameter-value pairs. |
|
220 Corresponds to a top level "body-fld-param" (i.e. not "body-fld-dsp" which is stored in iExtDispositionParameterList) |
|
221 */ |
|
222 RAttributeValuePairList iParameterList; |
|
223 |
|
224 // single-part data |
|
225 /** |
|
226 Corresponds to "body-fld-id" of RFC3501 |
|
227 */ |
|
228 TPtrC8 iBodyId; |
|
229 /** |
|
230 Corresponds to "body-fld-desc" of RFC3501 |
|
231 */ |
|
232 TPtrC8 iBodyDescription; |
|
233 /** |
|
234 Corresponds to "body-fld-enc" of RFC3501 |
|
235 */ |
|
236 TPtrC8 iBodyEncoding; |
|
237 /** |
|
238 Corresponds to "body-fld-octets" of RFC3501 |
|
239 */ |
|
240 TPtrC8 iBodySizeOctets; |
|
241 |
|
242 /** |
|
243 Corresponds to "body-fld-lines" of RFC3501 |
|
244 */ |
|
245 TPtrC8 iBodyLines; |
|
246 |
|
247 // extension data |
|
248 /** |
|
249 Corresponds to "body-fld-md5" of RFC3501 |
|
250 NOTE: This extension data item only applies to single-part structures |
|
251 */ |
|
252 TPtrC8 iExtMD5; |
|
253 /** |
|
254 A list of parameter-value pairs. |
|
255 Corresponds to the "string" part of "body-fld-dsp" of RFC3501 |
|
256 */ |
|
257 TPtrC8 iExtDispositionName; |
|
258 /** |
|
259 |
|
260 Corresponds to the "body-fld-param" in "body-fld-dsp" of RFC3501 |
|
261 */ |
|
262 RAttributeValuePairList iExtDispositionParameterList; |
|
263 /** |
|
264 A list of strings each representing a language |
|
265 Corresponds to "body-fld-lang" of RFC3501 |
|
266 */ |
|
267 RArrayTPtrC8 iExtLanguageList; |
|
268 /** |
|
269 Corresponds to "body-fld-loc" of RFC3501 |
|
270 */ |
|
271 TPtrC8 iExtLocation; |
|
272 |
|
273 // Note "future expansion" extension data is ignored safely by the parser. |
|
274 |
|
275 private: |
|
276 /** |
|
277 If the bodystructure has an envelope (i.e. it is of type MESSAGE/RFC822) |
|
278 then a CImapEnvelope will be required to point to envelope items. |
|
279 GetRfc822EnvelopeStructureL() will construct an object of this type when first called. |
|
280 It is likely that CImapEnvelope will later be used to populate CImMimeHeader - which will cause string copies to occur. |
|
281 */ |
|
282 CImapEnvelope* iRfc822EnvelopeStructure; |
|
283 }; |
|
284 |
|
285 #endif // __CIMAPBODYSTRUCTURE_H__ |