1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/cenrepsrv/obsrvr_noc.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,192 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef OBSRVR_H
1.20 +#define OBSRVR_H
1.21 +
1.22 +#include <e32base.h>
1.23 +
1.24 +class CSharedRepository;
1.25 +class CServerRepository;
1.26 +class CRepositoryTransactor;
1.27 +
1.28 +#include "inifile.h"
1.29 +
1.30 +#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
1.31 +class CHeapRepository;
1.32 +/**
1.33 +This simple T class is used to store information regarding
1.34 +the keyspace entry in the rofs list with respect to the
1.35 +extension used and the mount id order
1.36 +*/
1.37 +class TRofsFlag
1.38 +{
1.39 +public:
1.40 + TRofsFlag(const TDesC& aExt,TUint8 aMountId):iFlag(aMountId)
1.41 + {
1.42 + if (aExt.Compare(_L("txt"))==0)
1.43 + {
1.44 + iFlag |=0x80000000;
1.45 + }
1.46 + }
1.47 +
1.48 + static TInt CompareFlag(const TRofsFlag& aFlag1, const TRofsFlag& aFlag2)
1.49 + {
1.50 + return (aFlag1.iFlag & 0xFF)-(aFlag2.iFlag & 0xFF);
1.51 + }
1.52 +
1.53 +public:
1.54 + //the 16 bit flag in format of |8bit cre/txt flag|8bit mount_id|
1.55 + //obviously this is assuming the format of the mangled file
1.56 + //granulatiry currently set to default of 8 which is reasonable
1.57 + //MSB=1 indicates this is txt
1.58 + TUint32 iFlag;
1.59 +};
1.60 +
1.61 +/**
1.62 +This class is used to store information about potentially multiple
1.63 +files(in diffeernt rofs) used for a centrep keyspace
1.64 +*/
1.65 +class TMultiRofsList
1.66 + {
1.67 +public:
1.68 + TMultiRofsList(TUid aUid):iRepUid(aUid){}
1.69 +
1.70 +public:
1.71 + //repository uid
1.72 + TUid iRepUid;
1.73 + //list of the mount ids together with the extension(cre/txt)
1.74 + RArray<TRofsFlag> iMountFlagList;
1.75 + };
1.76 +#endif
1.77 +
1.78 +class MObserver
1.79 + {
1.80 +public:
1.81 + virtual void Notify(TUint32 aId) = 0;
1.82 + };
1.83 +
1.84 +class CObservable : public CBase
1.85 + {
1.86 +public:
1.87 + static CObservable* NewLC();
1.88 +
1.89 + ~CObservable();
1.90 +
1.91 + void AddObserverL(TUid aUid, CServerRepository* aRepositoryPointer);
1.92 + void RemoveObserver(TUid aUid, CServerRepository* aRepositoryPointer, TInt aInMemoryIndex);
1.93 +
1.94 + void Notify(TUid aUid, TUint32 aVal) const;
1.95 +
1.96 + void ReleaseTransactionLock(CRepositoryTransactor& aTransactor,TUid aRepositoryUid);
1.97 + void CancelTransaction(CRepositoryTransactor& aTransactor,TUid aRepositoryUid);
1.98 + TInt FindOpenRepository(TUid aUid) const;
1.99 + void RemoveOpenRepository(CSharedRepository* aRepository);
1.100 +
1.101 + inline CSharedRepository*& GetOpenRepository(TInt aIndex)
1.102 + {
1.103 + ASSERT((aIndex>=0)&&(aIndex<iOpenRepositories.Count()));
1.104 + return iOpenRepositories[aIndex];
1.105 + }
1.106 + inline void AddOpenRepositoryL(CSharedRepository* aRepository)
1.107 + {
1.108 + iOpenRepositories.AppendL(aRepository);
1.109 + }
1.110 +
1.111 + TInt FindConnectedRepository(TUid aUid) const;
1.112 +
1.113 +#ifdef CACHE_OOM_TESTABILITY
1.114 + void CloseiOpenRepositories();
1.115 + void CloseiRepositoryInfo();
1.116 + void Reset();
1.117 + TBool iTrapOOMOnOpen;
1.118 +#endif
1.119 +
1.120 + CSharedRepository* AccessL(TUid aUid, TBool aFailIfNotFound = ETrue);
1.121 + void LoadRepositoryLC(TUid aUid, TBool aFailIfNotFound, CSharedRepository*& aRepository, CIniFileIn::TIniFileOpenMode aIniFileOpenMode);
1.122 +
1.123 + /**
1.124 + @internalTechnology
1.125 + This is the class/structure which keeps shared non-persisted repository data
1.126 + */
1.127 + class TSharedRepositoryInfo
1.128 + {
1.129 + public:
1.130 + TSharedRepositoryInfo(TUid aUid);
1.131 + TUid iRepositoryUid;
1.132 + // all transactors in the order added
1.133 + TSglQue<CRepositoryTransactor> iTransactors;
1.134 + // combined read/write lock for pessimistic transactions.
1.135 + // -1 if in EReadWriteTransaction, otherwise non-negative number of EReadTransactions.
1.136 + TInt iPessimisticTransactionLockCount;
1.137 + // count of active concurrent read/write transactions:
1.138 + TInt iNumActiveConcurrentReadWriteTransactions;
1.139 +
1.140 +
1.141 + };
1.142 +
1.143 + TSharedRepositoryInfo* SharedRepositoryInfo(TUid aUid);
1.144 + void AddSharedRepositoryInfoL(TUid aUid);
1.145 + void RemoveSharedRepositoryInfo(TUid aUid);
1.146 + TInt CreateRepositoryL(CSharedRepository* aRepository, TCentRepLocation aLocation);
1.147 +#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
1.148 + void ProcessMultiRofsListL(const CDir& aList);
1.149 + static TInt CompareUid(const TMultiRofsList& aUid1, const TMultiRofsList& aUid2);
1.150 + RArray<TMultiRofsList>& GetMultiRofsList()
1.151 + {
1.152 + return iMultiRofsUidList;
1.153 + }
1.154 +#endif
1.155 +
1.156 + /**
1.157 + @internalTechnology
1.158 + This is the class/structure which keeps notification-related data
1.159 + */
1.160 + class TRepositoryObserverInfo
1.161 + {
1.162 + public:
1.163 + TUid iRepositoryUid;
1.164 + CServerRepository* iRepositoryPointer;
1.165 + };
1.166 + RArray<TRepositoryObserverInfo> iObservers;
1.167 +private:
1.168 + static TInt ObserverSortOrder(const TRepositoryObserverInfo &aRepository1, const TRepositoryObserverInfo &aRepository2);
1.169 + static TInt InfoSortOrder(const TSharedRepositoryInfo &aRepository1, const TSharedRepositoryInfo &aRepository2);
1.170 + static TInt CompareTUidValues(TInt aUid1, TInt aUid2);
1.171 +
1.172 + TInt ReadIniFileL(CSharedRepository*& aRepository,TCentRepLocation aLocation);
1.173 + TInt CreateRepositoryL(CSharedRepository*& aRepository, CIniFileIn::TIniFileOpenMode aIniFileOpenMode);
1.174 + TInt ReadSettingsL(CIniFileIn* aIniFileIn, CSharedRepository* aRep);
1.175 +
1.176 + TInt FindRepositoryInfo(TUid aUid);
1.177 + void RefreshTransactorAccessPolicies(CSharedRepository* aRepository, const TInt offset);
1.178 +#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
1.179 + //Multi ROFS stuff
1.180 + void ConstructL();
1.181 + void OverrideSettingL(TServerSetting& aBaseSetting,const TServerSetting& aOvSetting,CSharedRepository* aCoreRepository,TBool aNewOv,TBool aNewOvIndivPolicy);
1.182 + void MergeRepositoryL(CSharedRepository* aCoreRepository,CHeapRepository* aOverrideRepository);
1.183 + void MergeMultiRofsL(TBool aCoreInitialized,CSharedRepository* aCoreRepository,const RArray<TRofsFlag>& aOverridingFileList);
1.184 +#endif
1.185 +
1.186 +private:
1.187 + enum {KGranularity=8};
1.188 + RPointerArray<CSharedRepository> iOpenRepositories;
1.189 + RPointerArray<TSharedRepositoryInfo> iRepositoryInfo;
1.190 +#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
1.191 + RArray<TMultiRofsList> iMultiRofsUidList;
1.192 +#endif
1.193 + };
1.194 +
1.195 +#endif // OBSRVR_H