|
1 // Copyright (c) 2003-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 // cimencodeheader.cpp |
|
15 // |
|
16 |
|
17 #include "cimencodedheader.h" |
|
18 #include "MIUT_ERR.H" |
|
19 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
20 #include "miut_errconsts.h" |
|
21 #include "timrfc822datefield.h" |
|
22 #endif |
|
23 |
|
24 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB) |
|
25 #include <msvstd.h> |
|
26 #endif |
|
27 |
|
28 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB) |
|
29 _LIT16(KComma, ","); |
|
30 _LIT16(KDelimiter, ";"); |
|
31 #endif |
|
32 |
|
33 const TInt KArrayGranularity = 16; |
|
34 |
|
35 // Identifies which version of CImEncodedHeader has been stored in stream |
|
36 const TUint16 KImEncodedHeaderVersion = 1; |
|
37 |
|
38 extern TPtrC8 LimitStringSize(const TPtrC8& aString, TInt aMaxSize); |
|
39 extern TPtrC16 LimitStringSize(const TPtrC16& aString, TInt aMaxSize); |
|
40 extern void ExternalizeL(const CDesC8Array& anArray,RWriteStream& aStream); |
|
41 extern void InternalizeL(CDesC8Array& anArray,RReadStream& aStream); |
|
42 extern void ExternalizeL(const CDesC16Array& anArray,RWriteStream& aStream); |
|
43 extern void InternalizeL(CDesC16Array& anArray,RReadStream& aStream); |
|
44 |
|
45 //------------------------------------------------------------------------------ |
|
46 // Class CImEncodedHeader Functions |
|
47 //------------------------------------------------------------------------------ |
|
48 |
|
49 CImEncodedHeader::CImEncodedHeader() : iDecodeCharset(0) |
|
50 { |
|
51 } |
|
52 |
|
53 //------------------------------------------------------------------------------ |
|
54 |
|
55 CImEncodedHeader* CImEncodedHeader::NewLC() |
|
56 /** Allocates and creates a new CImHeader object, leaving the object on the cleanup |
|
57 stack. |
|
58 |
|
59 @return New CImEncodedHeader object */ |
|
60 { |
|
61 CImEncodedHeader* self = new(ELeave) CImEncodedHeader; |
|
62 CleanupStack::PushL(self); |
|
63 self->ConstructL(); |
|
64 return self; |
|
65 } |
|
66 |
|
67 //------------------------------------------------------------------------------ |
|
68 |
|
69 CImEncodedHeader* CImEncodedHeader::NewL() |
|
70 /** Allocates and creates a new CImHeader object, leaving the object on the cleanup |
|
71 stack. |
|
72 |
|
73 @return New CImEncodedHeader object */ |
|
74 { |
|
75 CImEncodedHeader* self = CImEncodedHeader::NewLC(); |
|
76 CleanupStack::Pop(self); |
|
77 return self; |
|
78 } |
|
79 |
|
80 //------------------------------------------------------------------------------ |
|
81 |
|
82 void CImEncodedHeader::ConstructL() |
|
83 { |
|
84 iTo = new (ELeave)CDesCArrayFlat(KArrayGranularity); |
|
85 iCc = new (ELeave)CDesCArrayFlat(KArrayGranularity); |
|
86 iBcc = new (ELeave)CDesCArrayFlat(KArrayGranularity); |
|
87 } |
|
88 |
|
89 //------------------------------------------------------------------------------ |
|
90 |
|
91 CImEncodedHeader::~CImEncodedHeader() |
|
92 { |
|
93 Reset(); |
|
94 delete iTo; |
|
95 delete iCc; |
|
96 delete iBcc; |
|
97 } |
|
98 |
|
99 //------------------------------------------------------------------------------ |
|
100 |
|
101 void CImEncodedHeader::Reset() |
|
102 { |
|
103 iVersion = KImEncodedHeaderVersion; |
|
104 delete iFrom; iFrom = NULL; |
|
105 delete iSubject; iSubject = NULL; |
|
106 delete iReplyTo; iReplyTo = NULL; |
|
107 |
|
108 if (iTo) |
|
109 iTo->Reset(); |
|
110 if (iCc) |
|
111 iCc->Reset(); |
|
112 if (iBcc) |
|
113 iBcc->Reset(); |
|
114 |
|
115 iDecodeCharset = 0; |
|
116 } |
|
117 |
|
118 //------------------------------------------------------------------------------ |
|
119 |
|
120 const TPtrC8 CImEncodedHeader::Subject() const |
|
121 /** Gets the "Subject" header field. |
|
122 |
|
123 @return Field value */ |
|
124 { |
|
125 return iSubject ? TPtrC8(*iSubject) : TPtrC8(); |
|
126 } |
|
127 |
|
128 //------------------------------------------------------------------------------ |
|
129 |
|
130 const TPtrC8 CImEncodedHeader::From() const |
|
131 /** Gets the "From" header field. |
|
132 |
|
133 This consists of an address and (possibly) an alias. |
|
134 |
|
135 @return Field value */ |
|
136 { |
|
137 return iFrom ? TPtrC8(*iFrom) : TPtrC8(); |
|
138 } |
|
139 |
|
140 //------------------------------------------------------------------------------ |
|
141 |
|
142 const TPtrC8 CImEncodedHeader::ReplyTo() const |
|
143 /** Gets the "ReplyTo" header field. |
|
144 |
|
145 @return Field value */ |
|
146 { |
|
147 return iReplyTo ? TPtrC8(*iReplyTo) : TPtrC8(); |
|
148 } |
|
149 |
|
150 //------------------------------------------------------------------------------ |
|
151 |
|
152 void CImEncodedHeader::SetSubjectL( const TDesC8& aSubject ) |
|
153 /** Sets the "Subject" header field. |
|
154 |
|
155 @param aSubject Field value */ |
|
156 { |
|
157 HBufC8* newSubject = aSubject.AllocL(); |
|
158 delete iSubject; |
|
159 iSubject = newSubject; |
|
160 } |
|
161 |
|
162 //------------------------------------------------------------------------------ |
|
163 |
|
164 void CImEncodedHeader::SetFromL( const TDesC8& aFrom ) |
|
165 /** Sets the "From" header field. |
|
166 |
|
167 @param aFrom Field value */ |
|
168 { |
|
169 HBufC8* newFrom = aFrom.AllocL(); |
|
170 delete iFrom; |
|
171 iFrom = newFrom; |
|
172 } |
|
173 |
|
174 //------------------------------------------------------------------------------ |
|
175 |
|
176 void CImEncodedHeader::SetReplyToL( const TDesC8& aReplyTo ) |
|
177 /** Sets the "ReplyTo" header field. |
|
178 |
|
179 @param aReplyTo Field value */ |
|
180 { |
|
181 HBufC8* newReplyTo = aReplyTo.AllocL(); |
|
182 delete iReplyTo; |
|
183 iReplyTo = newReplyTo; |
|
184 } |
|
185 |
|
186 //------------------------------------------------------------------------------ |
|
187 |
|
188 CDesCArray& CImEncodedHeader::ToRecipients () |
|
189 { |
|
190 return *iTo; |
|
191 } |
|
192 |
|
193 //------------------------------------------------------------------------------ |
|
194 |
|
195 CDesCArray& CImEncodedHeader::CcRecipients () |
|
196 /** Gets a list of "Cc" recipients. |
|
197 |
|
198 @return Recipient list */ |
|
199 { |
|
200 return *iCc; |
|
201 } |
|
202 |
|
203 //------------------------------------------------------------------------------ |
|
204 |
|
205 CDesCArray& CImEncodedHeader::BccRecipients() |
|
206 /** Gets a list of "Bcc" recipients. |
|
207 |
|
208 @return Recipient list */ |
|
209 { |
|
210 return *iBcc; |
|
211 } |
|
212 |
|
213 //------------------------------------------------------------------------------ |
|
214 |
|
215 const CDesCArray& CImEncodedHeader::ToRecipients () const |
|
216 /** Gets a const list of "To" recipients. |
|
217 |
|
218 @return Recipient list */ |
|
219 { |
|
220 return *iTo; |
|
221 } |
|
222 |
|
223 //------------------------------------------------------------------------------ |
|
224 |
|
225 const CDesCArray& CImEncodedHeader::CcRecipients () const |
|
226 /** Gets a const list of "Cc" recipients. |
|
227 |
|
228 @return Recipient list */ |
|
229 { |
|
230 return *iCc; |
|
231 } |
|
232 |
|
233 //------------------------------------------------------------------------------ |
|
234 |
|
235 const CDesCArray& CImEncodedHeader::BccRecipients() const |
|
236 /** Gets a const list of "Bcc" recipients. |
|
237 |
|
238 @return Recipient list */ |
|
239 { |
|
240 return *iBcc; |
|
241 } |
|
242 |
|
243 //------------------------------------------------------------------------------ |
|
244 |
|
245 void CImEncodedHeader::ExternalizeL( RMsvWriteStream& aWriteStream ) const |
|
246 /** Externalises the settings to a specified stream. |
|
247 |
|
248 @param aWriteStream Stream to write to */ |
|
249 { |
|
250 aWriteStream.WriteUint16L(Version()); // This MUST be the 1st item written into the stream |
|
251 |
|
252 aWriteStream << LimitStringSize(From(), KMaxImHeaderStringLength); |
|
253 aWriteStream << LimitStringSize(ReplyTo(), KMaxImHeaderStringLength); |
|
254 aWriteStream << LimitStringSize(Subject(), KMaxImHeaderStringLength); |
|
255 |
|
256 aWriteStream << ToRecipients(); |
|
257 aWriteStream << CcRecipients(); |
|
258 aWriteStream << BccRecipients(); |
|
259 |
|
260 aWriteStream.WriteUint32L(iDecodeCharset); |
|
261 } |
|
262 |
|
263 //------------------------------------------------------------------------------ |
|
264 |
|
265 void CImEncodedHeader::InternalizeL( RMsvReadStream& aReadStream ) |
|
266 /** Internalises the settings from a specified stream. |
|
267 |
|
268 @param aReadStream Stream to read from */ |
|
269 { |
|
270 Reset(); |
|
271 |
|
272 iVersion = aReadStream.ReadUint16L(); |
|
273 iFrom = HBufC8::NewL(aReadStream, KMaxImHeaderStringLength); |
|
274 iReplyTo = HBufC8::NewL(aReadStream, KMaxImHeaderStringLength); |
|
275 iSubject = HBufC8::NewL(aReadStream, KMaxImHeaderStringLength); |
|
276 |
|
277 aReadStream >> ToRecipients(); |
|
278 aReadStream >> CcRecipients(); |
|
279 aReadStream >> BccRecipients(); |
|
280 |
|
281 iDecodeCharset = aReadStream.ReadUint32L(); |
|
282 } |
|
283 |
|
284 void CImEncodedHeader::StoreL(CMsvStore& aMessageStore) const |
|
285 /** Stores settings to a specified message store. |
|
286 |
|
287 @param aMessageStore Message store to write to */ |
|
288 { |
|
289 //------------------------------------------------------------------------------ |
|
290 RMsvWriteStream out; |
|
291 out.AssignLC(aMessageStore, KUidMsgFileIMailEncodedHeader); |
|
292 ExternalizeL(out); |
|
293 out.CommitL(); |
|
294 CleanupStack::PopAndDestroy(&out); |
|
295 } |
|
296 |
|
297 |
|
298 void CImEncodedHeader::RestoreL(CMsvStore& aMessageStore) |
|
299 /** Restores settings from a specified message store. |
|
300 |
|
301 @param aMessageStore Message store to read from */ |
|
302 { |
|
303 RMsvReadStream in; |
|
304 in.OpenLC( aMessageStore, KUidMsgFileIMailEncodedHeader ); |
|
305 InternalizeL(in); |
|
306 in.Close(); |
|
307 CleanupStack::PopAndDestroy(&in); |
|
308 } |
|
309 //------------------------------------------------------------------------------ |
|
310 |
|
311 TUint16 CImEncodedHeader::Version() const |
|
312 { |
|
313 return iVersion; |
|
314 } |
|
315 |
|
316 //------------------------------------------------------------------------------ |
|
317 |
|
318 void CImEncodedHeader::SetVersion( TUint16 aVersion ) |
|
319 { |
|
320 iVersion = aVersion; |
|
321 } |
|
322 |
|
323 //------------------------------------------------------------------------------ |
|
324 |
|
325 TUint CImEncodedHeader::DecodeCharset() const |
|
326 { |
|
327 return iDecodeCharset; |
|
328 } |
|
329 |
|
330 //------------------------------------------------------------------------------ |
|
331 |
|
332 void CImEncodedHeader::SetDecodeCharset(TUint aCharset) |
|
333 { |
|
334 iDecodeCharset = aCharset; |
|
335 } |
|
336 |
|
337 //------------------------------------------------------------------------------ |
|
338 |
|
339 void CImEncodedHeader::CopyFromHeaderL( |
|
340 const CImHeader& aFromHeader, TBool aDeleteExistingData) |
|
341 { |
|
342 // From field |
|
343 const TPtrC& fromDes = aFromHeader.From(); |
|
344 if (fromDes.Length() && (!iFrom || aDeleteExistingData)) |
|
345 { |
|
346 HBufC8* buffer = HBufC8::NewL(fromDes.Length()); |
|
347 buffer->Des().Copy(fromDes); |
|
348 delete iFrom; |
|
349 iFrom = buffer; |
|
350 } |
|
351 |
|
352 // Subject field |
|
353 const TPtrC& subjectDes = aFromHeader.Subject(); |
|
354 if (subjectDes.Length() && (!iSubject || aDeleteExistingData)) |
|
355 { |
|
356 HBufC8* buffer = HBufC8::NewL(subjectDes.Length()); |
|
357 buffer->Des().Copy(subjectDes); |
|
358 delete iSubject; |
|
359 iSubject = buffer; |
|
360 } |
|
361 |
|
362 // ReplyTo field |
|
363 const TPtrC& replyToDes = aFromHeader.ReplyTo(); |
|
364 if (replyToDes.Length() && (!iReplyTo || aDeleteExistingData)) |
|
365 { |
|
366 HBufC8* buffer = HBufC8::NewL(replyToDes.Length()); |
|
367 buffer->Des().Copy(replyToDes); |
|
368 delete iReplyTo; |
|
369 iReplyTo = buffer; |
|
370 } |
|
371 // Copy iTo, iCc, iBcc |
|
372 const CDesCArray& srcToArray = aFromHeader.ToRecipients(); |
|
373 if (srcToArray.Count() && ((iTo->Count() == 0) || aDeleteExistingData)) |
|
374 ::CopyArrayL(srcToArray, *iTo); |
|
375 |
|
376 const CDesCArray& srcCcArray = aFromHeader.CcRecipients(); |
|
377 if (srcCcArray.Count() && ((iCc->Count() == 0) || aDeleteExistingData)) |
|
378 ::CopyArrayL(srcCcArray, *iCc); |
|
379 |
|
380 const CDesCArray& srcBccArray = aFromHeader.BccRecipients(); |
|
381 if (srcBccArray.Count() && ((iBcc->Count() == 0) || aDeleteExistingData)) |
|
382 ::CopyArrayL(srcBccArray, *iBcc); |
|
383 } |
|
384 |
|
385 //------------------------------------------------------------------------------ |
|
386 |
|
387 void CImEncodedHeader::CopyToHeaderL(CImHeader& aToHeader) const |
|
388 { |
|
389 // |
|
390 aToHeader.SetFromL(From()); |
|
391 aToHeader.SetSubjectL(Subject()); |
|
392 aToHeader.SetReplyToL(ReplyTo()); |
|
393 |
|
394 // Copy iTo, iCc, iBcc |
|
395 ::CopyArrayL(*iTo, aToHeader.ToRecipients()); |
|
396 ::CopyArrayL(*iCc, aToHeader.CcRecipients()); |
|
397 ::CopyArrayL(*iBcc, aToHeader.BccRecipients()); |
|
398 } |
|
399 |
|
400 //------------------------------------------------------------------------------ |
|
401 |
|
402 TInt CImEncodedHeader::DataSize() const |
|
403 /** Gets the combined length of all the field values stored. |
|
404 |
|
405 @return Combined length */ |
|
406 { |
|
407 TInt headerSize = 2; // CRLF at end of header |
|
408 const CImEncodedHeader* self = this; |
|
409 |
|
410 headerSize += self->From().Length(); |
|
411 headerSize += self->ReplyTo().Length(); |
|
412 headerSize += self->Subject().Length(); |
|
413 headerSize += sizeof(TUint); // size of Charset |
|
414 |
|
415 TInt count; |
|
416 CDesCArray& toArray = *self->iTo; |
|
417 for (count = 0; count < toArray.Count(); count++) |
|
418 { |
|
419 headerSize += toArray[count].Length(); |
|
420 } |
|
421 |
|
422 CDesCArray& ccArray = *self->iCc; |
|
423 for (count = 0; count < ccArray.Count(); count++) |
|
424 { |
|
425 headerSize += ccArray[count].Length(); |
|
426 } |
|
427 |
|
428 CDesCArray& bccArray = *self->iBcc; |
|
429 for (count = 0; count < bccArray.Count(); count++) |
|
430 { |
|
431 headerSize += bccArray[count].Length(); |
|
432 } |
|
433 |
|
434 return headerSize; |
|
435 } |
|
436 |
|
437 |
|
438 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB) |
|
439 /**Stores encoded header to a specified message store. |
|
440 * @param aMessageStore Message store to write to |
|
441 * @return None. |
|
442 */ |
|
443 void CImEncodedHeader::StoreEncodedDBL(CMsvStore& aMessageStore) const |
|
444 { |
|
445 CHeaderFields* emailHeaderFields = new (ELeave)CHeaderFields(); |
|
446 CleanupStack::PushL(emailHeaderFields); |
|
447 emailHeaderFields->iUid = KUidMsgFileIMailEncodedHeader; |
|
448 |
|
449 //----------------------Encoded Info 19th Field ------------------------------ // 19 |
|
450 CFieldPair* emaildetailField = new (ELeave)CFieldPair(); |
|
451 CleanupStack::PushL(emaildetailField); |
|
452 |
|
453 //Make a string from encoded header info. |
|
454 RBuf8 encodedheader; |
|
455 CleanupClosePushL(encodedheader); |
|
456 encodedheader.CreateL(EncodedBufSize()); // |
|
457 |
|
458 encodedheader.AppendNum(Version()); |
|
459 encodedheader.Append(KDelimiter); |
|
460 |
|
461 encodedheader.Append(LimitStringSize(From(), KMaxImHeaderStringLength)); |
|
462 encodedheader.Append(KDelimiter); |
|
463 encodedheader.Append(LimitStringSize(ReplyTo(), KMaxImHeaderStringLength)); |
|
464 encodedheader.Append(KDelimiter); |
|
465 encodedheader.Append(LimitStringSize(Subject(), KMaxImHeaderStringLength)); |
|
466 encodedheader.Append(KDelimiter); |
|
467 |
|
468 //ToRecipients |
|
469 for(TInt i=0 ; i<iTo->MdcaCount() ; i++) |
|
470 { |
|
471 encodedheader.Append(iTo->MdcaPoint(i)); |
|
472 if(i< iTo->MdcaCount()-1) |
|
473 encodedheader.Append(KComma); |
|
474 } |
|
475 encodedheader.Append(KDelimiter); |
|
476 |
|
477 //CcRecipients |
|
478 for(TInt i=0 ; i<iCc->MdcaCount() ; i++) |
|
479 { |
|
480 encodedheader.Append(iCc->MdcaPoint(i)); |
|
481 if(i< iCc->MdcaCount()-1) |
|
482 encodedheader.Append(KComma); |
|
483 } |
|
484 encodedheader.Append(KDelimiter); |
|
485 |
|
486 //BCcRecipients |
|
487 for(TInt i=0 ; i<iBcc->MdcaCount() ; i++) |
|
488 { |
|
489 encodedheader.Append(iBcc->MdcaPoint(i)); |
|
490 if(i< iBcc->MdcaCount()-1) |
|
491 encodedheader.Append(KComma); |
|
492 } |
|
493 encodedheader.Append(KDelimiter); |
|
494 |
|
495 encodedheader.AppendNum(iDecodeCharset); |
|
496 encodedheader.Append(KDelimiter); |
|
497 |
|
498 //8 bit to 16 bit |
|
499 HBufC* newFrom = HBufC::NewL(encodedheader.Length()); |
|
500 newFrom->Des().Copy(encodedheader); |
|
501 emaildetailField->iFieldTextValue = newFrom; |
|
502 emailHeaderFields->iFieldPairList.AppendL(emaildetailField); |
|
503 CleanupStack::Pop(); //RBuf8 |
|
504 CleanupStack::Pop(emaildetailField); |
|
505 |
|
506 //---------------------------Encoded info end------------------------------- |
|
507 |
|
508 TMsvWriteStore storeWriter(aMessageStore); |
|
509 storeWriter.AssignL(emailHeaderFields); |
|
510 encodedheader.Close(); |
|
511 CleanupStack::Pop(emailHeaderFields); |
|
512 } |
|
513 |
|
514 /** |
|
515 * Restores encoded header to a specified message store. |
|
516 * @param aMessageStore Message store to read from. |
|
517 * @return NOne. |
|
518 */ |
|
519 |
|
520 void CImEncodedHeader::ReStoreEncodedDBL(CMsvStore& aMessageStore) |
|
521 { |
|
522 Reset(); |
|
523 |
|
524 CHeaderFields* aEncodedHeader = NULL; |
|
525 TMsvReadStore storeReader(aMessageStore, KUidMsgFileIMailEncodedHeader); |
|
526 storeReader.ReadL(aEncodedHeader); |
|
527 |
|
528 TInt i = 0; // EncodedHeader field is on 19th coloum of header table. |
|
529 HBufC* encodedheaderinfo = aEncodedHeader->iFieldPairList[i++]->iFieldTextValue ; |
|
530 |
|
531 TPtr16 encodedheaderPtr = (encodedheaderinfo->Des()); |
|
532 |
|
533 //Parsing the encodedheader string |
|
534 TInt firstSemiColonPos = encodedheaderPtr.Locate(';'); |
|
535 TInt lastSemiColonPos = encodedheaderPtr.LocateReverse(';'); |
|
536 |
|
537 RPointerArray<HBufC16> encodedheaderinfoData; |
|
538 CleanupClosePushL(encodedheaderinfoData); |
|
539 TInt ii = 0 ; |
|
540 |
|
541 do |
|
542 { |
|
543 TPtrC16 str1 = encodedheaderPtr.Left(firstSemiColonPos); // First data |
|
544 HBufC16* tt = str1.AllocL(); |
|
545 firstSemiColonPos++; |
|
546 encodedheaderinfoData.AppendL(tt); |
|
547 |
|
548 if(firstSemiColonPos != lastSemiColonPos) |
|
549 { |
|
550 encodedheaderPtr = (encodedheaderPtr.Mid(firstSemiColonPos,encodedheaderPtr.Length()-(firstSemiColonPos) )); |
|
551 firstSemiColonPos = encodedheaderPtr.Locate(';'); |
|
552 lastSemiColonPos = encodedheaderPtr.LocateReverse(';'); |
|
553 if(firstSemiColonPos == lastSemiColonPos) |
|
554 { |
|
555 TPtrC16 str1 = encodedheaderPtr.Left(firstSemiColonPos); // Last data |
|
556 HBufC16* tt = str1.AllocL(); |
|
557 encodedheaderinfoData.AppendL(tt); |
|
558 } |
|
559 } |
|
560 |
|
561 ii++; |
|
562 }while(firstSemiColonPos != lastSemiColonPos); |
|
563 |
|
564 iVersion= ConvertToTInt(*encodedheaderinfoData[0]); |
|
565 |
|
566 HBufC8* form = HBufC8::NewL((encodedheaderinfoData[1])->Length()); |
|
567 form->Des().Copy(encodedheaderinfoData[1]->Des()); |
|
568 iFrom = form; |
|
569 |
|
570 HBufC8* replyTo = HBufC8::NewL((encodedheaderinfoData[2])->Length()); |
|
571 replyTo->Des().Copy(encodedheaderinfoData[2]->Des()); |
|
572 iReplyTo = replyTo ; |
|
573 |
|
574 HBufC8* subject = HBufC8::NewL((encodedheaderinfoData[3])->Length()); |
|
575 subject->Des().Copy(encodedheaderinfoData[3]->Des()); |
|
576 iSubject = subject ; |
|
577 |
|
578 //iTo |
|
579 HBufC16* tmpBuf = encodedheaderinfoData[4]->Des().AllocL(); |
|
580 if ((encodedheaderinfoData[4]->Des().Locate(',')) > -1 ) |
|
581 { |
|
582 CreateEncodedArrayListL(tmpBuf->Des(),0); //To |
|
583 } |
|
584 else |
|
585 { |
|
586 if(encodedheaderinfoData[4]->Length()>0) |
|
587 iTo->AppendL(tmpBuf->Des()); |
|
588 } |
|
589 delete tmpBuf; |
|
590 //iCc |
|
591 tmpBuf = encodedheaderinfoData[5]->Des().AllocL(); |
|
592 if ((encodedheaderinfoData[5]->Des().Locate(',')) > -1 ) |
|
593 { |
|
594 CreateEncodedArrayListL(tmpBuf->Des(),1); //CC |
|
595 } |
|
596 else |
|
597 { |
|
598 if(encodedheaderinfoData[5]->Length()>0) |
|
599 iCc->AppendL(tmpBuf->Des()); |
|
600 } |
|
601 delete tmpBuf; |
|
602 //iBcc |
|
603 tmpBuf = encodedheaderinfoData[6]->Des().AllocL(); |
|
604 if ((encodedheaderinfoData[6]->Des().Locate(',')) > -1 ) |
|
605 { |
|
606 CreateEncodedArrayListL(tmpBuf->Des(),2); //Bcc |
|
607 } |
|
608 else |
|
609 { |
|
610 if(encodedheaderinfoData[6]->Length()>0) |
|
611 iBcc->AppendL(tmpBuf->Des()); |
|
612 } |
|
613 |
|
614 delete tmpBuf; |
|
615 iDecodeCharset= ConvertToTInt(*encodedheaderinfoData[7]); |
|
616 encodedheaderinfoData.ResetAndDestroy(); |
|
617 encodedheaderinfoData.Close(); |
|
618 CleanupStack::Pop(); //RpointerArray |
|
619 |
|
620 |
|
621 } |
|
622 |
|
623 |
|
624 /** |
|
625 * Create Encoded Array List. |
|
626 * @param aEncodedStr : A string. |
|
627 * @param aI :A Integer value. |
|
628 * @return None. |
|
629 */ |
|
630 void CImEncodedHeader::CreateEncodedArrayListL(TPtrC16 aEncodedStr ,TInt aI) |
|
631 { |
|
632 TInt startPos = aEncodedStr.Locate(',') ; |
|
633 while(startPos >= -1 ) |
|
634 { |
|
635 TPtrC16 str2 = aEncodedStr.Left(startPos); |
|
636 //ainto.AppendL(str2); |
|
637 if(aI == 0) |
|
638 { |
|
639 //iTo |
|
640 iTo->AppendL(str2); |
|
641 } |
|
642 if(aI == 1) |
|
643 { |
|
644 //iCc |
|
645 iCc->AppendL(str2); |
|
646 } |
|
647 if( aI == 2) |
|
648 { |
|
649 //iBcc |
|
650 iBcc->AppendL(str2); |
|
651 } |
|
652 startPos++; |
|
653 aEncodedStr.Set(aEncodedStr.Mid(startPos, aEncodedStr.Length()- startPos)); |
|
654 |
|
655 startPos = aEncodedStr.Locate(','); |
|
656 if(startPos == -1) |
|
657 { |
|
658 TInt ll = aEncodedStr.Length(); |
|
659 TPtrC16 str3; |
|
660 str3.Set(aEncodedStr.Mid(0,aEncodedStr.Length())); |
|
661 if(aI == 0) |
|
662 { |
|
663 //iTo |
|
664 iTo->AppendL(str3); |
|
665 } |
|
666 if(aI == 1) |
|
667 { |
|
668 //iCc |
|
669 iCc->AppendL(str3); |
|
670 } |
|
671 if( aI == 2) |
|
672 { |
|
673 //iBcc |
|
674 iBcc->AppendL(str3); |
|
675 } |
|
676 break; |
|
677 } |
|
678 } |
|
679 } |
|
680 |
|
681 |
|
682 TInt CImEncodedHeader::EncodedBufSize() const |
|
683 /** Gets the combined length of all the field values stored. |
|
684 |
|
685 @return Combined length */ |
|
686 { |
|
687 TInt headerSize = 4; // Version |
|
688 const CImEncodedHeader* self = this; |
|
689 |
|
690 headerSize += Align4(self->From().Size()); |
|
691 headerSize += Align4(self->ReplyTo().Size()); |
|
692 headerSize += Align4(self->Subject().Size()); |
|
693 headerSize += sizeof(TUint); // size of Charset |
|
694 |
|
695 TInt count; |
|
696 for (count=0; count<iTo->MdcaCount(); count++) |
|
697 { |
|
698 headerSize += Align4(iTo->MdcaPoint(count).Size()) + 1; //1 for Comma |
|
699 } |
|
700 for (count=0; count<iCc->MdcaCount(); count++) |
|
701 { |
|
702 headerSize += Align4(iCc->MdcaPoint(count).Size()) + 1; //1 for Comma |
|
703 } |
|
704 for (count=0; count<iBcc->MdcaCount(); count++) |
|
705 { |
|
706 headerSize += Align4(iBcc->MdcaPoint(count).Size()) + 1;//1 for Comma |
|
707 } |
|
708 |
|
709 return headerSize + 8; //8 delimiters ";". |
|
710 } |
|
711 |
|
712 #endif |