homescreenpluginsrv/hspspluginregistry/src/hspsdefinitionrepository.cpp
branchRCL_3
changeset 19 edd621764147
parent 12 502e5d91ad42
equal deleted inserted replaced
16:b276298d5729 19:edd621764147
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <s32file.h>
    20 #include <s32file.h>
    21 #include <s32mem.h>
    21 #include <s32mem.h>
    22 #include <sysutil.h>
    22 #include <sysutil.h>
    23 #include <bautils.h>
    23 #include <bautils.h>
       
    24 #include <centralrepository.h>
    24 
    25 
    25 #include "hsps_builds_cfg.hrh"
    26 #include "hsps_builds_cfg.hrh"
    26 
    27 
    27 #include "hspsthememanagement.h"
    28 #include "hspsthememanagement.h"
    28 #include "hspsdefinitionrepository.h"
    29 #include "hspsdefinitionrepository.h"
    52 
    53 
    53 _LIT(KMatchSkeleton, ".o0000");
    54 _LIT(KMatchSkeleton, ".o0000");
    54 
    55 
    55 const TInt KTIntMahspsumbers( 11 );
    56 const TInt KTIntMahspsumbers( 11 );
    56 
    57 
       
    58 _LIT_SECURITY_POLICY_C1( KPSReadPolicy, ECapabilityReadDeviceData );
       
    59 _LIT_SECURITY_POLICY_C1( KPSWritePolicy, ECapabilityWriteDeviceData );
       
    60 
       
    61 
    57 // ============================= LOCAL FUNCTIONS ===============================
    62 // ============================= LOCAL FUNCTIONS ===============================
    58     
    63     
    59 // ============================ MEMBER FUNCTIONS ===============================
    64 // ============================ MEMBER FUNCTIONS ===============================
    60 
    65 
    61 // -----------------------------------------------------------------------------
    66 // -----------------------------------------------------------------------------
    62 // ChspsDefinitionRepository::ChspsDefinitionRepository
    67 // ChspsDefinitionRepository::ChspsDefinitionRepository
    63 // C++ default constructor can NOT contain any code, that
    68 // C++ default constructor can NOT contain any code, that
    64 // might leave.
    69 // might leave.
    65 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    66 //
    71 //
    67 ChspsDefinitionRepository::ChspsDefinitionRepository() :
    72 ChspsDefinitionRepository::ChspsDefinitionRepository( 
    68         iCacheLastODT( NULL )
    73         CRepository& aCentralRepository ) :
       
    74         iCacheLastODT( NULL ),
       
    75         iCentralRepository( aCentralRepository )
    69     {        
    76     {        
    70     }
    77     }
    71 
    78 
    72 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    73 // ChspsDefinitionRepository::ConstructL
    80 // ChspsDefinitionRepository::ConstructL
    74 // Symbian 2nd phase constructor can leave.
    81 // Symbian 2nd phase constructor can leave.
    75 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    76 //
    83 //
    77 void ChspsDefinitionRepository::ConstructL()
    84 void ChspsDefinitionRepository::ConstructL()
    78     {
    85     {    
       
    86     // Setup RProperty keys for the client applications
       
    87     SetupPropertiesL( KPropertyAI3Key );
       
    88     SetupPropertiesL( KPropertyMTKey );
       
    89                 
    79 	User::LeaveIfError( iFs.Connect() );
    90 	User::LeaveIfError( iFs.Connect() );
    80 	//Create private path if it doesn't exist already
    91 	//Create private path if it doesn't exist already
    81 	TInt err=iFs.CreatePrivatePath(EDriveC);
    92 	TInt err = iFs.CreatePrivatePath(EDriveC);
    82 	if (err!=KErrNone && err!=KErrAlreadyExists)
    93 	if (err!=KErrNone && err!=KErrAlreadyExists)
    83 		{
    94 		{
    84 		User::Leave(err);	
    95 		User::Leave(err);	
    85 		}
    96 		}
    86 	HBufC* path = HBufC::NewLC( KMaxFileName );
    97 	HBufC* path = HBufC::NewLC( KMaxFileName );
   101 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   102 // ChspsDefinitionRepository::NewL
   113 // ChspsDefinitionRepository::NewL
   103 // Two-phased constructor.
   114 // Two-phased constructor.
   104 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   105 //
   116 //
   106 EXPORT_C ChspsDefinitionRepository* ChspsDefinitionRepository::NewL()
   117 EXPORT_C ChspsDefinitionRepository* ChspsDefinitionRepository::NewL(
   107     {
   118         CRepository& aCentralRepository )
   108     ChspsDefinitionRepository* self = new( ELeave ) ChspsDefinitionRepository;
   119     {
       
   120     ChspsDefinitionRepository* self = 
       
   121             new( ELeave ) ChspsDefinitionRepository( aCentralRepository );
   109     
   122     
   110     CleanupStack::PushL( self );
   123     CleanupStack::PushL( self );
   111     self->ConstructL();
   124     self->ConstructL();
   112     CleanupStack::Pop( self );
   125     CleanupStack::Pop( self );
   113 
   126 
   115     }
   128     }
   116     
   129     
   117 // Destructor
   130 // Destructor
   118 ChspsDefinitionRepository::~ChspsDefinitionRepository()
   131 ChspsDefinitionRepository::~ChspsDefinitionRepository()
   119     {
   132     {
       
   133     iProperty.Close();
   120     iFs.Close();
   134     iFs.Close();
   121     iRepositoryInfoQueue.Reset();
   135     iRepositoryInfoQueue.Reset();
   122     iRepositoryInfoQueue.Close();
   136     iRepositoryInfoQueue.Close();
   123     iObservers.Reset();
   137     iObservers.Reset();
   124     iObservers.Close(); 
   138     iObservers.Close(); 
   126     
   140     
   127     delete iCacheLastODT;    
   141     delete iCacheLastODT;    
   128     
   142     
   129 	iTempFileName1 = KNullDesC;
   143 	iTempFileName1 = KNullDesC;
   130 	iTempFileName2 = KNullDesC;    
   144 	iTempFileName2 = KNullDesC;    
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // ChspsDefinitionRepository::SetupPropertiesL
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void ChspsDefinitionRepository::SetupPropertiesL( const TUint aKey )
       
   152     {    
       
   153     TInt err = RProperty::Define(
       
   154         KPropertyHspsCat,
       
   155         aKey,
       
   156         RProperty::EInt,
       
   157         KPSReadPolicy,
       
   158         KPSWritePolicy );
       
   159     if( err != KErrAlreadyExists && err != KErrNone )
       
   160         {
       
   161         User::LeaveIfError( err );
       
   162         }    
       
   163     // Init
       
   164     User::LeaveIfError( 
       
   165         RProperty::Set( 
       
   166             KPropertyHspsCat, 
       
   167             aKey, 
       
   168             KPropertyKeyDefault ) 
       
   169         );
   131     }
   170     }
   132 
   171 
   133 // -----------------------------------------------------------------------------
   172 // -----------------------------------------------------------------------------
   134 // ChspsDefinitionRepository::SetLocaleL
   173 // ChspsDefinitionRepository::SetLocaleL
   135 // Saves the dtd-file into the repository.
   174 // Saves the dtd-file into the repository.
   206 
   245 
   207     if( aODT.ConfigurationType() == EhspsAppConfiguration )
   246     if( aODT.ConfigurationType() == EhspsAppConfiguration )
   208         {
   247         {
   209         delete iCacheLastODT;
   248         delete iCacheLastODT;
   210 		iCacheLastODT = NULL;        
   249 		iCacheLastODT = NULL;        
   211         iCacheLastODT = aODT.CloneL();                
   250         iCacheLastODT = aODT.CloneL();              
       
   251                 
       
   252         // Check whether we updated active application configuration
       
   253         TInt configurationUid = -1;
       
   254         User::LeaveIfError( 
       
   255             iCentralRepository.Get( iCacheLastODT->RootUid(), configurationUid ) 
       
   256             );
       
   257         if( configurationUid == aODT.ThemeUid() )
       
   258             {            
       
   259             
       
   260             const TUint key = iCacheLastODT->RootUid();
       
   261                     
       
   262             // Get current value
       
   263             TInt version( 0 );
       
   264             User::LeaveIfError( 
       
   265                 RProperty::Get( 
       
   266                         KPropertyHspsCat, 
       
   267                         key, 
       
   268                         version ) 
       
   269                     );
       
   270             
       
   271             // Increment the version, each client session should update the ODT copies            
       
   272             version++;
       
   273             if( version < 1 )
       
   274                 {
       
   275                 version = 1;
       
   276                 }                                
       
   277             User::LeaveIfError( 
       
   278                 RProperty::Set( 
       
   279                         KPropertyHspsCat, 
       
   280                         key, 
       
   281                         version ) 
       
   282                     );
       
   283             }
   212         }
   284         }
   213     
   285     
   214     return ret;
   286     return ret;
   215     }
   287     }
   216 
   288