persistentstorage/centralrepository/cenrepsrv/obsrvr_noc.h
changeset 0 08ec8eefde2f
child 1 c084286672be
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15  
       
    16 #ifndef OBSRVR_H
       
    17 #define OBSRVR_H
       
    18 
       
    19 #include <e32base.h>
       
    20 
       
    21 class CSharedRepository;
       
    22 class CServerRepository;
       
    23 class CRepositoryTransactor;
       
    24 
       
    25 #include "inifile.h"
       
    26 
       
    27 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
       
    28 class CHeapRepository;
       
    29 /**
       
    30 This simple T class is used to store information regarding
       
    31 the keyspace entry in the rofs list with respect to the
       
    32 extension used and the mount id order
       
    33 */
       
    34 class TRofsFlag
       
    35 {
       
    36 public:
       
    37 	TRofsFlag(const TDesC& aExt,TUint8 aMountId):iFlag(aMountId)
       
    38 		{
       
    39 		if (aExt.Compare(_L("txt"))==0)
       
    40 			{
       
    41 			iFlag |=0x80000000;
       
    42 			}
       
    43 		}
       
    44 
       
    45 	static TInt CompareFlag(const TRofsFlag& aFlag1, const TRofsFlag& aFlag2)
       
    46 		{
       
    47 		return (aFlag1.iFlag & 0xFF)-(aFlag2.iFlag & 0xFF);
       
    48 		}
       
    49 
       
    50 public:
       
    51 	//the 16 bit flag in format of |8bit cre/txt flag|8bit mount_id|
       
    52 	//obviously this is assuming the format of the mangled file
       
    53 	//granulatiry currently set to default of 8 which is reasonable
       
    54 	//MSB=1 indicates this is txt
       
    55 	TUint32 iFlag;	
       
    56 };
       
    57 
       
    58 /**
       
    59 This class is used to store information about potentially multiple
       
    60 files(in diffeernt rofs) used for a centrep keyspace
       
    61 */
       
    62 class TMultiRofsList
       
    63 	{
       
    64 public:
       
    65 	TMultiRofsList(TUid aUid):iRepUid(aUid){}
       
    66 	
       
    67 public:
       
    68 	//repository uid
       
    69 	TUid iRepUid;
       
    70 	//list of the mount ids together with the extension(cre/txt)
       
    71 	RArray<TRofsFlag> iMountFlagList;		
       
    72 	};
       
    73 #endif	
       
    74 
       
    75 class MObserver
       
    76 	{
       
    77 public:
       
    78 	virtual void Notify(TUint32 aId) = 0;
       
    79 	};
       
    80 
       
    81 class CObservable : public CBase
       
    82 	{
       
    83 public:
       
    84 	static CObservable* NewLC();
       
    85 	
       
    86 	~CObservable();
       
    87 
       
    88 	void AddObserverL(TUid aUid, CServerRepository* aRepositoryPointer);
       
    89 	void RemoveObserver(TUid aUid, CServerRepository* aRepositoryPointer, TInt aInMemoryIndex);
       
    90 
       
    91 	void Notify(TUid aUid, TUint32 aVal) const;
       
    92 	
       
    93 	TInt FindOpenRepository(TUid aUid) const;
       
    94 	void RemoveOpenRepository(CSharedRepository* aRepository);
       
    95 	
       
    96 	inline CSharedRepository*& GetOpenRepository(TInt aIndex) 
       
    97 		{
       
    98 		ASSERT((aIndex>=0)&&(aIndex<iOpenRepositories.Count()));
       
    99 		return iOpenRepositories[aIndex];
       
   100 		}
       
   101 	inline void AddOpenRepositoryL(CSharedRepository* aRepository)
       
   102 		{
       
   103 		iOpenRepositories.AppendL(aRepository);
       
   104 		}
       
   105 	
       
   106 	TInt FindConnectedRepository(TUid aUid) const;
       
   107 			
       
   108 #ifdef CACHE_OOM_TESTABILITY
       
   109 	void CloseiOpenRepositories();
       
   110 	void CloseiRepositoryInfo();
       
   111 	void Reset();
       
   112 	TBool iTrapOOMOnOpen;
       
   113 #endif	
       
   114 	
       
   115 	CSharedRepository* AccessL(TUid aUid, TBool aFailIfNotFound = ETrue);
       
   116 	void LoadRepositoryLC(TUid aUid, TBool aFailIfNotFound, CSharedRepository*& aRepository, CIniFileIn::TIniFileOpenMode aIniFileOpenMode);
       
   117 
       
   118 	/**
       
   119 	@internalTechnology
       
   120 	This is the class/structure which keeps shared non-persisted repository data 
       
   121 	*/
       
   122 	class TSharedRepositoryInfo
       
   123 		{
       
   124 	public:
       
   125 		TSharedRepositoryInfo(TUid aUid);
       
   126 		TUid iRepositoryUid;
       
   127 		// all transactors in the order added
       
   128 		TSglQue<CRepositoryTransactor> iTransactors;
       
   129 		// combined read/write lock for pessimistic transactions.
       
   130 		// -1 if in EReadWriteTransaction, otherwise non-negative number of EReadTransactions.
       
   131 		TInt iPessimisticTransactionLockCount;
       
   132 		// count of active concurrent read/write transactions:
       
   133 		TInt iNumActiveConcurrentReadWriteTransactions;
       
   134 		
       
   135 
       
   136 		};
       
   137 
       
   138 	TSharedRepositoryInfo* SharedRepositoryInfo(TUid aUid);		
       
   139 	void AddSharedRepositoryInfoL(TUid aUid);
       
   140 	void RemoveSharedRepositoryInfo(TUid aUid);
       
   141 	TInt CreateRepositoryL(CSharedRepository* aRepository, TCentRepLocation aLocation);
       
   142 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS	
       
   143 	void ProcessMultiRofsListL(const CDir& aList);	
       
   144 	static TInt CompareUid(const TMultiRofsList& aUid1, const TMultiRofsList& aUid2);		
       
   145 	RArray<TMultiRofsList>& GetMultiRofsList()
       
   146 		{
       
   147 		return iMultiRofsUidList;	
       
   148 		}
       
   149 #endif		
       
   150 	
       
   151 	/**
       
   152 	@internalTechnology
       
   153 	This is the class/structure which keeps notification-related data 
       
   154 	*/
       
   155 	class TRepositoryObserverInfo
       
   156 		{
       
   157 	public:
       
   158 		TUid iRepositoryUid;
       
   159 		CServerRepository* iRepositoryPointer; 
       
   160 		};
       
   161 	RArray<TRepositoryObserverInfo> iObservers;		
       
   162 private:
       
   163 	static TInt ObserverSortOrder(const TRepositoryObserverInfo &aRepository1, const TRepositoryObserverInfo &aRepository2);
       
   164 	static TInt InfoSortOrder(const TSharedRepositoryInfo &aRepository1, const TSharedRepositoryInfo &aRepository2);
       
   165 	static TInt CompareTUidValues(TInt aUid1, TInt aUid2);
       
   166 	
       
   167 	TInt ReadIniFileL(CSharedRepository*& aRepository,TCentRepLocation aLocation);
       
   168 	TInt CreateRepositoryL(CSharedRepository*& aRepository, CIniFileIn::TIniFileOpenMode aIniFileOpenMode);
       
   169 	TInt ReadSettingsL(CIniFileIn* aIniFileIn, CSharedRepository* aRep);
       
   170 
       
   171 	TInt FindRepositoryInfo(TUid aUid);
       
   172 	void RefreshTransactorAccessPolicies(CSharedRepository* aRepository, const TInt offset);
       
   173 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS	
       
   174 	//Multi ROFS stuff
       
   175 	void ConstructL();
       
   176 	void OverrideSettingL(TServerSetting& aBaseSetting,const TServerSetting& aOvSetting,CSharedRepository* aCoreRepository,TBool aNewOv,TBool aNewOvIndivPolicy);	
       
   177 	void MergeRepositoryL(CSharedRepository* aCoreRepository,CHeapRepository* aOverrideRepository);
       
   178 	void MergeMultiRofsL(TBool aCoreInitialized,CSharedRepository* aCoreRepository,const RArray<TRofsFlag>& aOverridingFileList);
       
   179 #endif
       
   180 	
       
   181 private:
       
   182 	enum {KGranularity=8};	
       
   183 	RPointerArray<CSharedRepository> iOpenRepositories;	
       
   184 	RPointerArray<TSharedRepositoryInfo> iRepositoryInfo;
       
   185 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS	
       
   186 	RArray<TMultiRofsList> iMultiRofsUidList;
       
   187 #endif		
       
   188 	};
       
   189 
       
   190 #endif // OBSRVR_H