sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __CENREP_INIFILE_H__ sl@0: #define __CENREP_INIFILE_H__ sl@0: sl@0: #include sl@0: #include "centralrepository.h" sl@0: #include "log.h" sl@0: #include "srvdefs.h" sl@0: sl@0: using namespace NCentralRepositoryConstants; sl@0: using namespace NCentralRepositoryResources; sl@0: sl@0: //Forward declarations sl@0: class RRangePolicyArray; sl@0: class RDefaultMetaArray; sl@0: class TServerSetting; sl@0: class TSettingsAccessPolicy; sl@0: class CSharedRepository; sl@0: sl@0: //Max length of one setting statement sl@0: const TInt KMaxLengthWithPolicyInfo = KMaxBinaryLength * 2 + 64; sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////// sl@0: // CIniFileIn class sl@0: /** sl@0: @internalTechnology sl@0: */ sl@0: class CIniFileIn : public CBase sl@0: { sl@0: enum {KReadPolicy,KWritePolicy}; sl@0: sl@0: public: sl@0: enum TIniFileOpenMode {ERomOnly,EInstallOnly,EAuto}; sl@0: sl@0: public: sl@0: static TInt NewLC(RFs& aFs,CIniFileIn*& aIniFile,const TDesC& aFullFileName); sl@0: ~CIniFileIn(); sl@0: sl@0: TInt ReadSettingL(TServerSetting& aSetting,TSecurityPolicy& aSingleReadPolicy,TSecurityPolicy& aSingleWritePolicy, TBool& aSingleReadPolicyFound, TBool& aSingleWritePolicyFound, TBool& aSingleMetaFound); sl@0: sl@0: TInt ReadPlatSecSectionL(TSecurityPolicy& aDefaultReadPolicy, TBool& aGotDefaultReadPolicy, sl@0: TSecurityPolicy& aDefaultWritePolicy, TBool& aGotDefaultWritePolicy, sl@0: RRangePolicyArray& aRangePolicies); sl@0: TInt ReadRdPolicyL(TSecurityPolicy& aReadPolicy); sl@0: TInt ReadWrPolicyL(TSecurityPolicy& aWritePolicy); sl@0: TInt ReadOwnerSectionL(TUint32 &aOwnerUID) ; sl@0: TInt ReadTimeStampSectionL(TTime &aTimeStamp) ; sl@0: TInt ReadDefaultMetaSecSectionL(TUint32& aDefaultMeta, sl@0: RDefaultMetaArray& aDefaultMetaRanges) ; sl@0: TInt SkipPlatSecSectionL(); sl@0: TInt SkipOwnerSectionL() ; sl@0: TInt SkipDefaultMetaSectionL() ; sl@0: TInt SkipTimeStampSectionL() ; sl@0: sl@0: TInt FindMainSectionL(void) ; sl@0: sl@0: #ifdef CENTREP_TRACE sl@0: HBufC* FullName(); sl@0: #endif sl@0: private: sl@0: TInt ReadHeaderL(); sl@0: TInt ReadSettingOnlyL(TServerSetting& aSetting, TBool& aSingleMetaFound); sl@0: TInt ReadStringL(HBufC8*& aString); sl@0: TInt ReadString16To8L(HBufC8*& aString); sl@0: TInt ReadBinaryL(HBufC8*& aString); sl@0: void SkipComments(); sl@0: void SkipEqualSign(); sl@0: sl@0: TInt ReadNumber(TUint32& aVal); sl@0: TInt ReadCapabilityL(TCapability& aCapability); sl@0: void CheckForAlwaysPassOrFailL(TBool& aAlwaysPass,TBool& aAlwaysFail); sl@0: TInt ReadPolicyL(TSecurityPolicy& aPolicy,TInt aPolicyType); sl@0: TInt ReadCapabilitiesL(TSecurityPolicy& aPolicy); sl@0: TInt ReadSidAndCapabilitiesL(TSecurityPolicy& aPolicy,const TDesC& aPolicyType, sl@0: TSecureId& aSid); sl@0: TInt ReadRangePoliciesL(const TSecurityPolicy& aDefaultReadPolicy,const TSecurityPolicy& aDefaultWritePolicy, sl@0: RRangePolicyArray& aRangePolicies); sl@0: TInt ReadRangeMetaDefaultsL(RDefaultMetaArray& aDefaultMetaRanges); sl@0: sl@0: sl@0: TInt GetPlatSecSectionLC(HBufC*& aSection); sl@0: TInt GetTimeStampSectionLC(HBufC*& aSection); sl@0: TInt GetOwnerSectionLC(HBufC*& aSection) ; sl@0: TInt GetDefaultMetaSectionLC(HBufC*& aSection) ; sl@0: TInt GetSectionLC(const TDesC16& aSectionId, HBufC*& aSection) ; sl@0: CIniFileIn(RFs& aFs):iFs(aFs){} sl@0: private: sl@0: HBufC* iBuf; sl@0: #ifdef CENTREP_TRACE sl@0: HBufC* iFullName; sl@0: #endif sl@0: TLex iLex; sl@0: TLexMark iMainSectionMark; sl@0: RFs iFs; sl@0: // sl@0: }; sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////// sl@0: //The txt persistence is not needed inside the server but rather for the tool sl@0: #ifdef CENTREP_CONV_TOOL sl@0: sl@0: // CIniFileOut class sl@0: enum TCapAccessMode sl@0: { sl@0: ECapReadAccess, sl@0: ECapWriteAccess sl@0: }; sl@0: /** sl@0: @internalTechnology sl@0: */ sl@0: class CIniFileOut : public CBase sl@0: { sl@0: public: sl@0: static CIniFileOut* NewLC(RFs& aFs,const TDesC& aOutFileName); sl@0: ~CIniFileOut(); sl@0: void CommitL(); sl@0: sl@0: void WriteHeaderL(); sl@0: void WriteOwnerSectionL(TUid aOwner); sl@0: void WriteTimeStampL(const TTime& aTime); sl@0: void WriteMetaDataL(TUint32 aDefaultMeta, sl@0: const RDefaultMetaArray& aDefaultMetaRanges); sl@0: sl@0: #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS sl@0: void WritePlatSecL(const TSettingsAccessPolicy& aDefaultAccessPolicy, sl@0: const RRangePolicyArray& aRangePolicies,TUint32 aCreVersion); sl@0: #else sl@0: void WritePlatSecL(const TSecurityPolicy& aDefaultReadPolicy, sl@0: const TSecurityPolicy& aDefaultWritePolicy, sl@0: const RRangePolicyArray& aRangePolicies); sl@0: #endif sl@0: sl@0: void WriteMainSectionHeaderL(); sl@0: void WriteSettingL(const TServerSetting& aSetting sl@0: #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS sl@0: ,TUint32 aCreVersion sl@0: #endif sl@0: ); sl@0: void WriteSettingL(const TServerSetting& aSetting, sl@0: const TSettingsAccessPolicy& aAccessPolicy sl@0: #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS sl@0: ,TUint32 aCreVersion sl@0: #endif sl@0: ); sl@0: private: sl@0: CIniFileOut(RFs& aFs); sl@0: void ConstructL(const TDesC& aOutFileName); sl@0: void WriteLineL(const TDesC& aData); sl@0: void AppendSecurityPolicyL(const TSecurityPolicy& aPolicy, sl@0: TCapAccessMode aRdWrMode); sl@0: void DoSettingL(const TServerSetting& aSetting sl@0: #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS sl@0: ,TUint32 aCreVersion sl@0: #endif sl@0: ); sl@0: sl@0: private: sl@0: TBool iCommited; sl@0: RFile iTransFile; //Transaction file sl@0: RFileBuf iTransFileBuf; //Transaction file buffer sl@0: TParse iTransFilePath; //Transaction file name. sl@0: TBuf iBuf;//General purpose buffer, used internally sl@0: HBufC* iOutFileName; sl@0: RFs iFs; sl@0: }; sl@0: #endif //CENTREP_CONV_TOOL sl@0: sl@0: #endif // __CENREP_INIFILE_H__