|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Main class for handling provisioning message |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <biodb.h> // BIO Message Database and message query methods |
|
22 #include <msvuids.h> // KUidMsvMessageEntry const |
|
23 #include <biouids.h> // KUidBioMessageTypeMtm const |
|
24 #include <msvapi.h> |
|
25 #include <msvids.h> |
|
26 #include <txtfmlyr.h> |
|
27 #include <txtrich.h> |
|
28 #include <smut.h> |
|
29 #include <smuthdr.h> |
|
30 #include <provisioninghandlerresource.rsg> |
|
31 #include <pushmessage.h> |
|
32 #include <CWPEngine.h> |
|
33 #include <WPAdapterUtil.h> |
|
34 #include <data_caging_path_literals.hrh> |
|
35 #include <centralrepository.h> |
|
36 #include <csmsgetdetdescinterface.h> |
|
37 #include "MWPPhone.h" |
|
38 #include "WPPhoneFactory.h" |
|
39 #include "CWPBootstrap.h" |
|
40 #include "CWPMessage.h" |
|
41 #include "CWPPushMessage.h" |
|
42 #include "WPHandlerDebug.h" |
|
43 #include "WPHandlerUtil.h" |
|
44 #include "ProvisioningDebug.h" |
|
45 #include "ProvisioningInternalCRKeys.h" |
|
46 |
|
47 |
|
48 // CONSTANTS |
|
49 _LIT(KResourceName, "ProvisioningHandler"); |
|
50 |
|
51 _LIT(KDirAndFile,"z:ProvisioningHandler.rsc"); |
|
52 |
|
53 |
|
54 // ============================ MEMBER FUNCTIONS =============================== |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CWPMessage::CWPMessage |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CWPMessage::CWPMessage() |
|
63 { |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CWPMessage::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CWPMessage::ConstructL( CPushMessage& aMessage ) |
|
72 { |
|
73 FLOG( _L( "CWPMessage::ConstructL: Opening msg session" ) ); |
|
74 |
|
75 iSession = CMsvSession::OpenSyncL(*this); |
|
76 |
|
77 FLOG( _L( "CWPMessage::ConstructL: Constructing push message" ) ); |
|
78 iMessage = CWPPushMessage::NewL(); |
|
79 |
|
80 TPtrC8 bodyValue; |
|
81 TPtrC8 headerValue; |
|
82 if (aMessage.GetMessageBody(bodyValue) |
|
83 && aMessage.GetHeader(headerValue) ) |
|
84 { |
|
85 iMessage->SetL( headerValue, bodyValue ); |
|
86 } |
|
87 |
|
88 TPtrC8 serverValue; |
|
89 if( aMessage.GetServerAddress( serverValue ) ) |
|
90 { |
|
91 FLOG( _L( "CWPMessage::Begin originator" ) ); |
|
92 DHEX( serverValue ); |
|
93 FLOG( _L( "CWPMessage::End originator" ) ); |
|
94 iMessage->SetOriginatorL( serverValue ); |
|
95 iSender = serverValue.AllocL(); |
|
96 } |
|
97 |
|
98 FLOG( _L( "CWPMessage::Begin header" )); |
|
99 DHEX( iMessage->Header() ); |
|
100 FLOG( _L( "CWPMessage::Begin message body" ) ); |
|
101 DHEX( iMessage->Body() ); |
|
102 FLOG( _L( "CWPMessage::End message" ) ); |
|
103 |
|
104 FLOG( _L( "CWPMessage::ConstructL: Retrieving BIO message type" ) ); |
|
105 BioMessageTypeL( aMessage ); |
|
106 |
|
107 FLOG( _L( "CWPMessage::ConstructL: Finished" ) ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CWPMessage::NewL |
|
112 // Two-phased constructor. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 CWPMessage* CWPMessage::NewL( CPushMessage& aMessage ) |
|
116 { |
|
117 CWPMessage* self = new(ELeave) CWPMessage; |
|
118 CleanupStack::PushL(self); |
|
119 self->ConstructL( aMessage ); |
|
120 CleanupStack::Pop(self); |
|
121 return self; |
|
122 } |
|
123 |
|
124 // Destructor |
|
125 CWPMessage::~CWPMessage() |
|
126 { |
|
127 delete iPhone; |
|
128 delete iSession; |
|
129 delete iSender; |
|
130 delete iMessage; |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CWPMessage::HandleSessionEventL |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CWPMessage::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, |
|
138 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
139 { |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CWPMessage::ProcessL |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CWPMessage::ProcessL() |
|
147 { |
|
148 FLOG( _L( "CWPMessage::ProcessL: Started" ) ); |
|
149 |
|
150 // Create a phone if one does not already exist |
|
151 if( !iPhone ) |
|
152 { |
|
153 iPhone = WPPhoneFactory::CreateL(); |
|
154 } |
|
155 |
|
156 FLOG( _L( "CWPMessage::ProcessL: Creating engine" ) ); |
|
157 |
|
158 // Read the message into the engine |
|
159 CWPEngine* engine = CWPEngine::NewLC(); // on CS |
|
160 |
|
161 FLOG( _L( "CWPMessage::ProcessL: Importing document" ) ); |
|
162 engine->ImportDocumentL( iMessage->Body() ); |
|
163 |
|
164 FLOG( _L( "CWPMessage::ProcessL: Populating adapters" ) ); |
|
165 engine->PopulateL(); |
|
166 |
|
167 FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Number of settings: (%d)"), engine->ItemCount())); |
|
168 // Check if the sender can be trusted |
|
169 TPtrC8 orig8( iMessage->Originator() ); |
|
170 HBufC* originator = HBufC::NewLC( orig8.Length() ); |
|
171 TPtr orig16( originator->Des() ); |
|
172 orig16.Copy( orig8 ); |
|
173 if( engine->ContextExistsL( orig16 ) ) |
|
174 { |
|
175 iMessage->SetAuthenticated( ETrue ); |
|
176 } |
|
177 CleanupStack::PopAndDestroy(); // originator |
|
178 |
|
179 // Try bootstrapping |
|
180 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping" ) ); |
|
181 CWPBootstrap* bootstrap = CWPBootstrap::NewL( iPhone->SubscriberId() ); |
|
182 CleanupStack::PushL( bootstrap ); |
|
183 |
|
184 CWPBootstrap::TBootstrapResult result( |
|
185 bootstrap->BootstrapL( *iMessage, *engine, KNullDesC ) ); |
|
186 CleanupStack::PopAndDestroy(); // bootstrap |
|
187 |
|
188 FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Bootstrap result: (%d)"), result)); |
|
189 // See UI specs figure 1 |
|
190 TBool haveSettings( engine->ItemCount() > 0 ); |
|
191 switch( result ) |
|
192 { |
|
193 case CWPBootstrap::ENoBootstrap: |
|
194 { |
|
195 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENoBootstrap" ) ); |
|
196 // If there's no bootstrap, just save the message |
|
197 if( haveSettings ) |
|
198 { |
|
199 StoreMsgL(); |
|
200 } |
|
201 else |
|
202 { |
|
203 User::Leave( KErrCorrupt ); |
|
204 } |
|
205 break; |
|
206 } |
|
207 |
|
208 case CWPBootstrap::ENotAuthenticated: |
|
209 { |
|
210 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENotAuthenticated" ) ); |
|
211 if( haveSettings ) |
|
212 { |
|
213 StoreMsgL(); |
|
214 } |
|
215 else |
|
216 { |
|
217 |
|
218 // Message is ignored and an information SMs is put to Inbox. |
|
219 //Information SMs can be Class0, based on operator requirement. |
|
220 TInt auth_value; |
|
221 CRepository * rep = 0; |
|
222 TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV )); |
|
223 if(err == KErrNone) |
|
224 { |
|
225 rep->Get( KOMAProvAuthFailMsgHandling, auth_value ); |
|
226 delete rep; |
|
227 |
|
228 if(auth_value == 1) |
|
229 StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED); |
|
230 else |
|
231 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
|
232 |
|
233 User::Leave( KErrAccessDenied ); |
|
234 } |
|
235 else |
|
236 { |
|
237 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
|
238 User::Leave( KErrAccessDenied ); |
|
239 } |
|
240 } |
|
241 break; |
|
242 } |
|
243 |
|
244 case CWPBootstrap::EPinRequired: |
|
245 { |
|
246 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping EPinRequired" ) ); |
|
247 |
|
248 // If PIN is required, defer authentication to ProvisioningBC |
|
249 if( haveSettings ) |
|
250 { |
|
251 StoreMsgL(); |
|
252 } |
|
253 else |
|
254 { |
|
255 User::Leave( KErrCorrupt ); |
|
256 } |
|
257 break; |
|
258 } |
|
259 |
|
260 case CWPBootstrap::EAuthenticationFailed: |
|
261 { |
|
262 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping EAuthenticationFailed" ) ); |
|
263 |
|
264 // Bootstrap is ignored and an information SMS is put to Inbox. |
|
265 //Information SMs can be Class0, based on operator requirement. |
|
266 TInt auth_value; |
|
267 CRepository * rep = 0; |
|
268 TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV )); |
|
269 if(err == KErrNone) |
|
270 { |
|
271 rep->Get( KOMAProvAuthFailMsgHandling, auth_value ); |
|
272 delete rep; |
|
273 |
|
274 if(auth_value == 1) |
|
275 StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED); |
|
276 else |
|
277 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
|
278 |
|
279 User::Leave( KErrAccessDenied ); |
|
280 |
|
281 } |
|
282 else |
|
283 { |
|
284 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
|
285 User::Leave( KErrAccessDenied ); |
|
286 } |
|
287 break; |
|
288 } |
|
289 |
|
290 case CWPBootstrap::EBootstrapExists: |
|
291 { |
|
292 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping EBootstrapExists" ) ); |
|
293 |
|
294 if( haveSettings ) |
|
295 { |
|
296 StoreMsgL(); |
|
297 } |
|
298 else |
|
299 { |
|
300 // Bootstrap is ignored and an information SMS is put to Inbox |
|
301 StoreMsgL( R_TEXT_BOOTSTRAP_EXISTS ); |
|
302 User::Leave( KErrAlreadyExists ); |
|
303 } |
|
304 break; |
|
305 } |
|
306 |
|
307 case CWPBootstrap::ESucceeded: |
|
308 { |
|
309 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ESucceeded" ) ); |
|
310 |
|
311 if( haveSettings ) |
|
312 { |
|
313 StoreMsgL(); |
|
314 } |
|
315 else |
|
316 { |
|
317 StoreMsgL( R_TEXT_BOOTSTRAPPED ); |
|
318 } |
|
319 break; |
|
320 } |
|
321 |
|
322 default: |
|
323 { |
|
324 break; |
|
325 } |
|
326 } |
|
327 |
|
328 CleanupStack::PopAndDestroy(); // engine |
|
329 |
|
330 FLOG( _L( "CWPMessage::ProcessL: Finished" ) ); |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CWPMessage::BioMessageTypeL |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 void CWPMessage::BioMessageTypeL( CPushMessage& aMessage ) |
|
338 { |
|
339 FLOG( _L( "CWPMessage::BioMessageTypeL" ) ); |
|
340 |
|
341 // need to create local RFs for BIO otherwise raises exception |
|
342 RFs localFS; |
|
343 User::LeaveIfError(localFS.Connect()); |
|
344 CleanupClosePushL(localFS); |
|
345 CBIODatabase* bioDB = CBIODatabase::NewLC(localFS); |
|
346 |
|
347 TPtrC contentTypePtr; |
|
348 aMessage.GetContentType(contentTypePtr); |
|
349 |
|
350 iBioUID = KNullUid; |
|
351 // IsBioMessageL returns KErrNone if found or KErrNotFound if not found |
|
352 TInt retVal = bioDB->IsBioMessageL(EBioMsgIdIana, contentTypePtr, NULL, iBioUID); |
|
353 FTRACE(RDebug::Print(_L(" CWPMessage::BioMessageTypeL (%d)"), retVal)); |
|
354 CleanupStack::PopAndDestroy(2); // bioDB, localFS |
|
355 } |
|
356 |
|
357 // ----------------------------------------------------------------------------- |
|
358 // CWPMessage::StoreMsgL |
|
359 // ----------------------------------------------------------------------------- |
|
360 // |
|
361 void CWPMessage::StoreMsgL() |
|
362 { |
|
363 FLOG( _L( "CWPMessage::StoreMsgL" ) ); |
|
364 |
|
365 // create an invisible blank entry |
|
366 TMsvEntry entry; |
|
367 PrepareEntryLC( entry ); // details on cleanup stack |
|
368 entry.iBioType = iBioUID.iUid; |
|
369 entry.iMtm = KUidBIOMessageTypeMtm; |
|
370 |
|
371 // Look up and set the description |
|
372 FLOG( _L( "CWPMessage::StoreMsgL 1" ) ); |
|
373 |
|
374 TInt index; |
|
375 CBIODatabase* bioDB = CBIODatabase::NewLC( iSession->FileSession() ); |
|
376 FLOG( _L( "CWPMessage::StoreMsgL 2" ) ); |
|
377 TRAPD( err, bioDB->GetBioIndexWithMsgIDL( iBioUID, index ) ); |
|
378 if (err ==KErrNone) |
|
379 { |
|
380 FLOG( _L( "CWPMessage::StoreMsgL 3" ) ); |
|
381 HBufC* description = bioDB->BifReader(index).Description().AllocL(); |
|
382 FLOG( _L( "CWPMessage::StoreMsgL 4" ) ); |
|
383 entry.iDescription.Set(*description); |
|
384 FLOG( _L( "CWPMessage::StoreMsgL 5" ) ); |
|
385 CleanupStack::PopAndDestroy(); // bioDB |
|
386 CleanupStack::PushL( description ); |
|
387 } |
|
388 else |
|
389 { |
|
390 FTRACE(RDebug::Print(_L(" CWPMessage::StoreMsgL err (%d)"), err)); |
|
391 CleanupStack::PopAndDestroy(); // bioDB |
|
392 } |
|
393 |
|
394 FLOG( _L( "CWPMessage::StoreMsgL 6" ) ); |
|
395 // Store entry in inbox |
|
396 CMsvEntry* msvEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId ); |
|
397 FLOG( _L( "CWPMessage::StoreMsgL 7" ) ); |
|
398 CleanupStack::PushL(msvEntry); |
|
399 msvEntry->CreateL(entry); |
|
400 msvEntry->Session().CleanupEntryPushL(entry.Id()); |
|
401 msvEntry->SetEntryL(entry.Id()); |
|
402 FLOG( _L( "CWPMessage::StoreMsgL 8" ) ); |
|
403 // Save the message |
|
404 CMsvStore* store = msvEntry->EditStoreL(); |
|
405 CleanupStack::PushL(store); |
|
406 FLOG( _L( "CWPMessage::StoreMsgL 9" ) ); |
|
407 iMessage->StoreL( *store ); |
|
408 store->CommitL(); |
|
409 |
|
410 // Complete processing the message |
|
411 PostprocessEntryL( *msvEntry, entry ); |
|
412 |
|
413 CleanupStack::PopAndDestroy(); //store |
|
414 msvEntry->Session().CleanupEntryPop(); //entry |
|
415 CleanupStack::PopAndDestroy(3); //description, details, msvEntry |
|
416 FLOG( _L( "CWPMessage::StoreMsgL Done" ) ); |
|
417 } |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // CWPMessage::StoreMsgL |
|
421 // ----------------------------------------------------------------------------- |
|
422 // |
|
423 void CWPMessage::StoreMsgL( TInt aResource ) |
|
424 { |
|
425 FLOG( _L( "CWPMessage::StoreMsgL(aResource)" ) ); |
|
426 |
|
427 // create an invisible blank entry |
|
428 TMsvEntry entry; |
|
429 PrepareEntryLC( entry ); // details on cleanup stack |
|
430 entry.iMtm = KUidMsgTypeSMS; |
|
431 |
|
432 // Store entry in inbox |
|
433 CMsvEntry* msvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
434 CleanupStack::PushL(msvEntry); |
|
435 msvEntry->CreateL(entry); |
|
436 msvEntry->Session().CleanupEntryPushL(entry.Id()); |
|
437 msvEntry->SetEntryL(entry.Id()); |
|
438 |
|
439 // Save the message body |
|
440 CMsvStore* store = msvEntry->EditStoreL(); |
|
441 CleanupStack::PushL(store); |
|
442 CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); |
|
443 CleanupStack::PushL( paraFormat ); |
|
444 CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); |
|
445 CleanupStack::PushL( charFormat ); |
|
446 CRichText* body = CRichText::NewL( paraFormat, charFormat ); |
|
447 CleanupStack::PushL( body ); |
|
448 HBufC* text = LoadStringLC( aResource ); |
|
449 body->InsertL( body->DocumentLength(), *text ); |
|
450 store->StoreBodyTextL( *body ); |
|
451 |
|
452 // Store the actual message for post-mortem analysis |
|
453 iMessage->StoreL( *store ); |
|
454 |
|
455 // Save the SMS header and create a description field |
|
456 CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *body ); |
|
457 CleanupStack::PushL( header ); |
|
458 TBuf<KSmsDescriptionLength> description; |
|
459 |
|
460 CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); |
|
461 CleanupStack::PushL( smsPlugin ); |
|
462 smsPlugin->GetDescription( header->Message(), description ); |
|
463 CleanupStack::PopAndDestroy( smsPlugin ); |
|
464 |
|
465 entry.iDescription.Set( description ); |
|
466 header->StoreL( *store ); |
|
467 store->CommitL(); |
|
468 CleanupStack::PopAndDestroy( 5 ); // header, text, body, charformat, paraFormat |
|
469 |
|
470 // Complete processing the message |
|
471 PostprocessEntryL( *msvEntry, entry ); |
|
472 |
|
473 CleanupStack::PopAndDestroy(); //store |
|
474 msvEntry->Session().CleanupEntryPop(); //entry |
|
475 CleanupStack::PopAndDestroy(2); //details, msvEntry |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CWPMessage::StoreMsgclass0L |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 void CWPMessage::StoreMsgclass0L( TInt aResource ) |
|
483 { |
|
484 FLOG( _L( "CWPMessage::StoreMsgL(aResource)" ) ); |
|
485 |
|
486 // create an invisible blank entry |
|
487 TMsvEntry entry; |
|
488 PrepareEntryLC( entry ); // details on cleanup stack |
|
489 entry.iMtm = KUidMsgTypeSMS; |
|
490 |
|
491 // Store entry in inbox |
|
492 CMsvEntry* msvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); |
|
493 CleanupStack::PushL(msvEntry); |
|
494 msvEntry->CreateL(entry); |
|
495 msvEntry->Session().CleanupEntryPushL(entry.Id()); |
|
496 msvEntry->SetEntryL(entry.Id()); |
|
497 |
|
498 // Save the message body |
|
499 CMsvStore* store = msvEntry->EditStoreL(); |
|
500 CleanupStack::PushL(store); |
|
501 CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); |
|
502 CleanupStack::PushL( paraFormat ); |
|
503 CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); |
|
504 CleanupStack::PushL( charFormat ); |
|
505 CRichText* body = CRichText::NewL( paraFormat, charFormat ); |
|
506 CleanupStack::PushL( body ); |
|
507 HBufC* text = LoadStringLC( aResource ); |
|
508 body->InsertL( body->DocumentLength(), *text ); |
|
509 store->StoreBodyTextL( *body ); |
|
510 |
|
511 // Store the actual message for post-mortem analysis |
|
512 iMessage->StoreL( *store ); |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 // Save the SMS header and create a description field |
|
518 CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *body ); |
|
519 |
|
520 |
|
521 CleanupStack::PushL( header ); |
|
522 TBuf<KSmsDescriptionLength> description; |
|
523 |
|
524 |
|
525 //class 0 Implementation |
|
526 CSmsMessage &msg = header->Message(); |
|
527 CSmsPDU &pdu = msg.SmsPDU(); |
|
528 pdu.SetClass(ETrue,TSmsDataCodingScheme::ESmsClass0); |
|
529 |
|
530 CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); |
|
531 CleanupStack::PushL( smsPlugin ); |
|
532 smsPlugin->GetDescription( msg , description ); |
|
533 CleanupStack::PopAndDestroy( smsPlugin ); |
|
534 |
|
535 entry.iDescription.Set( description ); |
|
536 header->StoreL( *store ); |
|
537 store->CommitL(); |
|
538 CleanupStack::PopAndDestroy( 5 ); // header, text, body, charformat, paraFormat |
|
539 |
|
540 // Complete processing the message |
|
541 PostprocessEntryL( *msvEntry, entry ); |
|
542 |
|
543 CleanupStack::PopAndDestroy(); //store |
|
544 msvEntry->Session().CleanupEntryPop(); //entry |
|
545 CleanupStack::PopAndDestroy(2); //details, msvEntry |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // CWPMessage::PrepareEntry |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CWPMessage::PrepareEntryLC( TMsvEntry& aEntry ) |
|
553 { |
|
554 FLOG( _L( "CWPMessage::PrepareEntryLC" ) ); |
|
555 |
|
556 // Current time |
|
557 TTime time; |
|
558 |
|
559 // Get Universal time |
|
560 time.UniversalTime(); |
|
561 |
|
562 FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry" ) ); |
|
563 // create an invisible blank entry |
|
564 aEntry.iType = KUidMsvMessageEntry; |
|
565 aEntry.SetVisible(EFalse); |
|
566 aEntry.SetInPreparation(ETrue); |
|
567 aEntry.SetReadOnly(EFalse); |
|
568 aEntry.SetUnread(ETrue); |
|
569 aEntry.iDate = time; |
|
570 aEntry.iServiceId = KMsvLocalServiceIndexEntryId; |
|
571 aEntry.iError = KErrNone; |
|
572 // iMtmData1 is been used/reserved for count, please don't use for any other purpose. |
|
573 aEntry.SetMtmData1(3); |
|
574 FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) ); |
|
575 // Look up the details |
|
576 HBufC* details = NULL; |
|
577 if( iMessage->Authenticated() ) |
|
578 { |
|
579 FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() true" ) ); |
|
580 details = LoadStringLC( R_FROM_SERVICEPROVIDER ); |
|
581 FLOG( _L( "CWPMessage::PrepareEntryLC LoadString done" ) ); |
|
582 } |
|
583 else |
|
584 { |
|
585 FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() false" ) ); |
|
586 if( iSender ) |
|
587 { |
|
588 FLOG( _L( "CWPMessage::PrepareEntryLC iSender true" ) ); |
|
589 details = HBufC::NewLC( iSender->Length() ); |
|
590 details->Des().Copy( *iSender ); |
|
591 } |
|
592 else |
|
593 { |
|
594 FLOG( _L( "CWPMessage::PrepareEntryLC iSender false" ) ); |
|
595 details = KNullDesC().AllocLC(); |
|
596 } |
|
597 } |
|
598 FLOG( _L( "CWPMessage::PrepareEntryLC iDetails.Set" ) ); |
|
599 aEntry.iDetails.Set( *details ); |
|
600 FLOG( _L( "CWPMessage::PrepareEntryLC Done" ) ); |
|
601 } |
|
602 |
|
603 // ----------------------------------------------------------------------------- |
|
604 // CWPMessage::PostprocessEntryL |
|
605 // ----------------------------------------------------------------------------- |
|
606 // |
|
607 void CWPMessage::PostprocessEntryL( CMsvEntry& aCEntry, TMsvEntry& aTEntry ) |
|
608 { |
|
609 FLOG( _L( "CWPMessage::PostprocessEntryL" ) ); |
|
610 |
|
611 aTEntry.SetReadOnly(EFalse); |
|
612 aTEntry.SetVisible(ETrue); |
|
613 aTEntry.SetInPreparation(EFalse); |
|
614 aCEntry.ChangeL(aTEntry); |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CWPMessage::LoadStringLC |
|
619 // ----------------------------------------------------------------------------- |
|
620 // |
|
621 HBufC* CWPMessage::LoadStringLC( TInt aResourceId ) |
|
622 { |
|
623 FLOG( _L( "CWPMessage::LoadStringLC" ) ); |
|
624 |
|
625 TParse parse; |
|
626 FLOG( _L( "CWPMessage::LoadStringLC2" ) ); |
|
627 parse.Set(KDirAndFile, &KDC_RESOURCE_FILES_DIR, NULL); |
|
628 |
|
629 FLOG( _L( "CWPMessage::LoadStringLC3" ) ); |
|
630 HBufC* result = WPAdapterUtil::ReadHBufCL( parse.FullName(), KResourceName, aResourceId ); |
|
631 CleanupStack::PushL( result ); |
|
632 |
|
633 FLOG( _L( "CWPMessage::LoadStringLC done" ) ); |
|
634 |
|
635 return result; |
|
636 } |
|
637 |
|
638 // End of File |