114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: HSPS Theme Server. For more information, see the header.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#define __INCLUDE_CAPABILITY_NAMES__
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include <mw/MemoryManager.h>
|
|
23 |
#include <centralrepository.h>
|
|
24 |
#include <f32file.h>
|
|
25 |
#include <bautils.h>
|
|
26 |
#include <sbdefs.h>
|
|
27 |
#include <sysversioninfo.h>
|
|
28 |
#include <sysutil.h>
|
|
29 |
|
|
30 |
#include "hsps_builds_cfg.hrh"
|
|
31 |
#include "hspsthemeserver.h"
|
|
32 |
#include "hspsthemeserversession.h"
|
|
33 |
#include "hspssecurityenforcer.h"
|
|
34 |
#include "hspsserverutil.h"
|
|
35 |
#include "hspsdefinitionrepository.h"
|
|
36 |
#include "hspsdefinitionengineinterface.h"
|
|
37 |
#include "hspsconfiguration.h"
|
|
38 |
#include "hspsfamily.h"
|
|
39 |
#ifdef _hsps_PERFORMANCE_TEST_
|
|
40 |
#include "hspstimemon.h"
|
|
41 |
#endif //_hsps_PERFORMANCE_TEST_
|
|
42 |
|
|
43 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
44 |
#include "hspsrominstaller.h"
|
|
45 |
#include "hspsautoinstaller.h"
|
|
46 |
#include "hspsinstaller.h"
|
|
47 |
#include "hspsinstallationhandler.h"
|
|
48 |
#endif //__DISABLE_SISX_INSTALLATION_
|
|
49 |
|
|
50 |
#ifdef HSPS_LOG_ACTIVE
|
|
51 |
#include <hspsodtdump.h>
|
|
52 |
#include <hspslogbusfile.h>
|
|
53 |
#endif
|
|
54 |
|
|
55 |
// CONSTANTS
|
|
56 |
|
|
57 |
// Directories for backup folders
|
|
58 |
_LIT( KBackupThemesDirectoryC, "c:\\private\\200159c0\\backup\\themes\\" );
|
|
59 |
|
|
60 |
// Name of the installation file
|
|
61 |
_LIT( KManifestFile, "manifest.dat" );
|
|
62 |
|
|
63 |
// Name of the configuration file
|
|
64 |
_LIT( KConfFile, "*.o0000" );
|
|
65 |
|
|
66 |
// File prefixes for the *.DAT imports
|
|
67 |
_LIT( KPrefixFileApp, "app_");
|
|
68 |
_LIT( KPrefixFilePlugin, "plugin_");
|
|
69 |
|
|
70 |
_LIT( KUpgradePlugin, "upgrade_plugin" );
|
|
71 |
_LIT( KUpgrade, "upgrade" );
|
|
72 |
_LIT( KDoubleBackSlash, "\\" );
|
|
73 |
_LIT( KUpgradePluginWild, "upgrade_plugin_*.dat" );
|
|
74 |
// Just in case emulator cannot read system version we use this to
|
|
75 |
// prevent ROM installation on every boot up
|
|
76 |
_LIT( KDummyVersionInfo, "dummyversioninfo" );
|
|
77 |
|
|
78 |
_LIT( KProcessFindString, "hspsthemeserver*" );
|
|
79 |
|
|
80 |
const TUint KAppId_hspsAS = 270486738; // 0x101F4CD2 from S60 3.1 Xuikon AppShell in 3.1 product.
|
|
81 |
const TUint KAppId_hspsAI = 271012080 ; // 0x102750F0 support for Xuikon-based ActiveIdle
|
|
82 |
const TUint KAppId_LE = 270551469 ; // 0x102049AD LayoutTest
|
|
83 |
|
|
84 |
const TInt KAppIdAny = -1; // All applications
|
|
85 |
|
|
86 |
// ======== LOCAL FUNCTIONS ========
|
|
87 |
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
// ResetAndDestroyHBufCArray
|
|
90 |
// cleanup item for HBufC dynamic arrays
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
static void ResetAndDestroyHBufC8Array( TAny* aArray )
|
|
93 |
{
|
|
94 |
CArrayPtrSeg<HBufC8>* array = reinterpret_cast< CArrayPtrSeg<HBufC8>* >( aArray );
|
|
95 |
array->ResetAndDestroy();
|
|
96 |
delete array;
|
|
97 |
}
|
|
98 |
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
// ResetAndDestroyChspsODTArray
|
|
101 |
// cleanup item for ChspsODT dynamic arrays
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
static void ResetAndDestroyChspsODTArray( TAny* aArray )
|
|
104 |
{
|
|
105 |
CArrayPtrSeg<ChspsODT>* array = reinterpret_cast< CArrayPtrSeg<ChspsODT>* >( aArray );
|
|
106 |
array->ResetAndDestroy();
|
|
107 |
delete array;
|
|
108 |
}
|
|
109 |
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
// Callback function for removing repository lock if error occurs while repository is locked
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
static void UnlockRepository( TAny* aObject )
|
|
115 |
{
|
|
116 |
ChspsDefinitionRepository* DefRep = reinterpret_cast<ChspsDefinitionRepository*>( aObject );
|
|
117 |
|
|
118 |
if (DefRep->Locked())
|
|
119 |
{
|
|
120 |
DefRep->Unlock();
|
|
121 |
}
|
|
122 |
}
|
|
123 |
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
// GetFWVersion
|
|
126 |
// Gets firmware version of phone and sets it to buffer given as parameter
|
|
127 |
// -----------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
static void GetFWVersion( TDes& aVersion )
|
|
130 |
{
|
|
131 |
TInt err = SysVersionInfo::GetVersionInfo( SysVersionInfo::EFWVersion, aVersion );
|
|
132 |
if ( err != KErrNone )
|
|
133 |
{
|
|
134 |
// emulator might not have fwid*.txt files so we need to read sw version
|
|
135 |
// by using sysutil.
|
|
136 |
aVersion.Zero();
|
|
137 |
err = SysUtil::GetSWVersion( aVersion );
|
|
138 |
if ( err != KErrNone )
|
|
139 |
{
|
|
140 |
// for some reason emulator cannot read version info
|
|
141 |
aVersion.Copy( KDummyVersionInfo );
|
|
142 |
}
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
// RunServerL()
|
|
148 |
// Server startup code
|
|
149 |
// Perform all server initialisation, in particular creation of the
|
|
150 |
// scheduler and server and then run the scheduler
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
static void RunServerL()
|
|
154 |
{
|
|
155 |
#ifdef _hsps_PERFORMANCE_TEST_
|
|
156 |
ChspsTimeMon::PrintUserMem( _L("hspsThemeServer::RunServerL(): - initialising..") );
|
|
157 |
#endif//_hsps_PERFORMANCE_TEST_
|
|
158 |
// naming the server thread after the server helps to debug panics
|
|
159 |
User::LeaveIfError(User::RenameThread(KhspsThemeServerName));
|
|
160 |
// create and install the active scheduler we need
|
|
161 |
CActiveScheduler* s=new(ELeave) CActiveScheduler;
|
|
162 |
CleanupStack::PushL(s);
|
|
163 |
CActiveScheduler::Install(s);
|
|
164 |
// create the server (leave it on the cleanup stack)
|
|
165 |
ChspsThemeServer::NewLC();
|
|
166 |
// Initialisation complete, now signal the client
|
|
167 |
RProcess::Rendezvous(KErrNone);
|
|
168 |
CActiveScheduler::Start();
|
|
169 |
// Cleanup the server and scheduler
|
|
170 |
CleanupStack::PopAndDestroy( 2, s );
|
|
171 |
#ifdef _hsps_PERFORMANCE_TEST_
|
|
172 |
ChspsTimeMon::PrintUserMem( _L("hspsThemeServer::RunServerL(): - server fully running") );
|
|
173 |
#endif//_hsps_PERFORMANCE_TEST_
|
|
174 |
}
|
|
175 |
|
|
176 |
// -----------------------------------------------------------------------------
|
|
177 |
// E32Main
|
|
178 |
// Server process entry-point
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
TInt E32Main()
|
|
182 |
{
|
|
183 |
TFindProcess processFinder( KProcessFindString );
|
|
184 |
TFullName fullName;
|
|
185 |
TInt count = 0;
|
|
186 |
while( processFinder.Next( fullName ) == KErrNone )
|
|
187 |
{
|
|
188 |
count++;
|
|
189 |
}
|
|
190 |
if( count > 1 )
|
|
191 |
{
|
|
192 |
return KErrAlreadyExists;
|
|
193 |
}
|
|
194 |
fullName = KNullDesC();
|
|
195 |
|
|
196 |
RAllocator* iAllocator = MemoryManager::SwitchToFastAllocator();
|
|
197 |
|
|
198 |
__UHEAP_MARK;
|
|
199 |
CTrapCleanup* cleanup=CTrapCleanup::New();
|
|
200 |
TInt r=KErrNoMemory;
|
|
201 |
if (cleanup)
|
|
202 |
{
|
|
203 |
TRAP(r,RunServerL());
|
|
204 |
delete cleanup;
|
|
205 |
}
|
|
206 |
__UHEAP_MARKEND;
|
|
207 |
|
|
208 |
MemoryManager::CloseFastAllocator(iAllocator);
|
|
209 |
|
|
210 |
return r;
|
|
211 |
}
|
|
212 |
|
|
213 |
// ======== MEMBER FUNCTIONS ========
|
|
214 |
|
|
215 |
#ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
// CShutdown::NewL
|
|
218 |
// (other items were commented in a header).
|
|
219 |
// -----------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
CShutdown* CShutdown::NewL( MShutdownObserver& aObserver )
|
|
222 |
{
|
|
223 |
CShutdown* object = new (ELeave) CShutdown( aObserver );
|
|
224 |
CleanupStack::PushL( object );
|
|
225 |
object->ConstructL();
|
|
226 |
CleanupStack::Pop( object );
|
|
227 |
return object;
|
|
228 |
}
|
|
229 |
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
// CShutdown::CShutdown
|
|
232 |
// (other items were commented in a header).
|
|
233 |
// -----------------------------------------------------------------------------
|
|
234 |
//
|
|
235 |
CShutdown::CShutdown( MShutdownObserver& aObserver ) : CTimer(-1), iObserver( aObserver )
|
|
236 |
{
|
|
237 |
CActiveScheduler::Add(this);
|
|
238 |
}
|
|
239 |
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
// CShutdown::ConstructL
|
|
242 |
// (other items were commented in a header).
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
//
|
|
245 |
void CShutdown::ConstructL()
|
|
246 |
{
|
|
247 |
CTimer::ConstructL();
|
|
248 |
}
|
|
249 |
|
|
250 |
// -----------------------------------------------------------------------------
|
|
251 |
// CShutdown::Start
|
|
252 |
// (other items were commented in a header).
|
|
253 |
// -----------------------------------------------------------------------------
|
|
254 |
//
|
|
255 |
void CShutdown::Start()
|
|
256 |
{
|
|
257 |
After( KhspsShutdownDelay );
|
|
258 |
}
|
|
259 |
|
|
260 |
// -----------------------------------------------------------------------------
|
|
261 |
// CShutdown::RunL
|
|
262 |
// (other items were commented in a header).
|
|
263 |
// -----------------------------------------------------------------------------
|
|
264 |
//
|
|
265 |
void CShutdown::RunL()
|
|
266 |
{
|
|
267 |
// Notify observer.
|
|
268 |
iObserver.ShutdownInitiating();
|
|
269 |
|
|
270 |
// Stop active scheduler.
|
|
271 |
CActiveScheduler::Stop();
|
|
272 |
}
|
|
273 |
#endif // _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
274 |
|
|
275 |
// -----------------------------------------------------------------------------
|
|
276 |
// ChspsThemeServer::ChspsThemeServer
|
|
277 |
// (other items were commented in a header).
|
|
278 |
// -----------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
inline ChspsThemeServer::ChspsThemeServer():CPolicyServer(0,hspsThemePolicy,ESharableSessions)
|
|
281 |
{
|
|
282 |
}
|
|
283 |
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
// ChspsThemeServer::NewLC
|
|
286 |
// (other items were commented in a header).
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
CServer2* ChspsThemeServer::NewLC()
|
|
290 |
{
|
|
291 |
#ifdef _hsps_PERFORMANCE_TEST_
|
|
292 |
ChspsTimeMon::PrintUserMem( _L("SERVER: - ready to install server.") );
|
|
293 |
#endif
|
|
294 |
ChspsThemeServer* self=new(ELeave) ChspsThemeServer;
|
|
295 |
CleanupStack::PushL(self);
|
|
296 |
self->ConstructL();
|
|
297 |
|
|
298 |
#ifdef _hsps_PERFORMANCE_TEST_
|
|
299 |
ChspsTimeMon::PrintUserMem( _L("SERVER: - server installed.") );
|
|
300 |
#endif
|
|
301 |
return self;
|
|
302 |
}
|
|
303 |
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
// ChspsThemeServer::ConstructL
|
|
306 |
// 2nd phase construction - ensure the timer and server objects are running
|
|
307 |
// (other items were commented in a header).
|
|
308 |
// -----------------------------------------------------------------------------
|
|
309 |
//
|
|
310 |
void ChspsThemeServer::ConstructL()
|
|
311 |
{
|
|
312 |
User::LeaveIfError( iFsSession.Connect() );
|
|
313 |
|
|
314 |
#ifdef HSPS_LOG_ACTIVE
|
|
315 |
iLogBus = ChspsLogBusFile::NewL( ChspsLogBusFile::CreateLogFilename( _L("themeserver") ) );
|
|
316 |
iLogBus->LogText( _L( "--------------------------------------------------------" ) );
|
|
317 |
iLogBus->LogText( _L( "hspsThemeServer: constructing server" ) );
|
|
318 |
#endif
|
|
319 |
|
|
320 |
// Setup a runtime array of headers (=header cache)
|
|
321 |
iHeaderListCache = new ( ELeave ) CArrayPtrSeg< ChspsODT >( KHeaderListGranularity );
|
|
322 |
|
|
323 |
// Setup a Plug-in Repository listener
|
|
324 |
iCentralRepository = CRepository::NewL( KhspsThemeStatusRepositoryUid );
|
|
325 |
|
|
326 |
iDefinitionRepository = ChspsDefinitionRepository::NewL( *iCentralRepository );
|
|
327 |
#ifdef HSPS_LOG_ACTIVE
|
|
328 |
iDefinitionRepository->SetLogBus( iLogBus );
|
|
329 |
#endif
|
|
330 |
|
|
331 |
// Get active device language
|
|
332 |
iDeviceLanguage = GetDeviceLanguage();
|
|
333 |
#ifdef HSPS_LOG_ACTIVE
|
|
334 |
iLogBus->LogText( _L( "ChspsThemeServer::GetDeviceLanguage() %d" ), iDeviceLanguage );
|
|
335 |
#endif
|
|
336 |
|
|
337 |
// Setup a search mask for finding headers from the cache
|
|
338 |
iCacheMask = ChspsODT::NewL();
|
|
339 |
|
|
340 |
// Setup a listener for changes in the Central Repository
|
|
341 |
iCenRepListener = ChspsCenRepListener::NewL( *this, KhspsThemeStatusRepositoryUid );
|
|
342 |
|
|
343 |
// Access lists for client processes
|
|
344 |
iSecurityEnforcer = ChspsSecurityEnforcer::NewL( *iDefinitionRepository, *iCentralRepository );
|
|
345 |
#ifdef HSPS_LOG_ACTIVE
|
|
346 |
iSecurityEnforcer->SetLogBus( iLogBus );
|
|
347 |
#endif
|
|
348 |
|
|
349 |
// Find header files from the Plug-in Repository
|
|
350 |
TRAP_IGNORE( UpdateHeaderListCacheL() );
|
|
351 |
|
|
352 |
// Initialize remove index
|
|
353 |
iThemeIndexToRemove = KErrNotFound;
|
|
354 |
|
|
355 |
// Listen to changes in any key
|
|
356 |
iCenRepListener->SetupAll();
|
|
357 |
|
|
358 |
// Start observing the notifications
|
|
359 |
iDefinitionRepository->RegisterObserverL( *this );
|
|
360 |
|
|
361 |
#if defined(WINSCW) || defined(__WINS__)
|
|
362 |
// Resolution & orientation change listener
|
|
363 |
iFamily = ChspsFamilyListener::NewL( *this );
|
|
364 |
#else
|
|
365 |
iFamily = ChspsFamily::NewL();
|
|
366 |
#endif //defined(WINSCW) || defined(__WINS__)
|
|
367 |
|
|
368 |
// These might leave if configurations are invalid
|
|
369 |
TRAP_IGNORE( InitializeHeadersL() );
|
|
370 |
|
|
371 |
// Update configurations
|
|
372 |
// When server is started all configurations with "WaitForConfirmation" state are updated
|
|
373 |
// to "NotConfirmed" state to allow client to validate configurations
|
|
374 |
User::LeaveIfError( iCentralRepository->Set( KCenrepKeyCheckConf, 0 ) );
|
|
375 |
CheckConfigurationL( KAppIdAny );
|
|
376 |
// Activate configuration checking
|
|
377 |
// Configurations are checked every time when a new client session is created
|
|
378 |
User::LeaveIfError( iCentralRepository->Set( KCenrepKeyCheckConf, 1 ) );
|
|
379 |
|
|
380 |
// Backup event listener
|
|
381 |
iBRObserver = CHSPSBRObserver::NewL( *this );
|
|
382 |
iBRObserver->Start();
|
|
383 |
|
|
384 |
// Initialize backup state
|
|
385 |
iBRState = EhspsBRNormal;
|
|
386 |
|
|
387 |
#ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
388 |
iShutdown = CShutdown::NewL( *this );
|
|
389 |
#endif // _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
390 |
|
|
391 |
// Adds the server with the specified name to the active scheduler, and issues the
|
|
392 |
// first request for messages, and leaves if the operation fails
|
|
393 |
StartL( KhspsThemeServerName );
|
|
394 |
|
|
395 |
#ifdef HSPS_LOG_ACTIVE
|
|
396 |
iLogBus->LogText( _L( "hspsThemeServer: server fully constructed" ) );
|
|
397 |
iLogBus->LogText( _L( "--------------------------------------------------------" ) );
|
|
398 |
#endif
|
|
399 |
}
|
|
400 |
|
|
401 |
void ChspsThemeServer::InitializeHeadersL()
|
|
402 |
{
|
|
403 |
// Auto-localize ODTs in the Definition Repository when the device language has changed
|
|
404 |
HandleLanguageChangeL();
|
|
405 |
|
|
406 |
// Reinstall plug-ins/handle FOTA updates
|
|
407 |
HandleRomInstallationsL();
|
|
408 |
|
|
409 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
410 |
// Start observing of import folder to enable autoinstallations
|
|
411 |
EnableAutoInstallationL();
|
|
412 |
#endif //__DISABLE_SISX_INSTALLATION_
|
|
413 |
}
|
|
414 |
|
|
415 |
// Destructor
|
|
416 |
ChspsThemeServer::~ChspsThemeServer()
|
|
417 |
{
|
|
418 |
#ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
419 |
delete iShutdown;
|
|
420 |
iShutdown = NULL;
|
|
421 |
#else
|
|
422 |
// Server must call cleanup if shutdown object does not exist (and call it).
|
|
423 |
Cleanup();
|
|
424 |
#endif // _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
425 |
|
|
426 |
#ifdef HSPS_LOG_ACTIVE
|
|
427 |
// Delete log bus as absolute last!
|
|
428 |
// Some members might log destructor activity to this object.
|
|
429 |
delete iLogBus;
|
|
430 |
iLogBus = NULL;
|
|
431 |
#endif
|
|
432 |
|
|
433 |
iSessions.Reset();
|
|
434 |
}
|
|
435 |
|
|
436 |
#ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
437 |
// -----------------------------------------------------------------------------
|
|
438 |
// ChspsThemeServer::ShutdownInitiating
|
|
439 |
// From MShutdownObserver.
|
|
440 |
// -----------------------------------------------------------------------------
|
|
441 |
//
|
|
442 |
void ChspsThemeServer::ShutdownInitiating()
|
|
443 |
{
|
|
444 |
Cleanup();
|
|
445 |
}
|
|
446 |
#endif // #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
447 |
|
|
448 |
// -----------------------------------------------------------------------------
|
|
449 |
// ChspsThemeServer::Cleanup
|
|
450 |
// (other items were commented in a header).
|
|
451 |
// -----------------------------------------------------------------------------
|
|
452 |
//
|
|
453 |
void ChspsThemeServer::Cleanup()
|
|
454 |
{
|
|
455 |
#ifdef HSPS_LOG_ACTIVE
|
|
456 |
iLogBus->LogText( _L( "hspsThemeServer: server is shutting down" ) );
|
|
457 |
#endif
|
|
458 |
|
|
459 |
delete iFileMan;
|
|
460 |
if( iDefinitionRepository )
|
|
461 |
{
|
|
462 |
iDefinitionRepository->UnregisterObserver( *this );
|
|
463 |
}
|
|
464 |
|
|
465 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
466 |
DisableAutoInstallation();
|
|
467 |
#endif //__DISABLE_SISX_INSTALLATION_
|
|
468 |
|
|
469 |
if ( iFamily )
|
|
470 |
{
|
|
471 |
delete iFamily;
|
|
472 |
iFamily = NULL;
|
|
473 |
}
|
|
474 |
|
|
475 |
delete iCenRepListener;
|
|
476 |
iCenRepListener = NULL;
|
|
477 |
|
|
478 |
delete iRomInstaller;
|
|
479 |
iRomInstaller = NULL;
|
|
480 |
|
|
481 |
delete iAutoInstaller;
|
|
482 |
iAutoInstaller = NULL;
|
|
483 |
|
|
484 |
if( iHeaderListCache )
|
|
485 |
{
|
|
486 |
iHeaderListCache->ResetAndDestroy();
|
|
487 |
delete iHeaderListCache;
|
|
488 |
iHeaderListCache = NULL;
|
|
489 |
}
|
|
490 |
|
|
491 |
delete iDefinitionRepository;
|
|
492 |
iDefinitionRepository = NULL;
|
|
493 |
|
|
494 |
delete iCentralRepository;
|
|
495 |
iCentralRepository = NULL;
|
|
496 |
|
|
497 |
delete iSecurityEnforcer;
|
|
498 |
iSecurityEnforcer = NULL;
|
|
499 |
|
|
500 |
delete iCacheMask;
|
|
501 |
delete iBRObserver;
|
|
502 |
delete iActiveBackupClient;
|
|
503 |
delete iBRHandler;
|
|
504 |
|
|
505 |
iCacheMask = NULL;
|
|
506 |
|
|
507 |
iFsSession.Close();
|
|
508 |
}
|
|
509 |
|
|
510 |
// -----------------------------------------------------------------------------
|
|
511 |
// ChspsThemeServer::NewSessionL
|
|
512 |
// Create a new client session. This should really check the version number.
|
|
513 |
// (other items were commented in a header).
|
|
514 |
// -----------------------------------------------------------------------------
|
|
515 |
//
|
|
516 |
CSession2* ChspsThemeServer::NewSessionL(const TVersion&,const RMessage2& aMessage ) const
|
|
517 |
{
|
|
518 |
return new (ELeave) ChspsThemeServerSession( aMessage.SecureId().iId );
|
|
519 |
}
|
|
520 |
|
|
521 |
// -----------------------------------------------------------------------------
|
|
522 |
// ChspsThemeServer::AddSession
|
|
523 |
// A new session is being created
|
|
524 |
// (other items were commented in a header).
|
|
525 |
// -----------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
void ChspsThemeServer::AddSession( ChspsThemeServerSession* aSession )
|
|
528 |
{
|
|
529 |
if( aSession == NULL )
|
|
530 |
{
|
|
531 |
return;
|
|
532 |
}
|
|
533 |
|
|
534 |
iSessions.Append( aSession );
|
|
535 |
|
|
536 |
#ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
537 |
if( iShutdown->IsActive() )
|
|
538 |
{
|
|
539 |
iShutdown->Cancel();
|
|
540 |
}
|
|
541 |
#endif // _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
542 |
|
|
543 |
#ifdef HSPS_LOG_ACTIVE
|
|
544 |
iLogBus->LogText( _L( "ChspsThemeServer::AddSession(): - now %d concurrent sessions." ),
|
|
545 |
iSessions.Count() );
|
|
546 |
#endif
|
|
547 |
}
|
|
548 |
|
|
549 |
|
|
550 |
// -----------------------------------------------------------------------------
|
|
551 |
// ChspsThemeServer::DropSession
|
|
552 |
// A session is being destroyed
|
|
553 |
// (other items were commented in a header).
|
|
554 |
// -----------------------------------------------------------------------------
|
|
555 |
//
|
|
556 |
void ChspsThemeServer::DropSession( ChspsThemeServerSession* aSession )
|
|
557 |
{
|
|
558 |
const TInt index = iSessions.Find( aSession );
|
|
559 |
if( index != KErrNotFound )
|
|
560 |
{
|
|
561 |
iSessions.Remove( index );
|
|
562 |
}
|
|
563 |
|
|
564 |
#ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
565 |
if( iSessions.Count() == 0 )
|
|
566 |
{
|
|
567 |
iShutdown->Cancel();
|
|
568 |
iShutdown->Start();
|
|
569 |
}
|
|
570 |
#endif // _hsps_SERVER_SHUTDOWN_ENABLED_
|
|
571 |
|
|
572 |
#ifdef HSPS_LOG_ACTIVE
|
|
573 |
iLogBus->LogText( _L( "ChspsThemeServer::DropSession(): - %d concurrent sessions left." ),
|
|
574 |
iSessions.Count() );
|
|
575 |
#endif
|
|
576 |
}
|
|
577 |
|
|
578 |
// -----------------------------------------------------------------------------
|
|
579 |
// ChspsThemeServer::IncreaseRequestClientCount
|
|
580 |
// (other items were commented in a header).
|
|
581 |
// -----------------------------------------------------------------------------
|
|
582 |
//
|
|
583 |
void ChspsThemeServer::IncreaseRequestClientCount()
|
|
584 |
{
|
|
585 |
#ifdef HSPS_LOG_ACTIVE
|
|
586 |
iLogBus->LogText( _L( "ChspsThemeServer: ChspsThemeServer::IncreaseRequestClientCount()" ) );
|
|
587 |
#endif
|
|
588 |
|
|
589 |
iRequestClientCount++;
|
|
590 |
}
|
|
591 |
|
|
592 |
// -----------------------------------------------------------------------------
|
|
593 |
// ChspsThemeServer::DecreaseRequestClientCount
|
|
594 |
// (other items were commented in a header).
|
|
595 |
// -----------------------------------------------------------------------------
|
|
596 |
//
|
|
597 |
void ChspsThemeServer::DecreaseRequestClientCount()
|
|
598 |
{
|
|
599 |
#ifdef HSPS_LOG_ACTIVE
|
|
600 |
iLogBus->LogText( _L( "ChspsThemeServer: ChspsThemeServer::DecreaseRequestClientCount()" ) );
|
|
601 |
#endif
|
|
602 |
|
|
603 |
if ( iRequestClientCount )
|
|
604 |
{
|
|
605 |
iRequestClientCount--;
|
|
606 |
}
|
|
607 |
}
|
|
608 |
|
|
609 |
|
|
610 |
// -----------------------------------------------------------------------------
|
|
611 |
// ChspsThemeServer::HandleDefinitionRespositoryEvent()
|
|
612 |
// Handles events coming from hspsDefinitionRepository.
|
|
613 |
// (other items were commented in a header).
|
|
614 |
// -----------------------------------------------------------------------------
|
|
615 |
//
|
|
616 |
TBool ChspsThemeServer::HandleDefinitionRespositoryEvent( ThspsRepositoryInfo aRepositoryInfo )
|
|
617 |
{
|
|
618 |
TInt mask = aRepositoryInfo.iEventType;
|
|
619 |
TBool ret = EFalse;
|
|
620 |
|
|
621 |
#ifdef HSPS_LOG_ACTIVE
|
|
622 |
iLogBus->LogText( _L( "--------------------------------------------------------" ) );
|
|
623 |
#endif
|
|
624 |
|
|
625 |
if( aRepositoryInfo.iEventType & EhspsODTUpdated ||
|
|
626 |
aRepositoryInfo.iEventType & EhspsODTModified ||
|
|
627 |
aRepositoryInfo.iEventType & EhspsPluginReplaced )
|
|
628 |
{
|
|
629 |
SetResourceFileCopyRequired( aRepositoryInfo.iAppUid );
|
|
630 |
}
|
|
631 |
|
|
632 |
// If header cache should be updated from files in the Plug-in Repository
|
|
633 |
if (mask & EhspsCacheUpdate)
|
|
634 |
{
|
|
635 |
#ifdef HSPS_LOG_ACTIVE
|
|
636 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsCacheUpdate occurred." ) );
|
|
637 |
#endif
|
|
638 |
// Update the cache from contents of the themes folder in drive C (slowish operation!)
|
|
639 |
TRAP_IGNORE( UpdateHeaderListCacheL() );
|
|
640 |
}
|
|
641 |
|
|
642 |
// If a plug-in configuration was uninstalled from the Plug-in Repository
|
|
643 |
if (mask & EhspsClean)
|
|
644 |
{
|
|
645 |
#ifdef HSPS_LOG_ACTIVE
|
|
646 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsClean occurred." ) );
|
|
647 |
#endif
|
|
648 |
if(aRepositoryInfo.iLastNotification)
|
|
649 |
{
|
|
650 |
// Remove the provided ODT from the header list cache
|
|
651 |
UpdateHeaderListCache(
|
|
652 |
EhspsCacheRemoveHeader,
|
|
653 |
aRepositoryInfo.iPluginIfUid,
|
|
654 |
aRepositoryInfo.iPluginProviderUid,
|
|
655 |
aRepositoryInfo.iPluginUid
|
|
656 |
);
|
|
657 |
}
|
|
658 |
|
|
659 |
}
|
|
660 |
|
|
661 |
// If a plug-in configuration was installed into the Plug-in Repository
|
|
662 |
if (mask & EhspsODTAdded)
|
|
663 |
{
|
|
664 |
#ifdef HSPS_LOG_ACTIVE
|
|
665 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsODTAdded occurred." ) );
|
|
666 |
#endif
|
|
667 |
if(aRepositoryInfo.iLastNotification)
|
|
668 |
{
|
|
669 |
// Add the provided ODT to the header list cache
|
|
670 |
UpdateHeaderListCache(
|
|
671 |
EhspsCacheAddHeader,
|
|
672 |
aRepositoryInfo.iPluginIfUid,
|
|
673 |
aRepositoryInfo.iPluginProviderUid,
|
|
674 |
aRepositoryInfo.iPluginUid
|
|
675 |
);
|
|
676 |
}
|
|
677 |
|
|
678 |
}
|
|
679 |
|
|
680 |
// If a plug-in configuration was upgraded into the Plug-in Repository
|
|
681 |
if( mask & EhspsODTUpdated )
|
|
682 |
{
|
|
683 |
#ifdef HSPS_LOG_ACTIVE
|
|
684 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsODTUpdate occurred." ) );
|
|
685 |
#endif
|
|
686 |
if( aRepositoryInfo.iLastNotification )
|
|
687 |
{
|
|
688 |
// Add the provided ODT to the header list cache
|
|
689 |
UpdateHeaderListCache(
|
|
690 |
EhspsCacheAddHeader,
|
|
691 |
aRepositoryInfo.iPluginIfUid,
|
|
692 |
aRepositoryInfo.iPluginProviderUid,
|
|
693 |
aRepositoryInfo.iPluginUid
|
|
694 |
);
|
|
695 |
}
|
|
696 |
}
|
|
697 |
|
|
698 |
// If settings of an application configuration were modified
|
|
699 |
if (mask & EhspsSettingsChanged)
|
|
700 |
{
|
|
701 |
#ifdef HSPS_LOG_ACTIVE
|
|
702 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsSettingsChanged occurred." ) );
|
|
703 |
#endif
|
|
704 |
}
|
|
705 |
|
|
706 |
// If a plug-in configuration was added into or moved within an application configuration
|
|
707 |
if (mask & EhspsODTModified)
|
|
708 |
{
|
|
709 |
#ifdef HSPS_LOG_ACTIVE
|
|
710 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsODTModified occured." ) );
|
|
711 |
#endif
|
|
712 |
}
|
|
713 |
|
|
714 |
// If a plug-in configuration was removed from an application configuration
|
|
715 |
if (mask & EhspsODTRemoved)
|
|
716 |
{
|
|
717 |
#ifdef HSPS_LOG_ACTIVE
|
|
718 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleDefinitionRespositoryEvent(): - EhspsODTRemoved occurred." ) );
|
|
719 |
#endif
|
|
720 |
}
|
|
721 |
|
|
722 |
#ifdef HSPS_LOG_ACTIVE
|
|
723 |
iLogBus->LogText( _L( "--------------------------------------------------------" ) );
|
|
724 |
#endif
|
|
725 |
|
|
726 |
return ret;
|
|
727 |
}
|
|
728 |
|
|
729 |
// -----------------------------------------------------------------------------
|
|
730 |
// ChspsThemeServer::DefinitionRepository
|
|
731 |
// (other items were commented in a header).
|
|
732 |
// -----------------------------------------------------------------------------
|
|
733 |
//
|
|
734 |
ChspsDefinitionRepository& ChspsThemeServer::DefinitionRepository()
|
|
735 |
{
|
|
736 |
return *iDefinitionRepository;
|
|
737 |
}
|
|
738 |
|
|
739 |
// ChspsThemeServer::SecurityEnforcer
|
|
740 |
// (other items were commented in a header).
|
|
741 |
// -----------------------------------------------------------------------------
|
|
742 |
//
|
|
743 |
ChspsSecurityEnforcer& ChspsThemeServer::SecurityEnforcer()
|
|
744 |
{
|
|
745 |
return *iSecurityEnforcer;
|
|
746 |
}
|
|
747 |
|
|
748 |
|
|
749 |
// ChspsThemeServer::CentralRepository
|
|
750 |
// (other items were commented in a header).
|
|
751 |
// -----------------------------------------------------------------------------
|
|
752 |
//
|
|
753 |
CRepository& ChspsThemeServer::CentralRepository()
|
|
754 |
{
|
|
755 |
return *iCentralRepository;
|
|
756 |
}
|
|
757 |
|
|
758 |
// ChspsThemeServer::DeviceLaguage
|
|
759 |
// (other items were commented in a header).
|
|
760 |
// -----------------------------------------------------------------------------
|
|
761 |
//
|
|
762 |
TLanguage ChspsThemeServer::DeviceLanguage()
|
|
763 |
{
|
|
764 |
iDeviceLanguage = GetDeviceLanguage();
|
|
765 |
return iDeviceLanguage;
|
|
766 |
}
|
|
767 |
|
|
768 |
// -----------------------------------------------------------------------------
|
|
769 |
// ChspsThemeServer::UpdateHeaderListCache
|
|
770 |
// (other items were commented in a header).
|
|
771 |
// -----------------------------------------------------------------------------
|
|
772 |
//
|
|
773 |
CArrayPtrSeg<ChspsODT>& ChspsThemeServer::HeaderListCache()
|
|
774 |
{
|
|
775 |
return *iHeaderListCache;
|
|
776 |
}
|
|
777 |
|
|
778 |
// -----------------------------------------------------------------------------
|
|
779 |
// ChspsThemeServer::UninstallImport
|
|
780 |
// -----------------------------------------------------------------------------
|
|
781 |
//
|
|
782 |
void ChspsThemeServer::UninstallImport(
|
|
783 |
const CDir* aFilelist )
|
|
784 |
{
|
|
785 |
TInt count( 0 );
|
|
786 |
if ( aFilelist )
|
|
787 |
{
|
|
788 |
count = aFilelist->Count();
|
|
789 |
}
|
|
790 |
|
|
791 |
// Loop installed configurations
|
|
792 |
for( TInt i = 0; i < iInstalledSisxThemes.Count(); i++ )
|
|
793 |
{
|
|
794 |
// Suppose this is the one which was removed
|
|
795 |
iThemeIndexToRemove = i;
|
|
796 |
|
|
797 |
// Loop files under the imports folder
|
|
798 |
for( TInt j = 0; j < count; j++ )
|
|
799 |
{
|
|
800 |
TPtrC filename( ( *aFilelist )[j].iName );
|
|
801 |
|
|
802 |
// If theme path exists
|
|
803 |
if( filename == *( iInstalledSisxThemes[i] ) )
|
|
804 |
{
|
|
805 |
// Break inner loop
|
|
806 |
iThemeIndexToRemove = KErrNotFound;
|
|
807 |
break;
|
|
808 |
}
|
|
809 |
}
|
|
810 |
|
|
811 |
// iThemeIndexToRemove should now point the configuration which was removed
|
|
812 |
RunAutoInstaller( EAutoInstallerUninstall );
|
|
813 |
}
|
|
814 |
}
|
|
815 |
|
|
816 |
// -----------------------------------------------------------------------------
|
|
817 |
// ChspsThemeServer::GetManifestFromImportLC
|
|
818 |
// -----------------------------------------------------------------------------
|
|
819 |
//
|
|
820 |
HBufC* ChspsThemeServer::GetManifestFromImportLC(
|
|
821 |
const TDesC& aImportFile,
|
|
822 |
const TDesC& aPath )
|
|
823 |
{
|
|
824 |
HBufC* manifestBuf = 0;
|
|
825 |
|
|
826 |
const TChar KCharUnderscore('_');
|
|
827 |
|
|
828 |
// Strip file prefix
|
|
829 |
TPtrC fixedName;
|
|
830 |
TInt offset = aImportFile.Locate( KCharUnderscore );
|
|
831 |
if( offset )
|
|
832 |
{
|
|
833 |
TPtrC filePrefix( aImportFile.Left(offset+1) );
|
|
834 |
|
|
835 |
// If a valid prefix
|
|
836 |
if ( filePrefix.CompareF( KPrefixFileApp) || filePrefix.CompareF( KPrefixFilePlugin ) )
|
|
837 |
{
|
|
838 |
fixedName.Set( aImportFile.Mid( filePrefix.Length() ) );
|
|
839 |
}
|
|
840 |
}
|
|
841 |
|
|
842 |
// If stripping was successfull
|
|
843 |
if ( fixedName.Length() )
|
|
844 |
{
|
|
845 |
// Remove file extension
|
|
846 |
TParsePtrC parsePtr( fixedName );
|
|
847 |
TPtrC fileName( parsePtr.Name() );
|
|
848 |
|
|
849 |
// Setup path for the manifest file
|
|
850 |
manifestBuf = HBufC::NewLC( KMaxFileName );
|
|
851 |
TPtr manifestPtr( manifestBuf->Des() );
|
|
852 |
manifestPtr.Append( aPath );
|
|
853 |
manifestPtr.Append( fileName );
|
|
854 |
|
|
855 |
// Replace underscores with backslashes
|
|
856 |
TInt pos( manifestPtr.Locate( KCharUnderscore ) );
|
|
857 |
while( pos != KErrNotFound )
|
|
858 |
{
|
|
859 |
manifestPtr.Replace( pos, 1, KDoubleBackSlash );
|
|
860 |
pos = manifestPtr.Locate( KCharUnderscore );
|
|
861 |
}
|
|
862 |
manifestPtr.Append( KDoubleBackSlash );
|
|
863 |
|
|
864 |
// Find a manifest.dat file from the generated path
|
|
865 |
CDir* manifestDir( NULL );
|
|
866 |
TFindFile fileFinder( iFsSession );
|
|
867 |
fileFinder.FindWildByDir( KManifestFile, manifestPtr, manifestDir );
|
|
868 |
|
|
869 |
// Check whether the manifest was found
|
|
870 |
if( !manifestDir || manifestDir->Count() > 1 )
|
|
871 |
{
|
|
872 |
// Failed
|
|
873 |
CleanupStack::PopAndDestroy( 1, manifestBuf );
|
|
874 |
manifestBuf = NULL;
|
|
875 |
}
|
|
876 |
else
|
|
877 |
{
|
|
878 |
manifestPtr.Append( KManifestFile );
|
|
879 |
}
|
|
880 |
|
|
881 |
delete manifestDir;
|
|
882 |
manifestDir = NULL;
|
|
883 |
}
|
|
884 |
|
|
885 |
return manifestBuf;
|
|
886 |
}
|
|
887 |
|
|
888 |
// -----------------------------------------------------------------------------
|
|
889 |
// ChspsThemeServer::CheckConfiguration
|
|
890 |
// -----------------------------------------------------------------------------
|
|
891 |
//
|
|
892 |
void ChspsThemeServer::CheckConfigurationL(
|
|
893 |
const TInt aAppUid )
|
|
894 |
{
|
|
895 |
|
|
896 |
if ( iHeaderListCache )
|
|
897 |
{
|
|
898 |
TInt count = iHeaderListCache->Count();
|
|
899 |
if ( iDefinitionRepository->Locked() )
|
|
900 |
{
|
|
901 |
User::Leave( KErrInUse );
|
|
902 |
}
|
|
903 |
iDefinitionRepository->Lock();
|
|
904 |
|
|
905 |
// Check if configuration checking is activated
|
|
906 |
TPtrC8 confState;
|
|
907 |
TPtrC8 nextConfState;
|
|
908 |
TInt value( 0 );
|
|
909 |
User::LeaveIfError( iCentralRepository->Get( KCenrepKeyCheckConf, value ) );
|
|
910 |
if ( value == 1 )
|
|
911 |
{
|
|
912 |
// Configuration checking activated
|
|
913 |
// All configurations with "WaitForConfiguration" state will be updated to
|
|
914 |
// "Error" state
|
|
915 |
confState.Set( KConfStateWaitForConfirmation );
|
|
916 |
nextConfState.Set( KConfStateError );
|
|
917 |
}
|
|
918 |
else
|
|
919 |
{
|
|
920 |
// Configuration checking not activated
|
|
921 |
// All configurations with "WaitForConfiguration" state will be updated to
|
|
922 |
// "NotConfirmed" state
|
|
923 |
confState.Set( KConfStateWaitForConfirmation );
|
|
924 |
nextConfState.Set( KConfStateNotConfirmed );
|
|
925 |
}
|
|
926 |
|
|
927 |
for ( TInt i = 0; i < count; i++ )
|
|
928 |
{
|
|
929 |
ChspsODT* header = ( *iHeaderListCache )[ i ];
|
|
930 |
if ( header->ConfigurationType() == EhspsAppConfiguration &&
|
|
931 |
( header->RootUid() == aAppUid ||
|
|
932 |
aAppUid == KAppIdAny ) )
|
|
933 |
{
|
|
934 |
// Get ODT from definition repository
|
|
935 |
|
|
936 |
ChspsODT* odt = ChspsODT::NewL();
|
|
937 |
CleanupStack::PushL( odt );
|
|
938 |
odt->SetRootUid( header->RootUid() );
|
|
939 |
odt->SetThemeUid( header->ThemeUid() );
|
|
940 |
odt->SetConfigurationType( header->ConfigurationType() );
|
|
941 |
odt->SetRootUid( header->RootUid() );
|
|
942 |
odt->SetProviderUid( header->ProviderUid() );
|
|
943 |
odt->SetThemeUid( header->ThemeUid() );
|
|
944 |
odt->SetProviderNameL( header->ProviderName() );
|
|
945 |
odt->SetThemeFullNameL( header->ThemeFullName() );
|
|
946 |
odt->SetThemeShortNameL( header->ThemeShortName() );
|
|
947 |
odt->SetThemeVersionL( header->ThemeVersion() );
|
|
948 |
odt->SetDescriptionL( header->Description() );
|
|
949 |
odt->SetFlags( header->Flags() );
|
|
950 |
odt->SetMultiInstance( header->MultiInstance() );
|
|
951 |
|
|
952 |
User::LeaveIfError( iDefinitionRepository->GetOdtL( *odt ) );
|
|
953 |
|
|
954 |
// Update configuration states
|
|
955 |
TBool odtUpdated( EFalse );
|
|
956 |
hspsServerUtil::UpdateConfigurationStateL(
|
|
957 |
*odt,
|
|
958 |
confState,
|
|
959 |
nextConfState,
|
|
960 |
odtUpdated );
|
|
961 |
if ( odtUpdated )
|
|
962 |
{
|
|
963 |
// Update modified ODT to definition repository
|
|
964 |
User::LeaveIfError( iDefinitionRepository->SetOdtL( *odt ) );
|
|
965 |
}
|
|
966 |
|
|
967 |
CleanupStack::PopAndDestroy( odt );
|
|
968 |
}
|
|
969 |
}
|
|
970 |
iDefinitionRepository->Unlock();
|
|
971 |
}
|
|
972 |
}
|
|
973 |
|
|
974 |
// -----------------------------------------------------------------------------
|
|
975 |
// ChspsThemeServer::InstallImportsL
|
|
976 |
// -----------------------------------------------------------------------------
|
|
977 |
//
|
|
978 |
void ChspsThemeServer::InstallImportsL(
|
|
979 |
const CDir& aFilelist )
|
|
980 |
{
|
|
981 |
const TInt count( aFilelist.Count() );
|
|
982 |
|
|
983 |
// Go through the filtered file list
|
|
984 |
for( TInt importIndex = 0; importIndex < count; importIndex++ )
|
|
985 |
{
|
|
986 |
TBool found( EFalse );
|
|
987 |
TPtrC importName( aFilelist[importIndex].iName );
|
|
988 |
|
|
989 |
// Is the file already pending an installation?
|
|
990 |
for( TInt j = 0; !found && j < iInstallableSisxThemes.Count(); j++ )
|
|
991 |
{
|
|
992 |
if( importName == *( iInstallableSisxThemes[j] ) )
|
|
993 |
{
|
|
994 |
found = ETrue;
|
|
995 |
}
|
|
996 |
}
|
|
997 |
|
|
998 |
// Is the file already installed?
|
|
999 |
for( TInt j = 0; !found && j < iInstalledSisxThemes.Count(); j++ )
|
|
1000 |
{
|
|
1001 |
if( importName == *( iInstalledSisxThemes[j] ) )
|
|
1002 |
{
|
|
1003 |
found = ETrue;
|
|
1004 |
}
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
if ( !found )
|
|
1008 |
{
|
|
1009 |
// Get manifest from the import's name in C drive
|
|
1010 |
HBufC* manifestBuf = GetManifestFromImportLC(
|
|
1011 |
importName,
|
|
1012 |
KImportDirectoryC );
|
|
1013 |
if( manifestBuf )
|
|
1014 |
{
|
|
1015 |
// Append the manifest
|
|
1016 |
iManifestFiles.AppendL( manifestBuf );
|
|
1017 |
CleanupStack::Pop( manifestBuf );
|
|
1018 |
|
|
1019 |
// Append the import
|
|
1020 |
iInstallableSisxThemes.AppendL( importName.AllocL() );
|
|
1021 |
}
|
|
1022 |
}
|
|
1023 |
}
|
|
1024 |
|
|
1025 |
// Now that the manifest list has been parsed, initiate installation of
|
|
1026 |
// the new manifest files
|
|
1027 |
if( iAutoInstallerState != EAutoInstallerStateInstall )
|
|
1028 |
{
|
|
1029 |
RunAutoInstaller( EAutoInstallerStateInstall );
|
|
1030 |
}
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
// -----------------------------------------------------------------------------
|
|
1034 |
// ChspsThemeServer::HandleConfigurationImportsL
|
|
1035 |
// -----------------------------------------------------------------------------
|
|
1036 |
//
|
|
1037 |
void ChspsThemeServer::HandleConfigurationImportsL(
|
|
1038 |
const TDesC& aFilePrefix )
|
|
1039 |
{
|
|
1040 |
// Set mask for finding files under imports folder
|
|
1041 |
TPtrC filter( KFilterAllPluginImportsV1 );
|
|
1042 |
if ( aFilePrefix.CompareF( KPrefixFileApp ) == 0 )
|
|
1043 |
{
|
|
1044 |
filter.Set( KFilterAllAppImportsV1 );
|
|
1045 |
}
|
|
1046 |
|
|
1047 |
// Get a listing of plugin_*.dat files from the imports folder in C drive
|
|
1048 |
CDir* importsDir( NULL );
|
|
1049 |
TFindFile fileFinder( iFsSession );
|
|
1050 |
fileFinder.FindWildByDir( filter, KImportDirectoryC, importsDir );
|
|
1051 |
CleanupStack::PushL( importsDir );
|
|
1052 |
|
|
1053 |
// pathFileList can be NULL when no path_*.dat files are available in the import folder.
|
|
1054 |
// This can mean that currently the last sisx package is under unistallation, and because
|
|
1055 |
// of that, we need to check that case with pathFileCount = 0
|
|
1056 |
TInt importsCount( 0 );
|
|
1057 |
if( importsDir )
|
|
1058 |
{
|
|
1059 |
importsCount = importsDir->Count();
|
|
1060 |
}
|
|
1061 |
|
|
1062 |
// Find out number of installed themes with the provided file prefix
|
|
1063 |
TInt installedCount = 0;
|
|
1064 |
const TInt prefixLength = aFilePrefix.Length();
|
|
1065 |
for( TInt i=0; i < iInstalledSisxThemes.Count(); i++ )
|
|
1066 |
{
|
|
1067 |
TPtrC ptr( iInstalledSisxThemes[ i ]->Des() );
|
|
1068 |
if ( ptr.Length() > prefixLength )
|
|
1069 |
{
|
|
1070 |
if ( ptr.Left( prefixLength ).CompareF( aFilePrefix ) == 0 )
|
|
1071 |
{
|
|
1072 |
installedCount++;
|
|
1073 |
}
|
|
1074 |
}
|
|
1075 |
}
|
|
1076 |
|
|
1077 |
if( importsCount < installedCount )
|
|
1078 |
{
|
|
1079 |
// there were less *.dat files than in the last evaluation
|
|
1080 |
UninstallImport( importsDir );
|
|
1081 |
}
|
|
1082 |
else if( importsCount > installedCount && importsDir )
|
|
1083 |
{
|
|
1084 |
// If a *.dat file was added since the last evaluation
|
|
1085 |
InstallImportsL( *importsDir );
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
CleanupStack::PopAndDestroy( importsDir );
|
|
1089 |
}
|
|
1090 |
|
|
1091 |
// -----------------------------------------------------------------------------
|
|
1092 |
// ChspsThemeServer::HandleFileSystemChangeL
|
|
1093 |
// -----------------------------------------------------------------------------
|
|
1094 |
//
|
|
1095 |
void ChspsThemeServer::HandleFileSystemChangeL()
|
|
1096 |
{
|
|
1097 |
// Install unprocessed plug-in configurations from the import folders,
|
|
1098 |
// these might be referenced by one or more application configurations - thus,
|
|
1099 |
// this step should be done first!
|
|
1100 |
HandleConfigurationImportsL( KPrefixFilePlugin );
|
|
1101 |
|
|
1102 |
// Install remaining application configurations from the import folders
|
|
1103 |
HandleConfigurationImportsL( KPrefixFileApp );
|
|
1104 |
|
|
1105 |
// File system change can also mean that a theme is being updated
|
|
1106 |
HandleThemeUpgradeL();
|
|
1107 |
}
|
|
1108 |
|
|
1109 |
// -----------------------------------------------------------------------------
|
|
1110 |
// ChspsThemeServer::HandleFileSystemChange
|
|
1111 |
// -----------------------------------------------------------------------------
|
|
1112 |
//
|
|
1113 |
void ChspsThemeServer::HandleFileSystemChange()
|
|
1114 |
{
|
|
1115 |
// Fancy way of checking whether SISX installations are enabled :)
|
|
1116 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
1117 |
|
|
1118 |
// Register again ...
|
|
1119 |
iFileChangeListener->Setup();
|
|
1120 |
|
|
1121 |
// ... and then handle the change
|
|
1122 |
TRAP_IGNORE( HandleFileSystemChangeL() );
|
|
1123 |
|
|
1124 |
#endif // __DISABLE_SISX_INSTALLATION_
|
|
1125 |
}
|
|
1126 |
|
|
1127 |
// -----------------------------------------------------------------------------
|
|
1128 |
// ChspsThemeServer::CheckActiveTheme
|
|
1129 |
// CheckActiveTheme the specified theme.
|
|
1130 |
// (other items were commented in a header).
|
|
1131 |
// -----------------------------------------------------------------------------
|
|
1132 |
void ChspsThemeServer::CheckActiveThemesL()
|
|
1133 |
{
|
|
1134 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
1135 |
TInt themeUid;
|
|
1136 |
RArray<TUint32> res;
|
|
1137 |
CleanupClosePushL( res );
|
|
1138 |
TInt errorCode = KErrNone;
|
|
1139 |
iCentralRepository->FindL( 0x00000000,0xFFFFFFFF, res );
|
|
1140 |
const TInt keyCount = res.Count();
|
|
1141 |
for (TInt i = 0; i < keyCount; i++ )
|
|
1142 |
{
|
|
1143 |
errorCode = iCentralRepository->Get( res[i], themeUid );
|
|
1144 |
if ( !errorCode )
|
|
1145 |
{
|
|
1146 |
HBufC* matchthemeUid = HBufC::NewLC( KMaxFileName );
|
|
1147 |
TPtr matchthemeUidPtr = matchthemeUid->Des();
|
|
1148 |
matchthemeUidPtr.Append( KPrefixFileApp );
|
|
1149 |
matchthemeUidPtr.Append( _L("*_") );
|
|
1150 |
matchthemeUidPtr.AppendNumUC( themeUid, EHex );
|
|
1151 |
matchthemeUidPtr.Append( _L( "_*" ) );
|
|
1152 |
|
|
1153 |
HBufC* pathFileName = HBufC::NewL ( KMaxFileName );
|
|
1154 |
TPtr pathFileNamePtr = pathFileName->Des();
|
|
1155 |
CDir* fileList;
|
|
1156 |
TFindFile fileFinder( iFsSession );
|
|
1157 |
// Find path info file for matching unique themeuid
|
|
1158 |
fileFinder.FindWildByDir( *matchthemeUid, KImportDirectoryC, fileList );
|
|
1159 |
if( fileList )
|
|
1160 |
{
|
|
1161 |
TBool isItOpen = EFalse;
|
|
1162 |
pathFileNamePtr.Copy( KImportDirectoryC );
|
|
1163 |
pathFileNamePtr.Append( (*fileList)[0].iName );
|
|
1164 |
if ( res[i] == KAppId_hspsAS )
|
|
1165 |
{
|
|
1166 |
errorCode = iFsSession.IsFileOpen( pathFileNamePtr, isItOpen );
|
|
1167 |
if ( !isItOpen )
|
|
1168 |
{
|
|
1169 |
errorCode = iFileAS.Open(iFsSession, pathFileNamePtr, EFileRead );
|
|
1170 |
}
|
|
1171 |
}
|
|
1172 |
else if ( res[i] == KAppId_hspsAI )
|
|
1173 |
{
|
|
1174 |
errorCode = iFsSession.IsFileOpen( pathFileNamePtr, isItOpen );
|
|
1175 |
if ( !isItOpen )
|
|
1176 |
{
|
|
1177 |
errorCode = iFileAI.Open(iFsSession, pathFileNamePtr, EFileRead );
|
|
1178 |
}
|
|
1179 |
}
|
|
1180 |
else if ( res[i] == KAppId_LE )
|
|
1181 |
{
|
|
1182 |
errorCode = iFsSession.IsFileOpen( pathFileNamePtr, isItOpen );
|
|
1183 |
if ( !isItOpen )
|
|
1184 |
{
|
|
1185 |
errorCode = iFileLT.Open(iFsSession, pathFileNamePtr, EFileRead );
|
|
1186 |
}
|
|
1187 |
}
|
|
1188 |
}
|
|
1189 |
delete fileList;
|
|
1190 |
delete pathFileName;
|
|
1191 |
CleanupStack::PopAndDestroy( matchthemeUid );
|
|
1192 |
}
|
|
1193 |
}
|
|
1194 |
res.Close();
|
|
1195 |
CleanupStack::PopAndDestroy(1, &res);
|
|
1196 |
#endif //__DISABLE_SISX_INSTALLATION_
|
|
1197 |
}
|
|
1198 |
|
|
1199 |
// -----------------------------------------------------------------------------
|
|
1200 |
// ChspsThemeServer::UnlockSisxImportL()
|
|
1201 |
// -----------------------------------------------------------------------------
|
|
1202 |
//
|
|
1203 |
void ChspsThemeServer::UnlockSisxImportL(
|
|
1204 |
const TUint32 aAppUid )
|
|
1205 |
{
|
|
1206 |
__UHEAP_MARK;
|
|
1207 |
// Setup a filter for finding an SISX import with the provided application uid
|
|
1208 |
HBufC* filterBuf = HBufC::NewLC( KMaxFileName );
|
|
1209 |
TPtr filterPtr = filterBuf->Des();
|
|
1210 |
filterPtr.Copy( KPrefixFileApp );
|
|
1211 |
filterPtr.AppendNumUC( aAppUid, EHex );
|
|
1212 |
_LIT(KFilter, "_*_*_1.0.dat");
|
|
1213 |
filterPtr.Append( KFilter );
|
|
1214 |
|
|
1215 |
// Find imports with the generated filter (ROM based imports should not be found)
|
|
1216 |
CDir* importsDir( NULL );
|
|
1217 |
TFindFile fileFinder( iFsSession );
|
|
1218 |
fileFinder.FindWildByDir( filterPtr, KImportDirectoryC, importsDir );
|
|
1219 |
if( importsDir )
|
|
1220 |
{
|
|
1221 |
HBufC* importBuf = HBufC::NewLC ( KMaxFileName );
|
|
1222 |
TPtr importPtr = importBuf->Des();
|
|
1223 |
|
|
1224 |
// CleanupStack is not required since there are no leaving function calls below
|
|
1225 |
|
|
1226 |
// Loop application specific imports
|
|
1227 |
TInt errorCode = KErrNone;
|
|
1228 |
TBool isOpen = EFalse;
|
|
1229 |
for ( TInt i = 0; i< importsDir->Count(); i++ )
|
|
1230 |
{
|
|
1231 |
importPtr.Copy( KImportDirectoryC );
|
|
1232 |
importPtr.Append( (*importsDir)[i].iName );
|
|
1233 |
errorCode = iFsSession.IsFileOpen( importPtr, isOpen );
|
|
1234 |
if ( errorCode == KErrNone )
|
|
1235 |
{
|
|
1236 |
// Only a single file should be open
|
|
1237 |
if( isOpen )
|
|
1238 |
{
|
|
1239 |
// Close application specific file handles
|
|
1240 |
if ( aAppUid == KAppId_hspsAS )
|
|
1241 |
{
|
|
1242 |
iFileAS.Close();
|
|
1243 |
}
|
|
1244 |
else if ( aAppUid == KAppId_hspsAI )
|
|
1245 |
{
|
|
1246 |
iFileAI.Close();
|
|
1247 |
}
|
|
1248 |
else if ( aAppUid == KAppId_LE )
|
|
1249 |
{
|
|
1250 |
iFileLT.Close();
|
|
1251 |
}
|
|
1252 |
}
|
|
1253 |
}
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
CleanupStack::PopAndDestroy( importBuf );
|
|
1257 |
delete importsDir;
|
|
1258 |
}
|
|
1259 |
|
|
1260 |
CleanupStack::PopAndDestroy( filterBuf );
|
|
1261 |
__UHEAP_MARKEND;
|
|
1262 |
}
|
|
1263 |
|
|
1264 |
// -----------------------------------------------------------------------------
|
|
1265 |
// ChspsThemeServer::LockSisxImportL()
|
|
1266 |
// -----------------------------------------------------------------------------
|
|
1267 |
//
|
|
1268 |
void ChspsThemeServer::LockSisxImportL(
|
|
1269 |
const TUint32 aAppUid,
|
|
1270 |
const TInt aConfUid )
|
|
1271 |
{
|
|
1272 |
__UHEAP_MARK;
|
|
1273 |
// Setup a filter for finding specific application configuration
|
|
1274 |
HBufC* filterBuf = HBufC::NewLC( KMaxFileName );
|
|
1275 |
TPtr filterPtr = filterBuf->Des();
|
|
1276 |
filterPtr.Copy( KPrefixFileApp );
|
|
1277 |
filterPtr.Append( _L("*_*_") );
|
|
1278 |
filterPtr.AppendNumUC( aConfUid, EHex );
|
|
1279 |
filterPtr.Append( _L( "_1.0.dat" ) );
|
|
1280 |
|
|
1281 |
// Find imports with the generated filter (ROM based imports should not be found)
|
|
1282 |
CDir* importsDir( NULL );
|
|
1283 |
TFindFile fileFinder( iFsSession );
|
|
1284 |
fileFinder.FindWildByDir( filterPtr, KImportDirectoryC, importsDir );
|
|
1285 |
if ( importsDir )
|
|
1286 |
{
|
|
1287 |
CleanupStack::PushL( importsDir );
|
|
1288 |
|
|
1289 |
// themeuid is unique so count should be 1
|
|
1290 |
if ( importsDir->Count() == 1 )
|
|
1291 |
{
|
|
1292 |
HBufC* importBuf = HBufC::NewLC ( KMaxFileName );
|
|
1293 |
TPtr importPtr = importBuf->Des();
|
|
1294 |
importPtr.Copy( KImportDirectoryC );
|
|
1295 |
importPtr.Append( (*importsDir)[0].iName );
|
|
1296 |
|
|
1297 |
TBool isOpen = EFalse;
|
|
1298 |
TInt errorCode = iFsSession.IsFileOpen( importPtr, isOpen );
|
|
1299 |
if ( errorCode == KErrNone && !isOpen )
|
|
1300 |
{
|
|
1301 |
// Lock the application specific SISX imports
|
|
1302 |
if ( aAppUid == KAppId_hspsAS )
|
|
1303 |
{
|
|
1304 |
errorCode = iFileAS.Open( iFsSession, importPtr, EFileRead );
|
|
1305 |
}
|
|
1306 |
else if ( aAppUid == KAppId_hspsAI )
|
|
1307 |
{
|
|
1308 |
errorCode = iFileAI.Open( iFsSession, importPtr, EFileRead );
|
|
1309 |
}
|
|
1310 |
else if ( aAppUid == KAppId_LE )
|
|
1311 |
{
|
|
1312 |
errorCode = iFileLT.Open( iFsSession, importPtr, EFileRead );
|
|
1313 |
}
|
|
1314 |
}
|
|
1315 |
CleanupStack::PopAndDestroy( importBuf );
|
|
1316 |
}
|
|
1317 |
|
|
1318 |
CleanupStack::PopAndDestroy( importsDir );
|
|
1319 |
}
|
|
1320 |
|
|
1321 |
CleanupStack::PopAndDestroy( filterBuf );
|
|
1322 |
__UHEAP_MARKEND;
|
|
1323 |
}
|
|
1324 |
|
|
1325 |
|
|
1326 |
// -----------------------------------------------------------------------------
|
|
1327 |
// ChspsThemeServer::HandleCenRepChangeL()
|
|
1328 |
// Handles events coming from CentralRepository.
|
|
1329 |
// -----------------------------------------------------------------------------
|
|
1330 |
//
|
|
1331 |
void ChspsThemeServer::HandleCenRepChangeL( const TUint32 aKey )
|
|
1332 |
{
|
|
1333 |
switch ( aKey )
|
|
1334 |
{
|
|
1335 |
case KCenrepKeyLang:
|
|
1336 |
case KCenrepKeyPostRFS:
|
|
1337 |
case KCenrepKeyCheckConf:
|
|
1338 |
{
|
|
1339 |
// No processing required
|
|
1340 |
}
|
|
1341 |
break;
|
|
1342 |
default:
|
|
1343 |
{
|
|
1344 |
|
|
1345 |
// If SISX installations were enabled
|
|
1346 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
1347 |
// Get active application configuration for the provided application uid
|
|
1348 |
TInt confUid(0);
|
|
1349 |
TInt errorCode = iCentralRepository->Get( aKey, confUid );
|
|
1350 |
if ( !errorCode && confUid > 0 )
|
|
1351 |
{
|
|
1352 |
// Remove file lock from active SISX import
|
|
1353 |
UnlockSisxImportL( aKey );
|
|
1354 |
// Lock the new SISX import (prevents uninstallation of the SISX
|
|
1355 |
// while it's being used as an active application configuration)
|
|
1356 |
LockSisxImportL( aKey, confUid );
|
|
1357 |
}
|
|
1358 |
#endif //__DISABLE_SISX_INSTALLATION_
|
|
1359 |
|
|
1360 |
}
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
// Set up the listener to listen to changes in Central Repository for all settings
|
|
1364 |
iCenRepListener->SetupAll();
|
|
1365 |
}
|
|
1366 |
|
|
1367 |
// -----------------------------------------------------------------------------
|
|
1368 |
// ChspsThemeServer::HandleAutoInstallerEvent
|
|
1369 |
// (other items were commented in a header).
|
|
1370 |
// -----------------------------------------------------------------------------
|
|
1371 |
//
|
|
1372 |
void ChspsThemeServer::HandleAutoInstallerEvent( ThspsServiceCompletedMessage aMsg )
|
|
1373 |
{
|
|
1374 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
1375 |
switch ( aMsg )
|
|
1376 |
{
|
|
1377 |
case EhspsInstallPhaseSuccess:
|
|
1378 |
// Phase was success, installation will continue
|
|
1379 |
break;
|
|
1380 |
case EhspsInstallThemeSuccess:
|
|
1381 |
{
|
|
1382 |
// Mark current theme as installed
|
|
1383 |
TBool isInstalled = EFalse;
|
|
1384 |
|
|
1385 |
//check if theme is already listed as installed
|
|
1386 |
//there is a possibility that the install is an upgrade and the theme would be alredy listed
|
|
1387 |
//in the iInstalledSisxThemes
|
|
1388 |
if( iInstalledSisxThemes.Count() > iCurrentManifestFile )
|
|
1389 |
{
|
|
1390 |
for (TInt i = 0; i < iInstalledSisxThemes.Count(); i++)
|
|
1391 |
{
|
|
1392 |
if ( *iInstalledSisxThemes[i] == *iInstallableSisxThemes[ iCurrentManifestFile ] )
|
|
1393 |
{
|
|
1394 |
isInstalled = ETrue;
|
|
1395 |
break;
|
|
1396 |
}
|
|
1397 |
}
|
|
1398 |
}
|
|
1399 |
|
|
1400 |
//if theme is not installed yet than add it to iInstalledSisxThemes
|
|
1401 |
if ( !isInstalled )
|
|
1402 |
{
|
|
1403 |
iInstalledSisxThemes.Append( iInstallableSisxThemes[ iCurrentManifestFile ] );
|
|
1404 |
}
|
|
1405 |
|
|
1406 |
iCurrentManifestFile++;
|
|
1407 |
|
|
1408 |
// Check if more installable files available
|
|
1409 |
delete iAutoInstaller;
|
|
1410 |
iAutoInstaller = NULL;
|
|
1411 |
|
|
1412 |
RunAutoInstaller( EAutoInstallerStateInstall );
|
|
1413 |
}
|
|
1414 |
break;
|
|
1415 |
case EhspsRemoveThemeSuccess:
|
|
1416 |
{
|
|
1417 |
delete iInstalledSisxThemes[ iThemeIndexToRemove ];
|
|
1418 |
iInstalledSisxThemes[ iThemeIndexToRemove ] = NULL;
|
|
1419 |
iInstalledSisxThemes.Remove( iThemeIndexToRemove );
|
|
1420 |
}
|
|
1421 |
/* flow through */
|
|
1422 |
case EhspsRemoveThemeFailed:
|
|
1423 |
/* flow through */
|
|
1424 |
default:
|
|
1425 |
StopAutoInstaller();
|
|
1426 |
break;
|
|
1427 |
}
|
|
1428 |
#endif //__DISABLE_SISX_INSTALLATION_
|
|
1429 |
}
|
|
1430 |
|
|
1431 |
// -----------------------------------------------------------------------------
|
|
1432 |
// ChspsThemeServer::RunAutoInstaller
|
|
1433 |
// (other items were commented in a header).
|
|
1434 |
// -----------------------------------------------------------------------------
|
|
1435 |
//
|
|
1436 |
TBool ChspsThemeServer::RunAutoInstaller( TAutoInstallerStates aState )
|
|
1437 |
{
|
|
1438 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
1439 |
TBool started( EFalse );
|
|
1440 |
|
|
1441 |
if( !iAutoInstaller )
|
|
1442 |
{
|
|
1443 |
TRAP_IGNORE( iAutoInstaller = ChspsAutoInstaller::NewL( *this ) );
|
|
1444 |
#ifdef HSPS_LOG_ACTIVE
|
|
1445 |
if ( iAutoInstaller )
|
|
1446 |
{
|
|
1447 |
iAutoInstaller->SetLogBus( iLogBus );
|
|
1448 |
}
|
|
1449 |
#endif
|
|
1450 |
}
|
|
1451 |
|
|
1452 |
iAutoInstallerState = aState;
|
|
1453 |
|
|
1454 |
switch( aState )
|
|
1455 |
{
|
|
1456 |
case EAutoInstallerStateInstall:
|
|
1457 |
{
|
|
1458 |
if( iCurrentManifestFile < iManifestFiles.Count() )
|
|
1459 |
{
|
|
1460 |
TInt ret = KErrNone;
|
|
1461 |
|
|
1462 |
TRAPD( err, ret = iAutoInstaller->InstallThemeL( *iManifestFiles[ iCurrentManifestFile ] ) );
|
|
1463 |
if( err == KErrNone && ret == KErrNone )
|
|
1464 |
{
|
|
1465 |
started = ETrue;
|
|
1466 |
}
|
|
1467 |
}
|
|
1468 |
}
|
|
1469 |
break;
|
|
1470 |
case EAutoInstallerUninstall:
|
|
1471 |
{
|
|
1472 |
if( iThemeIndexToRemove != KErrNotFound && iThemeIndexToRemove < iInstalledSisxThemes.Count() )
|
|
1473 |
{
|
|
1474 |
TRAPD( err, iAutoInstaller->UnInstallThemeL( *iInstalledSisxThemes[ iThemeIndexToRemove ] ) )
|
|
1475 |
|
|
1476 |
if( !err )
|
|
1477 |
{
|
|
1478 |
started = ETrue;
|
|
1479 |
}
|
|
1480 |
else
|
|
1481 |
{
|
|
1482 |
delete iInstalledSisxThemes[ iThemeIndexToRemove ];
|
|
1483 |
iInstalledSisxThemes[ iThemeIndexToRemove ] = NULL;
|
|
1484 |
iInstalledSisxThemes.Remove( iThemeIndexToRemove );
|
|
1485 |
}
|
|
1486 |
}
|
|
1487 |
}
|
|
1488 |
break;
|
|
1489 |
default:
|
|
1490 |
{
|
|
1491 |
iAutoInstallerState = EAutoInstallerStateIdle;
|
|
1492 |
}
|
|
1493 |
break;
|
|
1494 |
}
|
|
1495 |
|
|
1496 |
if( !started )
|
|
1497 |
{
|
|
1498 |
StopAutoInstaller();
|
|
1499 |
}
|
|
1500 |
|
|
1501 |
return started;
|
|
1502 |
#else
|
|
1503 |
return EFalse;
|
|
1504 |
#endif // __DISABLE_SISX_INSTALLATION_
|
|
1505 |
}
|
|
1506 |
|
|
1507 |
// -----------------------------------------------------------------------------
|
|
1508 |
// ChspsThemeServer::StopAutoInstaller
|
|
1509 |
// (other items were commented in a header).
|
|
1510 |
// -----------------------------------------------------------------------------
|
|
1511 |
//
|
|
1512 |
void ChspsThemeServer::StopAutoInstaller()
|
|
1513 |
{
|
|
1514 |
#ifndef __DISABLE_SISX_INSTALLATION_
|
|
1515 |
switch( iAutoInstallerState )
|
|
1516 |
{
|
|
1517 |
case EAutoInstallerStateInstall:
|
|
1518 |
{
|
|
1519 |
iCurrentManifestFile = 0;
|
|
1520 |
iInstallableSisxThemes.Reset();
|
|
1521 |
iManifestFiles.ResetAndDestroy();
|
|
1522 |
}
|
|
1523 |
break;
|
|
1524 |
case EAutoInstallerUninstall:
|
|
1525 |
{
|
|
1526 |
iThemeIndexToRemove = KErrNotFound;
|
|
1527 |
}
|
|
1528 |
break;
|
|
1529 |
default:
|
|
1530 |
break;
|
|
1531 |
}
|
|
1532 |
|
|
1533 |
iAutoInstallerState = EAutoInstallerStateIdle;
|
|
1534 |
|
|
1535 |
delete iAutoInstaller;
|
|
1536 |
iAutoInstaller = NULL;
|
|
1537 |
#endif // __DISABLE_SISX_INSTALLATION_
|
|
1538 |
}
|
|
1539 |
|
|
1540 |
// -----------------------------------------------------------------------------
|
|
1541 |
// ChspsThemeServer::CheckInstalledPluginUsageL
|
|
1542 |
// -----------------------------------------------------------------------------
|
|
1543 |
//
|
|
1544 |
TInt ChspsThemeServer::CheckInstalledPluginUsageL( const TInt aPluginUid )
|
|
1545 |
{
|
|
1546 |
TInt sum = 0;
|
|
1547 |
if ( iHeaderListCache )
|
|
1548 |
{
|
|
1549 |
TInt count = iHeaderListCache->Count();
|
|
1550 |
if ( iDefinitionRepository->Locked() )
|
|
1551 |
{
|
|
1552 |
User::Leave( KErrInUse );
|
|
1553 |
}
|
|
1554 |
iDefinitionRepository->Lock();
|
|
1555 |
for ( TInt i = 0; i < count; i++ )
|
|
1556 |
{
|
|
1557 |
ChspsODT* header = ( *iHeaderListCache )[ i ];
|
|
1558 |
if ( header->ConfigurationType() == EhspsAppConfiguration )
|
|
1559 |
{
|
|
1560 |
|
|
1561 |
ChspsODT* odt = ChspsODT::NewL();
|
|
1562 |
CleanupStack::PushL( odt );
|
|
1563 |
odt->SetRootUid( header->RootUid() );
|
|
1564 |
odt->SetThemeUid( header->ThemeUid() );
|
|
1565 |
odt->SetConfigurationType( header->ConfigurationType() );
|
|
1566 |
odt->SetRootUid( header->RootUid() );
|
|
1567 |
odt->SetProviderUid( header->ProviderUid() );
|
|
1568 |
odt->SetThemeUid( header->ThemeUid() );
|
|
1569 |
odt->SetProviderNameL( header->ProviderName() );
|
|
1570 |
odt->SetThemeFullNameL( header->ThemeFullName() );
|
|
1571 |
odt->SetThemeShortNameL( header->ThemeShortName() );
|
|
1572 |
odt->SetThemeVersionL( header->ThemeVersion() );
|
|
1573 |
odt->SetDescriptionL( header->Description() );
|
|
1574 |
odt->SetFlags( header->Flags() );
|
|
1575 |
odt->SetMultiInstance( header->MultiInstance() );
|
|
1576 |
User::LeaveIfError( iDefinitionRepository->GetOdtL( *odt ) );
|
|
1577 |
TInt count = 0;
|
|
1578 |
hspsServerUtil::PluginInstanceCountL( *odt, aPluginUid, count );
|
|
1579 |
sum = sum + count;
|
|
1580 |
CleanupStack::PopAndDestroy( odt );
|
|
1581 |
}
|
|
1582 |
}
|
|
1583 |
iDefinitionRepository->Unlock();
|
|
1584 |
|
|
1585 |
}
|
|
1586 |
return sum;
|
|
1587 |
}
|
|
1588 |
|
|
1589 |
// -----------------------------------------------------------------------------
|
|
1590 |
// ChspsThemeServer::PluginInHeaderCache
|
|
1591 |
// -----------------------------------------------------------------------------
|
|
1592 |
//
|
|
1593 |
TBool ChspsThemeServer::PluginInHeaderCache( const TUid aPluginUid )
|
|
1594 |
{
|
|
1595 |
TBool found = EFalse;
|
|
1596 |
|
|
1597 |
if ( iHeaderListCache )
|
|
1598 |
{
|
|
1599 |
const TInt count = iHeaderListCache->Count();
|
|
1600 |
for ( TInt i = 0; i < count; i++ )
|
|
1601 |
{
|
|
1602 |
ChspsODT* header = (*iHeaderListCache)[i];
|
|
1603 |
if( header->ThemeUid() == aPluginUid.iUid )
|
|
1604 |
{
|
|
1605 |
found = ETrue;
|
|
1606 |
break;
|
|
1607 |
}
|
|
1608 |
}
|
|
1609 |
}
|
|
1610 |
|
|
1611 |
return found;
|
|
1612 |
}
|
|
1613 |
|
|
1614 |
// -----------------------------------------------------------------------------
|
|
1615 |
// ChspsThemeServer::UpdateHeaderListCacheL
|
|
1616 |
// -----------------------------------------------------------------------------
|
|
1617 |
//
|
|
1618 |
void ChspsThemeServer::UpdateHeaderListCacheL()
|
|
1619 |
{
|
|
1620 |
if ( iHeaderListPending )
|
|
1621 |
{
|
|
1622 |
#ifdef HSPS_LOG_ACTIVE
|
|
1623 |
iLogBus->LogText( _L( "ChspsThemeServer::UpdateHeaderListCacheL(): already updating the cache" ) );
|
|
1624 |
#endif
|
|
1625 |
}
|
|
1626 |
else
|
|
1627 |
{
|
|
1628 |
iHeaderListPending = ETrue;
|
|
1629 |
|
|
1630 |
#ifdef _hsps_PERFORMANCE_TEST_
|
|
1631 |
TTime start_time;
|
|
1632 |
start_time = ChspsTimeMon::StartTiming(_L("timer started"));
|
|
1633 |
#endif
|
|
1634 |
|
|
1635 |
// Get headers from the Plug-in Repository
|
|
1636 |
CArrayPtrSeg<ChspsODT>* headerList = new (ELeave)CArrayPtrSeg<ChspsODT>(KHeaderListGranularity);
|
|
1637 |
CleanupStack::PushL( headerList );
|
|
1638 |
|
|
1639 |
// Reset search mask
|
|
1640 |
iCacheMask->SetRootUid( 0 );
|
|
1641 |
iCacheMask->SetProviderUid( 0 );
|
|
1642 |
iCacheMask->SetThemeUid( 0 );
|
|
1643 |
|
|
1644 |
TInt err = DoUpdateHeaderListCache( *headerList );
|
|
1645 |
User::LeaveIfError( err );
|
|
1646 |
|
|
1647 |
if ( headerList->Count() > 0 )
|
|
1648 |
{
|
|
1649 |
// Destroys all objects whose pointers form the elements of the array,
|
|
1650 |
// before resetting the array.
|
|
1651 |
iHeaderListCache->ResetAndDestroy();
|
|
1652 |
|
|
1653 |
TInt count = headerList->Count() - 1;
|
|
1654 |
for (TInt i = count; i >= 0; --i)
|
|
1655 |
{
|
|
1656 |
// Update the cache array (ownership is transferred)
|
|
1657 |
TRAP( err, iHeaderListCache->InsertL(0, headerList->At(i)) );
|
|
1658 |
|
|
1659 |
// If allocation failed
|
|
1660 |
if ( err )
|
|
1661 |
{
|
|
1662 |
break;
|
|
1663 |
}
|
|
1664 |
|
|
1665 |
// Complete the ownership transfer
|
|
1666 |
headerList->Delete(i);
|
|
1667 |
}
|
|
1668 |
}
|
|
1669 |
|
|
1670 |
// Destroys all objects whose pointers form the elements of the array,
|
|
1671 |
// before resetting the array.
|
|
1672 |
headerList->ResetAndDestroy();
|
|
1673 |
CleanupStack::PopAndDestroy( headerList );
|
|
1674 |
|
|
1675 |
// calculating service time
|
|
1676 |
#ifdef _hsps_PERFORMANCE_TEST_
|
|
1677 |
ChspsTimeMon::StopTiming( start_time, _L( "ChspsThemeServer::UpdateHeaderListCache(): - timer stopped" ) );
|
|
1678 |
#endif
|
|
1679 |
|
|
1680 |
iHeaderListPending = EFalse;
|
|
1681 |
}
|
|
1682 |
}
|
|
1683 |
|
|
1684 |
// -----------------------------------------------------------------------------
|
|
1685 |
// ChspsThemeServer::UpdateHeaderListCache
|
|
1686 |
// -----------------------------------------------------------------------------
|
|
1687 |
//
|
|
1688 |
TInt ChspsThemeServer::UpdateHeaderListCache(
|
|
1689 |
ThspsCacheOperations aOperation,
|
|
1690 |
const TInt aRootUid,
|
|
1691 |
const TInt aProviderUid,
|
|
1692 |
const TInt aConfigurationUid )
|
|
1693 |
{
|
|
1694 |
TInt err = KErrNone;
|
|
1695 |
|
|
1696 |
// Input validation
|
|
1697 |
if ( aRootUid < 1 || aProviderUid < 1 || aConfigurationUid < 1 )
|
|
1698 |
{
|
|
1699 |
err = KErrArgument;
|
|
1700 |
}
|
|
1701 |
|
|
1702 |
if ( !err )
|
|
1703 |
{
|
|
1704 |
if ( aOperation == EhspsCacheAddHeader )
|
|
1705 |
{
|
|
1706 |
// Add or replace a header in the header list cache
|
|
1707 |
TRAP(
|
|
1708 |
err,
|
|
1709 |
HeaderCacheAddL(
|
|
1710 |
aRootUid,
|
|
1711 |
aProviderUid,
|
|
1712 |
aConfigurationUid )
|
|
1713 |
);
|
|
1714 |
}
|
|
1715 |
else
|
|
1716 |
{
|
|
1717 |
// Remove a header from the header list cache
|
|
1718 |
err = HeaderCacheRemove(
|
|
1719 |
aRootUid,
|
|
1720 |
aProviderUid,
|
|
1721 |
aConfigurationUid
|
|
1722 |
);
|
|
1723 |
}
|
|
1724 |
}
|
|
1725 |
|
|
1726 |
if ( err )
|
|
1727 |
{
|
|
1728 |
#ifdef HSPS_LOG_ACTIVE
|
|
1729 |
iLogBus->LogText(
|
|
1730 |
_L( "ChspsThemeServer::UpdateHeaderListCache(): - Failed to update %d header in the cache!" ),
|
|
1731 |
aConfigurationUid
|
|
1732 |
);
|
|
1733 |
#endif
|
|
1734 |
}
|
|
1735 |
|
|
1736 |
return err;
|
|
1737 |
}
|
|
1738 |
|
|
1739 |
// -----------------------------------------------------------------------------
|
|
1740 |
// ChspsThemeServer::DoUpdateHeaderListCache
|
|
1741 |
// -----------------------------------------------------------------------------
|
|
1742 |
//
|
|
1743 |
TInt ChspsThemeServer::DoUpdateHeaderListCache(
|
|
1744 |
CArrayPtrSeg<ChspsODT>& aHeaderList )
|
|
1745 |
{
|
|
1746 |
// Get headers matching the search mask
|
|
1747 |
TRAPD( err, GetHeaderListL( aHeaderList, *iCacheMask ) );
|
|
1748 |
if ( err )
|
|
1749 |
{
|
|
1750 |
#ifdef HSPS_LOG_ACTIVE
|
|
1751 |
iLogBus->LogText(
|
|
1752 |
_L( "ChspsThemeServer::DoUpdateHeaderListCache(): - failed %d"),
|
|
1753 |
err
|
|
1754 |
);
|
|
1755 |
#endif
|
|
1756 |
}
|
|
1757 |
|
|
1758 |
return err;
|
|
1759 |
}
|
|
1760 |
|
|
1761 |
// -----------------------------------------------------------------------------
|
|
1762 |
// ChspsThemeServer::HeaderCacheAddL
|
|
1763 |
// -----------------------------------------------------------------------------
|
|
1764 |
//
|
|
1765 |
void ChspsThemeServer::HeaderCacheAddL(
|
|
1766 |
const TInt aRootUid,
|
|
1767 |
const TInt aProviderUid,
|
|
1768 |
const TInt aConfigurationUid )
|
|
1769 |
{
|
|
1770 |
// Setup a search mask
|
|
1771 |
iCacheMask->SetRootUid( aRootUid );
|
|
1772 |
iCacheMask->SetProviderUid( aProviderUid );
|
|
1773 |
iCacheMask->SetThemeUid( aConfigurationUid );
|
|
1774 |
|
|
1775 |
// Setup a list for headers matching the search mask
|
|
1776 |
CArrayPtrSeg<ChspsODT>* newHeadersList = new (ELeave)CArrayPtrSeg<ChspsODT>(KHeaderListGranularity);
|
|
1777 |
CleanupStack::PushL( newHeadersList );
|
|
1778 |
|
|
1779 |
// Find the headers
|
|
1780 |
User::LeaveIfError( DoUpdateHeaderListCache( *newHeadersList ) );
|
|
1781 |
|
|
1782 |
// There should be only one match
|
|
1783 |
if ( newHeadersList->Count() != 1 )
|
|
1784 |
{
|
|
1785 |
#ifdef HSPS_LOG_ACTIVE
|
|
1786 |
iLogBus->LogText(
|
|
1787 |
_L( "ChspsThemeServer::HeaderCacheAddL(): - same %S header was found several times!" ),
|
|
1788 |
&(newHeadersList->At(0)->ThemeShortName())
|
|
1789 |
);
|
|
1790 |
#endif
|
|
1791 |
User::Leave( KErrGeneral );
|
|
1792 |
}
|
|
1793 |
|
|
1794 |
// Set new default position
|
|
1795 |
TInt newIndex = 0;
|
|
1796 |
|
|
1797 |
// Check if old version of the header instance exists in the cache
|
|
1798 |
TBool replaced = EFalse;
|
|
1799 |
ChspsODT* header = NULL;
|
|
1800 |
for( TInt index=0; !replaced && index < iHeaderListCache->Count(); index++ )
|
|
1801 |
{
|
|
1802 |
header = iHeaderListCache->At( index );
|
|
1803 |
if ( header )
|
|
1804 |
{
|
|
1805 |
if ( header->RootUid() == aRootUid
|
|
1806 |
&& header->ProviderUid() == aProviderUid
|
|
1807 |
&& header->ThemeUid() == aConfigurationUid )
|
|
1808 |
{
|
|
1809 |
// Remove the old header instance
|
|
1810 |
iHeaderListCache->Delete( index );
|
|
1811 |
delete header;
|
|
1812 |
header = NULL;
|
|
1813 |
replaced = ETrue;
|
|
1814 |
newIndex = index;
|
|
1815 |
}
|
|
1816 |
}
|
|
1817 |
}
|
|
1818 |
|
|
1819 |
// Append the new version into the specified position (ownership is transferred)
|
|
1820 |
iHeaderListCache->InsertL(newIndex, newHeadersList->At(0) );
|
|
1821 |
|
|
1822 |
#ifdef HSPS_LOG_ACTIVE
|
|
1823 |
iLogBus->LogText( _L( "ChspsThemeServer::HeaderCacheAddL(): - header '%S' was added/updated to cache!" ), &(newHeadersList->At(0)->ThemeShortName()) );
|
|
1824 |
#endif
|
|
1825 |
|
|
1826 |
// Complete the ownership transfer
|
|
1827 |
newHeadersList->Delete(0);
|
|
1828 |
|
|
1829 |
// Cleanup
|
|
1830 |
newHeadersList->ResetAndDestroy();
|
|
1831 |
CleanupStack::PopAndDestroy( newHeadersList );
|
|
1832 |
}
|
|
1833 |
|
|
1834 |
// -----------------------------------------------------------------------------
|
|
1835 |
// ChspsThemeServer::HeaderCacheRemove
|
|
1836 |
// -----------------------------------------------------------------------------
|
|
1837 |
//
|
|
1838 |
TInt ChspsThemeServer::HeaderCacheRemove(
|
|
1839 |
const TInt aRootUid,
|
|
1840 |
const TInt aProviderUid,
|
|
1841 |
const TInt aConfigurationUid )
|
|
1842 |
{
|
|
1843 |
TInt err = KErrNone;
|
|
1844 |
|
|
1845 |
// Find the header to be removed from the cache
|
|
1846 |
ChspsODT* header = NULL;
|
|
1847 |
for( TInt index=0; index < iHeaderListCache->Count(); index++ )
|
|
1848 |
{
|
|
1849 |
header = iHeaderListCache->At( index );
|
|
1850 |
if ( header )
|
|
1851 |
{
|
|
1852 |
if ( header->RootUid() == aRootUid
|
|
1853 |
&& header->ProviderUid() == aProviderUid
|
|
1854 |
&& header->ThemeUid() == aConfigurationUid )
|
|
1855 |
{
|
|
1856 |
#ifdef HSPS_LOG_ACTIVE
|
|
1857 |
iLogBus->LogText( _L( "ChspsThemeServer::HeaderCacheRemove(): - header '%S' was removed from cache!" ), &(header->ThemeShortName()) );
|
|
1858 |
#endif
|
|
1859 |
iHeaderListCache->Delete( index );
|
|
1860 |
delete header;
|
|
1861 |
header = NULL;
|
|
1862 |
break;
|
|
1863 |
}
|
|
1864 |
}
|
|
1865 |
}
|
|
1866 |
|
|
1867 |
return err;
|
|
1868 |
}
|
|
1869 |
|
|
1870 |
// -----------------------------------------------------------------------------
|
|
1871 |
// ChspsThemeServer::CompareL
|
|
1872 |
// (other items were commented in a header).
|
|
1873 |
// -----------------------------------------------------------------------------
|
|
1874 |
//
|
|
1875 |
TBool ChspsThemeServer::ComparePaths(const ChspsODT& aOldHeader, const ChspsODT& aNewHeader)
|
|
1876 |
{
|
|
1877 |
TBool ret;
|
|
1878 |
if (
|
|
1879 |
(
|
|
1880 |
aOldHeader.RootUid() == aNewHeader.RootUid()
|
|
1881 |
)
|
|
1882 |
&&
|
|
1883 |
(
|
|
1884 |
aOldHeader.ProviderUid() == aNewHeader.ProviderUid()
|
|
1885 |
)
|
|
1886 |
&&
|
|
1887 |
(
|
|
1888 |
aOldHeader.ThemeUid() == aNewHeader.ThemeUid()
|
|
1889 |
)
|
|
1890 |
&&
|
|
1891 |
(
|
|
1892 |
!aOldHeader.ThemeVersion().Compare( aNewHeader.ThemeVersion())
|
|
1893 |
)
|
|
1894 |
)
|
|
1895 |
{
|
|
1896 |
ret = ETrue;
|
|
1897 |
}
|
|
1898 |
else
|
|
1899 |
{
|
|
1900 |
ret = EFalse;
|
|
1901 |
}
|
|
1902 |
return ret;
|
|
1903 |
}
|
|
1904 |
|
|
1905 |
// -----------------------------------------------------------------------------
|
|
1906 |
// ChspsThemeServer::GetDeviceLanguage()
|
|
1907 |
// (other items were commented in a header).
|
|
1908 |
// -----------------------------------------------------------------------------
|
|
1909 |
//
|
|
1910 |
TLanguage ChspsThemeServer::GetDeviceLanguage()
|
|
1911 |
{
|
|
1912 |
return User::Language();
|
|
1913 |
}
|
|
1914 |
|
|
1915 |
// -----------------------------------------------------------------------------
|
|
1916 |
// ChspsThemeServer::GetHeaderListL
|
|
1917 |
// (other items were commented in a header).
|
|
1918 |
// -----------------------------------------------------------------------------
|
|
1919 |
//
|
|
1920 |
void ChspsThemeServer::GetHeaderListL(CArrayPtrSeg<ChspsODT>& aHeaderList, const ChspsODT& aSearchMask )
|
|
1921 |
{
|
|
1922 |
CArrayPtrSeg<ChspsODT>* licenceeDefaultList = new (ELeave)CArrayPtrSeg<ChspsODT>( KHeaderListGranularity );
|
|
1923 |
CleanupStack::PushL( TCleanupItem( ResetAndDestroyChspsODTArray, licenceeDefaultList ) );
|
|
1924 |
|
|
1925 |
CArrayPtrSeg<HBufC8>* headerDataList = new (ELeave)CArrayPtrSeg<HBufC8>( KHeaderListGranularity );
|
|
1926 |
CleanupStack::PushL( TCleanupItem( ResetAndDestroyHBufC8Array, headerDataList ) );
|
|
1927 |
iDefinitionRepository->GetThemeListAsStreamL( *headerDataList, aSearchMask );
|
|
1928 |
|
|
1929 |
// Convert data streams into header instances and populate the lincencee and header lists
|
|
1930 |
for ( TInt i=0; i < headerDataList->Count(); i++ )
|
|
1931 |
{
|
|
1932 |
HBufC8* headerData = headerDataList->At(i);
|
|
1933 |
if ( headerData )
|
|
1934 |
{
|
|
1935 |
ChspsODT* header = ChspsODT::UnMarshalHeaderLC( *headerData );
|
|
1936 |
if ( header->Flags() & EhspsThemeStatusLicenceeDefault )
|
|
1937 |
{
|
|
1938 |
licenceeDefaultList->AppendL( header );
|
|
1939 |
}
|
|
1940 |
else
|
|
1941 |
{
|
|
1942 |
// Get header's file path
|
|
1943 |
HBufC* fileBuf = HBufC::NewLC ( KMaxFileName );
|
|
1944 |
TPtr filePtr = fileBuf->Des();
|
|
1945 |
iDefinitionRepository->GetResourcePathL( *header, EResourceODT, filePtr );
|
|
1946 |
aHeaderList.AppendL( header );
|
|
1947 |
CleanupStack::PopAndDestroy( fileBuf );
|
|
1948 |
}
|
|
1949 |
CleanupStack::Pop( header );
|
|
1950 |
}
|
|
1951 |
}
|
|
1952 |
|
|
1953 |
// Cleanup the data streams
|
|
1954 |
CleanupStack::PopAndDestroy( headerDataList );
|
|
1955 |
|
|
1956 |
|
|
1957 |
// remove duplicate headers from the licencee list
|
|
1958 |
if( aHeaderList.Count() )
|
|
1959 |
{
|
|
1960 |
// go through the theme list again and put back the themes without update
|
|
1961 |
const TInt headersCount = aHeaderList.Count();
|
|
1962 |
for( TInt i = 0; i < licenceeDefaultList->Count(); i++ )
|
|
1963 |
{
|
|
1964 |
ChspsODT* licenceeHeader = licenceeDefaultList->At( i );
|
|
1965 |
|
|
1966 |
TBool found( EFalse );
|
|
1967 |
for( TInt j = 0; !found && j < headersCount; j++ )
|
|
1968 |
{
|
|
1969 |
ChspsODT* header = aHeaderList.At( j );
|
|
1970 |
|
|
1971 |
// compare two themes to find out are they they the same
|
|
1972 |
if( ComparePaths( *header, *licenceeHeader ) )
|
|
1973 |
{
|
|
1974 |
// there was an update, this theme does not need licencee default
|
|
1975 |
licenceeDefaultList->Delete( i );
|
|
1976 |
delete licenceeHeader;
|
|
1977 |
// next i
|
|
1978 |
i--;
|
|
1979 |
found = ETrue;
|
|
1980 |
}
|
|
1981 |
}
|
|
1982 |
}
|
|
1983 |
}
|
|
1984 |
|
|
1985 |
// append headers from the licencee list into the headers list
|
|
1986 |
for ( TInt i = 0; i < licenceeDefaultList->Count(); i++)
|
|
1987 |
{
|
|
1988 |
ChspsODT* licenceeHeader = licenceeDefaultList->At(i);
|
|
1989 |
|
|
1990 |
HBufC8* data = licenceeHeader->MarshalHeaderL();
|
|
1991 |
CleanupStack::PushL( data );
|
|
1992 |
|
|
1993 |
ChspsODT* odt = ChspsODT::UnMarshalHeaderLC( data->Des() );
|
|
1994 |
aHeaderList.AppendL( odt );
|
|
1995 |
CleanupStack::Pop( odt );
|
|
1996 |
|
|
1997 |
CleanupStack::PopAndDestroy( data );
|
|
1998 |
}
|
|
1999 |
|
|
2000 |
CleanupStack::PopAndDestroy( licenceeDefaultList );
|
|
2001 |
|
|
2002 |
// Modify headers flags
|
|
2003 |
for ( TInt i = 0; i < aHeaderList.Count(); i++ )
|
|
2004 |
{
|
|
2005 |
ChspsODT* header = aHeaderList.At(i);
|
|
2006 |
TInt appUid = header->RootUid();
|
|
2007 |
if ( header->ConfigurationType() == EhspsAppConfiguration )
|
|
2008 |
{
|
|
2009 |
// Check whether the application has an active configuration
|
|
2010 |
TInt confUid = 0;
|
|
2011 |
if ( iCentralRepository->Get( appUid, confUid ) == KErrNone && confUid > 0 )
|
|
2012 |
{
|
|
2013 |
// If active application configuration is the same as the header in question
|
|
2014 |
if ( header->ThemeUid() == confUid )
|
|
2015 |
{
|
|
2016 |
// Update header's flags
|
|
2017 |
TUint flags = header->Flags();
|
|
2018 |
header->SetFlags( flags | EhspsThemeStatusActive );
|
|
2019 |
}
|
|
2020 |
}
|
|
2021 |
}
|
|
2022 |
}
|
|
2023 |
|
|
2024 |
}
|
|
2025 |
|
|
2026 |
|
|
2027 |
// -----------------------------------------------------------------------------
|
|
2028 |
// ChspsThemeServer::CustomSecurityCheckL
|
|
2029 |
// (other items were commented in a header).
|
|
2030 |
// -----------------------------------------------------------------------------
|
|
2031 |
//
|
|
2032 |
CPolicyServer::TCustomResult ChspsThemeServer::CustomSecurityCheckL(const RMessage2& aMsg,
|
|
2033 |
TInt& /*aAction*/, TSecurityInfo& /*aMissing*/ )
|
|
2034 |
{
|
|
2035 |
CPolicyServer::TCustomResult ret;
|
|
2036 |
if ( iSecurityEnforcer->CheckAccessRightsL( aMsg ) )
|
|
2037 |
{
|
|
2038 |
ret = EPass;
|
|
2039 |
}
|
|
2040 |
else
|
|
2041 |
{
|
|
2042 |
ret = EFail;
|
|
2043 |
}
|
|
2044 |
return ret;
|
|
2045 |
}
|
|
2046 |
|
|
2047 |
// -----------------------------------------------------------------------------
|
|
2048 |
// ChspsThemeServerSession::HandleThemeUpgradeL
|
|
2049 |
// (other items were commented in a header).
|
|
2050 |
// -----------------------------------------------------------------------------
|
|
2051 |
//
|
|
2052 |
void ChspsThemeServer::HandleThemeUpgradeL()
|
|
2053 |
{
|
|
2054 |
CDir* upgradePathFileList( NULL );
|
|
2055 |
TFindFile upgradeFileFinder( iFsSession );
|
|
2056 |
|
|
2057 |
// If a upgrade_path_*.dat file appears in the import directory this means that a theme is being upgraded
|
|
2058 |
upgradeFileFinder.FindWildByDir( KUpgradePluginWild ,
|
|
2059 |
KImportDirectoryC, upgradePathFileList );
|
|
2060 |
if( !upgradePathFileList )
|
|
2061 |
{
|
|
2062 |
return;
|
|
2063 |
}
|
|
2064 |
// only one upgrade_path file can be present because it is deleted after upgrade
|
|
2065 |
if ( upgradePathFileList->Count() == 1 )
|
|
2066 |
{
|
|
2067 |
CleanupStack::PushL( upgradePathFileList );
|
|
2068 |
TPtrC upgradePathFile( ( *upgradePathFileList )[0].iName );
|
|
2069 |
|
|
2070 |
//path_*.dat theme file
|
|
2071 |
HBufC* fileNamePathOnly = HBufC::NewLC( KMaxFileName );
|
|
2072 |
TPtr fileNamePathOnlyPtr( fileNamePathOnly->Des() );
|
|
2073 |
TParsePtrC parsePtrTemp( upgradePathFile.Right(
|
|
2074 |
upgradePathFile.Length() - KUpgrade().Length() - 1 ) );
|
|
2075 |
fileNamePathOnlyPtr.Append( parsePtrTemp.FullName() );
|
|
2076 |
|
|
2077 |
TBool isInstalled = EFalse;
|
|
2078 |
//check if theme is installed
|
|
2079 |
for (TInt i = 0; i < iInstalledSisxThemes.Count(); i++)
|
|
2080 |
{
|
|
2081 |
if ( *iInstalledSisxThemes[i] == *fileNamePathOnly )
|
|
2082 |
{
|
|
2083 |
isInstalled = ETrue;
|
|
2084 |
break;
|
|
2085 |
}
|
|
2086 |
}
|
|
2087 |
|
|
2088 |
if ( !isInstalled )
|
|
2089 |
{
|
|
2090 |
// base theme package is not an installed theme
|
|
2091 |
#ifdef HSPS_LOG_ACTIVE
|
|
2092 |
iLogBus->LogText( _L( "hspsThemeServer: ChspsThemeServer::HandleThemeUpgradeL(): Base theme package not installed" ) );
|
|
2093 |
#endif
|
|
2094 |
}
|
|
2095 |
else
|
|
2096 |
{
|
|
2097 |
//upgrade_path_*.dat file path portion
|
|
2098 |
TParsePtrC parsePtr( upgradePathFile.Right(
|
|
2099 |
upgradePathFile.Length() - KUpgradePlugin().Length() - 1 ) );
|
|
2100 |
TPtrC fileNameUpgradePath( parsePtr.Name() );
|
|
2101 |
|
|
2102 |
//path to manifest
|
|
2103 |
HBufC* manifestFile = HBufC::NewLC( KMaxFileName );
|
|
2104 |
TPtr manifestFilePtr( manifestFile->Des() );
|
|
2105 |
manifestFilePtr.Append( KImportDirectoryC );
|
|
2106 |
manifestFilePtr.Append( fileNameUpgradePath );
|
|
2107 |
|
|
2108 |
TInt pos( manifestFilePtr.Locate( TChar( '_' ) ) );
|
|
2109 |
while( pos != KErrNotFound )
|
|
2110 |
{
|
|
2111 |
manifestFilePtr.Replace( pos, 1, KDoubleBackSlash );
|
|
2112 |
pos = manifestFilePtr.Locate( TChar( '_' ) );
|
|
2113 |
}
|
|
2114 |
|
|
2115 |
manifestFilePtr.Append( KDoubleBackSlash );
|
|
2116 |
manifestFilePtr.Append( KManifestFile );
|
|
2117 |
|
|
2118 |
//store manifest file for autoinstaller
|
|
2119 |
iManifestFiles.AppendL( manifestFile );
|
|
2120 |
|
|
2121 |
//Store current path_*.dat file
|
|
2122 |
iInstallableSisxThemes.AppendL( ( *fileNamePathOnly ).AllocL() );
|
|
2123 |
iCurrentManifestFile = 0;
|
|
2124 |
|
|
2125 |
if( !RunAutoInstaller( EAutoInstallerStateInstall ) )
|
|
2126 |
{
|
|
2127 |
// All installation files are not present
|
|
2128 |
// here should be some kind of error handling
|
|
2129 |
}
|
|
2130 |
|
|
2131 |
CleanupStack::Pop( manifestFile ); //manifestFile
|
|
2132 |
}
|
|
2133 |
|
|
2134 |
HBufC * upgradePathFileToDelete = HBufC::NewLC( KMaxFileName );
|
|
2135 |
TPtr upgradePathFileToDeletePtr( upgradePathFileToDelete->Des() );
|
|
2136 |
upgradePathFileToDeletePtr.Append( KImportDirectoryC );
|
|
2137 |
upgradePathFileToDeletePtr.Append( upgradePathFile );
|
|
2138 |
|
|
2139 |
//delete the upgrade_path_*.dat auxiliary file
|
|
2140 |
TInt err = iFsSession.Delete( *upgradePathFileToDelete );
|
|
2141 |
if ( err != KErrNone )
|
|
2142 |
{
|
|
2143 |
#ifdef HSPS_LOG_ACTIVE
|
|
2144 |
//file not deleted error handling
|
|
2145 |
iLogBus->LogText( _L( "hspsThemeServer: ChspsThemeServer::HandleThemeUpgradeL(): %d ,upgrade_path_*.dat file not deleted" ), err );
|
|
2146 |
#endif
|
|
2147 |
}
|
|
2148 |
|
|
2149 |
CleanupStack::PopAndDestroy( upgradePathFileToDelete );
|
|
2150 |
CleanupStack::PopAndDestroy( fileNamePathOnly );
|
|
2151 |
CleanupStack::PopAndDestroy( upgradePathFileList );
|
|
2152 |
}
|
|
2153 |
else
|
|
2154 |
{
|
|
2155 |
#ifdef HSPS_LOG_ACTIVE
|
|
2156 |
//more than one upgrade_path is present. in import directory error handling
|
|
2157 |
iLogBus->LogText( _L( "hspsThemeServer: ChspsThemeServer::HandleThemeUpgradeL(): more than one upgrade_path_*.dat file" ) );
|
|
2158 |
#endif
|
|
2159 |
}
|
|
2160 |
}
|
|
2161 |
|
|
2162 |
// -----------------------------------------------------------------------------
|
|
2163 |
// Checks whether the device language has been changed and updates
|
|
2164 |
// configurations accordingly
|
|
2165 |
// -----------------------------------------------------------------------------
|
|
2166 |
//
|
|
2167 |
void ChspsThemeServer::HandleLanguageChangeL()
|
|
2168 |
{
|
|
2169 |
#ifdef HSPS_LOG_ACTIVE
|
|
2170 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL()") );
|
|
2171 |
#endif
|
|
2172 |
|
|
2173 |
// The key should already exist
|
|
2174 |
const TUint32 fullMask = 0xFFFFFFFF;
|
|
2175 |
RArray<TUint32> res;
|
|
2176 |
CleanupClosePushL( res );
|
|
2177 |
|
|
2178 |
iCentralRepository->FindL( KCenrepKeyLang, fullMask, res );
|
|
2179 |
if ( res.Count() == 0 )
|
|
2180 |
{
|
|
2181 |
#ifdef HSPS_LOG_ACTIVE
|
|
2182 |
iLogBus->LogText(
|
|
2183 |
_L( "ChspsThemeServer::HandleLanguageChangeL(): - Couldn't find %d key from the HSPS cenrep!" ),
|
|
2184 |
KCenrepKeyLang );
|
|
2185 |
#endif
|
|
2186 |
|
|
2187 |
User::Leave( KErrNotFound );
|
|
2188 |
}
|
|
2189 |
|
|
2190 |
// Check the cenrep key's value
|
|
2191 |
TInt prevLanguage = ELangNone;
|
|
2192 |
iCentralRepository->Get( KCenrepKeyLang, prevLanguage );
|
|
2193 |
|
|
2194 |
// If the language has been changed
|
|
2195 |
if( iDeviceLanguage != prevLanguage )
|
|
2196 |
{
|
|
2197 |
// Update all the ODTs so that the localized configurations can be fetched
|
|
2198 |
LocalizeConfigurationsL();
|
|
2199 |
|
|
2200 |
UpdateHeaderListCacheL();
|
|
2201 |
|
|
2202 |
// Finally, update the cenrep with the new language
|
|
2203 |
TInt errorCode = iCentralRepository->Set( KCenrepKeyLang, iDeviceLanguage );
|
|
2204 |
if ( errorCode )
|
|
2205 |
{
|
|
2206 |
#ifdef HSPS_LOG_ACTIVE
|
|
2207 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL(): - Failed to update the cenrep!" ) );
|
|
2208 |
#endif
|
|
2209 |
|
|
2210 |
User::Leave( KErrWrite );
|
|
2211 |
}
|
|
2212 |
else
|
|
2213 |
{
|
|
2214 |
#ifdef HSPS_LOG_ACTIVE
|
|
2215 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleLanguageChangeL(): - themes were localized successfully" ) );
|
|
2216 |
#endif
|
|
2217 |
}
|
|
2218 |
}
|
|
2219 |
|
|
2220 |
res.Close();
|
|
2221 |
CleanupStack::PopAndDestroy(1, &res);
|
|
2222 |
}
|
|
2223 |
|
|
2224 |
|
|
2225 |
// -----------------------------------------------------------------------------
|
|
2226 |
// ChspsThemeServer::SetHeadersLanguages()
|
|
2227 |
// -----------------------------------------------------------------------------
|
|
2228 |
//
|
|
2229 |
void ChspsThemeServer::LocalizeConfigurationsL()
|
|
2230 |
{
|
|
2231 |
#ifdef HSPS_LOG_ACTIVE
|
|
2232 |
iLogBus->LogText( _L( "ChspsThemeServer::LocalizeConfigurationsL()" ) );
|
|
2233 |
#endif
|
|
2234 |
|
|
2235 |
// Check header count
|
|
2236 |
TInt headerCount = HeaderListCache().Count();
|
|
2237 |
if( headerCount )
|
|
2238 |
{
|
|
2239 |
_LIT8(KhspsDefinitionEngine, "hspsdefinitionengine");
|
|
2240 |
ChspsDefinitionEngineInterface* defEngine = ChspsDefinitionEngineInterface::NewL(KhspsDefinitionEngine);
|
|
2241 |
CleanupStack::PushL( defEngine );
|
|
2242 |
|
|
2243 |
// Loop found headers
|
|
2244 |
ChspsODT* header = NULL;
|
|
2245 |
const TInt KInterfaceUid = 0;
|
|
2246 |
for( TInt headerIndex=0; headerIndex < headerCount; headerIndex++ )
|
|
2247 |
{
|
|
2248 |
// Get pointer to the header (contains minimal information from an ODT)
|
|
2249 |
header = iHeaderListCache->At( headerIndex );
|
|
2250 |
|
|
2251 |
// Get the ODT based on header UIDs
|
|
2252 |
ChspsODT* odt = ChspsODT::NewL();
|
|
2253 |
CleanupStack::PushL( odt );
|
|
2254 |
GetConfigurationL(
|
|
2255 |
KInterfaceUid,
|
|
2256 |
header->ThemeUid(),
|
|
2257 |
*odt );
|
|
2258 |
if ( !odt || !odt->ThemeUid() )
|
|
2259 |
{
|
|
2260 |
#ifdef HSPS_LOG_ACTIVE
|
|
2261 |
iLogBus->LogText( _L( "ChspsThemeServer::LocalizeConfigurationsL(): - Failed to retrieve header with an configuration uid %d" ),
|
|
2262 |
header->ThemeUid() );
|
|
2263 |
#endif
|
|
2264 |
|
|
2265 |
User::Leave( KErrNotFound );
|
|
2266 |
}
|
|
2267 |
|
|
2268 |
// Try to localize the ODT according to the new device language
|
|
2269 |
TBool localized = LocalizeL(
|
|
2270 |
*defEngine,
|
|
2271 |
*odt );
|
|
2272 |
if ( localized )
|
|
2273 |
{
|
|
2274 |
// Set header's name from the ODT
|
|
2275 |
header->SetThemeFullNameL( odt->ThemeFullName() );
|
|
2276 |
header->SetDescriptionL( odt->Description() );
|
|
2277 |
}
|
|
2278 |
|
|
2279 |
CleanupStack::PopAndDestroy( odt );
|
|
2280 |
} // for loop
|
|
2281 |
|
|
2282 |
CleanupStack::PopAndDestroy( defEngine );
|
|
2283 |
|
|
2284 |
} // count
|
|
2285 |
}
|
|
2286 |
|
|
2287 |
// -----------------------------------------------------------------------------
|
|
2288 |
// ChspsThemeServer::ResetResourcesL()
|
|
2289 |
// -----------------------------------------------------------------------------
|
|
2290 |
//
|
|
2291 |
void ChspsThemeServer::ResetResourcesL(
|
|
2292 |
ChspsODT& aAppODT )
|
|
2293 |
{
|
|
2294 |
// If active configuration
|
|
2295 |
TInt confUid = -1;
|
|
2296 |
iCentralRepository->Get( aAppODT.RootUid(), confUid );
|
|
2297 |
if( confUid == aAppODT.ThemeUid() )
|
|
2298 |
{
|
|
2299 |
if( !iFileMan )
|
|
2300 |
{
|
|
2301 |
iFileMan= CFileMan::NewL( iFsSession );
|
|
2302 |
}
|
|
2303 |
|
|
2304 |
// Find unique plug-in UIDs from the app configuration
|
|
2305 |
RArray<TInt> uidArray;
|
|
2306 |
CleanupClosePushL( uidArray );
|
|
2307 |
hspsServerUtil::FindUniquePluginsL( aAppODT, uidArray );
|
|
2308 |
|
|
2309 |
// Remove old copies from the client path, localized copies will be
|
|
2310 |
// restored when the app configuration is fetched again
|
|
2311 |
for( TInt i=0; i < uidArray.Count(); i++ )
|
|
2312 |
{
|
|
2313 |
ChspsODT* pluginODT = ChspsODT::NewL();
|
|
2314 |
CleanupStack::PushL( pluginODT );
|
|
2315 |
|
|
2316 |
GetConfigurationL(
|
|
2317 |
0,
|
|
2318 |
uidArray[i],
|
|
2319 |
*pluginODT );
|
|
2320 |
|
|
2321 |
if( pluginODT->ThemeUid() )
|
|
2322 |
{
|
|
2323 |
hspsServerUtil::RemoveResourceFilesL(
|
|
2324 |
*iFileMan,
|
|
2325 |
iFsSession,
|
|
2326 |
aAppODT.RootUid(),
|
|
2327 |
*pluginODT );
|
|
2328 |
}
|
|
2329 |
|
|
2330 |
CleanupStack::PopAndDestroy();
|
|
2331 |
}
|
|
2332 |
|
|
2333 |
uidArray.Reset();
|
|
2334 |
CleanupStack::PopAndDestroy( &uidArray );
|
|
2335 |
}
|
|
2336 |
}
|
|
2337 |
|
|
2338 |
// -----------------------------------------------------------------------------
|
|
2339 |
// ChspsThemeServer::LocalizeL()
|
|
2340 |
// -----------------------------------------------------------------------------
|
|
2341 |
//
|
|
2342 |
TBool ChspsThemeServer::LocalizeL(
|
|
2343 |
ChspsDefinitionEngineInterface& aEngine,
|
|
2344 |
ChspsODT& aOdt )
|
|
2345 |
{
|
|
2346 |
TBool localized = ETrue;
|
|
2347 |
iFsSession.SetSessionToPrivate( EDriveC );
|
|
2348 |
|
|
2349 |
TLanguage requestedLanguage = DeviceLanguage();
|
|
2350 |
if ( requestedLanguage == ELangNone )
|
|
2351 |
{
|
|
2352 |
requestedLanguage = ELangTest;
|
|
2353 |
}
|
|
2354 |
|
|
2355 |
if ( aOdt.OdtLanguage() != requestedLanguage )
|
|
2356 |
{
|
|
2357 |
localized = EFalse;
|
|
2358 |
TBool domChanged = EFalse;
|
|
2359 |
|
|
2360 |
// Localize XML configuration with the requested language
|
|
2361 |
if ( aOdt.ConfigurationType() == EhspsAppConfiguration )
|
|
2362 |
{
|
|
2363 |
// Apply plugin and application specific DTD files
|
|
2364 |
domChanged = LocalizeApplicationConfigurationL(
|
|
2365 |
aEngine,
|
|
2366 |
aOdt,
|
|
2367 |
requestedLanguage );
|
|
2368 |
|
|
2369 |
ResetResourcesL( aOdt );
|
|
2370 |
}
|
|
2371 |
else
|
|
2372 |
{
|
|
2373 |
// Apply plugin specific DTD files only
|
|
2374 |
domChanged = LocalizePluginConfigurationL(
|
|
2375 |
aEngine,
|
|
2376 |
aOdt,
|
|
2377 |
requestedLanguage,
|
|
2378 |
0 );
|
|
2379 |
}
|
|
2380 |
|
|
2381 |
if ( domChanged )
|
|
2382 |
{
|
|
2383 |
// Update ODT with the new localized name from the XML configuration
|
|
2384 |
TPtrC8 name( hspsServerUtil::FindConfigurationAttrL( aOdt, KConfigurationAttrName ) );
|
|
2385 |
if ( name.Length() )
|
|
2386 |
{
|
|
2387 |
HBufC* buf = HBufC::NewLC( name.Length() );
|
|
2388 |
buf->Des().Copy( name );
|
|
2389 |
aOdt.SetThemeFullNameL( buf->Des() );
|
|
2390 |
CleanupStack::PopAndDestroy( buf );
|
|
2391 |
|
|
2392 |
// The ODT instance has now been localized - either with the requested language or a test language
|
|
2393 |
aOdt.SetOdtLanguage( requestedLanguage );
|
|
2394 |
}
|
|
2395 |
|
|
2396 |
// Update ODT with the new localized description from the XML configuration
|
|
2397 |
TPtrC8 desc( hspsServerUtil::FindConfigurationAttrL( aOdt, KConfigurationAttrDesc ) );
|
|
2398 |
if ( desc.Length() )
|
|
2399 |
{
|
|
2400 |
HBufC* buf = HBufC::NewLC( desc.Length() );
|
|
2401 |
buf->Des().Copy( desc );
|
|
2402 |
aOdt.SetDescriptionL( buf->Des() );
|
|
2403 |
CleanupStack::PopAndDestroy( buf );
|
|
2404 |
}
|
|
2405 |
|
|
2406 |
// Save the changes
|
|
2407 |
iDefinitionRepository->SetOdtL( aOdt );
|
|
2408 |
localized = ETrue;
|
|
2409 |
}
|
|
2410 |
|
|
2411 |
if ( !localized )
|
|
2412 |
{
|
|
2413 |
#ifdef HSPS_LOG_ACTIVE
|
|
2414 |
iLogBus->LogText(
|
|
2415 |
_L( "ChspsThemeServer::LocalizeL(): - failed to localize header %S!" ),
|
|
2416 |
&aOdt.ThemeShortName()
|
|
2417 |
);
|
|
2418 |
#endif
|
|
2419 |
}
|
|
2420 |
|
|
2421 |
#ifdef HSPS_LOG_ACTIVE
|
|
2422 |
iLogBus->LogText( _L( "ChspsThemeServer::LocalizeL() - DOM dump after localization:" ) );
|
|
2423 |
// Print DOM debug
|
|
2424 |
ChspsOdtDump::Dump( aOdt, *iLogBus );
|
|
2425 |
#endif
|
|
2426 |
}
|
|
2427 |
|
|
2428 |
return localized;
|
|
2429 |
}
|
|
2430 |
|
|
2431 |
// -----------------------------------------------------------------------------
|
|
2432 |
// ChspsThemeServer::LocalizeApplicationConfigurationL()
|
|
2433 |
// -----------------------------------------------------------------------------
|
|
2434 |
//
|
|
2435 |
TBool ChspsThemeServer::LocalizeApplicationConfigurationL(
|
|
2436 |
ChspsDefinitionEngineInterface& aEngine,
|
|
2437 |
ChspsODT& aOdt,
|
|
2438 |
const TLanguage aRequestedLanguage )
|
|
2439 |
{
|
|
2440 |
#ifdef HSPS_LOG_ACTIVE
|
|
2441 |
iLogBus->LogText(
|
|
2442 |
_L( "ChspsThemeServer::LocalizeApplicationConfigurationL(): - Localizing %S application configuration..." ),
|
|
2443 |
&aOdt.ThemeShortName()
|
|
2444 |
);
|
|
2445 |
#endif
|
|
2446 |
|
|
2447 |
// Localize the application configuration itself
|
|
2448 |
TInt resourceFilter = aOdt.ThemeUid();
|
|
2449 |
TBool domLocalized = LocalizePluginConfigurationL(
|
|
2450 |
aEngine,
|
|
2451 |
aOdt,
|
|
2452 |
aRequestedLanguage,
|
|
2453 |
resourceFilter );
|
|
2454 |
|
|
2455 |
// Next, localize all plugins instances in the DOM
|
|
2456 |
if ( domLocalized )
|
|
2457 |
{
|
|
2458 |
// Find all unique plugin uids that are used in the application configuration
|
|
2459 |
RArray<TInt> pluginArray;
|
|
2460 |
CleanupClosePushL( pluginArray );
|
|
2461 |
hspsServerUtil::FindUniquePluginsL( aOdt, pluginArray );
|
|
2462 |
|
|
2463 |
// Loop the plugins
|
|
2464 |
const TInt pluginsCount = pluginArray.Count();
|
|
2465 |
for( TInt pluginIndex=0; domLocalized && pluginIndex < pluginsCount; pluginIndex++ )
|
|
2466 |
{
|
|
2467 |
// Apply plugin specific DTD files only
|
|
2468 |
TBool pluginLocalized = LocalizePluginConfigurationL(
|
|
2469 |
aEngine,
|
|
2470 |
aOdt,
|
|
2471 |
aRequestedLanguage,
|
|
2472 |
pluginArray[pluginIndex] );
|
|
2473 |
}
|
|
2474 |
|
|
2475 |
pluginArray.Reset();
|
|
2476 |
CleanupStack::PopAndDestroy( &pluginArray );
|
|
2477 |
}
|
|
2478 |
|
|
2479 |
return domLocalized;
|
|
2480 |
}
|
|
2481 |
|
|
2482 |
// -----------------------------------------------------------------------------
|
|
2483 |
// ChspsThemeServer::LocalizePluginConfigurationL()
|
|
2484 |
// -----------------------------------------------------------------------------
|
|
2485 |
//
|
|
2486 |
TBool ChspsThemeServer::LocalizePluginConfigurationL(
|
|
2487 |
ChspsDefinitionEngineInterface& aEngine,
|
|
2488 |
ChspsODT& aOdt,
|
|
2489 |
const TLanguage aRequestedLanguage,
|
|
2490 |
TInt aPluginUid )
|
|
2491 |
{
|
|
2492 |
// If the plugin has already been localized as requested
|
|
2493 |
if ( aOdt.OdtLanguage() == aRequestedLanguage )
|
|
2494 |
{
|
|
2495 |
return ETrue;
|
|
2496 |
}
|
|
2497 |
|
|
2498 |
TBool domLocalized = EFalse;
|
|
2499 |
const TInt resourceCount = aOdt.ResourceCount();
|
|
2500 |
|
|
2501 |
// Localize XML document
|
|
2502 |
TFileName pluginFolder;
|
|
2503 |
for( TInt resourceIndex=0; !domLocalized && resourceIndex < resourceCount; resourceIndex++ )
|
|
2504 |
{
|
|
2505 |
ChspsResource& r = aOdt.ResourceL( resourceIndex );
|
|
2506 |
if ( r.ResourceType() == EResourceDTD )
|
|
2507 |
{
|
|
2508 |
TBool isPluginSpecific = ETrue;
|
|
2509 |
|
|
2510 |
// If plugin uid restriction was set (localizing an application configuration)
|
|
2511 |
if ( aPluginUid > 0 )
|
|
2512 |
{
|
|
2513 |
// Check whether the resource belongs to the plugin
|
|
2514 |
pluginFolder.Format( _L("\\%d\\"), aPluginUid );
|
|
2515 |
isPluginSpecific = ( r.FileName().Find(pluginFolder) > 0 );
|
|
2516 |
}
|
|
2517 |
if ( isPluginSpecific && r.Language() == aRequestedLanguage )
|
|
2518 |
{
|
|
2519 |
// Parses the given DTD file and replaces all entity referencies in the DOM tree
|
|
2520 |
aEngine.ApplyLanguageL(
|
|
2521 |
iFsSession,
|
|
2522 |
r.FileName(),
|
|
2523 |
aOdt );
|
|
2524 |
domLocalized = ETrue;
|
|
2525 |
#ifdef HSPS_LOG_ACTIVE
|
|
2526 |
if ( aPluginUid > 0 )
|
|
2527 |
{
|
|
2528 |
iLogBus->LogText(
|
|
2529 |
_L( "ChspsThemeServer::LocalizePluginConfigurationL(): - %S/%X instances localized to %d language!" ),
|
|
2530 |
&aOdt.ThemeShortName(),
|
|
2531 |
aPluginUid,
|
|
2532 |
aRequestedLanguage );
|
|
2533 |
}
|
|
2534 |
else
|
|
2535 |
{
|
|
2536 |
iLogBus->LogText(
|
|
2537 |
_L( "ChspsThemeServer::LocalizePluginConfigurationL(): - %S localized to %d language!" ),
|
|
2538 |
&aOdt.ThemeShortName(),
|
|
2539 |
aRequestedLanguage );
|
|
2540 |
}
|
|
2541 |
#endif
|
|
2542 |
}
|
|
2543 |
}
|
|
2544 |
}
|
|
2545 |
|
|
2546 |
// If the requested locale couldn't be found
|
|
2547 |
if ( !domLocalized )
|
|
2548 |
{
|
|
2549 |
// Localize XML document with the test locale (mandatory language, used by HSPS developers)
|
|
2550 |
for( TInt resourceIndex=0; !domLocalized && resourceIndex < resourceCount; resourceIndex++ )
|
|
2551 |
{
|
|
2552 |
ChspsResource& r = aOdt.ResourceL( resourceIndex );
|
|
2553 |
if ( r.ResourceType() == EResourceDTD )
|
|
2554 |
{
|
|
2555 |
TBool isPluginSpecific = ETrue;
|
|
2556 |
|
|
2557 |
// If plugin uid restriction was set (localizing an application configuration)
|
|
2558 |
if ( aPluginUid > 0 )
|
|
2559 |
{
|
|
2560 |
// Check whether the resource belongs to the plugin
|
|
2561 |
pluginFolder.Format( _L("\\%d\\"), aPluginUid );
|
|
2562 |
isPluginSpecific = ( r.FileName().Find(pluginFolder) > 0 );
|
|
2563 |
}
|
|
2564 |
if ( isPluginSpecific && r.Language() == ELangTest )
|
|
2565 |
{
|
|
2566 |
// Parses the given DTD file and replaces all entity referencies in the DOM tree
|
|
2567 |
aEngine.ApplyLanguageL(
|
|
2568 |
iFsSession,
|
|
2569 |
r.FileName(),
|
|
2570 |
aOdt );
|
|
2571 |
domLocalized = ETrue;
|
|
2572 |
#ifdef HSPS_LOG_ACTIVE
|
|
2573 |
if ( aPluginUid > 0 )
|
|
2574 |
{
|
|
2575 |
iLogBus->LogText(
|
|
2576 |
_L( "ChspsThemeServer::LocalizePluginConfigurationL(): - %S/%X instances localized to %d language!" ),
|
|
2577 |
&aOdt.ThemeShortName(),
|
|
2578 |
aPluginUid,
|
|
2579 |
ELangTest );
|
|
2580 |
}
|
|
2581 |
else
|
|
2582 |
{
|
|
2583 |
iLogBus->LogText(
|
|
2584 |
_L( "ChspsThemeServer::LocalizePluginConfigurationL(): - %S localized to %d language!" ),
|
|
2585 |
&aOdt.ThemeShortName(),
|
|
2586 |
ELangTest );
|
|
2587 |
}
|
|
2588 |
#endif
|
|
2589 |
}
|
|
2590 |
}
|
|
2591 |
}
|
|
2592 |
}
|
|
2593 |
|
|
2594 |
return domLocalized;
|
|
2595 |
}
|
|
2596 |
|
|
2597 |
// -----------------------------------------------------------------------------
|
|
2598 |
// ChspsThemeServer::GetConfigurationL()
|
|
2599 |
// -----------------------------------------------------------------------------
|
|
2600 |
//
|
|
2601 |
TInt ChspsThemeServer::GetConfigurationL(
|
|
2602 |
const TInt aInterfaceUid,
|
|
2603 |
const TInt aConfigurationUid,
|
|
2604 |
ChspsODT& aRetrievedODT )
|
|
2605 |
{
|
|
2606 |
// Input validation
|
|
2607 |
if ( aInterfaceUid < 0 || aConfigurationUid < 1)
|
|
2608 |
{
|
|
2609 |
#ifdef HSPS_LOG_ACTIVE
|
|
2610 |
iLogBus->LogText( _L( "ChspsThemeServer::GetConfigurationL(): - Invalid arguments" ) );
|
|
2611 |
#endif
|
|
2612 |
|
|
2613 |
return KErrArgument;
|
|
2614 |
}
|
|
2615 |
|
|
2616 |
TInt headerCount = HeaderListCache().Count();
|
|
2617 |
if ( headerCount < 1 )
|
|
2618 |
{
|
|
2619 |
UpdateHeaderListCacheL();
|
|
2620 |
headerCount = HeaderListCache().Count();
|
|
2621 |
if ( headerCount < 1 )
|
|
2622 |
{
|
|
2623 |
// configurations were not found or repository is locked
|
|
2624 |
#ifdef HSPS_LOG_ACTIVE
|
|
2625 |
iLogBus->LogText( _L( "ChspsThemeServer::GetConfigurationL(): - Cache is empty" ) );
|
|
2626 |
#endif
|
|
2627 |
return KErrAbort;
|
|
2628 |
}
|
|
2629 |
}
|
|
2630 |
|
|
2631 |
#ifdef HSPS_LOG_ACTIVE
|
|
2632 |
iLogBus->LogText( _L( "ChspsThemeServer::GetConfigurationL(): - header count in cache: %d" ), iHeaderListCache->Count() );
|
|
2633 |
#endif
|
|
2634 |
|
|
2635 |
// Loop headers in the cache
|
|
2636 |
TBool found = EFalse;
|
|
2637 |
ChspsODT* h = NULL;
|
|
2638 |
for ( TInt i=0; !found && i<iHeaderListCache->Count(); i++ )
|
|
2639 |
{
|
|
2640 |
h = iHeaderListCache->At(i);
|
|
2641 |
TBool rootUidMatched = ETrue;
|
|
2642 |
TBool themeUidMatched = ETrue;
|
|
2643 |
if ( aInterfaceUid )
|
|
2644 |
{
|
|
2645 |
rootUidMatched = ( h->RootUid() == aInterfaceUid );
|
|
2646 |
}
|
|
2647 |
themeUidMatched = ( h->ThemeUid() == aConfigurationUid );
|
|
2648 |
|
|
2649 |
found = ( rootUidMatched && themeUidMatched );
|
|
2650 |
//#ifdef HSPS_LOG_ACTIVE
|
|
2651 |
// iLogBus->LogText( _L( "ChspsThemeServer::GetConfigurationL(): - header '%S' matched: %d" ), &(h->ThemeShortName()), found );
|
|
2652 |
//#endif
|
|
2653 |
}
|
|
2654 |
if ( !found )
|
|
2655 |
{
|
|
2656 |
#ifdef HSPS_LOG_ACTIVE
|
|
2657 |
iLogBus->LogText( _L( "ChspsThemeServer::GetConfigurationL(): - theme %D was not found!" ), aConfigurationUid );
|
|
2658 |
#endif
|
|
2659 |
return KErrNotFound;
|
|
2660 |
}
|
|
2661 |
|
|
2662 |
// Copy properties which are needed by the definition repository to form up ODT paths
|
|
2663 |
aRetrievedODT.SetRootUid( h->RootUid() );
|
|
2664 |
aRetrievedODT.SetThemeUid( h->ThemeUid() );
|
|
2665 |
aRetrievedODT.SetConfigurationType(h->ConfigurationType());
|
|
2666 |
aRetrievedODT.SetRootUid(h->RootUid());
|
|
2667 |
aRetrievedODT.SetProviderUid(h->ProviderUid());
|
|
2668 |
aRetrievedODT.SetThemeUid(h->ThemeUid());
|
|
2669 |
aRetrievedODT.SetProviderNameL(h->ProviderName());
|
|
2670 |
aRetrievedODT.SetThemeFullNameL(h->ThemeFullName());
|
|
2671 |
aRetrievedODT.SetThemeShortNameL(h->ThemeShortName());
|
|
2672 |
aRetrievedODT.SetThemeVersionL(h->ThemeVersion());
|
|
2673 |
aRetrievedODT.SetFlags(h->Flags());
|
|
2674 |
aRetrievedODT.SetMultiInstance( h->MultiInstance() );
|
|
2675 |
|
|
2676 |
// Get a complete ODT instance from the definition repository
|
|
2677 |
if ( iDefinitionRepository->GetOdtL( aRetrievedODT ) )
|
|
2678 |
{
|
|
2679 |
#ifdef HSPS_LOG_ACTIVE
|
|
2680 |
iLogBus->LogText( _L( "ChspsThemeServer::GetConfigurationL(): - theme cannot be accessed." ) );
|
|
2681 |
#endif
|
|
2682 |
return KErrAccessDenied;
|
|
2683 |
}
|
|
2684 |
|
|
2685 |
return KErrNone;
|
|
2686 |
}
|
|
2687 |
|
|
2688 |
// -----------------------------------------------------------------------------
|
|
2689 |
// ChspsThemeServer::InstallUDAWidgetsL()
|
|
2690 |
// -----------------------------------------------------------------------------
|
|
2691 |
//
|
|
2692 |
void ChspsThemeServer::InstallUDAWidgetsL( const TDesC& aImportDirectory )
|
|
2693 |
{
|
|
2694 |
//Get list of uda dir's
|
|
2695 |
TPtrC filter( KFilterAllPluginImportsV1 );
|
|
2696 |
CDir* importDir( NULL );
|
|
2697 |
TFindFile fileFinder( iFsSession );
|
|
2698 |
fileFinder.FindWildByDir( filter, aImportDirectory, importDir );
|
|
2699 |
CleanupStack::PushL( importDir );
|
|
2700 |
|
|
2701 |
if ( importDir && importDir->Count() > 0 )
|
|
2702 |
{
|
|
2703 |
CHSPSInstaller* installer = CHSPSInstaller::NewL( *this );
|
|
2704 |
CleanupStack::PushL( installer );
|
|
2705 |
|
|
2706 |
for ( TInt i = 0; i < importDir->Count(); i++ )
|
|
2707 |
{
|
|
2708 |
TPtrC udaName( (*importDir)[i].iName );
|
|
2709 |
// Get manifest path
|
|
2710 |
HBufC* manifestBuf = GetManifestFromImportLC(
|
|
2711 |
udaName,
|
|
2712 |
aImportDirectory );
|
|
2713 |
|
|
2714 |
//install
|
|
2715 |
TRAPD( err, installer->InstallConfigurationL( *manifestBuf ) );
|
|
2716 |
if ( err != KErrNone )
|
|
2717 |
{
|
|
2718 |
#ifdef HSPS_LOG_ACTIVE
|
|
2719 |
iLogBus->LogText( _L( "ChspsThemeServer::InstallUDAWidgetsL(): - Installation failed" ) );
|
|
2720 |
#endif
|
|
2721 |
}
|
|
2722 |
CleanupStack::PopAndDestroy( manifestBuf );
|
|
2723 |
}
|
|
2724 |
CleanupStack::PopAndDestroy( installer );
|
|
2725 |
}
|
|
2726 |
CleanupStack::PopAndDestroy( importDir );
|
|
2727 |
}
|
|
2728 |
|
|
2729 |
// -----------------------------------------------------------------------------
|
|
2730 |
// ChspsThemeServer::HandleRomInstallationsL()
|
|
2731 |
// -----------------------------------------------------------------------------
|
|
2732 |
//
|
|
2733 |
void ChspsThemeServer::HandleRomInstallationsL()
|
|
2734 |
{
|
|
2735 |
#ifdef HSPS_LOG_ACTIVE
|
|
2736 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleRomInstallationsL()" ) );
|
|
2737 |
#endif
|
|
2738 |
|
|
2739 |
const TInt key = KCenrepKeyPostRFS;
|
|
2740 |
const TUint32 fullMask = 0xFFFFFFFF;
|
|
2741 |
RArray<TUint32> res;
|
|
2742 |
CleanupClosePushL( res );
|
|
2743 |
iCentralRepository->FindL( key, fullMask, res );
|
|
2744 |
if ( res.Count() == 0 )
|
|
2745 |
{
|
|
2746 |
// The key should already exist!
|
|
2747 |
#ifdef HSPS_LOG_ACTIVE
|
|
2748 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleRomInstallationsL(): - Couldn't find %d key from the HSPS cenrep!" ), key );
|
|
2749 |
#endif
|
|
2750 |
|
|
2751 |
User::Leave( KErrNotFound );
|
|
2752 |
}
|
|
2753 |
|
|
2754 |
// Check the key's value
|
|
2755 |
// lets use KSysUtilVersionTextLength instead of KSysVersionInfoRevisionLength if we
|
|
2756 |
// have to use SysUtil::GetSWVersion because KSysUtilVersionTextLength is bigger.
|
|
2757 |
TBuf<KSysUtilVersionTextLength> fwVersion;
|
|
2758 |
TInt errorCode = iCentralRepository->Get( key, fwVersion );
|
|
2759 |
if( ( errorCode == KErrNone ) &&
|
|
2760 |
( fwVersion.Length() == 0 ) )
|
|
2761 |
{
|
|
2762 |
// Install widgets from install and import directories (eMMC, UDA ROM)
|
|
2763 |
InstallWidgetsL( ETrue );
|
|
2764 |
|
|
2765 |
// Post RFS installations have been done, prevent re-installations at next startup
|
|
2766 |
// by reading firmware version and saving it to cenrep.
|
|
2767 |
GetFWVersion( fwVersion );
|
|
2768 |
|
|
2769 |
errorCode = iCentralRepository->Set( key, fwVersion );
|
|
2770 |
if ( errorCode )
|
|
2771 |
{
|
|
2772 |
#ifdef HSPS_LOG_ACTIVE
|
|
2773 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleRomInstallationsL(): - Failed to update the cenrep!" ) );
|
|
2774 |
#endif
|
|
2775 |
|
|
2776 |
User::Leave( KErrWrite );
|
|
2777 |
}
|
|
2778 |
else
|
|
2779 |
{
|
|
2780 |
#ifdef HSPS_LOG_ACTIVE
|
|
2781 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleRomInstallationsL(): - ROM configurations were installed successfully." ) );
|
|
2782 |
#endif
|
|
2783 |
}
|
|
2784 |
}
|
|
2785 |
else
|
|
2786 |
{
|
|
2787 |
// We have to check whether phone software has been updated for example by FOTA.
|
|
2788 |
// If the firmware version is different we need to run backup and restore to
|
|
2789 |
// check whether there are any new widgets introduced and check can we use
|
|
2790 |
// still same application configure. If firmware is same nothing needs to be done.
|
|
2791 |
TBuf<KSysUtilVersionTextLength> currentFWVersion;
|
|
2792 |
GetFWVersion( currentFWVersion );
|
|
2793 |
if ( fwVersion != currentFWVersion )
|
|
2794 |
{
|
|
2795 |
// Phone software has been updated.
|
|
2796 |
CreateBackupDataL();
|
|
2797 |
InstallWidgetsL( EFalse );
|
|
2798 |
// Restore the personalization
|
|
2799 |
RestoreApplicationConfigurationsL();
|
|
2800 |
// Save new firmware version to cenrep
|
|
2801 |
if ( errorCode == KErrNone )
|
|
2802 |
{
|
|
2803 |
errorCode = iCentralRepository->Set( key, currentFWVersion );
|
|
2804 |
}
|
|
2805 |
else if ( errorCode == KErrArgument )
|
|
2806 |
{
|
|
2807 |
// We came here because older version of HSPS cenrep value
|
|
2808 |
// of key was integer and now it is string.
|
|
2809 |
// Delete key and create new with different type
|
|
2810 |
iCentralRepository->Delete( key );
|
|
2811 |
errorCode = iCentralRepository->Create( key, currentFWVersion );
|
|
2812 |
}
|
|
2813 |
|
|
2814 |
if ( errorCode )
|
|
2815 |
{
|
|
2816 |
#ifdef HSPS_LOG_ACTIVE
|
|
2817 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleRomInstallationsL(): - Failed to update the cenrep!" ) );
|
|
2818 |
#endif
|
|
2819 |
|
|
2820 |
User::Leave( KErrWrite );
|
|
2821 |
}
|
|
2822 |
else
|
|
2823 |
{
|
|
2824 |
#ifdef HSPS_LOG_ACTIVE
|
|
2825 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleRomInstallationsL(): - ROM configurations were installed successfully." ) );
|
|
2826 |
#endif
|
|
2827 |
}
|
|
2828 |
}
|
|
2829 |
}
|
|
2830 |
|
|
2831 |
#if defined(WINSCW) || defined(__WINS__)
|
|
2832 |
// Activate client specific root configurations from active display resolution
|
|
2833 |
ActivateRootConfigurationsL();
|
|
2834 |
#endif // defined(WINSCW)
|
|
2835 |
|
|
2836 |
res.Close();
|
|
2837 |
CleanupStack::PopAndDestroy(1, &res);
|
|
2838 |
}
|
|
2839 |
|
|
2840 |
// -----------------------------------------------------------------------------
|
|
2841 |
// ChspsThemeServer::InstallWidgetsL()
|
|
2842 |
// -----------------------------------------------------------------------------
|
|
2843 |
//
|
|
2844 |
void ChspsThemeServer::InstallWidgetsL(
|
|
2845 |
const TBool aInstallUdaEmmc )
|
|
2846 |
{
|
|
2847 |
__ASSERT_DEBUG( !iRomInstaller, User::Leave( KErrGeneral) );
|
|
2848 |
iRomInstaller = ChspsRomInstaller::NewL(
|
|
2849 |
*this,
|
|
2850 |
iFsSession,
|
|
2851 |
aInstallUdaEmmc );
|
|
2852 |
#ifdef HSPS_LOG_ACTIVE
|
|
2853 |
iRomInstaller->SetLogBus( iLogBus );
|
|
2854 |
#endif
|
|
2855 |
|
|
2856 |
iRomInstaller->InstallL();
|
|
2857 |
|
|
2858 |
delete iRomInstaller;
|
|
2859 |
iRomInstaller = 0;
|
|
2860 |
|
|
2861 |
// Force updating of the header cache
|
|
2862 |
TRAP_IGNORE( UpdateHeaderListCacheL() );
|
|
2863 |
}
|
|
2864 |
|
|
2865 |
// -----------------------------------------------------------------------------
|
|
2866 |
// ChspsThemeServer::GetConfigurationHeader()
|
|
2867 |
// -----------------------------------------------------------------------------
|
|
2868 |
//
|
|
2869 |
void ChspsThemeServer::GetConfigurationHeader(
|
|
2870 |
ChspsODT& aSearchMask,
|
|
2871 |
ChspsODT*& aConfHeader,
|
|
2872 |
TInt& aPos )
|
|
2873 |
{
|
|
2874 |
ChspsODT* header( NULL );
|
|
2875 |
aConfHeader = NULL;
|
|
2876 |
for ( TInt i = aPos; i < iHeaderListCache->Count() && aConfHeader == NULL; i++ )
|
|
2877 |
{
|
|
2878 |
TBool rootUidMatch( ETrue );
|
|
2879 |
TBool themeUidMatch( ETrue );
|
|
2880 |
TBool flagsMatch( ETrue );
|
|
2881 |
TBool typeMatch( ETrue );
|
|
2882 |
TBool familyMatch( ETrue );
|
|
2883 |
|
|
2884 |
header = iHeaderListCache->At(i);
|
|
2885 |
|
|
2886 |
if ( aSearchMask.RootUid() &&
|
|
2887 |
aSearchMask.RootUid() != header->RootUid() )
|
|
2888 |
{
|
|
2889 |
// Root UID defined in search criteria and Root UID does not match
|
|
2890 |
rootUidMatch = EFalse;
|
|
2891 |
}
|
|
2892 |
// else Root UID check ignored
|
|
2893 |
if ( aSearchMask.ThemeUid() &&
|
|
2894 |
aSearchMask.ThemeUid() != header->ThemeUid() )
|
|
2895 |
{
|
|
2896 |
// Theme UID defined in search criteria and Theme UID does not match
|
|
2897 |
themeUidMatch = EFalse;
|
|
2898 |
}
|
|
2899 |
// else Theme UID check ignored
|
|
2900 |
if ( aSearchMask.Flags() &&
|
|
2901 |
!( aSearchMask.Flags() & header->Flags() ) )
|
|
2902 |
{
|
|
2903 |
// Header flags defined in search criteria and Header flags does not match
|
|
2904 |
flagsMatch = EFalse;
|
|
2905 |
}
|
|
2906 |
// else header flags check ignored
|
|
2907 |
if ( aSearchMask.ConfigurationType() &&
|
|
2908 |
aSearchMask.ConfigurationType() != header->ConfigurationType() )
|
|
2909 |
{
|
|
2910 |
typeMatch = EFalse;
|
|
2911 |
}
|
|
2912 |
if ( aSearchMask.Family() &&
|
|
2913 |
!( aSearchMask.Family() & header->Family() ) )
|
|
2914 |
{
|
|
2915 |
// Family does not match
|
|
2916 |
familyMatch = EFalse;
|
|
2917 |
}
|
|
2918 |
// else configuration type ignored
|
|
2919 |
if ( rootUidMatch && themeUidMatch && flagsMatch && typeMatch && familyMatch )
|
|
2920 |
{
|
|
2921 |
aConfHeader = header;
|
|
2922 |
aPos = i;
|
|
2923 |
}
|
|
2924 |
}
|
|
2925 |
}
|
|
2926 |
|
|
2927 |
// -----------------------------------------------------------------------------
|
|
2928 |
// ChspsThemeServer::ReinstallConfL()
|
|
2929 |
// -----------------------------------------------------------------------------
|
|
2930 |
//
|
|
2931 |
void ChspsThemeServer::ReinstallConfL(
|
|
2932 |
TInt aAppUid,
|
|
2933 |
TInt aConfUid )
|
|
2934 |
{
|
|
2935 |
|
|
2936 |
RFs fileserver;
|
|
2937 |
CleanupClosePushL( fileserver );
|
|
2938 |
User::LeaveIfError( fileserver.Connect() );
|
|
2939 |
|
|
2940 |
ChspsRomInstaller* installer = ChspsRomInstaller::NewL( *this, fileserver );
|
|
2941 |
CleanupStack::PushL( installer );
|
|
2942 |
|
|
2943 |
installer->ReinstallThemeL( aAppUid, aConfUid );
|
|
2944 |
|
|
2945 |
CleanupStack::PopAndDestroy( installer );
|
|
2946 |
CleanupStack::PopAndDestroy( &fileserver );
|
|
2947 |
|
|
2948 |
}
|
|
2949 |
|
|
2950 |
// -----------------------------------------------------------------------------
|
|
2951 |
// ChspsThemeServer::HandleBREventL()
|
|
2952 |
// -----------------------------------------------------------------------------
|
|
2953 |
//
|
|
2954 |
void ChspsThemeServer::HandleBREventL(
|
|
2955 |
TInt aEvent )
|
|
2956 |
{
|
|
2957 |
|
|
2958 |
switch ( iBRState )
|
|
2959 |
{
|
|
2960 |
case EhspsBRRestore:
|
|
2961 |
{
|
|
2962 |
HandleBRRestoreStateL( aEvent );
|
|
2963 |
}
|
|
2964 |
break;
|
|
2965 |
case EhspsBRBackup:
|
|
2966 |
{
|
|
2967 |
HandleBRBackupStateL( aEvent );
|
|
2968 |
}
|
|
2969 |
break;
|
|
2970 |
default: // EhspsBRNormal
|
|
2971 |
{
|
|
2972 |
HandleBRNormalStateL( aEvent );
|
|
2973 |
}
|
|
2974 |
break;
|
|
2975 |
}
|
|
2976 |
|
|
2977 |
}
|
|
2978 |
|
|
2979 |
// -----------------------------------------------------------------------------
|
|
2980 |
// ChspsThemeServer::HandleBRNormalStateL()
|
|
2981 |
// -----------------------------------------------------------------------------
|
|
2982 |
//
|
|
2983 |
void ChspsThemeServer::HandleBRNormalStateL(
|
|
2984 |
TInt aEvent )
|
|
2985 |
{
|
|
2986 |
if ( aEvent & conn::EBURBackupFull ||
|
|
2987 |
aEvent & conn::EBURBackupPartial )
|
|
2988 |
{
|
|
2989 |
CreateBRHandlerL( aEvent );
|
|
2990 |
if ( iBRHandler && iActiveBackupClient )
|
|
2991 |
{
|
|
2992 |
iBRState = EhspsBRBackup;
|
|
2993 |
#ifdef HSPS_LOG_ACTIVE
|
|
2994 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleBRNormalStateL(): - Backup starts" ) );
|
|
2995 |
#endif
|
|
2996 |
}
|
|
2997 |
}
|
|
2998 |
|
|
2999 |
if ( aEvent & conn::EBURRestoreFull ||
|
|
3000 |
aEvent & conn::EBURRestorePartial )
|
|
3001 |
{
|
|
3002 |
CreateBRHandlerL( aEvent );
|
|
3003 |
if ( iBRHandler && iActiveBackupClient )
|
|
3004 |
{
|
|
3005 |
iBRState = EhspsBRRestore;
|
|
3006 |
#ifdef HSPS_LOG_ACTIVE
|
|
3007 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleBRNormalStateL(): - Restore starts" ) );
|
|
3008 |
#endif
|
|
3009 |
}
|
|
3010 |
}
|
|
3011 |
}
|
|
3012 |
|
|
3013 |
// -----------------------------------------------------------------------------
|
|
3014 |
// ChspsThemeServer::HandleBRBackupStateL()
|
|
3015 |
// -----------------------------------------------------------------------------
|
|
3016 |
//
|
|
3017 |
void ChspsThemeServer::HandleBRBackupStateL(
|
|
3018 |
TInt aEvent )
|
|
3019 |
{
|
|
3020 |
if ( aEvent & conn::EBURNormal )
|
|
3021 |
{
|
|
3022 |
DeleteBRHandler();
|
|
3023 |
iBRState = EhspsBRNormal;
|
|
3024 |
#ifdef HSPS_LOG_ACTIVE
|
|
3025 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleBRBackupStateL(): - Backup completed" ) );
|
|
3026 |
#endif
|
|
3027 |
}
|
|
3028 |
}
|
|
3029 |
|
|
3030 |
// -----------------------------------------------------------------------------
|
|
3031 |
// ChspsThemeServer::HandleBRRestoreState()
|
|
3032 |
// -----------------------------------------------------------------------------
|
|
3033 |
//
|
|
3034 |
void ChspsThemeServer::HandleBRRestoreStateL(
|
|
3035 |
TInt aEvent )
|
|
3036 |
{
|
|
3037 |
if ( aEvent & conn::EBURNormal )
|
|
3038 |
{
|
|
3039 |
// Disable auto installations
|
|
3040 |
DisableAutoInstallation();
|
|
3041 |
// Restore imported configurations from backup/import folder
|
|
3042 |
RestoreImportedConfigurationsL();
|
|
3043 |
// Update cache
|
|
3044 |
UpdateHeaderListCacheL();
|
|
3045 |
// Restore application configurations from backup/themes folder
|
|
3046 |
RestoreApplicationConfigurationsL();
|
|
3047 |
// Restore completed
|
|
3048 |
DeleteBRHandler();
|
|
3049 |
iBRState = EhspsBRNormal;
|
|
3050 |
EnableAutoInstallationL();
|
|
3051 |
#ifdef HSPS_LOG_ACTIVE
|
|
3052 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleBRRestoreStateL(): - Restore completed" ) );
|
|
3053 |
#endif
|
|
3054 |
}
|
|
3055 |
}
|
|
3056 |
|
|
3057 |
// -----------------------------------------------------------------------------
|
|
3058 |
// ChspsThemeServer::CreateBRHandlerL()
|
|
3059 |
// -----------------------------------------------------------------------------
|
|
3060 |
//
|
|
3061 |
void ChspsThemeServer::CreateBRHandlerL(
|
|
3062 |
TInt aEvent )
|
|
3063 |
{
|
|
3064 |
if ( !iBRHandler )
|
|
3065 |
{
|
|
3066 |
iBRHandler = CHSPSBRHandler::NewL( *this );
|
|
3067 |
}
|
|
3068 |
if ( !iActiveBackupClient )
|
|
3069 |
{
|
|
3070 |
iActiveBackupClient = conn::CActiveBackupClient::NewL( iBRHandler );
|
|
3071 |
}
|
|
3072 |
if ( aEvent & conn::EBURBackupPartial ||
|
|
3073 |
aEvent & conn::EBURRestorePartial )
|
|
3074 |
{
|
|
3075 |
if( !iActiveBackupClient->DoesPartialBURAffectMeL() )
|
|
3076 |
{
|
|
3077 |
DeleteBRHandler();
|
|
3078 |
}
|
|
3079 |
}
|
|
3080 |
if ( iBRHandler && iActiveBackupClient )
|
|
3081 |
{
|
|
3082 |
iActiveBackupClient->ConfirmReadyForBURL( KErrNone );
|
|
3083 |
}
|
|
3084 |
}
|
|
3085 |
|
|
3086 |
// -----------------------------------------------------------------------------
|
|
3087 |
// ChspsThemeServer::DeleteBRHandler()
|
|
3088 |
// -----------------------------------------------------------------------------
|
|
3089 |
//
|
|
3090 |
void ChspsThemeServer::DeleteBRHandler()
|
|
3091 |
{
|
|
3092 |
delete iActiveBackupClient;
|
|
3093 |
iActiveBackupClient = NULL;
|
|
3094 |
delete iBRHandler;
|
|
3095 |
iBRHandler = NULL;
|
|
3096 |
}
|
|
3097 |
|
|
3098 |
// -----------------------------------------------------------------------------
|
|
3099 |
// ChspsThemeServer::CreateBackupDataL()
|
|
3100 |
// -----------------------------------------------------------------------------
|
|
3101 |
//
|
|
3102 |
void ChspsThemeServer::CreateBackupDataL()
|
|
3103 |
{
|
|
3104 |
|
|
3105 |
// Clear previous backup data
|
|
3106 |
iDefinitionRepository->ClearBackupsL();
|
|
3107 |
|
|
3108 |
// Get first application configuration header
|
|
3109 |
ChspsODT* searchMask = ChspsODT::NewL();
|
|
3110 |
CleanupStack::PushL( searchMask );
|
|
3111 |
searchMask->SetConfigurationType( EhspsAppConfiguration );
|
|
3112 |
ChspsODT* confHeader( NULL );
|
|
3113 |
TInt pos( 0 );
|
|
3114 |
GetConfigurationHeader( *searchMask, confHeader, pos );
|
|
3115 |
|
|
3116 |
while ( confHeader != NULL )
|
|
3117 |
{
|
|
3118 |
// Backup application configuration
|
|
3119 |
iDefinitionRepository->BackupConfigurationL( *confHeader );
|
|
3120 |
// Get next application configuration header
|
|
3121 |
pos++;
|
|
3122 |
GetConfigurationHeader( *searchMask, confHeader, pos );
|
|
3123 |
}
|
|
3124 |
|
|
3125 |
CleanupStack::PopAndDestroy( searchMask );
|
|
3126 |
}
|
|
3127 |
|
|
3128 |
// -----------------------------------------------------------------------------
|
|
3129 |
// ChspsThemeServer::EnableAutoInstallationL()
|
|
3130 |
// -----------------------------------------------------------------------------
|
|
3131 |
//
|
|
3132 |
void ChspsThemeServer::EnableAutoInstallationL()
|
|
3133 |
{
|
|
3134 |
|
|
3135 |
// Reset installation arrays
|
|
3136 |
iInstallableSisxThemes.Reset();
|
|
3137 |
iInstalledSisxThemes.ResetAndDestroy();
|
|
3138 |
iManifestFiles.ResetAndDestroy();
|
|
3139 |
|
|
3140 |
// Get installed configurations from the import folders
|
|
3141 |
CDir* fileList( NULL );
|
|
3142 |
TFindFile fileFinder( iFsSession );
|
|
3143 |
fileFinder.FindWildByDir(
|
|
3144 |
KFilterAllImportsV1,
|
|
3145 |
KImportDirectoryC,
|
|
3146 |
fileList );
|
|
3147 |
CleanupStack::PushL( fileList );
|
|
3148 |
if( fileList )
|
|
3149 |
{
|
|
3150 |
const TInt installedCount = fileList->Count();
|
|
3151 |
for( TInt i = 0; i < installedCount ; i++ )
|
|
3152 |
{
|
|
3153 |
const TEntry& entry = (*fileList)[i];
|
|
3154 |
iInstalledSisxThemes.AppendL( entry.iName.AllocL() );
|
|
3155 |
}
|
|
3156 |
}
|
|
3157 |
CleanupStack::PopAndDestroy( fileList );
|
|
3158 |
|
|
3159 |
// Create file change listener to observe changes in import folder
|
|
3160 |
delete iFileChangeListener;
|
|
3161 |
iFileChangeListener = NULL;
|
|
3162 |
iFileChangeListener = ChspsFileChangeListener::NewL(
|
|
3163 |
iFsSession,
|
|
3164 |
*this,
|
|
3165 |
ENotifyAll,
|
|
3166 |
KImportDirectoryC,
|
|
3167 |
TImportDirListener );
|
|
3168 |
#ifdef HSPS_LOG_ACTIVE
|
|
3169 |
iFileChangeListener->SetLogBus( iLogBus );
|
|
3170 |
#endif
|
|
3171 |
iFileChangeListener->Setup();
|
|
3172 |
|
|
3173 |
}
|
|
3174 |
|
|
3175 |
// -----------------------------------------------------------------------------
|
|
3176 |
// ChspsThemeServer::DisableAutoInstallation()
|
|
3177 |
// -----------------------------------------------------------------------------
|
|
3178 |
//
|
|
3179 |
void ChspsThemeServer::DisableAutoInstallation()
|
|
3180 |
{
|
|
3181 |
// Reset installation arrays
|
|
3182 |
iInstallableSisxThemes.Reset();
|
|
3183 |
iInstalledSisxThemes.ResetAndDestroy();
|
|
3184 |
iManifestFiles.ResetAndDestroy();
|
|
3185 |
|
|
3186 |
// Delete import folder observer
|
|
3187 |
delete iFileChangeListener;
|
|
3188 |
iFileChangeListener = NULL;
|
|
3189 |
}
|
|
3190 |
|
|
3191 |
// -----------------------------------------------------------------------------
|
|
3192 |
// ChspsThemeServer::RestoreImportedConfigurationsL()
|
|
3193 |
// -----------------------------------------------------------------------------
|
|
3194 |
//
|
|
3195 |
void ChspsThemeServer::RestoreImportedConfigurationsL()
|
|
3196 |
{
|
|
3197 |
// Check that import folder exists and can be opened
|
|
3198 |
if ( BaflUtils::CheckFolder( iFsSession, KImportDirectoryC ) == KErrNone )
|
|
3199 |
{
|
|
3200 |
// Get list of restored configuration manifest.dat files included in
|
|
3201 |
// import directory
|
|
3202 |
RArray <TFileName> files;
|
|
3203 |
CleanupClosePushL( files );
|
|
3204 |
hspsServerUtil::FindFilesL(
|
|
3205 |
KImportDirectoryC,
|
|
3206 |
KManifestFile,
|
|
3207 |
files );
|
|
3208 |
|
|
3209 |
// Install found configurations
|
|
3210 |
TInt err( KErrNone );
|
|
3211 |
CHSPSInstaller* installer = CHSPSInstaller::NewL( *this );
|
|
3212 |
installer->InstallationHandler().DisableNotifications();
|
|
3213 |
CleanupStack::PushL( installer );
|
|
3214 |
for ( TInt i = 0; i < files.Count(); i++ )
|
|
3215 |
{
|
|
3216 |
#ifdef HSPS_LOG_ACTIVE
|
|
3217 |
iLogBus->LogText( _L( "ChspsThemeServer::InstallRestoredConfigurationsL(): - Install configuration: %S" ), &files[ i ] );
|
|
3218 |
#endif
|
|
3219 |
TRAP( err, installer->InstallConfigurationL( files[ i ] ) );
|
|
3220 |
#ifdef HSPS_LOG_ACTIVE
|
|
3221 |
if ( err != KErrNone )
|
|
3222 |
{
|
|
3223 |
iLogBus->LogText( _L( "ChspsThemeServer::InstallRestoredConfigurationsL(): - Installation failed: %S" ), &files[ i ] );
|
|
3224 |
}
|
|
3225 |
#endif
|
|
3226 |
}
|
|
3227 |
CleanupStack::PopAndDestroy( installer );
|
|
3228 |
CleanupStack::PopAndDestroy( &files );
|
|
3229 |
}
|
|
3230 |
}
|
|
3231 |
|
|
3232 |
// -----------------------------------------------------------------------------
|
|
3233 |
// ChspsThemeServer::RestoreApplicationConfigurationsL()
|
|
3234 |
// -----------------------------------------------------------------------------
|
|
3235 |
//
|
|
3236 |
void ChspsThemeServer::RestoreApplicationConfigurationsL()
|
|
3237 |
{
|
|
3238 |
// Get the list of application configuration files included
|
|
3239 |
// backup/themes directory
|
|
3240 |
RArray <TFileName> files;
|
|
3241 |
CleanupClosePushL( files );
|
|
3242 |
hspsServerUtil::FindFilesL(
|
|
3243 |
KBackupThemesDirectoryC,
|
|
3244 |
KConfFile,
|
|
3245 |
files );
|
|
3246 |
|
|
3247 |
// Get application configuration ODT's
|
|
3248 |
TInt err( KErrNone );
|
|
3249 |
CArrayPtrSeg<ChspsODT>* odts =
|
|
3250 |
new ( ELeave )CArrayPtrSeg<ChspsODT>( KHeaderListGranularity );
|
|
3251 |
CleanupStack::PushL( TCleanupItem( ResetAndDestroyChspsODTArray, odts ) );
|
|
3252 |
|
|
3253 |
for ( TInt i = 0; i < files.Count(); i++ )
|
|
3254 |
{
|
|
3255 |
#ifdef HSPS_LOG_ACTIVE
|
|
3256 |
iLogBus->LogText( _L( "ChspsThemeServer::RestoreApplicationConfigurationsL(): - Read application configuration ODT: %S" ), &files[ i ] );
|
|
3257 |
#endif
|
|
3258 |
ChspsODT* odt = ChspsODT::NewL();
|
|
3259 |
CleanupStack::PushL( odt );
|
|
3260 |
TRAP( err, iDefinitionRepository->GetOdtL( files[ i ], *odt ) );
|
|
3261 |
if ( err == KErrNone )
|
|
3262 |
{
|
|
3263 |
// Add ODT to ODT list
|
|
3264 |
odts->AppendL( odt );
|
|
3265 |
CleanupStack::Pop( odt );
|
|
3266 |
}
|
|
3267 |
else
|
|
3268 |
{
|
|
3269 |
#ifdef HSPS_LOG_ACTIVE
|
|
3270 |
iLogBus->LogText( _L( "ChspsThemeServer::RestoreApplicationConfigurationsL(): - Application configuration ODT reading faild: %S" ), &files[ i ] );
|
|
3271 |
#endif
|
|
3272 |
CleanupStack::PopAndDestroy( odt );
|
|
3273 |
}
|
|
3274 |
}
|
|
3275 |
|
|
3276 |
// Validate application configurations
|
|
3277 |
for ( TInt i = 0; i < odts->Count(); i++ )
|
|
3278 |
{
|
|
3279 |
ChspsODT* odt = odts->At( i );
|
|
3280 |
#ifdef HSPS_LOG_ACTIVE
|
|
3281 |
iLogBus->LogText( _L( "ChspsThemeServer::RestoreApplicationConfigurationsL(): - Validate applicartion configuration: %S" ), &odt->ThemeFullName() );
|
|
3282 |
#endif
|
|
3283 |
TRAP( err, ValidateRestoredConfigurationL( *odt ) );
|
|
3284 |
if ( err == KErrNone )
|
|
3285 |
{
|
|
3286 |
// Restore application configuration
|
|
3287 |
RestoreConfigurationL( *odt );
|
|
3288 |
}
|
|
3289 |
else
|
|
3290 |
{
|
|
3291 |
#ifdef HSPS_LOG_ACTIVE
|
|
3292 |
iLogBus->LogText( _L( "ChspsThemeServer::RestoreApplicationConfigurationsL(): - Validation failed: %S" ), &odt->ThemeFullName() );
|
|
3293 |
#endif
|
|
3294 |
}
|
|
3295 |
}
|
|
3296 |
|
|
3297 |
CleanupStack::PopAndDestroy( odts );
|
|
3298 |
CleanupStack::PopAndDestroy( &files );
|
|
3299 |
|
|
3300 |
}
|
|
3301 |
|
|
3302 |
// -----------------------------------------------------------------------------
|
|
3303 |
// ChspsThemeServer::ValidateRestoredConfigurationL()
|
|
3304 |
// -----------------------------------------------------------------------------
|
|
3305 |
//
|
|
3306 |
void ChspsThemeServer::ValidateRestoredConfigurationL(
|
|
3307 |
ChspsODT& aOdt )
|
|
3308 |
{
|
|
3309 |
|
|
3310 |
// Validate application configuration
|
|
3311 |
TBuf8<10> appConfUid;
|
|
3312 |
_LIT8( KFormat8, "%X" );
|
|
3313 |
_LIT8( KHexPrefix, "0x" );
|
|
3314 |
appConfUid.Append( KHexPrefix );
|
|
3315 |
appConfUid.AppendFormat( KFormat8, aOdt.ThemeUid() );
|
|
3316 |
TPtrC8 appConfState;
|
|
3317 |
hspsServerUtil::GetAttributeValueL(
|
|
3318 |
aOdt,
|
|
3319 |
KConfigurationElement,
|
|
3320 |
KConfigurationAttrUid,
|
|
3321 |
appConfUid,
|
|
3322 |
KConfigurationAttrState,
|
|
3323 |
appConfState );
|
|
3324 |
|
|
3325 |
if ( appConfState.Compare( KConfStateError ) == 0 )
|
|
3326 |
{
|
|
3327 |
// Invalid application configuration
|
|
3328 |
User::Leave( KErrGeneral );
|
|
3329 |
}
|
|
3330 |
|
|
3331 |
// Check application configuration version
|
|
3332 |
ChspsODT* searchMask = ChspsODT::NewL();
|
|
3333 |
CleanupStack::PushL( searchMask );
|
|
3334 |
searchMask->SetThemeUid( aOdt.ThemeUid() );
|
|
3335 |
ChspsODT* header( NULL );
|
|
3336 |
TInt pos( 0 );
|
|
3337 |
GetConfigurationHeader( *searchMask, header, pos );
|
|
3338 |
if ( !header )
|
|
3339 |
{
|
|
3340 |
User::Leave( KErrNotFound );
|
|
3341 |
}
|
|
3342 |
else
|
|
3343 |
{
|
|
3344 |
hspsServerUtil::CheckConfigurationVersionL(
|
|
3345 |
aOdt,
|
|
3346 |
aOdt.ThemeUid(),
|
|
3347 |
header->ThemeVersion() );
|
|
3348 |
}
|
|
3349 |
CleanupStack::PopAndDestroy( searchMask );
|
|
3350 |
|
|
3351 |
// Validate included plugins
|
|
3352 |
// Get configuration UIDs from restored configuration
|
|
3353 |
RArray <TInt> uids;
|
|
3354 |
CleanupClosePushL( uids );
|
|
3355 |
hspsServerUtil::FindUniquePluginsL(
|
|
3356 |
aOdt,
|
|
3357 |
uids );
|
|
3358 |
|
|
3359 |
for ( TInt i = 0; i < uids.Count(); i++ )
|
|
3360 |
{
|
|
3361 |
// Check if the configuration is installed
|
|
3362 |
TInt err( KErrNone );
|
|
3363 |
ChspsODT* searchMask = ChspsODT::NewL();
|
|
3364 |
CleanupStack::PushL( searchMask );
|
|
3365 |
searchMask->SetThemeUid( uids[ i ] );
|
|
3366 |
ChspsODT* header( NULL );
|
|
3367 |
TInt pos( 0 );
|
|
3368 |
GetConfigurationHeader( *searchMask, header, pos );
|
|
3369 |
if ( !header ) // Configuration not found
|
|
3370 |
{
|
|
3371 |
err = KErrNotFound;
|
|
3372 |
}
|
|
3373 |
else // Configuration found
|
|
3374 |
{
|
|
3375 |
// Check the configuration version
|
|
3376 |
TPtrC8 version;
|
|
3377 |
TRAP( err, hspsServerUtil::CheckConfigurationVersionL(
|
|
3378 |
aOdt,
|
|
3379 |
uids[ i ],
|
|
3380 |
header->ThemeVersion() ) );
|
|
3381 |
if ( err == KErrNone )
|
|
3382 |
{
|
|
3383 |
// Check that configuration resource files are found
|
|
3384 |
TRAP( err, hspsServerUtil::CheckResourceFilesL(
|
|
3385 |
aOdt,
|
|
3386 |
uids[ i ] ) );
|
|
3387 |
}
|
|
3388 |
}
|
|
3389 |
|
|
3390 |
// Check configuration state attribute
|
|
3391 |
// Configuration UID as HEX string
|
|
3392 |
// 10 -> TInt as 0xXXXXXXXX string
|
|
3393 |
TBuf8<10> confUid;
|
|
3394 |
_LIT8( KFormat8, "%X" );
|
|
3395 |
_LIT8( KHexPrefix, "0x" );
|
|
3396 |
confUid.Append( KHexPrefix );
|
|
3397 |
confUid.AppendFormat( KFormat8, uids[ i ] );
|
|
3398 |
TPtrC8 state;
|
|
3399 |
hspsServerUtil::GetAttributeValueL(
|
|
3400 |
aOdt,
|
|
3401 |
KConfigurationElement,
|
|
3402 |
KConfigurationAttrUid,
|
|
3403 |
confUid,
|
|
3404 |
KConfigurationAttrState,
|
|
3405 |
state );
|
|
3406 |
|
|
3407 |
if ( err != KErrNone )
|
|
3408 |
{
|
|
3409 |
// Set plugin configuration to "error" state
|
|
3410 |
state.Set( KConfStateError );
|
|
3411 |
|
|
3412 |
// Remove missing plugins, thus there will be no error note later on
|
|
3413 |
hspsServerUtil::RemovePluginResourcesL( aOdt, uids[ i ] );
|
|
3414 |
|
|
3415 |
}
|
|
3416 |
else if ( state.CompareF( KConfStateError ) != 0 )
|
|
3417 |
{
|
|
3418 |
state.Set( KConfStateNotConfirmed );
|
|
3419 |
}
|
|
3420 |
hspsServerUtil::SetAttributeValueL(
|
|
3421 |
aOdt,
|
|
3422 |
KConfigurationElement,
|
|
3423 |
KConfigurationAttrUid,
|
|
3424 |
confUid,
|
|
3425 |
KConfigurationAttrState,
|
|
3426 |
state );
|
|
3427 |
|
|
3428 |
CleanupStack::PopAndDestroy( searchMask );
|
|
3429 |
}
|
|
3430 |
|
|
3431 |
CleanupStack::PopAndDestroy( &uids );
|
|
3432 |
}
|
|
3433 |
|
|
3434 |
// -----------------------------------------------------------------------------
|
|
3435 |
// ChspsThemeServer::RestoreConfigurationL()
|
|
3436 |
// -----------------------------------------------------------------------------
|
|
3437 |
//
|
|
3438 |
void ChspsThemeServer::RestoreConfigurationL(
|
|
3439 |
ChspsODT& aOdt )
|
|
3440 |
{
|
|
3441 |
|
|
3442 |
if ( iDefinitionRepository->Locked() )
|
|
3443 |
{
|
|
3444 |
User::Leave( KErrServerBusy );
|
|
3445 |
}
|
|
3446 |
iDefinitionRepository->Lock();
|
|
3447 |
CleanupStack::PushL( TCleanupItem( UnlockRepository, iDefinitionRepository ) );
|
|
3448 |
|
|
3449 |
iDefinitionRepository->SetOdtL( aOdt );
|
|
3450 |
// repository is unlocked in UnlockRepository function during PopAndDestroy
|
|
3451 |
CleanupStack::PopAndDestroy();
|
|
3452 |
}
|
|
3453 |
|
|
3454 |
// -----------------------------------------------------------------------------
|
|
3455 |
// ChspsThemeServer::ActivateThemeL()
|
|
3456 |
// -----------------------------------------------------------------------------
|
|
3457 |
//
|
|
3458 |
TInt ChspsThemeServer::ActivateThemeL(
|
|
3459 |
const ChspsODT& aSetMask,
|
|
3460 |
ChspsODT& aOdt )
|
|
3461 |
{
|
|
3462 |
TInt errorCode = GetConfigurationL(
|
|
3463 |
aSetMask.RootUid(),
|
|
3464 |
aSetMask.ThemeUid(),
|
|
3465 |
aOdt );
|
|
3466 |
if ( aOdt.ConfigurationType() != EhspsAppConfiguration )
|
|
3467 |
{
|
|
3468 |
errorCode = KErrArgument;
|
|
3469 |
}
|
|
3470 |
|
|
3471 |
if( !errorCode )
|
|
3472 |
{
|
|
3473 |
const TUint32 KMask = 0xFFFFFFFF;
|
|
3474 |
RArray<TUint32> res;
|
|
3475 |
CleanupClosePushL( res );
|
|
3476 |
|
|
3477 |
iCentralRepository->FindL( aSetMask.RootUid(), KMask, res );
|
|
3478 |
if ( res.Count() == 0 )
|
|
3479 |
{
|
|
3480 |
errorCode = iCentralRepository->Create( aSetMask.RootUid(), aSetMask.ThemeUid() );
|
|
3481 |
}
|
|
3482 |
else
|
|
3483 |
{
|
|
3484 |
errorCode = iCentralRepository->Set( aSetMask.RootUid(), aSetMask.ThemeUid() );
|
|
3485 |
}
|
|
3486 |
if ( !errorCode )
|
|
3487 |
{
|
|
3488 |
// Request re-evaluation of the new application configuration
|
|
3489 |
hspsServerUtil::UpdateAppConfigurationStateL(
|
|
3490 |
aOdt,
|
|
3491 |
KConfStateConfirmed,
|
|
3492 |
KConfStateNotConfirmed );
|
|
3493 |
|
|
3494 |
// Store changes to the Plug-in Repository
|
|
3495 |
iDefinitionRepository->SetOdtL( aOdt );
|
|
3496 |
}
|
|
3497 |
|
|
3498 |
res.Close();
|
|
3499 |
CleanupStack::PopAndDestroy(); // res
|
|
3500 |
}
|
|
3501 |
|
|
3502 |
return errorCode;
|
|
3503 |
}
|
|
3504 |
|
|
3505 |
// -----------------------------------------------------------------------------
|
|
3506 |
// ChspsThemeServer::GetActivateAppConfigurationL()
|
|
3507 |
// -----------------------------------------------------------------------------
|
|
3508 |
//
|
|
3509 |
TInt ChspsThemeServer::GetActivateAppConfigurationL(
|
|
3510 |
const TInt aAppUid,
|
|
3511 |
ChspsODT& aOdt )
|
|
3512 |
{
|
|
3513 |
// Get active application configuration for the provided application
|
|
3514 |
TInt configurationUid = -1;
|
|
3515 |
TInt errorCode = iCentralRepository->Get(
|
|
3516 |
aAppUid,
|
|
3517 |
configurationUid );
|
|
3518 |
if ( !errorCode )
|
|
3519 |
{
|
|
3520 |
__ASSERT_DEBUG( configurationUid > 0, User::Leave( KErrArgument) );
|
|
3521 |
|
|
3522 |
// Get the ODT object
|
|
3523 |
errorCode = GetConfigurationL(
|
|
3524 |
aAppUid,
|
|
3525 |
configurationUid,
|
|
3526 |
aOdt );
|
|
3527 |
|
|
3528 |
__ASSERT_DEBUG( aOdt.ConfigurationType() == EhspsAppConfiguration, User::Leave( KErrArgument) );
|
|
3529 |
}
|
|
3530 |
|
|
3531 |
return errorCode;
|
|
3532 |
}
|
|
3533 |
|
|
3534 |
// -----------------------------------------------------------------------------
|
|
3535 |
// ChspsThemeServer::GetActiveFamilyL()
|
|
3536 |
// -----------------------------------------------------------------------------
|
|
3537 |
//
|
|
3538 |
TUint32 ChspsThemeServer::GetActiveFamilyL(
|
|
3539 |
const TInt aAppUid )
|
|
3540 |
{
|
|
3541 |
if ( aAppUid < 1 )
|
|
3542 |
{
|
|
3543 |
User::Leave( KErrArgument );
|
|
3544 |
}
|
|
3545 |
TUint32 familyMask( 0 );
|
|
3546 |
ChspsODT* appODT = ChspsODT::NewL();
|
|
3547 |
CleanupStack::PushL( appODT );
|
|
3548 |
if ( !GetActivateAppConfigurationL( aAppUid, *appODT ) )
|
|
3549 |
{
|
|
3550 |
familyMask = appODT->Family();
|
|
3551 |
}
|
|
3552 |
CleanupStack::PopAndDestroy( appODT );
|
|
3553 |
return familyMask;
|
|
3554 |
}
|
|
3555 |
|
|
3556 |
#if defined(WINSCW) || defined(__WINS__)
|
|
3557 |
void ChspsThemeServer::ActivateRootConfigurationsL()
|
|
3558 |
{
|
|
3559 |
// Get family from the active resolution
|
|
3560 |
const ThspsFamily family = iFamily->GetFamilyType();
|
|
3561 |
|
|
3562 |
// Try to activate an application configuration which was designed
|
|
3563 |
// for the active resolution
|
|
3564 |
if ( !HandleFamilyChangeL( family ) )
|
|
3565 |
{
|
|
3566 |
// Try default family or just use the last one installed
|
|
3567 |
HandleFamilyChangeL( KDefaultFamily );
|
|
3568 |
}
|
|
3569 |
}
|
|
3570 |
#endif // defined(WINSCW) || defined(__WINS__)
|
|
3571 |
|
|
3572 |
|
|
3573 |
// -----------------------------------------------------------------------------
|
|
3574 |
// ChspsThemeServer::HandleFamilyChangeL()
|
|
3575 |
// -----------------------------------------------------------------------------
|
|
3576 |
//
|
|
3577 |
TBool ChspsThemeServer::HandleFamilyChangeL(
|
|
3578 |
const ThspsFamily aNewFamily )
|
|
3579 |
{
|
|
3580 |
#ifdef HSPS_LOG_ACTIVE
|
|
3581 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleFamilyChangeL(): resolution has changed, notifying clients..." ) );
|
|
3582 |
#endif // HSPS_LOG_ACTIVE
|
|
3583 |
|
|
3584 |
__ASSERT_DEBUG( aNewFamily > EhspsFamilyUnknown && aNewFamily <= EhspsFamilyVga_tch, User::Leave( KErrArgument) );
|
|
3585 |
|
|
3586 |
RArray<ChspsODT*> notificationTargets;
|
|
3587 |
CleanupClosePushL( notificationTargets );
|
|
3588 |
|
|
3589 |
if ( iDefinitionRepository->Locked() )
|
|
3590 |
{
|
|
3591 |
User::Leave( KErrAccessDenied );
|
|
3592 |
}
|
|
3593 |
// In case of error. repository is unlocked
|
|
3594 |
iDefinitionRepository->Lock();
|
|
3595 |
CleanupStack::PushL( TCleanupItem( UnlockRepository, iDefinitionRepository ) );
|
|
3596 |
|
|
3597 |
// Find first application configurations with the provided family id
|
|
3598 |
ChspsODT* header = NULL;
|
|
3599 |
ChspsODT* targetHeader = NULL;
|
|
3600 |
for ( TInt headerIndex=0; headerIndex < iHeaderListCache->Count(); headerIndex++ )
|
|
3601 |
{
|
|
3602 |
header = iHeaderListCache->At( headerIndex );
|
|
3603 |
|
|
3604 |
// It's totally acceptable that all clients haven't got resolution specific widgets,
|
|
3605 |
// in that case the UI should remaing the same - others should reload the application configuration
|
|
3606 |
// when appropriate for them
|
|
3607 |
if ( header->ConfigurationType() == EhspsAppConfiguration )
|
|
3608 |
{
|
|
3609 |
|
|
3610 |
// If the bit is set
|
|
3611 |
if ( header->Family() & aNewFamily )
|
|
3612 |
{
|
|
3613 |
|
|
3614 |
// Skip family change if it's already up to date
|
|
3615 |
TInt activeConfigurationUid = -1;
|
|
3616 |
const TInt err = iCentralRepository->Get( header->RootUid(), activeConfigurationUid );
|
|
3617 |
if( err )
|
|
3618 |
{
|
|
3619 |
continue;
|
|
3620 |
}
|
|
3621 |
|
|
3622 |
// Notify each client only once
|
|
3623 |
TBool alreadyIncluded = EFalse;
|
|
3624 |
for( TInt targetIndex=0; targetIndex < notificationTargets.Count(); targetIndex++ )
|
|
3625 |
{
|
|
3626 |
targetHeader = notificationTargets[ targetIndex ];
|
|
3627 |
if ( header->RootUid() == targetHeader->RootUid() )
|
|
3628 |
{
|
|
3629 |
alreadyIncluded = ETrue;
|
|
3630 |
break;
|
|
3631 |
}
|
|
3632 |
}
|
|
3633 |
if ( !alreadyIncluded )
|
|
3634 |
{
|
|
3635 |
notificationTargets.Append( header );
|
|
3636 |
|
|
3637 |
// Check if active configuration supports the current family
|
|
3638 |
TBool updateRequired = ETrue;
|
|
3639 |
for( TInt i=0; i < iHeaderListCache->Count(); i++ )
|
|
3640 |
{
|
|
3641 |
ChspsODT* h = iHeaderListCache->At( i );
|
|
3642 |
if( h->ThemeUid() == activeConfigurationUid )
|
|
3643 |
{
|
|
3644 |
if( (ThspsFamily)h->Family() & aNewFamily )
|
|
3645 |
{
|
|
3646 |
// No need to change the active root configuration
|
|
3647 |
updateRequired = EFalse;
|
|
3648 |
break;
|
|
3649 |
}
|
|
3650 |
}
|
|
3651 |
}
|
|
3652 |
if( updateRequired && activeConfigurationUid != header->ThemeUid() )
|
|
3653 |
{
|
|
3654 |
// Activate the resolution specific theme
|
|
3655 |
ChspsODT* newOdt = ChspsODT::NewL();
|
|
3656 |
CleanupStack::PushL( newOdt );
|
|
3657 |
ActivateThemeL( *header, *newOdt );
|
|
3658 |
CleanupStack::PopAndDestroy( newOdt );
|
|
3659 |
#ifdef HSPS_LOG_ACTIVE
|
|
3660 |
iLogBus->LogText(
|
|
3661 |
_L( "ChspsThemeServer::HandleFamilyChangeL(): application configuration %D has been activated" ),
|
|
3662 |
header->ThemeUid()
|
|
3663 |
);
|
|
3664 |
#endif // HSPS_LOG_ACTIVE
|
|
3665 |
}
|
|
3666 |
} // updateRequired
|
|
3667 |
|
|
3668 |
} // header type
|
|
3669 |
|
|
3670 |
}
|
|
3671 |
|
|
3672 |
} // headers loop
|
|
3673 |
|
|
3674 |
iDefinitionRepository->Unlock();
|
|
3675 |
CleanupStack::Pop(iDefinitionRepository);
|
|
3676 |
|
|
3677 |
// Signal that we found an application configuration for the requested family
|
|
3678 |
TBool activated = ( notificationTargets.Count() > 0 );
|
|
3679 |
|
|
3680 |
// Reloading notifications are sent from void ChspsClientRequestHandler::HandleCenRepChangeL()
|
|
3681 |
notificationTargets.Close();
|
|
3682 |
CleanupStack::PopAndDestroy( ¬ificationTargets );
|
|
3683 |
|
|
3684 |
#ifdef HSPS_LOG_ACTIVE
|
|
3685 |
iLogBus->LogText( _L( "ChspsThemeServer::HandleFamilyChangeL(): notifications sent" ) );
|
|
3686 |
#endif // HSPS_LOG_ACTIVE
|
|
3687 |
|
|
3688 |
return activated;
|
|
3689 |
}
|
|
3690 |
|
|
3691 |
// -----------------------------------------------------------------------------
|
|
3692 |
// ChspsThemeServer::Family()
|
|
3693 |
// -----------------------------------------------------------------------------
|
|
3694 |
//
|
|
3695 |
ChspsFamily* ChspsThemeServer::Family()
|
|
3696 |
{
|
|
3697 |
return iFamily;
|
|
3698 |
}
|
|
3699 |
|
|
3700 |
|
|
3701 |
// -----------------------------------------------------------------------------
|
|
3702 |
// ChspsThemeServer::SetResourceFileCopyRequired()
|
|
3703 |
// -----------------------------------------------------------------------------
|
|
3704 |
//
|
|
3705 |
void ChspsThemeServer::SetResourceFileCopyRequired( const TInt aAppUid )
|
|
3706 |
{
|
|
3707 |
// Handle all related sessions
|
|
3708 |
for( TInt i = 0; i < iSessions.Count(); i++ )
|
|
3709 |
{
|
|
3710 |
if( iSessions[i]->AppUid() == aAppUid )
|
|
3711 |
{
|
|
3712 |
iSessions[i]->SetResourceFileCopyRequired( ETrue );
|
|
3713 |
}
|
|
3714 |
}
|
|
3715 |
}
|
|
3716 |
|
|
3717 |
// end of file
|
|
3718 |
|