|
1 /* |
|
2 * Copyright (c) 2008 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: Encapsulates hsps liw service |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <liwservicehandler.h> |
|
21 #include <liwvariant.h> |
|
22 #include <bamdesca.h> |
|
23 |
|
24 #include <hspluginsettings.h> |
|
25 #include "hspsconfiguration.h" |
|
26 #include "itemmap.h" |
|
27 #include "propertymap.h" |
|
28 #include <mhomescreensettingsif.h> |
|
29 #include <mhomescreensettingsobserver.h> |
|
30 |
|
31 _LIT8( KHSPS, "Service.HSPS" ); |
|
32 _LIT8( KHSPSConfigurationIf, "IConfiguration" ); |
|
33 |
|
34 _LIT8( KHSPSCommandGetPluginConf, "GetPluginConf" ); |
|
35 _LIT8( KHSPSSetPluginSettings, "SetPluginSettings" ); |
|
36 _LIT8( KPluginConfKey, "pluginConf" ); |
|
37 |
|
38 _LIT8( KOutKeyStatus ,"status"); |
|
39 _LIT8( KHspsAppUid, "appUid" ); |
|
40 _LIT8( KKeyPluginId, "pluginId" ); |
|
41 |
|
42 _LIT8( KKeyStoringParams, "storingParams" ); |
|
43 |
|
44 _LIT8( KKeyStorePluginRefence, "storePluginConf" ); |
|
45 _LIT8( KKeyStoreAppConf, "storeAppConf" ); |
|
46 |
|
47 _LIT8( KKeyItemId, "itemId" ); |
|
48 _LIT8( KKeyName, "name" ); |
|
49 _LIT8( KKeyValue, "value" ); |
|
50 _LIT8( KKeyProperties, "properties" ); |
|
51 _LIT8( KKeySettings, "settings" ); |
|
52 |
|
53 _LIT8( KRequestNotification, "RequestNotification" ); |
|
54 |
|
55 _LIT8( KSettingsChanged, "PluginSettingsChanged" ); |
|
56 |
|
57 namespace HSPluginSettingsIf{ |
|
58 |
|
59 NONSHARABLE_CLASS( CTlsEntry ): public CBase |
|
60 { |
|
61 public: |
|
62 /** |
|
63 * Instance to home screen settings. |
|
64 */ |
|
65 CHomescreenSettings* iInstance; |
|
66 |
|
67 /** |
|
68 * Reference count. |
|
69 */ |
|
70 TInt iRefCount; |
|
71 }; |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C CHomescreenSettings* CHomescreenSettings::Instance() |
|
77 { |
|
78 CHomescreenSettings* instance = NULL; |
|
79 |
|
80 CTlsEntry* entry = static_cast<CTlsEntry*>( Dll::Tls() ); |
|
81 if( entry ) |
|
82 { |
|
83 instance = entry->iInstance; |
|
84 } |
|
85 |
|
86 return instance; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C void CHomescreenSettings::InitializeL( const TDesC8& aAppUid ) |
|
93 { |
|
94 CTlsEntry* entry = static_cast<CTlsEntry*>( Dll::Tls() ); |
|
95 |
|
96 if( !entry ) |
|
97 { |
|
98 entry = new (ELeave) CTlsEntry(); |
|
99 entry->iInstance = NULL; |
|
100 entry->iRefCount = 1; |
|
101 |
|
102 CleanupStack::PushL( entry ); |
|
103 entry->iInstance = CHomescreenSettings::NewL( aAppUid ); |
|
104 CleanupStack::Pop( entry ); |
|
105 |
|
106 Dll::SetTls( entry ); |
|
107 } |
|
108 else |
|
109 { |
|
110 entry->iRefCount++; |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C void CHomescreenSettings::UnInitialize() |
|
118 { |
|
119 CTlsEntry* entry = static_cast<CTlsEntry*>( Dll::Tls() ); |
|
120 |
|
121 if( !entry ) |
|
122 { |
|
123 return; |
|
124 } |
|
125 |
|
126 entry->iRefCount--; |
|
127 |
|
128 if( entry->iRefCount == 0 ) |
|
129 { |
|
130 delete entry->iInstance; |
|
131 entry->iInstance = NULL; |
|
132 delete entry; |
|
133 Dll::SetTls( NULL ); |
|
134 } |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C void CHomescreenSettings::AddObserverL( MHomeScreenSettingsObserver* aObserver ) |
|
141 { |
|
142 if( iObservers.Find( aObserver ) == KErrNotFound ) |
|
143 { |
|
144 iObservers.AppendL( aObserver ); |
|
145 } |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void CHomescreenSettings::RemoveObserver( MHomeScreenSettingsObserver* aObserver ) |
|
152 { |
|
153 const TInt index = iObservers.Find( aObserver ); |
|
154 if( index != KErrNotFound ) |
|
155 { |
|
156 iObservers.Remove( index ); |
|
157 } |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CHomescreenSettings::CHomescreenSettings() |
|
164 { |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 void CHomescreenSettings::ConstructL( const TDesC8& aAppUid ) |
|
171 { |
|
172 // Attach to HSPS: |
|
173 iServiceHandler = CLiwServiceHandler::NewL(); |
|
174 |
|
175 iHspsService = CLiwCriteriaItem::NewL( 1, KHSPSConfigurationIf, KHSPS ); |
|
176 iHspsService->SetServiceClass( TUid::Uid( KLiwClassBase ) ); |
|
177 |
|
178 RCriteriaArray interestList; |
|
179 interestList.AppendL( iHspsService ); |
|
180 iServiceHandler->AttachL( interestList ); |
|
181 interestList.Reset(); |
|
182 |
|
183 CLiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
184 CLiwGenericParamList& outParamList = iServiceHandler->OutParamListL(); |
|
185 |
|
186 TLiwGenericParam appUid; |
|
187 TLiwVariant uidVar; |
|
188 uidVar.Set( aAppUid ); |
|
189 appUid.SetNameAndValueL( KHspsAppUid, uidVar ); |
|
190 appUid.PushL(); |
|
191 inParamList.AppendL( appUid ); |
|
192 CleanupStack::Pop(); |
|
193 appUid.Reset(); |
|
194 |
|
195 iServiceHandler->ExecuteServiceCmdL( *iHspsService,inParamList,outParamList ); |
|
196 inParamList.Reset(); |
|
197 TInt pos = 0; |
|
198 outParamList.FindFirst( pos, KHSPSConfigurationIf ); |
|
199 if( pos != KErrNotFound ) |
|
200 { |
|
201 iHspsInterface = outParamList[ pos ].Value().AsInterface(); |
|
202 outParamList.Reset(); |
|
203 } |
|
204 else |
|
205 { |
|
206 outParamList.Reset(); |
|
207 User::Leave( KErrNotFound ); |
|
208 } |
|
209 |
|
210 inParamList.Reset(); |
|
211 outParamList.Reset(); |
|
212 |
|
213 iTransactionId = -1; |
|
214 iHspsInterface->ExecuteCmdL( KRequestNotification, |
|
215 inParamList, |
|
216 outParamList, |
|
217 KLiwOptASyncronous, |
|
218 this ); |
|
219 |
|
220 const TLiwGenericParam* outParam( NULL ); |
|
221 |
|
222 pos = 0; |
|
223 outParam = outParamList.FindFirst( pos, _L8("status") ); |
|
224 |
|
225 if( outParam ) |
|
226 { |
|
227 TInt retval; |
|
228 retval = outParam->Value().AsTInt32(); |
|
229 if( retval == KErrNone ) |
|
230 { |
|
231 pos = 0; |
|
232 outParam = outParamList.FindFirst( pos, _L8( "TransactionID" ) ); |
|
233 if( outParam ) |
|
234 { |
|
235 retval = outParam->Value().AsTInt32(); |
|
236 iTransactionId = retval; |
|
237 } |
|
238 } |
|
239 } |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 CHomescreenSettings* CHomescreenSettings::NewL( |
|
246 const TDesC8& aAppUid ) |
|
247 { |
|
248 CHomescreenSettings* self = CHomescreenSettings::NewLC( aAppUid ); |
|
249 CleanupStack::Pop( self ); |
|
250 return self; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 CHomescreenSettings* CHomescreenSettings::NewLC( |
|
257 const TDesC8& aAppUid ) |
|
258 { |
|
259 CHomescreenSettings* self = new( ELeave ) CHomescreenSettings(); |
|
260 CleanupStack::PushL( self ); |
|
261 self->ConstructL( aAppUid ); |
|
262 |
|
263 return self; |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------------------------- |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 CHomescreenSettings::~CHomescreenSettings() |
|
270 { |
|
271 iObservers.Reset(); |
|
272 |
|
273 if( iHspsInterface ) |
|
274 { |
|
275 // Close interface |
|
276 iHspsInterface->Close(); |
|
277 } |
|
278 |
|
279 if( iServiceHandler && iHspsService ) |
|
280 { |
|
281 // Detach services from the handler |
|
282 RCriteriaArray interestList; |
|
283 TRAP_IGNORE( interestList.AppendL( iHspsService ) ); |
|
284 TRAP_IGNORE( iServiceHandler->DetachL( interestList ) ); |
|
285 interestList.Reset(); |
|
286 } |
|
287 |
|
288 delete iHspsService; |
|
289 delete iServiceHandler; |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 TInt CHomescreenSettings::SetPluginSettingsL( |
|
296 const TDesC8& aPluginId, |
|
297 const RPointerArray<CItemMap>& aSettings, |
|
298 const TDesC8& aStoringParam ) |
|
299 { |
|
300 // Compose AddPlugin hsps LIW message to Service.HomeScreenPluginConfiguration |
|
301 CLiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
302 CLiwGenericParamList& outParamList = iServiceHandler->OutParamListL(); |
|
303 |
|
304 TLiwGenericParam pluginIdParam; |
|
305 pluginIdParam.SetNameAndValueL( KKeyPluginId, TLiwVariant(aPluginId) ); |
|
306 pluginIdParam.PushL(); |
|
307 inParamList.AppendL( pluginIdParam ); |
|
308 CleanupStack::Pop( &pluginIdParam ); |
|
309 pluginIdParam.Reset(); |
|
310 |
|
311 CLiwDefaultList* itemMapList = CLiwDefaultList::NewLC(); |
|
312 for( int i = 0; i < aSettings.Count(); i++ ) |
|
313 { |
|
314 CItemMap* itemMap = aSettings[i]; |
|
315 |
|
316 CLiwDefaultMap* inItemMap = CLiwDefaultMap::NewLC(); |
|
317 FillMapFromItemL(*inItemMap,*itemMap); |
|
318 itemMapList->AppendL( TLiwVariant(inItemMap) ); |
|
319 CleanupStack::Pop(inItemMap); |
|
320 inItemMap->Close(); |
|
321 } |
|
322 |
|
323 TLiwGenericParam settingsParam; |
|
324 settingsParam.SetNameAndValueL( KKeySettings, TLiwVariant(itemMapList) ); |
|
325 settingsParam.PushL(); |
|
326 inParamList.AppendL( settingsParam ); |
|
327 CleanupStack::Pop( &settingsParam ); |
|
328 settingsParam.Reset(); |
|
329 |
|
330 TLiwGenericParam storingParams; |
|
331 storingParams.SetNameAndValueL( KKeyStoringParams, TLiwVariant(aStoringParam) ); |
|
332 storingParams.PushL(); |
|
333 inParamList.AppendL( storingParams ); |
|
334 CleanupStack::Pop( &storingParams ); |
|
335 storingParams.Reset(); |
|
336 |
|
337 iHspsInterface->ExecuteCmdL( KHSPSSetPluginSettings, |
|
338 inParamList, |
|
339 outParamList ); |
|
340 |
|
341 CleanupStack::PopAndDestroy( itemMapList ); |
|
342 |
|
343 inParamList.Reset(); |
|
344 |
|
345 |
|
346 // check success |
|
347 const TLiwGenericParam* outParam = NULL; |
|
348 TInt pos(0); |
|
349 outParam = outParamList.FindFirst( pos, KOutKeyStatus ); |
|
350 TInt status(KErrGeneral); |
|
351 |
|
352 if ( outParam ) |
|
353 { |
|
354 status = outParam->Value().AsTInt32(); |
|
355 } |
|
356 outParamList.Reset(); |
|
357 return status; |
|
358 } |
|
359 // --------------------------------------------------------------------------- |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 EXPORT_C TInt CHomescreenSettings::SetSettingsL( |
|
363 const TDesC8& aPluginId, |
|
364 const RPointerArray<CItemMap>& aSettings, |
|
365 const TBool aStoringParams) |
|
366 { |
|
367 TInt error = KErrNone; |
|
368 |
|
369 if( aStoringParams ) |
|
370 { |
|
371 error = SetPluginSettingsL(aPluginId, aSettings, KKeyStorePluginRefence()); |
|
372 } |
|
373 else |
|
374 { |
|
375 error = SetPluginSettingsL(aPluginId, aSettings, KKeyStoreAppConf()); |
|
376 } |
|
377 |
|
378 return error; |
|
379 } |
|
380 // --------------------------------------------------------------------------- |
|
381 // --------------------------------------------------------------------------- |
|
382 // |
|
383 EXPORT_C TInt CHomescreenSettings::GetSettingsL( |
|
384 const TDesC8& aPluginId, |
|
385 RPointerArray<CItemMap>& aSettings) |
|
386 { |
|
387 TInt error = KErrNone; |
|
388 CHspsConfiguration* configuration = CHspsConfiguration::NewLC(); |
|
389 |
|
390 // Compose AddPlugin hsps LIW message to Service.HomeScreenPluginConfiguration |
|
391 CLiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
392 CLiwGenericParamList& outParamList = iServiceHandler->OutParamListL(); |
|
393 |
|
394 TLiwGenericParam pluginIdParam; |
|
395 pluginIdParam.SetNameAndValueL( KKeyPluginId, TLiwVariant(aPluginId) ); |
|
396 pluginIdParam.PushL(); |
|
397 inParamList.AppendL( pluginIdParam ); |
|
398 CleanupStack::Pop( &pluginIdParam ); |
|
399 pluginIdParam.Reset(); |
|
400 |
|
401 |
|
402 iHspsInterface->ExecuteCmdL( KHSPSCommandGetPluginConf, |
|
403 inParamList, |
|
404 outParamList ); |
|
405 |
|
406 inParamList.Reset(); |
|
407 |
|
408 TInt index(0); |
|
409 const TLiwGenericParam* conf = outParamList.FindFirst(index,KPluginConfKey); |
|
410 |
|
411 if(conf) |
|
412 { |
|
413 const CLiwMap* confMap = conf->Value().AsMap(); |
|
414 // 2: Process Configuration map |
|
415 if(confMap) |
|
416 { |
|
417 TLiwVariant tempVariant; |
|
418 tempVariant.PushL(); |
|
419 |
|
420 if( confMap->FindL( _L8("settings"), tempVariant )) |
|
421 { |
|
422 const CLiwList* settings_list( tempVariant.AsList() ); |
|
423 if( settings_list ) |
|
424 { |
|
425 aSettings.Reset(); |
|
426 ProcessConfigurationSettingsL(*settings_list,*configuration); |
|
427 RPointerArray<CItemMap>& settings = configuration->Settings(); |
|
428 CItemMap* itemMapIn(0); |
|
429 CPropertyMap* readProperty(0); |
|
430 CPropertyMap* propertyIn(0); |
|
431 |
|
432 for( TInt i = 0; i < settings.Count(); i++ ) |
|
433 { |
|
434 CItemMap* readItem = settings[i]; |
|
435 itemMapIn = CItemMap::NewLC(); |
|
436 itemMapIn->SetItemIdL(readItem->ItemId()); |
|
437 const TDesC8& itemName = readItem->ItemName(); |
|
438 itemMapIn->SetItemNameL(itemName); |
|
439 |
|
440 RPointerArray<CPropertyMap>& readProperties = readItem->Properties(); |
|
441 |
|
442 for( TInt j=0; j < readProperties.Count(); j++ ) |
|
443 { |
|
444 readProperty = readProperties[j]; |
|
445 propertyIn = CPropertyMap::NewLC(); |
|
446 propertyIn->SetNameL(readProperty->Name()); |
|
447 propertyIn->SetValueL(readProperty->Value()); |
|
448 // Dispatching is based on item name |
|
449 itemMapIn->AddPropertyMapL(propertyIn); |
|
450 CleanupStack::Pop(propertyIn); |
|
451 } |
|
452 |
|
453 aSettings.AppendL(itemMapIn); |
|
454 |
|
455 CleanupStack::Pop(itemMapIn); |
|
456 } |
|
457 } |
|
458 else |
|
459 { |
|
460 error=KErrNotFound; |
|
461 } |
|
462 } |
|
463 else |
|
464 { |
|
465 error= KErrNotFound; |
|
466 } |
|
467 |
|
468 |
|
469 CleanupStack::Pop(&tempVariant); |
|
470 tempVariant.Reset(); |
|
471 } |
|
472 } |
|
473 |
|
474 outParamList.Reset(); |
|
475 CleanupStack::PopAndDestroy(configuration); |
|
476 |
|
477 return error; |
|
478 } |
|
479 |
|
480 |
|
481 |
|
482 // --------------------------------------------------------------------------- |
|
483 // --------------------------------------------------------------------------- |
|
484 // |
|
485 void CHomescreenSettings::ProcessConfigurationSettingsL( |
|
486 const CLiwList& aItemList, |
|
487 CHspsConfiguration& aTarget) |
|
488 { |
|
489 TLiwVariant itemMapVariant; |
|
490 itemMapVariant.PushL(); |
|
491 for( int i=0;i<aItemList.Count();++i ) |
|
492 { |
|
493 if( aItemList.AtL(i,itemMapVariant) ) |
|
494 { |
|
495 const CLiwMap* itemMap( itemMapVariant.AsMap() ); |
|
496 TLiwVariant itemVariant; |
|
497 itemVariant.PushL(); |
|
498 if( itemMap ) |
|
499 { |
|
500 CItemMap* item = CItemMap::NewLC(); |
|
501 if( itemMap->FindL( _L8("itemId"),itemVariant) ) |
|
502 { |
|
503 item->SetItemIdL( itemVariant.AsData() ); |
|
504 } |
|
505 if( itemMap->FindL( _L8("name"),itemVariant) ) |
|
506 { |
|
507 item->SetItemNameL( itemVariant.AsData() ); |
|
508 } |
|
509 if( itemMap->FindL( _L8("properties"),itemVariant) ) |
|
510 { |
|
511 const CLiwList* properties( itemVariant.AsList() ); |
|
512 if(properties) |
|
513 { |
|
514 ProcessConfItemPropertiesL(*properties,*item); |
|
515 } |
|
516 } |
|
517 |
|
518 aTarget.AddItemMapL(item); |
|
519 CleanupStack::Pop(item); |
|
520 } |
|
521 CleanupStack::Pop(&itemVariant); |
|
522 itemVariant.Reset(); |
|
523 } |
|
524 |
|
525 } |
|
526 CleanupStack::Pop(&itemMapVariant); |
|
527 itemMapVariant.Reset(); |
|
528 } |
|
529 |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // --------------------------------------------------------------------------- |
|
533 // |
|
534 void CHomescreenSettings::ProcessConfItemPropertiesL( |
|
535 const CLiwList& aPropertyMapList, |
|
536 CItemMap& aItemMap) |
|
537 { |
|
538 TLiwVariant propertyMapVariant; |
|
539 propertyMapVariant.PushL(); |
|
540 for( int i=0;i<aPropertyMapList.Count();++i ) |
|
541 { |
|
542 if( aPropertyMapList.AtL(i,propertyMapVariant) ) |
|
543 { |
|
544 const CLiwMap* propertyMap( propertyMapVariant.AsMap() ); |
|
545 TLiwVariant propertyVariant; |
|
546 propertyVariant.PushL(); |
|
547 if( propertyMap ) |
|
548 { |
|
549 CPropertyMap* property = CPropertyMap::NewLC(); |
|
550 if( propertyMap->FindL( _L8("name"),propertyVariant ) ) |
|
551 { |
|
552 property->SetNameL( propertyVariant.AsData() ); |
|
553 } |
|
554 if( propertyMap->FindL( _L8("value"),propertyVariant ) ) |
|
555 { |
|
556 property->SetValueL( propertyVariant.AsData() ); |
|
557 } |
|
558 aItemMap.AddPropertyMapL(property); |
|
559 CleanupStack::Pop(property); |
|
560 } |
|
561 CleanupStack::Pop(&propertyVariant); |
|
562 propertyVariant.Reset(); |
|
563 } |
|
564 |
|
565 } |
|
566 CleanupStack::Pop(&propertyMapVariant); |
|
567 propertyMapVariant.Reset(); |
|
568 } |
|
569 |
|
570 |
|
571 |
|
572 // --------------------------------------------------------------------------- |
|
573 // --------------------------------------------------------------------------- |
|
574 // |
|
575 void CHomescreenSettings::FillMapFromItemL( CLiwDefaultMap& aMap, const CItemMap& aItemMap ) |
|
576 { |
|
577 aMap.InsertL( KKeyItemId, TLiwVariant(aItemMap.ItemId()) ); |
|
578 aMap.InsertL( KKeyName, TLiwVariant(aItemMap.ItemName()) ); |
|
579 |
|
580 CLiwDefaultList* inPropertyMapList = CLiwDefaultList::NewLC(); |
|
581 FillMapFromPropertiesL(*inPropertyMapList,aItemMap.Properties()); |
|
582 aMap.InsertL( KKeyProperties, TLiwVariant(inPropertyMapList) ); |
|
583 CleanupStack::Pop(inPropertyMapList); |
|
584 inPropertyMapList->Close(); |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // --------------------------------------------------------------------------- |
|
589 // |
|
590 void CHomescreenSettings::FillMapFromPropertiesL( |
|
591 CLiwDefaultList& aInPropertyMapList, |
|
592 const RPointerArray<CPropertyMap>& aProperties ) |
|
593 { |
|
594 |
|
595 for(int i=0; i<aProperties.Count(); ++i) |
|
596 { |
|
597 CLiwDefaultMap* inPropertyMap = CLiwDefaultMap::NewLC(); |
|
598 inPropertyMap->InsertL( KKeyName, TLiwVariant(aProperties[i]->Name()) ); |
|
599 inPropertyMap->InsertL( KKeyValue, TLiwVariant(aProperties[i]->Value()) ); |
|
600 aInPropertyMapList.AppendL(inPropertyMap); |
|
601 CleanupStack::Pop(inPropertyMap); |
|
602 inPropertyMap->Close(); |
|
603 } |
|
604 } |
|
605 |
|
606 // --------------------------------------------------------------------------- |
|
607 // --------------------------------------------------------------------------- |
|
608 // |
|
609 TInt CHomescreenSettings::HandleNotifyL( TInt aCmdId, TInt aEventId, |
|
610 CLiwGenericParamList& aEventParamList, |
|
611 const CLiwGenericParamList& /*aInParamList*/ ) |
|
612 { |
|
613 TInt retval( KErrNone ); |
|
614 |
|
615 if( iTransactionId == aCmdId && iObservers.Count() > 0 ) |
|
616 { |
|
617 const TLiwGenericParam* outParam( NULL ); |
|
618 |
|
619 TInt pos( 0 ); |
|
620 outParam = aEventParamList.FindFirst( pos, _L8("status") ); |
|
621 |
|
622 if ( outParam ) |
|
623 { |
|
624 retval = outParam->Value().AsTInt32(); |
|
625 } |
|
626 else |
|
627 { |
|
628 pos = 0; |
|
629 |
|
630 retval = KErrNotFound; |
|
631 |
|
632 outParam = aEventParamList.FindFirst( pos, _L8("notification") ); |
|
633 |
|
634 if( !outParam ) |
|
635 { |
|
636 // should never happen, but change status back to KErrNotFound |
|
637 return retval; |
|
638 } |
|
639 |
|
640 HBufC8* event( NULL ); |
|
641 HBufC8* pluginUid( NULL ); |
|
642 HBufC8* pluginName( NULL ); |
|
643 TInt pushCount( 0 ); |
|
644 |
|
645 TLiwVariant variant; |
|
646 variant.PushL(); |
|
647 pushCount++; |
|
648 |
|
649 variant = outParam->Value(); |
|
650 |
|
651 const CLiwMap* notifMap( variant.AsMap() ); |
|
652 |
|
653 if ( notifMap->FindL( _L8("event"), variant ) ) |
|
654 { |
|
655 event = variant.AsData().AllocLC(); |
|
656 pushCount++; |
|
657 } |
|
658 |
|
659 variant.Reset(); |
|
660 |
|
661 if ( event && event->Des().Compare( KSettingsChanged ) == 0 ) |
|
662 { |
|
663 if( notifMap->FindL( _L8("name"), variant ) ) |
|
664 { |
|
665 pluginName = variant.AsData().AllocLC(); |
|
666 pushCount++; |
|
667 } |
|
668 |
|
669 variant.Reset(); |
|
670 |
|
671 if( notifMap->FindL( _L8("pluginUid"), variant ) ) |
|
672 { |
|
673 pluginUid = variant.AsData().AllocLC(); |
|
674 pushCount++; |
|
675 } |
|
676 |
|
677 |
|
678 variant.Reset(); |
|
679 |
|
680 if( notifMap->FindL( _L8("pluginIds"), variant ) ) |
|
681 { |
|
682 const CLiwList* pluginIdList( variant.AsList() ); |
|
683 |
|
684 variant.Reset(); |
|
685 |
|
686 TInt count( pluginIdList->Count() ); |
|
687 |
|
688 retval = KErrNone; |
|
689 |
|
690 for( TInt i = 0; i < count && retval == KErrNone; i++ ) |
|
691 { |
|
692 pluginIdList->AtL( i, variant ); |
|
693 HBufC8* pluginId( NULL ); |
|
694 pluginId = variant.AsData().AllocLC(); |
|
695 |
|
696 for( TInt i = 0; i < iObservers.Count(); i++ ) |
|
697 { |
|
698 iObservers[i]->SettingsChangedL( |
|
699 ( event ) ? *event : KNullDesC8(), |
|
700 ( pluginName ) ? *pluginName : KNullDesC8(), |
|
701 ( pluginUid ) ? *pluginUid : KNullDesC8(), |
|
702 ( pluginId ) ? *pluginId : KNullDesC8() ); |
|
703 } |
|
704 |
|
705 CleanupStack::PopAndDestroy( pluginId ); |
|
706 |
|
707 variant.Reset(); |
|
708 } |
|
709 } |
|
710 |
|
711 } |
|
712 |
|
713 CleanupStack::PopAndDestroy( pushCount ); |
|
714 } |
|
715 } |
|
716 |
|
717 if( retval != KErrNone && aEventId != KLiwEventInProgress) |
|
718 { |
|
719 CLiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
720 CLiwGenericParamList& outParamList = iServiceHandler->OutParamListL(); |
|
721 |
|
722 inParamList.Reset(); |
|
723 outParamList.Reset(); |
|
724 //cancel old notification request |
|
725 iHspsInterface->ExecuteCmdL( KRequestNotification, |
|
726 inParamList, |
|
727 outParamList, |
|
728 KLiwOptCancel, |
|
729 this ); |
|
730 |
|
731 inParamList.Reset(); |
|
732 outParamList.Reset(); |
|
733 //request notification again |
|
734 iTransactionId = -1; |
|
735 iHspsInterface->ExecuteCmdL( KRequestNotification, |
|
736 inParamList, |
|
737 outParamList, |
|
738 KLiwOptASyncronous, |
|
739 this ); |
|
740 |
|
741 const TLiwGenericParam* outParam( NULL ); |
|
742 |
|
743 TInt pos( 0 ); |
|
744 outParam = outParamList.FindFirst( pos, _L8("status") ); |
|
745 |
|
746 if ( outParam ) |
|
747 { |
|
748 TInt retval; |
|
749 retval = outParam->Value().AsTInt32(); |
|
750 |
|
751 if(retval == KErrNone ) |
|
752 { |
|
753 pos = 0; |
|
754 outParam = outParamList.FindFirst( pos, _L8("TransactionID") ); |
|
755 |
|
756 if( outParam ) |
|
757 { |
|
758 retval = outParam->Value().AsTInt32(); |
|
759 iTransactionId = retval; |
|
760 } |
|
761 } |
|
762 } |
|
763 |
|
764 } |
|
765 |
|
766 return retval; |
|
767 } |
|
768 |
|
769 } |
|
770 //End of file |