sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "T_EntryData.h"
|
sl@0
|
20 |
#include "T_SfSrvServer.h"
|
sl@0
|
21 |
#include "FileserverUtil.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
// Commands
|
sl@0
|
24 |
_LIT( KCmdAssignmentOperator, "=" );
|
sl@0
|
25 |
_LIT( KCmdIndexOperator, "[]" );
|
sl@0
|
26 |
_LIT( KCmdDelete, "~" );
|
sl@0
|
27 |
_LIT( KCmdIsArchive, "IsArchive" );
|
sl@0
|
28 |
_LIT( KCmdIsDir, "IsDir" );
|
sl@0
|
29 |
_LIT( KCmdIsHidden, "IsHidden" );
|
sl@0
|
30 |
_LIT( KCmdIsReadOnly, "IsReadOnly" );
|
sl@0
|
31 |
_LIT( KCmdIsSystem, "IsSystem" );
|
sl@0
|
32 |
_LIT( KCmdIsTypeValid, "IsTypeValid" );
|
sl@0
|
33 |
_LIT( KCmdIsUidPresent, "IsUidPresent" );
|
sl@0
|
34 |
_LIT( KCmdMostDerivedUid, "MostDerivedUid" );
|
sl@0
|
35 |
_LIT( KCmdNew, "new" );
|
sl@0
|
36 |
_LIT( KCmdSetAttribute, "SetAttribute" );
|
sl@0
|
37 |
|
sl@0
|
38 |
// Parameters
|
sl@0
|
39 |
_LIT( KParamAttribute, "attribute" );
|
sl@0
|
40 |
_LIT( KParamObject, "object" );
|
sl@0
|
41 |
_LIT( KExpected, "expected" );
|
sl@0
|
42 |
_LIT( KParamIndex, "index" );
|
sl@0
|
43 |
_LIT( KParamState, "state" );
|
sl@0
|
44 |
_LIT( KValue, "value" );
|
sl@0
|
45 |
|
sl@0
|
46 |
// Attributes
|
sl@0
|
47 |
_LIT(KEntryAttNormalStr, "KEntryAttNormal");
|
sl@0
|
48 |
_LIT(KEntryAttReadOnlyStr, "KEntryAttReadOnly");
|
sl@0
|
49 |
_LIT(KEntryAttHiddenStr, "KEntryAttHidden");
|
sl@0
|
50 |
_LIT(KEntryAttSystemStr, "KEntryAttSystem");
|
sl@0
|
51 |
_LIT(KEntryAttVolumeStr, "KEntryAttVolume");
|
sl@0
|
52 |
_LIT(KEntryAttDirStr, "KEntryAttDir");
|
sl@0
|
53 |
_LIT(KEntryAttArchiveStr, "KEntryAttArchive");
|
sl@0
|
54 |
_LIT(KEntryAttXIPStr, "KEntryAttXIP");
|
sl@0
|
55 |
|
sl@0
|
56 |
|
sl@0
|
57 |
// other string values
|
sl@0
|
58 |
#define KTimeFormatSize 30
|
sl@0
|
59 |
|
sl@0
|
60 |
|
sl@0
|
61 |
CT_EntryData* CT_EntryData::NewL( )
|
sl@0
|
62 |
/**
|
sl@0
|
63 |
* Two phase constructor
|
sl@0
|
64 |
*/
|
sl@0
|
65 |
{
|
sl@0
|
66 |
CT_EntryData* ret = new (ELeave) CT_EntryData( );
|
sl@0
|
67 |
CleanupStack::PushL( ret );
|
sl@0
|
68 |
ret->ConstructL();
|
sl@0
|
69 |
CleanupStack::Pop( ret );
|
sl@0
|
70 |
return ret;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
CT_EntryData::CT_EntryData( )
|
sl@0
|
74 |
: iEntry(NULL)
|
sl@0
|
75 |
, iFs(NULL)
|
sl@0
|
76 |
|
sl@0
|
77 |
/**
|
sl@0
|
78 |
* Protected constructor. First phase construction
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
{
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
void CT_EntryData::ConstructL()
|
sl@0
|
84 |
/**
|
sl@0
|
85 |
* Protected constructor. Second phase construction
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
{
|
sl@0
|
88 |
}
|
sl@0
|
89 |
|
sl@0
|
90 |
CT_EntryData::~CT_EntryData()
|
sl@0
|
91 |
/**
|
sl@0
|
92 |
* Destructor.
|
sl@0
|
93 |
*/
|
sl@0
|
94 |
{
|
sl@0
|
95 |
DoCleanup();
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
void CT_EntryData::DoCleanup()
|
sl@0
|
99 |
/** Deltes TEntry class instance */
|
sl@0
|
100 |
{
|
sl@0
|
101 |
INFO_PRINTF1( _L( "Delete TEntry class instance" ) );
|
sl@0
|
102 |
delete iEntry;
|
sl@0
|
103 |
iEntry = NULL;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
TAny* CT_EntryData::GetObject()
|
sl@0
|
107 |
/**
|
sl@0
|
108 |
* Return a pointer to the object that the data wraps
|
sl@0
|
109 |
*
|
sl@0
|
110 |
* @return pointer to the object that the data wraps
|
sl@0
|
111 |
*/
|
sl@0
|
112 |
{
|
sl@0
|
113 |
return iEntry;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
void CT_EntryData::SetObjectL( TAny* aAny )
|
sl@0
|
117 |
/**
|
sl@0
|
118 |
* Set the wrapped data object with new value
|
sl@0
|
119 |
*/
|
sl@0
|
120 |
{
|
sl@0
|
121 |
DoCleanup();
|
sl@0
|
122 |
iEntry = static_cast<TEntry*> ( aAny );
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
void CT_EntryData::DisownObjectL()
|
sl@0
|
126 |
/**
|
sl@0
|
127 |
* Clear the wrapped data object pointer w/o de-initialization
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
{
|
sl@0
|
130 |
iEntry = NULL;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
inline TCleanupOperation CT_EntryData::CleanupOperation()
|
sl@0
|
134 |
/**
|
sl@0
|
135 |
* Return static cleanup function
|
sl@0
|
136 |
*/
|
sl@0
|
137 |
{
|
sl@0
|
138 |
return CleanupOperation;
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
void CT_EntryData::CleanupOperation( TAny* aAny )
|
sl@0
|
142 |
/**
|
sl@0
|
143 |
* Static cleanup function
|
sl@0
|
144 |
*/
|
sl@0
|
145 |
{
|
sl@0
|
146 |
TEntry* entry = static_cast<TEntry*> ( aAny );
|
sl@0
|
147 |
delete entry;
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
TBool CT_EntryData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
|
sl@0
|
151 |
/**
|
sl@0
|
152 |
* Process a command read from the ini file
|
sl@0
|
153 |
*
|
sl@0
|
154 |
* @param aCommand the command to process
|
sl@0
|
155 |
* @param aSection the entry in the ini file requiring the command to be processed
|
sl@0
|
156 |
*
|
sl@0
|
157 |
* @return ETrue if the command is processed
|
sl@0
|
158 |
*/
|
sl@0
|
159 |
{
|
sl@0
|
160 |
TBool retVal = ETrue;
|
sl@0
|
161 |
|
sl@0
|
162 |
if ( aCommand == KCmdAssignmentOperator )
|
sl@0
|
163 |
{
|
sl@0
|
164 |
DoCmdAssignmentOperatorL( aSection );
|
sl@0
|
165 |
}
|
sl@0
|
166 |
else if ( aCommand == KCmdIndexOperator )
|
sl@0
|
167 |
{
|
sl@0
|
168 |
DoCmdIndexOperator( aSection );
|
sl@0
|
169 |
}
|
sl@0
|
170 |
else if ( aCommand == KCmdDelete )
|
sl@0
|
171 |
{
|
sl@0
|
172 |
DoCleanup();
|
sl@0
|
173 |
}
|
sl@0
|
174 |
else if ( aCommand == KCmdIsArchive )
|
sl@0
|
175 |
{
|
sl@0
|
176 |
DoCmdIsArchive( aSection );
|
sl@0
|
177 |
}
|
sl@0
|
178 |
else if ( aCommand == KCmdIsDir )
|
sl@0
|
179 |
{
|
sl@0
|
180 |
DoCmdIsDir( aSection );
|
sl@0
|
181 |
}
|
sl@0
|
182 |
else if ( aCommand == KCmdIsHidden )
|
sl@0
|
183 |
{
|
sl@0
|
184 |
DoCmdIsHidden( aSection );
|
sl@0
|
185 |
}
|
sl@0
|
186 |
else if ( aCommand == KCmdIsReadOnly )
|
sl@0
|
187 |
{
|
sl@0
|
188 |
DoCmdIsReadOnly( aSection );
|
sl@0
|
189 |
}
|
sl@0
|
190 |
else if ( aCommand == KCmdIsSystem )
|
sl@0
|
191 |
{
|
sl@0
|
192 |
DoCmdIsSystem( aSection );
|
sl@0
|
193 |
}
|
sl@0
|
194 |
else if ( aCommand == KCmdIsTypeValid )
|
sl@0
|
195 |
{
|
sl@0
|
196 |
DoCmdIsTypeValid( aSection );
|
sl@0
|
197 |
}
|
sl@0
|
198 |
else if ( aCommand == KCmdIsUidPresent )
|
sl@0
|
199 |
{
|
sl@0
|
200 |
DoCmdIsUidPresent( aSection );
|
sl@0
|
201 |
}
|
sl@0
|
202 |
else if ( aCommand == KCmdMostDerivedUid )
|
sl@0
|
203 |
{
|
sl@0
|
204 |
DoCmdMostDerived( aSection );
|
sl@0
|
205 |
}
|
sl@0
|
206 |
else if ( aCommand == KCmdNew )
|
sl@0
|
207 |
{
|
sl@0
|
208 |
DoCmdNew( aSection );
|
sl@0
|
209 |
}
|
sl@0
|
210 |
else if ( aCommand == KCmdSetAttribute )
|
sl@0
|
211 |
{
|
sl@0
|
212 |
DoCmdSetAttribute( aSection );
|
sl@0
|
213 |
}
|
sl@0
|
214 |
else
|
sl@0
|
215 |
{
|
sl@0
|
216 |
retVal = EFalse;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
|
sl@0
|
219 |
return retVal;
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
void CT_EntryData::DoCmdNew( const TDesC& aSection )
|
sl@0
|
223 |
/** Creates new TEntry class instance */
|
sl@0
|
224 |
{
|
sl@0
|
225 |
DoCleanup();
|
sl@0
|
226 |
|
sl@0
|
227 |
TPtrC entryObjectName;
|
sl@0
|
228 |
if( GET_OPTIONAL_STRING_PARAMETER( KParamObject, aSection, entryObjectName ) )
|
sl@0
|
229 |
{
|
sl@0
|
230 |
INFO_PRINTF1( _L( "Create new TEntry(TEntry) class instance." ) );
|
sl@0
|
231 |
|
sl@0
|
232 |
TEntry* entryObject = NULL;
|
sl@0
|
233 |
TRAPD( err, entryObject = (TEntry*)GetDataObjectL(entryObjectName));
|
sl@0
|
234 |
if ( err == KErrNone )
|
sl@0
|
235 |
{
|
sl@0
|
236 |
TRAPD( err, iEntry = new (ELeave) TEntry(*entryObject) );
|
sl@0
|
237 |
if ( err != KErrNone )
|
sl@0
|
238 |
{
|
sl@0
|
239 |
ERR_PRINTF2( _L( "new TEntry(TEntry) error %d" ), err );
|
sl@0
|
240 |
SetError( err );
|
sl@0
|
241 |
}
|
sl@0
|
242 |
}
|
sl@0
|
243 |
else
|
sl@0
|
244 |
{
|
sl@0
|
245 |
ERR_PRINTF3( _L( "Unrecognized object name parameter value: %S. Error %d"), &entryObjectName, err );
|
sl@0
|
246 |
SetBlockResult( EFail );
|
sl@0
|
247 |
}
|
sl@0
|
248 |
}
|
sl@0
|
249 |
else
|
sl@0
|
250 |
{
|
sl@0
|
251 |
INFO_PRINTF1( _L( "Create new TEntry() class instance." ) );
|
sl@0
|
252 |
TRAPD( err, iEntry = new (ELeave) TEntry() );
|
sl@0
|
253 |
if ( err!=KErrNone )
|
sl@0
|
254 |
{
|
sl@0
|
255 |
ERR_PRINTF2( _L( "new TEntry() error %d" ), err );
|
sl@0
|
256 |
SetError( err );
|
sl@0
|
257 |
}
|
sl@0
|
258 |
}
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
void CT_EntryData::DoCmdIndexOperator( const TDesC& aSection )
|
sl@0
|
262 |
/** Checks if the given UID is the same as required */
|
sl@0
|
263 |
{
|
sl@0
|
264 |
TInt iniIndex;
|
sl@0
|
265 |
if ( GET_MANDATORY_INT_PARAMETER( KParamIndex, aSection, iniIndex ) )
|
sl@0
|
266 |
{
|
sl@0
|
267 |
TInt value = (*iEntry)[iniIndex].iUid;
|
sl@0
|
268 |
INFO_PRINTF3( _L( "UID[%d] = %d" ), iniIndex, value );
|
sl@0
|
269 |
|
sl@0
|
270 |
TInt iniExpected;
|
sl@0
|
271 |
if ( GET_OPTIONAL_INT_PARAMETER( KExpected, aSection, iniExpected ) )
|
sl@0
|
272 |
{
|
sl@0
|
273 |
if ( value != iniExpected )
|
sl@0
|
274 |
{
|
sl@0
|
275 |
INFO_PRINTF3( _L( "values not the same %d != %d" ), value, iniExpected );
|
sl@0
|
276 |
SetBlockResult( EFail );
|
sl@0
|
277 |
}
|
sl@0
|
278 |
}
|
sl@0
|
279 |
}
|
sl@0
|
280 |
}
|
sl@0
|
281 |
|
sl@0
|
282 |
void CT_EntryData::DoCmdAssignmentOperatorL( const TDesC& aSection )
|
sl@0
|
283 |
/** Assigns another TEntry to this TEntry using "=" operator */
|
sl@0
|
284 |
{
|
sl@0
|
285 |
TPtrC entryObjectName;
|
sl@0
|
286 |
if( GET_MANDATORY_STRING_PARAMETER( KParamObject, aSection, entryObjectName ) )
|
sl@0
|
287 |
{
|
sl@0
|
288 |
INFO_PRINTF2( _L( "Assign a %S to this TEntry" ), &entryObjectName );
|
sl@0
|
289 |
|
sl@0
|
290 |
TEntry* entryObject = NULL;
|
sl@0
|
291 |
TRAPD( err, entryObject = (TEntry*)GetDataObjectL(entryObjectName));
|
sl@0
|
292 |
if ( err == KErrNone && entryObject)
|
sl@0
|
293 |
{
|
sl@0
|
294 |
*iEntry = iEntry->operator=(*entryObject);
|
sl@0
|
295 |
}
|
sl@0
|
296 |
else
|
sl@0
|
297 |
{
|
sl@0
|
298 |
ERR_PRINTF3( _L( "Object not found or not initialised: %S. Error %d"), &entryObjectName, err );
|
sl@0
|
299 |
SetBlockResult( EFail );
|
sl@0
|
300 |
}
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
if ( !FileserverUtil::VerifyTEntryDataFromIniL(*this, aSection, *iEntry))
|
sl@0
|
304 |
{
|
sl@0
|
305 |
SetBlockResult(EFail);
|
sl@0
|
306 |
}
|
sl@0
|
307 |
}
|
sl@0
|
308 |
|
sl@0
|
309 |
void CT_EntryData::DoCmdIsArchive( const TDesC& aSection )
|
sl@0
|
310 |
/** Checks if TEntry has Archive attribute using IsArchive() function */
|
sl@0
|
311 |
{
|
sl@0
|
312 |
INFO_PRINTF1( _L( "IsArchive()" ) );
|
sl@0
|
313 |
TBool result = iEntry->IsArchive();
|
sl@0
|
314 |
|
sl@0
|
315 |
TBool expected;
|
sl@0
|
316 |
if( GET_MANDATORY_BOOL_PARAMETER( KExpected, aSection, expected ) )
|
sl@0
|
317 |
{
|
sl@0
|
318 |
if ( !( CompareBool(result, expected) ) )
|
sl@0
|
319 |
{
|
sl@0
|
320 |
ERR_PRINTF1( _L( "Error compare function result and expected value" ));
|
sl@0
|
321 |
SetBlockResult(EFail);
|
sl@0
|
322 |
}
|
sl@0
|
323 |
}
|
sl@0
|
324 |
}
|
sl@0
|
325 |
|
sl@0
|
326 |
void CT_EntryData::DoCmdIsDir( const TDesC& aSection )
|
sl@0
|
327 |
/** Checks if TEntry has Dir attribute using IsDir() function */
|
sl@0
|
328 |
{
|
sl@0
|
329 |
INFO_PRINTF1( _L( "IsDir()" ) );
|
sl@0
|
330 |
TBool result = iEntry->IsDir();
|
sl@0
|
331 |
|
sl@0
|
332 |
TBool expected;
|
sl@0
|
333 |
if( GET_MANDATORY_BOOL_PARAMETER( KExpected, aSection, expected ) )
|
sl@0
|
334 |
{
|
sl@0
|
335 |
if ( !( CompareBool(result, expected) ) )
|
sl@0
|
336 |
{
|
sl@0
|
337 |
ERR_PRINTF1( _L( "Error compare function result and expected value" ));
|
sl@0
|
338 |
SetBlockResult(EFail);
|
sl@0
|
339 |
}
|
sl@0
|
340 |
}
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
void CT_EntryData::DoCmdIsHidden( const TDesC& aSection )
|
sl@0
|
344 |
/** Checks if TEntry has Hidden attribute using IsHidden() function */
|
sl@0
|
345 |
{
|
sl@0
|
346 |
INFO_PRINTF1( _L( "IsHidden()" ) );
|
sl@0
|
347 |
TBool result = iEntry->IsHidden();
|
sl@0
|
348 |
|
sl@0
|
349 |
TBool expected;
|
sl@0
|
350 |
if( GET_MANDATORY_BOOL_PARAMETER( KExpected, aSection, expected ) )
|
sl@0
|
351 |
{
|
sl@0
|
352 |
if ( !( CompareBool(result, expected) ) )
|
sl@0
|
353 |
{
|
sl@0
|
354 |
ERR_PRINTF1( _L( "Error compare function result and expected value" ));
|
sl@0
|
355 |
SetBlockResult(EFail);
|
sl@0
|
356 |
}
|
sl@0
|
357 |
}
|
sl@0
|
358 |
}
|
sl@0
|
359 |
|
sl@0
|
360 |
void CT_EntryData::DoCmdIsReadOnly( const TDesC& aSection )
|
sl@0
|
361 |
/** Checks if TEntry has ReadOnly attribute using IsReadOnly() function */
|
sl@0
|
362 |
{
|
sl@0
|
363 |
INFO_PRINTF1( _L( "IsReadOnly()" ) );
|
sl@0
|
364 |
TBool result = iEntry->IsReadOnly();
|
sl@0
|
365 |
|
sl@0
|
366 |
TBool expected;
|
sl@0
|
367 |
if( GET_MANDATORY_BOOL_PARAMETER( KExpected, aSection, expected ) )
|
sl@0
|
368 |
{
|
sl@0
|
369 |
if ( !( CompareBool(result, expected) ) )
|
sl@0
|
370 |
{
|
sl@0
|
371 |
ERR_PRINTF1( _L( "Error compare function result and expected value" ));
|
sl@0
|
372 |
SetBlockResult(EFail);
|
sl@0
|
373 |
}
|
sl@0
|
374 |
}
|
sl@0
|
375 |
}
|
sl@0
|
376 |
|
sl@0
|
377 |
void CT_EntryData::DoCmdIsSystem( const TDesC& aSection )
|
sl@0
|
378 |
/** Checks if TEntry has System attribute using IsSystem() function */
|
sl@0
|
379 |
{
|
sl@0
|
380 |
INFO_PRINTF1( _L( "IsSystem()" ) );
|
sl@0
|
381 |
TBool result = iEntry->IsSystem();
|
sl@0
|
382 |
|
sl@0
|
383 |
TBool expected;
|
sl@0
|
384 |
if( GET_MANDATORY_BOOL_PARAMETER( KExpected, aSection, expected ) )
|
sl@0
|
385 |
{
|
sl@0
|
386 |
if ( !( CompareBool(result, expected) ) )
|
sl@0
|
387 |
{
|
sl@0
|
388 |
ERR_PRINTF1( _L( "Error compare function result and expected value" ));
|
sl@0
|
389 |
SetBlockResult(EFail);
|
sl@0
|
390 |
}
|
sl@0
|
391 |
}
|
sl@0
|
392 |
}
|
sl@0
|
393 |
|
sl@0
|
394 |
void CT_EntryData::DoCmdIsTypeValid( const TDesC& aSection )
|
sl@0
|
395 |
/** Checks if TEntry has a valid UID using IsTypeValid() function */
|
sl@0
|
396 |
{
|
sl@0
|
397 |
INFO_PRINTF1( _L( "IsTypeValid()" ) );
|
sl@0
|
398 |
TBool result = iEntry->IsTypeValid();
|
sl@0
|
399 |
|
sl@0
|
400 |
TBool expected;
|
sl@0
|
401 |
if( GET_MANDATORY_BOOL_PARAMETER( KExpected, aSection, expected ) )
|
sl@0
|
402 |
{
|
sl@0
|
403 |
if ( !( CompareBool(result, expected) ) )
|
sl@0
|
404 |
{
|
sl@0
|
405 |
ERR_PRINTF1( _L( "Error compare function result and expected value" ));
|
sl@0
|
406 |
SetBlockResult(EFail);
|
sl@0
|
407 |
}
|
sl@0
|
408 |
}
|
sl@0
|
409 |
}
|
sl@0
|
410 |
|
sl@0
|
411 |
void CT_EntryData::DoCmdIsUidPresent( const TDesC& aSection )
|
sl@0
|
412 |
/** Checks if TEntry has a valid UID using IsTypeValid() function */
|
sl@0
|
413 |
{
|
sl@0
|
414 |
TInt theIntUid;
|
sl@0
|
415 |
TBool expected;
|
sl@0
|
416 |
if( GET_MANDATORY_BOOL_PARAMETER( KExpected, aSection, expected ) &&
|
sl@0
|
417 |
GET_MANDATORY_INT_PARAMETER( KValue, aSection, theIntUid ) )
|
sl@0
|
418 |
{
|
sl@0
|
419 |
INFO_PRINTF2( _L( "IsUidPresent( Uid(%d) )" ), theIntUid );
|
sl@0
|
420 |
TUid theUid;
|
sl@0
|
421 |
theUid.iUid = theIntUid;
|
sl@0
|
422 |
|
sl@0
|
423 |
TBool result = iEntry->IsUidPresent( theUid );
|
sl@0
|
424 |
|
sl@0
|
425 |
if ( !( CompareBool(result, expected) ) )
|
sl@0
|
426 |
{
|
sl@0
|
427 |
ERR_PRINTF1( _L( "Error compare function result and expected value" ));
|
sl@0
|
428 |
SetBlockResult(EFail);
|
sl@0
|
429 |
}
|
sl@0
|
430 |
}
|
sl@0
|
431 |
}
|
sl@0
|
432 |
|
sl@0
|
433 |
void CT_EntryData::DoCmdMostDerived( const TDesC& aSection )
|
sl@0
|
434 |
/** checks if UID with given index is the same as the most derived one by using MostDerived() function */
|
sl@0
|
435 |
{
|
sl@0
|
436 |
TInt id = iEntry->MostDerivedUid().iUid;
|
sl@0
|
437 |
INFO_PRINTF2( _L( "MostDerivedUid = %d" ), id);
|
sl@0
|
438 |
|
sl@0
|
439 |
TInt expected;
|
sl@0
|
440 |
if( GET_OPTIONAL_INT_PARAMETER( KExpected, aSection, expected ) )
|
sl@0
|
441 |
{
|
sl@0
|
442 |
if ( expected != id )
|
sl@0
|
443 |
{
|
sl@0
|
444 |
ERR_PRINTF3( _L( "Error compare UID %d != expected %d" ), id, expected );
|
sl@0
|
445 |
SetBlockResult( EFail );
|
sl@0
|
446 |
}
|
sl@0
|
447 |
}
|
sl@0
|
448 |
}
|
sl@0
|
449 |
|
sl@0
|
450 |
void CT_EntryData::DoCmdSetAttribute( const TDesC& aSection )
|
sl@0
|
451 |
/** Sets or resets attributes */
|
sl@0
|
452 |
{
|
sl@0
|
453 |
TPtrC attrName;
|
sl@0
|
454 |
TBool attrState;
|
sl@0
|
455 |
if( GET_MANDATORY_BOOL_PARAMETER( KParamState, aSection, attrState ) &&
|
sl@0
|
456 |
GET_MANDATORY_STRING_PARAMETER( KParamAttribute, aSection, attrName ) )
|
sl@0
|
457 |
{
|
sl@0
|
458 |
TBool errHappened = EFalse;
|
sl@0
|
459 |
TUint attr;
|
sl@0
|
460 |
if (attrName == KEntryAttNormalStr)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
attr = KEntryAttNormal;
|
sl@0
|
463 |
}
|
sl@0
|
464 |
else if (attrName == KEntryAttReadOnlyStr)
|
sl@0
|
465 |
{
|
sl@0
|
466 |
attr = KEntryAttReadOnly;
|
sl@0
|
467 |
}
|
sl@0
|
468 |
else if (attrName == KEntryAttHiddenStr)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
attr = KEntryAttHidden;
|
sl@0
|
471 |
}
|
sl@0
|
472 |
else if (attrName == KEntryAttSystemStr)
|
sl@0
|
473 |
{
|
sl@0
|
474 |
attr = KEntryAttSystem;
|
sl@0
|
475 |
}
|
sl@0
|
476 |
else if (attrName == KEntryAttVolumeStr)
|
sl@0
|
477 |
{
|
sl@0
|
478 |
attr = KEntryAttVolume;
|
sl@0
|
479 |
}
|
sl@0
|
480 |
else if (attrName == KEntryAttDirStr)
|
sl@0
|
481 |
{
|
sl@0
|
482 |
attr = KEntryAttDir;
|
sl@0
|
483 |
}
|
sl@0
|
484 |
else if (attrName == KEntryAttArchiveStr)
|
sl@0
|
485 |
{
|
sl@0
|
486 |
attr = KEntryAttArchive;
|
sl@0
|
487 |
}
|
sl@0
|
488 |
else if (attrName == KEntryAttXIPStr)
|
sl@0
|
489 |
{
|
sl@0
|
490 |
attr = KEntryAttXIP;
|
sl@0
|
491 |
}
|
sl@0
|
492 |
else
|
sl@0
|
493 |
{
|
sl@0
|
494 |
errHappened = ETrue;
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
if ( errHappened )
|
sl@0
|
498 |
{
|
sl@0
|
499 |
ERR_PRINTF2( _L( "Unknown attribute name parameter: %S" ), &attrName );
|
sl@0
|
500 |
SetBlockResult( EFail );
|
sl@0
|
501 |
}
|
sl@0
|
502 |
else
|
sl@0
|
503 |
{
|
sl@0
|
504 |
TPtrC attrStateString;
|
sl@0
|
505 |
GET_MANDATORY_STRING_PARAMETER( KParamState, aSection, attrStateString );
|
sl@0
|
506 |
INFO_PRINTF3( _L( "SetAttribute(%S, %S)" ), &attrName, &attrStateString);
|
sl@0
|
507 |
|
sl@0
|
508 |
if ( attrState ) // set attribute
|
sl@0
|
509 |
{
|
sl@0
|
510 |
iEntry->iAtt = iEntry->iAtt | attr;
|
sl@0
|
511 |
}
|
sl@0
|
512 |
else // reset attribute
|
sl@0
|
513 |
{
|
sl@0
|
514 |
iEntry->iAtt = iEntry->iAtt ^ ( iEntry->iAtt & attr );
|
sl@0
|
515 |
}
|
sl@0
|
516 |
}
|
sl@0
|
517 |
}
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
|
sl@0
|
521 |
TBool CT_EntryData::CompareBool( TBool aResult, TBool aExpected )
|
sl@0
|
522 |
/** compare 2 TBool values, which can be !=0 and !=1 - some TEntry functions return 2, 3 etc */
|
sl@0
|
523 |
{
|
sl@0
|
524 |
return ( ( aResult > 0 ) == ( aExpected > 0 ) );
|
sl@0
|
525 |
}
|
sl@0
|
526 |
|