|
1 // Copyright (c) 2004-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 #include <badesca.h> |
|
17 #include <s32mem.h> |
|
18 |
|
19 #include <cmsvmimeheaders.h> |
|
20 #include <cmsvattachment.h> |
|
21 |
|
22 const TUid KUidMimeHeaders = {0x10204281}; |
|
23 const TInt KDesCArrayGranularity = 8; |
|
24 const TInt KStreamBufferGranularity = 512; |
|
25 |
|
26 _LIT8(KTxtWildcardBase64, "*base64*"); |
|
27 _LIT8(KTxtWildcardQP, "*quoted-printable*"); |
|
28 _LIT8(KTxtWildcard7Bit, "*7bit*"); |
|
29 _LIT8(KTxtWildcard8Bit, "*8bit*"); |
|
30 _LIT8(KTxtWildcardBinary, "*binary*"); |
|
31 _LIT8(KTxtWildcardUU, "*uu*"); |
|
32 |
|
33 /** |
|
34 Standard 2-phase construction, creates the mime headers object. |
|
35 |
|
36 Creates and initailises the mime headers with no data. |
|
37 |
|
38 @return Pointer to the created mime headers object. |
|
39 */ |
|
40 EXPORT_C CMsvMimeHeaders* CMsvMimeHeaders::NewL() |
|
41 { |
|
42 CMsvMimeHeaders* self = NewLC(); |
|
43 CleanupStack::Pop(self); |
|
44 return self; |
|
45 } |
|
46 |
|
47 /** |
|
48 Standard 2-phase construction, creates the mime headers object. |
|
49 |
|
50 Creates and initailises the mime headers with no data. Leaves a pointer on the |
|
51 cleanup stack. |
|
52 |
|
53 @return Pointer to the created mime headers object. |
|
54 */ |
|
55 EXPORT_C CMsvMimeHeaders* CMsvMimeHeaders::NewLC() |
|
56 { |
|
57 CMsvMimeHeaders* self = new(ELeave) CMsvMimeHeaders(); |
|
58 CleanupStack::PushL(self); |
|
59 self->ConstructL(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 CMsvMimeHeaders::CMsvMimeHeaders() |
|
64 { |
|
65 } |
|
66 |
|
67 void CMsvMimeHeaders::ConstructL() |
|
68 { |
|
69 iContentTypeParams = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); |
|
70 iContentDispositionParams = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); |
|
71 iXTypeParams = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); |
|
72 } |
|
73 |
|
74 /** |
|
75 Standard destructor. |
|
76 */ |
|
77 EXPORT_C CMsvMimeHeaders::~CMsvMimeHeaders() |
|
78 { |
|
79 Reset(); |
|
80 delete iContentTypeParams; |
|
81 delete iContentDispositionParams; |
|
82 delete iXTypeParams; |
|
83 } |
|
84 |
|
85 /** |
|
86 Resets the mime headers. |
|
87 |
|
88 Resets and removes all the mime headers and data that has been set. |
|
89 */ |
|
90 EXPORT_C void CMsvMimeHeaders::Reset() |
|
91 { |
|
92 delete iContentDescription; |
|
93 iContentDescription = NULL; |
|
94 delete iContentBase; |
|
95 iContentBase = NULL; |
|
96 delete iContentLocation; |
|
97 iContentLocation = NULL; |
|
98 delete iContentId; |
|
99 iContentId = NULL; |
|
100 delete iContentType; |
|
101 iContentType = NULL; |
|
102 delete iContentSubType; |
|
103 iContentSubType = NULL; |
|
104 delete iContentDisposition; |
|
105 iContentDisposition = NULL; |
|
106 iContentTypeParams->Reset(); |
|
107 iContentDispositionParams->Reset(); |
|
108 iXTypeParams->Reset(); |
|
109 iMimeCharset = 0; |
|
110 delete iSuggestedFilename; |
|
111 iSuggestedFilename = NULL; |
|
112 delete iRelativePath; |
|
113 iRelativePath = NULL; |
|
114 iContentTransferEncoding = EEncodingTypeUnknown; |
|
115 } |
|
116 |
|
117 /** |
|
118 Returns the size of all the mime header data. |
|
119 |
|
120 Returns the approximate size in bytes of all the mime header data |
|
121 stored by this object. The returned value is a sum of the lengths |
|
122 of all the string data and the size of an integer for each integer |
|
123 type data. |
|
124 |
|
125 @return The size in bytes of all the mime header data. |
|
126 */ |
|
127 EXPORT_C TInt CMsvMimeHeaders::Size() const |
|
128 { |
|
129 TInt size = 0; |
|
130 size += ContentDescription().Length(); |
|
131 size += ContentBase().Length(); |
|
132 size += ContentLocation().Length(); |
|
133 size += ContentId().Length(); |
|
134 size += ContentType().Length(); |
|
135 size += ContentSubType().Length(); |
|
136 size += ContentDisposition().Length(); |
|
137 |
|
138 TInt ii; |
|
139 for( ii=0; ii<ContentTypeParams().Count(); ++ii ) |
|
140 size += ContentTypeParams()[ii].Length(); |
|
141 |
|
142 for( ii=0; ii<ContentDispositionParams().Count(); ++ii ) |
|
143 size += ContentDispositionParams()[ii].Length(); |
|
144 |
|
145 for( ii=0; ii<XTypeParams().Count(); ++ii ) |
|
146 size += XTypeParams()[ii].Length(); |
|
147 |
|
148 size += sizeof(TUint); // for mime charset |
|
149 size += SuggestedFilename().Length(); |
|
150 size += RelativePath().Length(); |
|
151 size += sizeof(TMsvEncodingType); |
|
152 |
|
153 return size; |
|
154 } |
|
155 |
|
156 /** |
|
157 Stores the mime header data. |
|
158 |
|
159 Associated and stores all the mime header data stored in this object |
|
160 as an attribute of an attachment object. The RestoreL method should be |
|
161 used to restore the data from the attachment. |
|
162 |
|
163 @param aAttachment The attachment object to store the mime header data to. |
|
164 */ |
|
165 EXPORT_C void CMsvMimeHeaders::StoreL(CMsvAttachment& aAttachment) const |
|
166 { |
|
167 CBufFlat* streamBuffer = CBufFlat::NewL(KStreamBufferGranularity); |
|
168 CleanupStack::PushL(streamBuffer); |
|
169 RBufWriteStream writeStream(*streamBuffer); |
|
170 writeStream.PushL(); |
|
171 |
|
172 writeStream << ContentDescription(); |
|
173 writeStream << ContentBase(); |
|
174 writeStream << ContentLocation(); |
|
175 writeStream << ContentId(); |
|
176 writeStream << ContentType(); |
|
177 writeStream << ContentSubType(); |
|
178 writeStream << ContentDisposition(); |
|
179 |
|
180 TInt count = ContentTypeParams().Count(); |
|
181 writeStream.WriteInt32L(count); |
|
182 TInt ii; |
|
183 for( ii=0; ii<count; ++ii ) |
|
184 writeStream << ContentTypeParams()[ii]; |
|
185 |
|
186 count = ContentDispositionParams().Count(); |
|
187 writeStream.WriteInt32L(count); |
|
188 for( ii=0; ii<count; ++ii ) |
|
189 writeStream << ContentDispositionParams()[ii]; |
|
190 |
|
191 count = XTypeParams().Count(); |
|
192 writeStream.WriteInt32L(count); |
|
193 for( ii=0; ii<count; ++ii ) |
|
194 writeStream << XTypeParams()[ii]; |
|
195 |
|
196 writeStream.WriteUint32L(MimeCharset()); |
|
197 writeStream << SuggestedFilename(); |
|
198 writeStream << RelativePath(); |
|
199 writeStream.WriteUint32L(iContentTransferEncoding); |
|
200 |
|
201 writeStream.CommitL(); |
|
202 CleanupStack::PopAndDestroy(&writeStream); |
|
203 |
|
204 // set the headers as an attribute in the attachment |
|
205 aAttachment.SetDesC8AttributeL(KUidMimeHeaders, streamBuffer->Ptr(0)); |
|
206 CleanupStack::PopAndDestroy(streamBuffer); |
|
207 } |
|
208 |
|
209 /** |
|
210 Restores the mime header data. |
|
211 |
|
212 Restores all the mime header data from an existing attachment object. This |
|
213 restores mime headers that was stored using the StoreL method. If the |
|
214 attachment does not contain any mime headers, this object is reset. |
|
215 |
|
216 @param aAttachment The attachment object to restore the mime header data from. |
|
217 |
|
218 */ |
|
219 EXPORT_C void CMsvMimeHeaders::RestoreL(CMsvAttachment& aAttachment) |
|
220 { |
|
221 Reset(); |
|
222 |
|
223 TPtrC8 bufferPtr; |
|
224 TInt err = aAttachment.GetDesC8Attribute(KUidMimeHeaders, bufferPtr); |
|
225 if( err == KErrNone ) |
|
226 { |
|
227 RDesReadStream readStream(bufferPtr); |
|
228 readStream.PushL(); |
|
229 |
|
230 iContentDescription = HBufC8::NewL(readStream, KMaxTInt); |
|
231 iContentBase = HBufC8::NewL(readStream, KMaxTInt); |
|
232 iContentLocation = HBufC16::NewL(readStream, KMaxTInt); |
|
233 iContentId = HBufC8::NewL(readStream, KMaxTInt); |
|
234 iContentType = HBufC8::NewL(readStream, KMaxTInt); |
|
235 iContentSubType = HBufC8::NewL(readStream, KMaxTInt); |
|
236 iContentDisposition = HBufC8::NewL(readStream, KMaxTInt); |
|
237 |
|
238 TInt count = readStream.ReadInt32L(); |
|
239 TInt ii; |
|
240 HBufC8* desBuffer; |
|
241 for( ii=0; ii<count; ++ii ) |
|
242 { |
|
243 desBuffer = HBufC8::NewLC(readStream, KMaxTInt); |
|
244 ContentTypeParams().AppendL(*desBuffer); |
|
245 CleanupStack::PopAndDestroy(desBuffer); |
|
246 } |
|
247 |
|
248 count = readStream.ReadInt32L(); |
|
249 for( ii=0; ii<count; ++ii ) |
|
250 { |
|
251 desBuffer = HBufC8::NewLC(readStream, KMaxTInt); |
|
252 ContentDispositionParams().AppendL(*desBuffer); |
|
253 CleanupStack::PopAndDestroy(desBuffer); |
|
254 } |
|
255 |
|
256 count = readStream.ReadInt32L(); |
|
257 for( ii=0; ii<count; ++ii ) |
|
258 { |
|
259 desBuffer = HBufC8::NewLC(readStream, KMaxTInt); |
|
260 XTypeParams().AppendL(*desBuffer); |
|
261 CleanupStack::PopAndDestroy(desBuffer); |
|
262 } |
|
263 |
|
264 iMimeCharset = readStream.ReadUint32L(); |
|
265 iSuggestedFilename = HBufC16::NewL(readStream, KMaxTInt); |
|
266 iRelativePath = HBufC8::NewL(readStream, KMaxTInt); |
|
267 iContentTransferEncoding = static_cast<TMsvEncodingType>(readStream.ReadUint32L()); |
|
268 |
|
269 readStream.Close(); |
|
270 CleanupStack::PopAndDestroy(&readStream); |
|
271 } |
|
272 // else do nothing if not found |
|
273 } |
|
274 |
|
275 /** |
|
276 Sets the Content-Description mime header. |
|
277 |
|
278 Over-writes any existing data. |
|
279 |
|
280 @param aContentDescription Descriptor conatining the Content-Description mime header. |
|
281 */ |
|
282 EXPORT_C void CMsvMimeHeaders::SetContentDescriptionL(const TDesC8& aContentDescription) |
|
283 { |
|
284 delete iContentDescription; |
|
285 iContentDescription = aContentDescription.AllocL(); |
|
286 } |
|
287 |
|
288 /** |
|
289 Gets the Content-Description mime header. |
|
290 |
|
291 Returns a zero length descriptor if mime header not set. |
|
292 |
|
293 @return Descriptor containing the Content-Description mime header. Zero length |
|
294 if the mime header not set. |
|
295 */ |
|
296 EXPORT_C const TDesC8& CMsvMimeHeaders::ContentDescription() const |
|
297 { |
|
298 if( iContentDescription==NULL ) |
|
299 return KNullDesC8(); |
|
300 |
|
301 return *iContentDescription; |
|
302 } |
|
303 |
|
304 /** |
|
305 Sets the Content-Base mime header. |
|
306 |
|
307 Over-writes any existing data. |
|
308 |
|
309 @param aContentBase Descriptor conatining the Content-Base mime header. |
|
310 */ |
|
311 EXPORT_C void CMsvMimeHeaders::SetContentBaseL(const TDesC8& aContentBase) |
|
312 { |
|
313 delete iContentBase; |
|
314 iContentBase = aContentBase.AllocL(); |
|
315 } |
|
316 |
|
317 /** |
|
318 Gets the Content-Base mime header. |
|
319 |
|
320 Returns a zero length descriptor if mime header not set. |
|
321 |
|
322 @return Descriptor containing the Content-Base mime header. Zero length |
|
323 if the mime header not set. |
|
324 */ |
|
325 EXPORT_C const TDesC8& CMsvMimeHeaders::ContentBase() const |
|
326 { |
|
327 if( iContentBase==NULL) |
|
328 return KNullDesC8(); |
|
329 |
|
330 return *iContentBase; |
|
331 } |
|
332 |
|
333 /** |
|
334 Sets the Content-Location mime header. |
|
335 |
|
336 Over-writes any existing data. |
|
337 |
|
338 @param aContentLocation Descriptor conatining the Content-Base mime header. |
|
339 */ |
|
340 EXPORT_C void CMsvMimeHeaders::SetContentLocationL(const TDesC16& aContentLocation) |
|
341 { |
|
342 delete iContentLocation; |
|
343 iContentLocation = aContentLocation.AllocL(); |
|
344 } |
|
345 |
|
346 /** |
|
347 Gets the Content-Location mime header. |
|
348 |
|
349 Returns a zero length descriptor if mime header not set. |
|
350 |
|
351 @return Descriptor containing the Content-Location mime header. Zero length |
|
352 if the mime header not set. |
|
353 */ |
|
354 EXPORT_C const TDesC16& CMsvMimeHeaders::ContentLocation() const |
|
355 { |
|
356 if( iContentLocation==NULL ) |
|
357 return KNullDesC(); |
|
358 |
|
359 return *iContentLocation; |
|
360 } |
|
361 |
|
362 /** |
|
363 Sets the Content-Id mime header. |
|
364 |
|
365 Over-writes any existing data. |
|
366 |
|
367 @param aContentId Descriptor conatining the Content-Id mime header. |
|
368 */ |
|
369 EXPORT_C void CMsvMimeHeaders::SetContentIdL(const TDesC8& aContentId) |
|
370 { |
|
371 delete iContentId; |
|
372 iContentId = aContentId.AllocL(); |
|
373 } |
|
374 |
|
375 /** |
|
376 Gets the Content-Id mime header. |
|
377 |
|
378 Returns a zero length descriptor if mime header not set. |
|
379 |
|
380 @return Descriptor containing the Content-Id mime header. Zero length |
|
381 if the mime header not set. |
|
382 */ |
|
383 EXPORT_C const TDesC8& CMsvMimeHeaders::ContentId() const |
|
384 { |
|
385 if( iContentId==NULL ) |
|
386 return KNullDesC8(); |
|
387 |
|
388 return *iContentId; |
|
389 } |
|
390 |
|
391 /** |
|
392 Sets the Content-Type mime header. |
|
393 |
|
394 Over-writes any existing data. This mime header contains the beginning part of the |
|
395 mime-type, eg. the 'text' part of 'text/plain'. |
|
396 |
|
397 @param aContentType Descriptor conatining the Content-Type mime header. |
|
398 */ |
|
399 EXPORT_C void CMsvMimeHeaders::SetContentTypeL(const TDesC8& aContentType) |
|
400 { |
|
401 delete iContentType; |
|
402 iContentType = aContentType.AllocL(); |
|
403 } |
|
404 |
|
405 /** |
|
406 Gets the Content-Type mime header. |
|
407 |
|
408 Returns a zero length descriptor if mime header not set. This mime header contains |
|
409 the beginning part of the mime-type, eg. the 'text' part of 'text/plain'. |
|
410 |
|
411 @return Descriptor containing the Content-Type mime header. Zero length |
|
412 if the mime header not set. |
|
413 */ |
|
414 EXPORT_C const TDesC8& CMsvMimeHeaders::ContentType() const |
|
415 { |
|
416 if( iContentType==NULL ) |
|
417 return KNullDesC8(); |
|
418 |
|
419 return *iContentType; |
|
420 } |
|
421 |
|
422 /** |
|
423 Sets the Content-SubType mime header. |
|
424 |
|
425 Over-writes any existing data. This mime header contains the end part of the |
|
426 mime-type, eg. the 'plain' part of 'text/plain'. |
|
427 |
|
428 @param aContentSubType Descriptor conatining the Content-SubType mime header. |
|
429 */ |
|
430 EXPORT_C void CMsvMimeHeaders::SetContentSubTypeL(const TDesC8& aContentSubType) |
|
431 { |
|
432 delete iContentSubType; |
|
433 iContentSubType = aContentSubType.AllocL(); |
|
434 } |
|
435 |
|
436 /** |
|
437 Gets the Content-SubType mime header. |
|
438 |
|
439 Returns a zero length descriptor if mime header not set. This mime header contains |
|
440 the end part of the mime-type, eg. the 'plain' part of 'text/plain'. |
|
441 |
|
442 @return Descriptor containing the Content-SubType mime header. Zero length |
|
443 if the mime header not set. |
|
444 */ |
|
445 EXPORT_C const TDesC8& CMsvMimeHeaders::ContentSubType() const |
|
446 { |
|
447 if( iContentSubType==NULL ) |
|
448 return KNullDesC8(); |
|
449 |
|
450 return *iContentSubType; |
|
451 } |
|
452 |
|
453 /** |
|
454 Sets the Content-Disposition mime header. |
|
455 |
|
456 Over-writes any existing data. |
|
457 |
|
458 @param aContentId Descriptor conatining the Content-Disposition mime header. |
|
459 */ |
|
460 EXPORT_C void CMsvMimeHeaders::SetContentDispositionL(const TDesC8& aContentDisposition) |
|
461 { |
|
462 delete iContentDisposition; |
|
463 iContentDisposition = aContentDisposition.AllocL(); |
|
464 } |
|
465 |
|
466 /** |
|
467 Gets the Content-Disposition mime header. |
|
468 |
|
469 Returns a zero length descriptor if mime header not set. |
|
470 |
|
471 @return Descriptor containing the Content-Disposition mime header. Zero length |
|
472 if the mime header not set. |
|
473 */ |
|
474 EXPORT_C const TDesC8& CMsvMimeHeaders::ContentDisposition() const |
|
475 { |
|
476 if( iContentDisposition==NULL ) |
|
477 return KNullDesC8(); |
|
478 |
|
479 return *iContentDisposition; |
|
480 } |
|
481 |
|
482 /** |
|
483 Returns a modifiable descriptor array containing the Content-Type parameters. |
|
484 |
|
485 @return A modifiable descriptor array. |
|
486 */ |
|
487 EXPORT_C CDesC8Array& CMsvMimeHeaders::ContentTypeParams() |
|
488 { |
|
489 return *iContentTypeParams; |
|
490 } |
|
491 |
|
492 /** |
|
493 Returns a modifiable descriptor array containing the Content-Disposition parameters. |
|
494 |
|
495 @return A modifiable descriptor array. |
|
496 */ |
|
497 EXPORT_C CDesC8Array& CMsvMimeHeaders::ContentDispositionParams() |
|
498 { |
|
499 return *iContentDispositionParams; |
|
500 } |
|
501 |
|
502 /** |
|
503 Returns a modifiable descriptor array containing the X-Type parameters. |
|
504 |
|
505 @return A modifiable descriptor array. |
|
506 */ |
|
507 EXPORT_C const CDesC8Array& CMsvMimeHeaders::XTypeParams() const |
|
508 { |
|
509 return *iXTypeParams; |
|
510 } |
|
511 |
|
512 /** |
|
513 Returns a non-modifiable descriptor array containing the Content-Type parameters. |
|
514 |
|
515 @return A non-modifiable descriptor array. |
|
516 */ |
|
517 EXPORT_C const CDesC8Array& CMsvMimeHeaders::ContentTypeParams() const |
|
518 { |
|
519 return *iContentTypeParams; |
|
520 } |
|
521 |
|
522 /** |
|
523 Returns a non-modifiable descriptor array containing the Content-Disposition parameters. |
|
524 |
|
525 @return A non-modifiable descriptor array. |
|
526 */ |
|
527 EXPORT_C const CDesC8Array& CMsvMimeHeaders::ContentDispositionParams() const |
|
528 { |
|
529 return *iContentDispositionParams; |
|
530 } |
|
531 |
|
532 /** |
|
533 Returns a non-modifiable descriptor array containing the X-Type parameters. |
|
534 |
|
535 @return A non-modifiable descriptor array. |
|
536 */ |
|
537 EXPORT_C CDesC8Array& CMsvMimeHeaders::XTypeParams() |
|
538 { |
|
539 return *iXTypeParams; |
|
540 } |
|
541 |
|
542 /** |
|
543 Sets the mime charset header. |
|
544 |
|
545 Over-writes any existing data. |
|
546 |
|
547 @param Integer representing the mime charset. |
|
548 */ |
|
549 EXPORT_C void CMsvMimeHeaders::SetMimeCharset(TUint aMimeCharset) |
|
550 { |
|
551 iMimeCharset = aMimeCharset; |
|
552 } |
|
553 |
|
554 /** |
|
555 Gets the mime charset header. |
|
556 |
|
557 @return An integer representing the mime charset. |
|
558 */ |
|
559 EXPORT_C TUint CMsvMimeHeaders::MimeCharset() const |
|
560 { |
|
561 return iMimeCharset; |
|
562 } |
|
563 |
|
564 /** |
|
565 Sets the suggested filename mime header. |
|
566 |
|
567 Over-writes any existing data. |
|
568 |
|
569 @param aSuggestedFilename Descriptor containing the suggested filename mime header data. |
|
570 */ |
|
571 EXPORT_C void CMsvMimeHeaders::SetSuggestedFilenameL(const TDesC16& aSuggestedFilename) |
|
572 { |
|
573 delete iSuggestedFilename; |
|
574 iSuggestedFilename = aSuggestedFilename.AllocL(); |
|
575 } |
|
576 |
|
577 /** |
|
578 Gets the suggested filename mime header. |
|
579 |
|
580 Returns a zero length descriptor if header is not set. |
|
581 |
|
582 @return Descriptor containing the suggested filename mime header. Zero length |
|
583 if the header not set. |
|
584 */ |
|
585 EXPORT_C const TDesC16& CMsvMimeHeaders::SuggestedFilename() const |
|
586 { |
|
587 if( iSuggestedFilename==NULL ) |
|
588 return KNullDesC(); |
|
589 |
|
590 return *iSuggestedFilename; |
|
591 } |
|
592 |
|
593 /** |
|
594 Sets the relative path header. |
|
595 |
|
596 Over-writes any existing data. |
|
597 |
|
598 @param aSuggestedFilename Descriptor containing the suggested filename header data. |
|
599 */ |
|
600 EXPORT_C void CMsvMimeHeaders::SetRelativePathL(const TDesC8& aRelativePath) |
|
601 { |
|
602 delete iRelativePath; |
|
603 iRelativePath = aRelativePath.AllocL(); |
|
604 } |
|
605 |
|
606 /** |
|
607 Gets the relative path mime header. |
|
608 |
|
609 Returns a zero length descriptor if header is not set. |
|
610 |
|
611 @return Descriptor containing the relative path mime header. Zero length |
|
612 if the header not set. |
|
613 */ |
|
614 EXPORT_C const TDesC8& CMsvMimeHeaders::RelativePath() const |
|
615 { |
|
616 if( iRelativePath==NULL ) |
|
617 return KNullDesC8(); |
|
618 |
|
619 return *iRelativePath; |
|
620 } |
|
621 |
|
622 /** |
|
623 Sets the Content-Transfer Encoding mime header. |
|
624 |
|
625 Over-writes any existing data. |
|
626 |
|
627 @param aEncodingType Descriptor conatining the Content-Transfer Encoding mime header. |
|
628 */ |
|
629 EXPORT_C void CMsvMimeHeaders::SetContentTransferEncoding(const TDesC8& aEncodingType) |
|
630 { |
|
631 iContentTransferEncoding = EEncodingTypeUnknown; |
|
632 |
|
633 if (KErrNone==aEncodingType.MatchF(KTxtWildcardBase64)) |
|
634 iContentTransferEncoding = EEncodingTypeBASE64; |
|
635 else if (KErrNone==aEncodingType.MatchF(KTxtWildcardQP)) |
|
636 iContentTransferEncoding = EEncodingTypeQP; |
|
637 else if (KErrNone==aEncodingType.MatchF(KTxtWildcard7Bit)) |
|
638 iContentTransferEncoding = EEncodingType7Bit; |
|
639 else if (KErrNone==aEncodingType.MatchF(KTxtWildcard8Bit)) |
|
640 iContentTransferEncoding = EEncodingType8Bit; |
|
641 else if (KErrNone==aEncodingType.MatchF(KTxtWildcardBinary)) |
|
642 iContentTransferEncoding = EEncodingTypeBinary; |
|
643 else if (KErrNone==aEncodingType.MatchF(KTxtWildcardUU)) // can't be right - there's no MIME standard text to describe UU is there?? |
|
644 iContentTransferEncoding = EEncodingTypeUU; |
|
645 } |
|
646 |
|
647 /** |
|
648 Gets the Content-Transfer Encoding mime header. |
|
649 |
|
650 @return An enumeration of the Content-Transfer Encoding header. Returns EEncodingTypeUnknown if not set. |
|
651 @see TMsvEncodingType |
|
652 */ |
|
653 EXPORT_C CMsvMimeHeaders::TMsvEncodingType CMsvMimeHeaders::ContentTransferEncoding() const |
|
654 { |
|
655 return iContentTransferEncoding; |
|
656 } |
|
657 |
|
658 /** |
|
659 Gets the Content-Transfer Encoding mime header. |
|
660 |
|
661 Also provides a descriptor that contains a textual representation of the content-transfer |
|
662 encoding header. |
|
663 |
|
664 @param aEncodingType This desriptor is set to a textual representation of the mime header. |
|
665 Returns a zero-length |
|
666 @return An enumeration of the Content-Transfer Encoding header. Returns EEncodingTypeUnknown if not set. |
|
667 @see TMsvEncodingType |
|
668 */ |
|
669 EXPORT_C CMsvMimeHeaders::TMsvEncodingType CMsvMimeHeaders::ContentTransferEncoding(TPtrC8& aEncodingType) const |
|
670 { |
|
671 switch (iContentTransferEncoding) |
|
672 { |
|
673 case EEncodingTypeBASE64: |
|
674 aEncodingType.Set(KMsvBase64String); |
|
675 break; |
|
676 case EEncodingTypeQP: |
|
677 aEncodingType.Set(KMsvQPString); |
|
678 break; |
|
679 case EEncodingType7Bit: |
|
680 aEncodingType.Set(KMsv7BitString); |
|
681 break; |
|
682 case EEncodingType8Bit: |
|
683 aEncodingType.Set(KMsv8BitString); |
|
684 break; |
|
685 case EEncodingTypeBinary: |
|
686 aEncodingType.Set(KMsvBinaryString); |
|
687 break; |
|
688 case EEncodingTypeUU: |
|
689 aEncodingType.Set(KMsvUUString); |
|
690 break; |
|
691 case EEncodingTypeNone: |
|
692 case EEncodingTypeUnknown: |
|
693 default: |
|
694 aEncodingType.Set(KNullDesC8()); |
|
695 break; |
|
696 } |
|
697 return iContentTransferEncoding; |
|
698 } |
|
699 |
|
700 /** |
|
701 Gets the Content-Type mime header parameter value. |
|
702 |
|
703 This method finds the specifed parameter and extracts the value for it. |
|
704 |
|
705 @param aContentTypeParameter The Content-Type parameter to get the value for. |
|
706 @return The Content-Type parameter value requested. Returns a zero-length if |
|
707 the paramter cannot be found. |
|
708 */ |
|
709 EXPORT_C const TPtrC8 CMsvMimeHeaders::GetContentTypeValue(const TDesC8& aContentTypeParameter) const |
|
710 { |
|
711 __ASSERT_DEBUG (!(iContentTypeParams->Count()&1), User::Invariant()); // Should not have odd number of elements |
|
712 |
|
713 TInt result; |
|
714 if (KErrNone==iContentTypeParams->Find(aContentTypeParameter,result,ECmpFolded8)) |
|
715 { |
|
716 ++result; |
|
717 if ((result&1) && result <= iContentTypeParams->Count()) // check result+1 is odd & entry exists |
|
718 { |
|
719 return ContentTypeParams()[result]; |
|
720 } |
|
721 } |
|
722 return KNullDesC8(); // couldn't find match so return an empty descriptor |
|
723 } |
|
724 |
|
725 /** |
|
726 Enquire whether a CMsvAttachment has MIME headers without restoring all the headers. |
|
727 |
|
728 @param aAttachment The attachment. |
|
729 @return True if there is an MIME headers |
|
730 */ |
|
731 EXPORT_C TBool CMsvMimeHeaders::ContainsMimeHeaders(const CMsvAttachment& aAttachment) |
|
732 { |
|
733 TPtrC8 bufferPtr; |
|
734 return (aAttachment.GetDesC8Attribute(KUidMimeHeaders, bufferPtr) == KErrNone); |
|
735 } |
|
736 |