|
1 // Copyright (c) 2008-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 |
|
17 /** |
|
18 * HEADER FILES |
|
19 */ |
|
20 |
|
21 #include "cmsvversion1version2converter.h" |
|
22 #include "cmessageconvertermanager.h" |
|
23 #include "CMsvCachedStore.h" |
|
24 #include "MSVUTILS.H" |
|
25 #include "txtrich.h" |
|
26 |
|
27 |
|
28 // constants |
|
29 const TInt KArrayGranularity = 16; |
|
30 const TInt KMaxImHeaderStringLength = 1000; |
|
31 const TInt KMaxImMimeFieldLength = 1000; |
|
32 const TInt KDesCArrayGranularity = 8; |
|
33 const TInt KMaxBufferLength = 1000; |
|
34 const TInt KDBCommitCount = 50; |
|
35 const TInt KMaxLengthOfRecipientField = 50; |
|
36 const TInt KSmcmSmsNumberMaxNumberLength = 21; |
|
37 const TInt KSmcmSmsNumberMaxNameLength = 256; |
|
38 const TUid KUidMsvSmsEmailFieldsStream = {0x10204C9D}; |
|
39 const TUid KUidSMSHeaderStream = {0x10001834}; |
|
40 const TUid KMsvEntryFileForSms={0x10003C68}; |
|
41 const TUid KUidMsgFileIMailHeader = {0x100001D8}; // mail header UID |
|
42 const TUid KUidMsgFileIMailEncodedHeader = {0x101FD0E3}; |
|
43 const TUid KUidMsgFileMimeHeader = {0x1000160F}; // 268441103 decimal |
|
44 const TInt KMaxConverterNumber = 100; |
|
45 const TInt KMaxPathConverter = 1000; |
|
46 |
|
47 //Literals |
|
48 _LIT16(KSeparator,";"); |
|
49 _LIT16(KComma,","); |
|
50 _LIT16(KDetails,""); |
|
51 _LIT16(KSpace,""); |
|
52 _LIT16(KDelimiter, ";"); |
|
53 |
|
54 // Sms header fields |
|
55 _LIT16(KSmsHeadearversion , "SmsHeadearversion"); |
|
56 _LIT16(KSmsRecipientCount , "RecipientCount"); |
|
57 _LIT16(KRecipients , "To"); |
|
58 _LIT16(KSmsFlags , "SmsFlags"); |
|
59 _LIT16(KTextBioMsgIdType,"BioMsgIdType"); |
|
60 |
|
61 |
|
62 // global function declaration |
|
63 extern void ExternalizeL(const CDesC8Array& anArray,RWriteStream& aStream); |
|
64 extern void InternalizeL(CDesC8Array& anArray,RReadStream& aStream); |
|
65 extern void ExternalizeL(const CDesC16Array& anArray,RWriteStream& aStream); |
|
66 extern void InternalizeL(CDesC16Array& anArray,RReadStream& aStream); |
|
67 |
|
68 /** |
|
69 InternalizeL() |
|
70 |
|
71 @param anArray: A reference to an array of 16 bit descriptor arrays |
|
72 @param aStream: The read stream interface |
|
73 @retun None. |
|
74 */ |
|
75 void InternalizeL(CDesC8Array& anArray,RReadStream& aStream) |
|
76 { |
|
77 TCardinality card; |
|
78 aStream >> card; |
|
79 TInt count=card; |
|
80 anArray.Reset(); |
|
81 for (TInt ii=0;ii<count;++ii) |
|
82 { |
|
83 HBufC8* buf=HBufC8::NewLC(aStream,KMaxImHeaderStringLength); |
|
84 anArray.CArrayFixBase::InsertL(ii,&buf); |
|
85 CleanupStack::Pop(); |
|
86 } |
|
87 } |
|
88 |
|
89 /** |
|
90 InternalizeL() |
|
91 |
|
92 @param anArray: A reference to an array of 16 bit descriptor arrays |
|
93 @param aStream: The read stream interface |
|
94 @retun None. |
|
95 */ |
|
96 void InternalizeL(CDesC16Array& anArray,RReadStream& aStream) |
|
97 { |
|
98 TCardinality card; |
|
99 aStream >> card; |
|
100 TInt count=card; |
|
101 anArray.Reset(); |
|
102 for (TInt ii=0;ii<count;++ii) |
|
103 { |
|
104 HBufC16* buf=HBufC16::NewLC(aStream,KMaxImHeaderStringLength); |
|
105 anArray.CArrayFixBase::InsertL(ii,&buf); |
|
106 CleanupStack::Pop(); |
|
107 } |
|
108 } |
|
109 |
|
110 /** |
|
111 HMsvReadBuffer() |
|
112 |
|
113 @param aBuf: 8-bit non-modifiable descriptors |
|
114 @retun None. |
|
115 */ |
|
116 HMsvReadBuffer::HMsvReadBuffer(const TDesC8 &aBuf) |
|
117 { |
|
118 TUint8* ptr=(TUint8 *)aBuf.Ptr(); |
|
119 Set(ptr,ptr+aBuf.Length(),ERead); |
|
120 } |
|
121 |
|
122 void HMsvReadBuffer::DoRelease() |
|
123 { |
|
124 delete this; |
|
125 } |
|
126 |
|
127 |
|
128 //**************************************************************************************** |
|
129 // Class TImHeaderEncodingInfo Functions |
|
130 //**************************************************************************************** |
|
131 |
|
132 TImHeaderEncodingInfo::TImHeaderEncodingInfo() : |
|
133 iType(ENoEncoding), iAddSpace(EFalse), iCharsetUid(0) |
|
134 { |
|
135 } |
|
136 |
|
137 |
|
138 /** |
|
139 TImHeaderEncodingInfo() |
|
140 Copy constructor. |
|
141 |
|
142 @param aFrom: Object to copy |
|
143 */ |
|
144 TImHeaderEncodingInfo::TImHeaderEncodingInfo(const TImHeaderEncodingInfo& aFrom) |
|
145 { |
|
146 SetField( aFrom.Field() ); |
|
147 SetOffset( aFrom.Offset() ); |
|
148 SetLength( aFrom.Length() ); |
|
149 SetEncodingType( aFrom.EncodingType() ); |
|
150 SetArrayValue( aFrom.ArrayValue() ); |
|
151 SetCharsetUid(aFrom.CharsetUid()); |
|
152 SetAddSpace( aFrom.AddSpace() ); |
|
153 SetEncodedLength( aFrom.EncodedLength() ); |
|
154 } |
|
155 |
|
156 |
|
157 /** |
|
158 InternalizeL() |
|
159 Internalises the object from the specified stream. |
|
160 |
|
161 @param aReadStream Stream to read from */ |
|
162 void TImHeaderEncodingInfo::InternalizeL( RReadStream& aReadStream ) |
|
163 { |
|
164 SetField( (TFieldList) aReadStream.ReadUint16L()); |
|
165 SetOffset( aReadStream.ReadUint16L()); |
|
166 SetLength( aReadStream.ReadUint16L()); |
|
167 SetEncodingType( (TEncodingType) aReadStream.ReadUint16L()); |
|
168 SetArrayValue( aReadStream.ReadUint16L()); |
|
169 SetCharsetUid( aReadStream.ReadUint32L()); |
|
170 SetAddSpace( aReadStream.ReadUint16L()); |
|
171 SetEncodedLength( aReadStream.ReadUint8L()); |
|
172 } |
|
173 |
|
174 void TImHeaderEncodingInfo::SetField(const TFieldList aField) |
|
175 { |
|
176 iField = aField; |
|
177 } |
|
178 |
|
179 /** |
|
180 Gets the field type. |
|
181 |
|
182 @return Field type |
|
183 */ |
|
184 TImHeaderEncodingInfo::TFieldList TImHeaderEncodingInfo::Field() const |
|
185 { |
|
186 return iField; |
|
187 } |
|
188 |
|
189 /** |
|
190 Sets the field offset. |
|
191 |
|
192 @param aOffset Field offset |
|
193 */ |
|
194 void TImHeaderEncodingInfo::SetOffset(const TInt aOffset) |
|
195 { |
|
196 iOffset = (TUint16)aOffset; |
|
197 } |
|
198 |
|
199 /** |
|
200 Gets the field offset. |
|
201 |
|
202 @return Field offset |
|
203 */ |
|
204 TInt TImHeaderEncodingInfo::Offset() const |
|
205 { |
|
206 return iOffset; |
|
207 } |
|
208 |
|
209 /** |
|
210 Sets the field length. |
|
211 |
|
212 @param aLength Field length |
|
213 */ |
|
214 void TImHeaderEncodingInfo::SetLength(const TInt aLength) |
|
215 { |
|
216 iLength = (TUint16)aLength; |
|
217 } |
|
218 |
|
219 /** |
|
220 Gets the field length. |
|
221 |
|
222 @return Field length |
|
223 */ |
|
224 TInt TImHeaderEncodingInfo::Length() const |
|
225 { |
|
226 return iLength; |
|
227 } |
|
228 |
|
229 /** Sets the character set UID. |
|
230 |
|
231 @param aUid Character set UID |
|
232 */ |
|
233 void TImHeaderEncodingInfo::SetCharsetUid(const TUint aUid) |
|
234 { |
|
235 iCharsetUid = aUid; |
|
236 } |
|
237 |
|
238 /** |
|
239 Gets the character set UID. |
|
240 @return Character set UID |
|
241 */ |
|
242 TUint TImHeaderEncodingInfo::CharsetUid() const |
|
243 { |
|
244 return iCharsetUid; |
|
245 } |
|
246 |
|
247 /** |
|
248 Sets the encoding type (string). |
|
249 @param aChar Encoding type |
|
250 */ |
|
251 void TImHeaderEncodingInfo::SetEncodingType(const TDesC8& aChar) |
|
252 { |
|
253 // If invalid, defaults to QPEncoding |
|
254 if (aChar[0] == 'b' || aChar[0] == 'B') |
|
255 iType = TImHeaderEncodingInfo::EBase64; |
|
256 else if (aChar[0] == 'q' || aChar[0] == 'Q') |
|
257 iType = TImHeaderEncodingInfo::EQP; |
|
258 else |
|
259 iType = TImHeaderEncodingInfo::ENoEncoding; |
|
260 } |
|
261 |
|
262 /** |
|
263 Sets the encoding type (enumeration). |
|
264 |
|
265 @param aType Encoding type |
|
266 */ |
|
267 void TImHeaderEncodingInfo::SetEncodingType(const TEncodingType aType) |
|
268 { |
|
269 iType = aType; |
|
270 } |
|
271 |
|
272 /** |
|
273 Gets the encoding type (enumeration). |
|
274 |
|
275 @return Encoding type |
|
276 */ |
|
277 TImHeaderEncodingInfo::TEncodingType TImHeaderEncodingInfo::EncodingType() const |
|
278 { |
|
279 return iType; |
|
280 } |
|
281 |
|
282 /** |
|
283 Sets the array value. |
|
284 |
|
285 @param aValue Array value |
|
286 */ |
|
287 void TImHeaderEncodingInfo::SetArrayValue(const TInt aValue) |
|
288 { |
|
289 iArrayValue = (TUint16)aValue; |
|
290 } |
|
291 |
|
292 /** |
|
293 Gets the array value. |
|
294 |
|
295 @return Array value |
|
296 */ |
|
297 TInt TImHeaderEncodingInfo::ArrayValue() const |
|
298 { |
|
299 return iArrayValue; |
|
300 } |
|
301 |
|
302 /** |
|
303 Sets if a space character needs adding between two adjoining encoded-words. |
|
304 |
|
305 @param atrueFalse True to add a space character |
|
306 */ |
|
307 void TImHeaderEncodingInfo::SetAddSpace(const TBool atrueFalse) |
|
308 { |
|
309 iAddSpace = atrueFalse; |
|
310 } |
|
311 |
|
312 /** |
|
313 Tests if the add space character flag is set. |
|
314 |
|
315 @return True for added space characters |
|
316 */ |
|
317 TBool TImHeaderEncodingInfo::AddSpace() const |
|
318 { |
|
319 return iAddSpace; |
|
320 } |
|
321 |
|
322 /** |
|
323 Sets the encoded length. |
|
324 |
|
325 @param aLength Encoded length |
|
326 */ |
|
327 void TImHeaderEncodingInfo::SetEncodedLength(const TInt aLength) |
|
328 { |
|
329 iEncodedLength = (TInt8) aLength; |
|
330 } |
|
331 |
|
332 /** |
|
333 Gets the encoded length. |
|
334 |
|
335 @return Encoded length |
|
336 */ |
|
337 TInt TImHeaderEncodingInfo::EncodedLength() const |
|
338 { |
|
339 return iEncodedLength + (AddSpace() ? 1 : 0); |
|
340 } |
|
341 |
|
342 |
|
343 |
|
344 //**************************************************************************************** |
|
345 // Class CMsvVersion1Version2Converter Functions |
|
346 //**************************************************************************************** |
|
347 |
|
348 |
|
349 /* |
|
350 CMsvVersion1Version2Converter() |
|
351 |
|
352 @param aDBAdapter: |
|
353 @param aMesasgeDBAdapter: |
|
354 @retun None. |
|
355 @internalComponent |
|
356 */ |
|
357 CMsvVersion1Version2Converter::CMsvVersion1Version2Converter(CMsvDBAdapter& aDBAdapter,CMsvMessageDBAdapter& aMessageDBAdapter,TDriveNumber aDriveNum,TBool aConversionResume) |
|
358 : iDBAdapter(aDBAdapter),iMessageDBAdapter(aMessageDBAdapter) |
|
359 { |
|
360 iResume = aConversionResume; |
|
361 iDrive = aDriveNum; |
|
362 } |
|
363 |
|
364 /** |
|
365 NewL() |
|
366 |
|
367 @param aDBAdapter: |
|
368 @param aMesasgeDBAdapter: |
|
369 @retun None. |
|
370 @internalComponent |
|
371 */ |
|
372 CMsvVersion1Version2Converter* CMsvVersion1Version2Converter::NewL(CMsvDBAdapter& aDBAdapter,CMsvMessageDBAdapter& aMessageDBAdapter,TDriveNumber aDriveNum,TBool aConversionResume) |
|
373 { |
|
374 CMsvVersion1Version2Converter* self = new (ELeave) CMsvVersion1Version2Converter(aDBAdapter,aMessageDBAdapter,aDriveNum,aConversionResume); |
|
375 CleanupStack::PushL(self); |
|
376 |
|
377 self->ConstructL(); |
|
378 |
|
379 CleanupStack::Pop(self); |
|
380 return self; |
|
381 } |
|
382 |
|
383 /** |
|
384 ~CMsvVersion1Version2Converter() |
|
385 |
|
386 @param None: |
|
387 @retun None. |
|
388 @internalComponent |
|
389 */ |
|
390 CMsvVersion1Version2Converter::~CMsvVersion1Version2Converter() |
|
391 { |
|
392 iConvertedMtmArray.Close(); |
|
393 |
|
394 delete iSmsRecipientAddressFields; |
|
395 iSmsRecipientAddressFields = NULL; |
|
396 |
|
397 iRecipientDetails.Close(); |
|
398 iEmailOverSmsAddress.Close(); |
|
399 |
|
400 iEmailfieldPairList.ResetAndDestroy(); |
|
401 iEmailfieldPairList.Close(); |
|
402 iTableFieldPairList.ResetAndDestroy(); |
|
403 iTableFieldPairList.Close(); |
|
404 |
|
405 delete iEncodingInfo; |
|
406 iEncodingInfo = NULL; |
|
407 |
|
408 iServiceIdArray.Close(); |
|
409 } |
|
410 |
|
411 /** |
|
412 ConstructL() |
|
413 |
|
414 @param None: |
|
415 @retun None. |
|
416 @internalComponent |
|
417 */ |
|
418 void CMsvVersion1Version2Converter::ConstructL() |
|
419 { |
|
420 iResumeStatus.lastId = 0; |
|
421 iResumeStatus.mtmId.iUid = 0; |
|
422 iResumeStatus.serviceId = 0; |
|
423 iResumeStatus.sourceVersion = 1; |
|
424 iResumeStatus.targetVersion = 2; |
|
425 iResumeStatus.remainingCount = 0; |
|
426 |
|
427 iEncodingInfo = new (ELeave) CArrayFixFlat<TImHeaderEncodingInfo>(KArrayGranularity); |
|
428 } |
|
429 |
|
430 /* |
|
431 GetPropertyValue() |
|
432 Gets the value of RProperty object. This value is used to check if cancel request is |
|
433 issued for the store conversion in progress |
|
434 |
|
435 @param None |
|
436 @return: Value of the property |
|
437 @internalComponent |
|
438 */ |
|
439 TInt CMsvVersion1Version2Converter::GetPropertyValue() |
|
440 { |
|
441 TInt value; |
|
442 TInt err = RProperty::Get(KMyPropertyCat,KMyPropertyName, value); |
|
443 return value; |
|
444 } |
|
445 |
|
446 |
|
447 /** |
|
448 ConvertMessageStoreL() |
|
449 Starts conversion of version 1 message store to version 2 |
|
450 It is responsible for the conversion of sms, imap and pop messages. |
|
451 It sequentially converts the above MTM's, reading messages and inserting the same in database table |
|
452 Header tables for MTM's are created only if a service entry is found for it. |
|
453 It takes care of resuming conversion (RESTART), updation/removal of conversion status table entries, |
|
454 creation of header tables etc. |
|
455 |
|
456 @param None: |
|
457 @retun None. |
|
458 @internalComponent |
|
459 */ |
|
460 void CMsvVersion1Version2Converter::ConvertMessageStoreL() |
|
461 { |
|
462 // this class will take care of converting all mtms for v1 to v2 |
|
463 |
|
464 iConvertedMtmArray.AppendL(KUidMsvSmsMtm); |
|
465 iConvertedMtmArray.AppendL(KUidMsgTypeIMAP4); // imap |
|
466 iConvertedMtmArray.AppendL(KUidMsgTypePOP3); // pop/smtpKUidMsgTypeSMTP |
|
467 iConvertedMtmArray.AppendL(KUidMsgTypeSMTP); // pop/smtpKUidMsgTypeSMTP |
|
468 |
|
469 TInt pos=0; |
|
470 if(iResume) |
|
471 { |
|
472 iDBAdapter.GetConversionStatusL(iResumeStatus); |
|
473 pos = iConvertedMtmArray.Find(iResumeStatus.mtmId); |
|
474 |
|
475 if (pos == KErrNotFound)// nothing found |
|
476 { |
|
477 pos = 0; |
|
478 iResume = EFalse; |
|
479 } |
|
480 } |
|
481 |
|
482 while(pos < iConvertedMtmArray.Count()) |
|
483 { |
|
484 |
|
485 TInt mtmId = iConvertedMtmArray[pos].iUid; |
|
486 |
|
487 switch(mtmId) |
|
488 { |
|
489 case 0x1000102C: // sms |
|
490 { |
|
491 /* |
|
492 1. Read TMsvIds |
|
493 2. Construct path |
|
494 3. Create header table for header part |
|
495 4. Open file and Read header part and Email over sms part |
|
496 5. Insert Header and Email Over sms part into the header table |
|
497 6 Open file and Read body part |
|
498 7. Insert body part into the body table |
|
499 8. commit the changes. |
|
500 */ |
|
501 iResumeStatus.mtmId.iUid = iConvertedMtmArray[pos].iUid; |
|
502 iDBAdapter.BeginTransactionL(); |
|
503 if(iResume) |
|
504 { |
|
505 // Resume conversion from the last point |
|
506 iDBAdapter.GetRemainingServiceIdsL(iServiceIdArray); |
|
507 iResume = EFalse; |
|
508 } |
|
509 else |
|
510 { |
|
511 // get all serviceIds belong to sms mtm. |
|
512 iDBAdapter.GetAllServiceIDsForMtmL(iConvertedMtmArray[pos].iUid,iServiceIdArray); |
|
513 |
|
514 //Lets create resume status for all the serviceids |
|
515 iResumeStatus.mtmId.iUid = iConvertedMtmArray[pos].iUid; |
|
516 |
|
517 for(TInt j =0; j < iServiceIdArray.Count(); j++) |
|
518 { |
|
519 iResumeStatus.lastId = 0; |
|
520 |
|
521 iResumeStatus.serviceId = iServiceIdArray[j]; |
|
522 iResumeStatus.sourceVersion = 1; |
|
523 iResumeStatus.targetVersion = 2; |
|
524 iResumeStatus.remainingCount = iDBAdapter.GetMessageCountL(iServiceIdArray[j]); |
|
525 iDBAdapter.AddConversionStatusEntryL(iResumeStatus); |
|
526 } |
|
527 if(iServiceIdArray.Count() !=0) |
|
528 { |
|
529 CreateSmsHeaderTableL(); |
|
530 iMessageDBAdapter.CreateHeaderTableL(TUid::Uid(iResumeStatus.mtmId.iUid),iTableFieldPairList,iLastErrorMessage); |
|
531 iTableFieldPairList.ResetAndDestroy(); |
|
532 } |
|
533 } |
|
534 |
|
535 iDBAdapter.CommitTransactionL(); |
|
536 |
|
537 for(TInt serviceIdPosition = 0;serviceIdPosition<iServiceIdArray.Count();serviceIdPosition++) |
|
538 { |
|
539 /* Read and Insert Header and Body part of Sms Mesasge */ |
|
540 InternalizeSmsMessageL(iServiceIdArray[serviceIdPosition],iResumeStatus.mtmId.iUid); |
|
541 } |
|
542 /* remove all conversion status entries */ |
|
543 for(TInt serviceIdPosition = 0;serviceIdPosition<iServiceIdArray.Count();serviceIdPosition++) |
|
544 { |
|
545 iDBAdapter.RemoveConversionStatusEntriesL(); |
|
546 } |
|
547 |
|
548 iServiceIdArray.Reset(); |
|
549 pos++; // next one is imap |
|
550 |
|
551 // get all service ids for IMAP |
|
552 iDBAdapter.GetAllServiceIDsForMtmL(iConvertedMtmArray[pos].iUid,iServiceIdArray); |
|
553 } |
|
554 break; |
|
555 case 0x1000102A: // imap |
|
556 { |
|
557 ConvertEMailImapMessagesL(pos); |
|
558 |
|
559 iServiceIdArray.Reset(); |
|
560 pos++; // next one is pop |
|
561 |
|
562 // get all service ids for POP |
|
563 iDBAdapter.GetAllServiceIDsForMtmL(iConvertedMtmArray[pos].iUid,iServiceIdArray); |
|
564 |
|
565 break;// imap conversion |
|
566 } |
|
567 |
|
568 case 0x10001029: //email pop/smtp |
|
569 { |
|
570 ConvertEMailPopMessagesL(pos); |
|
571 iServiceIdArray.Reset(); |
|
572 pos++; |
|
573 // get all service ids for POP |
|
574 iDBAdapter.GetAllServiceIDsForMtmL(iConvertedMtmArray[pos].iUid,iServiceIdArray); |
|
575 |
|
576 break; |
|
577 } |
|
578 |
|
579 case 0x10001028: |
|
580 { |
|
581 ConvertEMailSmtpMessagesL(pos); |
|
582 iServiceIdArray.Reset(); |
|
583 pos++; |
|
584 } |
|
585 } |
|
586 } |
|
587 } |
|
588 |
|
589 /** |
|
590 ConvertEMailImapMessagesL() |
|
591 Converts IMAP message headers |
|
592 |
|
593 @param None: |
|
594 @retun None. |
|
595 @internalComponent |
|
596 */ |
|
597 void CMsvVersion1Version2Converter::ConvertEMailImapMessagesL(TInt aConvertedMtmArrayIndex) |
|
598 { |
|
599 if(iResume) |
|
600 { |
|
601 // Resume conversion from the last point |
|
602 iDBAdapter.GetRemainingServiceIdsL(iServiceIdArray); |
|
603 |
|
604 iResume = EFalse; |
|
605 } |
|
606 else // new conversion request |
|
607 { |
|
608 if(iServiceIdArray.Count()) |
|
609 { |
|
610 /* New request for Imap messages. |
|
611 iServiceIdArray array is filled with all service ids prior to this function call. |
|
612 This ensures we periodically update the conversion resume table and commit the open |
|
613 transaction with the database*/ |
|
614 |
|
615 iDBAdapter.BeginTransactionL(); |
|
616 |
|
617 //Lets create resume status for all the serviceids |
|
618 iResumeStatus.mtmId.iUid = iConvertedMtmArray[aConvertedMtmArrayIndex].iUid; |
|
619 |
|
620 for(TInt j =0; j < iServiceIdArray.Count(); j++) |
|
621 { |
|
622 iResumeStatus.lastId = 0; |
|
623 |
|
624 iResumeStatus.serviceId = iServiceIdArray[j]; |
|
625 iResumeStatus.sourceVersion = 1; |
|
626 iResumeStatus.targetVersion = 2; |
|
627 iResumeStatus.remainingCount = iDBAdapter.GetMessageCountL(iServiceIdArray[j]); |
|
628 iDBAdapter.AddConversionStatusEntryL(iResumeStatus); |
|
629 } |
|
630 |
|
631 // Create header table |
|
632 CreateEMailHeaderTableL(iConvertedMtmArray[aConvertedMtmArrayIndex]); |
|
633 |
|
634 iDBAdapter.CommitTransactionL();// done |
|
635 } |
|
636 } |
|
637 iResumeStatus.mtmId.iUid = iConvertedMtmArray[aConvertedMtmArrayIndex].iUid; |
|
638 |
|
639 StartEMailMessageConversionL(iResumeStatus.mtmId.iUid); |
|
640 |
|
641 // remove all conversion status entries |
|
642 iDBAdapter.RemoveConversionStatusEntriesL(); |
|
643 } |
|
644 |
|
645 /** |
|
646 ConvertEMailPopMessagesL() |
|
647 Converts POP message headers. |
|
648 |
|
649 @param None: |
|
650 @retun None. |
|
651 @internalComponent |
|
652 */ |
|
653 void CMsvVersion1Version2Converter::ConvertEMailPopMessagesL(TInt aConvertedMtmArrayIndex) |
|
654 { |
|
655 |
|
656 iResumeStatus.mtmId.iUid = iConvertedMtmArray[aConvertedMtmArrayIndex].iUid; |
|
657 |
|
658 if(iResume) |
|
659 { |
|
660 // Resume conversion from the last point |
|
661 iDBAdapter.GetRemainingServiceIdsL(iServiceIdArray); |
|
662 iDBAdapter.GetConversionStatusL(iResumeStatus); |
|
663 iResume = EFalse; |
|
664 } |
|
665 else |
|
666 { |
|
667 if(iServiceIdArray.Count()) |
|
668 { |
|
669 /* New request for pop messages. |
|
670 iServiceIdArray array is filled with all service ids prior to this function call. |
|
671 This ensures we periodically update the conversion resume table and commit the open |
|
672 transaction with the database */ |
|
673 |
|
674 iDBAdapter.BeginTransactionL(); |
|
675 |
|
676 iTableFieldPairList.ResetAndDestroy(); |
|
677 |
|
678 // Create header table |
|
679 CreateEMailHeaderTableL(iConvertedMtmArray[aConvertedMtmArrayIndex]); |
|
680 |
|
681 //Lets create resume status for all the serviceids |
|
682 iResumeStatus.mtmId.iUid = iConvertedMtmArray[aConvertedMtmArrayIndex].iUid; |
|
683 |
|
684 for(TInt j =0; j < iServiceIdArray.Count(); j++) |
|
685 { |
|
686 iResumeStatus.lastId = 0; |
|
687 |
|
688 iResumeStatus.serviceId = iServiceIdArray[j]; |
|
689 iResumeStatus.sourceVersion = 1; |
|
690 iResumeStatus.targetVersion = 2; |
|
691 iResumeStatus.remainingCount = iDBAdapter.GetMessageCountL(iServiceIdArray[j]); |
|
692 iDBAdapter.AddConversionStatusEntryL(iResumeStatus); |
|
693 } |
|
694 |
|
695 iDBAdapter.CommitTransactionL();// done |
|
696 } |
|
697 } |
|
698 StartEMailMessageConversionL(iResumeStatus.mtmId.iUid); |
|
699 |
|
700 // remove all conversion ststus entries |
|
701 iDBAdapter.RemoveConversionStatusEntriesL(); |
|
702 |
|
703 } |
|
704 |
|
705 /** |
|
706 ConvertEMailPopMessagesL() |
|
707 Converts POP message headers. |
|
708 |
|
709 @param None: |
|
710 @retun None. |
|
711 @internalComponent |
|
712 */ |
|
713 void CMsvVersion1Version2Converter::ConvertEMailSmtpMessagesL(TInt aConvertedMtmArrayIndex) |
|
714 { |
|
715 |
|
716 iResumeStatus.mtmId.iUid = iConvertedMtmArray[aConvertedMtmArrayIndex].iUid; |
|
717 |
|
718 if(iResume) |
|
719 { |
|
720 // Resume conversion from the last point |
|
721 iDBAdapter.GetRemainingServiceIdsL(iServiceIdArray); |
|
722 iDBAdapter.GetConversionStatusL(iResumeStatus); |
|
723 iResume = EFalse; |
|
724 } |
|
725 else |
|
726 { |
|
727 if(iServiceIdArray.Count()) |
|
728 { |
|
729 /* New request for smtp messages. |
|
730 iServiceIdArray array is filled with all service ids prior to this function call. |
|
731 This ensures we periodically update the conversion resume table and commit the open |
|
732 transaction with the database*/ |
|
733 iDBAdapter.BeginTransactionL(); |
|
734 iTableFieldPairList.ResetAndDestroy(); |
|
735 |
|
736 //Lets create resume status for all the serviceids |
|
737 iResumeStatus.mtmId.iUid = iConvertedMtmArray[aConvertedMtmArrayIndex].iUid; |
|
738 |
|
739 TBool messagesFound = EFalse; |
|
740 for(TInt j =0; j < iServiceIdArray.Count(); j++) |
|
741 { |
|
742 iResumeStatus.lastId = 0; |
|
743 |
|
744 iResumeStatus.serviceId = iServiceIdArray[j]; |
|
745 iResumeStatus.sourceVersion = 1; |
|
746 iResumeStatus.targetVersion = 2; |
|
747 iResumeStatus.remainingCount = iDBAdapter.GetMessageCountL(iServiceIdArray[j]); |
|
748 if(iResumeStatus.remainingCount != 0) |
|
749 { |
|
750 messagesFound = ETrue; |
|
751 } |
|
752 iDBAdapter.AddConversionStatusEntryL(iResumeStatus); |
|
753 } |
|
754 |
|
755 // Create header table if only we have some messages anywhere in the message store |
|
756 if(messagesFound) |
|
757 { |
|
758 CreateEMailHeaderTableL(iConvertedMtmArray[aConvertedMtmArrayIndex]); |
|
759 } |
|
760 |
|
761 iDBAdapter.CommitTransactionL();// done |
|
762 } |
|
763 } |
|
764 StartEMailMessageConversionL(iResumeStatus.mtmId.iUid); |
|
765 |
|
766 // remove all conversion ststus entries |
|
767 iDBAdapter.RemoveConversionStatusEntriesL(); |
|
768 |
|
769 } |
|
770 /** |
|
771 AddFieldL() |
|
772 Appends a CFieldPair object for common header fields to RPointerArray of CFieldPair objects |
|
773 |
|
774 @param aField: Commonly used header fields |
|
775 @retun None. |
|
776 @internalComponent |
|
777 */ |
|
778 void CMsvVersion1Version2Converter::AddFieldL(TCommonHeaderField aField) |
|
779 { |
|
780 CFieldPair *fieldObject = new(ELeave) CFieldPair(); |
|
781 CleanupStack::PushL(fieldObject); |
|
782 |
|
783 fieldObject->iFieldType = ETextField; |
|
784 switch (aField) |
|
785 { |
|
786 case EFrom: |
|
787 _LIT16(KFromText, "From"); |
|
788 fieldObject->iFieldName = KFromText().AllocL(); |
|
789 break; |
|
790 |
|
791 case ETo: |
|
792 _LIT16(KToText, "To"); |
|
793 fieldObject->iFieldName = KToText().AllocL(); |
|
794 break; |
|
795 |
|
796 case ECC: |
|
797 _LIT16(KCCText, "CC"); |
|
798 fieldObject->iFieldName = KCCText().AllocL(); |
|
799 break; |
|
800 |
|
801 case EBCC: |
|
802 _LIT16(KBCCText, "BCC"); |
|
803 fieldObject->iFieldName = KBCCText().AllocL(); |
|
804 break; |
|
805 |
|
806 case ESubject: |
|
807 _LIT16(KSubjectText, "Subject"); |
|
808 fieldObject->iFieldName = KSubjectText().AllocL(); |
|
809 break; |
|
810 |
|
811 default: |
|
812 User::Leave(KErrArgument); |
|
813 } |
|
814 |
|
815 iTableFieldPairList.AppendL(fieldObject); |
|
816 CleanupStack::Pop(fieldObject); |
|
817 } |
|
818 |
|
819 /** |
|
820 AddFieldL() |
|
821 Appends a CFieldPair object to RPointerArray of CFieldPair objects |
|
822 |
|
823 @param aFieldName: Name of the field |
|
824 @param aFieldType: Field type |
|
825 @retun None. |
|
826 @internalComponent |
|
827 */ |
|
828 void CMsvVersion1Version2Converter::AddFieldL(HBufC* aFieldName, EFieldType aFieldType) |
|
829 { |
|
830 if(NULL == aFieldName) |
|
831 { |
|
832 User::Leave(KErrArgument); |
|
833 } |
|
834 |
|
835 CFieldPair *fieldObject = new(ELeave) CFieldPair(); |
|
836 CleanupStack::PushL(fieldObject); |
|
837 |
|
838 fieldObject->iFieldType = aFieldType; |
|
839 fieldObject->iFieldName = aFieldName; |
|
840 |
|
841 iTableFieldPairList.AppendL(fieldObject); |
|
842 CleanupStack::Pop(fieldObject); |
|
843 } |
|
844 |
|
845 |
|
846 /** |
|
847 StartEMailMessageConversionL() |
|
848 Gets all message IDs for each service entry for the mtm that is being converted. |
|
849 It creates the path of the message, reads the message and inserts them in database. |
|
850 For Mime conversion, it checks if the message has attachments and if so than converts its mime information |
|
851 It periodically updates the conversion status entries in the database and commits the same on the main database. |
|
852 |
|
853 @param None: |
|
854 @retun None. |
|
855 @internalComponent |
|
856 */ |
|
857 void CMsvVersion1Version2Converter::StartEMailMessageConversionL(TInt32 aMtm) |
|
858 { |
|
859 TMsvId iD; |
|
860 for(TInt pos = 0; pos<iServiceIdArray.Count();pos++) |
|
861 { |
|
862 |
|
863 |
|
864 iDBAdapter.BeginTransactionL(); |
|
865 |
|
866 RArray<TMsvId> iDArray; |
|
867 CleanupClosePushL (iDArray); |
|
868 |
|
869 // Get ids from the last point |
|
870 // Note : if we are resuming than value of iResumeStatus.lastId is set to the last |
|
871 // message id that was converted, else it is Zero. |
|
872 iDBAdapter.GetAllMessageIdsL(iServiceIdArray[pos],iDArray,aMtm, iResumeStatus.lastId); |
|
873 iResumeStatus.remainingCount = iDArray.Count(); |
|
874 |
|
875 TInt i=0; |
|
876 for (;i<iDArray.Count();i++) |
|
877 { |
|
878 iResumeStatus.lastId = iDArray[i]; |
|
879 iResumeStatus.remainingCount--; |
|
880 |
|
881 iDBAdapter.GetOwningServiceL(iDArray[i],iD); |
|
882 |
|
883 RBuf path; |
|
884 CleanupClosePushL(path); |
|
885 path.CreateL(KMaxPath); |
|
886 |
|
887 CreatePathL(path,iDArray[i],iD); |
|
888 |
|
889 //Read the message |
|
890 TInt headerError = ReadEMailMessageHeaderL(path); |
|
891 TInt encodeHeaderError = ReadEMailMessageEncodedHeaderL(path); |
|
892 |
|
893 if(headerError == KErrNone || encodeHeaderError == KErrNone) |
|
894 { |
|
895 iMessageDBAdapter.CreateHeaderEntryL(TUid::Uid(iResumeStatus.mtmId.iUid), iDArray[i], iEmailfieldPairList); //header |
|
896 iEmailfieldPairList.ResetAndDestroy(); |
|
897 } |
|
898 |
|
899 path.Close(); |
|
900 path.CreateL(KMaxPathConverter); |
|
901 // check if this has mime |
|
902 |
|
903 RArray<TMsvId> mimeIdArray; |
|
904 CleanupClosePushL(mimeIdArray); |
|
905 |
|
906 mimeIdArray.Append(iDArray[i]); |
|
907 iDBAdapter.GetAllMimeIdsL(iDArray[i],mimeIdArray); |
|
908 |
|
909 if(mimeIdArray.Count()) |
|
910 { |
|
911 for(TInt index = 0; index < mimeIdArray.Count();index++) |
|
912 { |
|
913 |
|
914 CreatePathL(path,mimeIdArray[index],iD); |
|
915 |
|
916 TInt error = ReadEmailMimeHeaderL(path); |
|
917 if(!error) |
|
918 { |
|
919 iMessageDBAdapter.CreateHeaderEntryL(iResumeStatus.mtmId, mimeIdArray[index], iEmailfieldPairList); //header |
|
920 iEmailfieldPairList.ResetAndDestroy(); |
|
921 } |
|
922 path.Zero(); |
|
923 } |
|
924 } |
|
925 CleanupStack::PopAndDestroy(&mimeIdArray); |
|
926 CleanupStack::PopAndDestroy(); //path |
|
927 |
|
928 //check if we have a request for cancellation |
|
929 TInt cancel = GetPropertyValue(); |
|
930 if(cancel == KErrCancel ) |
|
931 { |
|
932 User::Leave(KErrCancel); |
|
933 } |
|
934 |
|
935 //update the conversion status |
|
936 if(i % KDBCommitCount == 0 && i != 0) |
|
937 { |
|
938 iResumeStatus.lastId = iDArray[i]; |
|
939 iResumeStatus.serviceId = iServiceIdArray[pos]; |
|
940 iResumeStatus.remainingCount -= KDBCommitCount; |
|
941 |
|
942 iDBAdapter.UpdateConversionStatusEntryL(iResumeStatus); |
|
943 iDBAdapter.CommitTransactionL(); |
|
944 iDBAdapter.BeginTransactionL(); |
|
945 } |
|
946 } |
|
947 |
|
948 CleanupStack::PopAndDestroy(&iDArray); |
|
949 |
|
950 //update status for this service id |
|
951 iResumeStatus.lastId = 0; |
|
952 iResumeStatus.serviceId = iServiceIdArray[pos]; |
|
953 iResumeStatus.remainingCount = 0; |
|
954 iDBAdapter.UpdateConversionStatusEntryL(iResumeStatus); |
|
955 iDBAdapter.CommitTransactionL(); |
|
956 } |
|
957 } |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 /** |
|
963 CreatePathL() |
|
964 Creates path of aessage. The path is constructed based on the message id and its owning service id. |
|
965 |
|
966 @param aMessagePath: Message path |
|
967 @param aId: Message id |
|
968 @param aOwningId: owning id. |
|
969 @retun None. |
|
970 @internalComponent |
|
971 */ |
|
972 void CMsvVersion1Version2Converter::CreatePathL(TDes& aMessagePath, TMsvId aId,TMsvId& aOwningId) |
|
973 { |
|
974 // Construct the mail path for this message entry |
|
975 _LIT16(KMessageFilePath,"\\private\\1000484b\\mail2\\"); |
|
976 TBuf<KMaxPath> src; |
|
977 TPtrC drive(TDriveUnit(iDrive).Name()); |
|
978 |
|
979 aMessagePath.Append(drive); |
|
980 aMessagePath.Append(KMessageFilePath); |
|
981 |
|
982 TBuf<KFileNameFixedWidth> dir; |
|
983 dir.NumFixedWidth(aOwningId, EHex, KFileNameFixedWidth); |
|
984 _LIT16(KMsvDirectoryExt, "_S\\"); |
|
985 aMessagePath.Append(dir); |
|
986 aMessagePath.Append(KMsvDirectoryExt); |
|
987 |
|
988 _LIT16(KDirSep,"\\"); |
|
989 TBuf<KFileNameFixedWidth> dir1; |
|
990 |
|
991 dir1.NumFixedWidth(aId&0xf, EHex,1); |
|
992 aMessagePath.Append(dir1); |
|
993 aMessagePath.Append(KDirSep); |
|
994 dir.NumFixedWidth(aId, EHex, KFileNameFixedWidth); |
|
995 aMessagePath.Append(dir); |
|
996 } |
|
997 |
|
998 /** |
|
999 CreateEMailHeaderTableL() |
|
1000 Creates structure necessary to create email header table. |
|
1001 |
|
1002 @param aMtmId: mtm Id of email component. |
|
1003 @retun None. |
|
1004 @internalComponent |
|
1005 */ |
|
1006 void CMsvVersion1Version2Converter::CreateEMailHeaderTableL(const TUid aMtmId) |
|
1007 { |
|
1008 CreateEMailHeaderTableStructureL(); |
|
1009 iMessageDBAdapter.CreateHeaderTableL(aMtmId,iTableFieldPairList,iLastErrorMessage); |
|
1010 } |
|
1011 |
|
1012 /** |
|
1013 CreateEMailHeaderTableStructureL() |
|
1014 Creates structure necessary to create email header table. |
|
1015 |
|
1016 @param None: |
|
1017 @retun None. |
|
1018 @internalComponent |
|
1019 */ |
|
1020 void CMsvVersion1Version2Converter::CreateEMailHeaderTableStructureL() |
|
1021 { |
|
1022 _LIT16(KEmailHeaderVersion , "Version"); |
|
1023 AddFieldL(KEmailHeaderVersion().AllocL(),EIntegerField); //0 |
|
1024 |
|
1025 _LIT16(KReceiptAddress , "ReceiptAddress"); |
|
1026 AddFieldL(KReceiptAddress().AllocL(),ETextField);//1 |
|
1027 |
|
1028 _LIT16(KImMsgId , "ImMsgId"); |
|
1029 AddFieldL(KImMsgId().AllocL(),ETextField);//2 |
|
1030 |
|
1031 AddFieldL(EFrom);//3 |
|
1032 |
|
1033 _LIT16(KReplyTo , "ReplyTo"); |
|
1034 AddFieldL(KReplyTo().AllocL(),ETextField);//4 |
|
1035 |
|
1036 AddFieldL(ESubject);//5 |
|
1037 |
|
1038 _LIT16(KiRemoteSize , "iRemoteSize"); |
|
1039 AddFieldL(KiRemoteSize().AllocL(),EIntegerField);//6 |
|
1040 |
|
1041 AddFieldL(ETo);//7 |
|
1042 |
|
1043 AddFieldL(ECC);//8 |
|
1044 |
|
1045 AddFieldL(EBCC);//9 |
|
1046 |
|
1047 _LIT16(KEncodingInfo , "EncodingInfo"); |
|
1048 AddFieldL(KEncodingInfo().AllocL(),ETextField);//10 |
|
1049 |
|
1050 _LIT16(KResentMsgId , "ResentMsgId"); |
|
1051 AddFieldL(KResentMsgId().AllocL(),ETextField);//11 |
|
1052 |
|
1053 _LIT16(KResentFrom , "ResentFrom"); |
|
1054 AddFieldL(KResentFrom().AllocL(),ETextField);//12 |
|
1055 |
|
1056 _LIT16(KResentToRecipients , "ResentToRecipients"); |
|
1057 AddFieldL(KResentToRecipients().AllocL(),ETextField);//13 |
|
1058 |
|
1059 _LIT16(KResentCcRecipients , "ResentCcRecipients"); |
|
1060 AddFieldL(KResentCcRecipients().AllocL(),ETextField);//14 |
|
1061 |
|
1062 _LIT16(KResentBccRecipients , "ResentBccRecipients"); |
|
1063 AddFieldL(KResentBccRecipients().AllocL(),ETextField);//15 |
|
1064 |
|
1065 _LIT16(KInReplyTo , "InReplyTo"); |
|
1066 AddFieldL(KInReplyTo().AllocL(),ETextField);//16 |
|
1067 |
|
1068 _LIT16(KBodyEncoding , "BodyEncoding"); |
|
1069 AddFieldL(KBodyEncoding().AllocL(),EIntegerField);//17 |
|
1070 |
|
1071 _LIT16(KCharset , "Charset"); |
|
1072 AddFieldL(KCharset().AllocL(),EIntegerField);//18 |
|
1073 } |
|
1074 |
|
1075 /** |
|
1076 EncodingInfo() |
|
1077 Returns TImHeaderEncodingInfo header encoding info. |
|
1078 |
|
1079 @param None: |
|
1080 @retun None. |
|
1081 @internalComponent |
|
1082 */ |
|
1083 CArrayFix<TImHeaderEncodingInfo>& CMsvVersion1Version2Converter::EncodingInfo() |
|
1084 { |
|
1085 return *iEncodingInfo; |
|
1086 } |
|
1087 |
|
1088 /** |
|
1089 ReadEMailMessageHeaderL() |
|
1090 Reads an email message header from the specified path and fills RPointerArray of CHeaderFields |
|
1091 from the header objects. |
|
1092 |
|
1093 @param aMessagePath: Message path. |
|
1094 @retun None. |
|
1095 @internalComponent |
|
1096 */ |
|
1097 TInt CMsvVersion1Version2Converter::ReadEMailMessageHeaderL(TDesC& aMessagePath) |
|
1098 { |
|
1099 RFs fs; |
|
1100 User::LeaveIfError(fs.Connect()); |
|
1101 CleanupClosePushL(fs); |
|
1102 |
|
1103 RFile file; |
|
1104 TInt error = file.Open(fs,aMessagePath,EFileRead); |
|
1105 |
|
1106 if(error != KErrNone) |
|
1107 { |
|
1108 CleanupStack::PopAndDestroy(&fs); //fs |
|
1109 file.Close(); |
|
1110 fs.Close(); |
|
1111 return EFalse; |
|
1112 } |
|
1113 |
|
1114 CleanupClosePushL(file); |
|
1115 |
|
1116 RFileReadStream in(file); |
|
1117 in.PushL(); |
|
1118 |
|
1119 TCheckedUid check; |
|
1120 in >> check; |
|
1121 if(check.UidType().IsValid()==EFalse) |
|
1122 return EFalse; |
|
1123 |
|
1124 CArrayFix<TPairedTUidHBufC8>* iStreams = new(ELeave) CArrayFixFlat<TPairedTUidHBufC8>(5); |
|
1125 in >> *iStreams;; |
|
1126 |
|
1127 // check if this stream is present |
|
1128 TPairedTUidHBufC8 entry; |
|
1129 entry.iUid=KUidMsgFileIMailHeader; |
|
1130 TKeyArrayFix key(_FOFF(TPairedTUidHBufC8,iUid),ECmpTInt32); |
|
1131 |
|
1132 TInt pos; |
|
1133 TInt found = (iStreams->FindIsq(entry,key,pos)); |
|
1134 |
|
1135 if(found == KErrNone) |
|
1136 { |
|
1137 |
|
1138 HBufC8 *buffer=iStreams->At(pos).iBuf; |
|
1139 HMsvReadBuffer *buf = new (ELeave) HMsvReadBuffer(*buffer); |
|
1140 RReadStream infoHeader(buf); |
|
1141 |
|
1142 /*Lets start reading the Header Info */ |
|
1143 CHeaderFields* emailHeaderFields = new (ELeave)CHeaderFields(); |
|
1144 CleanupStack::PushL(emailHeaderFields); |
|
1145 emailHeaderFields->iUid = KUidMsgFileIMailHeader; |
|
1146 CleanupStack::Pop(emailHeaderFields); |
|
1147 |
|
1148 CFieldPair* emailHeaderVersionfield = new (ELeave)CFieldPair(); |
|
1149 CleanupStack::PushL(emailHeaderVersionfield); |
|
1150 emailHeaderVersionfield->iFieldNumValue = infoHeader.ReadUint16L(); |
|
1151 emailHeaderFields->iFieldPairList.AppendL(emailHeaderVersionfield); |
|
1152 CleanupStack::Pop(emailHeaderVersionfield); |
|
1153 |
|
1154 HBufC16* receipt = HBufC::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1155 CFieldPair* emailReceiptAddress = new (ELeave)CFieldPair(); |
|
1156 CleanupStack::PushL(emailReceiptAddress); |
|
1157 emailReceiptAddress->iFieldTextValue = receipt; |
|
1158 emailHeaderFields->iFieldPairList.AppendL(emailReceiptAddress); |
|
1159 CleanupStack::Pop(emailReceiptAddress); |
|
1160 |
|
1161 HBufC8* msgId = HBufC8::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1162 CFieldPair* emailImMsgId = new (ELeave)CFieldPair(); |
|
1163 CleanupStack::PushL(emailImMsgId); |
|
1164 emailImMsgId->iFieldTextValue = HBufC16::NewL(KMaxImHeaderStringLength); |
|
1165 emailImMsgId->iFieldTextValue->Des().Copy(msgId->Des()); |
|
1166 emailHeaderFields->iFieldPairList.AppendL(emailImMsgId); |
|
1167 CleanupStack::Pop(emailImMsgId); |
|
1168 delete msgId; |
|
1169 |
|
1170 HBufC16* from = HBufC::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1171 CFieldPair* emailFrom = new (ELeave)CFieldPair(); |
|
1172 CleanupStack::PushL(emailFrom); |
|
1173 emailFrom->iFieldTextValue = from; |
|
1174 emailHeaderFields->iFieldPairList.AppendL(emailFrom); |
|
1175 CleanupStack::Pop(emailFrom); |
|
1176 |
|
1177 HBufC16* replyTo = HBufC::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1178 CFieldPair* emailReplyTo = new (ELeave)CFieldPair(); |
|
1179 CleanupStack::PushL(emailReplyTo); |
|
1180 emailReplyTo->iFieldTextValue = replyTo; |
|
1181 emailHeaderFields->iFieldPairList.AppendL(emailReplyTo); |
|
1182 CleanupStack::Pop(emailReplyTo); |
|
1183 |
|
1184 HBufC16* subject = HBufC::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1185 CFieldPair* emailSubject = new (ELeave)CFieldPair(); |
|
1186 CleanupStack::PushL(emailSubject); |
|
1187 emailSubject->iFieldTextValue = subject; |
|
1188 emailHeaderFields->iFieldPairList.AppendL(emailSubject); |
|
1189 CleanupStack::Pop(emailSubject); |
|
1190 |
|
1191 CFieldPair* emailRemoteSize = new (ELeave)CFieldPair(); |
|
1192 CleanupStack::PushL(emailRemoteSize); |
|
1193 emailRemoteSize->iFieldNumValue = infoHeader.ReadUint32L(); |
|
1194 emailHeaderFields->iFieldPairList.AppendL(emailRemoteSize); |
|
1195 CleanupStack::Pop(emailRemoteSize); |
|
1196 |
|
1197 TInt index = 0; |
|
1198 RBuf strbuf; |
|
1199 CleanupClosePushL(strbuf); |
|
1200 strbuf.CreateL(500); |
|
1201 |
|
1202 CDesCArray* to = new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
1203 infoHeader >> *to; |
|
1204 for( index = 0;index< to->MdcaCount();index++) |
|
1205 { |
|
1206 strbuf.Append(to->MdcaPoint(index)); |
|
1207 if((index + 1) != to->MdcaCount()) |
|
1208 { |
|
1209 strbuf.Append(KComma); |
|
1210 } |
|
1211 else |
|
1212 { |
|
1213 strbuf.Append(KSeparator); |
|
1214 } |
|
1215 } |
|
1216 |
|
1217 delete to; |
|
1218 to = NULL; |
|
1219 |
|
1220 CFieldPair* emailToRecipients = new (ELeave)CFieldPair(); |
|
1221 CleanupStack::PushL(emailToRecipients); |
|
1222 emailToRecipients->iFieldTextValue = strbuf.AllocL(); |
|
1223 emailHeaderFields->iFieldPairList.AppendL(emailToRecipients); |
|
1224 CleanupStack::Pop(emailToRecipients); |
|
1225 |
|
1226 strbuf.Zero(); |
|
1227 |
|
1228 CDesCArray* cc = new (ELeave)CDesCArrayFlat( KArrayGranularity ); |
|
1229 infoHeader >> *cc; |
|
1230 |
|
1231 for( index = 0;index< cc->MdcaCount();index++) |
|
1232 { |
|
1233 strbuf.Append(cc->MdcaPoint(index)); |
|
1234 if((index + 1) != cc->MdcaCount()) |
|
1235 { |
|
1236 strbuf.Append(KComma); |
|
1237 } |
|
1238 else |
|
1239 { |
|
1240 strbuf.Append(KSeparator); |
|
1241 } |
|
1242 |
|
1243 |
|
1244 |
|
1245 } |
|
1246 delete cc; |
|
1247 cc = NULL; |
|
1248 |
|
1249 CFieldPair* emailCcRecipients = new (ELeave)CFieldPair(); |
|
1250 CleanupStack::PushL(emailCcRecipients); |
|
1251 emailCcRecipients->iFieldTextValue = strbuf.AllocL(); |
|
1252 emailHeaderFields->iFieldPairList.AppendL(emailCcRecipients); |
|
1253 CleanupStack::Pop(emailCcRecipients); |
|
1254 |
|
1255 strbuf.Zero(); |
|
1256 |
|
1257 CDesCArray* bcc = new (ELeave)CDesCArrayFlat( KArrayGranularity ); |
|
1258 infoHeader >> *bcc; |
|
1259 |
|
1260 for( index = 0;index< bcc->MdcaCount();index++) |
|
1261 { |
|
1262 strbuf.Append(bcc->MdcaPoint(index)); |
|
1263 if((index + 1) != bcc->MdcaCount()) |
|
1264 { |
|
1265 strbuf.Append(KComma); |
|
1266 } |
|
1267 else |
|
1268 { |
|
1269 strbuf.Append(KSeparator); |
|
1270 } |
|
1271 |
|
1272 } |
|
1273 delete bcc; |
|
1274 bcc = NULL; |
|
1275 |
|
1276 CFieldPair* emailBCcRecipients = new (ELeave)CFieldPair(); |
|
1277 CleanupStack::PushL(emailBCcRecipients); |
|
1278 emailBCcRecipients->iFieldTextValue = strbuf.AllocL(); |
|
1279 emailHeaderFields->iFieldPairList.AppendL(emailBCcRecipients); |
|
1280 CleanupStack::Pop(emailBCcRecipients); |
|
1281 |
|
1282 strbuf.Zero(); |
|
1283 |
|
1284 //Read Email encoding info |
|
1285 infoHeader >> EncodingInfo(); |
|
1286 CFieldPair* emailEncodingInfo = new (ELeave)CFieldPair(); |
|
1287 |
|
1288 RBuf16 encodinginfo; |
|
1289 CleanupClosePushL(encodinginfo); |
|
1290 encodinginfo.CreateL(iEncodingInfo->Count() * sizeof(TImHeaderEncodingInfo)); |
|
1291 if(iEncodingInfo->Count()) |
|
1292 { |
|
1293 for (index =0; index<iEncodingInfo->Count(); index++) |
|
1294 { |
|
1295 encodinginfo.AppendNum(iEncodingInfo->At(index).Field()); |
|
1296 strbuf.Append(KComma); |
|
1297 encodinginfo.AppendNum(iEncodingInfo->At(index).Offset()); |
|
1298 strbuf.Append(KComma); |
|
1299 encodinginfo.AppendNum(iEncodingInfo->At(index).Length()); |
|
1300 strbuf.Append(KComma); |
|
1301 encodinginfo.AppendNum(iEncodingInfo->At(index).EncodingType()); |
|
1302 strbuf.Append(KComma); |
|
1303 encodinginfo.AppendNum(iEncodingInfo->At(index).ArrayValue()); |
|
1304 strbuf.Append(KComma); |
|
1305 encodinginfo.AppendNum(iEncodingInfo->At(index).CharsetUid()); |
|
1306 strbuf.Append(KComma); |
|
1307 encodinginfo.AppendNum(iEncodingInfo->At(index).AddSpace()); |
|
1308 strbuf.Append(KComma); |
|
1309 encodinginfo.AppendNum(iEncodingInfo->At(index).EncodedLength()); |
|
1310 strbuf.Append(KSeparator); |
|
1311 } |
|
1312 emailEncodingInfo->iFieldTextValue = encodinginfo.AllocL(); |
|
1313 } |
|
1314 else |
|
1315 { |
|
1316 emailEncodingInfo->iFieldTextValue = KNullDesC().AllocL(); |
|
1317 } |
|
1318 emailHeaderFields->iFieldPairList.AppendL(emailEncodingInfo); |
|
1319 |
|
1320 HBufC8* resentMsgId = HBufC8::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1321 CFieldPair* emailResentMsgId = new (ELeave)CFieldPair(); |
|
1322 CleanupStack::PushL(emailResentMsgId); |
|
1323 emailResentMsgId->iFieldTextValue = (HBufC16*)(resentMsgId); |
|
1324 emailHeaderFields->iFieldPairList.AppendL(emailResentMsgId); |
|
1325 CleanupStack::Pop(emailResentMsgId); |
|
1326 |
|
1327 HBufC16* resentFrom = HBufC::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1328 CFieldPair* emailResentFrom = new (ELeave)CFieldPair(); |
|
1329 CleanupStack::PushL(emailResentFrom); |
|
1330 emailResentFrom->iFieldTextValue =(HBufC16*)(resentFrom); |
|
1331 emailHeaderFields->iFieldPairList.AppendL(emailResentFrom); |
|
1332 CleanupStack::Pop(emailResentFrom); |
|
1333 |
|
1334 CDesCArray* resentTo = new (ELeave)CDesCArrayFlat( KArrayGranularity ); |
|
1335 CDesCArray* resentCc = new (ELeave)CDesCArrayFlat( KArrayGranularity ); |
|
1336 CDesCArray* resentBcc = new (ELeave)CDesCArrayFlat( KArrayGranularity ); |
|
1337 |
|
1338 |
|
1339 CFieldPair* emailResentToRecipients= new (ELeave)CFieldPair(); |
|
1340 CleanupStack::PushL(emailResentToRecipients); |
|
1341 infoHeader >> *resentTo; |
|
1342 for(index = 0;index< resentTo->MdcaCount();index++) |
|
1343 { |
|
1344 strbuf.Append(resentTo->MdcaPoint(index)); |
|
1345 if((index + 1) != resentTo->MdcaCount()) |
|
1346 { |
|
1347 strbuf.Append(KComma); |
|
1348 } |
|
1349 else |
|
1350 { |
|
1351 strbuf.Append(KSeparator); |
|
1352 } |
|
1353 } |
|
1354 |
|
1355 emailResentToRecipients->iFieldTextValue = strbuf.AllocL(); |
|
1356 emailHeaderFields->iFieldPairList.AppendL(emailResentToRecipients); |
|
1357 CleanupStack::Pop(emailResentToRecipients); |
|
1358 |
|
1359 delete resentTo; |
|
1360 resentTo = NULL; |
|
1361 |
|
1362 strbuf.Zero(); |
|
1363 |
|
1364 CFieldPair* emailResentCcRecipients= new (ELeave)CFieldPair(); |
|
1365 CleanupStack::PushL(emailResentCcRecipients); |
|
1366 infoHeader >> *resentCc; |
|
1367 for(index = 0;index< resentCc->MdcaCount();index++) |
|
1368 { |
|
1369 strbuf.Append(resentCc->MdcaPoint(index)); |
|
1370 if((index + 1) != resentCc->MdcaCount()) |
|
1371 { |
|
1372 strbuf.Append(KComma); |
|
1373 } |
|
1374 else |
|
1375 { |
|
1376 strbuf.Append(KSeparator); |
|
1377 } |
|
1378 } |
|
1379 emailResentCcRecipients->iFieldTextValue = strbuf.AllocL(); |
|
1380 emailHeaderFields->iFieldPairList.AppendL(emailResentCcRecipients); |
|
1381 CleanupStack::Pop(emailResentCcRecipients); |
|
1382 |
|
1383 delete resentCc; |
|
1384 resentCc = NULL; |
|
1385 strbuf.Zero(); |
|
1386 |
|
1387 CFieldPair* emailResentBccRecipients= new (ELeave)CFieldPair(); |
|
1388 CleanupStack::PushL(emailResentBccRecipients); |
|
1389 infoHeader >> *resentBcc; |
|
1390 for(index = 0;index< resentBcc->MdcaCount();index++) |
|
1391 { |
|
1392 strbuf.Append(resentBcc->MdcaPoint(index)); |
|
1393 if((index + 1) != resentBcc->MdcaCount()) |
|
1394 { |
|
1395 strbuf.Append(KComma); |
|
1396 } |
|
1397 else |
|
1398 { |
|
1399 strbuf.Append(KSeparator); |
|
1400 } |
|
1401 } |
|
1402 |
|
1403 emailResentBccRecipients->iFieldTextValue = strbuf.AllocL(); |
|
1404 emailHeaderFields->iFieldPairList.AppendL(emailResentBccRecipients); |
|
1405 CleanupStack::Pop(emailResentBccRecipients); |
|
1406 |
|
1407 delete resentBcc; |
|
1408 resentBcc = NULL; |
|
1409 strbuf.Zero(); |
|
1410 |
|
1411 HBufC8* inReplyTo = HBufC8::NewL( infoHeader, KMaxImHeaderStringLength ); |
|
1412 CFieldPair* emailInReplyTo = new (ELeave)CFieldPair(); |
|
1413 CleanupStack::PushL(emailInReplyTo); |
|
1414 emailInReplyTo->iFieldTextValue = (HBufC16*)(inReplyTo); |
|
1415 emailHeaderFields->iFieldPairList.AppendL(emailInReplyTo); |
|
1416 CleanupStack::Pop(emailInReplyTo); |
|
1417 |
|
1418 TInt bodyEncoding = infoHeader.ReadUint8L(); |
|
1419 CFieldPair* emailBodyEncoding = new (ELeave)CFieldPair(); |
|
1420 CleanupStack::PushL(emailBodyEncoding); |
|
1421 emailBodyEncoding->iFieldNumValue = bodyEncoding; |
|
1422 emailHeaderFields->iFieldPairList.AppendL(emailBodyEncoding); |
|
1423 CleanupStack::Pop(emailBodyEncoding); |
|
1424 |
|
1425 TUint headerCharset = infoHeader.ReadUint32L(); |
|
1426 CFieldPair* emailCharset = new (ELeave)CFieldPair(); |
|
1427 CleanupStack::PushL(emailCharset); |
|
1428 emailCharset->iFieldNumValue = headerCharset; |
|
1429 emailHeaderFields->iFieldPairList.AppendL(emailCharset); |
|
1430 CleanupStack::Pop(emailCharset); |
|
1431 |
|
1432 CFieldPair* emaildetailField = new (ELeave)CFieldPair(); |
|
1433 CleanupStack::PushL(emaildetailField); |
|
1434 emaildetailField->iFieldName = KDetails().AllocL(); |
|
1435 emaildetailField->iFieldType = ETextField; |
|
1436 emaildetailField->iFieldTextValue = KSpace().AllocL(); |
|
1437 emailHeaderFields->iFieldPairList.AppendL(emaildetailField); |
|
1438 CleanupStack::Pop(emaildetailField); |
|
1439 |
|
1440 iEmailfieldPairList.AppendL(emailHeaderFields); |
|
1441 |
|
1442 CleanupStack::PopAndDestroy(&encodinginfo); |
|
1443 CleanupStack::PopAndDestroy(&strbuf); |
|
1444 infoHeader.Close(); |
|
1445 } |
|
1446 TInt count=iStreams->Count(); |
|
1447 while(count--) |
|
1448 { |
|
1449 delete iStreams->At(count).iBuf; |
|
1450 } |
|
1451 |
|
1452 delete iStreams; |
|
1453 iStreams=NULL; |
|
1454 CleanupStack::PopAndDestroy(3); // in , file.fs |
|
1455 |
|
1456 return KErrNone; |
|
1457 } |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 /** |
|
1464 ReadEMailMessageEncodedHeaderL() |
|
1465 Reads an email message encoded header from the specified path and fills RPointerArray of CHeaderFields |
|
1466 from these read header objects. |
|
1467 |
|
1468 @param aMessagePath: message path. |
|
1469 @retun TInt: Error code specifying if the message was read successfully. |
|
1470 @internalComponent |
|
1471 */ |
|
1472 TInt CMsvVersion1Version2Converter::ReadEMailMessageEncodedHeaderL(TDesC& aMessagePath) |
|
1473 { |
|
1474 RFs fs; |
|
1475 User::LeaveIfError(fs.Connect()); |
|
1476 CleanupClosePushL(fs); |
|
1477 |
|
1478 RFile file; |
|
1479 TInt error = file.Open(fs,aMessagePath,EFileRead|EFileShareAny); |
|
1480 if(error != KErrNone) |
|
1481 { |
|
1482 CleanupStack::PopAndDestroy(&fs); // fs |
|
1483 file.Close(); |
|
1484 fs.Close(); |
|
1485 return EFalse; |
|
1486 } |
|
1487 |
|
1488 CleanupClosePushL(file); |
|
1489 |
|
1490 /*Prepare the stream*/ |
|
1491 CArrayFix<TPairedTUidHBufC8> *iStreams = new(ELeave) CArrayFixFlat<TPairedTUidHBufC8>(5); |
|
1492 |
|
1493 RFileReadStream in(file); |
|
1494 in.PushL(); |
|
1495 |
|
1496 TCheckedUid check; |
|
1497 in >> check; |
|
1498 if(check.UidType().IsValid()==EFalse) |
|
1499 return EFalse; |
|
1500 |
|
1501 in >> *iStreams;; |
|
1502 |
|
1503 TPairedTUidHBufC8 entry; |
|
1504 entry.iUid=KUidMsgFileIMailEncodedHeader; |
|
1505 |
|
1506 TKeyArrayFix key(_FOFF(TPairedTUidHBufC8,iUid),ECmpTInt32); |
|
1507 |
|
1508 TInt pos; |
|
1509 TInt found = (iStreams->FindIsq(entry,key,pos)); |
|
1510 |
|
1511 if(found == KErrNone) |
|
1512 { |
|
1513 HBufC8 *buffer=iStreams->At(pos).iBuf; |
|
1514 HMsvReadBuffer *buf = new (ELeave) HMsvReadBuffer(*buffer); |
|
1515 RReadStream infoencodedHeader(buf); |
|
1516 |
|
1517 TInt version = infoencodedHeader.ReadUint16L(); |
|
1518 |
|
1519 HBufC8* from = HBufC8::NewL(infoencodedHeader, KMaxImHeaderStringLength); |
|
1520 HBufC8* replyTo = HBufC8::NewL(infoencodedHeader, KMaxImHeaderStringLength); |
|
1521 HBufC8* subject = HBufC8::NewL(infoencodedHeader, KMaxImHeaderStringLength); |
|
1522 |
|
1523 CDesCArray* to = new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
1524 CDesCArray* cc = new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
1525 CDesCArray* bcc = new (ELeave) CDesCArrayFlat( KArrayGranularity ); |
|
1526 |
|
1527 infoencodedHeader >> *to; |
|
1528 infoencodedHeader >> *cc; |
|
1529 infoencodedHeader >> *bcc; |
|
1530 |
|
1531 TInt decodeCharset = infoencodedHeader.ReadUint32L(); |
|
1532 |
|
1533 // prepare the RBuf |
|
1534 RBuf strbuf; |
|
1535 CleanupClosePushL(strbuf); |
|
1536 strbuf.CreateL(KMaxBufferLength); |
|
1537 strbuf.AppendNum(version); |
|
1538 |
|
1539 strbuf.Append(KSeparator); |
|
1540 |
|
1541 HBufC16* fromTextValue = HBufC16::NewL(KMaxImHeaderStringLength); |
|
1542 fromTextValue->Des().Copy(from->Des()); |
|
1543 strbuf.Append(fromTextValue->Des()); |
|
1544 delete from; |
|
1545 delete fromTextValue; |
|
1546 |
|
1547 strbuf.Append(KSeparator); |
|
1548 |
|
1549 HBufC16* replyTextValue = HBufC16::NewL(KMaxImHeaderStringLength); |
|
1550 replyTextValue->Des().Copy(replyTo->Des()); |
|
1551 strbuf.Append(replyTextValue->Des()); |
|
1552 delete replyTo; |
|
1553 delete replyTextValue; |
|
1554 |
|
1555 strbuf.Append(KSeparator); |
|
1556 |
|
1557 HBufC16* subjectTextValue = HBufC16::NewL(KMaxImHeaderStringLength); |
|
1558 subjectTextValue->Des().Copy(subject->Des()); |
|
1559 strbuf.Append(subjectTextValue->Des()); |
|
1560 delete subject; |
|
1561 delete subjectTextValue; |
|
1562 |
|
1563 strbuf.Append(KSeparator); |
|
1564 |
|
1565 for(TInt i = 0;i< to->MdcaCount();i++) |
|
1566 { |
|
1567 strbuf.Append(to->MdcaPoint(i)); |
|
1568 if((i + 1) != (to->MdcaCount())) |
|
1569 |
|
1570 { |
|
1571 strbuf.Append(KComma); |
|
1572 } |
|
1573 } |
|
1574 strbuf.Append(KSeparator); |
|
1575 delete to; |
|
1576 to = NULL; |
|
1577 |
|
1578 for(TInt i = 0;i< cc->MdcaCount();i++) |
|
1579 { |
|
1580 strbuf.Append(cc->MdcaPoint(i)); |
|
1581 if((i+1) != cc->MdcaCount()) |
|
1582 { |
|
1583 strbuf.Append(KComma); |
|
1584 } |
|
1585 } |
|
1586 strbuf.Append(KSeparator); |
|
1587 delete cc; |
|
1588 cc = NULL; |
|
1589 |
|
1590 |
|
1591 for(TInt i = 0;i< bcc->MdcaCount();i++) |
|
1592 { |
|
1593 strbuf.Append(bcc->MdcaPoint(i)); |
|
1594 if((i + 1) != bcc->MdcaCount()) |
|
1595 { |
|
1596 strbuf.Append(KComma); |
|
1597 } |
|
1598 } |
|
1599 strbuf.Append(KSeparator); |
|
1600 delete bcc; |
|
1601 bcc = NULL; |
|
1602 |
|
1603 |
|
1604 strbuf.AppendNum(decodeCharset); |
|
1605 strbuf.Append(KSeparator); |
|
1606 |
|
1607 CHeaderFields* emailEncodedHeaderFields = new (ELeave) CHeaderFields(); |
|
1608 CleanupStack::PushL(emailEncodedHeaderFields); |
|
1609 emailEncodedHeaderFields->iUid = KUidMsgFileIMailEncodedHeader; |
|
1610 CleanupStack::Pop(emailEncodedHeaderFields); |
|
1611 |
|
1612 CFieldPair* emailHeaderVersionfield = new (ELeave)CFieldPair(); |
|
1613 CleanupStack::PushL(emailHeaderVersionfield); |
|
1614 emailEncodedHeaderFields->iFieldPairList.AppendL(emailHeaderVersionfield); |
|
1615 CleanupStack::Pop(emailHeaderVersionfield); |
|
1616 |
|
1617 CFieldPair* emailReceiptAddress = new (ELeave)CFieldPair(); |
|
1618 CleanupStack::PushL(emailReceiptAddress); |
|
1619 emailReceiptAddress->iFieldTextValue = KSpace().Alloc(); |
|
1620 emailEncodedHeaderFields->iFieldPairList.AppendL(emailReceiptAddress); |
|
1621 CleanupStack::Pop(emailReceiptAddress); |
|
1622 |
|
1623 CFieldPair* emailImMsgId = new (ELeave)CFieldPair(); |
|
1624 CleanupStack::PushL(emailImMsgId); |
|
1625 emailImMsgId->iFieldTextValue = KSpace().AllocL(); |
|
1626 emailEncodedHeaderFields->iFieldPairList.AppendL(emailImMsgId); |
|
1627 CleanupStack::Pop(emailImMsgId); |
|
1628 |
|
1629 CFieldPair* emailFrom = new (ELeave)CFieldPair(); |
|
1630 CleanupStack::PushL(emailFrom); |
|
1631 emailFrom->iFieldTextValue = KSpace().AllocL(); |
|
1632 emailEncodedHeaderFields->iFieldPairList.AppendL(emailFrom); |
|
1633 CleanupStack::Pop(emailFrom); |
|
1634 |
|
1635 CFieldPair* emailReplyTo = new (ELeave)CFieldPair(); |
|
1636 CleanupStack::PushL(emailReplyTo); |
|
1637 emailReplyTo->iFieldTextValue = KSpace().AllocL();; |
|
1638 emailEncodedHeaderFields->iFieldPairList.AppendL(emailReplyTo); |
|
1639 CleanupStack::Pop(emailReplyTo); |
|
1640 |
|
1641 CFieldPair* emailSubject = new (ELeave)CFieldPair(); |
|
1642 CleanupStack::PushL(emailSubject); |
|
1643 emailSubject->iFieldTextValue = KSpace().AllocL();; |
|
1644 emailEncodedHeaderFields->iFieldPairList.AppendL(emailSubject); |
|
1645 CleanupStack::Pop(emailSubject); |
|
1646 |
|
1647 CFieldPair* emailRemoteSize = new (ELeave)CFieldPair(); |
|
1648 CleanupStack::PushL(emailRemoteSize); |
|
1649 emailEncodedHeaderFields->iFieldPairList.AppendL(emailRemoteSize); |
|
1650 CleanupStack::Pop(emailRemoteSize); |
|
1651 |
|
1652 CFieldPair* emailToRecipients = new (ELeave)CFieldPair(); |
|
1653 CleanupStack::PushL(emailToRecipients); |
|
1654 emailToRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1655 emailEncodedHeaderFields->iFieldPairList.AppendL(emailToRecipients); |
|
1656 CleanupStack::Pop(emailToRecipients); |
|
1657 |
|
1658 CFieldPair* emailCcRecipients = new (ELeave)CFieldPair(); |
|
1659 CleanupStack::PushL(emailCcRecipients); |
|
1660 emailCcRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1661 emailEncodedHeaderFields->iFieldPairList.AppendL(emailCcRecipients); |
|
1662 CleanupStack::Pop(emailCcRecipients); |
|
1663 |
|
1664 CFieldPair* emailBCcRecipients = new (ELeave)CFieldPair(); |
|
1665 CleanupStack::PushL(emailBCcRecipients); |
|
1666 emailBCcRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1667 emailEncodedHeaderFields->iFieldPairList.AppendL(emailBCcRecipients); |
|
1668 CleanupStack::Pop(emailBCcRecipients); |
|
1669 |
|
1670 //Read Email encoding info |
|
1671 CFieldPair* emailEncodingInfo = new (ELeave)CFieldPair(); |
|
1672 CleanupStack::PushL(emailEncodingInfo); |
|
1673 emailEncodingInfo->iFieldTextValue = KSpace().AllocL(); |
|
1674 emailEncodedHeaderFields->iFieldPairList.AppendL(emailEncodingInfo); |
|
1675 CleanupStack::Pop(emailEncodingInfo); |
|
1676 |
|
1677 CFieldPair* emailResentMsgId = new (ELeave)CFieldPair(); |
|
1678 CleanupStack::PushL(emailResentMsgId); |
|
1679 emailResentMsgId->iFieldTextValue = KSpace().AllocL();; |
|
1680 emailEncodedHeaderFields->iFieldPairList.AppendL(emailResentMsgId); |
|
1681 CleanupStack::Pop(emailResentMsgId); |
|
1682 |
|
1683 CFieldPair* emailResentFrom = new (ELeave)CFieldPair(); |
|
1684 CleanupStack::PushL(emailResentFrom); |
|
1685 emailResentFrom->iFieldTextValue = KSpace().AllocL(); |
|
1686 emailEncodedHeaderFields->iFieldPairList.AppendL(emailResentFrom); |
|
1687 CleanupStack::Pop(emailResentFrom); |
|
1688 |
|
1689 CFieldPair* emailResentToRecipients= new (ELeave)CFieldPair(); |
|
1690 CleanupStack::PushL(emailResentToRecipients); |
|
1691 emailResentToRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1692 emailEncodedHeaderFields->iFieldPairList.AppendL(emailResentToRecipients); |
|
1693 CleanupStack::Pop(emailResentToRecipients); |
|
1694 |
|
1695 CFieldPair* emailResentCcRecipients= new (ELeave)CFieldPair(); |
|
1696 CleanupStack::PushL(emailResentCcRecipients); |
|
1697 emailResentCcRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1698 emailEncodedHeaderFields->iFieldPairList.AppendL(emailResentCcRecipients); |
|
1699 CleanupStack::Pop(emailResentCcRecipients); |
|
1700 |
|
1701 CFieldPair* emailResentBccRecipients= new (ELeave)CFieldPair(); |
|
1702 CleanupStack::PushL(emailResentBccRecipients); |
|
1703 emailResentBccRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1704 emailEncodedHeaderFields->iFieldPairList.AppendL(emailResentBccRecipients); |
|
1705 CleanupStack::Pop(emailResentBccRecipients); |
|
1706 |
|
1707 CFieldPair* emailInReplyTo = new (ELeave)CFieldPair(); |
|
1708 CleanupStack::PushL(emailInReplyTo); |
|
1709 emailInReplyTo->iFieldTextValue = KSpace().AllocL(); |
|
1710 emailEncodedHeaderFields->iFieldPairList.AppendL(emailInReplyTo); |
|
1711 CleanupStack::Pop(emailInReplyTo); |
|
1712 |
|
1713 CFieldPair* emailBodyEncoding = new (ELeave)CFieldPair(); |
|
1714 CleanupStack::PushL(emailBodyEncoding); |
|
1715 emailEncodedHeaderFields->iFieldPairList.AppendL(emailBodyEncoding); |
|
1716 CleanupStack::Pop(emailBodyEncoding); |
|
1717 |
|
1718 CFieldPair* emailCharset = new (ELeave)CFieldPair(); |
|
1719 CleanupStack::PushL(emailCharset); |
|
1720 emailEncodedHeaderFields->iFieldPairList.AppendL(emailCharset); |
|
1721 CleanupStack::Pop(emailCharset); |
|
1722 |
|
1723 CFieldPair* emaildetailField = new (ELeave)CFieldPair(); |
|
1724 CleanupStack::PushL(emaildetailField); |
|
1725 emaildetailField->iFieldType = ETextField; |
|
1726 emaildetailField->iFieldTextValue = strbuf.AllocL(); |
|
1727 emailEncodedHeaderFields->iFieldPairList.AppendL(emaildetailField); |
|
1728 CleanupStack::Pop(emaildetailField); |
|
1729 |
|
1730 iEmailfieldPairList.AppendL(emailEncodedHeaderFields); |
|
1731 |
|
1732 CleanupStack::PopAndDestroy(); //strbuf |
|
1733 |
|
1734 infoencodedHeader.Close(); |
|
1735 } |
|
1736 TInt count=iStreams->Count(); |
|
1737 while(count--) |
|
1738 { |
|
1739 delete iStreams->At(count).iBuf; |
|
1740 } |
|
1741 |
|
1742 delete iStreams; |
|
1743 iStreams=NULL; |
|
1744 CleanupStack::PopAndDestroy(3); //fs, in, file |
|
1745 fs.Close(); |
|
1746 in.Close(); |
|
1747 return KErrNone; |
|
1748 } |
|
1749 |
|
1750 |
|
1751 /** |
|
1752 ReadEmailMimeHeaderL() |
|
1753 Reads an email message mime header from the specified path and fills RPointerArray of CHeaderFields |
|
1754 from these read header objects. |
|
1755 |
|
1756 @param aMessagePath: message path. |
|
1757 @retun TInt: Error code specifying if the message was read successfully. |
|
1758 @internalComponent |
|
1759 */ |
|
1760 TInt CMsvVersion1Version2Converter::ReadEmailMimeHeaderL(TDesC& aMessagePath) |
|
1761 { |
|
1762 RFs fs; |
|
1763 User::LeaveIfError(fs.Connect()); |
|
1764 CleanupClosePushL(fs); |
|
1765 |
|
1766 RFile file; |
|
1767 TInt error = file.Open(fs,aMessagePath,EFileRead|EFileShareAny); |
|
1768 if(error != KErrNone) |
|
1769 { |
|
1770 CleanupStack::PopAndDestroy(&fs); //fs |
|
1771 file.Close(); |
|
1772 fs.Close(); |
|
1773 return error; |
|
1774 } |
|
1775 CleanupClosePushL(file); |
|
1776 |
|
1777 CArrayFix<TPairedTUidHBufC8> *iStreams = new(ELeave) CArrayFixFlat<TPairedTUidHBufC8>(5);; |
|
1778 |
|
1779 RFileReadStream in(file); |
|
1780 in.PushL(); |
|
1781 |
|
1782 TCheckedUid check; |
|
1783 in >> check; |
|
1784 if(check.UidType().IsValid()==EFalse) |
|
1785 return EFalse; |
|
1786 |
|
1787 in >> *iStreams;; |
|
1788 |
|
1789 TPairedTUidHBufC8 entry; |
|
1790 entry.iUid=KUidMsgFileMimeHeader; |
|
1791 TKeyArrayFix key(_FOFF(TPairedTUidHBufC8,iUid),ECmpTInt32); |
|
1792 |
|
1793 TInt pos; |
|
1794 TBool found = (iStreams->FindIsq(entry,key,pos)); |
|
1795 |
|
1796 if(found == KErrNone) |
|
1797 { |
|
1798 HBufC8 *buffer=iStreams->At(pos).iBuf; |
|
1799 HMsvReadBuffer *buf = new (ELeave) HMsvReadBuffer(*buffer); |
|
1800 |
|
1801 RReadStream infoMimeHeader(buf); |
|
1802 |
|
1803 RBuf8 mimeStr; |
|
1804 mimeStr.Create(KMaxBufferLength); |
|
1805 CleanupClosePushL(mimeStr); |
|
1806 |
|
1807 TInt version = infoMimeHeader.ReadUint16L(); |
|
1808 mimeStr.AppendNum(version); |
|
1809 mimeStr.Append(KSeparator); |
|
1810 |
|
1811 HBufC8* relativePath = HBufC8::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1812 mimeStr.Append(relativePath->Des()); |
|
1813 mimeStr.Append(KSeparator); |
|
1814 delete relativePath; |
|
1815 |
|
1816 HBufC8* contentType = HBufC8::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1817 mimeStr.Append(contentType->Des()); |
|
1818 mimeStr.Append(KSeparator); |
|
1819 delete contentType; |
|
1820 |
|
1821 HBufC8* contentSubType = HBufC8::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1822 mimeStr.Append(contentSubType->Des()); |
|
1823 mimeStr.Append(KSeparator); |
|
1824 delete contentSubType; |
|
1825 |
|
1826 |
|
1827 TInt contentTransferEncoding = infoMimeHeader.ReadInt8L(); |
|
1828 mimeStr.AppendNum(contentTransferEncoding); |
|
1829 mimeStr.Append(KSeparator); |
|
1830 |
|
1831 HBufC8* contentDisposition = HBufC8::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1832 mimeStr.Append(contentDisposition->Des()); |
|
1833 mimeStr.Append(KSeparator); |
|
1834 delete contentDisposition; |
|
1835 |
|
1836 HBufC8* contentDescription = HBufC8::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1837 mimeStr.Append(contentDescription->Des()); |
|
1838 mimeStr.Append(KSeparator); |
|
1839 delete contentDescription; |
|
1840 |
|
1841 HBufC8* contentBase = HBufC8::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1842 mimeStr.Append(contentBase->Des()); |
|
1843 mimeStr.Append(KSeparator); |
|
1844 delete contentBase; |
|
1845 |
|
1846 HBufC16* contentLocation = HBufC16::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1847 mimeStr.Append(contentLocation->Des()); |
|
1848 mimeStr.Append(KSeparator); |
|
1849 delete contentLocation; |
|
1850 |
|
1851 HBufC8* contentID = HBufC8::NewL( infoMimeHeader, KMaxImMimeFieldLength ); |
|
1852 mimeStr.Append(contentID->Des()); |
|
1853 mimeStr.Append(KSeparator); |
|
1854 delete contentID; |
|
1855 |
|
1856 CDesC8Array* contentTypeParams = new (ELeave)CDesC8ArrayFlat( KDesCArrayGranularity ); |
|
1857 CDesC8Array* contentDispositionParams = new (ELeave)CDesC8ArrayFlat( KDesCArrayGranularity ); |
|
1858 CDesC8Array* xTypeParams = new(ELeave) CDesC8ArrayFlat(KDesCArrayGranularity); |
|
1859 |
|
1860 infoMimeHeader >> *contentTypeParams; |
|
1861 for(TInt i = 0; i<contentTypeParams->Count(); i++) |
|
1862 { |
|
1863 mimeStr.Append(contentTypeParams->MdcaPoint(i)); |
|
1864 if((i + 1) != contentTypeParams->MdcaCount()) |
|
1865 { |
|
1866 mimeStr.Append(KComma); |
|
1867 } |
|
1868 } |
|
1869 delete contentTypeParams; |
|
1870 contentTypeParams = NULL; |
|
1871 |
|
1872 mimeStr.Append(KSeparator); |
|
1873 |
|
1874 infoMimeHeader >> *contentDispositionParams; |
|
1875 for(TInt i = 0; i<contentDispositionParams->Count(); i++) |
|
1876 { |
|
1877 mimeStr.Append(contentDispositionParams->MdcaPoint(i)); |
|
1878 if((i + 1) != contentDispositionParams->MdcaCount()) |
|
1879 { |
|
1880 mimeStr.Append(KComma); |
|
1881 } |
|
1882 } |
|
1883 |
|
1884 delete contentDispositionParams; |
|
1885 contentDispositionParams = NULL; |
|
1886 |
|
1887 mimeStr.Append(KSeparator); |
|
1888 |
|
1889 infoMimeHeader >> *xTypeParams; |
|
1890 for(TInt i = 0; i<xTypeParams->Count(); i++) |
|
1891 { |
|
1892 mimeStr.Append(xTypeParams->MdcaPoint(i)); |
|
1893 |
|
1894 if((i + 1) != xTypeParams->MdcaCount()) |
|
1895 { |
|
1896 mimeStr.Append(KComma); |
|
1897 } |
|
1898 } |
|
1899 delete xTypeParams; |
|
1900 xTypeParams = NULL; |
|
1901 |
|
1902 mimeStr.Append(KSeparator); |
|
1903 |
|
1904 TInt mimeCharset = infoMimeHeader.ReadUint32L(); |
|
1905 mimeStr.AppendNum(mimeCharset); |
|
1906 mimeStr.Append(KSeparator); |
|
1907 |
|
1908 /*Lets start reading the Header Info */ |
|
1909 CHeaderFields* emailMimeHeaderFields = new (ELeave) CHeaderFields(); |
|
1910 emailMimeHeaderFields->iUid = KUidMsgFileMimeHeader; |
|
1911 |
|
1912 CFieldPair* emailHeaderVersionfield = new (ELeave)CFieldPair(); |
|
1913 CleanupStack::PushL(emailHeaderVersionfield); |
|
1914 emailMimeHeaderFields->iFieldPairList.AppendL(emailHeaderVersionfield); |
|
1915 CleanupStack::Pop(emailHeaderVersionfield); |
|
1916 |
|
1917 CFieldPair* emailReceiptAddress = new (ELeave)CFieldPair(); |
|
1918 CleanupStack::PushL(emailReceiptAddress); |
|
1919 emailReceiptAddress->iFieldTextValue = KSpace().AllocL(); |
|
1920 emailMimeHeaderFields->iFieldPairList.AppendL(emailReceiptAddress); |
|
1921 CleanupStack::Pop(emailReceiptAddress); |
|
1922 |
|
1923 CFieldPair* emailImMsgId = new (ELeave)CFieldPair(); |
|
1924 CleanupStack::PushL(emailImMsgId); |
|
1925 emailImMsgId->iFieldTextValue = KSpace().AllocL(); |
|
1926 emailMimeHeaderFields->iFieldPairList.AppendL(emailImMsgId); |
|
1927 CleanupStack::Pop(emailImMsgId); |
|
1928 |
|
1929 CFieldPair* emailFrom = new (ELeave)CFieldPair(); |
|
1930 CleanupStack::PushL(emailFrom); |
|
1931 emailFrom->iFieldTextValue = KSpace().AllocL(); |
|
1932 emailMimeHeaderFields->iFieldPairList.AppendL(emailFrom); |
|
1933 CleanupStack::Pop(emailFrom); |
|
1934 |
|
1935 CFieldPair* emailReplyTo = new (ELeave)CFieldPair(); |
|
1936 CleanupStack::PushL(emailReplyTo); |
|
1937 emailReplyTo->iFieldTextValue = KSpace().AllocL();; |
|
1938 emailMimeHeaderFields->iFieldPairList.AppendL(emailReplyTo); |
|
1939 CleanupStack::Pop(emailReplyTo); |
|
1940 |
|
1941 CFieldPair* emailSubject = new (ELeave)CFieldPair(); |
|
1942 CleanupStack::PushL(emailSubject); |
|
1943 emailSubject->iFieldTextValue = KSpace().AllocL();; |
|
1944 emailMimeHeaderFields->iFieldPairList.AppendL(emailSubject); |
|
1945 CleanupStack::Pop(emailSubject); |
|
1946 |
|
1947 CFieldPair* emailRemoteSize = new (ELeave)CFieldPair(); |
|
1948 CleanupStack::PushL(emailRemoteSize); |
|
1949 emailMimeHeaderFields->iFieldPairList.AppendL(emailRemoteSize); |
|
1950 CleanupStack::Pop(emailRemoteSize); |
|
1951 |
|
1952 CFieldPair* emailToRecipients = new (ELeave)CFieldPair(); |
|
1953 CleanupStack::PushL(emailToRecipients); |
|
1954 emailToRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1955 emailMimeHeaderFields->iFieldPairList.AppendL(emailToRecipients); |
|
1956 CleanupStack::Pop(emailToRecipients); |
|
1957 |
|
1958 CFieldPair* emailCcRecipients = new (ELeave)CFieldPair(); |
|
1959 CleanupStack::PushL(emailCcRecipients); |
|
1960 emailCcRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1961 emailMimeHeaderFields->iFieldPairList.AppendL(emailCcRecipients); |
|
1962 CleanupStack::Pop(emailCcRecipients); |
|
1963 |
|
1964 CFieldPair* emailBCcRecipients = new (ELeave)CFieldPair(); |
|
1965 CleanupStack::PushL(emailBCcRecipients); |
|
1966 emailBCcRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1967 emailMimeHeaderFields->iFieldPairList.AppendL(emailBCcRecipients); |
|
1968 CleanupStack::Pop(emailBCcRecipients); |
|
1969 |
|
1970 //Read Email encoding info |
|
1971 CFieldPair* emailEncodingInfo = new (ELeave)CFieldPair(); |
|
1972 CleanupStack::PushL(emailEncodingInfo); |
|
1973 emailEncodingInfo->iFieldTextValue = KSpace().AllocL(); |
|
1974 emailMimeHeaderFields->iFieldPairList.AppendL(emailEncodingInfo); |
|
1975 CleanupStack::Pop(emailEncodingInfo); |
|
1976 |
|
1977 CFieldPair* emailResentMsgId = new (ELeave)CFieldPair(); |
|
1978 CleanupStack::PushL(emailResentMsgId); |
|
1979 emailResentMsgId->iFieldTextValue = KSpace().AllocL(); |
|
1980 emailMimeHeaderFields->iFieldPairList.AppendL(emailResentMsgId); |
|
1981 CleanupStack::Pop(emailResentMsgId); |
|
1982 |
|
1983 CFieldPair* emailResentFrom = new (ELeave)CFieldPair(); |
|
1984 CleanupStack::PushL(emailResentFrom); |
|
1985 emailResentFrom->iFieldTextValue = KSpace().AllocL(); |
|
1986 emailMimeHeaderFields->iFieldPairList.AppendL(emailResentFrom); |
|
1987 CleanupStack::Pop(emailResentFrom); |
|
1988 |
|
1989 CFieldPair* emailResentToRecipients= new (ELeave)CFieldPair(); |
|
1990 CleanupStack::PushL(emailResentToRecipients); |
|
1991 emailResentToRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1992 emailMimeHeaderFields->iFieldPairList.AppendL(emailResentToRecipients); |
|
1993 CleanupStack::Pop(emailResentToRecipients); |
|
1994 |
|
1995 CFieldPair* emailResentCcRecipients= new (ELeave)CFieldPair(); |
|
1996 CleanupStack::PushL(emailResentCcRecipients); |
|
1997 emailResentCcRecipients->iFieldTextValue = KSpace().AllocL(); |
|
1998 emailMimeHeaderFields->iFieldPairList.AppendL(emailResentCcRecipients); |
|
1999 CleanupStack::Pop(emailResentCcRecipients); |
|
2000 |
|
2001 CFieldPair* emailResentBccRecipients= new (ELeave)CFieldPair(); |
|
2002 CleanupStack::PushL(emailResentBccRecipients); |
|
2003 emailResentBccRecipients->iFieldTextValue = KSpace().AllocL(); |
|
2004 emailMimeHeaderFields->iFieldPairList.AppendL(emailResentBccRecipients); |
|
2005 CleanupStack::Pop(emailResentBccRecipients); |
|
2006 |
|
2007 CFieldPair* emailInReplyTo = new (ELeave)CFieldPair(); |
|
2008 CleanupStack::PushL(emailInReplyTo); |
|
2009 emailInReplyTo->iFieldTextValue = KSpace().AllocL(); |
|
2010 emailMimeHeaderFields->iFieldPairList.AppendL(emailInReplyTo); |
|
2011 CleanupStack::Pop(emailInReplyTo); |
|
2012 |
|
2013 CFieldPair* emailBodyEncoding = new (ELeave)CFieldPair(); |
|
2014 CleanupStack::PushL(emailBodyEncoding); |
|
2015 emailMimeHeaderFields->iFieldPairList.AppendL(emailBodyEncoding); |
|
2016 CleanupStack::Pop(emailBodyEncoding); |
|
2017 |
|
2018 CFieldPair* emailCharset = new (ELeave)CFieldPair(); |
|
2019 CleanupStack::PushL(emailCharset); |
|
2020 emailMimeHeaderFields->iFieldPairList.AppendL(emailCharset); |
|
2021 CleanupStack::Pop(emailCharset); |
|
2022 // 8bit to 16bit |
|
2023 HBufC* newMimeStr = HBufC::NewL(mimeStr.Length()); |
|
2024 newMimeStr->Des().Copy(mimeStr); |
|
2025 |
|
2026 CFieldPair* emaildetailField = new (ELeave)CFieldPair(); |
|
2027 CleanupStack::PushL(emaildetailField); |
|
2028 emaildetailField->iFieldName = KDetails().AllocL();; |
|
2029 emaildetailField->iFieldType = ETextField; |
|
2030 emaildetailField->iFieldTextValue= newMimeStr; |
|
2031 emailMimeHeaderFields->iFieldPairList.AppendL(emaildetailField); |
|
2032 CleanupStack::Pop(emaildetailField); |
|
2033 |
|
2034 iEmailfieldPairList.AppendL(emailMimeHeaderFields); |
|
2035 |
|
2036 CleanupStack::PopAndDestroy(); //mimestr |
|
2037 |
|
2038 infoMimeHeader.Close(); |
|
2039 } |
|
2040 TInt count=iStreams->Count(); |
|
2041 while(count--) |
|
2042 { |
|
2043 delete iStreams->At(count).iBuf; |
|
2044 } |
|
2045 delete iStreams; |
|
2046 iStreams=NULL; |
|
2047 CleanupStack::PopAndDestroy(3); //fs,file,in |
|
2048 |
|
2049 fs.Close(); |
|
2050 in.Close(); |
|
2051 |
|
2052 return KErrNone; |
|
2053 } |
|
2054 |
|
2055 /* start SMS conversion APIs */ |
|
2056 |
|
2057 /** |
|
2058 Read and Insert header and body part of the SMS message. |
|
2059 @param aServiceIdPosition Service Id belong to Sms MTM. |
|
2060 @return void. |
|
2061 @internalComponent |
|
2062 */ |
|
2063 |
|
2064 void CMsvVersion1Version2Converter::InternalizeSmsMessageL(TMsvId aServiceId,TUint32 aMtm) |
|
2065 { |
|
2066 RArray<TMsvId> iDArray; |
|
2067 CleanupClosePushL (iDArray); |
|
2068 TMsvId iD; |
|
2069 |
|
2070 iDBAdapter.BeginTransactionL(); |
|
2071 /* Get all TMsvIds belong to one service Id */ |
|
2072 iDBAdapter.GetAllMessageIdsL(aServiceId,iDArray,aMtm, iResumeStatus.lastId); |
|
2073 iResumeStatus.remainingCount = iDArray.Count(); |
|
2074 |
|
2075 for(TInt i=0;i<iDArray.Count();i++) |
|
2076 { |
|
2077 iResumeStatus.lastId = iDArray[i]; |
|
2078 iResumeStatus.remainingCount--; |
|
2079 |
|
2080 RBuf path; |
|
2081 CleanupClosePushL(path); |
|
2082 path.CreateL(KMaxPath); |
|
2083 iDBAdapter.GetOwningServiceL(iDArray[i],iD); |
|
2084 CreatePathL(path,iDArray[i],iD); |
|
2085 |
|
2086 InitializeL(); |
|
2087 /* Read Sms Header part of the message */ |
|
2088 TBool foundSmsHeader = ReadSmsMessageHeaderL(path); |
|
2089 |
|
2090 iEmailfieldPairList.AppendL(iSmsHeaderFields); |
|
2091 iEmailfieldPairList.AppendL(iEmailOverSmsAddressFields); |
|
2092 |
|
2093 // Insert Sms header into DB |
|
2094 if(foundSmsHeader) |
|
2095 { |
|
2096 iMessageDBAdapter.CreateHeaderEntryL(TUid::Uid(aMtm), iDArray[i], iEmailfieldPairList); |
|
2097 } |
|
2098 |
|
2099 //update the conversion status |
|
2100 if(i % KDBCommitCount == 0 && i != 0) |
|
2101 { |
|
2102 iResumeStatus.lastId = iDArray[i]; |
|
2103 iResumeStatus.serviceId = aServiceId; |
|
2104 iResumeStatus.remainingCount -= KDBCommitCount; |
|
2105 |
|
2106 iDBAdapter.UpdateConversionStatusEntryL(iResumeStatus); |
|
2107 iDBAdapter.CommitTransactionL(); |
|
2108 iDBAdapter.BeginTransactionL(); |
|
2109 } |
|
2110 DeAllocateMemory(); // destroy the allocated resources |
|
2111 path.Close(); |
|
2112 CleanupStack::PopAndDestroy(); //path |
|
2113 } |
|
2114 CleanupStack::PopAndDestroy(&iDArray); |
|
2115 |
|
2116 // check if we have a request for Cancellation. |
|
2117 // if one is found than we immediately cancel without comminting to the database. |
|
2118 TInt cancel = GetPropertyValue(); |
|
2119 if(cancel == KErrCancel ) |
|
2120 { |
|
2121 User::Leave(KErrCancel); |
|
2122 } |
|
2123 |
|
2124 |
|
2125 //update status for this service id |
|
2126 iResumeStatus.lastId = 0; |
|
2127 iResumeStatus.serviceId = aServiceId; |
|
2128 iResumeStatus.remainingCount = 0; |
|
2129 iDBAdapter.UpdateConversionStatusEntryL(iResumeStatus); |
|
2130 iDBAdapter.CommitTransactionL(); |
|
2131 |
|
2132 } |
|
2133 |
|
2134 /** |
|
2135 Create SMS header table in DB. |
|
2136 @param None. |
|
2137 @return void. |
|
2138 @internalComponent |
|
2139 */ |
|
2140 void CMsvVersion1Version2Converter::CreateSmsHeaderTableL() |
|
2141 { |
|
2142 AddFieldL(KSmsHeadearversion().AllocL(),EIntegerField); |
|
2143 AddFieldL(KSmsRecipientCount().AllocL(),EIntegerField); |
|
2144 AddFieldL(KRecipients().AllocL(),ETextField); |
|
2145 AddFieldL(KSmsFlags().AllocL(),EIntegerField); |
|
2146 AddFieldL(KTextBioMsgIdType().AllocL(),EIntegerField); |
|
2147 } |
|
2148 |
|
2149 /** |
|
2150 Internalizing CMsvRecipient fields and Sms Number fields from file store. |
|
2151 @param aStream A ref for reading the content from file store. |
|
2152 @param aDetailsOfRecipients Recipient detailfields buffer. |
|
2153 @return void. |
|
2154 @internalComponent |
|
2155 */ |
|
2156 void CMsvVersion1Version2Converter::InternalizeSmsHeaderL(RReadStream& aStream,TDes16& aDetailsOfRecipients) |
|
2157 { |
|
2158 TInt16 version = aStream.ReadInt16L(); |
|
2159 |
|
2160 // Its internalize as per CMsvRecipient::InternalizeL(aStream) |
|
2161 TRecipientStatus aStatus = (TRecipientStatus)aStream.ReadInt32L(); |
|
2162 aDetailsOfRecipients.AppendNum(aStatus); |
|
2163 aDetailsOfRecipients.Append(KComma); |
|
2164 |
|
2165 CFieldPair* smsRecipientStatus = new (ELeave)CFieldPair(); |
|
2166 CleanupStack::PushL(smsRecipientStatus); |
|
2167 smsRecipientStatus->iFieldNumValue = (TInt64)aStatus; |
|
2168 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsRecipientStatus); |
|
2169 CleanupStack::Pop(smsRecipientStatus); |
|
2170 |
|
2171 TInt32 aError = aStream.ReadInt32L(); |
|
2172 aDetailsOfRecipients.AppendNum(aError); |
|
2173 aDetailsOfRecipients.Append(KComma); |
|
2174 CFieldPair* smsError = new (ELeave)CFieldPair(); |
|
2175 CleanupStack::PushL(smsError); |
|
2176 smsError->iFieldNumValue = (TInt64)aError; |
|
2177 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsError); |
|
2178 CleanupStack::Pop(smsError); |
|
2179 |
|
2180 TInt aRetries = aStream.ReadInt32L(); |
|
2181 aDetailsOfRecipients.AppendNum(aRetries); |
|
2182 aDetailsOfRecipients.Append(KComma); |
|
2183 |
|
2184 CFieldPair* smsRetries = new (ELeave)CFieldPair(); |
|
2185 CleanupStack::PushL(smsRetries); |
|
2186 smsRetries->iFieldNumValue = (TInt64)aRetries; |
|
2187 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsRetries); |
|
2188 CleanupStack::Pop(smsRetries); |
|
2189 |
|
2190 TInt64 time; |
|
2191 aStream >> time; |
|
2192 aDetailsOfRecipients.AppendNum(time); |
|
2193 aDetailsOfRecipients.Append(KComma); |
|
2194 |
|
2195 CFieldPair* smsTime = new (ELeave)CFieldPair(); |
|
2196 CleanupStack::PushL(smsTime); |
|
2197 smsTime->iFieldNumValue = time; |
|
2198 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsTime); |
|
2199 CleanupStack::Pop(smsTime); |
|
2200 // end of CMsvRecipient::Internalize(aStream) |
|
2201 |
|
2202 HBufC16* number = HBufC16::NewL(aStream, KSmcmSmsNumberMaxNumberLength); |
|
2203 CleanupStack::PushL(number); |
|
2204 aDetailsOfRecipients.Append(*number); |
|
2205 aDetailsOfRecipients.Append(KComma); |
|
2206 |
|
2207 CFieldPair* smsNumber = new (ELeave)CFieldPair(); |
|
2208 CleanupStack::PushL(smsNumber); |
|
2209 smsNumber->iFieldTextValue = number; |
|
2210 CleanupStack::Pop(smsNumber); |
|
2211 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsNumber); |
|
2212 |
|
2213 CleanupStack::Pop(number); |
|
2214 |
|
2215 HBufC* name = HBufC::NewL(aStream, KSmcmSmsNumberMaxNameLength); |
|
2216 CleanupStack::PushL(name); |
|
2217 aDetailsOfRecipients.Append(*name); |
|
2218 aDetailsOfRecipients.Append(KComma); |
|
2219 |
|
2220 CFieldPair* smsName = new (ELeave)CFieldPair(); |
|
2221 CleanupStack::PushL(smsName); |
|
2222 smsName->iFieldName = name; |
|
2223 CleanupStack::Pop(smsName); |
|
2224 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsName); |
|
2225 |
|
2226 CleanupStack::Pop(name); |
|
2227 |
|
2228 TLogId logId; |
|
2229 logId = aStream.ReadInt32L(); |
|
2230 aDetailsOfRecipients.AppendNum(logId); |
|
2231 aDetailsOfRecipients.Append(KComma); |
|
2232 |
|
2233 CFieldPair* smsLogId = new (ELeave)CFieldPair(); |
|
2234 CleanupStack::PushL(smsLogId); |
|
2235 smsLogId->iFieldNumValue = (TInt64)logId; |
|
2236 CleanupStack::Pop(smsLogId); |
|
2237 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsLogId); |
|
2238 |
|
2239 CFieldPair* smsDeliverySatus = new (ELeave)CFieldPair(); |
|
2240 |
|
2241 TSmsAckStatus deliveryStatus; |
|
2242 if( version >= 2 ) |
|
2243 { |
|
2244 deliveryStatus = (TSmsAckStatus) aStream.ReadInt8L(); |
|
2245 aDetailsOfRecipients.AppendNum(deliveryStatus); |
|
2246 aDetailsOfRecipients.Append(KDelimiter); |
|
2247 |
|
2248 smsDeliverySatus->iFieldNumValue = (TInt64)deliveryStatus; |
|
2249 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsDeliverySatus); |
|
2250 } |
|
2251 else |
|
2252 { |
|
2253 deliveryStatus = ENoAckRequested; |
|
2254 aDetailsOfRecipients.AppendNum(deliveryStatus); |
|
2255 aDetailsOfRecipients.Append(KDelimiter); |
|
2256 |
|
2257 smsDeliverySatus->iFieldNumValue = (TInt64)deliveryStatus; |
|
2258 iSmsRecipientAddressFields->iFieldPairList.AppendL(smsDeliverySatus); |
|
2259 } |
|
2260 } |
|
2261 |
|
2262 /** |
|
2263 Internalizing the Sms header part of the message from file store. |
|
2264 @param aPath: Path which identify the location of the file. |
|
2265 @return TInt Return error if path or sms header is not found. |
|
2266 @internalComponent |
|
2267 */ |
|
2268 |
|
2269 TBool CMsvVersion1Version2Converter::ReadSmsMessageHeaderL(TDes& aPath) |
|
2270 { |
|
2271 RFs fs; |
|
2272 User::LeaveIfError(fs.Connect()); |
|
2273 CleanupClosePushL(fs); |
|
2274 |
|
2275 RFile file; |
|
2276 TInt error = file.Open(fs,aPath,EFileRead|EFileShareAny); |
|
2277 CleanupClosePushL(file); |
|
2278 |
|
2279 if(error !=KErrNone) |
|
2280 { |
|
2281 CleanupStack::PopAndDestroy(); //fs |
|
2282 CleanupStack::PopAndDestroy(); // file |
|
2283 return EFalse; |
|
2284 } |
|
2285 |
|
2286 RFileReadStream in(file); |
|
2287 in.PushL(); |
|
2288 TCheckedUid check; |
|
2289 in >> check; |
|
2290 |
|
2291 if(check.UidType().IsValid()==EFalse) |
|
2292 { |
|
2293 return EFalse; |
|
2294 } |
|
2295 if(check.UidType()[0]!=KMsvEntryFileForSms) |
|
2296 { |
|
2297 return EFalse; |
|
2298 } |
|
2299 |
|
2300 iStreams = new(ELeave) CArrayFixFlat<TPairedTUidHBufC8>(5); |
|
2301 in >> *iStreams; |
|
2302 |
|
2303 TInt position = 0; |
|
2304 error = FindStream(KUidSMSHeaderStream,position); |
|
2305 if(error == KErrNone) |
|
2306 { |
|
2307 |
|
2308 HBufC8 *buffer = iStreams->At(position).iBuf; |
|
2309 HMsvReadBuffer *buf = new (ELeave) HMsvReadBuffer(*buffer); |
|
2310 CleanupStack::PushL(buf); |
|
2311 RReadStream smsHeader(buf); |
|
2312 CleanupStack::Pop(buf); |
|
2313 |
|
2314 iSmsHeaderFields->iUid = KUidSMSHeaderStream; |
|
2315 |
|
2316 //Version |
|
2317 CFieldPair* smsHeaderVersionField = new (ELeave)CFieldPair(); |
|
2318 CleanupStack::PushL(smsHeaderVersionField); |
|
2319 smsHeaderVersionField->iFieldNumValue = (TInt64)smsHeader.ReadInt16L(); |
|
2320 iSmsHeaderFields->iFieldPairList.AppendL(smsHeaderVersionField); |
|
2321 CleanupStack::Pop(smsHeaderVersionField); |
|
2322 |
|
2323 //internalizing recipient count from sms header |
|
2324 TInt32 recipientCount = smsHeader.ReadInt32L(); |
|
2325 CFieldPair* smsRecipientCountField = new (ELeave)CFieldPair(); |
|
2326 CleanupStack::PushL(smsRecipientCountField); |
|
2327 smsRecipientCountField->iFieldNumValue = (TInt64)recipientCount; |
|
2328 iSmsHeaderFields->iFieldPairList.AppendL(smsRecipientCountField); |
|
2329 CleanupStack::Pop(smsRecipientCountField); |
|
2330 |
|
2331 iRecipientDetails.Create(KMaxLengthOfRecipientField*recipientCount); |
|
2332 |
|
2333 while(recipientCount--) |
|
2334 { |
|
2335 InternalizeSmsHeaderL(smsHeader,iRecipientDetails); |
|
2336 } |
|
2337 |
|
2338 CFieldPair* detailsOfRecipientField = new (ELeave)CFieldPair(); |
|
2339 CleanupStack::PushL(detailsOfRecipientField); |
|
2340 detailsOfRecipientField->iFieldTextValue = iRecipientDetails.AllocL(); |
|
2341 iSmsHeaderFields->iFieldPairList.AppendL(detailsOfRecipientField); |
|
2342 CleanupStack::Pop(detailsOfRecipientField); |
|
2343 |
|
2344 // reading sms flag |
|
2345 TUint32 iFlags = smsHeader.ReadUint32L(); |
|
2346 CFieldPair* smsHeaderFlagField = new (ELeave)CFieldPair(); |
|
2347 CleanupStack::PushL(smsHeaderFlagField); |
|
2348 smsHeaderFlagField->iFieldNumValue = (TInt64)iFlags; |
|
2349 iSmsHeaderFields->iFieldPairList.AppendL(smsHeaderFlagField); |
|
2350 CleanupStack::Pop(smsHeaderFlagField); |
|
2351 |
|
2352 // reading sms biomsgtype |
|
2353 TInt64 iBioMsgIdType = smsHeader.ReadInt8L(); |
|
2354 CFieldPair* smsHeaderBioMsgFlagField = new (ELeave)CFieldPair(); |
|
2355 CleanupStack::PushL(smsHeaderBioMsgFlagField); |
|
2356 smsHeaderBioMsgFlagField->iFieldNumValue = iBioMsgIdType; |
|
2357 iSmsHeaderFields->iFieldPairList.AppendL(smsHeaderBioMsgFlagField); |
|
2358 CleanupStack::Pop(smsHeaderBioMsgFlagField); |
|
2359 |
|
2360 CFieldPair* smsDetailField = new (ELeave)CFieldPair(); |
|
2361 CleanupStack::PushL(smsDetailField); |
|
2362 smsDetailField->iFieldTextValue = KSpace().AllocL(); |
|
2363 iSmsHeaderFields->iFieldPairList.AppendL(smsDetailField); |
|
2364 CleanupStack::Pop(smsDetailField); |
|
2365 |
|
2366 /* Started reading EmailOverSms part of the Message */ |
|
2367 TInt eosPosition = 0; |
|
2368 error = FindStream(KUidMsvSmsEmailFieldsStream,eosPosition); |
|
2369 |
|
2370 if(error != KErrNone) |
|
2371 { |
|
2372 FillEmptyEosBufferL(); // It meant Sms message does not have EOS fields |
|
2373 } |
|
2374 else |
|
2375 { |
|
2376 HBufC8 *eosBuffer = iStreams->At(position).iBuf; |
|
2377 CleanupStack::PushL(eosBuffer); |
|
2378 HMsvReadBuffer *eosBuf = new (ELeave) HMsvReadBuffer(*eosBuffer); |
|
2379 CleanupStack::PushL(eosBuf); |
|
2380 RReadStream smsEmailHeaderField(eosBuf); |
|
2381 |
|
2382 InternalizeEmailOverSmsHeaderL(smsEmailHeaderField); |
|
2383 |
|
2384 CleanupStack::Pop(eosBuf); |
|
2385 CleanupStack::Pop(eosBuffer); |
|
2386 |
|
2387 smsHeader.Close(); |
|
2388 smsEmailHeaderField.Close(); |
|
2389 } |
|
2390 } |
|
2391 |
|
2392 TInt count=iStreams->Count(); |
|
2393 while(count--) |
|
2394 { |
|
2395 delete iStreams->At(count).iBuf; |
|
2396 } |
|
2397 delete iStreams; |
|
2398 iStreams=NULL; |
|
2399 in.Pop(); |
|
2400 in.Close(); |
|
2401 |
|
2402 CleanupStack::PopAndDestroy(); //file |
|
2403 file.Close(); |
|
2404 CleanupStack::PopAndDestroy(); // fs |
|
2405 return ETrue; |
|
2406 } |
|
2407 |
|
2408 /** |
|
2409 Internalizing the EOS fields from file store. |
|
2410 @param aSmsHeaderEmailOverSmsPart A ref for reading the content from file store. |
|
2411 @return void. |
|
2412 @internalComponent |
|
2413 */ |
|
2414 void CMsvVersion1Version2Converter::InternalizeEmailOverSmsHeaderL(RReadStream& aSmsHeaderEmailOverSmsPart) |
|
2415 { |
|
2416 iEmailOverSmsAddress.Create(KSmcmSmsNumberMaxNumberLength*KMaxConverterNumber); |
|
2417 iEmailOverSmsAddressFields->iUid = KUidMsvSmsEmailFieldsStream; |
|
2418 |
|
2419 // reading EmailOverSms version |
|
2420 iEmailOverSmsAddress.AppendNum(aSmsHeaderEmailOverSmsPart.ReadInt16L()); |
|
2421 iEmailOverSmsAddress.Append(KDelimiter); |
|
2422 |
|
2423 TCardinality cardinality; |
|
2424 aSmsHeaderEmailOverSmsPart >> cardinality; |
|
2425 TInt count = cardinality; |
|
2426 |
|
2427 iEmailOverSmsAddress.AppendNum(count); |
|
2428 iEmailOverSmsAddress.Append(KDelimiter); |
|
2429 |
|
2430 for( TInt i = 0; i < count; ++i ) |
|
2431 { |
|
2432 HBufC* buf = HBufC::NewLC(aSmsHeaderEmailOverSmsPart, KMaxTInt); |
|
2433 iEmailOverSmsAddress.Append(*buf); |
|
2434 if(i<count-1) |
|
2435 iEmailOverSmsAddress.Append(KComma); |
|
2436 CleanupStack::Pop(buf); |
|
2437 } |
|
2438 iEmailOverSmsAddress.Append(KDelimiter); |
|
2439 |
|
2440 // read the subject |
|
2441 HBufC* emailOverSmsSubject = HBufC::NewLC(aSmsHeaderEmailOverSmsPart, KMaxTInt); |
|
2442 iEmailOverSmsAddress.Append(*emailOverSmsSubject); |
|
2443 iEmailOverSmsAddress.Append(KDelimiter); |
|
2444 CleanupStack::Pop(emailOverSmsSubject); |
|
2445 |
|
2446 CFieldPair* eosAddressField = new (ELeave)CFieldPair(); |
|
2447 CleanupStack::PushL(eosAddressField); |
|
2448 eosAddressField->iFieldTextValue = iEmailOverSmsAddress.AllocL(); |
|
2449 iEmailOverSmsAddressFields->iFieldPairList.AppendL(eosAddressField); |
|
2450 CleanupStack::Pop(eosAddressField); |
|
2451 |
|
2452 } |
|
2453 |
|
2454 /** |
|
2455 Initialising the objects. |
|
2456 @param None. |
|
2457 @return void. |
|
2458 @internalComponent |
|
2459 */ |
|
2460 void CMsvVersion1Version2Converter::InitializeL() |
|
2461 { |
|
2462 iSmsHeaderFields = new (ELeave) CHeaderFields(); |
|
2463 iSmsRecipientAddressFields = new (ELeave) CHeaderFields(); |
|
2464 iEmailOverSmsAddressFields = new (ELeave) CHeaderFields(); |
|
2465 } |
|
2466 |
|
2467 /** |
|
2468 Destroying the memory allocated. |
|
2469 @param None. |
|
2470 @return void. |
|
2471 @internalComponent |
|
2472 */ |
|
2473 void CMsvVersion1Version2Converter::DeAllocateMemory() |
|
2474 { |
|
2475 iEmailfieldPairList.ResetAndDestroy(); |
|
2476 if(iSmsRecipientAddressFields != NULL) |
|
2477 { |
|
2478 delete iSmsRecipientAddressFields; |
|
2479 iSmsRecipientAddressFields = NULL; |
|
2480 } |
|
2481 |
|
2482 iRecipientDetails.Close(); |
|
2483 iEmailOverSmsAddress.Close(); |
|
2484 } |
|
2485 |
|
2486 |
|
2487 /** |
|
2488 Find the stream by passing the Uid of the stream |
|
2489 @param aUid. The const which identify to start position for reading. |
|
2490 @param aPos. Starting position of the stream. |
|
2491 @return TInt returning the error if stream not found. |
|
2492 @internalComponent |
|
2493 */ |
|
2494 TInt CMsvVersion1Version2Converter::FindStream(TUid aUid,TInt &aPos) |
|
2495 { |
|
2496 TPairedTUidHBufC8 entry; |
|
2497 entry.iUid=aUid; |
|
2498 TKeyArrayFix key(_FOFF(TPairedTUidHBufC8,iUid),ECmpTInt32); |
|
2499 return(iStreams->FindIsq(entry,key,aPos)); |
|
2500 } |
|
2501 |
|
2502 /** |
|
2503 Store the empty buffer part in emailoversms header fields |
|
2504 @param None |
|
2505 @return void. |
|
2506 @internalComponent |
|
2507 */ |
|
2508 void CMsvVersion1Version2Converter::FillEmptyEosBufferL() |
|
2509 { |
|
2510 iEmailOverSmsAddressFields->iUid = KUidMsvSmsEmailFieldsStream; |
|
2511 |
|
2512 CFieldPair* smsdetailField = new (ELeave)CFieldPair(); |
|
2513 CleanupStack::PushL(smsdetailField); |
|
2514 smsdetailField->iFieldTextValue = KSpace().AllocL(); |
|
2515 iEmailOverSmsAddressFields->iFieldPairList.AppendL(smsdetailField); |
|
2516 CleanupStack::Pop(smsdetailField); |
|
2517 } |
|
2518 |