|
1 /* |
|
2 * Copyright (c) 2002-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 HSPS MhspsMaintenanceService interface defined |
|
15 * in hspsThemeManagement.h. For details, see header file. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <centralrepository.h> |
|
21 |
|
22 #include "hsps_builds_cfg.hrh" |
|
23 #include "hspsthememanagement.h" |
|
24 #include "hspsdefinitionrepository.h" |
|
25 #include "hspsresource.h" |
|
26 #include "hspsresult.h" |
|
27 #include "hspspluginidlist.h" |
|
28 #include "hspsodt.h" |
|
29 #include "hspsmaintenancehandler.h" |
|
30 #include "hspsthemeserver.h" |
|
31 #include "hspsinstallationhandler.h" |
|
32 #include "hspssecurityenforcer.h" |
|
33 #include "hspsconfiguration.h" |
|
34 #include "hspsdomdocument.h" |
|
35 #include "hspsdomlist.h" |
|
36 #include "hspsdomdepthiterator.h" |
|
37 #include "hspsdomnode.h" |
|
38 #include "hspsdomattribute.h" |
|
39 #include "hspsmanifest.h" |
|
40 #include "hspsserverutil.h" |
|
41 #include "hspsthemeserversession.h" |
|
42 |
|
43 #ifdef HSPS_LOG_ACTIVE |
|
44 #include <hspsodtdump.h> |
|
45 #include <hspslogbus.h> |
|
46 #endif |
|
47 |
|
48 |
|
49 _LIT(KSourcesFolder, "\\sources\\"); |
|
50 _LIT(KLocalesFolder, "\\locales\\"); |
|
51 |
|
52 const TInt KAdditionalRequiredDiskSpace = 256 * 1024; /// 256KB in bytes. |
|
53 |
|
54 // ============================= LOCAL FUNCTIONS =============================== |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // Callback function for removing repository lock if error occurs while repository is locked |
|
58 // Returns: void |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 LOCAL_C void UnlockRepository( TAny* aObject ) |
|
62 { |
|
63 ChspsDefinitionRepository* DefRep = reinterpret_cast<ChspsDefinitionRepository*>( aObject ); |
|
64 |
|
65 if( DefRep->Locked() ) |
|
66 { |
|
67 DefRep->Unlock(); |
|
68 } |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // ResetAndDestroyArray Callback function for cleaning up the CArrayPtr. |
|
73 // Returns: void |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 LOCAL_C void ResetAndDestroyArray( TAny* aArray ) |
|
77 { |
|
78 reinterpret_cast<CArrayPtrSeg<HBufC>*>( aArray )->ResetAndDestroy(); |
|
79 } |
|
80 |
|
81 |
|
82 // ============================ MEMBER FUNCTIONS =============================== |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // ChspsMaintenanceHandler::ChspsMaintenanceHandler |
|
86 // C++ default constructor can NOT contain any code, that |
|
87 // might leave. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 ChspsMaintenanceHandler::ChspsMaintenanceHandler( |
|
91 ChspsThemeServer& aThemeServer, |
|
92 const TUint aSecureId ): |
|
93 CTimer(EPriorityLow), |
|
94 iLanguage ( aThemeServer.DeviceLanguage() ), |
|
95 iThemeServer( aThemeServer ), |
|
96 iSecureId( aSecureId ), |
|
97 iCentralRepository( aThemeServer.CentralRepository() ), |
|
98 iDefinitionRepository( aThemeServer.DefinitionRepository() ), |
|
99 iSecurityEnforcer( aThemeServer.SecurityEnforcer() ), |
|
100 iHeaderListCache( aThemeServer.HeaderListCache() ), |
|
101 iFileMan( NULL ) |
|
102 { |
|
103 iDeliveryCount = 0; |
|
104 iSubscription = EFalse; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // ChspsMaintenanceService::NewL |
|
109 // Two-phased constructor. |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 ChspsMaintenanceHandler* ChspsMaintenanceHandler::NewL( |
|
113 ChspsThemeServer& aThemeServer, |
|
114 const TUint aSecureId ) |
|
115 { |
|
116 ChspsMaintenanceHandler* h = ChspsMaintenanceHandler::NewLC( |
|
117 aThemeServer, aSecureId ); |
|
118 CleanupStack::Pop(h); |
|
119 return (h); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // ChspsMaintenanceService::NewLC |
|
124 // Two-phased constructor. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 ChspsMaintenanceHandler* ChspsMaintenanceHandler::NewLC( |
|
128 ChspsThemeServer& aThemeServer, |
|
129 const TUint aSecureId ) |
|
130 { |
|
131 ChspsMaintenanceHandler* h = new (ELeave) ChspsMaintenanceHandler( |
|
132 aThemeServer, aSecureId ); |
|
133 CleanupStack::PushL(h); |
|
134 h->ConstructL(); |
|
135 return (h); |
|
136 } |
|
137 |
|
138 // Destructor |
|
139 ChspsMaintenanceHandler::~ChspsMaintenanceHandler() |
|
140 { |
|
141 Cancel(); |
|
142 if (iHeaderDataList) |
|
143 { |
|
144 iHeaderDataList->ResetAndDestroy(); |
|
145 } |
|
146 delete iHeaderDataList; |
|
147 delete iSearchMask; |
|
148 delete iSetMask; |
|
149 delete iResult; |
|
150 delete iFileMan; |
|
151 iDefinitionRepository.UnregisterObserver( *this ); |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // ChspsMaintenanceHandler::ConstructL |
|
157 // Symbian 2nd phase constructor can leave. |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void ChspsMaintenanceHandler::ConstructL() |
|
161 { |
|
162 // call the base class ConstructL |
|
163 CTimer::ConstructL(); |
|
164 iHeaderDataList = new( ELeave ) CArrayPtrSeg<HBufC8>(KHeaderListGranularity); |
|
165 iResult = ChspsResult::NewL(); |
|
166 // add this timer to the active scheduler |
|
167 CActiveScheduler::Add(this); |
|
168 iDefinitionRepository.RegisterObserverL( *this ); |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // ChspsMaintenanceHandler::ServiceGetListHeadersL |
|
173 // Fetches the header list from repository and writes the first header back to the caller |
|
174 // (other items were commented in a header). |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void ChspsMaintenanceHandler::ServiceGetListHeadersL(const RMessage2& aMessage) |
|
178 { |
|
179 // only allow one request to be submitted at a time |
|
180 // all synch call must use local message pointer variable |
|
181 RMessagePtr2 messagePtr = aMessage; |
|
182 ThspsServiceCompletedMessage ret = EhspsGetListHeadersFailed; |
|
183 iDeliveryCount = 0; |
|
184 |
|
185 if (!IsActive() && !iSubscription) // first request |
|
186 { |
|
187 TBuf8<KMaxHeaderDataLength8> searchMaskData;// save a search mask |
|
188 messagePtr.ReadL(1,searchMaskData,0); |
|
189 // constructing iSearcMask -object |
|
190 if (iSearchMask) |
|
191 { |
|
192 delete iSearchMask; |
|
193 iSearchMask = NULL; |
|
194 } |
|
195 iSearchMask = ChspsODT::NewL(); |
|
196 iSearchMask->UnMarshalHeaderL(searchMaskData); |
|
197 |
|
198 // check the device language |
|
199 iLanguage = iThemeServer.DeviceLanguage(); |
|
200 iSearchMask->SetOdtLanguage( (TInt)iLanguage ); |
|
201 |
|
202 // now there is a subscription |
|
203 iSubscription = ETrue; |
|
204 // fetch the header list from repository |
|
205 ret = hspsGetListHeaders(searchMaskData, *iHeaderDataList); |
|
206 if (ret == EhspsGetListHeadersSuccess) |
|
207 { |
|
208 TInt count = iHeaderDataList->Count(); |
|
209 // result informs list count in query |
|
210 iResult->iIntValue1 = count; |
|
211 if ( !count ) |
|
212 { |
|
213 ret = EhspsGetListHeadersEmpty; |
|
214 } |
|
215 } |
|
216 |
|
217 CompleteRequest(ret, messagePtr); |
|
218 } |
|
219 else |
|
220 { |
|
221 iResult->iSystemError = KErrInUse; |
|
222 iResult->iSystemError = KErrInUse; |
|
223 CompleteRequest( EhspsServiceRequestError, iMessagePtr ); |
|
224 } |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // ChspsMaintenanceHandler::ServiceGetNextHeaderL |
|
229 // Writes back to the caller the next headers in the header list one at a time |
|
230 // (other items were commented in a header). |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void ChspsMaintenanceHandler::ServiceGetNextHeaderL(const RMessage2& aMessage) |
|
234 { |
|
235 // only allow one request to be submitted at a time |
|
236 iRequestMessage = (ThspsServiceRequestMessage) aMessage.Function(); |
|
237 iCompletedMessage = EhspsGetListHeadersUpdate; |
|
238 // now using message pointer as member variable because of asynch call |
|
239 iMessagePtr = aMessage; |
|
240 if ( !IsActive() && iSubscription) // requesting next as should |
|
241 { |
|
242 // is there headers to delivere left |
|
243 if (iHeaderDataList->Count() > iDeliveryCount) |
|
244 { |
|
245 // Handle copying of logo icon resources |
|
246 CopyIconsToHomescreenL( aMessage.SecureId().iId ); |
|
247 |
|
248 // at least one header on the list |
|
249 TPtr8 bufPtr( iHeaderDataList->At(iDeliveryCount)->Des() ); |
|
250 iMessagePtr.WriteL(2, bufPtr, 0); |
|
251 // add list count |
|
252 iDeliveryCount++; |
|
253 // deliver a list item |
|
254 CompleteRequest( EhspsGetListHeadersUpdate, iMessagePtr ); |
|
255 } |
|
256 } |
|
257 else |
|
258 { |
|
259 iResult->iSystemError = KErrInUse; |
|
260 iResult->iXuikonError = KErrPermissionDenied; |
|
261 CompleteRequest( EhspsServiceRequestError, iMessagePtr ); |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // ChspsMaintenanceHandler::CopyIconsToHomescreenL |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void ChspsMaintenanceHandler::CopyIconsToHomescreenL( |
|
270 const TUint aAppUid ) |
|
271 { |
|
272 HBufC8* headerData = iHeaderDataList->At(iDeliveryCount); |
|
273 ChspsODT* header = ChspsODT::UnMarshalHeaderLC( headerData->Des() ); |
|
274 if ( iServerSession && header ) |
|
275 { |
|
276 if( header->LogoFile().Length() ) |
|
277 { |
|
278 // If a file reference was found from the logo declaration |
|
279 TFileName filename; |
|
280 if ( hspsServerUtil::IsFile( header->LogoFile(), filename ) ) |
|
281 { |
|
282 if ( !iFileMan ) |
|
283 { |
|
284 iFileMan = CFileMan::NewL( iServerSession->FileSystem() ); |
|
285 } |
|
286 |
|
287 // Get client's private directory: |
|
288 // We should use some common directory if there are more than one SAPI clients, |
|
289 // for now we can copy files to AI3's private folder |
|
290 _LIT( KPrivatePath, "c:\\private\\%X\\"); |
|
291 TPath privatePath; |
|
292 privatePath.Format( KPrivatePath, aAppUid ); |
|
293 |
|
294 // Append private path to the logo file reference |
|
295 TInt offset = header->LogoFile().FindF( filename ); |
|
296 if ( offset >= 0 ) |
|
297 { |
|
298 // Insert private path prior to the file reference |
|
299 HBufC* logoBuf = HBufC::NewLC( |
|
300 privatePath.Length() + header->LogoFile().Length() ); |
|
301 logoBuf->Des().Copy( header->LogoFile() ); |
|
302 logoBuf->Des().Insert( offset, privatePath ); |
|
303 header->SetLogoFileL( logoBuf->Des() ); |
|
304 CleanupStack::PopAndDestroy( logoBuf ); |
|
305 |
|
306 // Replace the serialized header descriptor |
|
307 HBufC8* newHeaderData = header->MarshalHeaderL(); |
|
308 CleanupStack::PushL( newHeaderData ); |
|
309 iHeaderDataList->InsertL( |
|
310 iDeliveryCount, |
|
311 newHeaderData ); |
|
312 CleanupStack::Pop( newHeaderData ); |
|
313 delete headerData; |
|
314 headerData = 0; |
|
315 iHeaderDataList->Delete( iDeliveryCount + 1 ); |
|
316 } |
|
317 |
|
318 // Set target directory for file copying |
|
319 TPath targetPath; |
|
320 targetPath.Copy( privatePath ); |
|
321 targetPath.Append( filename ); |
|
322 |
|
323 // Set source directory for file copying |
|
324 TFileName sourceFile; |
|
325 _LIT( KThemesFolder, "themes\\" ); |
|
326 iServerSession->FileSystem().SessionPath( sourceFile ); |
|
327 sourceFile.Append( KThemesFolder ); |
|
328 sourceFile.Append( filename ); |
|
329 |
|
330 // Create the target path and copy files when required |
|
331 hspsServerUtil::CopyResourceFileL( |
|
332 iServerSession->FileSystem(), |
|
333 *iFileMan, |
|
334 targetPath, |
|
335 sourceFile ); |
|
336 } |
|
337 } |
|
338 } |
|
339 CleanupStack::PopAndDestroy( header ); |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // ChspsMaintenanceHandler::SetServerSession |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void ChspsMaintenanceHandler::SetServerSession( |
|
347 ChspsThemeServerSession* aServerSession ) |
|
348 { |
|
349 iServerSession = aServerSession; |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // ChspsMaintenanceHandler::ServiceSetActiveThemeL |
|
354 // Sets the active theme and writes back that themes header data |
|
355 // (other items were commented in a header). |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void ChspsMaintenanceHandler::ServiceSetActiveThemeL(const RMessage2& aMessage) |
|
359 { |
|
360 ThspsServiceCompletedMessage ret = EhspsSetActiveThemeFailed; |
|
361 // using message pointer as a local variable because of a synch call |
|
362 RMessagePtr2 messagePtr = aMessage; |
|
363 |
|
364 TBuf8<KMaxHeaderDataLength8> setMaskData; |
|
365 messagePtr.ReadL(1,setMaskData,0); |
|
366 //constructing setMask -object |
|
367 if( iSetMask ) |
|
368 { |
|
369 delete iSetMask; |
|
370 iSetMask = NULL; |
|
371 } |
|
372 iSetMask = ChspsODT::NewL(); |
|
373 iSetMask->UnMarshalHeaderL( setMaskData ); |
|
374 |
|
375 // calling actual activation |
|
376 ChspsODT* odt; |
|
377 odt = ChspsODT::NewL(); |
|
378 CleanupStack::PushL(odt); |
|
379 |
|
380 |
|
381 iDefinitionRepository.Lock(); |
|
382 // In case of error. repository is unlocked |
|
383 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
384 ret = hspsSetActiveTheme( *iSetMask, *odt ); |
|
385 if ( ret == EhspsSetActiveThemeSuccess ) |
|
386 { |
|
387 // Store updated ODT to definition repository |
|
388 iDefinitionRepository.SetOdtL( *odt ); |
|
389 |
|
390 HBufC8* headerdata; |
|
391 headerdata = odt->MarshalHeaderL(); |
|
392 if (headerdata != NULL) |
|
393 { |
|
394 // Write activated ODT header data to client |
|
395 CleanupStack::PushL(headerdata); |
|
396 messagePtr.WriteL(2,headerdata->Des(),0); |
|
397 CleanupStack::PopAndDestroy(headerdata); |
|
398 |
|
399 ThspsRepositoryInfo info( EhspsODTActivated ); |
|
400 iDefinitionRepository.RegisterNotification( info ); |
|
401 } |
|
402 } |
|
403 iDefinitionRepository.Unlock(); |
|
404 CleanupStack::Pop(&iDefinitionRepository); |
|
405 |
|
406 |
|
407 CleanupStack::Pop(odt); |
|
408 if (odt) |
|
409 { |
|
410 delete odt; |
|
411 odt = NULL; |
|
412 } |
|
413 |
|
414 // complete the message |
|
415 CompleteRequest(ret, messagePtr ); |
|
416 } |
|
417 |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // ChspsMaintenanceHandler::ServiceRestoreDefaultL |
|
421 // Restores the default theme according to the information in aMessage and writes |
|
422 // back restored themes header data. |
|
423 // (other items were commented in a header). |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 void ChspsMaintenanceHandler::ServiceRestoreDefaultL( const RMessage2& aMessage ) |
|
427 { |
|
428 ThspsServiceCompletedMessage ret = EhspsRestoreDefaultFailed; |
|
429 // using message pointer as a local variable because of synch call |
|
430 RMessagePtr2 messagePtr = aMessage; |
|
431 // TIpcArgs(TInt aAppUid, &aSetMaskData, &aHeaderData) |
|
432 TBuf8<KMaxHeaderDataLength8> setMaskData; |
|
433 messagePtr.ReadL( 1, setMaskData, 0 ); |
|
434 //constructing setMask -object |
|
435 if ( iSetMask ) |
|
436 { |
|
437 delete iSetMask; |
|
438 iSetMask = NULL; |
|
439 } |
|
440 iSetMask = ChspsODT::NewL(); |
|
441 iSetMask->UnMarshalHeaderL( setMaskData ); |
|
442 ChspsODT* odt; |
|
443 odt = ChspsODT::NewL(); |
|
444 CleanupStack::PushL( odt ); |
|
445 |
|
446 if ( !iDefinitionRepository.Locked() ) |
|
447 { |
|
448 iDefinitionRepository.Lock(); |
|
449 // In case of error. repository is unlocked |
|
450 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
451 // calling actual restoration |
|
452 ret = hspsRestoreDefault( *iSetMask, *odt ); |
|
453 if ( ret == EhspsRestoreDefaultSuccess ) |
|
454 { |
|
455 HBufC8* headerdata; |
|
456 headerdata = odt->MarshalHeaderL(); |
|
457 if (headerdata != NULL) |
|
458 { |
|
459 CleanupStack::PushL( headerdata ); |
|
460 messagePtr.WriteL( 2, headerdata->Des(), 0 ); |
|
461 CleanupStack::PopAndDestroy( headerdata ); |
|
462 |
|
463 // inform for cache update to the repository so that everyone will know |
|
464 // about the change |
|
465 ThspsRepositoryInfo info( EhspsCacheUpdate ); |
|
466 iDefinitionRepository.RegisterNotification( info ); |
|
467 } |
|
468 } |
|
469 iDefinitionRepository.Unlock(); |
|
470 CleanupStack::Pop(&iDefinitionRepository); |
|
471 } |
|
472 else |
|
473 { |
|
474 ret = EhspsRestoreDefaultFailed; |
|
475 |
|
476 #ifdef HSPS_LOG_ACTIVE |
|
477 if( iLogBus ) |
|
478 { |
|
479 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceRestoreDefaultL(): - failed, repository is locked." ) ); |
|
480 } |
|
481 #endif |
|
482 } |
|
483 |
|
484 |
|
485 CleanupStack::PopAndDestroy( odt ); |
|
486 // complete the message |
|
487 CompleteRequest( ret, messagePtr ); |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // ChspsMaintenanceHandler::ServiceRemoveThemeL |
|
492 // Reads ODT from RMessage2 and calls the actual removal method. |
|
493 // (other items were commented in a header). |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 void ChspsMaintenanceHandler::ServiceRemoveThemeL( const RMessage2& aMessage ) |
|
497 { |
|
498 ThspsServiceCompletedMessage ret = EhspsRemoveThemeFailed; |
|
499 // using message pointer as a local variable because of synch call |
|
500 RMessagePtr2 messagePtr = aMessage; |
|
501 |
|
502 // TIpcArgs(TInt aAppUid, &aSetMaskData, &aHeaderData) |
|
503 TBuf8<KMaxHeaderDataLength8> setMaskData; |
|
504 messagePtr.ReadL( 1, setMaskData, 0 ); |
|
505 |
|
506 //constructing setMask -object |
|
507 if ( iSetMask ) |
|
508 { |
|
509 delete iSetMask; |
|
510 iSetMask = NULL; |
|
511 } |
|
512 |
|
513 iSetMask = ChspsODT::NewL(); |
|
514 iSetMask->UnMarshalHeaderL( setMaskData ); |
|
515 |
|
516 // calling actual removal |
|
517 ret = hspsRemoveThemeL( *iSetMask ); |
|
518 |
|
519 // complete the message |
|
520 CompleteRequest( ret, messagePtr ); |
|
521 } |
|
522 |
|
523 // ----------------------------------------------------------------------------- |
|
524 // Appends an application configuration with the provided plugin configuration |
|
525 // ----------------------------------------------------------------------------- |
|
526 // |
|
527 void ChspsMaintenanceHandler::ServiceAddPluginL( const RMessage2& aMessage ) |
|
528 { |
|
529 // Defaults |
|
530 ThspsServiceCompletedMessage ret = EhspsAddPluginFailed; |
|
531 iResult->iXuikonError = KErrNotFound; |
|
532 TInt err = KErrNone; |
|
533 |
|
534 // Parameters |
|
535 RMessagePtr2 messagePtr = aMessage; |
|
536 |
|
537 // IPC slots: |
|
538 // #0) output: externalized ChspsResult for error handling |
|
539 // #1) input: ThpsParamAddPlugin struct |
|
540 // #2) output: added plugin id |
|
541 |
|
542 // Get service parameters from IPC slot #1 |
|
543 ThpsParamAddPlugin params; |
|
544 TPckg<ThpsParamAddPlugin> packagedStruct(params); |
|
545 aMessage.ReadL(1, packagedStruct); |
|
546 const TInt appUid = params.appUid; |
|
547 const TInt configurationId = params.configurationId; |
|
548 const TInt pluginUid = params.pluginUid; |
|
549 const TInt newPos = params.positionIndex; |
|
550 |
|
551 // Application configuration |
|
552 ChspsODT *appODT = NULL; |
|
553 if ( !err ) |
|
554 { |
|
555 // Get active application configuration from the central repository |
|
556 TInt appConfUid; |
|
557 err = iCentralRepository.Get( appUid, appConfUid ); |
|
558 if ( err || appConfUid < 1 ) |
|
559 { |
|
560 err = KErrNotFound; |
|
561 } |
|
562 else |
|
563 { |
|
564 // Get application configuration |
|
565 appODT = ChspsODT::NewL(); |
|
566 CleanupStack::PushL( appODT ); |
|
567 err = iThemeServer.GetConfigurationL( |
|
568 appUid, |
|
569 appConfUid, |
|
570 *appODT ); |
|
571 } |
|
572 } |
|
573 |
|
574 // Plugin configuration |
|
575 ChspsODT* pluginODT = NULL; |
|
576 if ( !err ) |
|
577 { |
|
578 // Find the plugin configuration (interface is unknown, so 1st argument is set to zero) |
|
579 pluginODT = ChspsODT::NewL(); |
|
580 CleanupStack::PushL( pluginODT ); |
|
581 err = iThemeServer.GetConfigurationL( |
|
582 0, |
|
583 pluginUid, |
|
584 *pluginODT ); |
|
585 } |
|
586 |
|
587 // Check needed space for addition. Returns system wide error code. |
|
588 if( !err ) |
|
589 { |
|
590 err = hspsServerUtil::EnoughDiskSpaceAvailableL( |
|
591 *pluginODT, |
|
592 iThemeServer.DeviceLanguage(), |
|
593 iServerSession->FileSystem(), |
|
594 EDriveC, |
|
595 KAdditionalRequiredDiskSpace ); |
|
596 } |
|
597 |
|
598 // Modifications |
|
599 TInt usedConfId = 0; |
|
600 TInt usedPluginId = 0; |
|
601 if ( !err && appODT && pluginODT ) |
|
602 { |
|
603 if ( iDefinitionRepository.Locked() ) |
|
604 { |
|
605 // Repository locked |
|
606 err = KErrAccessDenied; |
|
607 } |
|
608 else |
|
609 { |
|
610 // Lock the Plugin Repository (a.k.a. Def.rep) |
|
611 iDefinitionRepository.Lock(); |
|
612 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
613 |
|
614 // Get used conf & plugin ids |
|
615 GetUsedIdsL( |
|
616 appODT->DomDocument(), |
|
617 usedConfId, |
|
618 usedPluginId ); |
|
619 |
|
620 // Add the plugin configuration into the application configuration |
|
621 err = AppendConfigurationL( |
|
622 *appODT, |
|
623 *pluginODT, |
|
624 configurationId, |
|
625 newPos, |
|
626 usedConfId, |
|
627 usedPluginId ); |
|
628 |
|
629 #ifdef HSPS_LOG_ACTIVE |
|
630 if( appODT && iLogBus ) |
|
631 { |
|
632 ChspsOdtDump::Dump( *appODT, *iLogBus ); |
|
633 } |
|
634 #endif |
|
635 |
|
636 // Stores the new application configuration into the repository |
|
637 if ( !err ) |
|
638 { |
|
639 err = iDefinitionRepository.SetOdtL( *appODT ); |
|
640 if ( err ) |
|
641 { |
|
642 #ifdef HSPS_LOG_ACTIVE |
|
643 if( iLogBus ) |
|
644 { |
|
645 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceAddPluginL(): - Updating failed with code: %d" ), err ); |
|
646 } |
|
647 #endif |
|
648 } |
|
649 } |
|
650 |
|
651 // Unlock after the changes have been done |
|
652 iDefinitionRepository.Unlock(); |
|
653 CleanupStack::Pop(&iDefinitionRepository); |
|
654 |
|
655 if ( !err ) |
|
656 { |
|
657 // Inform clients that the ODT has been modified |
|
658 ThspsRepositoryInfo info( |
|
659 ThspsRepositoryEvent(EhspsODTModified), |
|
660 appODT->RootUid(), |
|
661 appODT->ThemeUid(), |
|
662 aMessage.SecureId().iId, |
|
663 appODT->ProviderUid(), |
|
664 0, |
|
665 0, |
|
666 pluginUid,usedPluginId,ETrue, |
|
667 pluginODT->ThemeFullName(), |
|
668 (TLanguage)(appODT->OdtLanguage() ) ); |
|
669 iDefinitionRepository.RegisterNotification( info ); |
|
670 } |
|
671 } |
|
672 } |
|
673 |
|
674 // Cleaning |
|
675 if ( pluginODT ) |
|
676 { |
|
677 CleanupStack::PopAndDestroy( pluginODT ); |
|
678 pluginODT = NULL; |
|
679 } |
|
680 if ( appODT ) |
|
681 { |
|
682 CleanupStack::PopAndDestroy( appODT ); |
|
683 appODT = NULL; |
|
684 } |
|
685 |
|
686 // Error handling |
|
687 iResult->iXuikonError = err; |
|
688 if ( !err ) |
|
689 { |
|
690 // Get plugin configuration |
|
691 ret = EhspsAddPluginSuccess; |
|
692 } |
|
693 |
|
694 // Return id of the added plugin |
|
695 TPckg<TInt> packagedInt(usedPluginId); |
|
696 messagePtr.WriteL(2, packagedInt ); |
|
697 |
|
698 // Completion |
|
699 CompleteRequest( ret, messagePtr ); |
|
700 } |
|
701 |
|
702 // ----------------------------------------------------------------------------- |
|
703 // Finds last id value from the provided DOM. |
|
704 // ----------------------------------------------------------------------------- |
|
705 // |
|
706 void ChspsMaintenanceHandler::GetUsedIdsL( |
|
707 ChspsDomDocument& aDom, |
|
708 TInt& aLastUsedConfId, |
|
709 TInt& aLastUsedPluginId ) |
|
710 { |
|
711 aLastUsedConfId = 0; |
|
712 aLastUsedPluginId = 0; |
|
713 |
|
714 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *aDom.RootNode() ); |
|
715 CleanupStack::PushL( iter ); |
|
716 |
|
717 // Find a plugin node with an id attribute that matches the provided parent plugin id |
|
718 ChspsDomNode* node = iter->First(); |
|
719 while( node ) |
|
720 { |
|
721 const TDesC8& name = node->Name(); |
|
722 |
|
723 // A Configuration element was found |
|
724 if ( name == KConfigurationElement ) |
|
725 { |
|
726 // Get value of the id attribute (should exist) |
|
727 ChspsDomList& attrList = node->AttributeList(); |
|
728 ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KConfigurationAttrId) ); |
|
729 if ( !attr ) |
|
730 { |
|
731 #ifdef HSPS_LOG_ACTIVE |
|
732 if( iLogBus ) |
|
733 { |
|
734 iLogBus->LogText( _L( "ChspsMaintenanceHandler::GetUsedIdsL(): Id attribute is missing!" ) ); |
|
735 } |
|
736 #endif |
|
737 User::Leave( KErrCorrupt ); |
|
738 } |
|
739 |
|
740 TInt id(0); |
|
741 const TDesC8& idDesc = attr->Value(); |
|
742 TLex8 lex( idDesc ); |
|
743 if ( lex.Val( id ) ) |
|
744 { |
|
745 #ifdef HSPS_LOG_ACTIVE |
|
746 if( iLogBus ) |
|
747 { |
|
748 iLogBus->LogText( _L( "ChspsMaintenanceHandler::GetUsedIdsL(): Invalid id" ) ); |
|
749 } |
|
750 #endif |
|
751 User::Leave( KErrCorrupt ); |
|
752 } |
|
753 if ( id > aLastUsedConfId ) |
|
754 { |
|
755 aLastUsedConfId = id; |
|
756 } |
|
757 } |
|
758 |
|
759 // A Plugin element was found |
|
760 else if ( name == KPluginElement ) |
|
761 { |
|
762 // Get value of the id attribute (should exist) |
|
763 ChspsDomList& attrList = node->AttributeList(); |
|
764 ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KPluginAttrId) ); |
|
765 if ( !attr ) |
|
766 { |
|
767 #ifdef HSPS_LOG_ACTIVE |
|
768 if( iLogBus ) |
|
769 { |
|
770 iLogBus->LogText( _L( "ChspsMaintenanceHandler::GetUsedIdsL(): Id attribute is missing!" ) ); |
|
771 } |
|
772 #endif |
|
773 User::Leave( KErrCorrupt ); |
|
774 } |
|
775 |
|
776 TInt id(0); |
|
777 const TDesC8& idDesc = attr->Value(); |
|
778 TLex8 lex( idDesc ); |
|
779 if ( lex.Val( id ) ) |
|
780 { |
|
781 #ifdef HSPS_LOG_ACTIVE |
|
782 if( iLogBus ) |
|
783 { |
|
784 iLogBus->LogText( _L( "ChspsMaintenanceHandler::GetUsedIdsL(): Invalid id" ) ); |
|
785 } |
|
786 #endif |
|
787 User::Leave( KErrCorrupt ); |
|
788 } |
|
789 if ( id > aLastUsedPluginId ) |
|
790 { |
|
791 aLastUsedPluginId = id; |
|
792 } |
|
793 } |
|
794 node = iter->NextL(); |
|
795 } |
|
796 CleanupStack::PopAndDestroy( iter ); |
|
797 } |
|
798 |
|
799 // ----------------------------------------------------------------------------- |
|
800 // Appends an application configuration with an instance of a plugin configuration. |
|
801 // ----------------------------------------------------------------------------- |
|
802 // |
|
803 TInt ChspsMaintenanceHandler::AppendConfigurationL( |
|
804 ChspsODT& aAppODT, |
|
805 const ChspsODT& aPluginODT, |
|
806 const TInt aConfigurationId, |
|
807 const TInt aNewPosition, |
|
808 TInt& aConfId, |
|
809 TInt& aPluginId ) |
|
810 { |
|
811 TInt ret = KErrNone; |
|
812 |
|
813 // Input validation |
|
814 if ( aPluginODT.ConfigurationType() == EhspsAppConfiguration |
|
815 || aConfigurationId < 0 |
|
816 || aPluginODT.ThemeUid() < 1 |
|
817 || aConfId < 0 |
|
818 || aPluginId < 0 ) |
|
819 { |
|
820 return KErrArgument; |
|
821 } |
|
822 |
|
823 // Find a specific configuration node |
|
824 ChspsDomNode* confNode = hspsServerUtil::FindConfigurationNodeL( |
|
825 aAppODT, |
|
826 aConfigurationId ); |
|
827 if ( !confNode ) |
|
828 { |
|
829 return KErrNotFound; |
|
830 } |
|
831 |
|
832 // Find first plugins node under the searchFromNode node |
|
833 ChspsDomNode* pluginsNode = FindPluginsNode( *confNode ); |
|
834 if ( !pluginsNode ) |
|
835 { |
|
836 // If there is no plugins node, it means we cannot add plugins! |
|
837 return KErrAccessDenied; |
|
838 } |
|
839 |
|
840 // Find plugin references from the plugin configuration being added, |
|
841 // generate ids and update the plugin dom accordingly (changes are not saved) |
|
842 ret = HandlePluginReferencesL( |
|
843 aAppODT, |
|
844 (ChspsODT&)aPluginODT, |
|
845 aConfId, |
|
846 aPluginId ); |
|
847 if ( !ret ) |
|
848 { |
|
849 // Get new unique id |
|
850 aPluginId++; |
|
851 |
|
852 // Append the application configuration with the full plugin configuration dom |
|
853 ret = AppendPluginConfigurationL( |
|
854 aAppODT, |
|
855 *pluginsNode, |
|
856 aPluginODT, |
|
857 aNewPosition, |
|
858 aPluginId ); |
|
859 } |
|
860 |
|
861 return ret; |
|
862 } |
|
863 |
|
864 // ----------------------------------------------------------------------------- |
|
865 // Finds the plugins node of the provided plugin node. |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 ChspsDomNode* ChspsMaintenanceHandler::FindPluginsNode( |
|
869 ChspsDomNode& aPluginNode ) |
|
870 { |
|
871 ChspsDomNode* pluginsNode = NULL; |
|
872 ChspsDomNode* confNode = &aPluginNode; |
|
873 if ( aPluginNode.Name() != KConfigurationElement ) |
|
874 { |
|
875 ChspsDomList& childList = aPluginNode.ChildNodes(); |
|
876 confNode = (ChspsDomNode*)childList.FindByName( KConfigurationElement ); |
|
877 } |
|
878 if ( confNode ) |
|
879 { |
|
880 ChspsDomNode* controlNode = (ChspsDomNode*)confNode->ChildNodes().FindByName( KControlElement ); |
|
881 if ( controlNode ) |
|
882 { |
|
883 pluginsNode = (ChspsDomNode*)controlNode->ChildNodes().FindByName( KPluginsElement ); |
|
884 } |
|
885 } |
|
886 |
|
887 #ifdef HSPS_LOG_ACTIVE |
|
888 if ( !pluginsNode ) |
|
889 { |
|
890 if( iLogBus ) |
|
891 { |
|
892 iLogBus->LogText( _L( "ChspsMaintenanceHandler::FindPluginsNode(): failed to find a plugins node" ) ); |
|
893 } |
|
894 } |
|
895 #endif |
|
896 |
|
897 return pluginsNode; |
|
898 } |
|
899 |
|
900 // ----------------------------------------------------------------------------- |
|
901 // Appends a plugins list with a new plugin node |
|
902 // ----------------------------------------------------------------------------- |
|
903 // |
|
904 TInt ChspsMaintenanceHandler::AppendPluginConfigurationL( |
|
905 ChspsODT& aAppODT, |
|
906 ChspsDomNode& aPluginsNode, |
|
907 const ChspsODT& aPluginODT, |
|
908 const TInt aNewPosition, |
|
909 const TInt aNewPluginId ) |
|
910 { |
|
911 TInt err = KErrGeneral; |
|
912 |
|
913 // Input validation |
|
914 if ( aPluginODT.ThemeUid() < 1 || aNewPluginId < 1 ) |
|
915 { |
|
916 return KErrArgument; |
|
917 } |
|
918 |
|
919 // Find a node to be added, step over any optional xml elements |
|
920 // (start cloning from the configuration element onwards) |
|
921 ChspsDomDocument& appDom = aAppODT.DomDocument(); |
|
922 ChspsDomDepthIterator* pluginIter = ChspsDomDepthIterator::NewL( *aPluginODT.DomDocument().RootNode() ); |
|
923 CleanupStack::PushL( pluginIter ); |
|
924 ChspsDomNode* node = pluginIter->First(); |
|
925 TBool steppingtoConfNode(EFalse); |
|
926 while(node && !steppingtoConfNode) |
|
927 { |
|
928 const TDesC8& pluginNodeName = node->Name(); |
|
929 |
|
930 // Find the Configuration element |
|
931 if( pluginNodeName == KConfigurationElement ) |
|
932 { |
|
933 steppingtoConfNode=ETrue; |
|
934 } |
|
935 else |
|
936 { |
|
937 node = pluginIter->NextL(); |
|
938 } |
|
939 } |
|
940 CleanupStack::PopAndDestroy( pluginIter ); |
|
941 |
|
942 if ( node ) |
|
943 { |
|
944 // The node instance should now hold the configuration element etc |
|
945 ChspsDomNode* confNode = node->CloneL( aPluginsNode.StringPool()); |
|
946 CleanupStack::PushL( confNode ); |
|
947 |
|
948 // Create a new plugin node with mandatory attributes |
|
949 ChspsDomNode* pluginNode = appDom.CreateElementNSL( |
|
950 KPluginElement, |
|
951 aPluginsNode.Namespace() |
|
952 ); |
|
953 CleanupStack::PushL( pluginNode ); |
|
954 |
|
955 // Attach to the plugin node |
|
956 pluginNode->AddChildL( confNode ); |
|
957 confNode->SetParent( pluginNode ); |
|
958 |
|
959 // Set attributes of the plugin node |
|
960 hspsServerUtil::AddAttributeNumericL( *pluginNode, KPluginAttrId, aNewPluginId ); |
|
961 hspsServerUtil::AddAttributeNumericL( *pluginNode, KPluginAttrUid, aPluginODT.ThemeUid(), EHex ); |
|
962 |
|
963 // Add active attribute. |
|
964 // If first plugin in list, then set as active. |
|
965 // Otherwise other plugin should already be active at this level. |
|
966 if( aPluginsNode.ChildNodes().Length() == 0 ) |
|
967 { |
|
968 hspsServerUtil::AddAttributeDescL( *pluginNode, KPluginAttrActive, KPluginActiveStateActive ); |
|
969 } |
|
970 else |
|
971 { |
|
972 hspsServerUtil::AddAttributeDescL( *pluginNode, KPluginAttrActive, KPluginActiveStateNotActive ); |
|
973 } |
|
974 |
|
975 // Also make sure that if new node has child nodes, that they get active parameter also. |
|
976 hspsServerUtil::EditPluginNodeActivityL( pluginNode, |
|
977 hspsServerUtil::EActivateFirst ); |
|
978 |
|
979 // Check when to insert and when to add to the end |
|
980 if ( aNewPosition < 0 || aNewPosition >= aPluginsNode.ChildNodes().Length() ) |
|
981 { |
|
982 // Append the plugin node to the end |
|
983 aPluginsNode.AddChildL( pluginNode ); |
|
984 } |
|
985 else |
|
986 { |
|
987 // Insert the plugin node to the position |
|
988 aPluginsNode.AddChildL( pluginNode, aNewPosition ); |
|
989 } |
|
990 pluginNode->SetParent( &aPluginsNode ); |
|
991 |
|
992 CleanupStack::Pop( pluginNode ); |
|
993 CleanupStack::Pop( confNode ); |
|
994 err = KErrNone; |
|
995 } |
|
996 |
|
997 return err; |
|
998 } |
|
999 |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // ----------------------------------------------------------------------------- |
|
1002 // ChspsMaintenanceHandler::HandlePluginReferencesL() |
|
1003 // ImportPlugins phase. |
|
1004 // ----------------------------------------------------------------------------- |
|
1005 // |
|
1006 TInt ChspsMaintenanceHandler::HandlePluginReferencesL( |
|
1007 ChspsODT& aAppODT, |
|
1008 ChspsODT& aPluginODT, |
|
1009 TInt& aLastConfId, |
|
1010 TInt& aLastPluginId ) |
|
1011 { |
|
1012 |
|
1013 ChspsDomDocument& pluginDom = aPluginODT.DomDocument(); |
|
1014 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *pluginDom.RootNode() ); |
|
1015 CleanupStack::PushL( iter ); |
|
1016 |
|
1017 // Each configuration element get's an unique id value - same applies to the plugin elements. |
|
1018 // The ids are then used to reference a specific configuration or plugin instance |
|
1019 // in the whole application configuration |
|
1020 |
|
1021 ChspsDomNode* node = iter->First(); |
|
1022 while( node ) |
|
1023 { |
|
1024 const TDesC8& name = node->Name(); |
|
1025 |
|
1026 // Configuration element |
|
1027 if ( name == KConfigurationElement ) |
|
1028 { |
|
1029 // Generate an ID attribute for the configuration element |
|
1030 aLastConfId++; |
|
1031 hspsServerUtil::AddAttributeNumericL( *node, KConfigurationAttrId, aLastConfId ); |
|
1032 } |
|
1033 |
|
1034 // Plugin element |
|
1035 else if ( name == KPluginElement ) |
|
1036 { |
|
1037 // Check parent element |
|
1038 ChspsDomNode* parentNode = node->Parent(); |
|
1039 const TDesC8& parentName = parentNode->Name(); |
|
1040 if( parentName == KPluginsElement ) |
|
1041 { |
|
1042 ChspsDomList& attrList = node->AttributeList(); |
|
1043 |
|
1044 // Get configuration attribute from the plugin configuration |
|
1045 ChspsDomAttribute* pluginUidAttr = |
|
1046 static_cast<ChspsDomAttribute*> ( attrList.FindByName(KPluginAttrUid) ); |
|
1047 if( !pluginUidAttr ) |
|
1048 { |
|
1049 #ifdef HSPS_LOG_ACTIVE |
|
1050 if( iLogBus ) |
|
1051 { |
|
1052 iLogBus->LogText( _L( "ChspsMaintenanceHandler::HandlePluginReferencesL(): - Invalid XML" ) ); |
|
1053 } |
|
1054 #endif |
|
1055 User::Leave( KErrCorrupt ); |
|
1056 } |
|
1057 |
|
1058 // Convert uids from string to numeric format |
|
1059 const TDesC8& pluginUidValue = pluginUidAttr->Value(); |
|
1060 const TUid pluginUid = hspsServerUtil::ConvertDescIntoUid(pluginUidValue); |
|
1061 |
|
1062 // Get plugin configuration |
|
1063 ChspsODT* pluginOdt = ChspsODT::NewL(); |
|
1064 CleanupStack::PushL( pluginOdt ); |
|
1065 TInt err = iThemeServer.GetConfigurationL( |
|
1066 0, |
|
1067 pluginUid.iUid, |
|
1068 *pluginOdt ); |
|
1069 if ( err ) |
|
1070 { |
|
1071 #ifdef HSPS_LOG_ACTIVE |
|
1072 if( iLogBus ) |
|
1073 { |
|
1074 iLogBus->LogText( _L( "ChspsMaintenanceHandler::HandlePluginReferencesL(): - Failed to find a plugin" ) ); |
|
1075 } |
|
1076 #endif |
|
1077 |
|
1078 // Append an empty configuration with error status |
|
1079 AddErrorConfigurationL( |
|
1080 pluginDom, |
|
1081 *node, |
|
1082 pluginUid.iUid ); |
|
1083 |
|
1084 // Generate an ID attribute for the plugin element |
|
1085 aLastPluginId++; |
|
1086 hspsServerUtil::AddAttributeNumericL( *node, KPluginAttrId, aLastPluginId ); |
|
1087 } |
|
1088 else |
|
1089 { |
|
1090 // Set value of the ID attribute |
|
1091 aLastPluginId++; |
|
1092 hspsServerUtil::AddAttributeNumericL( *node, KPluginAttrId, aLastPluginId ); |
|
1093 |
|
1094 |
|
1095 // Copy resources of the referenced plug-in instance to the application configuration |
|
1096 TInt resourceCount = pluginOdt->ResourceCount(); |
|
1097 for ( TInt index=0; index < resourceCount; index++ ) |
|
1098 { |
|
1099 ChspsResource& pluginResource = pluginOdt->ResourceL(index); |
|
1100 // Add only those that are located under the sources folder |
|
1101 if ( pluginResource.FileName().FindF( KSourcesFolder ) > 0 |
|
1102 || pluginResource.FileName().FindF( KLocalesFolder ) > 0 ) |
|
1103 |
|
1104 { |
|
1105 ChspsResource* r = pluginResource.CloneL(); |
|
1106 CleanupStack::PushL( r ); |
|
1107 aAppODT.AddResourceL( r ); |
|
1108 CleanupStack::Pop( r ); |
|
1109 } |
|
1110 } |
|
1111 |
|
1112 ChspsDomDocument& document = pluginOdt->DomDocument(); |
|
1113 if ( !document.RootNode() ) |
|
1114 { |
|
1115 User::Leave( KErrGeneral ); |
|
1116 } |
|
1117 |
|
1118 // Find the KConfigurationElement to step over any optional xml elements |
|
1119 ChspsDomDepthIterator* pluginIter = ChspsDomDepthIterator::NewL( *document.RootNode() ); |
|
1120 CleanupStack::PushL( pluginIter ); |
|
1121 ChspsDomNode* pluginNode = pluginIter->First(); |
|
1122 TBool steppingtoConfNode(EFalse); |
|
1123 while(pluginNode && !steppingtoConfNode) |
|
1124 { |
|
1125 const TDesC8& pluginNodeName = pluginNode->Name(); |
|
1126 |
|
1127 if( pluginNodeName == KConfigurationElement ) |
|
1128 { |
|
1129 steppingtoConfNode=ETrue; |
|
1130 } |
|
1131 else |
|
1132 { |
|
1133 pluginNode = pluginIter->NextL(); |
|
1134 } |
|
1135 } |
|
1136 CleanupStack::PopAndDestroy( pluginIter ); |
|
1137 |
|
1138 // Copy the plugin configuration to the main document. |
|
1139 ChspsDomNode* rootCopy = pluginNode->CloneL( node->StringPool()); |
|
1140 rootCopy->SetParent( node ); |
|
1141 node->AddChildL( rootCopy ); |
|
1142 } |
|
1143 |
|
1144 CleanupStack::PopAndDestroy( pluginOdt ); |
|
1145 } |
|
1146 } |
|
1147 node = iter->NextL(); |
|
1148 } |
|
1149 CleanupStack::PopAndDestroy( iter ); |
|
1150 |
|
1151 // Copy resources of the plugin to the application configuration |
|
1152 TInt resourceCount = aPluginODT.ResourceCount(); |
|
1153 for ( TInt index=0; index < resourceCount; index++ ) |
|
1154 { |
|
1155 ChspsResource& pluginResource = aPluginODT.ResourceL(index); |
|
1156 |
|
1157 // Add only those that are located under the sources folder |
|
1158 if ( pluginResource.FileName().FindF( KSourcesFolder ) > 0 |
|
1159 || pluginResource.FileName().FindF( KLocalesFolder ) > 0 ) |
|
1160 { |
|
1161 ChspsResource* r = pluginResource.CloneL(); |
|
1162 CleanupStack::PushL( r ); |
|
1163 aAppODT.AddResourceL( r ); |
|
1164 CleanupStack::Pop( r ); |
|
1165 } |
|
1166 } |
|
1167 |
|
1168 return KErrNone; |
|
1169 } |
|
1170 |
|
1171 |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // Service for removing a plugin |
|
1174 // ----------------------------------------------------------------------------- |
|
1175 // |
|
1176 void ChspsMaintenanceHandler::ServiceRemovePluginL( const RMessage2& aMessage ) |
|
1177 { |
|
1178 // Defaults |
|
1179 ThspsServiceCompletedMessage ret = EhspsRemovePluginFailed; |
|
1180 iResult->iXuikonError = KErrNotFound; |
|
1181 TInt err = KErrNone; |
|
1182 |
|
1183 // Parameters |
|
1184 RMessagePtr2 messagePtr = aMessage; |
|
1185 |
|
1186 // IPC slots: |
|
1187 // #0) output: externalized ChspsResult for error handling |
|
1188 // #1) input: ThpsParamRemovePlugin struct |
|
1189 |
|
1190 // Get service parameters from IPC slot #1 |
|
1191 ThpsParamRemovePlugin params; |
|
1192 TPckg<ThpsParamRemovePlugin> packagedStruct(params); |
|
1193 aMessage.ReadL(1, packagedStruct); |
|
1194 const TInt appUid = params.appUid; |
|
1195 const TInt pluginId = params.pluginId; |
|
1196 |
|
1197 if ( pluginId < 1 ) |
|
1198 { |
|
1199 err = KErrArgument; |
|
1200 } |
|
1201 |
|
1202 // Application configuration |
|
1203 ChspsODT *appODT = NULL; |
|
1204 if ( !err ) |
|
1205 { |
|
1206 // Get active application configuration from the central repository |
|
1207 TInt appConfUid; |
|
1208 err = iCentralRepository.Get( appUid, appConfUid ); |
|
1209 if ( err || appConfUid < 1 ) |
|
1210 { |
|
1211 err = KErrNotFound; |
|
1212 } |
|
1213 else |
|
1214 { |
|
1215 appODT = ChspsODT::NewL(); |
|
1216 CleanupStack::PushL( appODT ); |
|
1217 err = iThemeServer.GetConfigurationL( |
|
1218 appUid, |
|
1219 appConfUid, |
|
1220 *appODT ); |
|
1221 } |
|
1222 } |
|
1223 |
|
1224 // Modifications |
|
1225 if ( !err ) |
|
1226 { |
|
1227 if ( iDefinitionRepository.Locked() ) |
|
1228 { |
|
1229 // Repository locked |
|
1230 err = KErrAccessDenied; |
|
1231 } |
|
1232 else |
|
1233 { |
|
1234 TInt pluginUid; |
|
1235 TBuf<KMaxFileName> pluginName; |
|
1236 err = GetConfigurationNodeDataL(*appODT, |
|
1237 pluginId,pluginUid, pluginName); |
|
1238 // Lock the Plugin Repository (a.k.a. Def.rep) |
|
1239 iDefinitionRepository.Lock(); |
|
1240 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
1241 if( !err ) |
|
1242 { |
|
1243 // Remove the plugin configuration from the application configuration |
|
1244 err = RemoveConfigurationL( |
|
1245 *appODT, |
|
1246 pluginId ); |
|
1247 } |
|
1248 if ( !err ) |
|
1249 { |
|
1250 |
|
1251 #ifdef HSPS_LOG_ACTIVE |
|
1252 if( appODT && iLogBus ) |
|
1253 { |
|
1254 ChspsOdtDump::Dump( *appODT, *iLogBus ); |
|
1255 } |
|
1256 #endif |
|
1257 // Stores the new application configuration into the repository |
|
1258 err = iDefinitionRepository.SetOdtL( *appODT ); |
|
1259 if ( err ) |
|
1260 { |
|
1261 #ifdef HSPS_LOG_ACTIVE |
|
1262 if( iLogBus ) |
|
1263 { |
|
1264 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceRemovePluginL(): - Updating failed" ) ); |
|
1265 } |
|
1266 #endif |
|
1267 } |
|
1268 } |
|
1269 |
|
1270 // Unlock after the changes have been done |
|
1271 iDefinitionRepository.Unlock(); |
|
1272 CleanupStack::Pop(&iDefinitionRepository); |
|
1273 |
|
1274 if ( !err ) |
|
1275 { |
|
1276 // Inform clients that the ODT has been modified |
|
1277 ThspsRepositoryInfo info( |
|
1278 ThspsRepositoryEvent(EhspsODTRemoved), |
|
1279 appODT->RootUid(), |
|
1280 appODT->ThemeUid(), |
|
1281 aMessage.SecureId().iId, |
|
1282 appODT->ProviderUid(), |
|
1283 0,0, |
|
1284 pluginUid,pluginId,ETrue, |
|
1285 pluginName, |
|
1286 (TLanguage)(appODT->OdtLanguage()) |
|
1287 ); |
|
1288 iDefinitionRepository.RegisterNotification( info ); |
|
1289 } |
|
1290 } |
|
1291 } |
|
1292 |
|
1293 // Cleaning |
|
1294 if ( appODT ) |
|
1295 { |
|
1296 CleanupStack::PopAndDestroy( appODT ); |
|
1297 appODT = NULL; |
|
1298 } |
|
1299 |
|
1300 // Error handling |
|
1301 iResult->iXuikonError = err; |
|
1302 if ( !err ) |
|
1303 { |
|
1304 ret = EhspsRemovePluginSuccess; |
|
1305 } |
|
1306 |
|
1307 // Completion |
|
1308 CompleteRequest( ret, messagePtr ); |
|
1309 } |
|
1310 |
|
1311 // ----------------------------------------------------------------------------- |
|
1312 // Service for setting plugin active. |
|
1313 // ----------------------------------------------------------------------------- |
|
1314 // |
|
1315 void ChspsMaintenanceHandler::ServiceSetActivePluginL( const RMessage2& aMessage ) |
|
1316 { |
|
1317 // Init output parameters. |
|
1318 iResult->ResetData(); |
|
1319 |
|
1320 // Read input parameters. |
|
1321 ThpsParamSetActivePlugin params; |
|
1322 TPckg<ThpsParamSetActivePlugin> packagedStruct( params ); |
|
1323 aMessage.ReadL( 1, packagedStruct ); |
|
1324 |
|
1325 // Get uid of active application configuration. |
|
1326 TInt appConfUid = 0; |
|
1327 TInt err = iCentralRepository.Get( params.appUid, appConfUid ); |
|
1328 if ( err != KErrNone || appConfUid < 1 ) |
|
1329 { |
|
1330 err = KErrNotFound; |
|
1331 } |
|
1332 |
|
1333 // Load configuration from repository. |
|
1334 ChspsODT* appODT = NULL; |
|
1335 if( err == KErrNone ) |
|
1336 { |
|
1337 appODT = ChspsODT::NewL(); |
|
1338 CleanupStack::PushL( appODT ); |
|
1339 err = iThemeServer.GetConfigurationL( |
|
1340 params.appUid, |
|
1341 appConfUid, |
|
1342 *appODT ); |
|
1343 } |
|
1344 |
|
1345 // Initialize notification structure. |
|
1346 ThspsRepositoryInfo notification( EhspsPluginActivated ); |
|
1347 if( err == KErrNone && appODT ) |
|
1348 { |
|
1349 notification.iAppUid = appODT->RootUid(); |
|
1350 notification.iAppConfUid = appODT->ThemeUid(); |
|
1351 notification.iSecureId = 0; |
|
1352 notification.iAppConfProviderUid = 0; |
|
1353 notification.iPluginIfUid = 0; |
|
1354 notification.iPluginProviderUid = 0; |
|
1355 notification.iPluginUid = 0; |
|
1356 notification.iPluginId = 0; |
|
1357 notification.iLastNotification = ETrue; |
|
1358 notification.iName = KNullDesC(); |
|
1359 notification.iLanguage = ELangTest; |
|
1360 } |
|
1361 |
|
1362 // Find required node and set it active. |
|
1363 if( err == KErrNone ) |
|
1364 { |
|
1365 // Find a plugin node with the provided id. |
|
1366 ChspsDomNode* pluginNode = hspsServerUtil::FindPluginNodeL( *appODT, |
|
1367 params.pluginId ); |
|
1368 if ( pluginNode ) |
|
1369 { |
|
1370 // Get parent node. |
|
1371 ChspsDomNode* parentNode = pluginNode->Parent(); |
|
1372 if ( parentNode ) |
|
1373 { |
|
1374 // Deactivate all plugins at defined level. Do not recurse. |
|
1375 const TInt KDepth = 1; |
|
1376 hspsServerUtil::EditPluginNodeActivityL( parentNode, |
|
1377 hspsServerUtil::EDeactivateAll, |
|
1378 KDepth ); |
|
1379 |
|
1380 // Activate defined plugin. |
|
1381 hspsServerUtil::AddAttributeDescL( *pluginNode, |
|
1382 KPluginAttrActive, |
|
1383 KPluginActiveStateActive ); |
|
1384 |
|
1385 // Fill notification up2date. |
|
1386 notification.iPluginUid = hspsServerUtil::GetPluginUid( pluginNode ).iUid; |
|
1387 notification.iPluginId = hspsServerUtil::GetPluginId( pluginNode ); |
|
1388 } |
|
1389 else |
|
1390 { |
|
1391 err = KErrCorrupt; |
|
1392 } |
|
1393 } |
|
1394 else |
|
1395 { |
|
1396 err = KErrNotFound; |
|
1397 } |
|
1398 } |
|
1399 |
|
1400 if( err == KErrNone ) |
|
1401 { |
|
1402 if ( iDefinitionRepository.Locked() ) |
|
1403 { |
|
1404 // Repository locked |
|
1405 err = KErrAccessDenied; |
|
1406 } |
|
1407 } |
|
1408 |
|
1409 if( err == KErrNone ) |
|
1410 { |
|
1411 // Lock and push to cleanup stack. |
|
1412 iDefinitionRepository.Lock(); |
|
1413 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
1414 |
|
1415 // Stores the new application configuration into the repository |
|
1416 err = iDefinitionRepository.SetOdtL( *appODT ); |
|
1417 |
|
1418 // Unlock and remove from cleanupstack. |
|
1419 iDefinitionRepository.Unlock(); |
|
1420 CleanupStack::Pop( &iDefinitionRepository ); |
|
1421 } |
|
1422 |
|
1423 // Notify. |
|
1424 if( err == KErrNone ) |
|
1425 { |
|
1426 iDefinitionRepository.RegisterNotification( notification ); |
|
1427 } |
|
1428 |
|
1429 // Set output parameter values and complete request. |
|
1430 iResult->iSystemError = err; |
|
1431 iResult->iXuikonError = err; |
|
1432 |
|
1433 // Complete the message. |
|
1434 RMessagePtr2 messagePtr = aMessage; |
|
1435 if( err == KErrNone ) |
|
1436 { |
|
1437 CompleteRequest( EhspsSetActivePluginSuccess, messagePtr ); |
|
1438 } |
|
1439 else |
|
1440 { |
|
1441 CompleteRequest( EhspsSetActivePluginFailed, messagePtr ); |
|
1442 } |
|
1443 |
|
1444 #ifdef HSPS_LOG_ACTIVE |
|
1445 if( iLogBus ) |
|
1446 { |
|
1447 ChspsOdtDump::Dump( *appODT, *iLogBus ); |
|
1448 } |
|
1449 #endif |
|
1450 |
|
1451 // Cleanup. |
|
1452 if ( appODT ) |
|
1453 { |
|
1454 CleanupStack::PopAndDestroy( appODT ); |
|
1455 appODT = NULL; |
|
1456 } |
|
1457 |
|
1458 #ifdef HSPS_LOG_ACTIVE |
|
1459 if( iLogBus ) |
|
1460 { |
|
1461 if( err == KErrNone ) |
|
1462 { |
|
1463 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceSetActivePluginL: - OK" ) ); |
|
1464 } |
|
1465 else |
|
1466 { |
|
1467 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceSetActivePluginL: - Error" ) ); |
|
1468 } |
|
1469 } |
|
1470 #endif |
|
1471 } |
|
1472 |
|
1473 // ----------------------------------------------------------------------------- |
|
1474 // Get plugin's configuration node attributes(plugin name, pluginUid ) |
|
1475 // Can expanded to get configuration Id and plugin type also |
|
1476 // ----------------------------------------------------------------------------- |
|
1477 // |
|
1478 TInt ChspsMaintenanceHandler::GetConfigurationNodeDataL( |
|
1479 ChspsODT& aAppODT, |
|
1480 const TInt aPluginId, |
|
1481 TInt& aPluginUid, |
|
1482 TDes& aPluginName ) |
|
1483 { |
|
1484 TInt err = KErrNotFound; |
|
1485 ChspsDomNode *node = hspsServerUtil::FindPluginNodeL( aAppODT, aPluginId ); |
|
1486 if ( node ) |
|
1487 { |
|
1488 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *node ); |
|
1489 CleanupStack::PushL( iter ); |
|
1490 |
|
1491 // Find a configuration node with an id attribute that matches the provided id |
|
1492 ChspsDomNode* node2 = iter->First(); |
|
1493 TBool jobDone = EFalse; |
|
1494 while( node2 && !jobDone ) |
|
1495 { |
|
1496 const TDesC8& name = node2->Name(); |
|
1497 |
|
1498 // An element was found |
|
1499 if ( name == KConfigurationElement ) |
|
1500 { |
|
1501 TInt pluginUid = 0; |
|
1502 TBuf<KMaxFileName> pluginName; |
|
1503 ChspsDomList& attrList = node2->AttributeList(); |
|
1504 ChspsDomAttribute* pluginUidAttr = |
|
1505 static_cast<ChspsDomAttribute*> ( attrList.FindByName(KConfigurationAttrUid) ); |
|
1506 if( !pluginUidAttr ) |
|
1507 { |
|
1508 #ifdef HSPS_LOG_ACTIVE |
|
1509 if( iLogBus ) |
|
1510 { |
|
1511 iLogBus->LogText( _L( "ChspsMaintenanceHandler::GetConfigurationNodeDataL(): - Invalid XML" ) ); |
|
1512 } |
|
1513 #endif |
|
1514 err = KErrGeneral; |
|
1515 } |
|
1516 else |
|
1517 { |
|
1518 // Convert uids from string to numeric format |
|
1519 const TDesC8& pluginUidValue = pluginUidAttr->Value(); |
|
1520 const TUid uid = hspsServerUtil::ConvertDescIntoUid(pluginUidValue); |
|
1521 if ( uid.iUid > 0 ) |
|
1522 { |
|
1523 pluginUid = uid.iUid; |
|
1524 // Override default status |
|
1525 err = KErrNone; |
|
1526 } |
|
1527 } |
|
1528 if( !err ) |
|
1529 { |
|
1530 ChspsDomAttribute* pluginUidNameAttr = |
|
1531 static_cast<ChspsDomAttribute*> ( attrList.FindByName(KConfigurationAttrName) ); |
|
1532 if( !pluginUidNameAttr ) |
|
1533 { |
|
1534 #ifdef HSPS_LOG_ACTIVE |
|
1535 if( iLogBus ) |
|
1536 { |
|
1537 iLogBus->LogText( _L( "ChspsMaintenanceHandler::GetConfigurationNodeDataL(): - Invalid XML" ) ); |
|
1538 } |
|
1539 #endif |
|
1540 err = KErrGeneral; |
|
1541 } |
|
1542 else |
|
1543 { |
|
1544 // Convert uids from string to numeric format |
|
1545 const TDesC8& pluginNameValue = pluginUidNameAttr->Value(); |
|
1546 if ( pluginNameValue.Length() > 0 ) |
|
1547 { |
|
1548 pluginName.Copy( pluginNameValue ); |
|
1549 err = KErrNone; |
|
1550 } |
|
1551 } |
|
1552 } |
|
1553 if( !err ) |
|
1554 { |
|
1555 aPluginUid = pluginUid; |
|
1556 aPluginName.Copy( pluginName ); |
|
1557 jobDone = ETrue; |
|
1558 } |
|
1559 } |
|
1560 node2 = iter->NextL(); |
|
1561 } |
|
1562 CleanupStack::PopAndDestroy( iter ); |
|
1563 } |
|
1564 |
|
1565 |
|
1566 return err; |
|
1567 } |
|
1568 |
|
1569 // ----------------------------------------------------------------------------- |
|
1570 // ChspsMaintenanceHandler::ServiceReplacePluginL() |
|
1571 // ----------------------------------------------------------------------------- |
|
1572 // |
|
1573 void ChspsMaintenanceHandler::ServiceReplacePluginL( const RMessage2& aMessage ) |
|
1574 { |
|
1575 // Defaults |
|
1576 ThspsServiceCompletedMessage ret = EhspsReplacePluginFailed; |
|
1577 iResult->iXuikonError = KErrNotFound; |
|
1578 TInt err = KErrNone; |
|
1579 |
|
1580 // Parameters |
|
1581 RMessagePtr2 messagePtr = aMessage; |
|
1582 |
|
1583 // IPC slots: |
|
1584 // #0) output: externalized ChspsResult for error handling |
|
1585 // #1) input: ThpsParamReplacePlugin struct |
|
1586 ThspsParamReplacePlugin params; |
|
1587 TPckg<ThspsParamReplacePlugin> packagedStruct(params); |
|
1588 aMessage.ReadL(1, packagedStruct); |
|
1589 const TInt appUid( params.appUid ); |
|
1590 const TInt pluginId( params.pluginId ); |
|
1591 const TInt confUid( params.confUid ); |
|
1592 if ( pluginId < 1 || confUid < 1 ) |
|
1593 { |
|
1594 err = KErrArgument; |
|
1595 } |
|
1596 |
|
1597 // Application configuration |
|
1598 ChspsODT *appODT = NULL; |
|
1599 if ( !err ) |
|
1600 { |
|
1601 // Get active application configuration from the central repository |
|
1602 TInt appConfUid; |
|
1603 err = iCentralRepository.Get( appUid, appConfUid ); |
|
1604 if ( err || appConfUid < 1 ) |
|
1605 { |
|
1606 err = KErrNotFound; |
|
1607 } |
|
1608 else |
|
1609 { |
|
1610 appODT = ChspsODT::NewL(); |
|
1611 CleanupStack::PushL( appODT ); |
|
1612 err = iThemeServer.GetConfigurationL( |
|
1613 appUid, |
|
1614 appConfUid, |
|
1615 *appODT ); |
|
1616 } |
|
1617 } |
|
1618 |
|
1619 // Plugin configuration |
|
1620 ChspsODT *pluginODT = NULL; |
|
1621 if ( !err ) |
|
1622 { |
|
1623 // Find the plugin configuration (interface is unknown, so 1st argument is set to zero) |
|
1624 pluginODT = ChspsODT::NewL(); |
|
1625 CleanupStack::PushL( pluginODT ); |
|
1626 err = iThemeServer.GetConfigurationL( |
|
1627 0, |
|
1628 confUid, |
|
1629 *pluginODT ); |
|
1630 } |
|
1631 |
|
1632 // Check needed space for replace. Returns system wide error code. |
|
1633 if( !err ) |
|
1634 { |
|
1635 err = hspsServerUtil::EnoughDiskSpaceAvailableL( |
|
1636 *pluginODT, |
|
1637 iThemeServer.DeviceLanguage(), |
|
1638 iServerSession->FileSystem(), |
|
1639 EDriveC, |
|
1640 KAdditionalRequiredDiskSpace ); |
|
1641 } |
|
1642 |
|
1643 // Modifications |
|
1644 if ( !err ) |
|
1645 { |
|
1646 if ( iDefinitionRepository.Locked() ) |
|
1647 { |
|
1648 // Repository locked |
|
1649 err = KErrAccessDenied; |
|
1650 } |
|
1651 else |
|
1652 { |
|
1653 // Lock the Plugin Repository (a.k.a. Def.rep) |
|
1654 iDefinitionRepository.Lock(); |
|
1655 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
1656 |
|
1657 // Remove the plugin configuration from the application configuration |
|
1658 err = ReplaceConfigurationL( |
|
1659 *appODT, |
|
1660 pluginId, |
|
1661 *pluginODT ); |
|
1662 if ( !err ) |
|
1663 { |
|
1664 |
|
1665 #ifdef HSPS_LOG_ACTIVE |
|
1666 if( appODT && iLogBus ) |
|
1667 { |
|
1668 ChspsOdtDump::Dump( *appODT, *iLogBus ); |
|
1669 } |
|
1670 #endif |
|
1671 // Stores the new application configuration into the repository |
|
1672 err = iDefinitionRepository.SetOdtL( *appODT ); |
|
1673 // Unlock after the changes have been done |
|
1674 iDefinitionRepository.Unlock(); |
|
1675 if ( err ) |
|
1676 { |
|
1677 #ifdef HSPS_LOG_ACTIVE |
|
1678 if( iLogBus ) |
|
1679 { |
|
1680 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceReplacePluginL(): - Updating failed" ) ); |
|
1681 } |
|
1682 #endif |
|
1683 } |
|
1684 else |
|
1685 { |
|
1686 // Inform clients that the ODT has been modified |
|
1687 ThspsRepositoryInfo info( |
|
1688 ThspsRepositoryEvent(EhspsPluginReplaced), |
|
1689 appODT->RootUid(), |
|
1690 appODT->ThemeUid(), |
|
1691 aMessage.SecureId().iId, |
|
1692 0, |
|
1693 0, |
|
1694 0, |
|
1695 confUid, |
|
1696 pluginId, |
|
1697 ETrue, |
|
1698 KNullDesC(), |
|
1699 (TLanguage)(appODT->OdtLanguage()) |
|
1700 ); |
|
1701 iDefinitionRepository.RegisterNotification( info ); |
|
1702 } |
|
1703 } |
|
1704 else |
|
1705 { |
|
1706 // Unlock repository |
|
1707 iDefinitionRepository.Unlock(); |
|
1708 } |
|
1709 |
|
1710 CleanupStack::Pop(&iDefinitionRepository); |
|
1711 } |
|
1712 } |
|
1713 |
|
1714 // Cleaning |
|
1715 if ( pluginODT ) |
|
1716 { |
|
1717 CleanupStack::PopAndDestroy( pluginODT ); |
|
1718 } |
|
1719 if ( appODT ) |
|
1720 { |
|
1721 CleanupStack::PopAndDestroy( appODT ); |
|
1722 appODT = NULL; |
|
1723 } |
|
1724 |
|
1725 // Error handling |
|
1726 iResult->iXuikonError = err; |
|
1727 if ( !err ) |
|
1728 { |
|
1729 ret = EhspsReplacePluginSuccess; |
|
1730 } |
|
1731 |
|
1732 // Completion |
|
1733 CompleteRequest( ret, messagePtr ); |
|
1734 } |
|
1735 |
|
1736 // ----------------------------------------------------------------------------- |
|
1737 // ChspsMaintenanceHandler::ReplaceConfigurationL() |
|
1738 // ----------------------------------------------------------------------------- |
|
1739 // |
|
1740 TInt ChspsMaintenanceHandler::ReplaceConfigurationL( |
|
1741 ChspsODT& aAppODT, |
|
1742 const TInt aPluginId, |
|
1743 const ChspsODT& aPluginODT ) |
|
1744 { |
|
1745 // Input validation |
|
1746 if ( aAppODT.ConfigurationType() != EhspsAppConfiguration |
|
1747 || aAppODT.ThemeUid() < 1 |
|
1748 || aPluginId < 1 |
|
1749 || aPluginODT.ConfigurationType() == EhspsAppConfiguration |
|
1750 || aPluginODT.ThemeUid() < 1 ) |
|
1751 { |
|
1752 return KErrArgument; |
|
1753 } |
|
1754 |
|
1755 TInt err = KErrNotFound; |
|
1756 |
|
1757 // Find a plugin node with the provided plugin id |
|
1758 ChspsDomNode* pluginNode = hspsServerUtil::FindPluginNodeL( aAppODT, aPluginId); |
|
1759 if ( pluginNode ) |
|
1760 { |
|
1761 ChspsDomNode* pluginsNode = pluginNode->Parent(); |
|
1762 |
|
1763 // Get current position in the plugins list |
|
1764 TInt currentPosition = FindPluginPosition( *pluginNode ); |
|
1765 if ( currentPosition < 0 ) |
|
1766 { |
|
1767 User::Leave( KErrGeneral ); |
|
1768 } |
|
1769 |
|
1770 // Get configuration id from existing configuration |
|
1771 ChspsDomNode* oldConfNode = (ChspsDomNode *)pluginNode->ChildNodes().Item( 0 ); |
|
1772 if ( !oldConfNode ) |
|
1773 { |
|
1774 User::Leave( KErrGeneral ); |
|
1775 } |
|
1776 ChspsDomList& attrList = oldConfNode->AttributeList(); |
|
1777 ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KConfigurationAttrId) ); |
|
1778 if ( !attr ) |
|
1779 { |
|
1780 User::Leave( KErrGeneral ); |
|
1781 } |
|
1782 const TInt oldConfId = hspsServerUtil::DecString2Int( attr->Value() ); |
|
1783 oldConfNode = 0; |
|
1784 |
|
1785 // Remove old plugin configuration instance and it's resources from the application configuration |
|
1786 err = RemoveConfigurationL( aAppODT, aPluginId ); |
|
1787 if ( err ) |
|
1788 { |
|
1789 User::Leave( KErrGeneral ); |
|
1790 } |
|
1791 pluginNode = 0; |
|
1792 |
|
1793 // Find configuration node from the plugin ODT |
|
1794 ChspsDomNode* confNode = aPluginODT.DomDocument().RootNode(); |
|
1795 if ( confNode->Name().CompareF(KConfigurationElement) != 0 ) |
|
1796 { |
|
1797 User::Leave( KErrGeneral ); |
|
1798 } |
|
1799 |
|
1800 // Add configuration id attribute |
|
1801 hspsServerUtil::AddAttributeNumericL( *confNode, KConfigurationAttrId, oldConfId ); |
|
1802 |
|
1803 // Append new plugin configuration node to the application configuration |
|
1804 err = AppendPluginConfigurationL( |
|
1805 aAppODT, |
|
1806 *pluginsNode, |
|
1807 aPluginODT, |
|
1808 currentPosition, |
|
1809 aPluginId ); |
|
1810 |
|
1811 if( !err ) |
|
1812 { |
|
1813 // Add resources of the new plugin into the application configuration |
|
1814 AddPluginResourcesL( |
|
1815 aAppODT, |
|
1816 aPluginODT.ThemeUid() ); |
|
1817 } |
|
1818 } |
|
1819 |
|
1820 return err; |
|
1821 } |
|
1822 |
|
1823 TInt ChspsMaintenanceHandler::FindPluginPosition( |
|
1824 ChspsDomNode& aPluginNode ) |
|
1825 { |
|
1826 TInt pos = -1; |
|
1827 ChspsDomList& childList = aPluginNode.Parent()->ChildNodes(); |
|
1828 for( TInt nodeIndex=0; nodeIndex < childList.Length(); nodeIndex++ ) |
|
1829 { |
|
1830 ChspsDomNode* node = (ChspsDomNode *)childList.Item( nodeIndex ); |
|
1831 |
|
1832 if ( node == &aPluginNode ) |
|
1833 { |
|
1834 pos = nodeIndex; |
|
1835 break; |
|
1836 } |
|
1837 } |
|
1838 return pos; |
|
1839 } |
|
1840 |
|
1841 |
|
1842 // ----------------------------------------------------------------------------- |
|
1843 // ChspsMaintenanceHandler::SetLogBus() |
|
1844 // ----------------------------------------------------------------------------- |
|
1845 // |
|
1846 #ifdef HSPS_LOG_ACTIVE |
|
1847 void ChspsMaintenanceHandler::SetLogBus( ChspsLogBus* aLogBus ) |
|
1848 { |
|
1849 iLogBus = aLogBus; |
|
1850 } |
|
1851 #endif |
|
1852 |
|
1853 // ----------------------------------------------------------------------------- |
|
1854 // Removes an plugin instance from the provided application configuration |
|
1855 // ----------------------------------------------------------------------------- |
|
1856 // |
|
1857 TInt ChspsMaintenanceHandler::RemoveConfigurationL( |
|
1858 ChspsODT& aAppODT, |
|
1859 const TInt aPluginId ) |
|
1860 { |
|
1861 TInt err = KErrNotFound; |
|
1862 |
|
1863 // Find a plugin node with the provided id |
|
1864 ChspsDomNode *node = hspsServerUtil::FindPluginNodeL( aAppODT, aPluginId ); |
|
1865 if ( node ) |
|
1866 { |
|
1867 // Get parent node |
|
1868 ChspsDomNode *parentNode = node->Parent(); |
|
1869 if ( parentNode ) |
|
1870 { |
|
1871 // Get uid attribute from the node |
|
1872 TInt pluginUid = 0; |
|
1873 ChspsDomList& attrList = node->AttributeList(); |
|
1874 ChspsDomAttribute* pluginUidAttr = |
|
1875 static_cast<ChspsDomAttribute*> ( attrList.FindByName(KPluginAttrUid) ); |
|
1876 if( !pluginUidAttr ) |
|
1877 { |
|
1878 #ifdef HSPS_LOG_ACTIVE |
|
1879 if( iLogBus ) |
|
1880 { |
|
1881 iLogBus->LogText( _L( "ChspsMaintenanceHandler::RemoveConfigurationL(): - Invalid XML" ) ); |
|
1882 } |
|
1883 #endif |
|
1884 |
|
1885 err = KErrGeneral; |
|
1886 } |
|
1887 else |
|
1888 { |
|
1889 // Convert uids from string to numeric format |
|
1890 const TDesC8& pluginUidValue = pluginUidAttr->Value(); |
|
1891 const TUid uid = hspsServerUtil::ConvertDescIntoUid(pluginUidValue); |
|
1892 if ( uid.iUid > 0 ) |
|
1893 { |
|
1894 pluginUid = uid.iUid; |
|
1895 // Override default status |
|
1896 err = KErrNone; |
|
1897 } |
|
1898 } |
|
1899 |
|
1900 // Store activity state for use after deletion. |
|
1901 TBool pluginWasActive = EFalse; |
|
1902 ChspsDomAttribute* pluginActivityAttr = |
|
1903 static_cast<ChspsDomAttribute*>( attrList.FindByName( KPluginAttrActive ) ); |
|
1904 if( pluginActivityAttr ) |
|
1905 { |
|
1906 if( pluginActivityAttr->Value().CompareF( KPluginActiveStateActive ) == 0 ) |
|
1907 { |
|
1908 pluginWasActive = ETrue; |
|
1909 } |
|
1910 } |
|
1911 |
|
1912 if ( !err ) |
|
1913 { |
|
1914 // Get number of plugin instances with the plugin uid |
|
1915 TInt instanceCount = 0; |
|
1916 GetPluginInstanceCountL( |
|
1917 aAppODT, |
|
1918 pluginUid, |
|
1919 instanceCount ); |
|
1920 |
|
1921 // Remove plugin resources form the application configuration: |
|
1922 // By default remove all plugin's resources from all instances |
|
1923 // - otherwise, after upgrades, there might be various versions of the same resources |
|
1924 err = RemovePluginResourcesL( aAppODT, pluginUid ); |
|
1925 if ( !err ) |
|
1926 { |
|
1927 // If the application configuration holds other instances of the same plugin |
|
1928 if ( instanceCount > 1 ) |
|
1929 { |
|
1930 // Put back the resources |
|
1931 AddPluginResourcesL( |
|
1932 aAppODT, |
|
1933 pluginUid ); |
|
1934 } |
|
1935 |
|
1936 // Remove the plugin node from parent node |
|
1937 parentNode->DeleteChild( node ); |
|
1938 } |
|
1939 } |
|
1940 |
|
1941 // If plugin was succesfully deleted and was active -> |
|
1942 // need set another plugin active. |
|
1943 // ( Choose to activate topmost item. ) |
|
1944 // ( Use depth of 1 to affect only one level. ) |
|
1945 if ( !err && pluginWasActive ) |
|
1946 { |
|
1947 const TInt KDepth = 1; |
|
1948 hspsServerUtil::EditPluginNodeActivityL( parentNode, |
|
1949 hspsServerUtil::EActivateFirst, |
|
1950 KDepth ); |
|
1951 } |
|
1952 } |
|
1953 } |
|
1954 |
|
1955 return err; |
|
1956 } |
|
1957 |
|
1958 //---------------------------------------------------------------------------- |
|
1959 // Finds a plugin node with the provided id which is also a children of |
|
1960 // the provided plugins node |
|
1961 // ---------------------------------------------------------------------------- |
|
1962 // |
|
1963 ChspsDomNode* ChspsMaintenanceHandler::FindChildPluginNode( |
|
1964 ChspsDomNode& aPluginsNode, |
|
1965 const TInt aPluginId ) |
|
1966 { |
|
1967 ChspsDomNode* pluginNode = NULL; |
|
1968 |
|
1969 // Loop child nodes |
|
1970 ChspsDomList& childList = aPluginsNode.ChildNodes(); |
|
1971 for( TInt nodeIndex=0; nodeIndex < childList.Length(); nodeIndex++ ) |
|
1972 { |
|
1973 // Find a specific node with the provided id value |
|
1974 ChspsDomNode* node = (ChspsDomNode *)childList.Item( nodeIndex ); |
|
1975 if ( node ) |
|
1976 { |
|
1977 // Find the ID attribute |
|
1978 ChspsDomList& attrList = node->AttributeList(); |
|
1979 ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KPluginAttrId) ); |
|
1980 if ( attr ) |
|
1981 { |
|
1982 TInt id = 0; |
|
1983 const TDesC8& idValue = attr->Value(); |
|
1984 TLex8 lex( idValue ); |
|
1985 if ( lex.Val( id ) == 0 && id == aPluginId ) |
|
1986 { |
|
1987 pluginNode = node; |
|
1988 break; |
|
1989 } |
|
1990 } |
|
1991 } |
|
1992 } |
|
1993 |
|
1994 return pluginNode; |
|
1995 } |
|
1996 |
|
1997 // ----------------------------------------------------------------------------- |
|
1998 // Returns a count of plugin instances. |
|
1999 // ----------------------------------------------------------------------------- |
|
2000 // |
|
2001 void ChspsMaintenanceHandler::GetPluginInstanceCountL( |
|
2002 const ChspsODT& aAppODT, |
|
2003 const TInt aPluginUid, |
|
2004 TInt& aInstanceCount ) |
|
2005 |
|
2006 { |
|
2007 aInstanceCount = 0; |
|
2008 |
|
2009 ChspsDomDocument& dom = aAppODT.DomDocument(); |
|
2010 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() ); |
|
2011 CleanupStack::PushL( iter ); |
|
2012 |
|
2013 // Find a plugin node with the provided id attribute |
|
2014 ChspsDomNode* node = iter->First(); |
|
2015 ChspsDomNode* prevNode = NULL; |
|
2016 TBool jobDone = EFalse; |
|
2017 while( node && !jobDone && prevNode != node ) |
|
2018 { |
|
2019 const TDesC8& name = node->Name(); |
|
2020 |
|
2021 // Plugin element was found |
|
2022 if ( name == KPluginElement ) |
|
2023 { |
|
2024 ChspsDomList& attrList = node->AttributeList(); |
|
2025 ChspsDomAttribute* attr = static_cast<ChspsDomAttribute*>( attrList.FindByName(KPluginAttrUid) ); |
|
2026 if ( !attr ) |
|
2027 { |
|
2028 // Mandatory information is missing for some reason (should be set at installation handler)! |
|
2029 // Exit with NULL |
|
2030 jobDone = ETrue; |
|
2031 } |
|
2032 else |
|
2033 { |
|
2034 // Convert from (hex?) string into TUid presentation |
|
2035 const TUid uid = hspsServerUtil::ConvertDescIntoUid( attr->Value() ); |
|
2036 if ( aPluginUid == uid.iUid ) |
|
2037 { |
|
2038 aInstanceCount++; |
|
2039 } |
|
2040 } |
|
2041 } |
|
2042 |
|
2043 prevNode = node; |
|
2044 node = iter->NextL(); |
|
2045 } |
|
2046 CleanupStack::PopAndDestroy( iter ); |
|
2047 } |
|
2048 |
|
2049 // ----------------------------------------------------------------------------- |
|
2050 // Removes plugin resources from the provided ODT |
|
2051 // ----------------------------------------------------------------------------- |
|
2052 // |
|
2053 TInt ChspsMaintenanceHandler::RemovePluginResourcesL( |
|
2054 ChspsODT& aAppODT, |
|
2055 const TInt aPluginUid ) |
|
2056 { |
|
2057 // Loop resources of the application configuration |
|
2058 for(TInt aresIndex = 0; aresIndex < aAppODT.ResourceCount(); aresIndex++ ) |
|
2059 { |
|
2060 ChspsResource& ares = aAppODT.ResourceL( aresIndex ); |
|
2061 |
|
2062 // If the plugin resource was found at resource list of the application configuration |
|
2063 if ( ares.ConfigurationUid() == aPluginUid ) |
|
2064 { |
|
2065 // Deletes resource from the application configuration |
|
2066 aAppODT.DeleteResourceL( aresIndex ); |
|
2067 aresIndex--; |
|
2068 } |
|
2069 |
|
2070 } |
|
2071 |
|
2072 return KErrNone; |
|
2073 } |
|
2074 |
|
2075 // ----------------------------------------------------------------------------- |
|
2076 // Adds plugin resources to the provided application ODT |
|
2077 // ----------------------------------------------------------------------------- |
|
2078 // |
|
2079 void ChspsMaintenanceHandler::AddPluginResourcesL( |
|
2080 ChspsODT& aAppODT, |
|
2081 const TInt aPluginUid ) |
|
2082 { |
|
2083 // Get plugin ODT |
|
2084 ChspsODT* pluginODT = ChspsODT::NewL(); |
|
2085 CleanupStack::PushL( pluginODT ); |
|
2086 TInt ret = iThemeServer.GetConfigurationL( |
|
2087 0, |
|
2088 aPluginUid, |
|
2089 *pluginODT ); |
|
2090 |
|
2091 if ( !ret && pluginODT->ThemeUid() ) |
|
2092 { |
|
2093 // Copy resources of the referenced plug-in instance to the application configuration |
|
2094 TInt resourceCount = pluginODT->ResourceCount(); |
|
2095 for ( TInt index=0; index < resourceCount; index++ ) |
|
2096 { |
|
2097 ChspsResource& pluginResource = pluginODT->ResourceL(index); |
|
2098 // Add only those that are located under the sources folder |
|
2099 if ( pluginResource.FileName().FindF( KSourcesFolder ) > 0 |
|
2100 || pluginResource.FileName().FindF( KLocalesFolder ) > 0 ) |
|
2101 { |
|
2102 ChspsResource* r = pluginResource.CloneL(); |
|
2103 CleanupStack::PushL( r ); |
|
2104 aAppODT.AddResourceL( r ); |
|
2105 CleanupStack::Pop( r ); |
|
2106 } |
|
2107 } |
|
2108 } |
|
2109 |
|
2110 if ( pluginODT ) |
|
2111 { |
|
2112 CleanupStack::PopAndDestroy( pluginODT ); |
|
2113 } |
|
2114 } |
|
2115 |
|
2116 // ----------------------------------------------------------------------------- |
|
2117 // Service for personalizing settings |
|
2118 // ----------------------------------------------------------------------------- |
|
2119 // |
|
2120 void ChspsMaintenanceHandler::ServiceSetPluginSettingsL( const RMessage2& aMessage ) |
|
2121 { |
|
2122 // Defaults |
|
2123 ThspsServiceCompletedMessage ret = EhspsSetPluginSettingsFailed; |
|
2124 iResult->iXuikonError = KErrNotFound; |
|
2125 TInt err = KErrNone; |
|
2126 |
|
2127 // Parameters |
|
2128 RMessagePtr2 messagePtr = aMessage; |
|
2129 |
|
2130 TBuf8<KMaxHeaderDataLength8> setMaskData; |
|
2131 |
|
2132 |
|
2133 ChspsODT* odt = NULL; |
|
2134 TInt appConfUid; |
|
2135 TInt pluginId; |
|
2136 TBool storingStatus(EFalse); |
|
2137 |
|
2138 // Checking active congiruation and security |
|
2139 messagePtr.ReadL(1,setMaskData,0); |
|
2140 |
|
2141 if (iSetMask) |
|
2142 { |
|
2143 delete iSetMask; |
|
2144 iSetMask = NULL; |
|
2145 } |
|
2146 |
|
2147 iSetMask = ChspsODT::NewL(); |
|
2148 iSetMask->UnMarshalHeaderL( setMaskData ); |
|
2149 |
|
2150 iCentralRepository.Get( iSetMask->RootUid(), appConfUid ); |
|
2151 |
|
2152 // Getting active configuration |
|
2153 odt = ChspsODT::NewL(); |
|
2154 CleanupStack::PushL(odt); |
|
2155 |
|
2156 err = iThemeServer.GetConfigurationL( |
|
2157 iSetMask->RootUid(), |
|
2158 appConfUid, |
|
2159 *odt ); |
|
2160 |
|
2161 if (iSetMask) |
|
2162 { |
|
2163 delete iSetMask; |
|
2164 iSetMask = NULL; |
|
2165 } |
|
2166 |
|
2167 // Set settings to active configuration |
|
2168 if( !err ) |
|
2169 { |
|
2170 if( iDefinitionRepository.Locked() ) |
|
2171 { |
|
2172 // Repository locked |
|
2173 err = KErrAccessDenied; |
|
2174 } |
|
2175 else |
|
2176 { |
|
2177 // Lock the Plugin Repository (a.k.a. Def.rep) |
|
2178 iDefinitionRepository.Lock(); |
|
2179 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
2180 //Read pluginID |
|
2181 // Get configuration |
|
2182 ThspsParamSetPluginSettings params; |
|
2183 TPckg<ThspsParamSetPluginSettings> packagedStruct(params); |
|
2184 |
|
2185 messagePtr.ReadL( 2, packagedStruct ); |
|
2186 |
|
2187 pluginId = params.pluginId ; |
|
2188 storingStatus = params.storingStatus ; |
|
2189 |
|
2190 |
|
2191 |
|
2192 // read Domdata |
|
2193 HBufC8* domData = HBufC8::NewL( messagePtr.GetDesLengthL( 3 ) ); |
|
2194 CleanupStack::PushL( domData ); |
|
2195 TPtr8 domPtr = domData->Des(); |
|
2196 messagePtr.ReadL( 3, domPtr, 0 ); |
|
2197 RDesReadStream readBuf( *domData ); |
|
2198 CleanupClosePushL( readBuf ); |
|
2199 |
|
2200 ChspsDomDocument* domDocument = ChspsDomDocument::NewL( readBuf ); |
|
2201 |
|
2202 CleanupStack::PopAndDestroy( &readBuf ); |
|
2203 CleanupStack::PopAndDestroy( domData ); |
|
2204 |
|
2205 CleanupStack::PushL( domDocument ); |
|
2206 err = hspsSetPluginSettingsL( *odt, pluginId, *domDocument ); |
|
2207 |
|
2208 if( !err ) |
|
2209 { |
|
2210 |
|
2211 #ifdef HSPS_LOG_ACTIVE |
|
2212 if( odt && iLogBus ) |
|
2213 { |
|
2214 ChspsOdtDump::Dump( *odt, *iLogBus ); |
|
2215 } |
|
2216 #endif |
|
2217 // Stores the new application configuration into the repository |
|
2218 err = iDefinitionRepository.SetOdtL( *odt ); |
|
2219 |
|
2220 if( !err ) |
|
2221 { |
|
2222 #ifdef HSPS_LOG_ACTIVE |
|
2223 if( iLogBus ) |
|
2224 { |
|
2225 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceSetPluginSettingsL(): - Updating Success" ) ); |
|
2226 } |
|
2227 #endif |
|
2228 } |
|
2229 } |
|
2230 CleanupStack::PopAndDestroy( domDocument ); |
|
2231 |
|
2232 // Unlock after the changes have been done |
|
2233 iDefinitionRepository.Unlock(); |
|
2234 CleanupStack::Pop(&iDefinitionRepository); |
|
2235 |
|
2236 if( storingStatus ) |
|
2237 { |
|
2238 // Lock the Plugin Repository (a.k.a. Def.rep) |
|
2239 iDefinitionRepository.Lock(); |
|
2240 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
2241 |
|
2242 ChspsDomNode* pluginNode = hspsServerUtil::FindPluginNodeL( *odt, pluginId ); |
|
2243 |
|
2244 if( pluginNode ) |
|
2245 { |
|
2246 |
|
2247 ChspsDomList& attrList = pluginNode->AttributeList(); |
|
2248 // Get configuration attribute from the plugin configuration |
|
2249 ChspsDomAttribute* pluginUidAttr = static_cast<ChspsDomAttribute*> ( attrList.FindByName(KPluginAttrUid) ); |
|
2250 |
|
2251 if( pluginUidAttr ) |
|
2252 { |
|
2253 |
|
2254 // Convert uids from string to numeric format |
|
2255 const TDesC8& pluginUidValue = pluginUidAttr->Value(); |
|
2256 const TUid pluginUid = hspsServerUtil::ConvertDescIntoUid(pluginUidValue); |
|
2257 // Get plugin configuration |
|
2258 ChspsODT* pluginOdt = ChspsODT::NewL(); |
|
2259 CleanupStack::PushL( pluginOdt ); |
|
2260 |
|
2261 err = iThemeServer.GetConfigurationL( |
|
2262 0, |
|
2263 pluginUid.iUid, |
|
2264 *pluginOdt ); |
|
2265 |
|
2266 if( !err ) |
|
2267 { |
|
2268 // read Domdata |
|
2269 HBufC8* domData = HBufC8::NewL( messagePtr.GetDesLengthL( 3 ) ); |
|
2270 CleanupStack::PushL( domData ); |
|
2271 TPtr8 domPtr = domData->Des(); |
|
2272 messagePtr.ReadL( 3, domPtr, 0 ); |
|
2273 RDesReadStream readBuf( *domData ); |
|
2274 CleanupClosePushL( readBuf ); |
|
2275 |
|
2276 ChspsDomDocument* domDocument = ChspsDomDocument::NewL( readBuf ); |
|
2277 |
|
2278 CleanupStack::PopAndDestroy( &readBuf ); |
|
2279 CleanupStack::PopAndDestroy( domData ); |
|
2280 |
|
2281 CleanupStack::PushL( domDocument ); |
|
2282 |
|
2283 err = hspsSavePluginSettingsL( *pluginOdt, *domDocument ); |
|
2284 |
|
2285 if( !err ) |
|
2286 { |
|
2287 #ifdef HSPS_LOG_ACTIVE |
|
2288 if( odt && iLogBus ) |
|
2289 { |
|
2290 ChspsOdtDump::Dump( *pluginOdt, *iLogBus ); |
|
2291 } |
|
2292 #endif |
|
2293 // Stores the new application configuration into the repository |
|
2294 err = iDefinitionRepository.SetOdtL( *pluginOdt ); |
|
2295 |
|
2296 if( !err ) |
|
2297 { |
|
2298 #ifdef HSPS_LOG_ACTIVE |
|
2299 if( iLogBus ) |
|
2300 { |
|
2301 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceSetPluginSettingsL(): - Updating plugin reference Success" ) ); |
|
2302 } |
|
2303 #endif |
|
2304 } |
|
2305 } |
|
2306 CleanupStack::PopAndDestroy( domDocument ); |
|
2307 } |
|
2308 if ( pluginOdt ) |
|
2309 { |
|
2310 CleanupStack::PopAndDestroy( pluginOdt ); |
|
2311 pluginOdt = NULL; |
|
2312 } |
|
2313 |
|
2314 } |
|
2315 else |
|
2316 { |
|
2317 err = KErrCorrupt; |
|
2318 } |
|
2319 } |
|
2320 else |
|
2321 { |
|
2322 err = KErrNotFound; |
|
2323 } |
|
2324 |
|
2325 // Unlock after the changes have been done |
|
2326 iDefinitionRepository.Unlock(); |
|
2327 CleanupStack::Pop(&iDefinitionRepository); |
|
2328 } |
|
2329 |
|
2330 if ( !err ) |
|
2331 { |
|
2332 // Inform clients that the ODT has been modified |
|
2333 ThspsRepositoryInfo info( |
|
2334 ThspsRepositoryEvent(EhspsSettingsChanged), |
|
2335 odt->RootUid(), |
|
2336 odt->ThemeUid(), |
|
2337 aMessage.SecureId().iId, //=Any file |
|
2338 odt->ProviderUid(), |
|
2339 0,0, |
|
2340 0,pluginId,ETrue,odt->ThemeFullName(), |
|
2341 (TLanguage)(odt->OdtLanguage()) |
|
2342 ); |
|
2343 iDefinitionRepository.RegisterNotification( info ); |
|
2344 } |
|
2345 } |
|
2346 } |
|
2347 |
|
2348 // Cleaning |
|
2349 if (odt) |
|
2350 { |
|
2351 CleanupStack::PopAndDestroy( odt ); |
|
2352 odt = NULL; |
|
2353 } |
|
2354 |
|
2355 // Error handling |
|
2356 iResult->iXuikonError = err; |
|
2357 if ( !err ) |
|
2358 { |
|
2359 ret = EhspsSetPluginSettingsSuccess; |
|
2360 } |
|
2361 |
|
2362 // Completion |
|
2363 CompleteRequest( ret, messagePtr ); |
|
2364 } |
|
2365 |
|
2366 // ----------------------------------------------------------------------------- |
|
2367 // |
|
2368 // Service to get plugin Odt according plugin uid |
|
2369 // packed parameters |
|
2370 // ----------------------------------------------------------------------------- |
|
2371 // |
|
2372 void ChspsMaintenanceHandler::ServiceGetPluginOdtL( const RMessage2& aMessage ) |
|
2373 { |
|
2374 #ifdef HSPS_LOG_ACTIVE |
|
2375 if( iLogBus ) |
|
2376 { |
|
2377 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceGetPluginOdtL: - service called" ) ); |
|
2378 } |
|
2379 #endif |
|
2380 |
|
2381 iMessagePtr = aMessage; |
|
2382 TInt err = KErrNone; |
|
2383 |
|
2384 // Get configuration |
|
2385 ThspsParamGetPluginOdt params; |
|
2386 TPckg<ThspsParamGetPluginOdt> packagedStruct(params); |
|
2387 iMessagePtr.ReadL(1, packagedStruct); |
|
2388 |
|
2389 ChspsODT* odt = ChspsODT::NewL(); |
|
2390 CleanupStack::PushL( odt ); |
|
2391 err = iThemeServer.GetConfigurationL( 0, params.pluginUid, *odt ); |
|
2392 |
|
2393 if( !err ) |
|
2394 { |
|
2395 TPath odtPath; |
|
2396 // Resolve odt path if no errors were occured |
|
2397 iDefinitionRepository.GetResourcePathL( *odt, EResourceODT, odtPath ); |
|
2398 TPckg<ThspsParamGetPluginOdt> packagedStruct( params ); |
|
2399 iMessagePtr.WriteL(2, odtPath); |
|
2400 } |
|
2401 #ifdef HSPS_LOG_ACTIVE |
|
2402 else |
|
2403 { |
|
2404 if( iLogBus ) |
|
2405 { |
|
2406 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceGetPluginOdtL: - error occured during GetConfigurationL()" ) ); |
|
2407 } |
|
2408 } |
|
2409 #endif |
|
2410 |
|
2411 CleanupStack::PopAndDestroy( odt ); |
|
2412 |
|
2413 // Error handling |
|
2414 iResult->iXuikonError = err; |
|
2415 |
|
2416 if ( err ) |
|
2417 { |
|
2418 #ifdef HSPS_LOG_ACTIVE |
|
2419 if( iLogBus ) |
|
2420 { |
|
2421 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceGetPluginOdtL: - EhspsGetPluginOdtFailed code: %d" ), err ); |
|
2422 } |
|
2423 #endif |
|
2424 |
|
2425 CompleteRequest( EhspsGetPluginOdtFailed, iMessagePtr ); |
|
2426 } |
|
2427 else |
|
2428 { |
|
2429 #ifdef HSPS_LOG_ACTIVE |
|
2430 if( iLogBus ) |
|
2431 { |
|
2432 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceGetPluginOdtL: - EhspsGetPluginOdtSuccess" ) ); |
|
2433 } |
|
2434 #endif |
|
2435 |
|
2436 CompleteRequest( EhspsGetPluginOdtSuccess, iMessagePtr ); |
|
2437 } |
|
2438 |
|
2439 } |
|
2440 |
|
2441 |
|
2442 // ----------------------------------------------------------------------------- |
|
2443 // hspsMaintenanceHandler::hspsSetPluginSettings |
|
2444 |
|
2445 // ----------------------------------------------------------------------------- |
|
2446 // |
|
2447 TInt ChspsMaintenanceHandler::hspsSetPluginSettingsL( ChspsODT& aOdt, |
|
2448 TInt aPluginId, ChspsDomDocument& aDom ) |
|
2449 { |
|
2450 TInt error = KErrNotFound; |
|
2451 |
|
2452 |
|
2453 TUint value = aPluginId; |
|
2454 |
|
2455 // Find a plugin node with the provided id |
|
2456 ChspsDomNode* pluginNode = hspsServerUtil::FindPluginNodeL( aOdt, value ); |
|
2457 if( !pluginNode ) |
|
2458 { |
|
2459 error = KErrNotFound; |
|
2460 return error; |
|
2461 } |
|
2462 ChspsDomNode* controlNode = &(FindNodeByTagL(KControlElement, *pluginNode )); |
|
2463 if( !controlNode ) |
|
2464 { |
|
2465 error = KErrNotFound; |
|
2466 return error; |
|
2467 } |
|
2468 ChspsDomList& childList = controlNode->ChildNodes(); |
|
2469 ChspsDomNode* settingsNode = (ChspsDomNode*)childList.FindByName( KSettingsElement ); |
|
2470 if( !settingsNode ) |
|
2471 { |
|
2472 error = KErrNotFound; |
|
2473 return error; |
|
2474 } |
|
2475 TInt index = controlNode->ItemIndex( *settingsNode ); |
|
2476 controlNode->DeleteChild(settingsNode); |
|
2477 |
|
2478 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *aDom.RootNode() ); |
|
2479 CleanupStack::PushL( iter ); |
|
2480 ChspsDomNode* node = iter->First(); |
|
2481 ChspsDomNode* prevNode = NULL; |
|
2482 TBool jobDone = EFalse; |
|
2483 while( node && !jobDone && node != prevNode) |
|
2484 { |
|
2485 const TDesC8& name = node->Name(); |
|
2486 if( name == KSettingsElement ) |
|
2487 { |
|
2488 // Attach to the plugin node |
|
2489 |
|
2490 ChspsDomNode* clone = node->CloneL( aOdt.DomDocument().StringPool() ); |
|
2491 CleanupStack::PushL( clone ); |
|
2492 controlNode->AddChildL( clone, index ); |
|
2493 clone->SetParent( controlNode ); |
|
2494 CleanupStack::Pop( clone ); |
|
2495 jobDone=ETrue; |
|
2496 error=KErrNone; |
|
2497 } |
|
2498 prevNode=node; |
|
2499 node=iter->NextL(); |
|
2500 } |
|
2501 CleanupStack::PopAndDestroy( iter ); |
|
2502 |
|
2503 |
|
2504 |
|
2505 return error; |
|
2506 |
|
2507 } |
|
2508 |
|
2509 // ----------------------------------------------------------------------------- |
|
2510 // Finds a node from a dom document. |
|
2511 // Looks for the next node tag. |
|
2512 // ----------------------------------------------------------------------------- |
|
2513 ChspsDomNode& ChspsMaintenanceHandler::FindNodeByTagL( |
|
2514 const TDesC8& aNodeTag, |
|
2515 ChspsDomNode& aDomNode ) |
|
2516 { |
|
2517 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( aDomNode ); |
|
2518 CleanupStack::PushL( iter ); |
|
2519 ChspsDomNode* targetNode( NULL ); |
|
2520 ChspsDomNode* node = iter->First(); |
|
2521 TBool found = EFalse; |
|
2522 while( !found && node ) |
|
2523 { |
|
2524 const TDesC8& name = node->Name(); |
|
2525 if ( name.Compare( aNodeTag ) == 0 ) |
|
2526 { |
|
2527 found = ETrue; |
|
2528 targetNode = node; |
|
2529 } |
|
2530 node = iter->NextL(); |
|
2531 } |
|
2532 CleanupStack::PopAndDestroy( iter ); |
|
2533 return *targetNode; |
|
2534 } |
|
2535 |
|
2536 // ----------------------------------------------------------------------------- |
|
2537 // ChspsMaintenanceHandler::hspsSavePluginSettingsL |
|
2538 |
|
2539 // ----------------------------------------------------------------------------- |
|
2540 // |
|
2541 TInt ChspsMaintenanceHandler::hspsSavePluginSettingsL( |
|
2542 ChspsODT& aOdt, |
|
2543 ChspsDomDocument& aDom ) |
|
2544 { |
|
2545 TInt error; |
|
2546 ChspsDomNode* node = aOdt.DomDocument().RootNode(); |
|
2547 |
|
2548 ChspsDomNode* controlNode = &(FindNodeByTagL(KControlElement, *node )); |
|
2549 |
|
2550 if( !controlNode ) |
|
2551 { |
|
2552 return KErrNotFound; |
|
2553 } |
|
2554 |
|
2555 ChspsDomList& childList = controlNode->ChildNodes(); |
|
2556 ChspsDomNode* settingsNode = (ChspsDomNode*)childList.FindByName( KSettingsElement ); |
|
2557 |
|
2558 if( !settingsNode ) |
|
2559 { |
|
2560 return KErrNotFound; |
|
2561 } |
|
2562 |
|
2563 TInt index = controlNode->ItemIndex( *settingsNode ); |
|
2564 controlNode->DeleteChild(settingsNode); |
|
2565 |
|
2566 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *aDom.RootNode() ); |
|
2567 CleanupStack::PushL( iter ); |
|
2568 ChspsDomNode* iterNode = iter->First(); |
|
2569 ChspsDomNode* prevNode = NULL; |
|
2570 TBool jobDone = EFalse; |
|
2571 |
|
2572 while( iterNode && !jobDone && iterNode != prevNode) |
|
2573 { |
|
2574 const TDesC8& name = iterNode->Name(); |
|
2575 if( name == KSettingsElement ) |
|
2576 { |
|
2577 // Attach to the plugin node |
|
2578 |
|
2579 ChspsDomNode* clone = iterNode->CloneL( aOdt.DomDocument().StringPool() ); |
|
2580 CleanupStack::PushL( clone ); |
|
2581 controlNode->AddChildL( clone, index ); |
|
2582 clone->SetParent( controlNode ); |
|
2583 CleanupStack::Pop( clone ); |
|
2584 jobDone=ETrue; |
|
2585 error=KErrNone; |
|
2586 } |
|
2587 prevNode=iterNode; |
|
2588 iterNode=iter->NextL(); |
|
2589 } |
|
2590 CleanupStack::PopAndDestroy( iter ); |
|
2591 |
|
2592 return error; |
|
2593 |
|
2594 } |
|
2595 // Service for updating plugin positions |
|
2596 // ----------------------------------------------------------------------------- |
|
2597 // |
|
2598 void ChspsMaintenanceHandler::ServiceMovePluginsL( const RMessage2& aMessage ) |
|
2599 { |
|
2600 // Defaults |
|
2601 ThspsServiceCompletedMessage ret = EhspsMovePluginsFailed; |
|
2602 iResult->iXuikonError = KErrNotFound; |
|
2603 TInt err = KErrNone; |
|
2604 |
|
2605 // Parameters |
|
2606 RMessagePtr2 messagePtr = aMessage; |
|
2607 |
|
2608 // IPC slots: |
|
2609 // #0) output: externalized ChspsResult for error handling |
|
2610 // #1) input: a struct |
|
2611 |
|
2612 // Get service parameters from IPC slot #1 |
|
2613 ThpsParamMovePlugins params; |
|
2614 TPckg<ThpsParamMovePlugins> packagedStruct(params); |
|
2615 aMessage.ReadL(1, packagedStruct); |
|
2616 const TInt appUid = params.appUid; |
|
2617 const TInt confId = params.configurationId; |
|
2618 TPtrC8 bufPtr( params.pluginIdsBuf ); |
|
2619 |
|
2620 // Internalize the plugin ids array from a descriptor |
|
2621 const TInt KGranularity = 6; |
|
2622 ChspsPluginIdList* idArray = new (ELeave)ChspsPluginIdList( KGranularity ); |
|
2623 CleanupStack::PushL( idArray ); |
|
2624 RDesReadStream readStream( bufPtr ); |
|
2625 CleanupClosePushL( readStream ); |
|
2626 TRAP( err, idArray->InternalizeL(readStream) ); |
|
2627 CleanupStack::PopAndDestroy( &readStream ); |
|
2628 |
|
2629 if ( err || appUid < 1 || confId < 1 || idArray->Count() < 1 ) |
|
2630 { |
|
2631 #ifdef HSPS_LOG_ACTIVE |
|
2632 if( iLogBus ) |
|
2633 { |
|
2634 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceMovePluginsL(): invalid input" ) ); |
|
2635 } |
|
2636 #endif |
|
2637 |
|
2638 err = KErrArgument; |
|
2639 } |
|
2640 |
|
2641 // Application configuration |
|
2642 ChspsODT *appODT = NULL; |
|
2643 if ( !err ) |
|
2644 { |
|
2645 // Get active application configuration from the central repository |
|
2646 TInt appConfUid; |
|
2647 err = iCentralRepository.Get( appUid, appConfUid ); |
|
2648 if ( err || appConfUid < 1 ) |
|
2649 { |
|
2650 err = KErrNotFound; |
|
2651 } |
|
2652 else |
|
2653 { |
|
2654 appODT = ChspsODT::NewL(); |
|
2655 CleanupStack::PushL( appODT ); |
|
2656 err = iThemeServer.GetConfigurationL( |
|
2657 appUid, |
|
2658 appConfUid, |
|
2659 *appODT ); |
|
2660 } |
|
2661 } |
|
2662 |
|
2663 // Modifications |
|
2664 if ( !err ) |
|
2665 { |
|
2666 if ( iDefinitionRepository.Locked() ) |
|
2667 { |
|
2668 // Repository locked |
|
2669 err = KErrAccessDenied; |
|
2670 } |
|
2671 else |
|
2672 { |
|
2673 // Lock the Plugin Repository (a.k.a. Def.rep) |
|
2674 iDefinitionRepository.Lock(); |
|
2675 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
2676 |
|
2677 // Update the provided configuration |
|
2678 err = UpdatePluginListL( |
|
2679 *appODT, |
|
2680 confId, |
|
2681 *idArray ); |
|
2682 if ( !err ) |
|
2683 { |
|
2684 |
|
2685 #ifdef HSPS_LOG_ACTIVE |
|
2686 if( appODT && iLogBus ) |
|
2687 { |
|
2688 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceRemovePluginL() - plugins moved:" ) ); |
|
2689 ChspsOdtDump::Dump( *appODT, *iLogBus ); |
|
2690 } |
|
2691 #endif |
|
2692 // Stores the new application configuration into the repository |
|
2693 err = iDefinitionRepository.SetOdtL( *appODT ); |
|
2694 if ( err ) |
|
2695 { |
|
2696 #ifdef HSPS_LOG_ACTIVE |
|
2697 if( iLogBus ) |
|
2698 { |
|
2699 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceRemovePluginL(): - Updating failed" ) ); |
|
2700 } |
|
2701 #endif |
|
2702 } |
|
2703 } |
|
2704 else |
|
2705 { |
|
2706 #ifdef HSPS_LOG_ACTIVE |
|
2707 if( iLogBus ) |
|
2708 { |
|
2709 iLogBus->LogText( _L( "ChspsMaintenanceHandler::ServiceRemovePluginL(): - UpdatePluginListL failed" ) ); |
|
2710 } |
|
2711 #endif |
|
2712 } |
|
2713 |
|
2714 // Unlock after the changes have been done |
|
2715 iDefinitionRepository.Unlock(); |
|
2716 CleanupStack::Pop(&iDefinitionRepository); |
|
2717 |
|
2718 if ( !err ) |
|
2719 { |
|
2720 // Inform clients that the ODT has been modified |
|
2721 ThspsRepositoryInfo info( |
|
2722 ThspsRepositoryEvent(EhspsODTModified), |
|
2723 appODT->RootUid(), |
|
2724 appODT->ThemeUid(), |
|
2725 0, //=Any file |
|
2726 appODT->ProviderUid(), |
|
2727 (TLanguage)(appODT->OdtLanguage()) |
|
2728 ); |
|
2729 iDefinitionRepository.RegisterNotification( info ); |
|
2730 } |
|
2731 } |
|
2732 } |
|
2733 |
|
2734 // Cleaning |
|
2735 if ( appODT ) |
|
2736 { |
|
2737 CleanupStack::PopAndDestroy( appODT ); |
|
2738 appODT = NULL; |
|
2739 } |
|
2740 |
|
2741 CleanupStack::PopAndDestroy( idArray ); |
|
2742 |
|
2743 // Error handling |
|
2744 iResult->iXuikonError = err; |
|
2745 if ( !err ) |
|
2746 { |
|
2747 ret = EhspsMovePluginsSuccess; |
|
2748 } |
|
2749 |
|
2750 // Completion |
|
2751 CompleteRequest( ret, messagePtr ); |
|
2752 } |
|
2753 |
|
2754 // ----------------------------------------------------------------------------- |
|
2755 // Service for updating configuration state |
|
2756 // ----------------------------------------------------------------------------- |
|
2757 // |
|
2758 void ChspsMaintenanceHandler::ServiceSetConfStateL( const RMessage2& aMessage ) |
|
2759 { |
|
2760 // Parameters |
|
2761 RMessagePtr2 messagePtr = aMessage; |
|
2762 |
|
2763 // Get service parameters from IPC slot #1 |
|
2764 ThspsParamSetConfState params; |
|
2765 TPckg<ThspsParamSetConfState> packagedStruct( params ); |
|
2766 aMessage.ReadL( 1, packagedStruct ); |
|
2767 |
|
2768 // Reserve definition repository |
|
2769 if ( iDefinitionRepository.Locked() ) |
|
2770 { |
|
2771 // Definition repository reserved |
|
2772 User::Leave( KErrAccessDenied ); |
|
2773 } |
|
2774 iDefinitionRepository.Lock(); |
|
2775 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
2776 |
|
2777 // Get application configuration |
|
2778 TInt appConfUid; |
|
2779 User::LeaveIfError( iCentralRepository.Get( params.appUid, appConfUid ) ); |
|
2780 ChspsODT* appODT = ChspsODT::NewL(); |
|
2781 CleanupStack::PushL( appODT ); |
|
2782 User::LeaveIfError( iThemeServer.GetConfigurationL( |
|
2783 params.appUid, |
|
2784 appConfUid, |
|
2785 *appODT ) ); |
|
2786 |
|
2787 // Update configuration state |
|
2788 SetConfStateL( *appODT, params.confId, params.state, params.filter ); |
|
2789 |
|
2790 // Store updated configuration |
|
2791 User::LeaveIfError( iDefinitionRepository.SetOdtL( *appODT ) ); |
|
2792 CleanupStack::PopAndDestroy( appODT ); |
|
2793 |
|
2794 // Release definition repository |
|
2795 iDefinitionRepository.Unlock(); |
|
2796 CleanupStack::Pop( &iDefinitionRepository ); |
|
2797 |
|
2798 // Completion |
|
2799 CompleteRequest( EhspsSetConfStateSuccess, messagePtr ); |
|
2800 } |
|
2801 |
|
2802 // ----------------------------------------------------------------------------- |
|
2803 // Service for restoring active application configuration |
|
2804 // ----------------------------------------------------------------------------- |
|
2805 // |
|
2806 void ChspsMaintenanceHandler::ServiceRestoreActiveAppConfL( const RMessage2& aMessage ) |
|
2807 { |
|
2808 // Parameters |
|
2809 RMessagePtr2 messagePtr = aMessage; |
|
2810 ThspsServiceCompletedMessage ret( EhspsRestoreActiveAppConfFailed ); |
|
2811 TInt err( KErrNone ); |
|
2812 |
|
2813 // Get service parameters from IPC slot #1 |
|
2814 ThspsParamRestoreActiveAppConf params; |
|
2815 TPckg<ThspsParamRestoreActiveAppConf> packagedStruct( params ); |
|
2816 aMessage.ReadL( 1, packagedStruct ); |
|
2817 |
|
2818 // Create search criteria |
|
2819 ChspsODT* searchMask = ChspsODT::NewL(); |
|
2820 CleanupStack::PushL( searchMask ); |
|
2821 searchMask->SetRootUid( params.appUid ); |
|
2822 searchMask->SetThemeUid( params.confUid ); |
|
2823 |
|
2824 // Get configuration header |
|
2825 ChspsODT* confHeader( NULL ); |
|
2826 TInt pos( 0 ); |
|
2827 iThemeServer.GetConfigurationHeader( *searchMask, confHeader, pos ); |
|
2828 |
|
2829 if ( confHeader && |
|
2830 !iDefinitionRepository.Locked() ) |
|
2831 { |
|
2832 // Lock definition repository |
|
2833 iDefinitionRepository.Lock(); |
|
2834 // Restore backup configuration if it exists |
|
2835 err = iDefinitionRepository.RestoreBackupConfiguration( *confHeader ); |
|
2836 // Release definition repository |
|
2837 iDefinitionRepository.Unlock(); |
|
2838 |
|
2839 if ( err != KErrNone ) |
|
2840 { |
|
2841 // Configuration backup not found - Restore default configuration |
|
2842 ChspsODT* odt = ChspsODT::NewL(); |
|
2843 CleanupStack::PushL( odt ); |
|
2844 RestoreDefaultAppConfL( confHeader, *odt ); |
|
2845 iDefinitionRepository.SetOdtL( *odt ); |
|
2846 CleanupStack::PopAndDestroy( odt ); |
|
2847 } |
|
2848 ret = EhspsRestoreActiveAppConfSuccess; |
|
2849 } |
|
2850 |
|
2851 CleanupStack::PopAndDestroy( searchMask ); |
|
2852 |
|
2853 // Completion |
|
2854 CompleteRequest( ret, messagePtr ); |
|
2855 } |
|
2856 |
|
2857 //---------------------------------------------------------------------------- |
|
2858 // ChspsMaintenanceHandler::UpdatePluginListL() |
|
2859 // ---------------------------------------------------------------------------- |
|
2860 // |
|
2861 TInt ChspsMaintenanceHandler::UpdatePluginListL( |
|
2862 ChspsODT& aAppODT, |
|
2863 const TInt aConfigurationId, |
|
2864 const CArrayFixFlat<TInt>& aPluginIdList ) |
|
2865 { |
|
2866 TInt err = KErrNone; |
|
2867 |
|
2868 // Find the configuration node |
|
2869 ChspsDomNode* confNode = hspsServerUtil::FindConfigurationNodeL( aAppODT, aConfigurationId ); |
|
2870 if ( !confNode ) |
|
2871 { |
|
2872 #ifdef HSPS_LOG_ACTIVE |
|
2873 if( iLogBus ) |
|
2874 { |
|
2875 iLogBus->LogText( _L( "ChspsMaintenanceHandler::UpdatePluginListL(): - configuration node was not found" ) ); |
|
2876 } |
|
2877 #endif |
|
2878 |
|
2879 err = KErrNotFound; |
|
2880 } |
|
2881 |
|
2882 ChspsDomNode* controlNode = NULL; |
|
2883 if ( !err ) |
|
2884 { |
|
2885 // Find a control node under the configuration node |
|
2886 controlNode = (ChspsDomNode *)confNode->ChildNodes().FindByName( KControlElement ); |
|
2887 if ( !controlNode ) |
|
2888 { |
|
2889 #ifdef HSPS_LOG_ACTIVE |
|
2890 if( iLogBus ) |
|
2891 { |
|
2892 iLogBus->LogText( _L( "ChspsMaintenanceHandler::UpdatePluginListL(): - control node was not found" ) ); |
|
2893 } |
|
2894 #endif |
|
2895 |
|
2896 err = KErrNotFound; |
|
2897 } |
|
2898 } |
|
2899 |
|
2900 ChspsDomNode* oldPluginsNode = NULL; |
|
2901 if ( !err ) |
|
2902 { |
|
2903 // Find a plugins node under the control node |
|
2904 oldPluginsNode = (ChspsDomNode *)controlNode->ChildNodes().FindByName( KPluginsElement ); |
|
2905 if ( !oldPluginsNode ) |
|
2906 { |
|
2907 #ifdef HSPS_LOG_ACTIVE |
|
2908 if( iLogBus ) |
|
2909 { |
|
2910 iLogBus->LogText( _L( "ChspsMaintenanceHandler::UpdatePluginListL(): - plugin node was not found" ) ); |
|
2911 } |
|
2912 #endif |
|
2913 err = KErrNotFound; |
|
2914 } |
|
2915 else |
|
2916 { |
|
2917 #ifdef HSPS_LOG_ACTIVE |
|
2918 if( iLogBus ) |
|
2919 { |
|
2920 iLogBus->LogText( _L( "ChspsMaintenanceHandler::UpdatePluginListL(): - old plugins node has %d childs" ), |
|
2921 oldPluginsNode->ChildNodes().Length() ); |
|
2922 } |
|
2923 #endif |
|
2924 } |
|
2925 } |
|
2926 |
|
2927 const TInt nodeCount = aPluginIdList.Count(); |
|
2928 if ( !err ) |
|
2929 { |
|
2930 // Plugin node count and provided id count should match |
|
2931 if ( nodeCount < 1 || nodeCount != oldPluginsNode->ChildNodes().Length() ) |
|
2932 { |
|
2933 err = KErrArgument; |
|
2934 } |
|
2935 } |
|
2936 |
|
2937 // Find all plugin nodes under the plugins node in the requested sequence |
|
2938 CArrayFixFlat<ChspsDomNode*>* nodeArray = NULL; |
|
2939 if ( !err ) |
|
2940 { |
|
2941 nodeArray = new (ELeave)CArrayFixFlat<ChspsDomNode*>( nodeCount ); |
|
2942 CleanupStack::PushL( nodeArray ); |
|
2943 ChspsDomNode* node = NULL; |
|
2944 for( TInt nodeIndex=0; nodeIndex < nodeCount; nodeIndex++ ) |
|
2945 { |
|
2946 const TInt pluginId = aPluginIdList.At(nodeIndex); |
|
2947 node = FindChildPluginNode( |
|
2948 *oldPluginsNode, |
|
2949 pluginId ); |
|
2950 if ( !node ) |
|
2951 { |
|
2952 #ifdef HSPS_LOG_ACTIVE |
|
2953 if( iLogBus ) |
|
2954 { |
|
2955 iLogBus->LogText( _L( "ChspsMaintenanceHandler::UpdatePluginListL(): - FindChildPluginNode failure" ) ); |
|
2956 } |
|
2957 #endif |
|
2958 |
|
2959 err = KErrNotFound; |
|
2960 break; |
|
2961 } |
|
2962 nodeArray->AppendL( node ); |
|
2963 |
|
2964 #ifdef HSPS_LOG_ACTIVE |
|
2965 if( iLogBus ) |
|
2966 { |
|
2967 iLogBus->LogText( _L( "ChspsMaintenanceHandler::UpdatePluginListL(): - plugin id=%d" ), |
|
2968 pluginId ); |
|
2969 } |
|
2970 #endif |
|
2971 } |
|
2972 } |
|
2973 |
|
2974 ChspsDomNode* newPluginsNode = NULL; |
|
2975 if ( !err ) |
|
2976 { |
|
2977 // Clone the plugins node |
|
2978 newPluginsNode = oldPluginsNode->CloneWithoutKidsL( oldPluginsNode->StringPool() ); |
|
2979 CleanupStack::PushL( newPluginsNode ); |
|
2980 |
|
2981 // Add the cloned plugins node into the control node (removal of the old plugins node is done later) |
|
2982 const TInt KNewPosition = 0; |
|
2983 controlNode->ChildNodes().AddItemL( newPluginsNode, KNewPosition ); |
|
2984 newPluginsNode->SetParent( controlNode ); |
|
2985 |
|
2986 // Transfer ownership of the plugin nodes |
|
2987 const TInt arrayCount = nodeArray->Count(); |
|
2988 for( TInt arrayIndex=0; arrayIndex < arrayCount; arrayIndex++) |
|
2989 { |
|
2990 ChspsDomNode* pluginNode = nodeArray->At(arrayIndex); |
|
2991 if ( !pluginNode ) |
|
2992 { |
|
2993 err = KErrGeneral; |
|
2994 break; |
|
2995 } |
|
2996 newPluginsNode->AddChildL( pluginNode ); |
|
2997 pluginNode->SetParent( newPluginsNode ); |
|
2998 } |
|
2999 } |
|
3000 |
|
3001 if ( !err ) |
|
3002 { |
|
3003 // Remove plugin nodes from the old plugins node |
|
3004 const TInt remainingCount = oldPluginsNode->ChildNodes().Length(); |
|
3005 for( TInt nodeIndex=0; nodeIndex < remainingCount; nodeIndex++) |
|
3006 { |
|
3007 ChspsDomNode* node = (ChspsDomNode*)oldPluginsNode->ChildNodes().Item( 0 ); |
|
3008 if ( node ) |
|
3009 { |
|
3010 oldPluginsNode->ChildNodes().RemoveItem( node ); |
|
3011 } |
|
3012 } |
|
3013 if ( oldPluginsNode->ChildNodes().Length() != 0 ) |
|
3014 { |
|
3015 err = KErrGeneral; |
|
3016 } |
|
3017 } |
|
3018 |
|
3019 if ( !err ) |
|
3020 { |
|
3021 // Remove the old plugins node from the control node |
|
3022 controlNode->ChildNodes().RemoveItem( oldPluginsNode ); |
|
3023 delete oldPluginsNode; |
|
3024 oldPluginsNode = NULL; |
|
3025 } |
|
3026 |
|
3027 if ( newPluginsNode ) |
|
3028 { |
|
3029 CleanupStack::Pop( newPluginsNode ); |
|
3030 } |
|
3031 if ( nodeArray ) |
|
3032 { |
|
3033 CleanupStack::PopAndDestroy( nodeArray ); |
|
3034 } |
|
3035 |
|
3036 return err; |
|
3037 } |
|
3038 |
|
3039 //---------------------------------------------------------------------------- |
|
3040 // ChspsMaintenanceHandler::SetConfStateL() |
|
3041 // ---------------------------------------------------------------------------- |
|
3042 // |
|
3043 void ChspsMaintenanceHandler::SetConfStateL( |
|
3044 ChspsODT& aAppODT, |
|
3045 TInt aConfId, |
|
3046 ThspsConfigurationState aState, |
|
3047 ThspsConfStateChangeFilter aFilter ) |
|
3048 { |
|
3049 |
|
3050 // Get state attribute value |
|
3051 TPtrC8 state; |
|
3052 switch ( aState ) |
|
3053 { |
|
3054 case EhspsConfStateNotConfirmed: |
|
3055 state.Set( KConfStateNotConfirmed ); |
|
3056 break; |
|
3057 case EhspsConfStateWaitForConfirmation: |
|
3058 state.Set( KConfStateWaitForConfirmation ); |
|
3059 break; |
|
3060 case EhspsConfStateConfirmed: |
|
3061 state.Set( KConfStateConfirmed ); |
|
3062 break; |
|
3063 default: |
|
3064 state.Set( KConfStateError ); |
|
3065 break; |
|
3066 } |
|
3067 |
|
3068 // Find a configuration node with an id attribute that matches the |
|
3069 // provided id and update found node state attribute |
|
3070 // If aConfId is -1 all configuration nodes are updated |
|
3071 ChspsDomDocument& dom = aAppODT.DomDocument(); |
|
3072 ChspsDomDepthIterator* iter = ChspsDomDepthIterator::NewL( *dom.RootNode() ); |
|
3073 CleanupStack::PushL( iter ); |
|
3074 ChspsDomNode* node = iter->First(); |
|
3075 ChspsDomNode* prevNode = NULL; |
|
3076 TBool jobDone = EFalse; |
|
3077 while( node && !jobDone && prevNode != node ) |
|
3078 { |
|
3079 const TDesC8& name = node->Name(); |
|
3080 |
|
3081 // Configuration node is found |
|
3082 if ( name == KConfigurationElement ) |
|
3083 { |
|
3084 if ( aConfId != -1 ) |
|
3085 { |
|
3086 ChspsDomList& attrList = node->AttributeList(); |
|
3087 ChspsDomAttribute* idAttr = static_cast<ChspsDomAttribute*>( |
|
3088 attrList.FindByName( KConfigurationAttrId ) ); |
|
3089 if ( !idAttr ) |
|
3090 { |
|
3091 User::Leave( KErrNotFound ); |
|
3092 } |
|
3093 TInt id(0); |
|
3094 const TDesC8& idValue = idAttr->Value(); |
|
3095 TLex8 lex( idValue ); |
|
3096 lex.Val( id ); |
|
3097 TBuf8<10> confId; |
|
3098 confId.Num( aConfId ); |
|
3099 if ( aConfId == id && aFilter == EhspsConfStateChangeNoFilter ) |
|
3100 { |
|
3101 hspsServerUtil::AddAttributeDescL( |
|
3102 *node, |
|
3103 KConfigurationAttrState, |
|
3104 state ); |
|
3105 jobDone = ETrue; |
|
3106 } |
|
3107 else if ( aFilter == EhspsConfStateChangePlugins && |
|
3108 hspsServerUtil::GetParentNode( |
|
3109 *node, |
|
3110 KConfigurationElement, |
|
3111 KConfigurationAttrId, |
|
3112 confId ) ) |
|
3113 { |
|
3114 hspsServerUtil::AddAttributeDescL( |
|
3115 *node, |
|
3116 KConfigurationAttrState, |
|
3117 state ); |
|
3118 } |
|
3119 } |
|
3120 else |
|
3121 { |
|
3122 hspsServerUtil::AddAttributeDescL( |
|
3123 *node, |
|
3124 KConfigurationAttrState, |
|
3125 state ); |
|
3126 } |
|
3127 } |
|
3128 |
|
3129 prevNode = node; |
|
3130 node = iter->NextL(); |
|
3131 } |
|
3132 CleanupStack::PopAndDestroy( iter ); |
|
3133 |
|
3134 } |
|
3135 |
|
3136 // ----------------------------------------------------------------------------- |
|
3137 // ChspsMaintenanceService::hspsGetListHeadersL |
|
3138 // Gets the header list to aHeaderDataList |
|
3139 // (other items were commented in a header). |
|
3140 // ----------------------------------------------------------------------------- |
|
3141 // |
|
3142 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsGetListHeaders(const TDesC8& |
|
3143 /*aSearchMaskData*/, CArrayPtrSeg<HBufC8>& aHeaderDataList) |
|
3144 { |
|
3145 // set the default response |
|
3146 ThspsServiceCompletedMessage ret = EhspsGetListHeadersEmpty; |
|
3147 TInt errorCode; |
|
3148 TRAP( errorCode, GetHeaderListL( aHeaderDataList, *iSearchMask ) ); |
|
3149 if (errorCode) |
|
3150 { |
|
3151 ret = EhspsGetListHeadersFailed; |
|
3152 } |
|
3153 else |
|
3154 { |
|
3155 ret = EhspsGetListHeadersSuccess; |
|
3156 } |
|
3157 |
|
3158 return ret; |
|
3159 } |
|
3160 |
|
3161 // ----------------------------------------------------------------------------- |
|
3162 // ChspsMaintenanceHandler::hspsGetNextHeader() |
|
3163 // Gets the header list to aHeaderDataList |
|
3164 // (other items were commented in a header). |
|
3165 // ----------------------------------------------------------------------------- |
|
3166 // |
|
3167 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsGetNextHeader() |
|
3168 { |
|
3169 return EhspsServiceNotSupported; |
|
3170 } |
|
3171 |
|
3172 // ----------------------------------------------------------------------------- |
|
3173 // ChspsMaintenanceHandler::hspsSetActiveTheme |
|
3174 // Sets the active theme to central repository. |
|
3175 // (other items were commented in a header). |
|
3176 // ----------------------------------------------------------------------------- |
|
3177 // |
|
3178 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsSetActiveTheme(const ChspsODT& aSetMask, |
|
3179 ChspsODT& aOdt) |
|
3180 { |
|
3181 // set the default response |
|
3182 ThspsServiceCompletedMessage ret = EhspsSetActiveThemeFailed; |
|
3183 TInt errorCode = KErrNone; |
|
3184 |
|
3185 #ifdef HSPS_LOG_ACTIVE |
|
3186 if( iLogBus ) |
|
3187 { |
|
3188 iLogBus->LogText( _L( "ChspsMaintenanceHandler::hspsSetActiveTheme(): - requested for AppUid = %d, ThemeUid= %d." ), |
|
3189 aSetMask.RootUid(), |
|
3190 aSetMask.ThemeUid() ); |
|
3191 } |
|
3192 #endif |
|
3193 |
|
3194 TRAP( errorCode, errorCode = iThemeServer.ActivateThemeL( aSetMask, aOdt )); |
|
3195 if ( errorCode ) |
|
3196 { |
|
3197 #ifdef HSPS_LOG_ACTIVE |
|
3198 if( iLogBus ) |
|
3199 { |
|
3200 iLogBus->LogText( _L( "ChspsMaintenanceHandler::hspsSetActiveTheme(): - theme activation failed - bad ODT!" ) ); |
|
3201 } |
|
3202 #endif |
|
3203 |
|
3204 ret = EhspsSetActiveThemeFailed; |
|
3205 } |
|
3206 else |
|
3207 { |
|
3208 #ifdef HSPS_LOG_ACTIVE |
|
3209 if( iLogBus ) |
|
3210 { |
|
3211 iLogBus->LogText( _L( "ChspsMaintenanceHandler::hspsSetActiveTheme(): - activated for AppUid = %d, ThemeUid= %d." ), |
|
3212 aOdt.RootUid(), |
|
3213 aOdt.ThemeUid() ); |
|
3214 } |
|
3215 #endif |
|
3216 |
|
3217 ret = EhspsSetActiveThemeSuccess; |
|
3218 } |
|
3219 return ret; |
|
3220 } |
|
3221 |
|
3222 // ----------------------------------------------------------------------------- |
|
3223 // ChspsMaintenanceHandler::hspsRestoreDefault |
|
3224 // Restores the default theme and returns either EhspsRestoreDefaultSuccess or |
|
3225 // EhspsRestoreDefaultFailed. |
|
3226 // (other items were commented in a header). |
|
3227 // ----------------------------------------------------------------------------- |
|
3228 // |
|
3229 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsRestoreDefault( const ChspsODT& aSetMask, |
|
3230 ChspsODT& aHeader ) |
|
3231 { |
|
3232 // set the default response |
|
3233 ThspsServiceCompletedMessage ret = EhspsRestoreDefaultFailed; |
|
3234 TInt errorCode = 0; |
|
3235 TRAP( errorCode, RestoredDefaultL( aSetMask, aHeader ) ); |
|
3236 if ( errorCode ) |
|
3237 { |
|
3238 ret = EhspsRestoreDefaultFailed; |
|
3239 } |
|
3240 else |
|
3241 { |
|
3242 ret = EhspsRestoreDefaultSuccess; |
|
3243 } |
|
3244 return ret; |
|
3245 } |
|
3246 |
|
3247 |
|
3248 // ----------------------------------------------------------------------------- |
|
3249 // ChspsMaintenanceHandler::hspsRemoveThemeL |
|
3250 // Removes the theme by calling the appropriate method in definition repository. |
|
3251 // (other items were commented in a header). |
|
3252 // ----------------------------------------------------------------------------- |
|
3253 // |
|
3254 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsRemoveThemeL( const ChspsODT& aSetMask ) |
|
3255 { |
|
3256 ThspsServiceCompletedMessage ret( EhspsRemoveThemeFailed ); |
|
3257 |
|
3258 if( !( aSetMask.Flags() & EhspsThemeStatusLicenceeDefault ) ) |
|
3259 { |
|
3260 RArray<ThspsRepositoryInfo> notifParams; |
|
3261 |
|
3262 if( !iDefinitionRepository.Locked() ) |
|
3263 { |
|
3264 iDefinitionRepository.Lock(); |
|
3265 |
|
3266 // In case of error. repository is unlocked |
|
3267 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
3268 |
|
3269 // Check what is being being uninstalled |
|
3270 TInt error( KErrNone ); |
|
3271 if ( aSetMask.ConfigurationType() != EhspsAppConfiguration ) |
|
3272 { |
|
3273 // Fix plugin instances and get notifications from valid cases |
|
3274 TRAP( error, RemovePluginFromAppConfsL( aSetMask, notifParams ) ); |
|
3275 } |
|
3276 |
|
3277 if( !error ) |
|
3278 { |
|
3279 // Remove the actual plugin from file system |
|
3280 TRAP( error, RemoveThemeL( aSetMask ) ); |
|
3281 } |
|
3282 |
|
3283 if( !error ) |
|
3284 { |
|
3285 // Remove header from the cache |
|
3286 iThemeServer.UpdateHeaderListCache( |
|
3287 EhspsCacheRemoveHeader, |
|
3288 aSetMask.RootUid(), |
|
3289 aSetMask.ProviderUid(), |
|
3290 aSetMask.ThemeUid() ); |
|
3291 } |
|
3292 |
|
3293 // Must be done before the notifications are sent |
|
3294 iDefinitionRepository.Unlock(); |
|
3295 CleanupStack::Pop( &iDefinitionRepository ); |
|
3296 |
|
3297 if ( !error ) |
|
3298 { |
|
3299 // Send the notifications which will update the client UIs |
|
3300 for( TInt i=0; i < notifParams.Count(); i++ ) |
|
3301 { |
|
3302 iDefinitionRepository.RegisterNotification( notifParams[i] ); |
|
3303 } |
|
3304 |
|
3305 ret = EhspsRemoveThemeSuccess; |
|
3306 } |
|
3307 } |
|
3308 |
|
3309 notifParams.Close(); |
|
3310 } |
|
3311 |
|
3312 return ret; |
|
3313 } |
|
3314 |
|
3315 // ----------------------------------------------------------------------------- |
|
3316 // RemovePluginFromAppConfsL |
|
3317 // ----------------------------------------------------------------------------- |
|
3318 // |
|
3319 void ChspsMaintenanceHandler::RemovePluginFromAppConfsL( |
|
3320 const ChspsODT& aOdt, |
|
3321 RArray<ThspsRepositoryInfo>& aNotificationParams ) |
|
3322 { |
|
3323 __ASSERT_DEBUG( aOdt.ThemeUid(), User::Leave( KErrArgument ) ); |
|
3324 |
|
3325 // Loop application configurations |
|
3326 const TInt count = iHeaderListCache.Count(); |
|
3327 for ( TInt i = 0; i < count; i++ ) |
|
3328 { |
|
3329 ChspsODT* header = iHeaderListCache.At(i); |
|
3330 if ( header && header->ConfigurationType() == EhspsAppConfiguration ) |
|
3331 { |
|
3332 // Get an ODT from the looped application configuration header |
|
3333 ChspsODT* appOdt = ChspsODT::NewL(); |
|
3334 CleanupStack::PushL( appOdt ); |
|
3335 |
|
3336 // Fill only those values which are required by the GetOdtL call |
|
3337 appOdt->SetRootUid( header->RootUid() ); |
|
3338 appOdt->SetProviderUid( header->ProviderUid() ); |
|
3339 appOdt->SetThemeUid( header->ThemeUid() ); |
|
3340 appOdt->SetProviderNameL( header->ProviderName() ); |
|
3341 appOdt->SetThemeShortNameL( header->ThemeShortName() ); |
|
3342 appOdt->SetThemeVersionL( header->ThemeVersion() ); |
|
3343 User::LeaveIfError( iDefinitionRepository.GetOdtL( *appOdt ) ); |
|
3344 |
|
3345 // Get active application configuration for the client in question |
|
3346 TInt activeAppConfUid = 0; |
|
3347 iCentralRepository.Get( appOdt->RootUid(), activeAppConfUid ); |
|
3348 |
|
3349 // Get plugin id's from the instances in the application configuration |
|
3350 RArray<TInt> pluginIds; |
|
3351 CleanupClosePushL( pluginIds ); |
|
3352 |
|
3353 hspsServerUtil::GetPluginIdsByUidL( *appOdt, |
|
3354 TUid::Uid( aOdt.ThemeUid() ), |
|
3355 pluginIds ); |
|
3356 |
|
3357 // If there were plugin instances in an application configuration |
|
3358 if ( pluginIds.Count() > 0 ) |
|
3359 { |
|
3360 |
|
3361 // If the application configuration is inactive |
|
3362 if ( activeAppConfUid != appOdt->ThemeUid() ) |
|
3363 { |
|
3364 // Prevent notifications and set state of the plugin instances to "uninstalled", |
|
3365 // AI3 will remove instances (or replaces them with an empty widget) |
|
3366 // when it loads the configuration after it has first been activated |
|
3367 TBool updatesDone = InvalidateUninstalledPluginInstancesL( |
|
3368 *appOdt, |
|
3369 aOdt.ThemeUid(), |
|
3370 pluginIds ); |
|
3371 #ifdef HSPS_LOG_ACTIVE |
|
3372 if( iLogBus ) |
|
3373 { |
|
3374 if ( updatesDone ) |
|
3375 { |
|
3376 iLogBus->LogText( |
|
3377 _L( "ChspsMaintenanceHandler::RemovePluginFromAppConfsL(): old plugin instances were updated in inactive root configuration" ) |
|
3378 ); |
|
3379 } |
|
3380 else |
|
3381 { |
|
3382 iLogBus->LogText( |
|
3383 _L( "ChspsMaintenanceHandler::RemovePluginFromAppConfsL(): nothing was done" ) |
|
3384 ); |
|
3385 } |
|
3386 } |
|
3387 #endif |
|
3388 } |
|
3389 else |
|
3390 { |
|
3391 // Notify active application configuration that old plugin instances need to be replaced |
|
3392 TBool lastNotification = EFalse; |
|
3393 for( TInt i = 0; i < pluginIds.Count(); i++ ) |
|
3394 { |
|
3395 if( i == pluginIds.Count() - 1 ) |
|
3396 { |
|
3397 lastNotification = ETrue; |
|
3398 } |
|
3399 ThspsRepositoryInfo info( |
|
3400 ThspsRepositoryEvent( EhspsClean ), |
|
3401 appOdt->RootUid(), |
|
3402 appOdt->ThemeUid(), |
|
3403 0, //=Any file |
|
3404 appOdt->ProviderUid(), |
|
3405 aOdt.RootUid(), |
|
3406 aOdt.ProviderUid(), |
|
3407 aOdt.ThemeUid(), |
|
3408 pluginIds[i], |
|
3409 lastNotification, |
|
3410 aOdt.ThemeFullName(), |
|
3411 (TLanguage)( aOdt.OdtLanguage() ) ); |
|
3412 aNotificationParams.Append(info); |
|
3413 } |
|
3414 #ifdef HSPS_LOG_ACTIVE |
|
3415 if( iLogBus ) |
|
3416 { |
|
3417 iLogBus->LogText( |
|
3418 _L( "ChspsMaintenanceHandler::RemovePluginFromAppConfsL(): plugin uninstalled notifications sent to SAPI for all instances" ) |
|
3419 ); |
|
3420 } |
|
3421 #endif |
|
3422 } |
|
3423 } // instance count > 0 |
|
3424 else |
|
3425 { |
|
3426 if ( activeAppConfUid == appOdt->ThemeUid() ) |
|
3427 { |
|
3428 // Notify active application configuration which had no plugin instances |
|
3429 ThspsRepositoryInfo info( |
|
3430 ThspsRepositoryEvent( EhspsClean ), |
|
3431 appOdt->RootUid(), |
|
3432 appOdt->ThemeUid(), |
|
3433 0, //=Any file |
|
3434 appOdt->ProviderUid(), |
|
3435 aOdt.RootUid(), |
|
3436 aOdt.ProviderUid(), |
|
3437 aOdt.ThemeUid(), |
|
3438 0, |
|
3439 ETrue, |
|
3440 aOdt.ThemeFullName(), |
|
3441 (TLanguage)( aOdt.OdtLanguage() ) ); |
|
3442 aNotificationParams.Append(info); |
|
3443 } |
|
3444 } |
|
3445 |
|
3446 pluginIds.Close(); |
|
3447 CleanupStack::PopAndDestroy( 2, appOdt ); // appOdt, pluginIds |
|
3448 appOdt = NULL; |
|
3449 |
|
3450 } // app configuration |
|
3451 |
|
3452 } // header loop |
|
3453 |
|
3454 } |
|
3455 |
|
3456 // ----------------------------------------------------------------------------- |
|
3457 // ChspsMaintenanceHandler::InvalidateUninstalledPluginInstancesL |
|
3458 // ----------------------------------------------------------------------------- |
|
3459 TBool ChspsMaintenanceHandler::InvalidateUninstalledPluginInstancesL( |
|
3460 ChspsODT& aAppODT, |
|
3461 const TInt aPluginUid, |
|
3462 const RArray<TInt>& aPluginIds ) |
|
3463 { |
|
3464 // Should be already locked by hspsRemoveThemeL() |
|
3465 __ASSERT_DEBUG( iDefinitionRepository.Locked(), User::Leave( KErrGeneral ) ); |
|
3466 |
|
3467 #ifdef HSPS_LOG_ACTIVE |
|
3468 if( iLogBus ) |
|
3469 { |
|
3470 iLogBus->LogText( _L( "ChspsMaintenanceHandler::InvalidateUninstalledPluginInstancesL(): - Before Error state updates:") ); |
|
3471 ChspsOdtDump::Dump( aAppODT, *iLogBus ); |
|
3472 } |
|
3473 #endif |
|
3474 |
|
3475 TInt processedCount = 0; |
|
3476 for( TInt idIndex = 0; idIndex < aPluginIds.Count(); idIndex++ ) |
|
3477 { |
|
3478 const TInt pluginId( aPluginIds[idIndex] ); |
|
3479 |
|
3480 // If full DOM/application configuration hasn't been generated yet (plugin IDs are unset) |
|
3481 if ( pluginId > 0 ) |
|
3482 { |
|
3483 ChspsDomNode *pluginNode = hspsServerUtil::FindPluginNodeL( aAppODT, pluginId ); |
|
3484 __ASSERT_DEBUG( pluginNode, User::Leave( KErrArgument) ); |
|
3485 if ( pluginNode ) |
|
3486 { |
|
3487 ChspsDomNode* confNode = (ChspsDomNode *)pluginNode->ChildNodes().Item( 0 ); |
|
3488 __ASSERT_DEBUG( confNode, User::Leave( KErrArgument) ); |
|
3489 if ( confNode ) |
|
3490 { |
|
3491 // Indicate that the configuration is in error state |
|
3492 // Should be changed to "uninstalled" when Homescreen supports it silently |
|
3493 hspsServerUtil::AddAttributeDescL( *confNode, KConfigurationAttrState, KConfStateError ); |
|
3494 processedCount++; |
|
3495 } |
|
3496 } |
|
3497 } |
|
3498 } |
|
3499 |
|
3500 if ( processedCount ) |
|
3501 { |
|
3502 // Remove uninstalled resources from the server (copies will remain in client's private directory) |
|
3503 RemovePluginResourcesL( aAppODT, aPluginUid ); |
|
3504 |
|
3505 // Store changes |
|
3506 User::LeaveIfError( iDefinitionRepository.SetOdtL( aAppODT ) ); |
|
3507 } |
|
3508 |
|
3509 #ifdef HSPS_LOG_ACTIVE |
|
3510 if( iLogBus ) |
|
3511 { |
|
3512 if ( processedCount > 0 ) |
|
3513 { |
|
3514 iLogBus->LogText( _L( "ChspsMaintenanceHandler::InvalidateUninstalledPluginInstancesL(): - Error states updated") ); |
|
3515 ChspsOdtDump::Dump( aAppODT, *iLogBus ); |
|
3516 } |
|
3517 else |
|
3518 { |
|
3519 iLogBus->LogText( _L( "ChspsMaintenanceHandler::InvalidateUninstalledPluginInstancesL(): - Error states were not added") ); |
|
3520 } |
|
3521 } |
|
3522 #endif |
|
3523 |
|
3524 return ( processedCount > 0 ); |
|
3525 } |
|
3526 |
|
3527 // ----------------------------------------------------------------------------- |
|
3528 // ChspsMaintenanceHandler::hspsPluginUpdateL |
|
3529 // (other items were commented in a header). |
|
3530 // ----------------------------------------------------------------------------- |
|
3531 |
|
3532 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsPluginUpdateL( const ChspsODT& aOdt ) |
|
3533 { |
|
3534 ThspsServiceCompletedMessage ret( EhspsUpdatePluginFailed ); |
|
3535 |
|
3536 if( !iDefinitionRepository.Locked() ) |
|
3537 { |
|
3538 iDefinitionRepository.Lock(); |
|
3539 |
|
3540 // In case of error. repository is unlocked |
|
3541 CleanupStack::PushL( TCleanupItem( UnlockRepository, &iDefinitionRepository ) ); |
|
3542 |
|
3543 // set the default response |
|
3544 ret = EhspsUpdatePluginSuccess; |
|
3545 |
|
3546 TInt errorCode( KErrNone ); |
|
3547 |
|
3548 //create whole pluginOdt aOdt is only header for pluginOdt |
|
3549 ChspsODT* odt = ChspsODT::NewL(); |
|
3550 CleanupStack::PushL( odt ); |
|
3551 odt->SetRootUid( aOdt.RootUid() ); |
|
3552 odt->SetThemeUid( aOdt.ThemeUid() ); |
|
3553 odt->SetConfigurationType( aOdt.ConfigurationType() ); |
|
3554 odt->SetRootUid( aOdt.RootUid() ); |
|
3555 odt->SetProviderUid( aOdt.ProviderUid() ); |
|
3556 odt->SetThemeUid( aOdt.ThemeUid() ); |
|
3557 odt->SetProviderNameL( aOdt.ProviderName() ); |
|
3558 odt->SetThemeFullNameL( aOdt.ThemeFullName() ); |
|
3559 odt->SetThemeShortNameL( aOdt.ThemeShortName() ); |
|
3560 odt->SetThemeVersionL( aOdt.ThemeVersion() ); |
|
3561 odt->SetFlags( aOdt.Flags() ); |
|
3562 odt->SetMultiInstance( aOdt.MultiInstance() ); |
|
3563 User::LeaveIfError( iDefinitionRepository.GetOdtL( *odt ) ); |
|
3564 |
|
3565 RArray<ThspsRepositoryInfo> notifParams; |
|
3566 |
|
3567 TRAP( errorCode, UpdatePluginFromAppConfsL( *odt, notifParams )); |
|
3568 |
|
3569 if( errorCode ) |
|
3570 { |
|
3571 ret = EhspsUpdatePluginFailed; |
|
3572 } |
|
3573 |
|
3574 iDefinitionRepository.Unlock(); |
|
3575 CleanupStack::Pop( &iDefinitionRepository ); |
|
3576 |
|
3577 if( ret == EhspsUpdatePluginSuccess ) |
|
3578 { |
|
3579 if(notifParams.Count() > 0 ) |
|
3580 { |
|
3581 //There is active app&appconfs to notify |
|
3582 |
|
3583 |
|
3584 for( TInt i=0; i < notifParams.Count(); i++ ) |
|
3585 { |
|
3586 iDefinitionRepository.RegisterNotification( notifParams[i] ); |
|
3587 } |
|
3588 } |
|
3589 |
|
3590 } |
|
3591 notifParams.Close(); |
|
3592 |
|
3593 CleanupStack::PopAndDestroy( odt ); |
|
3594 } |
|
3595 |
|
3596 return ret; |
|
3597 } |
|
3598 // ----------------------------------------------------------------------------- |
|
3599 // ChspsMaintenanceHandler::UpdatePluginFromAppConfsL |
|
3600 // (other items were commented in a header). |
|
3601 //--------------------------------------------------------------------- |
|
3602 void ChspsMaintenanceHandler::UpdatePluginFromAppConfsL( ChspsODT& aOdt, |
|
3603 RArray<ThspsRepositoryInfo>& aNotificationParams ) |
|
3604 { |
|
3605 |
|
3606 if ( iHeaderListCache.Length() > 0 ) |
|
3607 { |
|
3608 TInt count = iHeaderListCache.Count(); |
|
3609 for ( TInt i = 0; i < count; i++ ) |
|
3610 { |
|
3611 ChspsODT* header = iHeaderListCache.At(i); |
|
3612 if ( header->ConfigurationType() == EhspsAppConfiguration ) |
|
3613 { |
|
3614 ChspsODT* odt = ChspsODT::NewL(); |
|
3615 CleanupStack::PushL( odt ); |
|
3616 odt->SetRootUid( header->RootUid() ); |
|
3617 odt->SetThemeUid( header->ThemeUid() ); |
|
3618 odt->SetConfigurationType( header->ConfigurationType() ); |
|
3619 odt->SetRootUid( header->RootUid() ); |
|
3620 odt->SetProviderUid( header->ProviderUid() ); |
|
3621 odt->SetThemeUid( header->ThemeUid() ); |
|
3622 odt->SetProviderNameL( header->ProviderName() ); |
|
3623 odt->SetThemeFullNameL( header->ThemeFullName() ); |
|
3624 odt->SetThemeShortNameL( header->ThemeShortName() ); |
|
3625 odt->SetThemeVersionL( header->ThemeVersion() ); |
|
3626 odt->SetFlags( header->Flags() ); |
|
3627 odt->SetMultiInstance( header->MultiInstance() ); |
|
3628 User::LeaveIfError( iDefinitionRepository.GetOdtL( *odt ) ); |
|
3629 |
|
3630 |
|
3631 RArray<TInt> pluginIds; |
|
3632 |
|
3633 hspsServerUtil::GetPluginIdsByUidL( *odt, |
|
3634 TUid::Uid( aOdt.ThemeUid() ), |
|
3635 pluginIds ); |
|
3636 |
|
3637 |
|
3638 if ( pluginIds.Count() > 0 ) |
|
3639 { |
|
3640 |
|
3641 |
|
3642 TInt err = UpdatePluginConfigurationL( |
|
3643 *odt, |
|
3644 aOdt, |
|
3645 pluginIds ); |
|
3646 |
|
3647 User::LeaveIfError( iDefinitionRepository.SetOdtL( *odt ) ); |
|
3648 |
|
3649 |
|
3650 |
|
3651 TBool status = EFalse; |
|
3652 for(TInt i = 0; i < pluginIds.Count(); i++ ) |
|
3653 { |
|
3654 if( i == pluginIds.Count() - 1 ) |
|
3655 { |
|
3656 status = ETrue; |
|
3657 } |
|
3658 ThspsRepositoryInfo info( |
|
3659 ThspsRepositoryEvent( EhspsODTUpdated ), |
|
3660 odt->RootUid(), |
|
3661 odt->ThemeUid(), |
|
3662 0, //=Any file |
|
3663 0, |
|
3664 aOdt.RootUid(), |
|
3665 aOdt.ProviderUid(), |
|
3666 aOdt.ThemeUid(), |
|
3667 pluginIds[i], |
|
3668 status, |
|
3669 aOdt.ThemeFullName(), |
|
3670 (TLanguage)( aOdt.OdtLanguage() ) ); |
|
3671 aNotificationParams.Append(info); |
|
3672 } |
|
3673 } |
|
3674 |
|
3675 |
|
3676 |
|
3677 pluginIds.Close(); |
|
3678 |
|
3679 CleanupStack::PopAndDestroy( odt ); |
|
3680 |
|
3681 } |
|
3682 } |
|
3683 |
|
3684 } |
|
3685 } |
|
3686 // ----------------------------------------------------------------------------- |
|
3687 // ChspsMaintenanceHandler::UpdatePluginConfigurationL |
|
3688 // Not supported |
|
3689 // (other items were commented in a header). |
|
3690 // ----------------------------------------------------------------------------- |
|
3691 // |
|
3692 TInt ChspsMaintenanceHandler::UpdatePluginConfigurationL( |
|
3693 ChspsODT& aOdt, |
|
3694 ChspsODT& aPluginOdt, |
|
3695 RArray<TInt>& aPluginIds ) |
|
3696 { |
|
3697 TInt err(KErrNone); |
|
3698 |
|
3699 // remove old resources |
|
3700 err = RemovePluginResourcesL( aOdt, aPluginOdt.ThemeUid() ); |
|
3701 |
|
3702 if( err ) |
|
3703 { |
|
3704 return err; |
|
3705 } |
|
3706 |
|
3707 ChspsDomNode* pluginNode = NULL; |
|
3708 ChspsDomNode* configNode = NULL; |
|
3709 for(TInt i = 0; i < aPluginIds.Count() && err == KErrNone; i++ ) |
|
3710 { |
|
3711 pluginNode = |
|
3712 hspsServerUtil::FindPluginNodeL( aOdt, aPluginIds[i] ); |
|
3713 TInt index = 0; |
|
3714 |
|
3715 configNode = |
|
3716 hspsServerUtil::FindChildNodeByTagL( KConfigurationElement, *pluginNode, index ); |
|
3717 |
|
3718 if( configNode ) |
|
3719 { |
|
3720 TInt id = hspsServerUtil::DecString2Int( |
|
3721 configNode->AttributeValue(KConfigurationAttrId)); |
|
3722 hspsServerUtil::AddAttributeNumericL( *aPluginOdt.DomDocument().RootNode(), KConfigurationAttrId, id ); |
|
3723 |
|
3724 pluginNode->ReplaceChildL(configNode,aPluginOdt.DomDocument().RootNode()); |
|
3725 } |
|
3726 else |
|
3727 { |
|
3728 err = KErrNotFound; |
|
3729 } |
|
3730 |
|
3731 } |
|
3732 if( err ) |
|
3733 { |
|
3734 return err; |
|
3735 } |
|
3736 |
|
3737 _LIT(KSourcesFolder, "\\sources\\"); |
|
3738 _LIT(KLocalesFolder, "\\locales\\"); |
|
3739 // Add plugin resources |
|
3740 TInt resourceCount = aPluginOdt.ResourceCount(); |
|
3741 for ( TInt index=0; index < resourceCount; index++ ) |
|
3742 { |
|
3743 ChspsResource& pluginResource = aPluginOdt.ResourceL(index); |
|
3744 // Add only those that are located under the sources folder |
|
3745 if ( pluginResource.FileName().FindF( KSourcesFolder ) > 0 |
|
3746 || pluginResource.FileName().FindF( KLocalesFolder ) > 0 ) |
|
3747 { |
|
3748 ChspsResource* r = pluginResource.CloneL(); |
|
3749 CleanupStack::PushL( r ); |
|
3750 aOdt.AddResourceL( r ); |
|
3751 CleanupStack::Pop( r ); |
|
3752 } |
|
3753 } |
|
3754 |
|
3755 return err; |
|
3756 } |
|
3757 // ----------------------------------------------------------------------------- |
|
3758 // ChspsMaintenanceHandler::hspsGetListHeaders() |
|
3759 // Not supported |
|
3760 // (other items were commented in a header). |
|
3761 // ----------------------------------------------------------------------------- |
|
3762 // |
|
3763 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsGetListHeaders(const ChspsODT& /*aSearchMask*/, |
|
3764 CArrayPtrFlat<ChspsODT>& /*aHeaderList*/) |
|
3765 { |
|
3766 return EhspsServiceNotSupported; |
|
3767 } |
|
3768 |
|
3769 // ----------------------------------------------------------------------------- |
|
3770 // ChspsMaintenanceHandler::hspsSetActiveTheme() |
|
3771 // Not supported |
|
3772 // (other items were commented in a header). |
|
3773 // ----------------------------------------------------------------------------- |
|
3774 // |
|
3775 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsSetActiveTheme(const TDesC8& /*aSetMaskData*/, |
|
3776 TDes8& /*aHeaderData*/) |
|
3777 { |
|
3778 return EhspsServiceNotSupported; |
|
3779 } |
|
3780 |
|
3781 // ----------------------------------------------------------------------------- |
|
3782 // ChspsMaintenanceHandler::hspsAddPlugin() |
|
3783 // Not supported - inherited from an interface and not used. |
|
3784 // ----------------------------------------------------------------------------- |
|
3785 // |
|
3786 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsAddPlugin( |
|
3787 const TInt /*aAppUid*/, |
|
3788 const TInt /*aParentPluginId*/, |
|
3789 const TInt /*aPluginUid*/, |
|
3790 const TInt /*aPosition*/, |
|
3791 TInt& /*aAddedPluginId*/ ) |
|
3792 { |
|
3793 return EhspsServiceNotSupported; |
|
3794 } |
|
3795 |
|
3796 // ----------------------------------------------------------------------------- |
|
3797 // ChspsMaintenanceHandler::hspsRemovePlugin() |
|
3798 // Not supported - inherited from an interface and not used. |
|
3799 // ----------------------------------------------------------------------------- |
|
3800 // |
|
3801 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsRemovePlugin( |
|
3802 const TInt /*aAppUid*/, |
|
3803 const TInt /*aPluginId*/ ) |
|
3804 { |
|
3805 return EhspsServiceNotSupported; |
|
3806 } |
|
3807 |
|
3808 // ----------------------------------------------------------------------------- |
|
3809 // ChspsMaintenanceHandler::hspsSetActivePlugin() |
|
3810 // Not supported - inherited from an interface and not used. |
|
3811 // ----------------------------------------------------------------------------- |
|
3812 // |
|
3813 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsSetActivePlugin( |
|
3814 const TInt /*aAppUid*/, |
|
3815 const TInt /*aPluginId*/ ) |
|
3816 { |
|
3817 return EhspsServiceNotSupported; |
|
3818 } |
|
3819 |
|
3820 // ----------------------------------------------------------------------------- |
|
3821 // ChspsMaintenanceHandler::hspsReplacePlugin() |
|
3822 // Not supported - inherited from an interface and not used. |
|
3823 // ----------------------------------------------------------------------------- |
|
3824 // |
|
3825 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsReplacePlugin( |
|
3826 const TInt /*aAppUid*/, |
|
3827 const TInt /*aPluginId*/, |
|
3828 const TInt /*aConfUid*/ ) |
|
3829 { |
|
3830 return EhspsServiceNotSupported; |
|
3831 } |
|
3832 |
|
3833 // ----------------------------------------------------------------------------- |
|
3834 // ChspsMaintenanceHandler::hspsSetPluginSettings() |
|
3835 // Not supported - inherited from an interface and not used. |
|
3836 // ----------------------------------------------------------------------------- |
|
3837 // |
|
3838 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsSetPluginSettings( |
|
3839 const ChspsODT& /*aHeader*/, |
|
3840 const TInt /*aPluginId*/, |
|
3841 ChspsDomDocument& /*aDom*/, |
|
3842 const TBool /*aPluginStoringStatus*/) |
|
3843 { |
|
3844 return EhspsServiceNotSupported; |
|
3845 } |
|
3846 |
|
3847 // ----------------------------------------------------------------------------- |
|
3848 // ChspsMaintenanceHandler::hspsMovePluginsL() |
|
3849 // Not supported - inherited from an interface and not used. |
|
3850 // ----------------------------------------------------------------------------- |
|
3851 // |
|
3852 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsMovePluginsL( |
|
3853 const TInt /*aAppUid*/, |
|
3854 const TInt /*aConfId*/, |
|
3855 const CArrayFixFlat<TInt>& /*aPluginIdList*/ ) |
|
3856 { |
|
3857 return EhspsServiceNotSupported; |
|
3858 } |
|
3859 |
|
3860 // ----------------------------------------------------------------------------- |
|
3861 // ChspsMaintenanceHandler::hspsSetConfState() |
|
3862 // Not supported - inherited from an interface and not used. |
|
3863 // ----------------------------------------------------------------------------- |
|
3864 // |
|
3865 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsSetConfState( |
|
3866 const TInt /*aAppUid*/, |
|
3867 const TInt /*aConfId*/, |
|
3868 const ThspsConfigurationState /*aState*/, |
|
3869 const ThspsConfStateChangeFilter /*aFilter*/ ) |
|
3870 { |
|
3871 return EhspsServiceNotSupported; |
|
3872 } |
|
3873 |
|
3874 // ----------------------------------------------------------------------------- |
|
3875 // ChspsMaintenanceHandler::hspsRestoreActiveAppConf() |
|
3876 // Not supported - inherited from an interface and not used. |
|
3877 // ----------------------------------------------------------------------------- |
|
3878 // |
|
3879 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsRestoreActiveAppConf( |
|
3880 const TInt /*aAppUid*/, |
|
3881 const TInt /*aConfUid*/ ) |
|
3882 { |
|
3883 return EhspsServiceNotSupported; |
|
3884 } |
|
3885 |
|
3886 // ----------------------------------------------------------------------------- |
|
3887 // ChspsMaintenanceHandler::hspsCancelGetListHeaders() |
|
3888 // Cancels the GetListHeaders request |
|
3889 // (other items were commented in a header). |
|
3890 // ----------------------------------------------------------------------------- |
|
3891 // |
|
3892 ThspsServiceCompletedMessage ChspsMaintenanceHandler::hspsCancelGetListHeaders() |
|
3893 { |
|
3894 if ( IsActive() ) |
|
3895 { |
|
3896 Cancel(); |
|
3897 } |
|
3898 iHeaderDataList->ResetAndDestroy(); // no headers |
|
3899 iDeliveryCount = 0; // no delivered headers |
|
3900 iSubscription = EFalse; // no subscription |
|
3901 CompleteRequest( EhspsServiceRequestCanceled, iMessagePtr ); |
|
3902 // return with cancellation confirm |
|
3903 return EhspsServiceRequestCanceled; |
|
3904 } |
|
3905 // ----------------------------------------------------------------------------- |
|
3906 // ChspsClientRequestHandler::HandleDefinitionRespositoryEvent() |
|
3907 // Handles events coming from hspsDefinitionRepository. |
|
3908 // (other items were commented in a header). |
|
3909 // ----------------------------------------------------------------------------- |
|
3910 // |
|
3911 TBool ChspsMaintenanceHandler::HandleDefinitionRespositoryEvent( ThspsRepositoryInfo aRepositoryInfo ) |
|
3912 { |
|
3913 TInt errorCode = KErrNone; |
|
3914 TBool status(EFalse); |
|
3915 TRAP( errorCode, status = HandleDefinitionRespositoryEventL( aRepositoryInfo ) ); |
|
3916 if( errorCode != KErrNone ) |
|
3917 { |
|
3918 #ifdef HSPS_LOG_ACTIVE |
|
3919 if( iLogBus ) |
|
3920 { |
|
3921 iLogBus->LogText( _L( "ChspsClientRequestHandler::HandleDefinitionRespositoryEvent(): - Error occured in HandleDefinitionRespositoryEventL" ) ); |
|
3922 } |
|
3923 #endif |
|
3924 } |
|
3925 return status; |
|
3926 } |
|
3927 // ----------------------------------------------------------------------------- |
|
3928 // ChspsMaintenanceHandler::HandleDefinitionRespositoryEvent() |
|
3929 // Handles events coming from hspsDefinitionRepository. |
|
3930 // (other items were commented in a header). |
|
3931 // ----------------------------------------------------------------------------- |
|
3932 // |
|
3933 TBool ChspsMaintenanceHandler::HandleDefinitionRespositoryEventL( ThspsRepositoryInfo aRepositoryInfo ) |
|
3934 { |
|
3935 // is there any changes in cache |
|
3936 if ( ( aRepositoryInfo.iEventType & EhspsCacheUpdate ) && !iDefinitionRepository.Locked() && iSubscription && !iMessagePtr.IsNull() ) |
|
3937 { |
|
3938 // cache changed, check if there is any changes when comparing to the local list |
|
3939 // and what kind of change there is |
|
3940 iCompletedMessage = GetHeaderListUpdateL(); |
|
3941 // is there headers to deliver |
|
3942 if ( iCompletedMessage == EhspsGetListHeadersRestart ) |
|
3943 { |
|
3944 if (iHeaderDataList->Count()) |
|
3945 { |
|
3946 // at least one header on the list |
|
3947 iMessagePtr.WriteL(2,iHeaderDataList->At(iDeliveryCount)->Des(),0); |
|
3948 // add list count |
|
3949 iDeliveryCount++; |
|
3950 // delivery of the first header |
|
3951 } |
|
3952 CompleteRequest( EhspsGetListHeadersRestart, iMessagePtr ); |
|
3953 } |
|
3954 else if ( iCompletedMessage == EhspsGetListHeadersUpdate ) |
|
3955 { |
|
3956 // return list update, count continues from where it was |
|
3957 iMessagePtr.WriteL(2,iHeaderDataList->At(iDeliveryCount)->Des(),0); |
|
3958 // add list count |
|
3959 iDeliveryCount++; |
|
3960 // deliver a list item |
|
3961 CompleteRequest( EhspsGetListHeadersUpdate, iMessagePtr ); |
|
3962 } |
|
3963 else if (iCompletedMessage == EhspsGetListHeadersEmpty) |
|
3964 { |
|
3965 CompleteRequest( EhspsGetListHeadersEmpty, iMessagePtr ); |
|
3966 // no list update available at the moment, continue the polling for list updates |
|
3967 } |
|
3968 } |
|
3969 else if ( ( aRepositoryInfo.iEventType & EhspsCacheUpdate ) && iDefinitionRepository.Locked() |
|
3970 && !IsActive() && iSubscription ) |
|
3971 { |
|
3972 After(KHeaderListUpdatePollingTimeSpan); |
|
3973 } |
|
3974 return EFalse; |
|
3975 } |
|
3976 |
|
3977 // ----------------------------------------------------------------------------- |
|
3978 // ChspsMaintenanceHandler::DoCancel() |
|
3979 // Not implemented yet |
|
3980 // (other items were commented in a header). |
|
3981 // ----------------------------------------------------------------------------- |
|
3982 // |
|
3983 void ChspsMaintenanceHandler::DoCancel() |
|
3984 { |
|
3985 // no need to implement |
|
3986 } |
|
3987 |
|
3988 // ----------------------------------------------------------------------------- |
|
3989 // ChspsMaintenanceHandler::CompleteRequest() |
|
3990 // Completes client request |
|
3991 // (other items were commented in a header). |
|
3992 // ----------------------------------------------------------------------------- |
|
3993 // |
|
3994 void ChspsMaintenanceHandler::CompleteRequest(const ThspsServiceCompletedMessage aReturnMessage, |
|
3995 RMessagePtr2& aMessagePtr, const TDesC8& /*aHeaderData*/ ) |
|
3996 { |
|
3997 TInt errorCode = KErrNone; |
|
3998 RDesWriteStream writeBuf( iResultData ); |
|
3999 |
|
4000 TRAP( errorCode, iResult->ExternalizeL( writeBuf )); |
|
4001 |
|
4002 writeBuf.Close(); |
|
4003 |
|
4004 if ( !aMessagePtr.IsNull() ) |
|
4005 { |
|
4006 if ( errorCode ) |
|
4007 { |
|
4008 TRAP_IGNORE( aMessagePtr.WriteL( 0, KNullDesC8, 0 )); |
|
4009 } |
|
4010 else |
|
4011 { |
|
4012 TRAP_IGNORE( aMessagePtr.WriteL( 0, iResultData, 0 )); |
|
4013 } |
|
4014 aMessagePtr.Complete( aReturnMessage ); |
|
4015 } |
|
4016 } |
|
4017 |
|
4018 // ----------------------------------------------------------------------------- |
|
4019 // ChspsMaintenanceHandler::RunError |
|
4020 // From CActive. Called when error occurred in asynchronous request |
|
4021 // (other items were commented in a header). |
|
4022 // ----------------------------------------------------------------------------- |
|
4023 // |
|
4024 TInt ChspsMaintenanceHandler::RunError( TInt aError ) |
|
4025 { |
|
4026 iResult->iSystemError = aError; |
|
4027 iResult->iXuikonError = aError; |
|
4028 |
|
4029 #ifdef HSPS_LOG_ACTIVE |
|
4030 if( iLogBus ) |
|
4031 { |
|
4032 iLogBus->LogText( _L( "ChspsMaintenanceHandler::RunError(): - error %d" ), |
|
4033 aError ); |
|
4034 } |
|
4035 #endif |
|
4036 |
|
4037 CompleteRequest( EhspsGetListHeadersFailed, iMessagePtr ); |
|
4038 |
|
4039 return KErrNone; |
|
4040 } |
|
4041 |
|
4042 // ----------------------------------------------------------------------------- |
|
4043 // ChspsMaintenanceHandler::RunL() |
|
4044 // Handles header list polling |
|
4045 // (other items were commented in a header). |
|
4046 // ----------------------------------------------------------------------------- |
|
4047 // |
|
4048 void ChspsMaintenanceHandler::RunL() |
|
4049 { |
|
4050 if ( !iDefinitionRepository.Locked() && !iMessagePtr.IsNull() ) |
|
4051 { |
|
4052 // cache changed, check if there is any changes when comparring to the local list |
|
4053 // and what kind of change there is |
|
4054 iCompletedMessage = GetHeaderListUpdateL(); |
|
4055 // is there headers to deliver |
|
4056 if ( iCompletedMessage == EhspsGetListHeadersRestart) |
|
4057 { |
|
4058 if (iHeaderDataList->Count()) |
|
4059 { |
|
4060 // at least one header on the list |
|
4061 iMessagePtr.WriteL(2,iHeaderDataList->At(iDeliveryCount)->Des(),0); |
|
4062 // add list count |
|
4063 iDeliveryCount++; |
|
4064 // delivery of the first header |
|
4065 } |
|
4066 CompleteRequest( EhspsGetListHeadersRestart, iMessagePtr ); |
|
4067 } |
|
4068 else if ( iCompletedMessage == EhspsGetListHeadersUpdate ) |
|
4069 { |
|
4070 // return list update, count continues from where it was |
|
4071 iMessagePtr.WriteL(2,iHeaderDataList->At(iDeliveryCount)->Des(),0); |
|
4072 // add list count |
|
4073 iDeliveryCount++; |
|
4074 // deliver a list item |
|
4075 CompleteRequest( EhspsGetListHeadersUpdate, iMessagePtr ); |
|
4076 } |
|
4077 else if (iCompletedMessage == EhspsGetListHeadersEmpty) |
|
4078 { |
|
4079 CompleteRequest( EhspsGetListHeadersEmpty, iMessagePtr ); |
|
4080 // no list update available at the moment, continue the polling for list updates |
|
4081 } |
|
4082 } |
|
4083 else if ( !IsActive() ) |
|
4084 { |
|
4085 After(KHeaderListUpdatePollingTimeSpan); |
|
4086 } |
|
4087 } |
|
4088 |
|
4089 // ----------------------------------------------------------------------------- |
|
4090 // ChspsMaintenanceHandler::GetHeaderListUpdateL |
|
4091 // Checks if the header list has changed and returns the appropriate |
|
4092 // ThspsServiceCompletedMessage answer. |
|
4093 // (other items were commented in a header). |
|
4094 // ----------------------------------------------------------------------------- |
|
4095 // |
|
4096 ThspsServiceCompletedMessage ChspsMaintenanceHandler::GetHeaderListUpdateL() |
|
4097 { |
|
4098 ThspsServiceCompletedMessage ret = EhspsGetListHeadersNoChange; |
|
4099 |
|
4100 // chech if repository have a cache update available |
|
4101 TInt oldcount = iHeaderDataList->Count(); |
|
4102 CArrayPtrSeg<HBufC8>* newheaderDataList = new( ELeave ) CArrayPtrSeg<HBufC8> |
|
4103 (KHeaderListGranularity); |
|
4104 CleanupStack::PushL( TCleanupItem( ResetAndDestroyArray, newheaderDataList ) ); |
|
4105 |
|
4106 GetHeaderListL( *newheaderDataList, *iSearchMask ); |
|
4107 if ( newheaderDataList->Count() ) |
|
4108 { |
|
4109 TBool reset = EFalse; |
|
4110 TBool found = EFalse; |
|
4111 TInt newcount = newheaderDataList->Count(); |
|
4112 // cases: |
|
4113 // 0. both lists are empty => no change |
|
4114 if (!oldcount && !newcount) |
|
4115 { |
|
4116 ret = EhspsGetListHeadersNoChange; |
|
4117 } |
|
4118 else |
|
4119 // 1. new list has members but old list is empty => just add new headers on old list |
|
4120 // => restart anyway |
|
4121 if (!oldcount && newcount) |
|
4122 { |
|
4123 for (TInt k=0;k<newheaderDataList->Count();k++) |
|
4124 { |
|
4125 HBufC8* l = newheaderDataList->At(k)->AllocL(); |
|
4126 if (l != NULL) |
|
4127 { |
|
4128 CleanupStack::PushL(l); |
|
4129 iHeaderDataList->AppendL(l); |
|
4130 CleanupStack::Pop(l); |
|
4131 } |
|
4132 } |
|
4133 ret = EhspsGetListHeadersRestart; // start from begin |
|
4134 } |
|
4135 // 2. new list is empty and old has members => empty old list too => empty the list |
|
4136 else if (!newcount && oldcount) |
|
4137 { |
|
4138 // must fetch whole list again |
|
4139 iHeaderDataList->ResetAndDestroy(); |
|
4140 iDeliveryCount = 0; |
|
4141 ret = EhspsGetListHeadersEmpty; // empty the list |
|
4142 } |
|
4143 // 3. old list and new list both have members, newcount < oldcount => reset |
|
4144 else if (newcount < oldcount) |
|
4145 { |
|
4146 // must fetch whole list again |
|
4147 iHeaderDataList->ResetAndDestroy(); |
|
4148 iDeliveryCount = 0; |
|
4149 GetHeaderListL( *iHeaderDataList, *iSearchMask ); |
|
4150 ret = EhspsGetListHeadersRestart; |
|
4151 } |
|
4152 // 4. old list and new list both have members => examine next cases |
|
4153 else |
|
4154 { |
|
4155 TInt j=0; |
|
4156 for ( TInt i=0; i<iHeaderDataList->Count();i++ ) |
|
4157 { |
|
4158 HBufC8* old = iHeaderDataList->At(i); |
|
4159 if (old != NULL) |
|
4160 { |
|
4161 while ( j < newheaderDataList->Count() ) |
|
4162 { |
|
4163 HBufC8* cand = newheaderDataList->At(j); |
|
4164 |
|
4165 if (cand != NULL) |
|
4166 { |
|
4167 if (CompareHeadersL(*old, *cand)) // is it there |
|
4168 { |
|
4169 // delete existing from the new list |
|
4170 newheaderDataList->Delete(j); |
|
4171 delete cand; //free allocated memory |
|
4172 found = ETrue; |
|
4173 break; // take next i in for for-loop |
|
4174 } |
|
4175 else |
|
4176 { |
|
4177 // not found at this round, let see will the next one be a hit |
|
4178 j++; // next j |
|
4179 } |
|
4180 } |
|
4181 else |
|
4182 { |
|
4183 // not found at this round, let see will the next one be a hit |
|
4184 j++; // next j |
|
4185 } |
|
4186 } // while |
|
4187 } |
|
4188 // did it found a match for entry i on iHeaderDataList |
|
4189 if (!found) |
|
4190 { |
|
4191 // lists do not match |
|
4192 reset = ETrue; |
|
4193 break; |
|
4194 } |
|
4195 } // for |
|
4196 if ( reset || newheaderDataList->Count() ) |
|
4197 { |
|
4198 // must fetch whole list again |
|
4199 iHeaderDataList->ResetAndDestroy(); |
|
4200 iDeliveryCount = 0; |
|
4201 GetHeaderListL( *iHeaderDataList, *iSearchMask ); |
|
4202 ret = EhspsGetListHeadersRestart; |
|
4203 } |
|
4204 else |
|
4205 { |
|
4206 iDeliveryCount = 0; |
|
4207 ret = EhspsGetListHeadersNoChange; |
|
4208 } |
|
4209 } |
|
4210 } |
|
4211 else // no headers found => list must be emptied |
|
4212 { |
|
4213 // reset the list |
|
4214 iHeaderDataList->ResetAndDestroy(); |
|
4215 iDeliveryCount = 0; |
|
4216 ret = EhspsGetListHeadersEmpty; |
|
4217 } |
|
4218 CleanupStack::Pop( newheaderDataList ); |
|
4219 if ( newheaderDataList ) |
|
4220 { |
|
4221 newheaderDataList->ResetAndDestroy(); |
|
4222 delete newheaderDataList; |
|
4223 newheaderDataList = NULL; |
|
4224 } |
|
4225 return ret; |
|
4226 } |
|
4227 |
|
4228 // ----------------------------------------------------------------------------- |
|
4229 // ChspsMaintenanceHandler::GetHeaderListL |
|
4230 // Fills aHeaderDataList with headers and sets the appropriate flag for active theme |
|
4231 // (other items were commented in a header). |
|
4232 // ----------------------------------------------------------------------------- |
|
4233 // |
|
4234 void ChspsMaintenanceHandler::GetHeaderListL( |
|
4235 CArrayPtrSeg<HBufC8>& aHeaderDataList, |
|
4236 const ChspsODT& aSearchMask ) |
|
4237 { |
|
4238 HBufC8* headerBuf = aSearchMask.MarshalHeaderL(); |
|
4239 if ( !headerBuf ) |
|
4240 { |
|
4241 User::Leave(KErrGeneral); |
|
4242 } |
|
4243 CleanupStack::PushL( headerBuf ); |
|
4244 ChspsODT* searchOdt = ChspsODT::UnMarshalHeaderLC( *headerBuf ); |
|
4245 |
|
4246 // Reset search results |
|
4247 aHeaderDataList.ResetAndDestroy(); |
|
4248 |
|
4249 for ( TInt i = 0; i < iHeaderListCache.Count(); i++ ) |
|
4250 { |
|
4251 ChspsODT* header = iHeaderListCache.At( i ); |
|
4252 |
|
4253 // Check whether the header matches the search criteria |
|
4254 if ( FilterHeader( *searchOdt, *header ) ) |
|
4255 { |
|
4256 // Append to the search results |
|
4257 HBufC8* data = header->MarshalHeaderL(); |
|
4258 if ( data ) |
|
4259 { |
|
4260 CleanupStack::PushL( data ); |
|
4261 aHeaderDataList.AppendL( data ); |
|
4262 CleanupStack::Pop( data ); |
|
4263 } |
|
4264 } |
|
4265 } |
|
4266 |
|
4267 CleanupStack::PopAndDestroy( 2, headerBuf ); // searchOdt, headerBuf |
|
4268 } |
|
4269 |
|
4270 // ----------------------------------------------------------------------------- |
|
4271 // ChspsMaintenanceHandler::RestoredDefaultL |
|
4272 // Goes through the themes for the application in order to find the Licensee |
|
4273 // Default theme to restore. |
|
4274 // (other items were commented in a header). |
|
4275 // ----------------------------------------------------------------------------- |
|
4276 // |
|
4277 void ChspsMaintenanceHandler::RestoredDefaultL( const ChspsODT& aSetMask, ChspsODT& aHeader ) |
|
4278 { |
|
4279 TBool found = EFalse; |
|
4280 TUint mask = 0; |
|
4281 TUint rootUid = aSetMask.RootUid(); |
|
4282 ChspsODT* odt; |
|
4283 |
|
4284 if ( aSetMask.Flags() & EhspsThemeStatusOperatorDefault ) |
|
4285 { |
|
4286 mask = EhspsThemeStatusOperatorDefault; |
|
4287 } |
|
4288 else if ( aSetMask.Flags() & EhspsThemeStatusUserDefault ) |
|
4289 { |
|
4290 mask = EhspsThemeStatusUserDefault; |
|
4291 } |
|
4292 |
|
4293 // If all but ROM based configurations should be removed |
|
4294 if ( aSetMask.Flags() & EhspsThemeStatusClean ) |
|
4295 { |
|
4296 for( TInt i = 0; i < iHeaderListCache.Count(); i++) // delete themes from c: |
|
4297 { |
|
4298 odt = iHeaderListCache.At(i); |
|
4299 |
|
4300 // Remove specific application configurations which are not matching the mask and |
|
4301 // the licencee default flag |
|
4302 if ( rootUid == odt->RootUid() |
|
4303 && !( (odt->Flags() & mask) && (aSetMask.Flags() & mask) ) |
|
4304 && !( odt->Flags() & EhspsThemeStatusLicenceeDefault ) ) |
|
4305 { |
|
4306 // do not care about possible error |
|
4307 TRAP_IGNORE( RemoveThemeL( *odt ) ); |
|
4308 } |
|
4309 } |
|
4310 // update cache after deletion |
|
4311 iThemeServer.UpdateHeaderListCacheL(); |
|
4312 } |
|
4313 |
|
4314 // Try activating the first licencee restorable configuration in the cache |
|
4315 for( TInt i = 0; i < iHeaderListCache.Count() && !found; i++ ) |
|
4316 { |
|
4317 odt = iHeaderListCache.At(i); |
|
4318 if( rootUid == odt->RootUid() && odt->Flags() & EhspsThemeStatusLicenceeRestorable ) |
|
4319 { |
|
4320 if ( iThemeServer.ActivateThemeL( *odt, aHeader ) == KErrNone ) |
|
4321 { |
|
4322 found = ETrue; |
|
4323 } |
|
4324 } |
|
4325 } |
|
4326 // any default will do, depends on restoration level |
|
4327 // this is safe because the default theme could be updated only with other default theme |
|
4328 mask = EhspsThemeStatusLicenceeDefault + EhspsThemeStatusOperatorDefault + EhspsThemeStatusUserDefault; |
|
4329 |
|
4330 // If no luck so far, try activating a "default" configuration with the new mask |
|
4331 for( TInt i = 0; i < iHeaderListCache.Count() && !found; i++ ) |
|
4332 { |
|
4333 odt = iHeaderListCache.At(i); |
|
4334 |
|
4335 if( rootUid == odt->RootUid() && odt->Flags() & mask ) |
|
4336 { |
|
4337 if ( iThemeServer.ActivateThemeL( *odt, aHeader ) == KErrNone ) |
|
4338 { |
|
4339 found = ETrue; |
|
4340 } |
|
4341 } |
|
4342 } |
|
4343 |
|
4344 // If still no success, just select the first one in the cache |
|
4345 if( !found ) |
|
4346 { // should not get here |
|
4347 for( TInt i = 0; i < iHeaderListCache.Count() && !found; i++ ) // licensee default not found, activate some other theme |
|
4348 { |
|
4349 odt = iHeaderListCache.At(i); |
|
4350 if( rootUid == odt->RootUid() ) |
|
4351 { |
|
4352 if ( iThemeServer.ActivateThemeL( *odt, aHeader ) == KErrNone ) |
|
4353 { |
|
4354 found = ETrue; |
|
4355 } |
|
4356 } |
|
4357 } |
|
4358 } |
|
4359 |
|
4360 // If there were no application specific configurations, give up |
|
4361 if( !found ) |
|
4362 { |
|
4363 // should not get here |
|
4364 User::Leave( KErrNotFound ); |
|
4365 } |
|
4366 } |
|
4367 |
|
4368 |
|
4369 // ----------------------------------------------------------------------------- |
|
4370 // ChspsMaintenanceHandler::RemoveThemeL |
|
4371 // Removes given theme from repository. If theme is in use (KErrInUse), then the theme |
|
4372 // is added on cleanup list. |
|
4373 // (other items were commented in a header). |
|
4374 // ----------------------------------------------------------------------------- |
|
4375 // |
|
4376 void ChspsMaintenanceHandler::RemoveThemeL( const ChspsODT& aSetMask ) |
|
4377 { |
|
4378 // do not even try to delete a theme licencee default theme as it is located in rom |
|
4379 if( !( aSetMask.Flags() & EhspsThemeStatusLicenceeDefault ) ) |
|
4380 { |
|
4381 iDefinitionRepository.RemoveThemeL( aSetMask ); |
|
4382 } |
|
4383 } |
|
4384 |
|
4385 // ----------------------------------------------------------------------------- |
|
4386 // ChspsMaintenanceHandler::CompareHeadersL |
|
4387 // Compares the two theme headers and returns ETrue if they are the same |
|
4388 // (other items were commented in a header). |
|
4389 // ----------------------------------------------------------------------------- |
|
4390 // |
|
4391 TBool ChspsMaintenanceHandler::CompareHeadersL(const TDesC8& aOldHeaderData, const TDesC8& |
|
4392 aNewHeaderData) |
|
4393 { |
|
4394 TBool ret; |
|
4395 ChspsODT* old = ChspsODT::UnMarshalHeaderLC(aOldHeaderData); |
|
4396 ChspsODT* cand= ChspsODT::UnMarshalHeaderLC(aNewHeaderData); |
|
4397 if ( old->RootUid() == cand->RootUid() |
|
4398 && old->ProviderUid() == cand->ProviderUid() |
|
4399 && old->ThemeUid() == cand->ThemeUid() |
|
4400 && !old->ThemeVersion().Compare(cand->ThemeVersion()) |
|
4401 && old->Flags() == cand->Flags() |
|
4402 ) |
|
4403 { |
|
4404 ret = ETrue; |
|
4405 } |
|
4406 else |
|
4407 { |
|
4408 ret = EFalse; |
|
4409 } |
|
4410 CleanupStack::PopAndDestroy( cand ); |
|
4411 CleanupStack::PopAndDestroy( old ); |
|
4412 return ret; |
|
4413 } |
|
4414 |
|
4415 // ----------------------------------------------------------------------------- |
|
4416 // ChspsMaintenanceHandler::ComparePaths |
|
4417 // (other items were commented in a header). |
|
4418 // ----------------------------------------------------------------------------- |
|
4419 // |
|
4420 TBool ChspsMaintenanceHandler::ComparePaths(const ChspsODT& aOldHeader, const ChspsODT& aNewHeader) |
|
4421 { |
|
4422 TBool ret; |
|
4423 if ( aOldHeader.RootUid() == aNewHeader.RootUid() |
|
4424 && aOldHeader.ProviderUid() == aNewHeader.ProviderUid() |
|
4425 && aOldHeader.ThemeUid() == aNewHeader.ThemeUid() |
|
4426 && !aOldHeader.ThemeVersion().Compare(aNewHeader.ThemeVersion()) ) |
|
4427 { |
|
4428 ret = ETrue; |
|
4429 } |
|
4430 else |
|
4431 { |
|
4432 ret = EFalse; |
|
4433 } |
|
4434 return ret; |
|
4435 } |
|
4436 |
|
4437 // ----------------------------------------------------------------------------- |
|
4438 // ChspsMaintenanceHandler::FilterHeader |
|
4439 // Compares the header and mask and returns true if the mask doesn't have any different |
|
4440 // values than the header (missing values are OK). |
|
4441 // (other items were commented in a header). |
|
4442 // ----------------------------------------------------------------------------- |
|
4443 // |
|
4444 TBool ChspsMaintenanceHandler::FilterHeader( |
|
4445 const ChspsODT& aMask, |
|
4446 const ChspsODT& aHeader ) |
|
4447 { |
|
4448 TBool ret( EFalse ); |
|
4449 if ( |
|
4450 ( // 0 is not valid when comparing |
|
4451 (aMask.RootUid() && aMask.RootUid() == aHeader.RootUid()) |
|
4452 || |
|
4453 // 0 is OK in mask when aHeader is valid |
|
4454 (!aMask.RootUid() && aHeader.RootUid()) |
|
4455 ) |
|
4456 && |
|
4457 ( |
|
4458 (aMask.ProviderUid() && aMask.ProviderUid() == aHeader.ProviderUid()) |
|
4459 || |
|
4460 (!aMask.ProviderUid() && aHeader.ProviderUid()) |
|
4461 ) |
|
4462 && |
|
4463 ( |
|
4464 (aMask.ThemeUid() && aMask.ThemeUid() == aHeader.ThemeUid()) |
|
4465 || |
|
4466 (!aMask.ThemeUid() && aHeader.ThemeUid()) |
|
4467 ) |
|
4468 && |
|
4469 ( |
|
4470 (aMask.ThemeVersion().Length() && !aMask.ThemeVersion().Compare( |
|
4471 aHeader.ThemeVersion())) |
|
4472 || |
|
4473 (!aMask.ThemeVersion().Length() && aHeader.ThemeVersion().Length()) |
|
4474 ) |
|
4475 && |
|
4476 ( |
|
4477 ( aMask.ConfigurationType() && aMask.ConfigurationType() == aHeader.ConfigurationType() ) |
|
4478 || |
|
4479 ( !aMask.ConfigurationType() ) |
|
4480 ) |
|
4481 && |
|
4482 // Show widgets designed for the active resolution or scalable |
|
4483 ( ( aHeader.Family() & aMask.Family() ) || aHeader.Family() == 0 ) |
|
4484 ) |
|
4485 { |
|
4486 ret = ETrue; |
|
4487 } |
|
4488 |
|
4489 return ret; |
|
4490 } |
|
4491 |
|
4492 // ----------------------------------------------------------------------------- |
|
4493 // ChspsMaintenanceHandler::RestoreDefaultAppConfL |
|
4494 // (other items were commented in a header). |
|
4495 // ----------------------------------------------------------------------------- |
|
4496 // |
|
4497 void ChspsMaintenanceHandler::RestoreDefaultAppConfL( |
|
4498 ChspsODT*& aHeader, |
|
4499 ChspsODT& aOdt) |
|
4500 { |
|
4501 |
|
4502 if ( aHeader->Flags() & EhspsThemeStatusLicenceeRestorable ) |
|
4503 { |
|
4504 // Licensee restorable configuration active -> Reinstall configuration |
|
4505 iThemeServer.ReinstallConfL( aHeader->RootUid(), aHeader->ThemeUid() ); |
|
4506 } |
|
4507 else |
|
4508 { |
|
4509 // Get licensee restorable configuation |
|
4510 ChspsODT* searchMask = ChspsODT::NewL(); |
|
4511 CleanupStack::PushL( searchMask ); |
|
4512 searchMask->SetRootUid( aHeader->RootUid() ); |
|
4513 searchMask->SetFlags( EhspsThemeStatusLicenceeRestorable ); |
|
4514 TInt pos( 0 ); |
|
4515 iThemeServer.GetConfigurationHeader( *searchMask, aHeader, pos ); |
|
4516 if ( aHeader ) |
|
4517 { |
|
4518 // Activate licensee restorable configuration |
|
4519 iThemeServer.ActivateThemeL( *aHeader, aOdt ); |
|
4520 ThspsRepositoryInfo info( EhspsODTActivated ); |
|
4521 iDefinitionRepository.RegisterNotification( info ); |
|
4522 } |
|
4523 else |
|
4524 { |
|
4525 // Licensee restorable configuration not found |
|
4526 // There must be at least one licensee restorable configuration |
|
4527 User::Leave( KErrNotFound ); |
|
4528 } |
|
4529 CleanupStack::PopAndDestroy( searchMask ); |
|
4530 } |
|
4531 } |
|
4532 |
|
4533 // ----------------------------------------------------------------------------- |
|
4534 // ChspsMaintenanceHandler::AddErrorConfigurationL() |
|
4535 // ----------------------------------------------------------------------------- |
|
4536 // |
|
4537 void ChspsMaintenanceHandler::AddErrorConfigurationL( |
|
4538 ChspsDomDocument& aAppDom, |
|
4539 ChspsDomNode& aMissingPluginNode, |
|
4540 const TInt aPluginUid |
|
4541 ) |
|
4542 { |
|
4543 // Create a new dummy configuration element |
|
4544 ChspsDomNode* confNode = aAppDom.CreateElementNSL( |
|
4545 KConfigurationElement, |
|
4546 aMissingPluginNode.Namespace() |
|
4547 ); |
|
4548 CleanupStack::PushL( confNode ); |
|
4549 |
|
4550 hspsServerUtil::AddAttributeDescL( *confNode, KConfigurationAttrType, KConfTypeWidget ); |
|
4551 _LIT8( KUnknown, "unknown" ); |
|
4552 hspsServerUtil::AddAttributeDescL( *confNode, KConfigurationAttrInterface, KUnknown ); |
|
4553 hspsServerUtil::AddAttributeNumericL( *confNode, KConfigurationAttrUid, aPluginUid, EHex ); |
|
4554 hspsServerUtil::AddAttributeDescL( *confNode, KConfigurationAttrName, KUnknown ); |
|
4555 hspsServerUtil::AddAttributeDescL( *confNode, KConfigurationAttrNameEntity, KUnknown ); |
|
4556 hspsServerUtil::AddAttributeDescL( *confNode, KConfigurationAttrVersion, KUnknown ); |
|
4557 hspsServerUtil::AddAttributeNumericL( *confNode, KConfigurationAttrMaxChild, 0, EDecimal ); |
|
4558 |
|
4559 // Indicate that the configuration is in error state |
|
4560 hspsServerUtil::AddAttributeDescL( *confNode, KConfigurationAttrState, KConfStateError ); |
|
4561 |
|
4562 // Set parent node |
|
4563 aMissingPluginNode.AddChildL( confNode ); |
|
4564 CleanupStack::Pop( confNode ); |
|
4565 |
|
4566 confNode->SetParent( &aMissingPluginNode ); |
|
4567 |
|
4568 // Mandatory configuration-control node |
|
4569 ChspsDomNode* controlNode = aAppDom.CreateElementNSL( |
|
4570 KControlElement, |
|
4571 confNode->Namespace() |
|
4572 ); |
|
4573 CleanupStack::PushL( controlNode ); |
|
4574 confNode->AddChildL( controlNode ); |
|
4575 CleanupStack::Pop( controlNode ); |
|
4576 |
|
4577 controlNode->SetParent( confNode ); |
|
4578 |
|
4579 // Mandatory configuration-control-settings node |
|
4580 ChspsDomNode* settingsNode = aAppDom.CreateElementNSL( |
|
4581 KSettingsElement, |
|
4582 controlNode->Namespace() |
|
4583 ); |
|
4584 CleanupStack::PushL( settingsNode ); |
|
4585 controlNode->AddChildL( settingsNode ); |
|
4586 CleanupStack::Pop( settingsNode ); |
|
4587 settingsNode->SetParent( controlNode ); |
|
4588 |
|
4589 |
|
4590 // Mandatory configuration-resources node |
|
4591 ChspsDomNode* resourcesNode = aAppDom.CreateElementNSL( |
|
4592 KResourcesElement, |
|
4593 confNode->Namespace() |
|
4594 ); |
|
4595 CleanupStack::PushL( resourcesNode ); |
|
4596 confNode->AddChildL( resourcesNode ); |
|
4597 CleanupStack::Pop( resourcesNode ); |
|
4598 resourcesNode->SetParent( confNode ); |
|
4599 |
|
4600 } |
|
4601 |
|
4602 // end of file |