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