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