homescreenpluginsrv/hspsmanager/inc/hspsthemeserver.h
changeset 0 79c6a41cd166
child 8 d0529222e3f0
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 1020 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 server
       
    15 * 
       
    16 *  Architecture
       
    17 *  ************
       
    18 *  ChspsThemeServer derives CPolicyServer when compiled on EKA2 based Symbian OS.
       
    19 *  ChspsThemeServer depends on the following classes:
       
    20 *  - ChspsInstallationHandler which implements MhspsInstallationHandler,
       
    21 *  - ChspsMaintenanceHandler which implements MhspsMaintenanceHandler,
       
    22 *  - ChspsClientRequestHandler which implements MhspsClientRequestHandler,
       
    23 *  - ChspsDefinitionRepository and ChspsODT from Xuikon, 
       
    24 *  - ChspsFileChangeListener,
       
    25 *  - ChspsAutoInstaller, and
       
    26 *  - CRepository from Symbian.
       
    27 *
       
    28 *  Functionality
       
    29 *  *************
       
    30 *  When client connects to hspsThemeServer, the access rights are checked. 
       
    31 *  If access is granted, a server session is created. Once connected, client may
       
    32 *  perform service requests as long as it is connected. Service requests are 
       
    33 *  served by initiating appropriate service handlers. These service handlers are
       
    34 *  Symbian active objects, based on CActive-class. In using active ojects, it is
       
    35 *  possible to perform long-lasting service requests without blocking others 
       
    36 *  clients getting served on-time. Active objects are also used to assist 
       
    37 *  services to perform asynchronous operations internally, for e.g. when service
       
    38 *  is executing slow media conversions. Furthermore, some of these services are
       
    39 *  extended to implement timer-functionality, based on CTimer-class. 
       
    40 *  These active timers are used to control different time-based server 
       
    41 *  operations and initiate service-state refreshing functionality.
       
    42 *  hspsThemeServer contains auto-install feature that can install Application
       
    43 *  Theme on SISX-packet exctraction.
       
    44 *    
       
    45 *  
       
    46 *  Installation Handler
       
    47 *  ====================
       
    48 *  ChspsInstallatioHandler-active object performs all installation related
       
    49 *  functionality. Installation concerns reading installation instructions from 
       
    50 *  manifest-file, utilizind Xuikon Definition Engine to parse xml- and 
       
    51 *  css-files, and apply style and localisation information defined in dtd-files
       
    52 *  into the DOM-document created. Installer also handles resources that theme 
       
    53 *  may include. Some resource types may need conversions to fit on the target
       
    54 *  device's screen or audio device etc. In this case, the installer performs 
       
    55 *  media conversions by its Media Converter. Conversions are asynchronous and
       
    56 *  they deploy MIME-types. For more information of media conversions, see 
       
    57 *  ChspsMediaConverter documentation. When installation is successful, 
       
    58 *  Installation Handler utilizes Xuikon Definition Repository to store the 
       
    59 *  results. The resulted objects are for e.g. unlocalised and localised 
       
    60 *  versions of application theme. Theme associated resources are also handled 
       
    61 *  in unlocalised and localised versions. Resources are stored on repository 
       
    62 *  and their related information is stored on the list of ChspsResource-objects
       
    63 *  - a resource list. This list of ChspsResource-objects is called Resource List.
       
    64 *  Definition Repository is located in hspsThemeServer private  folder. 
       
    65 *  Repository is organisized by theme header information. 
       
    66 *  For more information, see hspsResource documentation.
       
    67 *  On theme updates, i.e. installation over previous one, Installation Handler
       
    68 *  deploys ChspsSecurityEnforcer to control theme update rights.
       
    69 *  For more information, see ChspsSecurityEnforcer documentation and 
       
    70 *  ChspsInstallatioHandler documentation. 
       
    71 *  
       
    72 *  Maintenance Handler
       
    73 *  ===================
       
    74 *  ChspsMaintenanceHandler-active timer performs all theme maintenance related 
       
    75 *  functionality. Maintenance services includes theme listing, theme activation,
       
    76 *  theme removal and default theme restoring operations. Maintenance functions 
       
    77 *  deploy Xuikon Definition Repository and Symbian Central Repository. 
       
    78 *  Definition Repository maintains Application Themes in save place and Central
       
    79 *  Repository maintains the information about which theme is active for what 
       
    80 *  application. Information in Central Repository is presented in pairs of 
       
    81 *  application UID and active theme UID.
       
    82 *  For more information, see ChspsMaintenanceHandler documentation. 
       
    83 *
       
    84 *  Client Request Handler
       
    85 *  ======================
       
    86 *  ChspsClientRequestHandler-active timer performs all request accesses from 
       
    87 *  Rendering Engine. When request exists, the just right one application theme 
       
    88 *  is delivered to client process using memory chunk passing. Resource List is
       
    89 *  delivered too. Client Request Handler uses Xuikon Definition Repository and 
       
    90 *  Symbian Central Repository to get match theme on the request. Client Request
       
    91 *  Handler serves also resource accesses. In using file handle passing 
       
    92 *  introduced by Symbian Platform Security concept, Client Request Service 
       
    93 *  arranges a resource access to hspsThemeServer's private folder for the client 
       
    94 *  process. RFile handle passing is used. 
       
    95 *  For more information, see ChspsClientRequestHandler documentation.
       
    96 *
       
    97 *  File Change Listener
       
    98 *  ==================
       
    99 *  ChspsFileChangeListener listens to given file folder and notifies its observer
       
   100 *  if there is any file change. Observer is given as a parameter on 
       
   101 *  initialising the listener. Observer must implement MhspsFileChangeObserver-interface.
       
   102 *  FileChangeListener is asynchronous object that deploys Symbian RFs client-sideAutoInstaller
       
   103 *  handle on File Manager. FileChangeListener is intended to be used by any object
       
   104 *  that wants listen Symbian file system events.
       
   105 *
       
   106 *  Auto Installer
       
   107 *  ==============
       
   108 *  ChspsAutoInstaller installs theme from given location. It is intended
       
   109 *  to be used by hspsThemeServer directly. AutoInstaller is initiated
       
   110 *  when FileChangeListener finds installable theme source on given
       
   111 *  location. Theme source is set during the SISX-package exctraction. 
       
   112 *  AutoInstaller is deployed by calling its function InstallThemeL with manifest-file 
       
   113 *  of the installable theme source set.
       
   114 *  AutoInstaller deploys ChspsInstallationHandler. ChspsInstallationHandler
       
   115 *  is asynchronous object, there for AutoInstaller is asynchronous object
       
   116 *  as well capable to deploy asynchronous installation.
       
   117 *  When installation ends, AutoInstaller calls its observer with 
       
   118 *  ThspsServiceCompletedMessage-type parameter. Observer is given on
       
   119 *  initialising of AutoInstaller and it must be ChspsThemeServer-type.
       
   120 *  AutoInstaller have functions to get ODT-header of successfully installed
       
   121 *  theme and ChspsResult-typed object expressing errors in unsuccessful cases.   
       
   122 *
       
   123 *  Security Enforcer
       
   124 *  =================
       
   125 *  ChspsSecurityEnforcer performs all security related functions in Xuikon
       
   126 *  Application Theme Management services.
       
   127 *  These functions are the following:
       
   128 *  - locking policy functionality,
       
   129 *  - style locking policy functionality,
       
   130 *  - control user access on service request, and
       
   131 *  - validate content of user queries.
       
   132 *
       
   133 *  Performance accelerators
       
   134 *  ************************
       
   135 *
       
   136 *  HeaderListCache
       
   137 *  ---------------
       
   138 *  To speed up serving the theme request operations initiated by Rendering 
       
   139 *  Engine in theme usage cases, hspsThemeServer maintains cache of the header
       
   140 *  information of the themes stored in Definition Repository. When installation
       
   141 *  occurs, cache is updated. First time the cache is updated when hspsThemeServer
       
   142 *  starts - server is started by system starter service. This quaranties
       
   143 *  that cache is up to date and hit will occur on the very first access. 
       
   144 *  Cache is updated also by MaintenanceHandler and ClientRequestHandler on 
       
   145 *  the cases where content of repository is affected.
       
   146 * 
       
   147 *  Pre-initialized objects
       
   148 *  -----------------------
       
   149 *  hspsThemeServer speeds up the performance also by pre-initialized objects 
       
   150 *  which it passes to ChspsClientRequestHandler when one is initiated on new 
       
   151 *  Client Request Service server session. These objects are the following:
       
   152 *  - ChspsDefinitionRepository
       
   153 *  - CRepository for the KhspsThemeStatusRepositoryUid  {0x10207342} 
       
   154 *
       
   155 *
       
   156 */
       
   157 
       
   158 
       
   159 #ifndef __hspsTHEMESERVER_H__
       
   160 #define __hspsTHEMESERVER_H__
       
   161 
       
   162 #include <e32base.h>
       
   163 #include <abclient.h>
       
   164 
       
   165 #include "hspsfilechangelistener.h"
       
   166 #include "hspscenreplistener.h"
       
   167 #if defined(WINSCW) || defined(__WINS__)
       
   168 #include "hspsfamilylistener.h"
       
   169 #endif // defined(WINSCW)
       
   170 #include "hspsthememanagement.h"
       
   171 #include "hspsodt.h"
       
   172 #include "hspsdefinitionrepository.h"
       
   173 #include "hspsbrobserver.h"
       
   174 #include "hspsbrhandler.h"
       
   175 
       
   176 #include "hsps_builds_cfg.hrh"
       
   177 
       
   178 /** hspsThemeServer name: */
       
   179 _LIT(KhspsThemeServerName,"hspsthemeserver");
       
   180 
       
   181 /** Supported manifest version */
       
   182 _LIT(KhspsSupportedManifestVersion,"1.0");
       
   183 
       
   184 /** hspsThemeServer Uid3 = SECUREID. */
       
   185 const TUid KhspsThemeServerUid3 = {0x200159C0}; //old uid 0x10207254};
       
   186 
       
   187 /** 
       
   188 *   KhspsThemeServerMajorVersionNumber, KhspsThemeServerMinorVersionNumber, 
       
   189 *   and KhspsThemeServerBuildVersionNumber.
       
   190 *   These constants define a version to be given for creating a session 
       
   191 *   with the hspsThemeServer.
       
   192 */
       
   193 const TUint KhspsThemeServerMajorVersionNumber=1;
       
   194 const TUint KhspsThemeServerMinorVersionNumber=0;
       
   195 const TUint KhspsThemeServerBuildVersionNumber=0;
       
   196 
       
   197 /*
       
   198 *  KDefaultMessageSlots. Number of hspsThemeServer message slots.
       
   199 *  Server slots allocation rules: 1 for synchronous request, 1 for each
       
   200 *  concurrent outstanding asynchronous requests and 1 for each cancellation
       
   201 *  => 3 in this case.
       
   202 */
       
   203 const TInt KDefaultMessageSlots = 3;
       
   204 
       
   205 // Forward declarations.
       
   206 class ChspsDefinitionRepository;
       
   207 class ChspsDefinitionEngineInterface;
       
   208 class CRepository;
       
   209 class ChspsSecurityEnforcer;
       
   210 class ChspsRomInstaller;
       
   211 class ChspsAutoInstaller;
       
   212 
       
   213 #ifdef HSPS_LOG_ACTIVE
       
   214 class ChspsLogBus;
       
   215 #endif
       
   216 
       
   217 // Keys for the Central Repository
       
   218 const TInt KCenrepKeyLang                = 100000001;      // Device language from previous startup
       
   219 const TInt KCenrepKeyPostRFS             = 100000002;      // Holds information whether the post RFS initializations have been done 
       
   220 const TInt KCenrepKeyCheckConf           = 100000003;      // Holds information whether the configuration states must be checked 
       
   221 const TInt KCenrepKeyAccessControlList   = 100000004;      // Holds information about security access control list
       
   222 
       
   223 const TInt KCenRepBufferSize = 255;   // Control Access List length
       
   224 
       
   225 /*
       
   226 * Server's policy.
       
   227 */
       
   228 
       
   229 /* Total number of ranges */
       
   230 const TUint hspsThemeRangeCount = 4;
       
   231 
       
   232 /* Definition of the ranges of IPC numbers */
       
   233 const TInt hspsThemeRanges[hspsThemeRangeCount] = 
       
   234         {
       
   235         EhspsInstallationBase, 	/* installation messages (0,1,2 ) */
       
   236         EhspsMaintenanceBase, 	/* maintenance messages (3,4,5,6,7,8) */
       
   237         EhspsClientRequestBase, /* client request messages (9,10,11,12,13) */
       
   238         EhspsNotSupported, 		/* and up; non implemented function end of range check ; ENotSupported */ 
       
   239         }; 
       
   240 
       
   241 /* Policy to implement for each of the above ranges */       
       
   242 const TUint8 hspsThemeElementsIndex[hspsThemeRangeCount] = 
       
   243         {
       
   244         CPolicyServer::ECustomCheck, //applies to 0th range
       
   245         CPolicyServer::ECustomCheck, //applies to 1st range
       
   246         CPolicyServer::ECustomCheck, //applies to 2nd range
       
   247         CPolicyServer::ENotSupported //applies to 3rd range (out of range IPC)
       
   248         };
       
   249 
       
   250 /* Specific capability checks */
       
   251 const CPolicyServer::TPolicyElement hspsThemeElements[] = 
       
   252         {
       
   253         {_INIT_SECURITY_POLICY_C1(ECapabilityReadUserData), CPolicyServer::EFailClient},  
       
   254         //policy "0"; fail call if ReadUserData not present
       
   255         {_INIT_SECURITY_POLICY_C1(ECapabilityTCB), CPolicyServer::EFailClient} 
       
   256         //policy "1"; fail call if TCB not present
       
   257         };
       
   258 
       
   259 /* Package all the above together into a policy */
       
   260 const CPolicyServer::TPolicy hspsThemePolicy =
       
   261         {
       
   262         CPolicyServer::EAlwaysPass, /* specifies all connect attempts should pass */
       
   263         hspsThemeRangeCount,  /* number of ranges */                                  
       
   264         hspsThemeRanges,  /* ranges array */
       
   265         hspsThemeElementsIndex, /* elements<->ranges index */
       
   266         hspsThemeElements,    /* array of elements */
       
   267         };
       
   268 
       
   269 // File filters related to imports folder
       
   270 _LIT( KFilterAllImportsV1, "*.dat");
       
   271 _LIT( KFilterAllAppImportsV1, "app_*.dat");
       
   272 _LIT( KFilterAllPluginImportsV1, "plugin_*.dat");
       
   273 _LIT( KFilterAllImportsV2, "*.*");
       
   274 
       
   275 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
       
   276 /** 
       
   277  * MShutdownObserver
       
   278  * Observer for automatic shutdown class.
       
   279  * 
       
   280  * @since S60 5.0  
       
   281  */
       
   282 class MShutdownObserver
       
   283     {
       
   284 public:
       
   285     /**
       
   286     * Notifies observer that shutdown is initiating.
       
   287     * 
       
   288     * @since S60 5.0
       
   289     */
       
   290     virtual void ShutdownInitiating() = 0;
       
   291     };
       
   292 
       
   293 /** 
       
   294  * CShutdown.
       
   295  * Auto shutdown class (standard pattern)
       
   296  * 
       
   297  * @since S60 5.0  
       
   298  */
       
   299 class CShutdown : public CTimer
       
   300     {    
       
   301 public:
       
   302     /**
       
   303     * Create new shutdown timer.
       
   304     * 
       
   305     * @since S60 5.0 
       
   306     * @param aObserver Shutdown observer.
       
   307     */    
       
   308     static CShutdown* NewL( MShutdownObserver& aObserver );
       
   309 
       
   310     /**
       
   311     * Start shutdown timer.
       
   312     * 
       
   313     * @since S60 5.0
       
   314     */        
       
   315     void Start();
       
   316   
       
   317 protected:
       
   318     /**
       
   319     * C++ constructor.
       
   320     *
       
   321     * @since S60 5.0  
       
   322     * @param aObserver Shutdown observer.
       
   323     */        
       
   324     CShutdown( MShutdownObserver& aObserver );    
       
   325     
       
   326     /**
       
   327     * Symbian 2nd phase constructor.
       
   328     * 
       
   329     * @since S60 5.0
       
   330     */        
       
   331     void ConstructL();
       
   332 
       
   333 private:
       
   334     /**
       
   335     * From CActive.
       
   336     */        
       
   337     void RunL();
       
   338     
       
   339 private:
       
   340     // Shutdown delay.
       
   341     enum { KhspsShutdownDelay = 2000000 };
       
   342     
       
   343     // Shutdown observer.
       
   344     MShutdownObserver& iObserver;
       
   345   };
       
   346 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_
       
   347 
       
   348 // States of the auto installer
       
   349 enum TAutoInstallerStates
       
   350     {
       
   351     EAutoInstallerStateIdle = 0,
       
   352     EAutoInstallerStateInstall = 1,
       
   353     EAutoInstallerUninstall = 2
       
   354     };
       
   355 
       
   356 // Operations for header cache updates
       
   357 enum ThspsCacheOperations 
       
   358     {
       
   359     EhspsCacheAddHeader,
       
   360     EhspsCacheRemoveHeader
       
   361     };
       
   362 
       
   363 // Backup states
       
   364 enum ThspsBRStates 
       
   365     {
       
   366     EhspsBRNormal = 0,
       
   367     EhspsBRBackup,
       
   368     EhspsBRRestore
       
   369     };
       
   370 
       
   371 
       
   372 /**
       
   373  * @ingroup group_hspsserver
       
   374  * ChspsThemeServer. 
       
   375  * @since S60 5.0
       
   376  **/
       
   377 class ChspsThemeServer : public CPolicyServer, 
       
   378                        public MhspsFileChangeObserver,
       
   379                        public MhspsDefinitionRepositoryObserver,
       
   380                        public MhspsCenRepObserver
       
   381 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
       
   382                        , public MShutdownObserver
       
   383 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_         
       
   384 #if defined(WINSCW) || defined(__WINS__)                         
       
   385                        , public MhspsFamilyObserver
       
   386 #endif // defined(WINSCW)
       
   387 
       
   388     {
       
   389 public:
       
   390 	
       
   391     /**
       
   392     * NewLC
       
   393     * @since S60 3.1
       
   394     */
       
   395     static CServer2* NewLC();
       
   396     
       
   397     /**
       
   398     * AddSession
       
   399     * @since S60 3.1
       
   400     */
       
   401     void AddSession();
       
   402     
       
   403     /**
       
   404     * DropSession
       
   405     * @since S60 3.1
       
   406     */
       
   407     void DropSession();
       
   408     
       
   409 public: // public functions
       
   410 	
       
   411     /**
       
   412     * UpdateHeaderListCacheL
       
   413     * Re-scans the file system under the Plug-in Repository. 
       
   414     * Execution is slow and should be used only when absolutely required. 
       
   415     * Updates headerlist cache
       
   416     * @since S60 5.0
       
   417     */
       
   418     void UpdateHeaderListCacheL();
       
   419     
       
   420     /**
       
   421      * Updates the header list cache based on the provided ODT information.
       
   422      * Should be preferred over the previous API.     
       
   423      * @since S60 5.0
       
   424      * @param aOperation is an enumeration of the cache operations
       
   425      * @param aRootUid is an UID of the application/interface
       
   426      * @param aProviderUid is an UID of the provider
       
   427      * @param aConfUid is an UID of the plug-in configuration
       
   428      */
       
   429     TInt UpdateHeaderListCache(    
       
   430         ThspsCacheOperations aOperation,
       
   431         const TInt aRootUid,
       
   432         const TInt aProviderUid,
       
   433         const TInt aConfigurationUid );
       
   434     
       
   435     /**
       
   436     * CleanupTemporaryFilesL
       
   437     * Cleans temporary files
       
   438     * @since S60 3.1
       
   439     */
       
   440     void CleanupTemporaryFilesL(TInt secureId = 0);
       
   441     
       
   442     /**
       
   443     * IncreaseRequestClientCount
       
   444     * Increases count of client requests
       
   445     * @since S60 5.0
       
   446     */
       
   447     void IncreaseRequestClientCount();
       
   448     
       
   449     /**
       
   450     * DecreaseRequestClientCount
       
   451     * Decreases count of client requests
       
   452     * @since S60 5.0
       
   453     */
       
   454     void DecreaseRequestClientCount();
       
   455         
       
   456     /**
       
   457     * HandleAutoInstallerEvent
       
   458     * Handles autoinstaller events
       
   459     * @since S60 3.1
       
   460     */
       
   461     void HandleAutoInstallerEvent( ThspsServiceCompletedMessage aMsg );
       
   462             
       
   463     /**
       
   464     * DefinitionRepository
       
   465     * @since S60 3.1
       
   466     */
       
   467     ChspsDefinitionRepository& DefinitionRepository();
       
   468     
       
   469     /**
       
   470     * SecurityEnforcer
       
   471     * @since S60 3.1
       
   472     */
       
   473     ChspsSecurityEnforcer& SecurityEnforcer();
       
   474     
       
   475     /**
       
   476     * CentralRepository
       
   477     * @since S60 3.1
       
   478     */
       
   479     CRepository& CentralRepository();
       
   480     
       
   481     /**
       
   482     * DeviceLanguage
       
   483     * Returns device language
       
   484     * @since S60 3.1
       
   485     */
       
   486     TLanguage DeviceLanguage();
       
   487         
       
   488     /**
       
   489     * HeaderListCache
       
   490     * Returns headerlist cache
       
   491     * @since S60 3.1
       
   492     */
       
   493     CArrayPtrSeg<ChspsODT>& HeaderListCache();
       
   494     
       
   495     /**
       
   496     * GetConfigurationL
       
   497     * Retrieves a configuration with the provided UIDs.
       
   498     * @since S60 5.0    
       
   499     * @param aInterfaceUid An uid of the interface or application (e.g. AI3, Java etc), optional.
       
   500     * @param aConfigurationUid An uid of the plugin configuration     
       
   501     * @param aRetrievedODT Retrieved configuration
       
   502     * @return KErrNone if operation succeeded
       
   503     */
       
   504     TInt GetConfigurationL(
       
   505 		const TInt aInterfaceUid,
       
   506 		const TInt aConfigurationUid,
       
   507 		ChspsODT& aRetrievedODT );
       
   508 
       
   509     /**
       
   510     * GetConfigurationHeaderL
       
   511     * Retrieves a configuration header matching the search criteria
       
   512     * @since S60 5.0    
       
   513     * @param aSearchMask ODT header defining search criteria
       
   514     * @param aConfHeader Found ODT header
       
   515     * @param aPos Start/Found position
       
   516     */
       
   517     void GetConfigurationHeader(
       
   518         ChspsODT& aSearchMask,
       
   519         ChspsODT*& aConfHeader,
       
   520         TInt& aPos );
       
   521     
       
   522     /**
       
   523      * Localizes an ODT.
       
   524      * Testing: change first two digits from \epoc32\RELEASE\WINSCW\udeb\
       
   525      * Z\resource\BootData\Languages.txt file and reboot the emulator.     
       
   526      * @since S60 5.0
       
   527      * @param aEngine is a service for replacing DTD entities in XML.
       
   528      * @param aOdt is an ODT instance to be localized.     
       
   529      * @return ETrue if the ODT was successfully localized
       
   530      */
       
   531     TBool LocalizeL( 
       
   532 		ChspsDefinitionEngineInterface& aEngine,
       
   533 		ChspsODT& aOdt );
       
   534     
       
   535     /**
       
   536      * Parses name of a manifest from the provided import's name.                      
       
   537      * @since S60 5.0
       
   538      * @param aImportFile is a name of the import to be parsed
       
   539      * @param aPath is a path from which the import should be found
       
   540      * @return descriptor holding name of the manifest or NULL     
       
   541      */
       
   542     HBufC* GetManifestFromImportLC(
       
   543         const TDesC& aImportFile,
       
   544         const TDesC& aPath );
       
   545 
       
   546     /**
       
   547      * Check the installed configurations
       
   548      * @param aAppUid Application UID which configurations are checked
       
   549      * @since S60 5.0
       
   550      */
       
   551     void CheckConfigurationL(
       
   552         const TInt aAppUid );
       
   553 
       
   554     /**
       
   555      * Reinstalls defined configuration
       
   556      * @param aAppUid Application UID which configuration is reinstalled
       
   557      * @param aConfUid Configuration UID of reinstalled configuration
       
   558      * @since S60 5.0
       
   559      */
       
   560     void ReinstallConfL(
       
   561         TInt aAppUid,
       
   562         TInt aConfUid );
       
   563 
       
   564     /**
       
   565      * Handles received backup event
       
   566      * @since S60 5.0
       
   567      * @param aEvent Backup event
       
   568      */
       
   569     void HandleBREventL( TInt aEvent );
       
   570 
       
   571     /**
       
   572      * Prepares backup data for passive backup
       
   573      * @since S60 5.0
       
   574      */
       
   575     void CreateBackupDataL();
       
   576 
       
   577 
       
   578     /**
       
   579      * Check the installed plugin is used in some application configuration
       
   580      * @since S60 5.0
       
   581      * @param aPluginUid Plugin UID of installed configuration
       
   582      */
       
   583    TInt CheckInstalledPluginUsageL( const TInt aPluginUid );
       
   584 
       
   585     /**
       
   586      * Check if given plugin is in header cache.
       
   587      * 
       
   588      * @since S60 5.0
       
   589      * @param aPluginUid Plugin UID to search from header cache.
       
   590      */    
       
   591     TBool PluginInHeaderCache( const TUid aPluginUid );
       
   592 
       
   593    /**
       
   594     * Cleanup server resources. This method is called when server is been
       
   595     * shut down and active scheduler is still installed.
       
   596     * 
       
   597     * @since S60 5.0
       
   598     */
       
   599    void Cleanup();
       
   600    
       
   601    /**
       
   602     * Activates provided application configuration. 
       
   603     * @param aSetMask Identifies an application configuration which is to be activated.
       
   604     * @param aOdt Activated application configuration
       
   605     */
       
   606    TInt ActivateThemeL(
       
   607            const ChspsODT& aSetMask, 
       
   608            ChspsODT& aOdt );
       
   609 
       
   610    /**
       
   611     * Retrieves active application configuration from Central Repository.
       
   612     * @since S60 5.0
       
   613     * @param aAppUid Identifies the application
       
   614     * @param aOdt Contains currently active application configuration
       
   615     */
       
   616    TInt GetActivateAppConfigurationL(
       
   617            const TInt aAppUid, 
       
   618            ChspsODT& aOdt );
       
   619    
       
   620    /**
       
   621     * Gets family information from an active application configuration.
       
   622     * @since S60 5.0
       
   623     * @param aAppUid Identifies the application    
       
   624     * @returns The active family
       
   625     */
       
   626    TUint32 GetActiveFamilyL( 
       
   627            const TInt aAppUid );      
       
   628    
       
   629 public: // from MhspsFileChangeObserver
       
   630 	
       
   631     /**
       
   632     * HandleFileSystemChange
       
   633     * Handles change of filesystem
       
   634     * @since S60 3.1
       
   635     */
       
   636     void HandleFileSystemChange();
       
   637     
       
   638     /**
       
   639     * HandleRepositoryChange
       
   640     * Handles change of repository
       
   641     * @since S60 3.1
       
   642     */
       
   643     inline void HandleRepositoryChange() {};
       
   644 
       
   645 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_
       
   646 public: // From MShutdownObserver
       
   647     /**
       
   648     * From MShutdownObserver.
       
   649     */
       
   650     void ShutdownInitiating();    
       
   651 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_
       
   652     
       
   653     
       
   654 public: // from MhspsDefinitioRepositoryObserver
       
   655 	
       
   656     /**
       
   657     * HandleDefinitionRespositoryEvent
       
   658     * Handles change events received from definition repository
       
   659     * @since S60 3.1
       
   660     */
       
   661     TBool HandleDefinitionRespositoryEvent( ThspsRepositoryInfo aRepositoryInfo );
       
   662     
       
   663 public: // from MhspsCenRepObserver
       
   664          
       
   665     void HandleCenRepChangeL( const TUint32 aId );    
       
   666      
       
   667 #if defined(WINSCW) || defined(__WINS__)    
       
   668 public: // from MshspFamilyObserver    
       
   669     TBool HandleFamilyChangeL( const ThspsFamily aNewFamily );
       
   670 #endif // defined(WINSCW)
       
   671     
       
   672 private:
       
   673 	
       
   674     /**
       
   675     * ChspsThemeServer
       
   676     * @since S60 3.1
       
   677     */
       
   678     ChspsThemeServer();
       
   679     
       
   680     /**
       
   681     * ~ChspsThemeServer
       
   682     * @since S60 3.1
       
   683     */
       
   684     ~ChspsThemeServer();
       
   685     
       
   686     /**
       
   687     * ConstructL
       
   688     * @since S60 3.1
       
   689     */
       
   690     void ConstructL();
       
   691     
       
   692     /**
       
   693     * NewSessionL
       
   694     * @since S60 3.1
       
   695     */
       
   696     CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
       
   697     
       
   698     /**
       
   699     * ComparePaths
       
   700     * @since S60 3.1
       
   701     */
       
   702     TBool ComparePaths(const ChspsODT& aOldHeader, const ChspsODT& aNewHeader);
       
   703     
       
   704     /**
       
   705     * GetHeaderListL
       
   706     * Gets current headerlist from filesystem
       
   707     * @param aHeaderList Destination for read headerlists from filesystem  
       
   708     * @param aSearchMask SearchMask to use when reading headerlists from filesystem  
       
   709     * @since S60 3.1
       
   710     */
       
   711     void GetHeaderListL(CArrayPtrSeg<ChspsODT>& aHeaderList, const ChspsODT& aSearchMask );
       
   712                    
       
   713     /**
       
   714     * CheckActiveThemesL
       
   715     * Check active themes from the central repository and if needed open path info file for them
       
   716     * @since S60 3.1
       
   717     */               
       
   718     void CheckActiveThemesL();
       
   719     
       
   720     //From CPolicyServer
       
   721     /**
       
   722     * CustomSecurityCheckL
       
   723     * @since S60 3.1
       
   724     */
       
   725     CPolicyServer::TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction,
       
   726                               TSecurityInfo& aMissing);
       
   727                               
       
   728     /**
       
   729     * HandleFileSystemChangeL
       
   730     * Does the actual filesystem change handling
       
   731     * @since S60 3.2
       
   732     */
       
   733     void HandleFileSystemChangeL(); 
       
   734 
       
   735     /**
       
   736     * RunAutoInstaller
       
   737     * Runs auto installer
       
   738     * @since S60 5.0
       
   739     */    
       
   740     TBool RunAutoInstaller( TAutoInstallerStates aState );
       
   741 
       
   742     /**
       
   743     * StopAutoInstaller
       
   744     * Stops auto installer and does house keeping after installation
       
   745     * @since S60 3.2
       
   746     */        
       
   747     void StopAutoInstaller();
       
   748    
       
   749    /**
       
   750     * HandleThemeUpgrade;
       
   751     * Handles the SIS theme upgrade
       
   752     */        
       
   753     void HandleThemeUpgradeL();
       
   754     
       
   755     /**
       
   756     * Checks whether the device language has been changed and updates 
       
   757 	* configurations accordingly
       
   758 	*/
       
   759     void HandleLanguageChangeL();
       
   760     
       
   761     /**
       
   762      * Localizes ODT files according to the device language.
       
   763      * @since S60 5.0
       
   764      */
       
   765     void LocalizeConfigurationsL();
       
   766     
       
   767     /**     
       
   768      * Localizes an application configuration with a device language. 
       
   769      * This function is used by the LocalizeL service.
       
   770      * @since S60 5.0
       
   771      * @param aEngine is a service for replacing DTD entities in XML.
       
   772      * @param aRequestedLanguage is the requsted language
       
   773      * @return ETrue if all the application and plugin configurations were localized
       
   774      */
       
   775     TBool LocalizeApplicationConfigurationL(
       
   776         ChspsDefinitionEngineInterface& aEngine,
       
   777         ChspsODT& aOdt,
       
   778         const TLanguage aRequestedLanguage );
       
   779     
       
   780     /**
       
   781      * Localizes a plugin configuration with a device language. 
       
   782      * This function is used by the LocalizeL service.
       
   783      * @since S60 5.0
       
   784      * @param aEngine is a service for replacing DTD entities in XML.
       
   785      * @param aRequestedLanguage is the requsted language
       
   786      * @param aPluginUid is > 0 when LocalizeApplicationConfigurationL() is used 
       
   787      * @return ETrue if the plugin configuration was localized
       
   788      */
       
   789     TBool LocalizePluginConfigurationL(
       
   790         ChspsDefinitionEngineInterface& aEngine,
       
   791         ChspsODT& aOdt,
       
   792         const TLanguage aRequestedLanguage,
       
   793         TInt aPluginUid );
       
   794                 
       
   795     /**
       
   796      * Handles installation of ROM based manifest files when a Restore Factory Settings (RFS)
       
   797      * operation has been executed (controlled via the Central Repository).    
       
   798      * This function is executed at bootup when the server starts. 
       
   799      * @since S60 5.0 
       
   800      */
       
   801     void HandleRomInstallationsL();
       
   802     
       
   803     /**
       
   804      * Executes installation of manifest files from the ROM drive.
       
   805      * @since S60 5.0 
       
   806      */
       
   807     void InstallManifestsFromRomDriveL();
       
   808                                 
       
   809     /**
       
   810      * V2 method for finding manifest files from Z\private\200159C0\install subfolders,
       
   811      * these folders should have a "hsps" subfolder.
       
   812      * Appends iManifestFiles array. 
       
   813      * @since S60 5.0     
       
   814      * @param aPluginFolders holds names of the plugin folders which are V2 based
       
   815      */
       
   816     void FindRomInstallationsV2L(        
       
   817         RPointerArray<HBufC>& aPluginFolders );
       
   818     
       
   819     /**
       
   820      * Initiates uninstallation of a manifest file located under the imports folder.
       
   821      * @since S60 5.0
       
   822      * @param aFilelist is a list of dat files under the imports folder or NULL 
       
   823      */
       
   824     void UninstallImport( 
       
   825 		const CDir* aFilelist );
       
   826                 
       
   827     /**
       
   828      * Installs new configuration based on the information in imports name.
       
   829      * @since S60 5.0
       
   830      * @param aFilelist is a list of dat files to be parsed under the imports folder
       
   831      */    
       
   832     void InstallImportsL( 
       
   833 		const CDir& aFilelist );        
       
   834     
       
   835     /**
       
   836      * Handles installation/uninstallation of imported configurations.
       
   837      * A file filter controls which type of configurations are to be handled. 
       
   838      * @since S60 5.0
       
   839      * @param aFilePrefix is a prefix for finding either plugin or application configuration imports.
       
   840      */
       
   841     void HandleConfigurationImportsL(
       
   842 		const TDesC& aFilePrefix );    
       
   843     
       
   844     /**
       
   845      * 
       
   846      * @since S60 5.0
       
   847      * @param aAppUid is an UID of the application
       
   848      */
       
   849     void UnlockSisxImportL( 
       
   850             const TUint32 aAppUid );
       
   851     
       
   852     /**
       
   853      * 
       
   854      * @since S60 5.0
       
   855      * @param aAppUid is an UID of the application
       
   856  	 * @param aConfUid is an UID of the active configuration
       
   857      */
       
   858     void LockSisxImportL( 
       
   859             const TUint32 aAppUid,
       
   860 			const TInt aConfUid );
       
   861 
       
   862     /**
       
   863     * GetDeviceLanguage
       
   864     * @since S60 5.0
       
   865     */
       
   866     TLanguage GetDeviceLanguage();
       
   867     
       
   868     /**     
       
   869      * Retrieves a list of headers matching a iCacheMask search mask.
       
   870      * @since S60 5.0
       
   871      * @param aHeaderList is a list of headers found from the Plug-in Repository
       
   872      * @return KErrNone if operation was successfull
       
   873      */
       
   874     TInt DoUpdateHeaderListCache(
       
   875             CArrayPtrSeg<ChspsODT>& aHeaderList );       
       
   876 
       
   877     
       
   878     /**
       
   879      * Adds specific header to the cache.
       
   880      * An alternative to UpdateHeaderListCacheL API for updating the header 
       
   881      * cache with a minimum performance hit. 
       
   882      * @since S60 5.0
       
   883      * @param aRootUid is an UID of the application/interface
       
   884      * @param aProviderUid is an UID of the provider
       
   885      * @param aConfUid is an UID of the plug-in configuration
       
   886      */
       
   887     void HeaderCacheAddL(
       
   888             const TInt aRootUid,
       
   889             const TInt aProviderUid,
       
   890             const TInt aConfigurationUid );
       
   891     
       
   892     /**
       
   893      * Removes specific header from the cache.
       
   894      * An alternative to UpdateHeaderListCacheL API for updating the header 
       
   895      * cache with a minimum performance hit. 
       
   896      * @since S60 5.0
       
   897      * @param aRootUid is an UID of the application/interface
       
   898      * @param aProviderUid is an UID of the provider
       
   899      * @param aConfUid is an UID of the plug-in configuration
       
   900      */
       
   901     TInt HeaderCacheRemove( 
       
   902             const TInt aRootUid,
       
   903             const TInt aProviderUid,
       
   904             const TInt aConfigurationUid );   
       
   905 
       
   906     /**
       
   907      * Handles backup events in EhspsBRNormal backup state
       
   908      * @since S60 5.0
       
   909      * @param aEvent is a received backup event
       
   910      */
       
   911     void HandleBRNormalStateL(
       
   912         TInt aEvent );
       
   913 
       
   914     /**
       
   915      * Handles backup events in EhspsBRBackup backup state
       
   916      * @since S60 5.0
       
   917      * @param aEvent is a received backup event
       
   918      */
       
   919     void HandleBRBackupStateL(
       
   920         TInt aEvent );
       
   921 
       
   922     /**
       
   923      * Handles backup events in EhspsBRRestore backup state
       
   924      * @since S60 5.0
       
   925      * @param aEvent is a received backup event
       
   926      */
       
   927     void HandleBRRestoreStateL(
       
   928         TInt aEvent );
       
   929 
       
   930     /**
       
   931      * Creates active backup and restore handler
       
   932      * @since S60 5.0
       
   933      * @param aEvent is a received backup event
       
   934      */
       
   935     void CreateBRHandlerL(
       
   936         TInt aEvent );
       
   937 
       
   938     /**
       
   939      * Deletes active backup and restore handler
       
   940      * @since S60 5.0
       
   941      */
       
   942     void DeleteBRHandler();
       
   943 
       
   944     /**
       
   945      * Enables autoinstallations
       
   946      * @since S60 5.0
       
   947      */
       
   948     void EnableAutoInstallationL();
       
   949 
       
   950     /**
       
   951      * Disable autoinstallations
       
   952      * @since S60 5.0
       
   953      */
       
   954     void DisableAutoInstallation();
       
   955 
       
   956     /**
       
   957      * Installs restored configurations from backup/import folder
       
   958      * @since S60 5.0
       
   959      */
       
   960     void RestoreImportedConfigurationsL();
       
   961 
       
   962     /**
       
   963      * Restores application configurations from backup/themes folder
       
   964      * @since S60 5.0
       
   965      */
       
   966     void RestoreApplicationConfigurationsL();
       
   967 
       
   968     /**
       
   969      * Validates restored application configuration
       
   970      * @since S60 5.0
       
   971      * @param aOdt is reference to application configuration to be validated
       
   972      */
       
   973     void ValidateRestoredConfigurationL(
       
   974         ChspsODT& aOdt );
       
   975 
       
   976     /**
       
   977      * Restore configuration
       
   978      * @since S60 5.0
       
   979      * @param aOdt is reference to application configuration to be restored
       
   980      */
       
   981     void RestoreConfigurationL(
       
   982         ChspsODT& aOdt );
       
   983     
       
   984 #if defined(WINSCW) || defined(__WINS__)    
       
   985 
       
   986     /**
       
   987      * Executed at startup to activate root configurations which were designed
       
   988      * for the current resolution.
       
   989      * @since S60 5.0 
       
   990      */
       
   991     void ActivateRootConfigurationsL();
       
   992            
       
   993 #endif // defined(WINSCW)
       
   994     
       
   995     
       
   996 private:
       
   997     TInt iSessionCount;
       
   998     
       
   999 #ifdef _hsps_SERVER_SHUTDOWN_ENABLED_    
       
  1000     CShutdown* iShutdown;
       
  1001 #endif // _hsps_SERVER_SHUTDOWN_ENABLED_
       
  1002 
       
  1003     /* 
       
  1004     * iRequestClientCount counts the number of RequestClientHandler instances
       
  1005     * when this number is 0, no resource file access exist and the temporary resource
       
  1006     * file instances can be removed safely
       
  1007     */
       
  1008     TInt iRequestClientCount;
       
  1009       
       
  1010     // Contents of the header cache
       
  1011     CArrayPtrSeg<ChspsODT>* iHeaderListCache;
       
  1012     TBool iHeaderListPending;
       
  1013            
       
  1014     RFs iFsSession;
       
  1015     ChspsDefinitionRepository* iDefinitionRepository;
       
  1016     CRepository* iCentralRepository;
       
  1017     ChspsSecurityEnforcer* iSecurityEnforcer;
       
  1018     ChspsFileChangeListener* iFileChangeListener;
       
  1019     
       
  1020     // Active device language
       
  1021     TLanguage iDeviceLanguage;
       
  1022         
       
  1023     ChspsODT* iCacheMask;
       
  1024     
       
  1025     // Installation handler for ROM imports 
       
  1026     ChspsRomInstaller* iRomInstaller;
       
  1027     
       
  1028     // Installation handler for SISX imports
       
  1029     ChspsAutoInstaller* iAutoInstaller;
       
  1030                                
       
  1031     // Array of installable *.dat files under the imports folder
       
  1032     RPointerArray<HBufC> iInstallableSisxThemes;
       
  1033     
       
  1034     // Array of installed *.dat files under the imports folder
       
  1035     RPointerArray<HBufC> iInstalledSisxThemes;        
       
  1036     
       
  1037     // Array of installable manifest files
       
  1038     RPointerArray<HBufC> iManifestFiles;
       
  1039     
       
  1040     // Index of a manifest in autoinstallation
       
  1041     TInt iCurrentManifestFile;
       
  1042     
       
  1043     // State of the SISX installer
       
  1044     TInt iAutoInstallerState;
       
  1045     
       
  1046     // Index of the theme to be removed
       
  1047     TInt iThemeIndexToRemove;
       
  1048     
       
  1049 	// File locks for preventing uninstallation of active SISX configurations
       
  1050     RFile iFileAS;
       
  1051     RFile iFileAI;
       
  1052     RFile iFileLT;
       
  1053     
       
  1054     // Pointer to Central Repository Listener        
       
  1055     ChspsCenRepListener* iCenRepListener;
       
  1056 
       
  1057     // Pointer to backup event listener
       
  1058     CHSPSBRObserver* iBRObserver;
       
  1059 
       
  1060     // Backup state
       
  1061     ThspsBRStates iBRState;
       
  1062 
       
  1063     // Active backup client
       
  1064     conn::CActiveBackupClient* iActiveBackupClient;
       
  1065     
       
  1066     // Backup handler
       
  1067     CHSPSBRHandler* iBRHandler;
       
  1068     
       
  1069 
       
  1070 #if defined(WINSCW) || defined(__WINS__)
       
  1071     // Listener for resolution and orientation changes
       
  1072     ChspsFamilyListener* iFamilyListener;
       
  1073 #endif // defined(WINSCW)    
       
  1074     
       
  1075 #ifdef HSPS_LOG_ACTIVE    
       
  1076     /**
       
  1077      * Log bus.
       
  1078      */        
       
  1079     ChspsLogBus* iLogBus;
       
  1080 #endif    
       
  1081     };
       
  1082 
       
  1083 #endif //__hspsTHEMESERVER_H__