143 } |
137 } |
144 |
138 |
145 return *(iCacheUris[aIndex]); |
139 return *(iCacheUris[aIndex]); |
146 } |
140 } |
147 |
141 |
148 |
|
149 // ---------------------------------------------------------------------------- |
142 // ---------------------------------------------------------------------------- |
150 // Return the cache uri |
143 // Return the cache uri |
151 // ---------------------------------------------------------------------------- |
144 // ---------------------------------------------------------------------------- |
152 void CTestSuiteInputData::CacheUris(RPointerArray<TDesC> & aUriArray) |
145 void CTestSuiteInputData::CacheUris(RPointerArray<TDesC> & aUriArray) |
153 { |
146 { |
154 for(TInt i = 0 ; i < iCacheUris.Count(); i++) |
147 for(TInt i = 0; i < iCacheUris.Count(); i++) |
155 { |
148 { |
156 aUriArray.Append(iCacheUris[i]->AllocL()); |
149 aUriArray.Append(iCacheUris[i]->AllocL()); |
157 } |
150 } |
158 } |
151 } |
159 |
152 |
160 // ---------------------------------------------------------------------------- |
153 // ---------------------------------------------------------------------------- |
161 // Sets the cache uris |
154 // Sets the cache uris |
162 // ---------------------------------------------------------------------------- |
155 // ---------------------------------------------------------------------------- |
163 void CTestSuiteInputData::ApendCacheUrisL(RPointerArray<TDesC>& aCacheUriArray) |
156 void CTestSuiteInputData::ApendCacheUrisL(RPointerArray<TDesC>& aCacheUriArray) |
164 { iCacheUris.ResetAndDestroy(); |
157 { |
|
158 iCacheUris.ResetAndDestroy(); |
165 for(TInt i =0; i <aCacheUriArray.Count(); i++ ) |
159 for(TInt i =0; i <aCacheUriArray.Count(); i++ ) |
166 iCacheUris.Append(aCacheUriArray[i]); |
160 iCacheUris.Append(aCacheUriArray[i]); |
167 } |
161 } |
168 |
162 |
169 |
163 |
266 } |
259 } |
267 else |
260 else |
268 { |
261 { |
269 // Wrong Input.. |
262 // Wrong Input.. |
270 User::Leave(KErrGeneral); |
263 User::Leave(KErrGeneral); |
271 |
|
272 } |
264 } |
273 |
265 } |
274 } |
266 } |
275 } |
|
276 |
|
277 |
267 |
278 // ----------------------------------------------------------------------------- |
268 // ----------------------------------------------------------------------------- |
279 // This function parses input for number id |
269 // This function parses input for number id |
280 // ----------------------------------------------------------------------------- |
270 // ----------------------------------------------------------------------------- |
281 void CTestSuiteInputData::ParseInputForIdL(TDesC& aInput) |
271 void CTestSuiteInputData::ParseInputForIdL(TDesC& aInput) |
282 { |
272 { |
283 |
273 TInt fieldId = 0; |
284 TInt fieldId = 0; |
274 TLex num(aInput); |
285 TLex num(aInput); |
275 |
286 |
276 TInt err = num.Val(fieldId); |
287 TInt err = num.Val(fieldId); |
277 if(err == KErrNone) |
288 if(err == KErrNone) |
278 { |
289 { |
279 iId = fieldId; |
290 iId = fieldId; |
280 } |
291 } |
281 else |
292 else |
282 { |
293 { |
283 User::Leave(KErrArgument); |
294 User::Leave(KErrArgument); |
284 } |
295 } |
|
296 |
|
297 } |
285 } |
298 |
286 |
299 // ----------------------------------------------------------------------------- |
287 // ----------------------------------------------------------------------------- |
300 // This function parses input for sort type |
288 // This function parses input for sort type |
301 // ----------------------------------------------------------------------------- |
289 // ----------------------------------------------------------------------------- |
346 |
333 |
347 // Get the uris which are separated by commas |
334 // Get the uris which are separated by commas |
348 GetCharacterSeparatedDataL( aInput,separator, Uris); |
335 GetCharacterSeparatedDataL( aInput,separator, Uris); |
349 for(TInt i = 0; i< Uris.Count(); i++) |
336 for(TInt i = 0; i< Uris.Count(); i++) |
350 { |
337 { |
351 HBufC *temp = Uris[i]->AllocL(); |
338 HBufC *temp = Uris[i]->AllocL(); |
352 iCacheUris.Append(Uris[i]); |
339 iCacheUris.Append(Uris[i]); |
353 |
340 } |
354 } |
341 } |
355 } |
|
356 |
|
357 |
342 |
358 // ----------------------------------------------------------------------------- |
343 // ----------------------------------------------------------------------------- |
359 // This function parses the input for display fields |
344 // This function parses the input for display fields |
360 // ----------------------------------------------------------------------------- |
345 // ----------------------------------------------------------------------------- |
361 void CTestSuiteInputData::ParseInputForDisplayFieldsL(TDesC& aInput) |
346 void CTestSuiteInputData::ParseInputForDisplayFieldsL(TDesC& aInput) |
393 for(TInt i = 0; i< grpIdsBuf.Count(); i++) |
378 for(TInt i = 0; i< grpIdsBuf.Count(); i++) |
394 { |
379 { |
395 TInt groupId = 0; |
380 TInt groupId = 0; |
396 TLex num(*(grpIdsBuf[i])); |
381 TLex num(*(grpIdsBuf[i])); |
397 |
382 |
398 TInt err = num.Val(groupId); // parse the string to extract integer value |
383 TInt err = num.Val(groupId); // parse the string to extract integer value |
399 if(err != KErrNone) |
384 if(err != KErrNone) |
400 { |
385 { |
401 User::Leave(KErrGeneral); |
386 User::Leave(KErrGeneral); |
402 } |
387 } |
403 else |
388 else |
404 { |
389 { |
405 iGroupIds.Append(groupId); |
390 iGroupIds.Append(groupId); |
406 } |
391 } |
407 } |
392 } |
408 } |
393 } |
409 |
394 |
410 // ----------------------------------------------------------------------------- |
395 // ----------------------------------------------------------------------------- |
411 // This function splits the the input separated by particular character |
396 // This function splits the the input separated by particular character |
412 // ----------------------------------------------------------------------------- |
397 // ----------------------------------------------------------------------------- |
413 void CTestSuiteInputData::GetCharacterSeparatedDataL(TDesC& aInput,TChar aSeparator, RPointerArray<TDesC> &aSeparatedData) |
398 void CTestSuiteInputData::GetCharacterSeparatedDataL(TDesC& aInput,TChar aSeparator, RPointerArray<TDesC> &aSeparatedData) |
414 { |
399 { |
415 |
|
416 TInt SeparatorPos = -1 ; |
400 TInt SeparatorPos = -1 ; |
417 for (TInt j = 0 ; j< aInput.Length();) |
401 for (TInt j = 0 ; j< aInput.Length();) |
418 { |
402 { |
419 |
403 TInt Startpos = SeparatorPos + 1; |
420 TInt Startpos = SeparatorPos + 1; |
|
421 // Get the data for each contact |
404 // Get the data for each contact |
422 while((aInput[j] != aSeparator) && (j < ( aInput.Length()-1) ) ) |
405 while((aInput[j] != aSeparator) && (j < ( aInput.Length()-1) ) ) |
423 j++; |
406 j++; |
424 if(j == (aInput.Length() - 1)) |
407 if(j == (aInput.Length() - 1)) |
425 j++; |
408 j++; |
426 |
409 |
427 TPtrC16 dataPtr = aInput.Mid(Startpos ,j - Startpos); |
410 TPtrC16 dataPtr = aInput.Mid(Startpos ,j - Startpos); |
428 |
411 |
429 |
412 // Add data to the output |
430 // Add data to the output |
413 HBufC* tempData = dataPtr.AllocL(); |
431 HBufC* tempData = dataPtr.AllocL(); |
414 aSeparatedData.Append(tempData); |
432 aSeparatedData.Append(tempData); |
415 SeparatorPos = j ; |
433 SeparatorPos = j ; |
416 j++; |
434 j++; |
417 } |
435 |
|
436 } |
|
437 |
|
438 } |
418 } |
439 |
419 |
440 // ----------------------------------------------------------------------------- |
420 // ----------------------------------------------------------------------------- |
441 // This function parses the input for search query |
421 // This function parses the input for search query |
442 // ----------------------------------------------------------------------------- |
422 // ----------------------------------------------------------------------------- |
443 void CTestSuiteInputData::ParseInputForSearchQueryL(TDesC& aInput) |
423 void CTestSuiteInputData::ParseInputForSearchQueryL(TDesC& aInput) |
444 { |
424 { |
445 |
|
446 RPointerArray<TDesC> queryData; |
425 RPointerArray<TDesC> queryData; |
447 TChar separator = ','; |
426 TChar separator = ','; |
448 GetCharacterSeparatedDataL( aInput,separator, queryData); |
427 GetCharacterSeparatedDataL( aInput,separator, queryData); |
449 |
428 |
450 // If there are more than 2 field, then it is an error |
429 // If there are more than 2 field, then it is an error |
516 item1->SetMode(keyboardMode); |
491 item1->SetMode(keyboardMode); |
517 aPsQuery.AppendL(*item1); |
492 aPsQuery.AppendL(*item1); |
518 } |
493 } |
519 } |
494 } |
520 |
495 |
521 |
|
522 // ----------------------------------------------------------------------------- |
496 // ----------------------------------------------------------------------------- |
523 // Perform the search settings |
497 // Perform the search settings |
524 // ----------------------------------------------------------------------------- |
498 // ----------------------------------------------------------------------------- |
525 |
499 |
526 void CTestSuiteInputData::PerformSearchSettingsL(CPsSettings& aSettings) |
500 void CTestSuiteInputData::PerformSearchSettingsL(CPsSettings& aSettings) |
527 { |
501 { |
528 |
|
529 RPointerArray<TDesC> databases; // list of databases |
502 RPointerArray<TDesC> databases; // list of databases |
530 RArray<TInt> displayFields; // list of display fields |
503 RArray<TInt> displayFields; // list of display fields |
531 TInt maxResults = 100; |
504 TInt maxResults = 100; |
532 |
505 |
533 // add the display fields |
506 // add the display fields |
534 if(iDisplayFields.Count()) |
507 if(iDisplayFields.Count()) |
535 { |
508 { |
536 for(TInt i =0; i<iDisplayFields.Count();i++) |
509 for(TInt i =0; i<iDisplayFields.Count();i++) |
537 displayFields.Append(iDisplayFields[i]); |
510 displayFields.Append(iDisplayFields[i]); |
538 |
|
539 } |
511 } |
540 else |
512 else |
541 { |
513 { |
542 displayFields.Append(6); // Firstname |
514 displayFields.Append(6); // Firstname |
543 displayFields.Append(4); // Lastname |
515 displayFields.Append(4); // Lastname |
544 displayFields.Append(27); // Company name |
516 displayFields.Append(27); // Company name |
545 } |
517 } |
546 |
|
547 |
518 |
548 // Set the databases to be searched |
519 // Set the databases to be searched |
549 for(TInt i =0; i <iCacheUris.Count(); i++ ) |
520 for(TInt i =0; i <iCacheUris.Count(); i++ ) |
550 { |
521 { |
551 databases.Append(iCacheUris[i]->AllocL()); |
522 databases.Append(iCacheUris[i]->AllocL()); |
552 |
|
553 } |
523 } |
554 |
524 |
555 // Perform the settings |
525 // Perform the settings |
556 aSettings.SetSearchUrisL(databases); |
526 aSettings.SetSearchUrisL(databases); |
557 aSettings.SetDisplayFieldsL(displayFields); |
527 aSettings.SetDisplayFieldsL(displayFields); |
558 aSettings.SetMaxResults(maxResults); |
528 aSettings.SetMaxResults(maxResults); |
559 |
|
560 |
529 |
561 // cleanup |
530 // cleanup |
562 displayFields.Close(); |
531 displayFields.Close(); |
563 databases.Reset(); |
532 databases.Reset(); |
564 databases.Close(); |
533 databases.Close(); |
565 |
|
566 |
|
567 } |
534 } |
568 |
535 |
569 TInt CTestSuiteInputData::CompareByDataL ( const CPsClientData& aObject1, const CPsClientData& aObject2 ) |
536 TInt CTestSuiteInputData::CompareByDataL ( const CPsClientData& aObject1, const CPsClientData& aObject2 ) |
570 { |
537 { |
571 TBuf<KBufferMaxLen> data1; |
538 TBuf<KBufferMaxLen> data1; |
572 TBuf<255> data2; |
539 TBuf<255> data2; |
573 |
540 |
574 _LIT(KSpace, " "); |
541 _LIT(KSpace, " "); |
575 |
542 |
576 data1 = KNullDesC; |
543 data1 = KNullDesC; |
577 for ( int i = 0; i < aObject1.DataElementCount(); i++ ) |
544 for ( int i = 0; i < aObject1.DataElementCount(); i++ ) |
578 { |
545 { |
579 if ( aObject1.Data(i) ) |
546 if ( aObject1.Data(i) ) |
580 { |
547 { |
581 data1 += aObject1.Data(i)->Des(); |
548 data1 += aObject1.Data(i)->Des(); |
582 data1 += KSpace; |
549 data1 += KSpace; |
583 } |
550 } |
584 } |
551 } |
585 |
552 |
586 // Trim the unnecessary white spaces before we compare |
553 // Trim the unnecessary white spaces before we compare |
587 data1.TrimAll(); |
554 data1.TrimAll(); |
588 |
555 |
589 data2 = KNullDesC; |
556 data2 = KNullDesC; |
590 for ( int i = 0; i < aObject2.DataElementCount(); i++ ) |
557 for ( int i = 0; i < aObject2.DataElementCount(); i++ ) |
591 { |
558 { |
592 if ( aObject2.Data(i) ) |
559 if ( aObject2.Data(i) ) |
593 { |
560 { |
594 data2 += aObject2.Data(i)->Des(); |
561 data2 += aObject2.Data(i)->Des(); |
595 data2 += KSpace; |
562 data2 += KSpace; |
596 } |
563 } |
597 } |
564 } |
598 |
565 |
599 // Trim the unnecessary white spaces before we compare |
566 // Trim the unnecessary white spaces before we compare |
600 data2.TrimAll(); |
567 data2.TrimAll(); |
601 |
568 |
602 // Get the standard method |
569 // Get the standard method |
603 TCollationMethod meth = *Mem::CollationMethodByIndex( 0 ); |
570 TCollationMethod meth = *Mem::CollationMethodByIndex( 0 ); |
604 meth.iFlags |= TCollationMethod::EIgnoreNone; |
571 meth.iFlags |= TCollationMethod::EIgnoreNone; |
605 meth.iFlags |= TCollationMethod::EFoldCase; |
572 meth.iFlags |= TCollationMethod::EFoldCase; |
606 |
573 |
607 // Magic: Collation level 3 is used |
574 // Magic: Collation level 3 is used |
608 TInt comparison(data1.CompareC( data2, 3, &meth )); |
575 TInt comparison(data1.CompareC( data2, 3, &meth )); |
609 return comparison; |
576 return comparison; |
610 } |
577 } |
|
578 |
611 // End of file |
579 // End of file |