policymanagement/policyengine/policyengineserver/inc/PolicyStorage.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Implementation of policymanagement components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef _POLICY_STORAGE_HEADER__
       
    21 #define _POLICY_STORAGE_HEADER__
       
    22 
       
    23 #define __EXCEPTION_HANDLING
       
    24 
       
    25 
       
    26 // INCLUDES
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <f32file.h>
       
    30 #include <SettingEnforcementInfo.h>
       
    31 #include "ElementBase.h"
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 LOCAL_C TChar KParentListStartMark = '~';
       
    36 
       
    37 // MACROS
       
    38 // DATA TYPES
       
    39 // FUNCTION PROTOTYPES
       
    40 // FORWARD DECLARATIONS
       
    41 
       
    42 class CElementBase;
       
    43 class CRepository;
       
    44 class CElementBase;
       
    45 class CPolicyParser;
       
    46 class CSettingEnforcementManager;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 class CPolicyStorage : public CBase
       
    51 {
       
    52 	friend class CPolicyEngineServer;
       
    53 
       
    54 	public:
       
    55 		static CPolicyStorage * NewL();
       
    56 		void ConstructL();
       
    57 		CPolicyStorage();
       
    58 		~CPolicyStorage();	
       
    59 
       
    60 		//static reference		
       
    61 		static CPolicyStorage * PolicyStorage();
       
    62 		
       
    63 		//New element handling
       
    64 		TInt SaveElementL( TUint32 aElementId, HBufC8 * aElementDescription);
       
    65 		void DeleteElementL( TUint32 aElementId);
       
    66 		void AddNewElementL( CElementBase * aElement);
       
    67 		void CommitChangesL( TBool aAcceptCommit);
       
    68 		void StartCommitSessionL();
       
    69 		
       
    70 		//element handling
       
    71 		void CheckElementL( CElementBase * aElement);
       
    72 		CElementBase * GetElementL( const TDesC8& iPolicyId );
       
    73 		CElementBase * GetElementL( const TUint32 aElementId);
       
    74 		CElementBase * GetEditableElementL( const TDesC8& aPolicyId );
       
    75 		CElementBase * GetEditableElementL( const TUint32 aElementId );
       
    76 		void ReleaseElements();
       
    77 //		TBool IsExist( const TDesC8& aElementId );
       
    78 
       
    79 		//element editing
       
    80 		void GetEditedElementsL( CSettingEnforcementManager* aSEManager);
       
    81 		void SaveEditableMemoryL();
       
    82 		void ResetEditableMemory();
       
    83 		
       
    84 		//id functions
       
    85 		TUint32 CreateIdL( TNativeElementTypes &aType);
       
    86 		TUint32 MapRealIdL( const TDesC8& aElementRealId, const TBool aOnlyCommitted);
       
    87 		TBool IsRealIdValidL( const TDesC8& aElementRealId);
       
    88 		TBool IsIdValidL( const TUint32& aId);
       
    89 		void ResetRealIdValidTest();
       
    90 		
       
    91 		//setting enforcement 
       
    92 		void ActivateEnforcementFlagL( KSettingEnforcements aSetting);
       
    93 		void DeactivateEnforcementFlagL( KSettingEnforcements aSetting);
       
    94 
       
    95 		//server id list
       
    96 		TInt AddNewServerId( const TDesC8& aServerId);
       
    97 		TInt RemoveServerId( const TDesC8& aServerId);
       
    98 		TInt ResetServerIdList();
       
    99 		TBool IsServerIdValid( const TDesC8& aServerId);
       
   100 	private:
       
   101 	
       
   102 		CElementBase * FindElement( RArray<CElementBase*> &aElementList, const TUint32 aElementId);
       
   103 		void AddElementL( RArray<CElementBase*> &aElementList, CElementBase * aElement);
       
   104 	//	void LoadElementL( const TUint32 aElementId);
       
   105 		void LoadElementL( CElementBase * aElement, TBool aAddToEditableCache);
       
   106 		
       
   107 		TInt SetElementL( TUint32 aId, const TDesC8& aDescription);
       
   108 		TInt GetElementL( TUint32 aId, HBufC8*& aDescription);
       
   109 	
       
   110 		//Backup functions
       
   111 		TInt CreatePaths();
       
   112 		void CheckCommitStateL();
       
   113 		void MakeBackupL( const TDesC& aFileName);
       
   114 		void MakeBackupL( const TUint32& aSettingId);
       
   115 		void RestoreBackupL();
       
   116 		void RemoveBackupL();
       
   117 		
       
   118 		//server id lists
       
   119 		void SaveServerIdListL();
       
   120 		void LoadServerIdListL();
       
   121 		void PrintServerIdList();
       
   122 		
       
   123 		//for mapping handling
       
   124 		TUint32 GetEditedMappingsL( const TDesC8& aElementRealId);	
       
   125 		TUint32 GetCommittedMappingsL( const TDesC8& aElementRealId);	
       
   126 		TUint32 GetMappingsFromDriveL( const TDesC8& aElementRealId, TDriveNumber aDrive, TBool aUpdateList);	
       
   127 		TBool ReadRealIdL( const TDesC& aFileName, const TDesC8& aElementRealId, TDriveNumber aDrive);
       
   128 	private:
       
   129 		RFs iRFs;
       
   130 		CRepository * iCentRep;
       
   131 		CRepository * iCentRepBackup;
       
   132 		CPolicyParser * iParser;
       
   133 		TBool iCommitted;
       
   134 		static CPolicyStorage* iPolicyStorage;
       
   135 
       
   136 		RElementArray iElementCache;
       
   137 		RElementArray iDepricatedElements;
       
   138 		RElementArray iEditedElements;
       
   139 		RPointerArray<HBufC8> iServerIdList;
       
   140 		RArray<TUint32> iSearchedUids;
       
   141 		RPointerArray<HBufC8> iInvalidServerIds;
       
   142 };
       
   143 
       
   144 class TElementReserver
       
   145 {
       
   146 	public:
       
   147 		TElementReserver();
       
   148 		TElementReserver( CElementBase* aElement);
       
   149 		TElementReserver( RElementContainer* aElements);
       
   150 		~TElementReserver();
       
   151 		void ReserveL( CElementBase* aElement);
       
   152 
       
   153 		void Release();
       
   154 	private:
       
   155 		typedef RArray<CElementBase*> RElementList;
       
   156 		void DoRelease();
       
   157 		
       
   158 #ifndef __EXCEPTION_HANDLING
       
   159 
       
   160 		class CWrapper : public CBase
       
   161 		{
       
   162 			public:
       
   163 				CWrapper( TElementReserver *aReserver);
       
   164 				~CWrapper();
       
   165 			public:
       
   166 				TElementReserver *iReserver;
       
   167 		};
       
   168 #endif // __EXCEPTION_HANDLING
       
   169 				
       
   170 	private:
       
   171 #ifndef __EXCEPTION_HANDLING
       
   172 		CWrapper * iWrapper;
       
   173 #endif // __EXCEPTION_HANDLING
       
   174 		CElementBase * iElement;
       
   175 		RElementContainer * iElements;
       
   176 		RElementList * iElementList;
       
   177 		
       
   178 		friend class CWrapper;
       
   179 };
       
   180 
       
   181 #endif