homescreenpluginsrv/hspsmanager/inc/hspsclientrequesthandler.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     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:  ChspsClientRequestHandler is a server-side implementation for
       
    15 *                retrieving configurations from the HSPS's Definition Repository.
       
    16 *                Configurations are binary presentations of a manifest, XML and
       
    17 *                resource files - actually, instances of the hspsODT class.
       
    18 *                Due to perfomance aspects, instead of the binary files, a file 
       
    19 *                handle is returned over the IPC channel, and on client side, 
       
    20 *                the handle is then used for internalizing the requested 
       
    21 *                configuration.
       
    22 *                  
       
    23 *
       
    24 */
       
    25 
       
    26 
       
    27 #ifndef __hspsCLIENTREQUESTHANDLER_H__
       
    28 #define __hspsCLIENTREQUESTHANDLER_H__
       
    29 
       
    30 #include <e32base.h>
       
    31 
       
    32 #include "hspscenreplistener.h"
       
    33 #include "hspsreqnotifparam.h"
       
    34 
       
    35 class MhspsClientRequestService;
       
    36 class ChspsSecurityEnforcer;
       
    37 class CRepository;
       
    38 class ChspsODT;
       
    39 class ChspsFileAccess;
       
    40 class ChspsResource;
       
    41 class ChspsThemeServer;
       
    42 class ChspsResult;
       
    43 class ChspsRequestNotifcationParams;
       
    44 
       
    45 #ifdef HSPS_LOG_ACTIVE
       
    46 class ChspsLogBus;
       
    47 #endif
       
    48 
       
    49 /**
       
    50 * 
       
    51 *  Class ChspsClientRequestHandler. ChspsClientRequestHandler performs all Xuikon Client Request Service 
       
    52 *  related functionality of Xuikon Theme Mangement Service APIs.
       
    53 *  Xuikon Client Request Service API is intended to serve Rendering Engines with Application Themes 
       
    54 *  and their associated resources. ChspsClientRequestHandler will provide access to 
       
    55 *  Xuikon's Application Theme database maintained by Xuikon Definition Repository.
       
    56 *  Definition Repository maintains Application Themes in ChspsODT-objects. 
       
    57 *  Themes can have resources like bitmaps etc. Resources can be accessed through this API also. 
       
    58 *  Every individual resource has corresponding ChspsResource-object. hspsResource-object is delivered 
       
    59 *  to the client side in a resource list which is associated to the theme. 
       
    60 *  Resource list is included in ODT as well as DOM-document which contains UI-definition. 
       
    61 *  There can be only one theme activated for a specific application at one time. 
       
    62 *  The information of activation of themes is stored in Symbian Central Repository -object. 
       
    63 *  The Central Repository is requested on every theme request that Rendering Engine commences. 
       
    64 *
       
    65 *  Class inheritance:
       
    66 *  ==================
       
    67 *  ChspsClientRequestHandler derives CTimer for active timer functionality. It implements 
       
    68 *  MhspsClientRequestService-interface for Xuikon Client Request Service API functionality,
       
    69 *  and MhspsDefinitionRepositoryObserver for listening to the definition repository events.  
       
    70 *
       
    71 *  Functionality:
       
    72 *  ==============
       
    73 *  To initiate theme usage, Rendering Engine must call hspsGetODT().
       
    74 *  
       
    75 *  hspsGetODT() returns one of the following codes:
       
    76 *  - EhspsGetODTSuccess. Theme was received successfully. Client can start its rendering.
       
    77 *  - EhspsGetODTFailed. Theme was not received. Check Additional Return Code in hspsResult-object
       
    78 *   for the exact reason. Theme load can fail for e.g. for missing rights.
       
    79 *  - EhspsGetODTLowMemoryStrategy. Possible memory low to create chunk. Client should
       
    80 *                                implement some low memory strategy. In version 3.1, 
       
    81 *                                the low-memory stategy is use direct file handle in
       
    82 *                                accessing ODT. System can be configured to use
       
    83 *                                low-memory strategy only.
       
    84 *
       
    85 *  After receiving the theme, Rendering Engine may subscribe the theme related events. 
       
    86 *  These events may concern the changes of the theme status (meaning that some other theme is 
       
    87 *  activated), or that the theme is updated. In both cases, client should reload the theme and do 
       
    88 *  the rendering again. To act as a subscriber of these events, client must implement the interface
       
    89 *  MhspsClientRequestServiceObserver. Subscription is applied by calling hspsGetODTUpdate(). 
       
    90 *  This function returns immediately one of the following codes:
       
    91 *  - EhspsGetODTUpdateSuccess - The subscription of the theme updates and/or status changes was 
       
    92                               successful. The cient must start observe the server events.
       
    93 *  - EhspsGetODTUpdateFailed  - The subscription of the theme updates and status changes was failed.
       
    94 *
       
    95 *  Once success-response was received, the observation of the Client Request Service events can 
       
    96 *  return one of the following codes:
       
    97 *
       
    98 *  - EhspsGetODTUpdateStatus - Theme status was changed. Client must reset rendering and request theme
       
    99 *                            again. 
       
   100 *  - EhspsGetODTUpdateHot    - Theme was updated. Client should reload the theme and then do the 
       
   101 *                            rendering again. 
       
   102 *  
       
   103 *  Rendering Engine can get information of the theme resources through the ChspsResource-objects 
       
   104 *  delivered on the resource list in ODT. When ChspsODT-object's DOM-document has a reference to 
       
   105 *  some resource-URL, the access method to the resource can be found in ChspsResource-object. 
       
   106 *  When access-method is resolved, client should call hspsAccessResourceFile() function with resource
       
   107 *  file path and empty RFile-handle. In successful cases, valid file handle to the associated 
       
   108 *  resource file is returned.
       
   109 *  This functionality is arranged by the means of Symbian 9.0 EKA2 Kernel's support for Platform 
       
   110 *  Security Concept. The return code can be one of the following:
       
   111 *  - EhspsAccessResourceFileSuccess - request to get access to a theme resource file was successful.
       
   112 *  - EhspsAccessResourceFileFailed  - request to get access to a theme resource file was unsuccessful
       
   113 *    possible in due to a security fault.
       
   114 * 
       
   115 *  Client Request Service functions may also return one of the following codes:
       
   116 *  - EhspsServiceRequestSheduled, or
       
   117 *  - EhspsServiceRequestError.
       
   118 *
       
   119 *  For explanation of the meanings of these messages, see ThspsServiceCompletedMessage-documentation.
       
   120 *
       
   121 *  @ingroup group_hspsserversession
       
   122 *  @lib hspsThemeServer.exe
       
   123 *  @since S60 5.0
       
   124 */       
       
   125 class ChspsClientRequestHandler : public CBase,
       
   126                                 public MhspsClientRequestService,
       
   127                                 public MhspsDefinitionRepositoryObserver,
       
   128                                 public MhspsCenRepObserver
       
   129                                                
       
   130     {
       
   131     public: // Constructors and destructor
       
   132         /**
       
   133         * NewL
       
   134         *
       
   135         * @since S60 5.0
       
   136         */
       
   137         static ChspsClientRequestHandler* NewL( ChspsThemeServer& aThemeServer );
       
   138         /**
       
   139         * NewLC
       
   140         *
       
   141         * @since S60 5.0
       
   142         */
       
   143         static ChspsClientRequestHandler* NewLC( ChspsThemeServer& aThemeServer );
       
   144              
       
   145         /**
       
   146         * ~ChspsClientRequestHandler
       
   147         * Destructor.
       
   148         */
       
   149         ~ChspsClientRequestHandler();
       
   150       
       
   151     public: // New functions
       
   152         /**
       
   153         * ServiceGetOdtL
       
   154         *
       
   155         * @since S60 5.0
       
   156         * @param aMessage contains the data received from the client
       
   157         */
       
   158         void ServiceGetOdtL(const RMessage2& aMessage);             
       
   159         /**
       
   160         * ServiceGetOdtUpdateL
       
   161         *
       
   162         * @since S60 5.0
       
   163         * @param aMessage contains the data received from the client
       
   164         */
       
   165         void ServiceGetOdtUpdateL(const RMessage2& aMessage);
       
   166         /**
       
   167         * ServiceAccessResourceFileL
       
   168         *
       
   169         * @since S60 5.0
       
   170         * @param aMessage contains the data received from the client
       
   171         */
       
   172         void ServiceAccessResourceFileL(const RMessage2& aMessage);
       
   173 
       
   174         /**
       
   175          * Finnishes installation of application configurations
       
   176          * @since S60 5.0
       
   177          * @param aAppODT is an ODT instance of an application configuration
       
   178          */
       
   179         void HandlePluginReferencesL(
       
   180                 ChspsODT& aAppODT );
       
   181 
       
   182 #ifdef HSPS_LOG_ACTIVE  
       
   183         /**
       
   184         * SetLogBus
       
   185         *
       
   186         * @since S60 5.0
       
   187         * @param aLogBus Log bus to be set.
       
   188         */
       
   189         void SetLogBus( ChspsLogBus* aLogBus );
       
   190 #endif        
       
   191         
       
   192     public: // From MhspsClientRequestService
       
   193             
       
   194         /** 
       
   195         * From MhspsClientRequestService hspsGetODT
       
   196         * @since S60 3.1
       
   197         * @param aAppUid is the UID of the application for which the theme is requested for.
       
   198         * @param aODT is an empty ChspsODT-object in where the theme is expected to be placed when 
       
   199         *        the call returns.
       
   200         * @return ThspsServiceCompletedMessage expressing the result of the call.
       
   201         */
       
   202         ThspsServiceCompletedMessage hspsGetODT(TInt aAppUid, ChspsODT& aODT);
       
   203         
       
   204         /** 
       
   205         * From MhspsClientRequestService hspsGetODT
       
   206         * @since S60 3.1
       
   207         * @param aAppUid is the UID of the application for which the theme is requested for.
       
   208         * @param aODT is an empty ChspsODT-object in where the theme is expected to be placed when 
       
   209         *             the call returns.
       
   210         * @param aResourceList is an empty list-object able to contain ChspsResource-objects. 
       
   211         *        On return of the call, every resource object on the list will describe a resource 
       
   212         *        belonging to the theme in hand. 
       
   213         * @return ThspsServiceCompletedMessage expressing the result of the call.
       
   214         *
       
   215         * DEPRECATED
       
   216         */  
       
   217         ThspsServiceCompletedMessage hspsGetODT(TInt aAppUid, ChspsODT& aODT, 
       
   218                           CArrayPtrSeg<ChspsResource>& aResourceList);
       
   219         
       
   220         /** 
       
   221         * From MhspsClientRequestService hspsGetODTUpdate
       
   222         * @since S60 3.1
       
   223         * @return ThspsServiceCompletedMessage expressing the result of the call.
       
   224         */
       
   225         ThspsServiceCompletedMessage hspsGetODTUpdate();
       
   226         
       
   227         /** 
       
   228         * From MhspsClientRequestService hspsCancelGetODTUpdate
       
   229         * @since S60 3.1
       
   230         * @return ThspsServiceCompletedMessage telling the result of the call.
       
   231         */
       
   232         ThspsServiceCompletedMessage hspsCancelGetODTUpdate();
       
   233         
       
   234         /** 
       
   235         * From MhspsClientRequestService hspsAccessResourceFile
       
   236         * @since S60 3.1
       
   237         * @param aResourceFileName is the path for resource file to requested. Resource file name is
       
   238         *        given in every ChspsResource-object listed on the resource list.
       
   239         * @param aFile is an empty RFile object which a valid file handle to the resourec file will
       
   240         *        be placed on return. 
       
   241         *        The file access is arranged by means of Symbian 9.0 EKA2 Platform Security file 
       
   242         *        handle sharing concept.
       
   243         * @return ThspsServiceCompletedMessage expressing the result of the call.
       
   244         */
       
   245         ThspsServiceCompletedMessage hspsAccessResourceFile(
       
   246             const TDesC& /*aResourceFileName*/,
       
   247             const ThspsConfiguration& /*aConfiguration*/,
       
   248             RFile& /*aFile*/ );
       
   249   
       
   250     public: // from MhspsDefinitioRepositoryObserver
       
   251          
       
   252          TBool HandleDefinitionRespositoryEvent( ThspsRepositoryInfo aRepositoryInfo );
       
   253   
       
   254     public: // from MhspsCenRepObserver
       
   255          
       
   256         void HandleCenRepChangeL( const TUint32 aId );
       
   257          
       
   258     protected:
       
   259         /**
       
   260         * ChspsClientRequestHandler
       
   261         * C++ default constructor.
       
   262         * @since S60 5.0
       
   263         */
       
   264         ChspsClientRequestHandler( ChspsThemeServer& aThemeServer );
       
   265         
       
   266         /**
       
   267         * ConstructL
       
   268         * By default Symbian 2nd phase constructor is private
       
   269         * @since S60 5.0
       
   270         */
       
   271         void ConstructL();
       
   272   
       
   273     private:
       
   274                 
       
   275         /**
       
   276         * RestoreDefaultL
       
   277         *
       
   278         * @since S60 3.1
       
   279         */
       
   280         void RestoreDefaultL( ChspsODT& aOdt );
       
   281         
       
   282         /**
       
   283         * CallGetODTPathL
       
   284         *
       
   285         * @since S60 5.0
       
   286         */
       
   287         void CallGetODTPathL( ChspsODT& aSearchMask, TDes& aODTPath );
       
   288         
       
   289         /**
       
   290         * CompleteRequest
       
   291         *
       
   292         * @since S60 5.0
       
   293         */
       
   294         void CompleteRequestL(const ThspsServiceCompletedMessage aReturnMessage,
       
   295                    RMessagePtr2& aMessagePtr, const TDesC8& aHeaderData = KNullDesC8 );
       
   296                 
       
   297         /**
       
   298         * RestoreValidThemeL
       
   299         * Restores operator/licensee default theme
       
   300         * @since S60 3.1
       
   301         * @param aCorruptedOdt  Odt which failed to render
       
   302         */
       
   303         void RestoreValidThemeL(ChspsODT& aCorruptedOdt);
       
   304         
       
   305       /**
       
   306         * HandleDefinitionRespositoryEventL
       
   307         *
       
   308         * @since S60 5.0
       
   309         */
       
   310         
       
   311         TBool HandleDefinitionRespositoryEventL( ThspsRepositoryInfo aRepositoryInfo );
       
   312         
       
   313         /**
       
   314          * Finds plug-in references from the provided application configuration and append 
       
   315          * XML document with plug-ins specific XML.
       
   316          * Applies to plug-in configurations of type "application configuration" only.
       
   317          * @param aAppODT is an ODT instance of an application configuration
       
   318          */
       
   319         void AppendPluginConfigurationsL( 
       
   320                 ChspsODT& aAppODT );
       
   321         
       
   322         /**
       
   323          * Appends missing plugin with a dummy configuration where status="Error"
       
   324          * @since S60 5.0
       
   325          * @param aAppDom is a DOM of an application configuration 
       
   326          * @param aMissingPluginNode is a plug-in node which was not found from the Plugin Repository
       
   327          * @param aPluginUid is an UID of the missing plugin
       
   328          */
       
   329         void AddErrorConfigurationL(
       
   330                 ChspsDomDocument& aAppDom,
       
   331                 ChspsDomNode& aMissingPluginNode,
       
   332                 const TInt aPluginUid );
       
   333 
       
   334         /**
       
   335          * Prepare given ChspsRequestNotificationParams for sending.
       
   336          * 
       
   337          * @since S60 5.0
       
   338          * @param aInfo         Info to build params from.    
       
   339          * @param aMessage      Completed message.
       
   340          */
       
   341         void PrepareAndCompleteRequestL( const ThspsRepositoryInfo& aInfo,
       
   342                                          const ThspsServiceCompletedMessage& aMessage );                                                                           
       
   343          
       
   344 	    /**
       
   345          * Finds plug-in's initial settings from the provided root configuration and modify 
       
   346          * plugin specific settings with these initial settings.
       
   347 		 *
       
   348 		 * @since S60 5.0
       
   349          * @param aAppODT is an ODT instance of an application configuration
       
   350          * @return KErNone if succeed
       
   351 		 */
       
   352         TInt AppendInitialSettingsL( ChspsODT& aAppODT );
       
   353 		
       
   354         /**
       
   355          * Parse initial settings items.
       
   356          * 
       
   357          * @since S60 5.0
       
   358          * @param aInitialSettingsNode         Initial settings node to be parsed(source node).    
       
   359          * @param aSettingsNode                Actual settings node(target node) where to initial settings needs to be copied.
       
   360          * @return KErNone if succeed
       
   361 		 */
       
   362         TInt ParseInitialSettingsItemsL( ChspsDomNode& aInitialSettingsNode,ChspsDomNode& aSettingsNode);
       
   363 		
       
   364         /**
       
   365          * Handling initial settings property nodes.
       
   366          * 
       
   367          * @since S60 5.0
       
   368          * @param aPropertyNode        Initial settings property node(property source node).    
       
   369          * @param aNode                Target node.
       
   370 		 * @return KErNone if succeed
       
   371          */
       
   372         TInt HandlePropertyNodeL( ChspsDomNode& aPropertyNode,ChspsDomNode& aNode );  
       
   373 		
       
   374         /**
       
   375          * Handling attributes.
       
   376          * 
       
   377          * @since S60 5.0
       
   378          * @param aAttrName       Attribute name.    
       
   379          * @param aAttrValue      Attribute value.
       
   380 		 * @param aNode           Target property node.
       
   381 		 * @return KErNone if succeed.
       
   382          */     
       
   383         TInt HandlePropertyAttributesL(const TDesC8& aAttrName,
       
   384                                     const TDesC8& aAttrValue,
       
   385                                     ChspsDomNode& aNode );
       
   386        
       
   387         /**
       
   388          * Finds a root node for liw structure from dom document by identifier
       
   389 		 *
       
   390 		 * @since S60 5.0
       
   391          * @param aNodeIdentifier An Tag.
       
   392          * @param aNodeIdentifier An Identifier.
       
   393          * @param aNode A Dom Node where the node is searched from.
       
   394          * @return Result node.
       
   395          */
       
   396         ChspsDomNode& FindRootNodeByIdentifierL( const TDesC8& aNodeTag,
       
   397                                                         const TDesC8& aNodeIdentifier,
       
   398                                                         ChspsDomNode& aNode );
       
   399         
       
   400     protected: // Functions from base classes
       
   401 
       
   402        
       
   403     private:    // Data
       
   404         // the next member variables should be used in asynchronous message handling only
       
   405         RMessagePtr2 iMessagePtr;
       
   406         TFileName iODTPath;
       
   407        
       
   408         // tells to restore default in repeated theme load cases
       
   409         TBool iRestoreDefault;
       
   410         ChspsResult* iResult;
       
   411         TBuf8<KMaxResultDataLength8> iResultData;
       
   412         ChspsRequestNotificationParams* iReqNotifParams;
       
   413         TBuf8<KMaxReqNotifDataLength8> iReqNotifData;
       
   414         HBufC8* iRequestData;
       
   415         
       
   416         // Index of the requested function
       
   417         ThspsServiceRequestMessage iRequestMessage;
       
   418         
       
   419         ThspsServiceCompletedMessage iCompletedMessage;
       
   420         TTime iLastHeaderListUpdateTime;
       
   421         TTime iLastSuccessThemeLoadTime;
       
   422         // application or interface uid
       
   423         TUint iRootUid;        
       
   424         // theme uid from the most recent request
       
   425         TUint iActiveThemeUid;
       
   426         TUint iSecureId;
       
   427         ChspsODT* iOdt;
       
   428         RFs iFs;
       
   429         TInt iThemeLoadRepeatCount;
       
   430         // ownership of the next objects is held by ChspsThemeServer
       
   431         ChspsThemeServer& iThemeServer;        
       
   432         // Reference to central repository
       
   433         CRepository& iCentralRepository;  
       
   434         // Pointer to Central Repository Listener        
       
   435         ChspsCenRepListener* iCenRepListener;
       
   436         // Reference to definition repository
       
   437         ChspsDefinitionRepository& iDefinitionRepository;
       
   438         // Reference to security enforcer
       
   439         ChspsSecurityEnforcer& iSecurityEnforcer;
       
   440         // header list cache
       
   441         CArrayPtrSeg<ChspsODT>& iHeaderListCache;   
       
   442         // Reserved pointer for future extension
       
   443         TAny* iReserved;
       
   444 
       
   445 #ifdef HSPS_LOG_ACTIVE        
       
   446         // Log bus to be used. Not owned.
       
   447         ChspsLogBus* iLogBus;
       
   448 #endif        
       
   449     };
       
   450 
       
   451 #endif //__hspsCLIENTREQUESTHANDLER_H__
       
   452 
       
   453 // end of file
       
   454