|
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: Implementation of CHSPSConfigurationIf class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32def.h> |
|
21 |
|
22 #include "hspsconfigurationif.h" |
|
23 #include "hspsliwutilities.h" |
|
24 #include "hspsliwvocabulary.hrh" |
|
25 #include "hspsxmlelements.h" |
|
26 #include "hspscallback.h" |
|
27 |
|
28 #ifdef HSPS_LOG_ACTIVE |
|
29 #include <hspslogbusfile.h> |
|
30 #include <hspsliwdump.h> |
|
31 #endif |
|
32 |
|
33 using namespace LIW; |
|
34 |
|
35 |
|
36 // ======== LOCAL FUNCTIONS ==================================================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // Cleanup function for CArrayPtrFlat arrays |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 static void DeleteArrayItems( TAny* aObject ) |
|
43 { |
|
44 CArrayPtrFlat<ChspsODT>* array = reinterpret_cast<CArrayPtrFlat<ChspsODT>*>( aObject ); |
|
45 array->ResetAndDestroy(); |
|
46 delete array; |
|
47 } |
|
48 |
|
49 // ======== MEMBER FUNCTIONS =================================================== |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // Two-phased constructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CHSPSConfigurationIf* CHSPSConfigurationIf::NewL( TDesC8& aAppUid ) |
|
56 { |
|
57 CHSPSConfigurationIf* self = new (ELeave) CHSPSConfigurationIf(); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL( aAppUid ); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // Destructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CHSPSConfigurationIf::~CHSPSConfigurationIf() |
|
69 { |
|
70 delete iHspsConfigurationService; |
|
71 delete iHspsPersonalisationService; |
|
72 delete iHspsLiwUtilities; |
|
73 |
|
74 #ifdef HSPS_LOG_ACTIVE |
|
75 // Delete liw dump object before logbus |
|
76 // since liw dump is dependant from ilogbus. |
|
77 delete iLiwDump; |
|
78 iLiwDump = NULL; |
|
79 delete iLogBus; |
|
80 iLogBus = NULL; |
|
81 #endif |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // Constructor |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CHSPSConfigurationIf::CHSPSConfigurationIf() |
|
89 { |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // Symbian Constructor |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CHSPSConfigurationIf::ConstructL( TDesC8& aAppUid ) |
|
97 { |
|
98 #ifdef HSPS_LOG_ACTIVE |
|
99 iLogBus = ChspsLogBusFile::NewL( ChspsLogBusFile::CreateLogFilename( _L("sapi_configurationIf") ) ); |
|
100 iLiwDump = ChspsLiwDump::NewL( *iLogBus ); |
|
101 #endif |
|
102 |
|
103 iHspsConfigurationService = CHspsConfigurationService::NewL(); |
|
104 |
|
105 #ifdef HSPS_LOG_ACTIVE |
|
106 iHspsConfigurationService->SetLogBus( iLogBus ); |
|
107 #endif |
|
108 |
|
109 //create ODT. |
|
110 //Convert appUid. |
|
111 TInt appIdInt = -1; |
|
112 //convert appId to a number. |
|
113 TLex8 input( aAppUid ); |
|
114 TInt convErr = input.Val( appIdInt ); |
|
115 if( convErr != KErrNone ) |
|
116 { |
|
117 User::Leave( KErrArgument ); |
|
118 } |
|
119 iHspsConfigurationService->GetODTL( appIdInt ); |
|
120 |
|
121 iHspsPersonalisationService = CHspsPersonalisationService::NewL(); |
|
122 |
|
123 iHspsLiwUtilities = CHspsLiwUtilities::NewL(); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // Executes the SAPI command |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CHSPSConfigurationIf::ExecuteCmdL( |
|
131 const TDesC8& aCmdName, |
|
132 const CLiwGenericParamList& aInParamList, |
|
133 CLiwGenericParamList& aOutParamList, |
|
134 TUint aCmdOptions, |
|
135 MLiwNotifyCallback* aCallback ) |
|
136 { |
|
137 #ifdef HSPS_LOG_ACTIVE |
|
138 iLogBus->LogText( _L( "CHSPSConfigurationIf::ExecuteCmdL" ) ); |
|
139 iLiwDump->LogLiwListAsText( const_cast<CLiwGenericParamList&>( aInParamList ) ); |
|
140 iLiwDump->LogLiwListAsBinary( const_cast<CLiwGenericParamList&>( aInParamList ) ); |
|
141 #endif |
|
142 |
|
143 if ( aCallback ) |
|
144 { |
|
145 AsyncMethodCallL( |
|
146 aCmdName, |
|
147 aInParamList, |
|
148 aOutParamList, |
|
149 aCmdOptions, |
|
150 aCallback ); |
|
151 } |
|
152 else |
|
153 { |
|
154 SyncMethodCallL( |
|
155 aCmdName, |
|
156 aInParamList, |
|
157 aOutParamList ); |
|
158 } |
|
159 |
|
160 #ifdef HSPS_LOG_ACTIVE |
|
161 iLiwDump->LogLiwListAsText( aOutParamList ); |
|
162 iLiwDump->LogLiwListAsBinary( aOutParamList ); |
|
163 #endif |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // Synchronous method calls |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CHSPSConfigurationIf::SyncMethodCallL( |
|
171 const TDesC8& aCmdName, |
|
172 const CLiwGenericParamList& aInParamList, |
|
173 CLiwGenericParamList& aOutParamList ) |
|
174 { |
|
175 TInt err; |
|
176 //GETACTIVEAPPCONF |
|
177 if ( aCmdName.CompareF( KGetActiveAppConf ) == 0 ) |
|
178 { |
|
179 TRAP( err, GetActiveAppConfL( aOutParamList ) ); |
|
180 } |
|
181 //GETPLUGINCONF |
|
182 else if( aCmdName.CompareF( KGetPluginConf ) == 0 ) |
|
183 { |
|
184 TRAP( err, GetPluginConfL( aInParamList, aOutParamList ) ); |
|
185 } |
|
186 //GETPLUGINS |
|
187 else if( aCmdName.CompareF( KGetPlugins ) == 0 ) |
|
188 { |
|
189 TRAP( err, GetPluginsL( aInParamList, aOutParamList ) ); |
|
190 } |
|
191 //GETPLUGINLIST |
|
192 else if( aCmdName.CompareF( KGetPluginList ) == 0 ) |
|
193 { |
|
194 TRAP( err, GetPluginListL( aInParamList, aOutParamList ) ); |
|
195 } |
|
196 //ADDPLUGIN |
|
197 else if( aCmdName.CompareF( KAddPlugin ) == 0 ) |
|
198 { |
|
199 TRAP( err, AddPluginL( aInParamList, aOutParamList ) ); |
|
200 } |
|
201 //REMOVEPLUGIN |
|
202 else if( aCmdName.CompareF( KRemovePlugin ) == 0 ) |
|
203 { |
|
204 TRAP( err, RemovePluginL( aInParamList, aOutParamList ) ); |
|
205 } |
|
206 //REPLACEPLUGIN |
|
207 else if( aCmdName.CompareF( KReplacePlugin ) == 0 ) |
|
208 { |
|
209 TRAP( err, ReplacePluginL( aInParamList, aOutParamList ) ); |
|
210 } |
|
211 //SETPLUGINSETTINGSL |
|
212 else if( aCmdName.CompareF( KSetPluginSettings ) == 0 ) |
|
213 { |
|
214 TRAP( err, SetPluginSettingsL( aInParamList, aOutParamList ) ); |
|
215 } |
|
216 //GETPLUGINSETTINGSL |
|
217 else if( aCmdName.CompareF( KGetPluginSettings ) == 0 ) |
|
218 { |
|
219 TRAP( err, GetPluginSettingsL( aInParamList, aOutParamList ) ); |
|
220 } |
|
221 //MOVEPLUGINSL |
|
222 else if( aCmdName.CompareF( KMovePlugins ) == 0 ) |
|
223 { |
|
224 TRAP( err, MovePluginsL( aInParamList, aOutParamList ) ); |
|
225 } |
|
226 //GETAPPCONFSL |
|
227 else if( aCmdName.CompareF( KGetAppConfs ) == 0 ) |
|
228 { |
|
229 TRAP( err, GetAppConfsL( aInParamList, aOutParamList ) ); |
|
230 } |
|
231 //SETACTIVEAPPCONFL |
|
232 else if( aCmdName.CompareF( KSetActiveAppConf ) == 0 ) |
|
233 { |
|
234 TRAP( err, SetActiveAppConfL( aInParamList, aOutParamList ) ); |
|
235 } |
|
236 //SETCONFSTATEL |
|
237 else if( aCmdName.CompareF( KSetConfState ) == 0 ) |
|
238 { |
|
239 TRAP( err, SetConfStateL( aInParamList, aOutParamList ) ); |
|
240 } |
|
241 //SETACTIVEPLUGIN |
|
242 else if( aCmdName.CompareF( KSetActivePlugin ) == 0 ) |
|
243 { |
|
244 TRAP( err, SetActivePluginL( aInParamList, aOutParamList ) ); |
|
245 } |
|
246 //UNKNOWN COMMAND |
|
247 else |
|
248 { |
|
249 // Invalid command |
|
250 err = KErrArgument; |
|
251 } |
|
252 if ( err != KErrNone ) |
|
253 { |
|
254 SetErrorL( aOutParamList, err ); |
|
255 } |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // Asynchronous method calls |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CHSPSConfigurationIf::AsyncMethodCallL( |
|
263 const TDesC8& aCmdName, |
|
264 const CLiwGenericParamList& aInParamList, |
|
265 CLiwGenericParamList& aOutParamList, |
|
266 TUint aCmdOptions, |
|
267 MLiwNotifyCallback* aCallback ) |
|
268 { |
|
269 TInt err = KErrNotSupported; |
|
270 TInt32 transactionId = -1; |
|
271 //REQUEST NOTIFICATION |
|
272 if(aCmdName.CompareF( KRequestNotification ) == 0) |
|
273 { |
|
274 if( aCallback && !(aCmdOptions & KLiwOptCancel) ) |
|
275 { |
|
276 TRAP( err, RequestNotificationL( aInParamList, aCallback, transactionId ) ); |
|
277 } |
|
278 else |
|
279 { |
|
280 if ( aCmdOptions & KLiwOptCancel ) |
|
281 { |
|
282 TRAP(err, iHspsConfigurationService->UnRegisterObserverL()); |
|
283 } |
|
284 } |
|
285 } |
|
286 //UNKNOWN COMMAND |
|
287 else |
|
288 { |
|
289 // Invalid command |
|
290 err = KErrArgument; |
|
291 } |
|
292 // Append transaction id in case of asynchronous requests |
|
293 if( aCallback && ( KLiwOptASyncronous & aCmdOptions ) && |
|
294 ( err == KErrNone ) && ( transactionId != -1 ) ) |
|
295 { |
|
296 |
|
297 SetErrorL( aOutParamList, err ); |
|
298 aOutParamList.AppendL(TLiwGenericParam( KTransactionID, |
|
299 TLiwVariant( TInt32( transactionId )))); |
|
300 } |
|
301 |
|
302 |
|
303 if ( err != KErrNone ) |
|
304 { |
|
305 SetErrorL( aOutParamList, err ); |
|
306 } |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // Error in the parameter. |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 void CHSPSConfigurationIf::SetErrorL( CLiwGenericParamList& aOutParamList, |
|
314 TInt32 err ) |
|
315 { |
|
316 aOutParamList.Reset(); |
|
317 CHspsLiwUtilities::AppendStatusL( err, aOutParamList ); |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // Closes the interface |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 void CHSPSConfigurationIf::Close() |
|
325 { |
|
326 delete this; |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // Gets root plugin of active configuration. |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 void CHSPSConfigurationIf::GetActiveAppConfL( |
|
334 CLiwGenericParamList& aOutParamList ) |
|
335 { |
|
336 //InParamList not needed, |
|
337 TPtrC8 pluginId; |
|
338 pluginId.Set( KHspsLiwEmptyValue ); |
|
339 |
|
340 // Get configuration node of application configuration |
|
341 ChspsDomNode* node = &( iHspsLiwUtilities->FindRootNodeByTagL( |
|
342 KConfigurationElement, |
|
343 *( iHspsConfigurationService->GetDOML().RootNode() ) ) ); |
|
344 |
|
345 if ( !node ) |
|
346 { |
|
347 User::Leave( KErrNotFound ); |
|
348 } |
|
349 |
|
350 // Get configuration state |
|
351 TPtrC8 state; |
|
352 CHspsLiwUtilities::GetAttributeValueL( |
|
353 *node, |
|
354 KConfigurationAttrState, |
|
355 state ); |
|
356 |
|
357 if ( state.Compare( KConfStateError ) == 0 ) |
|
358 { |
|
359 // Restore active application configuration |
|
360 TPtrC8 confUid; |
|
361 CHspsLiwUtilities::GetAttributeValueL( |
|
362 *node, |
|
363 KConfigurationAttrUid, |
|
364 confUid ); |
|
365 TInt appUid; |
|
366 iHspsConfigurationService->GetAppUidL( appUid ); |
|
367 iHspsPersonalisationService->RestoreActiveAppConfL( |
|
368 appUid, |
|
369 confUid ); |
|
370 |
|
371 // Invalidate ODT. |
|
372 iHspsConfigurationService->InvalidateODT(); |
|
373 } |
|
374 |
|
375 iHspsLiwUtilities->GetConfigurationL( |
|
376 KHspsLiwAppConf, |
|
377 pluginId, |
|
378 iHspsConfigurationService->GetDOML(), |
|
379 aOutParamList ); |
|
380 |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // Gets plugin of active configuration. |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 void CHSPSConfigurationIf::GetPluginConfL( |
|
388 const CLiwGenericParamList& aInParamList, |
|
389 CLiwGenericParamList& aOutParamList ) |
|
390 { |
|
391 TInt pos = 0; |
|
392 const TLiwGenericParam* inParam = aInParamList.FindFirst( pos, KPluginId ); |
|
393 |
|
394 if( inParam ) |
|
395 { |
|
396 TPtrC8 pluginId; |
|
397 TLiwVariant inParamVariant = inParam->Value(); |
|
398 pluginId.Set( inParamVariant.AsData() ); |
|
399 |
|
400 iHspsLiwUtilities->GetConfigurationL( |
|
401 KHspsLiwPluginConf, |
|
402 pluginId, |
|
403 iHspsConfigurationService->GetDOML(), |
|
404 aOutParamList ); |
|
405 } |
|
406 else |
|
407 { |
|
408 User::Leave( KErrArgument ); |
|
409 } |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // Gets list of plugins with defined interface |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 void CHSPSConfigurationIf::GetPluginsL( |
|
417 const CLiwGenericParamList& aInParamList, |
|
418 CLiwGenericParamList& aOutParamList ) |
|
419 { |
|
420 TInt pos; |
|
421 TPtrC8 interface; |
|
422 TPtrC8 type; |
|
423 const TLiwGenericParam* inParam; |
|
424 TLiwVariant inParamVariant; |
|
425 |
|
426 // Get interface parameter (mandatory) |
|
427 pos = 0; |
|
428 inParam = aInParamList.FindFirst( |
|
429 pos, |
|
430 KHspsLiwInterface ); |
|
431 |
|
432 if( inParam ) |
|
433 { |
|
434 inParamVariant = inParam->Value(); |
|
435 interface.Set( inParamVariant.AsData() ); |
|
436 |
|
437 // Get type parameter (optional) |
|
438 pos = 0; |
|
439 inParam = aInParamList.FindFirst( |
|
440 pos, |
|
441 KHspsLiwType ); |
|
442 if ( inParam ) |
|
443 { |
|
444 inParamVariant = inParam->Value(); |
|
445 type.Set( inParamVariant.AsData() ); |
|
446 } |
|
447 |
|
448 // Get headers list of defined interface |
|
449 TUint32 family; |
|
450 iHspsConfigurationService->GetFamilyL( family ); |
|
451 CArrayPtrFlat<ChspsODT>* list = |
|
452 new ( ELeave )CArrayPtrFlat<ChspsODT>( KHeaderListGranularity ); |
|
453 CleanupStack::PushL( TCleanupItem( DeleteArrayItems, list ) ); |
|
454 iHspsPersonalisationService->GetPluginListL( |
|
455 interface, |
|
456 type, |
|
457 family, |
|
458 *list ); |
|
459 |
|
460 // Create GetPlugins output parameters |
|
461 CHspsLiwUtilities::GetPluginsOutputL( *list, aOutParamList ); |
|
462 CleanupStack::PopAndDestroy( list ); |
|
463 } |
|
464 else |
|
465 { |
|
466 // Invalid method call |
|
467 User::Leave( KErrArgument ); |
|
468 } |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // Gets list of plugins with defined interface |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 void CHSPSConfigurationIf::GetPluginListL( |
|
476 const CLiwGenericParamList& aInParamList, |
|
477 CLiwGenericParamList& aOutParamList ) |
|
478 { |
|
479 |
|
480 TInt pos; |
|
481 TPtrC8 pluginId; |
|
482 TPtrC8 type; |
|
483 const TLiwGenericParam* inParam; |
|
484 TLiwVariant inParamVariant; |
|
485 |
|
486 // Get type parameter |
|
487 pos = 0; |
|
488 inParam = aInParamList.FindFirst( |
|
489 pos, |
|
490 KHspsLiwType ); |
|
491 |
|
492 if( inParam ) |
|
493 { |
|
494 inParamVariant = inParam->Value(); |
|
495 type.Set( inParamVariant.AsData() ); |
|
496 // Validate plugin type |
|
497 if ( type.Compare( KHspsLiwViewConf ) != 0 && |
|
498 type.Compare( KHspsLiwWidgetConf ) != 0 && |
|
499 type.Compare( KHspsLiwTemplateConf ) != 0 ) |
|
500 { |
|
501 User::Leave( KErrArgument ); |
|
502 } |
|
503 } |
|
504 |
|
505 // Get plugin id parameter |
|
506 pos = 0; |
|
507 inParam = aInParamList.FindFirst( |
|
508 pos, |
|
509 KPluginId ); |
|
510 |
|
511 if ( inParam ) |
|
512 { |
|
513 inParamVariant = inParam->Value(); |
|
514 pluginId.Set( inParamVariant.AsData() ); |
|
515 // Check that plugin node exists |
|
516 ChspsDomNode* node = &( CHspsLiwUtilities::FindRootNodeByIdentifierL( |
|
517 KPluginElement, |
|
518 pluginId, |
|
519 *( iHspsConfigurationService->GetDOML().RootNode() ) ) ); |
|
520 if ( !node ) |
|
521 { |
|
522 User::Leave( KErrNotFound ); |
|
523 } |
|
524 } |
|
525 |
|
526 // Create GetPluginList output parameters |
|
527 CHspsLiwUtilities::GetPluginListOutputL( |
|
528 *iHspsConfigurationService->GetDOML().RootNode(), |
|
529 type, |
|
530 pluginId, |
|
531 aOutParamList ); |
|
532 |
|
533 } |
|
534 |
|
535 // ----------------------------------------------------------------------------- |
|
536 // Add a new plugin to the defined configuration |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 void CHSPSConfigurationIf::AddPluginL( |
|
540 const CLiwGenericParamList& aInParamList, |
|
541 CLiwGenericParamList& aOutParamList ) |
|
542 { |
|
543 TInt pos; |
|
544 TPtrC8 confId; |
|
545 TPtrC8 pluginUid; |
|
546 TPtrC8 position; |
|
547 const TLiwGenericParam* inParam; |
|
548 TLiwVariant inParamVariant; |
|
549 TInt pluginId; |
|
550 TInt err( KErrNone ); |
|
551 |
|
552 // Get confId parameter (mandatory) |
|
553 pos = 0; |
|
554 inParam = aInParamList.FindFirst( |
|
555 pos, |
|
556 KHspsLiwConfId ); |
|
557 |
|
558 if( inParam ) |
|
559 { |
|
560 inParamVariant = inParam->Value(); |
|
561 confId.Set( inParamVariant.AsData() ); |
|
562 } |
|
563 else |
|
564 { |
|
565 // Mandatory element missing |
|
566 err = KErrArgument; |
|
567 } |
|
568 if ( err == KErrNone ) |
|
569 { |
|
570 // Get pluginUid parameter (mandatory) |
|
571 pos = 0; |
|
572 inParam = aInParamList.FindFirst( |
|
573 pos, |
|
574 KHspsLiwPluginUid ); |
|
575 if ( inParam ) |
|
576 { |
|
577 inParamVariant = inParam->Value(); |
|
578 pluginUid.Set( inParamVariant.AsData() ); |
|
579 } |
|
580 else |
|
581 { |
|
582 // Mandatory element missing |
|
583 err = KErrArgument; |
|
584 } |
|
585 } |
|
586 if ( err == KErrNone ) |
|
587 { |
|
588 // Get position parameter (optional) |
|
589 pos = 0; |
|
590 inParam = aInParamList.FindFirst( |
|
591 pos, |
|
592 KHspsLiwPosition ); |
|
593 if ( inParam ) |
|
594 { |
|
595 inParamVariant = inParam->Value(); |
|
596 position.Set( inParamVariant.AsData() ); |
|
597 } |
|
598 } |
|
599 |
|
600 User::LeaveIfError( err ); |
|
601 |
|
602 // Add plugin |
|
603 TInt appUid; |
|
604 iHspsConfigurationService->GetAppUidL( appUid ); |
|
605 |
|
606 iHspsPersonalisationService->AddPluginL( |
|
607 appUid, |
|
608 confId, |
|
609 pluginUid, |
|
610 position, |
|
611 pluginId |
|
612 ); |
|
613 |
|
614 // Invalidate ODT. |
|
615 iHspsConfigurationService->InvalidateODT(); |
|
616 |
|
617 // Create output parameters |
|
618 CHspsLiwUtilities::AddPluginOutputL( pluginId, aOutParamList ); |
|
619 |
|
620 } |
|
621 |
|
622 // ----------------------------------------------------------------------------- |
|
623 // Removes a plugin from the active configuration |
|
624 // ----------------------------------------------------------------------------- |
|
625 // |
|
626 void CHSPSConfigurationIf::RemovePluginL( |
|
627 const CLiwGenericParamList& aInParamList, |
|
628 CLiwGenericParamList& aOutParamList ) |
|
629 { |
|
630 TInt err( KErrNone ); |
|
631 const TLiwGenericParam* inParam; |
|
632 TLiwVariant inParamVariant; |
|
633 TPtrC8 pluginId; |
|
634 TInt pos; |
|
635 |
|
636 // Get pluginId parameter (mandatory) |
|
637 pos = 0; |
|
638 inParam = aInParamList.FindFirst( |
|
639 pos, |
|
640 KPluginId ); |
|
641 |
|
642 if( inParam ) |
|
643 { |
|
644 inParamVariant = inParam->Value(); |
|
645 pluginId.Set( inParamVariant.AsData() ); |
|
646 } |
|
647 else |
|
648 { |
|
649 // Mandatory element missing |
|
650 err = KErrArgument; |
|
651 } |
|
652 |
|
653 User::LeaveIfError( err ); |
|
654 |
|
655 // Remove plugin |
|
656 TInt appUid; |
|
657 iHspsConfigurationService->GetAppUidL( appUid ); |
|
658 |
|
659 iHspsPersonalisationService->RemovePluginL( |
|
660 appUid, |
|
661 pluginId ); |
|
662 |
|
663 // Invalidate ODT. |
|
664 iHspsConfigurationService->InvalidateODT(); |
|
665 |
|
666 // Create output parameters |
|
667 CHspsLiwUtilities::RemovePluginOutputL( aOutParamList ); |
|
668 |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // Replaces a plugin from the active configuration |
|
673 // ----------------------------------------------------------------------------- |
|
674 // |
|
675 void CHSPSConfigurationIf::ReplacePluginL( |
|
676 const CLiwGenericParamList& aInParamList, |
|
677 CLiwGenericParamList& aOutParamList ) |
|
678 { |
|
679 TInt err( KErrNone ); |
|
680 const TLiwGenericParam* inParam; |
|
681 TLiwVariant inParamVariant; |
|
682 TPtrC8 pluginId; |
|
683 TPtrC8 confUid; |
|
684 TInt pos; |
|
685 |
|
686 // Get pluginId parameter (mandatory) |
|
687 pos = 0; |
|
688 inParam = aInParamList.FindFirst( |
|
689 pos, |
|
690 KPluginId ); |
|
691 |
|
692 if( inParam ) |
|
693 { |
|
694 inParamVariant = inParam->Value(); |
|
695 pluginId.Set( inParamVariant.AsData() ); |
|
696 } |
|
697 else |
|
698 { |
|
699 // Mandatory element missing |
|
700 err = KErrArgument; |
|
701 } |
|
702 |
|
703 if ( err == KErrNone ) |
|
704 { |
|
705 // Get pluginUid parameter (mandatory) |
|
706 pos = 0; |
|
707 inParam = aInParamList.FindFirst( |
|
708 pos, |
|
709 KHspsLiwConfUid ); |
|
710 if ( inParam ) |
|
711 { |
|
712 inParamVariant = inParam->Value(); |
|
713 confUid.Set( inParamVariant.AsData() ); |
|
714 } |
|
715 else |
|
716 { |
|
717 // Mandatory element missing |
|
718 err = KErrArgument; |
|
719 } |
|
720 } |
|
721 |
|
722 |
|
723 User::LeaveIfError( err ); |
|
724 |
|
725 // Get active application uid |
|
726 TInt appUid; |
|
727 iHspsConfigurationService->GetAppUidL( appUid ); |
|
728 |
|
729 // Replace plugin in the application configuration |
|
730 iHspsPersonalisationService->ReplacePluginL( |
|
731 appUid, |
|
732 pluginId, |
|
733 confUid ); |
|
734 |
|
735 // Invalidate ODT. |
|
736 iHspsConfigurationService->InvalidateODT(); |
|
737 |
|
738 // Create output parameters |
|
739 CHspsLiwUtilities::ReplacePluginOutputL( aOutParamList ); |
|
740 } |
|
741 |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // Sets plugin settings |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CHSPSConfigurationIf::SetPluginSettingsL( |
|
748 const CLiwGenericParamList& aInParamList, |
|
749 CLiwGenericParamList& aOutParamList ) |
|
750 { |
|
751 TInt error = KErrNone; |
|
752 TPtrC8 pluginId; |
|
753 TInt pos = 0; |
|
754 TPtrC8 storingParams; |
|
755 TBool pluginStoringStatus(EFalse); // EFalse only rootconfiguration is stored. |
|
756 |
|
757 const CLiwList* settingsList; |
|
758 |
|
759 const TLiwGenericParam* inParam = aInParamList.FindFirst( pos, KPluginId ); |
|
760 |
|
761 if( inParam ) |
|
762 { |
|
763 TLiwVariant inParamVariant = inParam->Value(); |
|
764 pluginId.Set( inParamVariant.AsData() ); |
|
765 } |
|
766 else |
|
767 { |
|
768 // Mandatory element missing |
|
769 error = KErrArgument; |
|
770 } |
|
771 |
|
772 if( error == KErrNone ) |
|
773 { |
|
774 pos=0; |
|
775 const TLiwGenericParam* settingsParam = aInParamList.FindFirst( pos, KHspsLiwSettings ); |
|
776 TLiwVariant settingsParamVariant; |
|
777 if( settingsParam ) |
|
778 { |
|
779 settingsParamVariant = settingsParam->Value(); |
|
780 settingsList = settingsParamVariant.AsList(); |
|
781 } |
|
782 else |
|
783 { |
|
784 // Mandatory element missing |
|
785 error = KErrArgument; |
|
786 } |
|
787 } |
|
788 if( error == KErrNone ) |
|
789 { |
|
790 |
|
791 ChspsDomDocument& domDocument = iHspsConfigurationService->GetDOML( ); |
|
792 |
|
793 ChspsDomDocument* settingsDom = ChspsDomDocument::NewL(); |
|
794 CleanupStack::PushL( settingsDom ); |
|
795 |
|
796 error = iHspsLiwUtilities->SetPluginSettingsNodeL( |
|
797 *settingsList, |
|
798 pluginId, |
|
799 domDocument, |
|
800 *settingsDom |
|
801 ); |
|
802 |
|
803 if( error == KErrNone ) |
|
804 { |
|
805 |
|
806 // Get position parameter (optional) |
|
807 pos = 0; |
|
808 inParam = aInParamList.FindFirst( |
|
809 pos, |
|
810 KHspsLiwStoringParams ); |
|
811 |
|
812 |
|
813 if ( inParam ) |
|
814 { |
|
815 TLiwVariant inParamVariant = inParam->Value(); |
|
816 storingParams.Set( inParamVariant.AsData() ); |
|
817 if( storingParams.Compare( KHspsLiwStorePluginRefence ) == 0) |
|
818 { |
|
819 pluginStoringStatus = ETrue; |
|
820 } |
|
821 } |
|
822 TInt appUid; |
|
823 iHspsConfigurationService->GetAppUidL( appUid ); |
|
824 iHspsPersonalisationService->SetPluginSettingsL( |
|
825 appUid, |
|
826 pluginId, |
|
827 *settingsDom, |
|
828 pluginStoringStatus |
|
829 ); |
|
830 |
|
831 // Invalidate ODT. |
|
832 iHspsConfigurationService->InvalidateODT(); |
|
833 } |
|
834 |
|
835 CleanupStack::PopAndDestroy( settingsDom ); |
|
836 } |
|
837 |
|
838 User::LeaveIfError( error ); |
|
839 |
|
840 // Create output parameters |
|
841 CHspsLiwUtilities::SetPluginSettingsOutputL( aOutParamList ); |
|
842 |
|
843 } |
|
844 |
|
845 // ----------------------------------------------------------------------------- |
|
846 // Gets plugin settings |
|
847 // ----------------------------------------------------------------------------- |
|
848 // |
|
849 void CHSPSConfigurationIf::GetPluginSettingsL( |
|
850 const CLiwGenericParamList& aInParamList, |
|
851 CLiwGenericParamList& aOutParamList ) |
|
852 { |
|
853 #ifdef HSPS_LOG_ACTIVE |
|
854 iLogBus->LogText( _L( "CHSPSConfigurationIf::GetPluginSettingsL" ) ); |
|
855 #endif |
|
856 |
|
857 TInt pos = 0; |
|
858 const TLiwGenericParam* inParam = aInParamList.FindFirst( pos, KHspsLiwPluginUid ); |
|
859 |
|
860 if( inParam ) |
|
861 { |
|
862 TInt appUid; |
|
863 iHspsConfigurationService->GetAppUidL( appUid ); |
|
864 |
|
865 TPtrC8 pluginUid; |
|
866 TLiwVariant inParamVariant = inParam->Value(); |
|
867 pluginUid.Set( inParamVariant.AsData() ); |
|
868 |
|
869 ChspsODT* settingsOdt = ChspsODT::NewL(); |
|
870 CleanupStack::PushL( settingsOdt ); |
|
871 iHspsPersonalisationService->GetPluginOdtL( appUid, pluginUid, settingsOdt ); |
|
872 |
|
873 // Create output parameters |
|
874 iHspsLiwUtilities->GetPluginSettingsOutputL( settingsOdt->DomDocument(), aOutParamList ); |
|
875 |
|
876 #ifdef HSPS_LOG_ACTIVE |
|
877 iLiwDump->LogLiwListAsText( aOutParamList ); |
|
878 #endif |
|
879 |
|
880 CleanupStack::PopAndDestroy( settingsOdt ); |
|
881 } |
|
882 else |
|
883 { |
|
884 User::Leave( KErrArgument ); |
|
885 } |
|
886 |
|
887 } |
|
888 |
|
889 // Updates plugin positions |
|
890 // ----------------------------------------------------------------------------- |
|
891 // |
|
892 void CHSPSConfigurationIf::MovePluginsL( |
|
893 const CLiwGenericParamList& aInParamList, |
|
894 CLiwGenericParamList& aOutParamList ) |
|
895 { |
|
896 TPtrC8 confId; |
|
897 TInt pos = 0; |
|
898 CArrayFixFlat<TInt>* idArray = NULL; |
|
899 |
|
900 // Get confId |
|
901 const TLiwGenericParam* inParam = aInParamList.FindFirst( pos, KHspsLiwConfId ); |
|
902 if( !inParam ) |
|
903 { |
|
904 // Mandatory element missing |
|
905 User::Leave( KErrArgument ); |
|
906 } |
|
907 |
|
908 TLiwVariant inParamVariant = inParam->Value(); |
|
909 confId.Set( inParamVariant.AsData() ); |
|
910 |
|
911 // Get plugin id list |
|
912 pos = 0; |
|
913 const TLiwGenericParam* pluginsParam = aInParamList.FindFirst( pos, KHspsLiwPlugins ); |
|
914 if( !pluginsParam ) |
|
915 { |
|
916 // Mandatory element missing |
|
917 User::Leave( KErrArgument ); |
|
918 } |
|
919 |
|
920 TLiwVariant pluginsParamVariant; |
|
921 pluginsParamVariant = pluginsParam->Value(); |
|
922 const CLiwList* pluginsList = pluginsParamVariant.AsList(); |
|
923 const TInt KGranularity = 5; |
|
924 idArray = new ( ELeave )CArrayFixFlat<TInt>( KGranularity ); |
|
925 CleanupStack::PushL( idArray ); |
|
926 CHspsLiwUtilities::GetPluginIdListL( pluginsList, *idArray ); |
|
927 |
|
928 TInt appUid; |
|
929 iHspsConfigurationService->GetAppUidL( appUid ); |
|
930 iHspsPersonalisationService->MovePluginsL( |
|
931 appUid, |
|
932 confId, |
|
933 *idArray ); |
|
934 |
|
935 CleanupStack::PopAndDestroy( idArray ); |
|
936 |
|
937 // Invalidate ODT. |
|
938 iHspsConfigurationService->InvalidateODT(); |
|
939 |
|
940 // Create output parameters |
|
941 CHspsLiwUtilities::MovePluginsOutputL( aOutParamList ); |
|
942 } |
|
943 |
|
944 // ----------------------------------------------------------------------------- |
|
945 // Returns list of installed application configurations |
|
946 // ----------------------------------------------------------------------------- |
|
947 // |
|
948 void CHSPSConfigurationIf::GetAppConfsL( |
|
949 const CLiwGenericParamList& /*aInParamList*/, |
|
950 CLiwGenericParamList& aOutParamList ) |
|
951 { |
|
952 // Get app UID of active configuration |
|
953 TInt appUid( 0 ); |
|
954 iHspsConfigurationService->GetAppUidL( appUid ); |
|
955 |
|
956 // Get list of application configurations |
|
957 TUint32 family; |
|
958 iHspsConfigurationService->GetFamilyL( family ); |
|
959 CArrayPtrFlat<ChspsODT>* list = |
|
960 new ( ELeave )CArrayPtrFlat<ChspsODT>( KHeaderListGranularity ); |
|
961 CleanupStack::PushL( TCleanupItem( DeleteArrayItems, list ) ); |
|
962 |
|
963 iHspsPersonalisationService->GetAppConfListL( |
|
964 appUid, |
|
965 family, |
|
966 *list ); |
|
967 |
|
968 // Create GetAppConfs output parameters |
|
969 CHspsLiwUtilities::GetAppConfsOutputL( *list, aOutParamList ); |
|
970 |
|
971 // Cleanup application configuration list |
|
972 CleanupStack::PopAndDestroy( list ); |
|
973 } |
|
974 |
|
975 // ----------------------------------------------------------------------------- |
|
976 // Set application active configuration |
|
977 // ----------------------------------------------------------------------------- |
|
978 // |
|
979 void CHSPSConfigurationIf::SetActiveAppConfL( |
|
980 const CLiwGenericParamList& aInParamList, |
|
981 CLiwGenericParamList& aOutParamList ) |
|
982 { |
|
983 // Get confUid |
|
984 TPtrC8 confUid; |
|
985 TInt pos = 0; |
|
986 const TLiwGenericParam* inParam = aInParamList.FindFirst( |
|
987 pos, |
|
988 KHspsLiwConfUid ); |
|
989 if( !inParam ) |
|
990 { |
|
991 // Mandatory element missing |
|
992 User::Leave( KErrArgument ); |
|
993 } |
|
994 |
|
995 TLiwVariant inParamVariant = inParam->Value(); |
|
996 confUid.Set( inParamVariant.AsData() ); |
|
997 |
|
998 // Get app UID |
|
999 TInt appUid( 0 ); |
|
1000 iHspsConfigurationService->GetAppUidL( appUid ); |
|
1001 |
|
1002 // Set application configuration |
|
1003 iHspsPersonalisationService->SetActiveAppConfL( appUid, confUid ); |
|
1004 |
|
1005 // Invalidate ODT. |
|
1006 iHspsConfigurationService->InvalidateODT(); |
|
1007 |
|
1008 // Create output parameters |
|
1009 CHspsLiwUtilities::SetActiveAppConfOutputL( aOutParamList ); |
|
1010 |
|
1011 } |
|
1012 // --------------------------------------------------------------------------- |
|
1013 // Change Notification request to HSPS Service |
|
1014 // --------------------------------------------------------------------------- |
|
1015 // |
|
1016 void CHSPSConfigurationIf::RequestNotificationL( const CLiwGenericParamList& aInParamList, |
|
1017 MLiwNotifyCallback* aCallback, |
|
1018 TInt32& aTransactionId ) |
|
1019 { |
|
1020 aTransactionId = aCallback->GetTransactionID(); |
|
1021 |
|
1022 CHspsReqNotifCallback* cb = CHspsReqNotifCallback::NewL(aCallback, aInParamList, |
|
1023 aTransactionId, *iHspsConfigurationService ); |
|
1024 |
|
1025 CleanupStack::PushL( cb ); |
|
1026 |
|
1027 TInt status = iHspsConfigurationService->RegisterObserverL( cb ); |
|
1028 // Issue request |
|
1029 if( status == KErrNone) |
|
1030 { |
|
1031 CleanupStack::Pop( cb ); |
|
1032 } |
|
1033 else |
|
1034 { |
|
1035 CleanupStack::PopAndDestroy( cb ); |
|
1036 User::Leave(status); |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // Updates configuration's state |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // |
|
1044 void CHSPSConfigurationIf::SetConfStateL( |
|
1045 const CLiwGenericParamList& aInParamList, |
|
1046 CLiwGenericParamList& aOutParamList ) |
|
1047 { |
|
1048 |
|
1049 // Get confId |
|
1050 TPtrC8 confId; |
|
1051 TInt pos = 0; |
|
1052 const TLiwGenericParam* inParam = aInParamList.FindFirst( |
|
1053 pos, |
|
1054 KHspsLiwConfId ); |
|
1055 if( !inParam ) |
|
1056 { |
|
1057 // Mandatory element missing |
|
1058 User::Leave( KErrArgument ); |
|
1059 } |
|
1060 |
|
1061 TLiwVariant inParamVariant = inParam->Value(); |
|
1062 confId.Set( inParamVariant.AsData() ); |
|
1063 |
|
1064 // Get state |
|
1065 TPtrC8 state; |
|
1066 pos = 0; |
|
1067 inParam = aInParamList.FindFirst( |
|
1068 pos, |
|
1069 KHspsLiwConfState ); |
|
1070 if( !inParam ) |
|
1071 { |
|
1072 // Mandatory element missing |
|
1073 User::Leave( KErrArgument ); |
|
1074 } |
|
1075 |
|
1076 inParamVariant = inParam->Value(); |
|
1077 state.Set( inParamVariant.AsData() ); |
|
1078 |
|
1079 // Get filter parameter (optional) |
|
1080 TPtrC8 filter; |
|
1081 pos = 0; |
|
1082 inParam = aInParamList.FindFirst( |
|
1083 pos, |
|
1084 KHspsLiwFilter ); |
|
1085 if ( inParam ) |
|
1086 { |
|
1087 inParamVariant = inParam->Value(); |
|
1088 filter.Set( inParamVariant.AsData() ); |
|
1089 } |
|
1090 |
|
1091 // Get app UID |
|
1092 TInt appUid( 0 ); |
|
1093 iHspsConfigurationService->GetAppUidL( appUid ); |
|
1094 |
|
1095 // Set application configuration |
|
1096 iHspsPersonalisationService->SetConfStateL( appUid, confId, state, filter ); |
|
1097 |
|
1098 // Invalidate ODT. |
|
1099 iHspsConfigurationService->InvalidateODT(); |
|
1100 |
|
1101 // Create output parameters |
|
1102 CHspsLiwUtilities::SetConfStateOutputL( aOutParamList ); |
|
1103 |
|
1104 } |
|
1105 |
|
1106 // ----------------------------------------------------------------------------- |
|
1107 // Gets list of plugins with defined interface |
|
1108 // ----------------------------------------------------------------------------- |
|
1109 // |
|
1110 void CHSPSConfigurationIf::SetActivePluginL( |
|
1111 const CLiwGenericParamList& aInParamList, |
|
1112 CLiwGenericParamList& aOutParamList ) |
|
1113 { |
|
1114 |
|
1115 TInt pos; |
|
1116 TPtrC8 pluginId; |
|
1117 const TLiwGenericParam* inParam; |
|
1118 TLiwVariant inParamVariant; |
|
1119 |
|
1120 // Get plugin id parameter |
|
1121 pos = 0; |
|
1122 inParam = aInParamList.FindFirst( |
|
1123 pos, |
|
1124 KPluginId ); |
|
1125 |
|
1126 if ( inParam ) |
|
1127 { |
|
1128 inParamVariant = inParam->Value(); |
|
1129 pluginId.Set( inParamVariant.AsData() ); |
|
1130 // Check that plugin node exists |
|
1131 ChspsDomNode* node = &( CHspsLiwUtilities::FindRootNodeByIdentifierL( |
|
1132 KPluginElement, |
|
1133 pluginId, |
|
1134 *( iHspsConfigurationService->GetDOML().RootNode() ) ) ); |
|
1135 if ( !node ) |
|
1136 { |
|
1137 User::Leave( KErrNotFound ); |
|
1138 } |
|
1139 } |
|
1140 else |
|
1141 { |
|
1142 // Manadatory plugin id parameter missing |
|
1143 User::Leave( KErrArgument ); |
|
1144 } |
|
1145 |
|
1146 // Activate plugin |
|
1147 TInt appUid; |
|
1148 iHspsConfigurationService->GetAppUidL( appUid ); |
|
1149 |
|
1150 iHspsPersonalisationService->SetActivePluginL( |
|
1151 appUid, |
|
1152 pluginId ); |
|
1153 |
|
1154 // Invalidate ODT. |
|
1155 iHspsConfigurationService->InvalidateODT(); |
|
1156 |
|
1157 // Create output parameters |
|
1158 CHspsLiwUtilities::SetActivePluginOutputL( aOutParamList ); |
|
1159 |
|
1160 } |
|
1161 |
|
1162 // ======== GLOBAL FUNCTIONS =================================================== |
|
1163 |
|
1164 |
|
1165 // End of file |