Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "FileserverUtil.h"
22 * @enum Constant Literals used.
28 _LIT( KExpectedName, "expectedName" );
29 _LIT( KExpectedSize, "expectedSize" );
30 _LIT( KExpectedTime, "expectedTime" );
31 _LIT( KExpectedUid1, "expectedUid1" );
32 _LIT( KExpectedUid2, "expectedUid2" );
33 _LIT( KExpectedUid3, "expectedUid3" );
34 _LIT( KVolumeLabel, "volume_label" );
35 _LIT( KVolumeSize, "volume_size");
36 _LIT( KVolumeFreeSpace, "volume_free_space" );
37 _LIT( KVolumeUniqueID, "volume_unique_id");
38 _LIT( KExpectedMostDerivedUid, "expectedMostDerivedUid" );
39 _LIT( KVolumeFileCacheFlags, "volume_File_Cache_Flags" );
40 _LIT( KFileCacheReadEnabled, "EFileCacheReadEnabled" );
41 _LIT( KFileCacheReadOn, "EFileCacheReadOn");
42 _LIT( KFileCacheReadAheadEnabled, "EFileCacheReadAheadEnabled" );
43 _LIT( KFileCacheReadAheadOn, "EFileCacheReadAheadOn" );
44 _LIT( KFileCacheWriteEnabled, "EFileCacheWriteEnabled" );
45 _LIT( KFileCacheWriteOn, "EFileCacheWriteOn" );
48 _LIT(KEntryAttNormalStr, "KEntryAttNormal");
49 _LIT(KEntryAttReadOnlyStr, "KEntryAttReadOnly");
50 _LIT(KEntryAttHiddenStr, "KEntryAttHidden");
51 _LIT(KEntryAttSystemStr, "KEntryAttSystem");
52 _LIT(KEntryAttVolumeStr, "KEntryAttVolume");
53 _LIT(KEntryAttDirStr, "KEntryAttDir");
54 _LIT(KEntryAttArchiveStr, "KEntryAttArchive");
55 _LIT(KEntryAttXIPStr, "KEntryAttXIP");
56 #if (!defined(__Symbian_OS_v9_1__))
57 _LIT(KEntryAttRemoteStr, "KEntryAttRemote");
58 _LIT(KEntryAttMaskFileSystemSpecificStr,"KEntryAttMaskFileSystemSpecific");
60 _LIT(KEntryAttMatchMaskStr, "KEntryAttMatchMask");
61 _LIT(KEntryAttMaskSupportedStr, "KEntryAttMaskSupported");
62 _LIT(KEntryAttMatchExclusiveStr, "KEntryAttMatchExclusive");
63 _LIT(KEntryAttMatchExcludeStr, "KEntryAttMatchExclude");
64 _LIT(KEntryAttAllowUidStr, "KEntryAttAllowUid");
67 const TInt KUid1Index = 0;
68 const TInt KUid2Index = 1;
69 const TInt KUid3Index = 2;
71 const TInt KTimeFormatSize = 30;
72 _LIT( KTimeFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B" );
78 TBool FileserverUtil::VerifyTEntryDataFromIniL(CDataWrapper& aDataWrapper, const TDesC& aSection, TEntry& aEntry)
82 aDataWrapper.INFO_PRINTF2(_L("Entry name = %S"), &aEntry.iName );
85 if ( aDataWrapper.GetStringFromConfig(aSection, KExpectedName(), expectedStr) )
87 if (aEntry.iName.CompareC(expectedStr, 0, NULL) != 0)
89 aDataWrapper.ERR_PRINTF3(_L("%S != %S"), &aEntry.iName, &expectedStr);
94 aDataWrapper.INFO_PRINTF3(_L("%S == %S"), &aEntry.iName, &expectedStr);
99 if ( aDataWrapper.GetIntFromConfig(aSection, KExpectedSize(), expectedInt) )
101 aDataWrapper.INFO_PRINTF2(_L("Entry size = %d"), aEntry.iSize );
102 if (aEntry.iSize != expectedInt)
104 aDataWrapper.ERR_PRINTF3(_L("Size from ini file not equal with size returned from function (%d != %d)"), expectedInt, aEntry.iSize);
109 if ( aDataWrapper.GetStringFromConfig(aSection, KExpectedTime(), expectedStr) )
111 TBuf<KTimeFormatSize> dateString;
112 aEntry.iModified.FormatL(dateString, KTimeFormat);
113 aDataWrapper.INFO_PRINTF2(_L("Entry modified %S"), &dateString);
115 TTime modificationTime;
116 User::LeaveIfError(modificationTime.Set(expectedStr));
118 if (aEntry.iModified != modificationTime)
120 aDataWrapper.ERR_PRINTF1(_L("Time from ini file not equal with time returned from function."));
125 if ( aDataWrapper.GetIntFromConfig(aSection, KExpectedUid1(), expectedInt) )
127 TInt uid1 = aEntry.iType[KUid1Index].iUid;
128 aDataWrapper.INFO_PRINTF2(_L("Entry UID1 = %d"), uid1 );
130 if ( uid1 != expectedInt )
132 aDataWrapper.ERR_PRINTF3(_L("Entry UID1 %d != ini UID1 %d)"), uid1, expectedInt);
137 if ( aDataWrapper.GetIntFromConfig(aSection, KExpectedUid2(), expectedInt) )
139 TInt uid2 = aEntry.iType[KUid2Index].iUid;
140 aDataWrapper.INFO_PRINTF2(_L("Entry UID2 = %d"), uid2 );
142 if ( uid2 != expectedInt )
144 aDataWrapper.ERR_PRINTF3(_L("Entry UID2 %d != ini UID1 %d)"), uid2, expectedInt);
149 if ( aDataWrapper.GetIntFromConfig(aSection, KExpectedUid3(), expectedInt) )
151 TInt uid3 = aEntry.iType[KUid3Index].iUid;
152 aDataWrapper.INFO_PRINTF2(_L("Entry UID3 = %d"), uid3 );
154 if ( uid3 != expectedInt )
156 aDataWrapper.ERR_PRINTF3(_L("Entry UID3 %d != ini UID3 %d)"), uid3, expectedInt);
161 if ( aDataWrapper.GetIntFromConfig(aSection, KExpectedMostDerivedUid(), expectedInt) )
163 TInt mostDerivedUid = aEntry.MostDerivedUid().iUid;
164 aDataWrapper.INFO_PRINTF2(_L("MostDerivedUid = %d"), mostDerivedUid);
166 if ( mostDerivedUid != expectedInt )
168 aDataWrapper.ERR_PRINTF3(_L("Entry MostDerivedUid %d != ini MostDerivedUid %d)"), mostDerivedUid, expectedInt);
179 TBool FileserverUtil::VerifyTVolumeInfoDataFromIniL(CDataWrapper& aDataWrapper, const TDesC& aSection, TVolumeInfo& aVolumeInfo)
183 //Get volume name from config.
185 if (aDataWrapper.GetStringFromConfig(aSection, KVolumeLabel(), volumeLabel))
187 //Checking that name of volume is equal to passed through config file.
188 if (aVolumeInfo.iName.CompareC(volumeLabel, 0, NULL) != 0)
190 aDataWrapper.ERR_PRINTF1(_L("Volume name from ini file not equal with volume name returned from function"));
196 if (aDataWrapper.GetIntFromConfig(aSection, KVolumeSize(), tmp))
200 //Checking that size of volume is equal to passed through config file.
201 if (volumeSize != aVolumeInfo.iSize)
203 aDataWrapper.ERR_PRINTF1(_L("Volume size from ini file not equal with volume size returned from function"));
208 if (aDataWrapper.GetIntFromConfig(aSection, KVolumeFreeSpace(), tmp))
212 //Checking that free space of volume is equal to passed through config file.
213 if (freeSpace != aVolumeInfo.iFree)
215 aDataWrapper.ERR_PRINTF1(_L("Volume free space amount from ini file not equal with volume free space amount returned from function"));
220 if (aDataWrapper.GetIntFromConfig(aSection, KVolumeUniqueID(), tmp))
224 aDataWrapper.ERR_PRINTF1(_L("ID in config should be not less than 0 "));
229 TUint volumeUniqueID;
230 volumeUniqueID = (TUint)tmp;
231 //Checking that Unique ID of volume is equal to passed through config file.
232 if (volumeUniqueID != aVolumeInfo.iUniqueID)
234 aDataWrapper.ERR_PRINTF1(_L("Volume unique ID from ini file not equal with volume unique ID returned from function"));
240 TPtrC volumeFileCacheFlags;
241 if (aDataWrapper.GetStringFromConfig(aSection, KVolumeFileCacheFlags(), volumeFileCacheFlags))
243 TFileCacheFlags tmpFileCacheFlags;
244 if(volumeFileCacheFlags == KFileCacheReadEnabled())
246 tmpFileCacheFlags = EFileCacheReadEnabled;
248 else if(volumeFileCacheFlags == KFileCacheReadOn())
250 tmpFileCacheFlags = EFileCacheReadOn;
252 else if(volumeFileCacheFlags == KFileCacheReadAheadEnabled())
254 tmpFileCacheFlags = EFileCacheReadAheadEnabled;
256 else if(volumeFileCacheFlags == KFileCacheReadAheadOn())
258 tmpFileCacheFlags = EFileCacheReadAheadOn;
260 else if(volumeFileCacheFlags == KFileCacheWriteEnabled())
262 tmpFileCacheFlags = EFileCacheWriteEnabled;
264 else if(volumeFileCacheFlags == KFileCacheWriteOn())
266 tmpFileCacheFlags = EFileCacheWriteOn;
270 aDataWrapper.ERR_PRINTF1(_L("Volume file cache flags from ini file not equal with volume file cache flags returned from function"));
274 if(ret && (aVolumeInfo.iFileCacheFlags != tmpFileCacheFlags))
276 aDataWrapper.ERR_PRINTF1(_L("Volume file cache flags from ini file not equal with volume file cache flags returned from function"));
285 TBool FileserverUtil::GetAttMask(CDataWrapper& aDataWrapper, const TDesC& aSection, const TDesC& aParameterName, TUint& aAttMask)
288 TBool ret = aDataWrapper.GetStringFromConfig(aSection, aParameterName, iniAttMaskStr);
291 if ( !ConvertToAttMask(iniAttMaskStr, aAttMask) )
294 ret = aDataWrapper.GetIntFromConfig(aSection, aParameterName, intTemp);
307 TBool FileserverUtil::ConvertToAttMask(const TDesC& aAttMaskStr, TUint& aAttMask)
311 if (aAttMaskStr == KEntryAttNormalStr)
313 aAttMask = KEntryAttNormal;
315 else if (aAttMaskStr == KEntryAttReadOnlyStr)
317 aAttMask = KEntryAttReadOnly;
319 else if (aAttMaskStr == KEntryAttHiddenStr)
321 aAttMask = KEntryAttHidden;
323 else if (aAttMaskStr == KEntryAttSystemStr)
325 aAttMask = KEntryAttSystem;
327 else if (aAttMaskStr == KEntryAttVolumeStr)
329 aAttMask = KEntryAttVolume;
331 else if (aAttMaskStr == KEntryAttDirStr)
333 aAttMask = KEntryAttDir;
335 else if (aAttMaskStr == KEntryAttArchiveStr)
337 aAttMask = KEntryAttArchive;
339 else if (aAttMaskStr == KEntryAttXIPStr)
341 aAttMask = KEntryAttXIP;
343 #if (!defined(__Symbian_OS_v9_1__))
344 else if (aAttMaskStr == KEntryAttRemoteStr)
346 aAttMask = KEntryAttRemote;
348 else if (aAttMaskStr == KEntryAttMaskFileSystemSpecificStr)
350 aAttMask = KEntryAttMaskFileSystemSpecific;
353 else if (aAttMaskStr == KEntryAttMatchMaskStr)
355 aAttMask = KEntryAttMatchMask;
357 else if (aAttMaskStr == KEntryAttMaskSupportedStr)
359 aAttMask = KEntryAttMaskSupported;
361 else if (aAttMaskStr == KEntryAttMatchExclusiveStr)
363 aAttMask = KEntryAttMatchExclusive;
365 else if (aAttMaskStr == KEntryAttMatchExcludeStr)
367 aAttMask = KEntryAttMatchExclude;
369 else if (aAttMaskStr == KEntryAttAllowUidStr)
371 aAttMask = KEntryAttAllowUid;
373 else if (aAttMaskStr.Match((_L("*|*"))) != KErrNotFound)
377 TInt location = aAttMaskStr.Match(_L("*|*"));
378 //Converting Left part of the data
379 TPtrC left = aAttMaskStr.Left(location);
380 if (ConvertToAttMask(left, tmpAttMask))
382 aAttMask = tmpAttMask;
389 //Converting right data can be with another "|"
390 TPtrC right = aAttMaskStr.Mid(location + 1);
391 if (ConvertToAttMask(right, tmpAttMask))
393 aAttMask = aAttMask | tmpAttMask;