63
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
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".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <StifParser.h>
|
|
21 |
#include <CPsQueryItem.h>
|
|
22 |
#include <collate.h>
|
|
23 |
#include "TestSuiteInputData.h"
|
|
24 |
|
|
25 |
// ============================== MEMBER FUNCTIONS ============================
|
|
26 |
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
// Two Phase constructor
|
|
29 |
// ----------------------------------------------------------------------------
|
|
30 |
CTestSuiteInputData* CTestSuiteInputData::NewL(CStifItemParser& aItem)
|
|
31 |
{
|
|
32 |
CTestSuiteInputData* self = new (ELeave) CTestSuiteInputData();
|
|
33 |
CleanupStack::PushL(self);
|
|
34 |
self->ConstructL(aItem);
|
|
35 |
CleanupStack::Pop();
|
|
36 |
return self;
|
|
37 |
}
|
|
38 |
|
|
39 |
// ----------------------------------------------------------------------------
|
|
40 |
// Default constructor
|
|
41 |
// ----------------------------------------------------------------------------
|
|
42 |
CTestSuiteInputData::CTestSuiteInputData()
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
// ----------------------------------------------------------------------------
|
|
47 |
// Destructor
|
|
48 |
// ----------------------------------------------------------------------------
|
|
49 |
CTestSuiteInputData::~CTestSuiteInputData()
|
|
50 |
{
|
|
51 |
if(iQueryBuf)
|
|
52 |
{
|
|
53 |
delete iQueryBuf;
|
|
54 |
iQueryBuf = NULL;
|
|
55 |
}
|
|
56 |
if(iKeyboardModeBuf)
|
|
57 |
{
|
|
58 |
delete iKeyboardModeBuf;
|
|
59 |
iKeyboardModeBuf = NULL;
|
|
60 |
}
|
|
61 |
|
|
62 |
iCacheUris.ResetAndDestroy();
|
|
63 |
|
|
64 |
iDisplayFields.Close();
|
|
65 |
}
|
|
66 |
|
|
67 |
// ----------------------------------------------------------------------------
|
|
68 |
// Destructor
|
|
69 |
// ----------------------------------------------------------------------------
|
|
70 |
TDesC& CTestSuiteInputData::KeyboardMode() const
|
|
71 |
{
|
|
72 |
return *iKeyboardModeBuf;
|
|
73 |
}
|
|
74 |
|
|
75 |
// ----------------------------------------------------------------------------
|
|
76 |
// Returns the Id
|
|
77 |
// ----------------------------------------------------------------------------
|
|
78 |
TInt CTestSuiteInputData::Id()
|
|
79 |
{
|
|
80 |
return iId;
|
|
81 |
}
|
|
82 |
|
|
83 |
void CTestSuiteInputData::Data(RPointerArray<TDesC> & aDataArray)
|
|
84 |
{
|
|
85 |
for(TInt i = 0; i < iDataArray.Count(); i++)
|
|
86 |
{
|
|
87 |
aDataArray.Append(iDataArray[i]->AllocL());
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
// ----------------------------------------------------------------------------
|
|
92 |
// Sets the keyboard mode
|
|
93 |
// ----------------------------------------------------------------------------
|
|
94 |
void CTestSuiteInputData::SetKeyboardModeL(const TDesC& aKeyboardMode)
|
|
95 |
{
|
|
96 |
iKeyboardModeBuf = aKeyboardMode.AllocL();
|
|
97 |
}
|
|
98 |
|
|
99 |
TSortType CTestSuiteInputData::SortType() const
|
|
100 |
{
|
|
101 |
return iSortType;
|
|
102 |
}
|
|
103 |
|
|
104 |
void CTestSuiteInputData::SetSortType(TSortType aSortType)
|
|
105 |
{
|
|
106 |
iSortType = aSortType;
|
|
107 |
}
|
|
108 |
|
|
109 |
// ----------------------------------------------------------------------------
|
|
110 |
// Returns the search query (as specified in the config file)
|
|
111 |
// ----------------------------------------------------------------------------
|
|
112 |
TDesC& CTestSuiteInputData::Query() const
|
|
113 |
{
|
|
114 |
return *iQueryBuf;
|
|
115 |
}
|
|
116 |
|
|
117 |
// ----------------------------------------------------------------------------
|
|
118 |
// Sets the search query
|
|
119 |
//
|
|
120 |
// ----------------------------------------------------------------------------
|
|
121 |
void CTestSuiteInputData::SetQueryL(const TDesC& aQuery)
|
|
122 |
{
|
|
123 |
iQueryBuf = aQuery.AllocL();
|
|
124 |
}
|
|
125 |
|
|
126 |
// ----------------------------------------------------------------------------
|
|
127 |
// Return the cache uri at given index
|
|
128 |
// ----------------------------------------------------------------------------
|
|
129 |
TDesC& CTestSuiteInputData::CacheUriAt(TInt aIndex) const
|
|
130 |
{
|
|
131 |
if ( aIndex >= iCacheUris.Count() )
|
|
132 |
{
|
|
133 |
HBufC* temp = HBufC::NewL(2);
|
|
134 |
temp->Des().Copy(KNullDesC);
|
|
135 |
return *temp;
|
|
136 |
|
|
137 |
}
|
|
138 |
|
|
139 |
return *(iCacheUris[aIndex]);
|
|
140 |
}
|
|
141 |
|
|
142 |
// ----------------------------------------------------------------------------
|
|
143 |
// Return the cache uri
|
|
144 |
// ----------------------------------------------------------------------------
|
|
145 |
void CTestSuiteInputData::CacheUris(RPointerArray<TDesC> & aUriArray)
|
|
146 |
{
|
|
147 |
for(TInt i = 0; i < iCacheUris.Count(); i++)
|
|
148 |
{
|
|
149 |
aUriArray.Append(iCacheUris[i]->AllocL());
|
|
150 |
}
|
|
151 |
}
|
|
152 |
|
|
153 |
// ----------------------------------------------------------------------------
|
|
154 |
// Sets the cache uris
|
|
155 |
// ----------------------------------------------------------------------------
|
|
156 |
void CTestSuiteInputData::ApendCacheUrisL(RPointerArray<TDesC>& aCacheUriArray)
|
|
157 |
{
|
|
158 |
iCacheUris.ResetAndDestroy();
|
|
159 |
for(TInt i =0; i <aCacheUriArray.Count(); i++ )
|
|
160 |
iCacheUris.Append(aCacheUriArray[i]);
|
|
161 |
}
|
|
162 |
|
|
163 |
|
|
164 |
// ----------------------------------------------------------------------------
|
|
165 |
// Return the display fields
|
|
166 |
// ----------------------------------------------------------------------------
|
|
167 |
void CTestSuiteInputData::DisplayFields(RArray<TInt>& aDisplayFields)
|
|
168 |
{
|
|
169 |
for(TInt i = 0 ; i < iDisplayFields.Count(); i++)
|
|
170 |
{
|
|
171 |
aDisplayFields.Append(iDisplayFields[i]);
|
|
172 |
}
|
|
173 |
}
|
|
174 |
|
|
175 |
// ----------------------------------------------------------------------------
|
|
176 |
// Return the group ids
|
|
177 |
// ----------------------------------------------------------------------------
|
|
178 |
void CTestSuiteInputData::GroupIds(RArray<TInt>& aGroupId)
|
|
179 |
{
|
|
180 |
for(TInt i = 0 ; i < iGroupIds.Count(); i++)
|
|
181 |
{
|
|
182 |
aGroupId.Append(iGroupIds[i]);
|
|
183 |
}
|
|
184 |
}
|
|
185 |
// ----------------------------------------------------------------------------
|
|
186 |
// Second phase construction
|
|
187 |
// ----------------------------------------------------------------------------
|
|
188 |
void CTestSuiteInputData::ConstructL(CStifItemParser& /*aItem*/)
|
|
189 |
{
|
|
190 |
}
|
|
191 |
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
// This function parses the input parameters
|
|
194 |
// -----------------------------------------------------------------------------
|
|
195 |
void CTestSuiteInputData:: ParseInputL(CStifItemParser& aItem)
|
|
196 |
{
|
|
197 |
TPtrC string;
|
|
198 |
|
|
199 |
// parsing type to be set before parsing a string
|
|
200 |
// EQuoteStyleParsing: information between quotes is handled as a one string.
|
|
201 |
aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
|
|
202 |
|
|
203 |
// loop till there is a token in i/p string
|
|
204 |
while ( aItem.GetNextString ( string ) == KErrNone )
|
|
205 |
{
|
|
206 |
HBufC *item = string.AllocL();
|
|
207 |
TChar sqBracketOpen = '[';
|
|
208 |
TChar sqBracketClose = ']';
|
|
209 |
|
|
210 |
TInt sqBracketStartPos = string.Locate(sqBracketOpen);
|
|
211 |
TInt sqBracketEndPos = string.Locate(sqBracketClose);
|
|
212 |
|
|
213 |
if( (sqBracketStartPos != KErrNotFound) && ( sqBracketEndPos!=KErrNotFound))
|
|
214 |
{
|
|
215 |
TPtrC16 optionPtr = string.Left(sqBracketStartPos);
|
|
216 |
|
|
217 |
TPtrC16 dataPtr = string.Mid(sqBracketStartPos + 1,sqBracketEndPos - sqBracketStartPos - 1 );
|
|
218 |
|
|
219 |
|
|
220 |
// Check the type of tag, then do the corresponding parsing
|
|
221 |
if(optionPtr.Compare(KSearchQueryTag) == 0)
|
|
222 |
{
|
|
223 |
// Search query
|
|
224 |
ParseInputForSearchQueryL(dataPtr);
|
|
225 |
|
|
226 |
}
|
|
227 |
else if(optionPtr.Compare(KUriTag) == 0)
|
|
228 |
{
|
|
229 |
// Data store uris
|
|
230 |
ParseInputForDataStoresUriL(dataPtr);
|
|
231 |
}
|
|
232 |
|
|
233 |
else if(optionPtr.Compare(KIdTag) == 0)
|
|
234 |
{
|
|
235 |
// Id
|
|
236 |
ParseInputForIdL(dataPtr);
|
|
237 |
}
|
|
238 |
else if(optionPtr.Compare(KDataTag) == 0)
|
|
239 |
{
|
|
240 |
// data
|
|
241 |
ParseInputForData(dataPtr);
|
|
242 |
}
|
|
243 |
|
|
244 |
else if(optionPtr.Compare(KSetDisplayFields) == 0)
|
|
245 |
{
|
|
246 |
// Display fields
|
|
247 |
ParseInputForDisplayFieldsL(dataPtr);
|
|
248 |
}
|
|
249 |
else if(optionPtr.Compare(KSortTag) == 0)
|
|
250 |
{
|
|
251 |
// Sorting
|
|
252 |
ParseInputForSortTypeL(dataPtr);
|
|
253 |
}
|
|
254 |
else if(optionPtr.Compare(KGroupIdTag) == 0)
|
|
255 |
{
|
|
256 |
// Sorting
|
|
257 |
ParseInputForGroupIdsL(dataPtr);
|
|
258 |
}
|
|
259 |
}
|
|
260 |
else
|
|
261 |
{
|
|
262 |
// Wrong Input..
|
|
263 |
User::Leave(KErrGeneral);
|
|
264 |
}
|
|
265 |
}
|
|
266 |
}
|
|
267 |
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
// This function parses input for number id
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
void CTestSuiteInputData::ParseInputForIdL(TDesC& aInput)
|
|
272 |
{
|
|
273 |
TInt fieldId = 0;
|
|
274 |
TLex num(aInput);
|
|
275 |
|
|
276 |
TInt err = num.Val(fieldId);
|
|
277 |
if(err == KErrNone)
|
|
278 |
{
|
|
279 |
iId = fieldId;
|
|
280 |
}
|
|
281 |
else
|
|
282 |
{
|
|
283 |
User::Leave(KErrArgument);
|
|
284 |
}
|
|
285 |
}
|
|
286 |
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
// This function parses input for sort type
|
|
289 |
// -----------------------------------------------------------------------------
|
|
290 |
void CTestSuiteInputData::ParseInputForSortTypeL(TDesC& aInput)
|
|
291 |
{
|
|
292 |
// TSortType sorttype;
|
|
293 |
|
|
294 |
// set the sort type
|
|
295 |
if(aInput.Compare(KAlphabetic) == 0)
|
|
296 |
{
|
|
297 |
iSortType = EAlphabetical;
|
|
298 |
}
|
|
299 |
else if (aInput.Compare(KPattern) == 0)
|
|
300 |
{
|
|
301 |
iSortType = EPatternBased;
|
|
302 |
}
|
|
303 |
else
|
|
304 |
{
|
|
305 |
User::Leave(KErrArgument);
|
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
// -----------------------------------------------------------------------------
|
|
310 |
// This function parses input for cache uris
|
|
311 |
// -----------------------------------------------------------------------------
|
|
312 |
void CTestSuiteInputData::ParseInputForData(TDesC& aInput)
|
|
313 |
{
|
|
314 |
RPointerArray<TDesC> data;
|
|
315 |
TChar separator = ',';
|
|
316 |
|
|
317 |
// Get the uris which are separated by commas
|
|
318 |
GetCharacterSeparatedDataL( aInput,separator, data);
|
|
319 |
for(TInt i = 0; i< data.Count(); i++)
|
|
320 |
{
|
|
321 |
HBufC *temp = data[i]->AllocL();
|
|
322 |
iDataArray.Append(data[i]);
|
|
323 |
}
|
|
324 |
}
|
|
325 |
|
|
326 |
// -----------------------------------------------------------------------------
|
|
327 |
// This function parses input for cache uris
|
|
328 |
// -----------------------------------------------------------------------------
|
|
329 |
void CTestSuiteInputData::ParseInputForDataStoresUriL(TDesC& aInput)
|
|
330 |
{
|
|
331 |
RPointerArray<TDesC> Uris;
|
|
332 |
TChar separator = ',';
|
|
333 |
|
|
334 |
// Get the uris which are separated by commas
|
|
335 |
GetCharacterSeparatedDataL( aInput,separator, Uris);
|
|
336 |
for(TInt i = 0; i< Uris.Count(); i++)
|
|
337 |
{
|
|
338 |
HBufC *temp = Uris[i]->AllocL();
|
|
339 |
iCacheUris.Append(Uris[i]);
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
// -----------------------------------------------------------------------------
|
|
344 |
// This function parses the input for display fields
|
|
345 |
// -----------------------------------------------------------------------------
|
|
346 |
void CTestSuiteInputData::ParseInputForDisplayFieldsL(TDesC& aInput)
|
|
347 |
{
|
|
348 |
RPointerArray<TDesC> dispFieldsBuf;
|
|
349 |
|
|
350 |
TChar separator = ',';
|
|
351 |
GetCharacterSeparatedDataL( aInput,separator, dispFieldsBuf);
|
|
352 |
for(TInt i = 0; i< dispFieldsBuf.Count(); i++)
|
|
353 |
{
|
|
354 |
TInt fieldId = 0;
|
|
355 |
TLex num(*(dispFieldsBuf[i]));
|
|
356 |
|
|
357 |
TInt err = num.Val(fieldId); // parse the string to extract integer value
|
|
358 |
if(err != KErrNone)
|
|
359 |
{
|
|
360 |
User::Leave(KErrGeneral);
|
|
361 |
}
|
|
362 |
else
|
|
363 |
{
|
|
364 |
iDisplayFields.Append(fieldId);
|
|
365 |
}
|
|
366 |
}
|
|
367 |
}
|
|
368 |
|
|
369 |
// -----------------------------------------------------------------------------
|
|
370 |
// This function parses the input for expected group ids
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
void CTestSuiteInputData::ParseInputForGroupIdsL(TDesC& aInput)
|
|
373 |
{
|
|
374 |
RPointerArray<TDesC> grpIdsBuf;
|
|
375 |
|
|
376 |
TChar separator = ',';
|
|
377 |
GetCharacterSeparatedDataL( aInput,separator, grpIdsBuf);
|
|
378 |
for(TInt i = 0; i< grpIdsBuf.Count(); i++)
|
|
379 |
{
|
|
380 |
TInt groupId = 0;
|
|
381 |
TLex num(*(grpIdsBuf[i]));
|
|
382 |
|
|
383 |
TInt err = num.Val(groupId); // parse the string to extract integer value
|
|
384 |
if(err != KErrNone)
|
|
385 |
{
|
|
386 |
User::Leave(KErrGeneral);
|
|
387 |
}
|
|
388 |
else
|
|
389 |
{
|
|
390 |
iGroupIds.Append(groupId);
|
|
391 |
}
|
|
392 |
}
|
|
393 |
}
|
|
394 |
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
// This function splits the the input separated by particular character
|
|
397 |
// -----------------------------------------------------------------------------
|
|
398 |
void CTestSuiteInputData::GetCharacterSeparatedDataL(TDesC& aInput,TChar aSeparator, RPointerArray<TDesC> &aSeparatedData)
|
|
399 |
{
|
|
400 |
TInt SeparatorPos = -1 ;
|
|
401 |
for (TInt j = 0 ; j< aInput.Length();)
|
|
402 |
{
|
|
403 |
TInt Startpos = SeparatorPos + 1;
|
|
404 |
// Get the data for each contact
|
|
405 |
while((aInput[j] != aSeparator) && (j < ( aInput.Length()-1) ) )
|
|
406 |
j++;
|
|
407 |
if(j == (aInput.Length() - 1))
|
|
408 |
j++;
|
|
409 |
|
|
410 |
TPtrC16 dataPtr = aInput.Mid(Startpos ,j - Startpos);
|
|
411 |
|
|
412 |
// Add data to the output
|
|
413 |
HBufC* tempData = dataPtr.AllocL();
|
|
414 |
aSeparatedData.Append(tempData);
|
|
415 |
SeparatorPos = j ;
|
|
416 |
j++;
|
|
417 |
}
|
|
418 |
}
|
|
419 |
|
|
420 |
// -----------------------------------------------------------------------------
|
|
421 |
// This function parses the input for search query
|
|
422 |
// -----------------------------------------------------------------------------
|
|
423 |
void CTestSuiteInputData::ParseInputForSearchQueryL(TDesC& aInput)
|
|
424 |
{
|
|
425 |
RPointerArray<TDesC> queryData;
|
|
426 |
TChar separator = ',';
|
|
427 |
GetCharacterSeparatedDataL( aInput,separator, queryData);
|
|
428 |
|
|
429 |
// If there are more than 2 field, then it is an error
|
|
430 |
if(queryData.Count() == 2)
|
|
431 |
{
|
|
432 |
iQueryBuf = queryData[0]->AllocL();
|
|
433 |
iKeyboardModeBuf = queryData[1]->AllocL();
|
|
434 |
queryData.ResetAndDestroy();
|
|
435 |
}
|
|
436 |
else
|
|
437 |
{
|
|
438 |
queryData.ResetAndDestroy();
|
|
439 |
User::Leave(KErrArgument);
|
|
440 |
}
|
|
441 |
}
|
|
442 |
|
|
443 |
// -----------------------------------------------------------------------------
|
|
444 |
// This function creates the search query from the input buffer
|
|
445 |
// -----------------------------------------------------------------------------
|
|
446 |
void CTestSuiteInputData::CreateSearchQueryL(CPsQuery& aPsQuery,TDesC& aQueryBuf)
|
|
447 |
{
|
|
448 |
TKeyboardModes keyboardMode = EModeUndefined;
|
|
449 |
|
|
450 |
// Check the keyboard mode
|
|
451 |
if(iKeyboardModeBuf->Des().Compare(KItut) == 0)
|
|
452 |
{
|
|
453 |
keyboardMode = EItut;
|
|
454 |
}
|
|
455 |
else if (iKeyboardModeBuf->Des().Compare(KQwerty) == 0)
|
|
456 |
{
|
|
457 |
keyboardMode = EQwerty;
|
|
458 |
}
|
|
459 |
|
|
460 |
else // mixed mode
|
|
461 |
{
|
|
462 |
// convert the search query to the required format
|
|
463 |
_LIT(KCode,"i");
|
|
464 |
for(TInt i = 0; i < aQueryBuf.Length(); i++)
|
|
465 |
{
|
|
466 |
CPsQueryItem* item = CPsQueryItem::NewL();
|
|
467 |
item->SetCharacter(aQueryBuf[i]); // set search character
|
|
468 |
|
|
469 |
// set the keyboard mode
|
|
470 |
if( (iKeyboardModeBuf->Des().Mid(i,1)).Compare(KCode) == 0)
|
|
471 |
{
|
|
472 |
item->SetMode(EItut);
|
|
473 |
}
|
|
474 |
else
|
|
475 |
{
|
|
476 |
item->SetMode(EQwerty);
|
|
477 |
}
|
|
478 |
|
|
479 |
aPsQuery.AppendL(*item);
|
|
480 |
}
|
|
481 |
|
|
482 |
return ;
|
|
483 |
}
|
|
484 |
|
|
485 |
// create the query as CPsQuery object
|
|
486 |
// for EItut and EQwerty mode
|
|
487 |
for(TInt j = 0; j < aQueryBuf.Length(); j++)
|
|
488 |
{
|
|
489 |
CPsQueryItem* item1 = CPsQueryItem::NewL();
|
|
490 |
item1->SetCharacter(aQueryBuf[j]);
|
|
491 |
item1->SetMode(keyboardMode);
|
|
492 |
aPsQuery.AppendL(*item1);
|
|
493 |
}
|
|
494 |
}
|
|
495 |
|
|
496 |
// -----------------------------------------------------------------------------
|
|
497 |
// Perform the search settings
|
|
498 |
// -----------------------------------------------------------------------------
|
|
499 |
|
|
500 |
void CTestSuiteInputData::PerformSearchSettingsL(CPsSettings& aSettings)
|
|
501 |
{
|
|
502 |
RPointerArray<TDesC> databases; // list of databases
|
|
503 |
RArray<TInt> displayFields; // list of display fields
|
|
504 |
TInt maxResults = 100;
|
|
505 |
|
|
506 |
// add the display fields
|
|
507 |
if(iDisplayFields.Count())
|
|
508 |
{
|
|
509 |
for(TInt i =0; i<iDisplayFields.Count();i++)
|
|
510 |
displayFields.Append(iDisplayFields[i]);
|
|
511 |
}
|
|
512 |
else
|
|
513 |
{
|
|
514 |
displayFields.Append(6); // Firstname
|
|
515 |
displayFields.Append(4); // Lastname
|
|
516 |
displayFields.Append(27); // Company name
|
|
517 |
}
|
|
518 |
|
|
519 |
// Set the databases to be searched
|
|
520 |
for(TInt i =0; i <iCacheUris.Count(); i++ )
|
|
521 |
{
|
|
522 |
databases.Append(iCacheUris[i]->AllocL());
|
|
523 |
}
|
|
524 |
|
|
525 |
// Perform the settings
|
|
526 |
aSettings.SetSearchUrisL(databases);
|
|
527 |
aSettings.SetDisplayFieldsL(displayFields);
|
|
528 |
aSettings.SetMaxResults(maxResults);
|
|
529 |
|
|
530 |
// cleanup
|
|
531 |
displayFields.Close();
|
|
532 |
databases.Reset();
|
|
533 |
databases.Close();
|
|
534 |
}
|
|
535 |
|
|
536 |
TInt CTestSuiteInputData::CompareByDataL ( const CPsClientData& aObject1, const CPsClientData& aObject2 )
|
|
537 |
{
|
|
538 |
TBuf<KBufferMaxLen> data1;
|
|
539 |
TBuf<255> data2;
|
|
540 |
|
|
541 |
_LIT(KSpace, " ");
|
|
542 |
|
|
543 |
data1 = KNullDesC;
|
|
544 |
for ( int i = 0; i < aObject1.DataElementCount(); i++ )
|
|
545 |
{
|
|
546 |
if ( aObject1.Data(i) )
|
|
547 |
{
|
|
548 |
data1 += aObject1.Data(i)->Des();
|
|
549 |
data1 += KSpace;
|
|
550 |
}
|
|
551 |
}
|
|
552 |
|
|
553 |
// Trim the unnecessary white spaces before we compare
|
|
554 |
data1.TrimAll();
|
|
555 |
|
|
556 |
data2 = KNullDesC;
|
|
557 |
for ( int i = 0; i < aObject2.DataElementCount(); i++ )
|
|
558 |
{
|
|
559 |
if ( aObject2.Data(i) )
|
|
560 |
{
|
|
561 |
data2 += aObject2.Data(i)->Des();
|
|
562 |
data2 += KSpace;
|
|
563 |
}
|
|
564 |
}
|
|
565 |
|
|
566 |
// Trim the unnecessary white spaces before we compare
|
|
567 |
data2.TrimAll();
|
|
568 |
|
|
569 |
// Get the standard method
|
|
570 |
TCollationMethod meth = *Mem::CollationMethodByIndex( 0 );
|
|
571 |
meth.iFlags |= TCollationMethod::EIgnoreNone;
|
|
572 |
meth.iFlags |= TCollationMethod::EFoldCase;
|
|
573 |
|
|
574 |
// Magic: Collation level 3 is used
|
|
575 |
TInt comparison(data1.CompareC( data2, 3, &meth ));
|
|
576 |
return comparison;
|
|
577 |
}
|
|
578 |
|
|
579 |
// End of file
|