|
1 /* |
|
2 * Copyright (c) 2008 - 2009 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: handles interface to LIW and Content Publishing Service |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <cmailhandlerplugin.mbg> |
|
19 #include <AknUtils.h> |
|
20 #include <gulicon.h> |
|
21 #include <bautils.h> |
|
22 #include <StringLoader.h> |
|
23 #include <emailwidget.rsg> |
|
24 |
|
25 #include "emailtrace.h" |
|
26 #include "CFSMailClient.h" |
|
27 #include "cmailcpsif.h" |
|
28 #include "cmailcpsifconsts.h" |
|
29 #include "FreestyleEmailUiConstants.h" |
|
30 #include "cmailwidgetcenrepkeysinternal.h" |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CMailCpsIf::NewL |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CMailCpsIf* CMailCpsIf::NewL( CMailCpsHandler* aMailCpsHandler ) |
|
39 { |
|
40 FUNC_LOG; |
|
41 CMailCpsIf* self = new(ELeave) CMailCpsIf( aMailCpsHandler ); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CMailCpsIf::CMailCpsIf |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CMailCpsIf::CMailCpsIf( CMailCpsHandler* aMailCpsHandler ) : |
|
53 iMailCpsHandler( aMailCpsHandler ), |
|
54 iMsgInterface ( NULL ), |
|
55 iIgnoreHsNotifications( EFalse ) |
|
56 { |
|
57 FUNC_LOG; |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // CMailCpsIf::ConstructL |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CMailCpsIf::ConstructL() |
|
65 { |
|
66 FUNC_LOG; |
|
67 for (TInt i=0; i<KMaxMailboxCount; i++) |
|
68 { |
|
69 iAllowedToPublish[i] = EFalse; |
|
70 iInactive[i] = EFalse; |
|
71 } |
|
72 |
|
73 AllocateResourcesL(); |
|
74 iMsgInterface = GetMessagingInterfaceL(); |
|
75 RegisterForObserverL(); |
|
76 PublisherRegisteryActionL(); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CMailCpsIf::~CMailCpsIf |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CMailCpsIf::~CMailCpsIf() |
|
84 { |
|
85 FUNC_LOG; |
|
86 |
|
87 TRAP_IGNORE(UnRegisterForObserverL()); |
|
88 |
|
89 if ( iMsgInterface ) |
|
90 { |
|
91 iMsgInterface->Close(); |
|
92 iMsgInterface = NULL; |
|
93 } |
|
94 delete iServiceHandler; |
|
95 iInstIdList.ResetAndDestroy(); |
|
96 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CMailCpsIf::AllocateResourcesL |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 void CMailCpsIf::AllocateResourcesL() |
|
104 { |
|
105 FUNC_LOG; |
|
106 // create resourcefile |
|
107 CCoeEnv* env = CCoeEnv::Static(); |
|
108 |
|
109 TFileName resourceFile; |
|
110 TParse parse; |
|
111 |
|
112 parse.Set( KResourceFile, &KDC_ECOM_RESOURCE_DIR, NULL ); |
|
113 resourceFile = parse.FullName(); |
|
114 |
|
115 BaflUtils::NearestLanguageFile( env->FsSession(), resourceFile ); |
|
116 iResourceFileOffset = env->AddResourceFileL( resourceFile ); |
|
117 } |
|
118 |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CMailCpsIf::GetMessagingInterfaceL |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 MLiwInterface* CMailCpsIf::GetMessagingInterfaceL() |
|
125 { |
|
126 FUNC_LOG; |
|
127 if ( !iServiceHandler ) |
|
128 { |
|
129 iServiceHandler = CLiwServiceHandler::NewL(); |
|
130 } |
|
131 |
|
132 CLiwGenericParamList* inParam = CLiwGenericParamList::NewL(); |
|
133 CleanupStack::PushL( inParam ); |
|
134 CLiwGenericParamList* outParam = CLiwGenericParamList::NewL(); |
|
135 CleanupStack::PushL( outParam ); |
|
136 CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL( KLiwCmdAsStr, KCPInterface, |
|
137 KCPService ); |
|
138 crit->SetServiceClass( TUid::Uid(KLiwClassBase) ); |
|
139 |
|
140 RCriteriaArray criteriaArray; |
|
141 criteriaArray.AppendL( crit ); |
|
142 |
|
143 iServiceHandler->AttachL( criteriaArray ); |
|
144 iServiceHandler->ExecuteServiceCmdL( *crit, *inParam, *outParam ); |
|
145 |
|
146 delete crit; |
|
147 crit = NULL; |
|
148 criteriaArray.Reset(); |
|
149 |
|
150 // find service interface |
|
151 TInt pos = 0; |
|
152 MLiwInterface* msgInterface = NULL; |
|
153 outParam->FindFirst( pos, KCPInterface ); |
|
154 if ( pos != KErrNotFound ) |
|
155 { |
|
156 msgInterface = (*outParam)[pos].Value().AsInterface(); // indexing should be safe |
|
157 } |
|
158 outParam->Reset(); |
|
159 inParam->Reset(); |
|
160 |
|
161 if( !msgInterface ) |
|
162 { |
|
163 User::Leave( KErrNotFound ); |
|
164 } |
|
165 |
|
166 CleanupStack::PopAndDestroy( outParam ); |
|
167 CleanupStack::PopAndDestroy( inParam ); |
|
168 return msgInterface; |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CMailCpsIf::PublishSetupWizardL |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CMailCpsIf::PublishSetupWizardL(TInt instance) |
|
176 { |
|
177 FUNC_LOG; |
|
178 TFSMailMsgId mailBoxId; |
|
179 TFSMailMsgId folderId; |
|
180 |
|
181 HBufC* setupEmail = StringLoader::LoadLC(R_EMAILWIDGET_TEXT_SETUP_EMAIL); |
|
182 |
|
183 iSetupUid = PublishDescriptorL( |
|
184 KPubId, KContTypeSetupText, |
|
185 iInstIdList[instance]->Des(), |
|
186 *setupEmail, |
|
187 KKeySetupText, KTriggerWizard8, NULL, mailBoxId, folderId); |
|
188 |
|
189 PublishImageL( |
|
190 iInstIdList[instance]->Des(), |
|
191 KContTypeSetupIcon, |
|
192 KKeySetupIcon, |
|
193 EMbmCmailhandlerpluginQgn_prop_cmail_new_mailbox, |
|
194 EMbmCmailhandlerpluginQgn_prop_cmail_new_mailbox_mask, |
|
195 mailBoxId); |
|
196 |
|
197 CleanupStack::PopAndDestroy(setupEmail); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CMailCpsIf::PublishActiveMailboxNameL |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CMailCpsIf::PublishActiveMailboxNameL( |
|
205 const TInt aInstance, |
|
206 const TInt aRowNumber, |
|
207 const TDesC& aMailboxName, |
|
208 const TInt aMailBoxCount, |
|
209 TFSMailMsgId aMailBoxId, |
|
210 TFSMailMsgId aFolderId) |
|
211 { |
|
212 FUNC_LOG; |
|
213 |
|
214 TBuf<KMaxDescLen> row; |
|
215 row.Num(aRowNumber); |
|
216 |
|
217 TBuf<KMaxDescLen> contentType; |
|
218 contentType.Copy(KContTypeBodyText); |
|
219 contentType.Append(row); |
|
220 |
|
221 TBuf<KMaxDescLen> textKey; |
|
222 textKey.Copy(KKeyBodyText); |
|
223 textKey.Append(row); |
|
224 |
|
225 iMailboxNameUid = PublishDescriptorL( |
|
226 KPubId, contentType, |
|
227 iInstIdList[aInstance]->Des(), |
|
228 aMailboxName, |
|
229 textKey, KTriggerEmailUi8, aMailBoxCount, |
|
230 aMailBoxId, aFolderId); |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CMailCpsIf::PublishIndicatorIconL |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 void CMailCpsIf::PublishIndicatorIconL( const TInt aInstance, |
|
238 const TInt aRowNumber, |
|
239 const TInt aIcon ) |
|
240 { |
|
241 FUNC_LOG; |
|
242 TFSMailMsgId mailBoxId; |
|
243 |
|
244 TBuf<KMaxDescLen> row; |
|
245 row.Num(aRowNumber); |
|
246 |
|
247 TBuf<KMaxDescLen> contentType; |
|
248 contentType.Copy(KContTypeIndicatorIcon); |
|
249 contentType.Append(row); |
|
250 |
|
251 TBuf8<KMaxDescLen> row8; |
|
252 row8.Num(aRowNumber); |
|
253 |
|
254 TBuf8<KMaxDescLen> key; |
|
255 key.Copy(KKeyIndicatorIcon); |
|
256 key.Append(row8); |
|
257 |
|
258 PublishImageL( |
|
259 iInstIdList[aInstance]->Des(), |
|
260 contentType, |
|
261 key, |
|
262 aIcon, |
|
263 aIcon + 1, |
|
264 mailBoxId); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CMailCpsIf::PublishMailboxIconL |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 void CMailCpsIf::PublishMailboxIconL( const TInt aInstance, |
|
272 const TInt aRowNumber, |
|
273 const TInt aIcon, |
|
274 TFSMailMsgId aMailBoxId ) |
|
275 { |
|
276 FUNC_LOG; |
|
277 |
|
278 TBuf<KMaxDescLen> row; |
|
279 row.Num(aRowNumber); |
|
280 |
|
281 TBuf<KMaxDescLen> contentType; |
|
282 contentType.Copy(KContTypeMailboxIcons); |
|
283 contentType.Append(row); |
|
284 |
|
285 TBuf8<KMaxDescLen> row8; |
|
286 row8.Num(aRowNumber); |
|
287 |
|
288 TBuf8<KMaxDescLen> key; |
|
289 key.Copy(KKeyMailboxIcons); |
|
290 key.Append(row8); |
|
291 |
|
292 PublishImageL( |
|
293 iInstIdList[aInstance]->Des(), |
|
294 contentType, |
|
295 key, |
|
296 aIcon, |
|
297 aIcon + 1, |
|
298 aMailBoxId); |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------------------------- |
|
302 // CMailCpsIf::PublishMailDetailL |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 void CMailCpsIf::PublishMailDetailL( const TInt aInstance, |
|
306 const TInt aRowNumber, |
|
307 const TDesC& aText, |
|
308 TWidgetMailDetails aDetail) |
|
309 { |
|
310 FUNC_LOG; |
|
311 |
|
312 TBuf<KMaxDescLen> row; |
|
313 row.Num(aRowNumber); |
|
314 |
|
315 TBuf<KMaxDescLen> contentType; |
|
316 if (aDetail == ETime) |
|
317 { |
|
318 contentType.Copy(KContTypeTime); |
|
319 } |
|
320 else |
|
321 { |
|
322 contentType.Copy(KContTypeBodyText); |
|
323 } |
|
324 contentType.Append(row); |
|
325 |
|
326 TBuf<KMaxDescLen> textKey; |
|
327 if (aDetail == ETime) |
|
328 { |
|
329 textKey.Copy(KKeyTime); |
|
330 } |
|
331 else |
|
332 { |
|
333 textKey.Copy(KKeyBodyText); |
|
334 } |
|
335 textKey.Append(row); |
|
336 |
|
337 TFSMailMsgId mailBoxId; |
|
338 TFSMailMsgId folderId; |
|
339 |
|
340 iMailboxNameUid = PublishDescriptorL( |
|
341 KPubId, contentType, |
|
342 iInstIdList[aInstance]->Des(), |
|
343 aText, |
|
344 textKey, KNullDes8, NULL, |
|
345 mailBoxId, folderId); |
|
346 } |
|
347 |
|
348 // --------------------------------------------------------------------------- |
|
349 // CMailCpsIf::ResetMessageL |
|
350 // --------------------------------------------------------------------------- |
|
351 // |
|
352 void CMailCpsIf::ResetMessageL( TInt /*aRowNumber*/ ) |
|
353 { |
|
354 FUNC_LOG; |
|
355 RemoveL( iMsgUid ); |
|
356 iMsgUid = 0; |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // CMailCpsIf::ExtractItemId |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 TUint CMailCpsIf::ExtractItemId( |
|
364 const CLiwGenericParamList& aInParamList ) |
|
365 { |
|
366 FUNC_LOG; |
|
367 TUint result ( 0 ); |
|
368 TInt pos( 0 ); |
|
369 aInParamList.FindFirst( pos, KItemId ); |
|
370 if ( pos != KErrNotFound ) |
|
371 { |
|
372 // item id present - extract and return |
|
373 aInParamList[pos].Value().Get( result ); // indexing should be safe |
|
374 } |
|
375 return result; |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------------------------- |
|
379 // CMailCpsIf::PublishDescriptorL |
|
380 // --------------------------------------------------------------------------- |
|
381 // |
|
382 TUint CMailCpsIf::PublishDescriptorL( |
|
383 const TDesC& aPublisherId, |
|
384 const TDesC& aContentType, |
|
385 const TDesC& aContentId, |
|
386 const TDesC& aTextToAdd, |
|
387 const TDesC& aKey, |
|
388 const TDesC8& aTrigger, |
|
389 const TInt /*aMailBoxCount*/, |
|
390 TFSMailMsgId /*aMailBoxId*/, |
|
391 TFSMailMsgId /*aFolderId*/ ) |
|
392 { |
|
393 FUNC_LOG; |
|
394 |
|
395 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
396 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
397 TUint id(0); |
|
398 TBuf8<KMaxDescLen> key; |
|
399 key.Copy(aKey); |
|
400 if ( iMsgInterface ) |
|
401 { |
|
402 TLiwGenericParam cptype( KType, TLiwVariant( KCpData )); |
|
403 inparam->AppendL( cptype ); |
|
404 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
|
405 CLiwDefaultMap* map = CLiwDefaultMap::NewLC(); |
|
406 map->InsertL( key, TLiwVariant( aTextToAdd ) ); |
|
407 cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId )); |
|
408 cpdatamap->InsertL( KContentType, TLiwVariant( aContentType )); |
|
409 cpdatamap->InsertL( KContentId, TLiwVariant( aContentId )); |
|
410 cpdatamap->InsertL( KDataMap, TLiwVariant( map ) ); |
|
411 |
|
412 if( aTrigger.Length() > 0 ) |
|
413 { |
|
414 CLiwDefaultMap* mapAction = CLiwDefaultMap::NewLC(); |
|
415 CLiwDefaultMap* mapInterface = CLiwDefaultMap::NewLC(); |
|
416 CLiwDefaultMap* mapPlugin = CLiwDefaultMap::NewLC(); |
|
417 mapInterface ->InsertL( KDataForActionHandler, TLiwVariant( mapPlugin ) ); |
|
418 mapAction->InsertL( aTrigger, TLiwVariant( mapInterface ) ); |
|
419 cpdatamap->InsertL( KActionMap, TLiwVariant(mapAction) ); |
|
420 } |
|
421 |
|
422 TLiwGenericParam item( KItem, TLiwVariant( cpdatamap )); |
|
423 inparam->AppendL( item ); |
|
424 |
|
425 // Execute command |
|
426 iMsgInterface->ExecuteCmdL( KAdd , *inparam, *outparam ); |
|
427 |
|
428 id = ExtractItemId(*outparam ); |
|
429 |
|
430 if( aTrigger.Length() > 0 ) |
|
431 { |
|
432 CleanupStack::PopAndDestroy( 3 ); // action |
|
433 } |
|
434 |
|
435 CleanupStack::PopAndDestroy( map ); |
|
436 CleanupStack::PopAndDestroy( cpdatamap ); |
|
437 item.Reset(); |
|
438 cptype.Reset(); |
|
439 } |
|
440 outparam->Reset(); |
|
441 inparam->Reset(); |
|
442 return id; |
|
443 } |
|
444 |
|
445 // --------------------------------------------------------- |
|
446 // CMailCpsIf::PublishImageL |
|
447 // --------------------------------------------------------- |
|
448 // |
|
449 void CMailCpsIf::PublishImageL( |
|
450 const TDesC& aContentId, |
|
451 const TDesC& aContentType, |
|
452 const TDesC8& aKey, |
|
453 TInt aBitmapId, |
|
454 TInt aBitmapMaskId, |
|
455 TFSMailMsgId aMailBoxId ) |
|
456 { |
|
457 FUNC_LOG; |
|
458 |
|
459 TBuf<KMaxDescLen> iconIds(KNullDesC); |
|
460 |
|
461 if ( aBitmapId == EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account ) |
|
462 { |
|
463 // This is mailbox icon. Try finding branded mailbox icon. |
|
464 TInt error(KErrNone); |
|
465 TBuf<KMaxDescLen> brandedIconIds(KNullDesC); |
|
466 |
|
467 MFSMailBrandManager& brandManager = iMailCpsHandler->MailClient().GetBrandManagerL(); |
|
468 TRAPD( err, error = brandManager.GetGraphicIdsL( EFSMailboxIcon, aMailBoxId, brandedIconIds ) ); |
|
469 |
|
470 if ( err == KErrNone && error == KErrNone ) |
|
471 { |
|
472 iconIds.Copy(KMifPrefix); |
|
473 iconIds.Append(brandedIconIds); |
|
474 } |
|
475 } |
|
476 |
|
477 if (!iconIds.Length()) |
|
478 { |
|
479 TBuf<KMaxDescLen> id; |
|
480 iconIds.Copy(KMifPrefix); |
|
481 iconIds.Append(KMifPath); |
|
482 iconIds.Append(KSpace); |
|
483 id.Num(aBitmapId); |
|
484 iconIds.Append(id); |
|
485 iconIds.Append(KSpace); |
|
486 id.Num(aBitmapMaskId); |
|
487 iconIds.Append(id); |
|
488 } |
|
489 |
|
490 // The actual image publishing part starts here |
|
491 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
492 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
493 |
|
494 TLiwGenericParam type( KType, TLiwVariant(KCpData)); |
|
495 inparam->AppendL( type ); |
|
496 |
|
497 CLiwDefaultMap* pdatamap = CLiwDefaultMap::NewLC(); |
|
498 CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC(); |
|
499 |
|
500 pdatamap->InsertL( KPublisherId, TLiwVariant( KPubId )); |
|
501 pdatamap->InsertL( KContentType, TLiwVariant( aContentType )); |
|
502 pdatamap->InsertL( KContentId, TLiwVariant( aContentId )); |
|
503 |
|
504 datamap->InsertL(aKey, TLiwVariant(iconIds)); |
|
505 |
|
506 pdatamap->InsertL( KDataMap, TLiwVariant(datamap) ); |
|
507 TLiwGenericParam item( KItem, TLiwVariant( pdatamap )); |
|
508 inparam->AppendL( item ); |
|
509 |
|
510 // Publish icon ( or remove it from widget when no id provided ) |
|
511 if ( aBitmapId == KNullIcon ) |
|
512 { |
|
513 iMsgInterface->ExecuteCmdL( KDelete, *inparam, *outparam); |
|
514 } |
|
515 else |
|
516 { |
|
517 iMsgInterface->ExecuteCmdL( KAdd, *inparam, *outparam); |
|
518 } |
|
519 |
|
520 CleanupStack::PopAndDestroy( datamap ); |
|
521 CleanupStack::PopAndDestroy( pdatamap ); |
|
522 |
|
523 item.Reset(); |
|
524 type.Reset(); |
|
525 outparam->Reset(); |
|
526 inparam->Reset(); |
|
527 } |
|
528 |
|
529 // --------------------------------------------------------------------------- |
|
530 // CMailCpsIf::RemoveL |
|
531 // --------------------------------------------------------------------------- |
|
532 // |
|
533 void CMailCpsIf::RemoveL( TUint aId ) |
|
534 { |
|
535 FUNC_LOG; |
|
536 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
537 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
538 if ( iMsgInterface ) |
|
539 { |
|
540 TLiwGenericParam cptype( KType, TLiwVariant( KCpData )); |
|
541 inparam->AppendL( cptype ); |
|
542 CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); |
|
543 cpdatamap->InsertL( KId, TLiwVariant( aId )); |
|
544 |
|
545 TLiwGenericParam item( KFilter, TLiwVariant( cpdatamap )); |
|
546 inparam->AppendL( item ); |
|
547 |
|
548 iMsgInterface->ExecuteCmdL( KDelete , *inparam, *outparam); |
|
549 |
|
550 CleanupStack::PopAndDestroy( cpdatamap ); |
|
551 item.Reset(); |
|
552 cptype.Reset(); |
|
553 } |
|
554 outparam->Reset(); |
|
555 inparam->Reset(); |
|
556 } |
|
557 |
|
558 // --------------------------------------------------------------------------- |
|
559 // CMailCpsIf::PublisherRegisteryActionL |
|
560 // --------------------------------------------------------------------------- |
|
561 // |
|
562 void CMailCpsIf::PublisherRegisteryActionL() |
|
563 { |
|
564 FUNC_LOG; |
|
565 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
566 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
567 |
|
568 TLiwGenericParam type( KType, TLiwVariant( KPubData )); |
|
569 inparam->AppendL( type ); |
|
570 |
|
571 CLiwDefaultMap* publishermap = CLiwDefaultMap::NewLC(); |
|
572 |
|
573 // Create the map for publisher registry |
|
574 publishermap->InsertL( KPublisherId, TLiwVariant( KPubId )); |
|
575 publishermap->InsertL( KContentId, TLiwVariant( KCPAll )); |
|
576 publishermap->InsertL( KContentType, TLiwVariant( KCPAll )); |
|
577 |
|
578 // Create the action map for publisher registry |
|
579 CLiwDefaultMap* mapAction = CLiwDefaultMap::NewLC(); |
|
580 mapAction->InsertL(KActive, TLiwVariant( KData )); |
|
581 mapAction->InsertL(KDeActive, TLiwVariant( KData )); |
|
582 mapAction->InsertL(KSuspend, TLiwVariant( KData )); |
|
583 mapAction->InsertL(KResume, TLiwVariant( KData )); |
|
584 mapAction->InsertL(KInactive, TLiwVariant( KData )); |
|
585 |
|
586 publishermap->InsertL( KActionMap, TLiwVariant(mapAction)); |
|
587 CleanupStack::PopAndDestroy(mapAction); |
|
588 |
|
589 TLiwGenericParam item( KItem, TLiwVariant( publishermap )); |
|
590 inparam->AppendL( item ); |
|
591 |
|
592 iMsgInterface->ExecuteCmdL( KAdd, *inparam, *outparam); |
|
593 |
|
594 CleanupStack::PopAndDestroy( publishermap ); |
|
595 |
|
596 item.Reset(); |
|
597 type.Reset(); |
|
598 |
|
599 outparam->Reset(); |
|
600 inparam->Reset(); |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------------------------- |
|
604 // CMailCpsIf::RegisterForObserverL |
|
605 // --------------------------------------------------------------------------- |
|
606 // |
|
607 void CMailCpsIf::RegisterForObserverL() |
|
608 { |
|
609 FUNC_LOG; |
|
610 CLiwGenericParamList* inParamList = &(iServiceHandler->InParamListL()); |
|
611 CLiwGenericParamList* outParamList = &(iServiceHandler->OutParamListL()); |
|
612 |
|
613 CLiwDefaultMap* filter = CLiwDefaultMap::NewLC(); |
|
614 |
|
615 filter->InsertL( KPublisherId, TLiwVariant( KPubId ) ); |
|
616 filter->InsertL( KContentId, TLiwVariant( KCPAll ) ); |
|
617 filter->InsertL( KContentType, TLiwVariant( KCPAll ) ); |
|
618 filter->InsertL( KOperation, TLiwVariant( KExecute )); |
|
619 |
|
620 // Fill in input list for RequestNotification command |
|
621 inParamList->AppendL(TLiwGenericParam(KType,TLiwVariant( KContentAndPublisher_Registry ))); |
|
622 inParamList->AppendL(TLiwGenericParam(KFilter ,TLiwVariant( filter ))); |
|
623 |
|
624 TInt errori(KErrNone); |
|
625 TRAP(errori, iMsgInterface->ExecuteCmdL( KRequestNotification, *inParamList, |
|
626 *outParamList, 0, this )); |
|
627 |
|
628 CleanupStack::PopAndDestroy( filter ); |
|
629 outParamList->Reset(); |
|
630 inParamList->Reset(); |
|
631 } |
|
632 |
|
633 // --------------------------------------------------------------------------- |
|
634 // CMailCpsIf::UnRegisterForObserverL |
|
635 // --------------------------------------------------------------------------- |
|
636 // |
|
637 void CMailCpsIf::UnRegisterForObserverL() |
|
638 { |
|
639 FUNC_LOG; |
|
640 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
641 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
642 // Un Register for notification |
|
643 |
|
644 TInt err; |
|
645 err = KErrNone; |
|
646 |
|
647 // Un Register all the reuqest notification registered in this session |
|
648 TRAP( err, iMsgInterface->ExecuteCmdL( |
|
649 KRequestNotification, |
|
650 *inparam, |
|
651 *outparam, |
|
652 KLiwOptCancel, |
|
653 this ) ); |
|
654 |
|
655 outparam->Reset(); |
|
656 inparam->Reset(); |
|
657 } |
|
658 |
|
659 // --------------------------------------------------------------------------- |
|
660 // Notification handling |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 TInt CMailCpsIf::HandleNotifyL( |
|
664 TInt aErrorCode, |
|
665 TInt /*aEventId*/, |
|
666 CLiwGenericParamList& aEventParamList, |
|
667 const CLiwGenericParamList& /*aInParamList*/ ) |
|
668 { |
|
669 FUNC_LOG; |
|
670 PublisherStatusL ( aEventParamList); |
|
671 return aErrorCode; |
|
672 } |
|
673 |
|
674 // --------------------------------------------------------------------------- |
|
675 // Check if Publisher was activeated or deactivated |
|
676 // --------------------------------------------------------------------------- |
|
677 // |
|
678 TBool CMailCpsIf::PublisherStatusL(const CLiwGenericParamList& aEventParamList) |
|
679 { |
|
680 FUNC_LOG; |
|
681 TBool result(EFalse); |
|
682 TInt pos(0); |
|
683 const TInt KSAPIContentNameMaxLength = 255; |
|
684 TBuf<300> text; |
|
685 aEventParamList.FindFirst(pos, KChangeInfo); |
|
686 if (pos != KErrNotFound) |
|
687 { |
|
688 // Get list of maps |
|
689 TLiwVariant variant = (aEventParamList)[pos].Value(); |
|
690 variant.PushL(); |
|
691 const CLiwList* changeMapsList = variant.AsList(); |
|
692 |
|
693 TBuf<KSAPIContentNameMaxLength> contentid; |
|
694 TBuf<KSAPIContentNameMaxLength> operation; |
|
695 TBuf<KSAPIContentNameMaxLength> trigger; |
|
696 |
|
697 // Iter through list content |
|
698 |
|
699 TInt mapslistcount (changeMapsList->Count()); |
|
700 |
|
701 for (TInt i = 0; i < changeMapsList->Count(); ++i) |
|
702 { |
|
703 if ( changeMapsList->AtL(i, variant) ) |
|
704 { |
|
705 const CLiwMap* map = variant.AsMap(); |
|
706 |
|
707 // Check what triggered a notification |
|
708 if ( map->FindL(KOperation, variant) ) |
|
709 { |
|
710 variant.Get(operation); |
|
711 variant.Reset(); |
|
712 if( map->FindL( KContentId, variant) ) |
|
713 { |
|
714 variant.Get(contentid ); |
|
715 variant.Reset(); |
|
716 if( map->FindL( KActionTrigger, variant) ) |
|
717 { |
|
718 variant.Get(trigger ); |
|
719 } |
|
720 if (trigger.Compare(KInactive16) == 0) |
|
721 { |
|
722 // Homescreen page is about to change. |
|
723 // Ignore next deactivate event of this particular widget instance. |
|
724 HBufC* cid = contentid.AllocLC(); |
|
725 TInt widgetInstance = FindWidgetInstanceId(cid->Des()); |
|
726 iInactive[widgetInstance] = ETrue; |
|
727 CleanupStack::PopAndDestroy( cid ); |
|
728 } |
|
729 else if (trigger.Compare(KSuspend16) == 0) |
|
730 { |
|
731 // Publishing to homescreen suspended. |
|
732 HBufC* cid = contentid.AllocLC(); |
|
733 TInt widgetInstance = FindWidgetInstanceId(cid->Des()); |
|
734 iAllowedToPublish[widgetInstance] = EFalse; |
|
735 CleanupStack::PopAndDestroy( cid ); |
|
736 } |
|
737 else if (trigger.Compare(KResume16) == 0) |
|
738 { |
|
739 HBufC* cid = contentid.AllocLC(); |
|
740 if ( FindWidgetInstanceId(cid->Des()) < 0 ) |
|
741 { |
|
742 iInstIdList.AppendL( contentid.AllocL() ); |
|
743 } |
|
744 TInt widgetInstance = FindWidgetInstanceId(cid->Des()); |
|
745 PublishSetupWizardL(widgetInstance); |
|
746 iMailCpsHandler->UpdateMailboxesL(widgetInstance, cid->Des()); |
|
747 // Widget visible on the homescreen. Publishing allowed. |
|
748 iAllowedToPublish[widgetInstance] = ETrue; |
|
749 iInactive[widgetInstance] = EFalse; |
|
750 CleanupStack::PopAndDestroy( cid ); |
|
751 } |
|
752 else if (trigger.Compare(KActive16) == 0) |
|
753 { |
|
754 // Widget added to homescreen (or already on the screen when boot completes). |
|
755 HBufC* cid = contentid.AllocLC(); |
|
756 TInt widgetInstance = FindWidgetInstanceId(cid->Des()); |
|
757 if (iInactive[widgetInstance]) |
|
758 { |
|
759 iInactive[widgetInstance] = EFalse; |
|
760 } |
|
761 else |
|
762 { |
|
763 iInstIdList.AppendL( contentid.AllocL() ); |
|
764 } |
|
765 /* if (!alreadyAssociated) |
|
766 { |
|
767 iMailCpsHandler->LaunchWidgetSettingsL(cid->Des()); |
|
768 }*/ |
|
769 CleanupStack::PopAndDestroy( cid ); |
|
770 } |
|
771 else if (trigger.Compare(KDeActive16) == 0) |
|
772 { |
|
773 // Widget removed from homescreen. |
|
774 HBufC* cid = contentid.AllocLC(); |
|
775 TInt widgetInstance = FindWidgetInstanceId(cid->Des()); |
|
776 if (!iInactive[widgetInstance]) |
|
777 { |
|
778 iMailCpsHandler->DissociateWidgetFromSetting( cid->Des() ); |
|
779 iInstIdList.Remove(widgetInstance); |
|
780 } |
|
781 iAllowedToPublish[widgetInstance] = EFalse; |
|
782 CleanupStack::PopAndDestroy( cid ); |
|
783 } |
|
784 else if (trigger.Compare(KTriggerEmailUi) == 0) |
|
785 { |
|
786 HBufC* cid = contentid.AllocLC(); |
|
787 iMailCpsHandler->LaunchEmailUIL(cid->Des()); |
|
788 CleanupStack::PopAndDestroy( cid ); |
|
789 } |
|
790 else if ((trigger.Compare(KTriggerWizard) == 0) || |
|
791 ( trigger.Compare(KSettings16) == 0)) |
|
792 { |
|
793 // If no accounts are created launch email wizard |
|
794 // otherwice launch widget settings app |
|
795 if (iMailCpsHandler->GetMailboxCount()) |
|
796 { |
|
797 HBufC* cid = contentid.AllocLC(); |
|
798 iMailCpsHandler->LaunchWidgetSettingsL(cid->Des()); |
|
799 CleanupStack::PopAndDestroy( cid ); |
|
800 } |
|
801 else |
|
802 { |
|
803 iMailCpsHandler->LaunchEmailWizardL(); |
|
804 } |
|
805 } |
|
806 } |
|
807 } |
|
808 } |
|
809 } |
|
810 CleanupStack::PopAndDestroy(1); |
|
811 } |
|
812 return result; |
|
813 } |
|
814 |
|
815 // --------------------------------------------------------------------------- |
|
816 // CMailCpsIf::AllowedToPublish |
|
817 // --------------------------------------------------------------------------- |
|
818 // |
|
819 TBool CMailCpsIf::AllowedToPublish( TInt aWidgetInstance ) |
|
820 { |
|
821 FUNC_LOG; |
|
822 if ( !iAllowedToPublish[aWidgetInstance] && !iIgnoreHsNotifications ) |
|
823 { |
|
824 return EFalse; |
|
825 } |
|
826 else |
|
827 { |
|
828 return ETrue; |
|
829 } |
|
830 } |
|
831 |
|
832 // --------------------------------------------------------------------------- |
|
833 // CMailCpsIf::SetConfiguration |
|
834 // --------------------------------------------------------------------------- |
|
835 // |
|
836 void CMailCpsIf::SetConfiguration( const TInt32 aConfigData ) |
|
837 { |
|
838 FUNC_LOG; |
|
839 iIgnoreHsNotifications = aConfigData & KCMailIgnoreHsEvents; |
|
840 } |
|
841 |
|
842 // --------------------------------------------------------------------------- |
|
843 // CMailCpsIf::GetWidgetInstanceCount |
|
844 // --------------------------------------------------------------------------- |
|
845 // |
|
846 TInt CMailCpsIf::GetWidgetInstanceCount() |
|
847 { |
|
848 FUNC_LOG; |
|
849 return iInstIdList.Count(); |
|
850 } |
|
851 |
|
852 |
|
853 // --------------------------------------------------------------------------- |
|
854 // CMailCpsIf::FindWidgetInstanceId |
|
855 // --------------------------------------------------------------------------- |
|
856 // |
|
857 TInt CMailCpsIf::FindWidgetInstanceId( const TDesC& aContentId ) |
|
858 { |
|
859 FUNC_LOG; |
|
860 TInt instance(KErrNotFound); |
|
861 for (TInt i = 0; i < iInstIdList.Count(); i++) |
|
862 { |
|
863 TInt val = aContentId.Compare(iInstIdList[i]->Des()); |
|
864 if (!val) |
|
865 { |
|
866 instance = i; |
|
867 break; |
|
868 } |
|
869 } |
|
870 return instance; |
|
871 } |
|
872 |