1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "vMessageHandler.h" |
|
21 #include "obexutilsuilayer.h" |
|
22 #include "obexutilsdebug.h" |
|
23 #include "etelmm.h" |
|
24 #include <BTSapDomainPSKeys.h> |
|
25 #include <app/smut.h> // KUidMsgTypeSMS |
|
26 #ifdef NO101APPDEPFIXES_NEW |
|
27 #include <app/smuthdr.h> |
|
28 #endif //NO101APPDEPFIXES_NEW |
|
29 |
|
30 #include <gsmupdu.h> |
|
31 #include <txtrich.h> |
|
32 #include <msvuids.h> |
|
33 |
|
34 #include <app/csmsaccount.h> |
|
35 |
|
36 #ifdef NO101APPDEPFIXES_NEW |
|
37 // SMUT Unbranch |
|
38 #include <app/csmsgetdetdescinterface.h> |
|
39 #endif //NO101APPDEPFIXES_NEW |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 TBool CSapVMessageParser::HandleMessageL(CObexBufObject* aReceivedObject, const TUid aMtmID, |
|
43 RFile& aFile, CMsvSession* aMsvSession, TTime aTime) |
|
44 { |
|
45 FLOG( _L( " CSapVMessageParser: HandleMessageL\t" ) ); |
|
46 |
|
47 CSapVMessageParser* parser = CSapVMessageParser::NewLC(); |
|
48 TBool isVmsg=parser->ParseMessageL(aReceivedObject, aMtmID, aFile, aTime); |
|
49 if(isVmsg) |
|
50 { |
|
51 parser->SaveSapMessageL(aMsvSession); |
|
52 } |
|
53 CleanupStack::PopAndDestroy(parser); |
|
54 |
|
55 FLOG( _L( " CSapVMessageParser: HandleMessageL: Done\t" ) ); |
|
56 |
|
57 return isVmsg; |
|
58 } |
|
59 |
|
60 CSapVMessageParser* CSapVMessageParser::NewLC() |
|
61 { |
|
62 CSapVMessageParser* self = new (ELeave) CSapVMessageParser(); |
|
63 CleanupStack::PushL(self); |
|
64 self->ConstructL(); |
|
65 return self; |
|
66 } |
|
67 |
|
68 void CSapVMessageParser::ConstructL() |
|
69 { |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // Constructor |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 CSapVMessageParser::CSapVMessageParser() |
|
77 { |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------- |
|
81 // ParseMessageL |
|
82 // Recognises and parses SAP VMessage. |
|
83 // --------------------------------------------------------- |
|
84 // |
|
85 TBool CSapVMessageParser::ParseMessageL(CObexBufObject* aReceivedObject, const TUid aMtmID, |
|
86 RFile& aFile, TTime aTime) |
|
87 { |
|
88 FLOG( _L( " CSapVMessageParser: ParseMessageL\t" ) ); |
|
89 |
|
90 static const TInt KExpandSize = 16; |
|
91 |
|
92 iType=ESapVMessageUnknown; |
|
93 |
|
94 if( aMtmID != KUidMsgTypeBt || |
|
95 !CheckMime(aReceivedObject->Type()) || |
|
96 !CheckName(aReceivedObject->Name()) || |
|
97 !IsSapConnectionActive()) |
|
98 { |
|
99 FLOG( _L( " CSapVMessageParser: ParseMessageL: Unknown\t" ) ); |
|
100 return EFalse; |
|
101 } |
|
102 |
|
103 CBufFlat* buffer = CBufFlat::NewL( KExpandSize ); |
|
104 CleanupStack::PushL(buffer); // 1st push |
|
105 |
|
106 TInt fileLength; |
|
107 User::LeaveIfError( aFile.Size( fileLength ) ); |
|
108 |
|
109 // Read the file into buffer |
|
110 buffer->ResizeL( fileLength ); |
|
111 TPtr8 temp = buffer->Ptr(0); |
|
112 TInt pos = 0; |
|
113 aFile.Seek(ESeekStart, pos); |
|
114 User::LeaveIfError( aFile.Read( temp ) ); |
|
115 |
|
116 pos=0; |
|
117 aFile.Seek(ESeekStart, pos); // rewind file |
|
118 |
|
119 SimpleParseL(temp); |
|
120 |
|
121 CleanupStack::PopAndDestroy(buffer); // -1 pop |
|
122 |
|
123 iTimeReceived=aTime; |
|
124 if(aReceivedObject->Time()==TTime(0)) |
|
125 { |
|
126 iTimeOriginal = aTime; |
|
127 } |
|
128 else |
|
129 { |
|
130 iTimeOriginal = aReceivedObject->Time(); |
|
131 } |
|
132 |
|
133 return (iType!=ESapVMessageUnknown); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // IsSapConnectionActive |
|
138 // Recognises active SAP connection. |
|
139 // --------------------------------------------------------- |
|
140 // |
|
141 TBool CSapVMessageParser::IsSapConnectionActive() |
|
142 { |
|
143 FLOG( _L( " CSapVMessageParser: IsSapConnectionActive\t" ) ); |
|
144 |
|
145 TInt state=EBTSapNotConnected; |
|
146 RProperty::Get(KPSUidBluetoothSapConnectionState, KBTSapConnectionState, state); |
|
147 return state==EBTSapConnected; |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // CheckMime |
|
153 // Check MIME type of vMessage. |
|
154 // --------------------------------------------------------- |
|
155 // |
|
156 TBool CSapVMessageParser::CheckMime(const TDesC8& aType) |
|
157 { |
|
158 FLOG( _L( " CSapVMessageParser: CheckMime\t" ) ); |
|
159 |
|
160 _LIT8(KMimeVmsg,"text/x-vmsg\x00"); |
|
161 |
|
162 return (aType.Compare(KMimeVmsg)==0); |
|
163 } |
|
164 |
|
165 |
|
166 // --------------------------------------------------------- |
|
167 // CheckName |
|
168 // Check object name of SAP vMessage. |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 TBool CSapVMessageParser::CheckName(const TDesC& aName) |
|
172 { |
|
173 FLOG( _L( " CSapVMessageParser: CheckName\t" ) ); |
|
174 |
|
175 _LIT(KNameVmsg, "sap_sms.vmg"); |
|
176 |
|
177 return (aName.Compare(KNameVmsg)==0); |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------- |
|
181 // Address |
|
182 // Returns address field of parsed message. |
|
183 // --------------------------------------------------------- |
|
184 // |
|
185 const TDesC& CSapVMessageParser::Address() const |
|
186 { |
|
187 if(iType==ESapVMessageTextSMS && iAddress) |
|
188 { |
|
189 return *iAddress; |
|
190 } |
|
191 else |
|
192 { |
|
193 return KNullDesC; |
|
194 } |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------- |
|
198 // Message |
|
199 // Returns body text of parsed message. |
|
200 // --------------------------------------------------------- |
|
201 // |
|
202 const TDesC& CSapVMessageParser::Message() const |
|
203 { |
|
204 if(iType==ESapVMessageTextSMS && iMessage) |
|
205 { |
|
206 return *iMessage; |
|
207 } |
|
208 else |
|
209 { |
|
210 return KNullDesC; |
|
211 } |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------- |
|
215 // ~CSapVMessageParser |
|
216 // Destructor. |
|
217 // --------------------------------------------------------- |
|
218 // |
|
219 CSapVMessageParser::~CSapVMessageParser() |
|
220 { |
|
221 FLOG( _L( " CSapVMessageParser: ~CSapVMessageParser\t" ) ); |
|
222 |
|
223 delete iAddress; |
|
224 delete iMessage; |
|
225 } |
|
226 |
|
227 static TBool Compare(const TDesC8& aData, TInt& aReadBytes, const TDesC8& aToken) |
|
228 { |
|
229 if( (aData.Length() >= aReadBytes + aToken.Length()) && |
|
230 (aData.Mid(aReadBytes, aToken.Length()).Compare(aToken)==0) ) |
|
231 { |
|
232 aReadBytes+=aToken.Length(); |
|
233 return ETrue; |
|
234 } |
|
235 else |
|
236 { |
|
237 return EFalse; |
|
238 } |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------- |
|
242 // SimpleParseL |
|
243 // Parses SAP VMessage. |
|
244 // --------------------------------------------------------- |
|
245 // |
|
246 void CSapVMessageParser::SimpleParseL(const TDesC8& aData) |
|
247 { |
|
248 FLOG( _L( " CSapVMessageParser: SimpleParseL\t" ) ); |
|
249 |
|
250 // SAP VMessage format definitions |
|
251 _LIT8(KVmsgStatus, "BEGIN:VMSG\x0d\x0a" |
|
252 "VERSION:1.1\x0d\x0a" |
|
253 "X-IRMC-STATUS:"); |
|
254 _LIT8(KVmsgBox, "\x0d\x0a" |
|
255 "X-IRMC-TYPE:SMS\x0d\x0a" |
|
256 "X-IRMC-BOX:"); |
|
257 _LIT8(KVmsgVCard, "BEGIN:VCARD\x0d\x0a" |
|
258 "VERSION:2.1\x0d\x0a"); |
|
259 _LIT8(KVmsgName1, "N:"); |
|
260 _LIT8(KVmsgName2, "N;ENCODING=8BIT;CHARSET=UTF-8:"); |
|
261 _LIT8(KVmsgTel, "\x0d\x0a" |
|
262 "TEL:"); |
|
263 _LIT8(KVmsgVCardEnd,"\x0d\x0a" |
|
264 "END:VCARD\x0d\x0a"); |
|
265 _LIT8(KVmsgVEnv, "BEGIN:VENV\x0d\x0a"); |
|
266 _LIT8(KVmsgVBody, "BEGIN:VBODY\x0d\x0a" |
|
267 "X-SMS;TYPE=TEXT;ENCODING=8BIT;CHARSET=UTF-8:"); |
|
268 _LIT8(KVmsgEnd, "\x0d\x0a" |
|
269 "END:VBODY\x0d\x0a" |
|
270 "END:VENV\x0d\x0a" |
|
271 "END:VMSG\x0d\x0a"); |
|
272 _LIT8(KVmsgUnread, "UNREAD"); |
|
273 _LIT8(KVmsgRead, "READ"); |
|
274 _LIT8(KVmsgInbox, "INBOX\x0d\x0a"); |
|
275 _LIT8(KVmsgSentbox, "SENTBOX\x0d\x0a"); |
|
276 _LIT8(KCrLf, "\x0d\x0a"); |
|
277 |
|
278 // Simple SAP VMessage parsing |
|
279 TInt readBytes=0; |
|
280 if( Compare(aData, readBytes, KVmsgStatus) && |
|
281 aData.Right(KVmsgEnd().Length()).Compare(KVmsgEnd)==0 ) |
|
282 { // The begin and end of the message are correct |
|
283 if(Compare(aData, readBytes, KVmsgUnread)) |
|
284 { // Status: Unread |
|
285 iStatus=ESapVMessageStatusUnread; |
|
286 } |
|
287 else if(Compare(aData, readBytes, KVmsgRead)) |
|
288 { // Status: Read or Sent |
|
289 iStatus=ESapVMessageStatusRead; |
|
290 } |
|
291 else |
|
292 { // Unknown status |
|
293 return; |
|
294 } |
|
295 if( Compare(aData, readBytes, KVmsgBox) ) |
|
296 { |
|
297 if(iStatus==ESapVMessageStatusRead && Compare(aData, readBytes, KVmsgSentbox)) |
|
298 { // Status: Sent |
|
299 iStatus=ESapVMessageStatusSent; |
|
300 if(!Compare(aData, readBytes, KVmsgVEnv)) |
|
301 { |
|
302 return; |
|
303 } |
|
304 } |
|
305 else if(! Compare(aData, readBytes, KVmsgInbox) ) |
|
306 { |
|
307 return; |
|
308 } |
|
309 if( Compare(aData, readBytes, KVmsgVCard) && |
|
310 ( Compare(aData, readBytes, KVmsgName1) || |
|
311 Compare(aData, readBytes, KVmsgName2) ) ) |
|
312 { // The begin of the message is correct |
|
313 TInt beginOfName=readBytes; |
|
314 TInt endOfName=aData.Find(KVmsgTel); |
|
315 TInt endOfFrom=aData.Find(KVmsgVCardEnd); |
|
316 readBytes=endOfFrom+KVmsgVCardEnd().Length(); |
|
317 if(iStatus!=ESapVMessageStatusSent) |
|
318 { |
|
319 if(!Compare(aData, readBytes, KVmsgVEnv)) |
|
320 { |
|
321 return; |
|
322 } |
|
323 } |
|
324 if(endOfFrom!=KErrNotFound && endOfName!=KErrNotFound && |
|
325 endOfName<endOfFrom && Compare(aData, readBytes, KVmsgVBody)) |
|
326 { // The middle part of the message is correct |
|
327 TInt beginOfFrom=endOfName+KVmsgTel().Length(); |
|
328 TInt fromLength=endOfFrom-beginOfFrom; |
|
329 if(fromLength <= RMobilePhone::KMaxMobileTelNumberSize) |
|
330 { // The sender field of the message is not too long |
|
331 TInt beginOfBody=readBytes; |
|
332 TInt bodyLength=(aData.Length()-KVmsgEnd().Length())-beginOfBody; |
|
333 |
|
334 TPtrC8 name = aData.Mid(beginOfName, endOfName-beginOfName); |
|
335 TPtrC8 from = aData.Mid(beginOfFrom, fromLength); |
|
336 if((name.Find(KCrLf)==KErrNotFound) && (from.Find(KCrLf)==KErrNotFound)) |
|
337 { // Message is correct |
|
338 if(from.Length()==0 && name.Length()>0 && |
|
339 name.Length() <= RMobilePhone::KMaxMobileTelNumberSize) |
|
340 { |
|
341 iAddress = CnvUtfConverter::ConvertToUnicodeFromUtf8L(name); |
|
342 } |
|
343 else |
|
344 { |
|
345 iAddress = HBufC::NewL(from.Length()); |
|
346 iAddress->Des().Copy(from); |
|
347 } |
|
348 |
|
349 TPtrC8 body = aData.Mid(beginOfBody, bodyLength); |
|
350 iMessage = CnvUtfConverter::ConvertToUnicodeFromUtf8L(body); |
|
351 |
|
352 FLOG( _L( " CSapVMessageParser: SimpleParseL: SMS\t" ) ); |
|
353 iType=ESapVMessageTextSMS; |
|
354 } |
|
355 } |
|
356 } |
|
357 } |
|
358 } |
|
359 } |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------- |
|
363 // SaveSapMessageL |
|
364 // Saves parsed VMessage. |
|
365 // --------------------------------------------------------- |
|
366 // |
|
367 void CSapVMessageParser::SaveSapMessageL(CMsvSession* aMsvSession) |
|
368 { |
|
369 FLOG( _L( " CSapVMessageParser: SaveSapMessageL\t" ) ); |
|
370 |
|
371 switch(iType) |
|
372 { |
|
373 case ESapVMessageTextSMS: |
|
374 SaveSapSmsL(aMsvSession); |
|
375 break; |
|
376 |
|
377 case ESapVMessageMMSNotificationInd: |
|
378 SaveSapMmsL(aMsvSession); |
|
379 break; |
|
380 |
|
381 default: // Discard message |
|
382 break; |
|
383 } |
|
384 } |
|
385 |
|
386 // --------------------------------------------------------- |
|
387 // SaveSapSmsL |
|
388 // Saves parsed VMessage as SMS. |
|
389 // --------------------------------------------------------- |
|
390 // |
|
391 void CSapVMessageParser::SaveSapSmsL(CMsvSession* aMsvSession) |
|
392 { |
|
393 FLOG( _L( " CSapVMessageParser: SaveSapSmsL\t" ) ); |
|
394 |
|
395 CParaFormatLayer* richParaFormatLayer = CParaFormatLayer::NewL(); |
|
396 CleanupStack::PushL(richParaFormatLayer); // 1st push |
|
397 CCharFormatLayer* richCharFormatLayer = CCharFormatLayer::NewL(); |
|
398 CleanupStack::PushL(richCharFormatLayer); // 2nd push |
|
399 CRichText* |
|
400 richText = CRichText::NewL(richParaFormatLayer,richCharFormatLayer); |
|
401 CleanupStack::PushL(richText); // 3rd push |
|
402 |
|
403 richText->InsertL(0, Message()); |
|
404 |
|
405 if(iStatus==ESapVMessageStatusSent) |
|
406 { |
|
407 SaveSmsToSentL(aMsvSession, richText); |
|
408 } |
|
409 else |
|
410 { |
|
411 SaveSmsToInboxL(aMsvSession, richText); |
|
412 } |
|
413 |
|
414 CleanupStack::PopAndDestroy(3, richParaFormatLayer); |
|
415 |
|
416 FLOG( _L( " CSapVMessageParser: SaveSapSmsL: Done\t" ) ); |
|
417 } |
|
418 |
|
419 // --------------------------------------------------------- |
|
420 // SaveSapMmsL |
|
421 // Saves parsed VMessage as MMS notification. |
|
422 // --------------------------------------------------------- |
|
423 // |
|
424 void CSapVMessageParser::SaveSapMmsL(CMsvSession* /*aMsvSession*/) const |
|
425 { |
|
426 // This is not supported |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------- |
|
430 // SaveSmsToInboxL |
|
431 // Saves parsed VMessage to Inbox as SMS. |
|
432 // --------------------------------------------------------- |
|
433 // |
|
434 void CSapVMessageParser::SaveSmsToInboxL(CMsvSession* aMsvSession, CRichText* aMessage) |
|
435 { |
|
436 #ifndef NO101APPDEPFIXES_NEW |
|
437 (void) aMsvSession; |
|
438 (void) aMessage; |
|
439 #endif //NO101APPDEPFIXES_NEW |
|
440 #ifdef NO101APPDEPFIXES_NEW |
|
441 FLOG( _L( " CSapVMessageParser: SaveSmsToInboxL\t" ) ); |
|
442 CSmsHeader* header=CSmsHeader::NewL(CSmsPDU::ESmsDeliver, *aMessage ); |
|
443 CleanupStack::PushL(header); // 1st push |
|
444 header->SetFromAddressL(Address()); |
|
445 header->SetReplyPathProvided(EFalse); |
|
446 |
|
447 TMsvEntry newTEntry; |
|
448 |
|
449 newTEntry.iType = KUidMsvMessageEntry; |
|
450 newTEntry.iMtm = KUidMsgTypeSMS; |
|
451 newTEntry.SetComplete(EFalse); |
|
452 newTEntry.SetFailed(EFalse); |
|
453 newTEntry.SetOperation(EFalse); |
|
454 newTEntry.SetMultipleRecipients(EFalse); |
|
455 newTEntry.SetVisible(EFalse); // Make invisible |
|
456 // and in preparation to make sure gets cleaned up on errors. |
|
457 newTEntry.SetInPreparation(ETrue); |
|
458 newTEntry.SetSendingState(KMsvSendStateNotApplicable); |
|
459 newTEntry.iServiceId = KMsvLocalServiceIndexEntryId; |
|
460 newTEntry.iSize = 0; |
|
461 newTEntry.iDate = iTimeReceived; |
|
462 header->Message().SetTime(iTimeOriginal); |
|
463 ((CSmsDeliver*)&header->Message().SmsPDU())->SetServiceCenterTimeStamp(iTimeOriginal); |
|
464 |
|
465 // SMUT Unbranch |
|
466 CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); |
|
467 CleanupStack::PushL( smsPlugin ); |
|
468 |
|
469 TBuf<KSmsDescriptionLength> description; |
|
470 smsPlugin->GetDescription( header->Message(), description ); |
|
471 newTEntry.iDescription.Set(description); |
|
472 TBuf<KSmsDetailsLength> details; |
|
473 smsPlugin->GetDetails( aMsvSession->FileSession(), header->Message(), details ); |
|
474 newTEntry.iDetails.Set(details); |
|
475 |
|
476 CleanupStack::PopAndDestroy( smsPlugin ); |
|
477 |
|
478 // Create new entry to inbox |
|
479 CMsvEntry* inbox = aMsvSession->GetEntryL( KMsvGlobalInBoxIndexEntryId ); |
|
480 CleanupStack::PushL( inbox ); |
|
481 inbox->CreateL(newTEntry); |
|
482 CleanupStack::PopAndDestroy(inbox); |
|
483 |
|
484 TMsvId newEntryId=newTEntry.Id(); |
|
485 aMsvSession->CleanupEntryPushL(newEntryId); //2nd push |
|
486 |
|
487 // Get the created entry |
|
488 CMsvEntry* newEntry = aMsvSession->GetEntryL(newEntryId); |
|
489 CleanupStack::PushL(newEntry); // 3rd push |
|
490 |
|
491 // Store SMS message to the entry |
|
492 CMsvStore* newMessageStore = newEntry->EditStoreL(); |
|
493 CleanupStack::PushL(newMessageStore); // 4th push |
|
494 header->StoreL(*newMessageStore); |
|
495 newMessageStore->StoreBodyTextL(*aMessage); |
|
496 newMessageStore->CommitL(); |
|
497 |
|
498 // Save the size & make visible |
|
499 newTEntry = newEntry->Entry(); |
|
500 newTEntry.iSize = newMessageStore->SizeL(); |
|
501 |
|
502 // Saved OK. Make the entry visible and flag it as complete. |
|
503 newTEntry.SetVisible(ETrue); |
|
504 newTEntry.SetInPreparation(EFalse); |
|
505 newTEntry.SetUnread(iStatus==ESapVMessageStatusUnread); |
|
506 newTEntry.SetNew(iStatus==ESapVMessageStatusRead); |
|
507 newTEntry.SetComplete(ETrue); |
|
508 newTEntry.SetReadOnly(ETrue); |
|
509 newEntry->ChangeL(newTEntry); |
|
510 |
|
511 CleanupStack::PopAndDestroy(2, newEntry); |
|
512 aMsvSession->CleanupEntryPop(); |
|
513 CleanupStack::PopAndDestroy(header); |
|
514 |
|
515 FLOG( _L( " CSapVMessageParser: SaveSmsToInboxL: Done\t" ) ); |
|
516 #endif //NO101APPDEPFIXES_NEW |
|
517 } |
|
518 |
|
519 // --------------------------------------------------------- |
|
520 // SaveSmsToSentL |
|
521 // Saves parsed VMessage to Sent folder as SMS. |
|
522 // --------------------------------------------------------- |
|
523 // |
|
524 void CSapVMessageParser::SaveSmsToSentL(CMsvSession* aMsvSession, CRichText* aMessage) |
|
525 { |
|
526 #ifndef NO101APPDEPFIXES_NEW |
|
527 (void) aMsvSession; |
|
528 (void) aMessage; |
|
529 #endif //NO101APPDEPFIXES_NEW |
|
530 |
|
531 #ifdef NO101APPDEPFIXES_NEW |
|
532 FLOG( _L( " CSapVMessageParser: SaveSmsToSentL\t" ) ); |
|
533 |
|
534 CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsSubmit, *aMessage ); |
|
535 CleanupStack::PushL( header ); |
|
536 header->SetFromAddressL(Address()); |
|
537 |
|
538 TMsvEntry newTEntry; |
|
539 newTEntry.iType = KUidMsvMessageEntry; |
|
540 newTEntry.iMtm = KUidMsgTypeSMS; |
|
541 newTEntry.SetComplete(EFalse); |
|
542 newTEntry.SetFailed(EFalse); |
|
543 newTEntry.SetOperation(EFalse); |
|
544 newTEntry.SetMultipleRecipients(EFalse); |
|
545 newTEntry.SetVisible(EFalse); // Make invisible |
|
546 // and in preparation to make sure gets cleaned up on errors. |
|
547 newTEntry.SetInPreparation(ETrue); |
|
548 newTEntry.SetSendingState(KMsvSendStateSent); |
|
549 newTEntry.iServiceId = KMsvUnknownServiceIndexEntryId; |
|
550 newTEntry.iSize = 0; |
|
551 newTEntry.iDate=iTimeReceived; |
|
552 header->Message().SetTime(iTimeOriginal); |
|
553 |
|
554 // SMUT Unbranch |
|
555 CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); |
|
556 CleanupStack::PushL( smsPlugin ); |
|
557 |
|
558 TBuf<KSmsDescriptionLength> description; |
|
559 smsPlugin->GetDescription( header->Message(), description ); |
|
560 newTEntry.iDescription.Set(description); |
|
561 TBuf<KSmsDetailsLength> details; |
|
562 smsPlugin->GetDetails( aMsvSession->FileSession(), header->Message(), details ); |
|
563 newTEntry.iDetails.Set(details); |
|
564 |
|
565 CleanupStack::PopAndDestroy( smsPlugin ); |
|
566 |
|
567 CSmsSettings* settings = CSmsSettings::NewLC(); |
|
568 CSmsAccount* account = CSmsAccount::NewLC(); |
|
569 account->LoadSettingsL(*settings); |
|
570 CleanupStack::PopAndDestroy(account); |
|
571 header->SetSmsSettingsL( *settings ); |
|
572 TInt scindex = settings->DefaultServiceCenter(); |
|
573 if ( scindex != KErrNotFound ) |
|
574 { |
|
575 header->SetServiceCenterAddressL( ( settings->GetServiceCenter( scindex ) ).Address() ); |
|
576 } |
|
577 CleanupStack::PopAndDestroy(settings); |
|
578 |
|
579 CSmsNumber* rcpt = CSmsNumber::NewL(); |
|
580 CleanupStack::PushL( rcpt ); |
|
581 rcpt->SetAddressL(Address()); |
|
582 if(Address()!=details) |
|
583 { |
|
584 rcpt->SetNameL(details); |
|
585 } |
|
586 header->Recipients().ResetAndDestroy(); |
|
587 header->Recipients().AppendL( rcpt ); |
|
588 CleanupStack::Pop( rcpt ); |
|
589 |
|
590 // Create new entry to Sent folder |
|
591 CMsvEntry* sentFldr = aMsvSession->GetEntryL( KMsvSentEntryId ); |
|
592 CleanupStack::PushL( sentFldr ); |
|
593 sentFldr->CreateL(newTEntry); |
|
594 CleanupStack::PopAndDestroy(sentFldr); |
|
595 |
|
596 TMsvId newEntryId=newTEntry.Id(); |
|
597 aMsvSession->CleanupEntryPushL(newEntryId); //2nd push |
|
598 |
|
599 // Get the created entry |
|
600 CMsvEntry* newEntry = aMsvSession->GetEntryL(newEntryId); |
|
601 CleanupStack::PushL(newEntry); // 3rd push |
|
602 |
|
603 // Store SMS message to the entry |
|
604 CMsvStore* newMessageStore = newEntry->EditStoreL(); |
|
605 CleanupStack::PushL(newMessageStore); // 4th push |
|
606 header->StoreL(*newMessageStore); |
|
607 newMessageStore->StoreBodyTextL(*aMessage); |
|
608 newMessageStore->CommitL(); |
|
609 |
|
610 // Save the size & make visible |
|
611 newTEntry = newEntry->Entry(); |
|
612 newTEntry.iSize = newMessageStore->SizeL(); |
|
613 |
|
614 // Saved OK. Make the entry visible and flag it as complete. |
|
615 newTEntry.SetVisible(ETrue); |
|
616 newTEntry.SetInPreparation(EFalse); |
|
617 newTEntry.SetComplete(ETrue); |
|
618 newEntry->ChangeL(newTEntry); |
|
619 |
|
620 CleanupStack::PopAndDestroy(2, newEntry); |
|
621 aMsvSession->CleanupEntryPop(); |
|
622 CleanupStack::PopAndDestroy(header); |
|
623 |
|
624 FLOG( _L( " CSapVMessageParser: SaveSmsToSentL: Done\t" ) ); |
|
625 #endif //NO101APPDEPFIXES_NEW |
|
626 } |
|
627 |
|
628 // End of File |
|