|
1 /* |
|
2 * Copyright (c) 2005 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 the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * ?description_line |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "FT_CPosTp133.h" |
|
22 #include <EPos_CPosLandmarkDatabase.h> |
|
23 #include <EPos_CPosLandmarkSearch.h> |
|
24 #include <EPos_CPosLmTextCriteria.h> |
|
25 #include <EPos_CPosLMItemIterator.h> |
|
26 #include <EPos_CPosLmDisplayData.h> |
|
27 #include <EPos_CPosLmDisplayItem.h> |
|
28 #include <EPos_TPosLMSortPref.h> |
|
29 #include "FT_CSearchResult.h" |
|
30 #include <LbsPosition.h> |
|
31 |
|
32 #include <EPos_CPosLmDatabaseManager.h> |
|
33 #include <EPos_CPosLmMultiDbSearch.h> |
|
34 |
|
35 // CONSTANTS |
|
36 const TInt KNrOfDatabases = 5; |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 |
|
39 // --------------------------------------------------------- |
|
40 // CPosTp133::CloseTest |
|
41 // |
|
42 // (other items were commented in a header). |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 void CPosTp133::CloseTest() |
|
46 { |
|
47 iLog->Log(_L("CloseTest")); |
|
48 iSearchResults.ResetAndDestroy(); |
|
49 |
|
50 delete iDatabase; |
|
51 iDatabase = NULL; |
|
52 |
|
53 delete iDisplayData; |
|
54 iDisplayData = NULL; |
|
55 |
|
56 delete iLandmarkSearch; |
|
57 iLandmarkSearch = NULL; |
|
58 |
|
59 delete iMultiLandmarkSearch; |
|
60 iMultiLandmarkSearch = NULL; |
|
61 |
|
62 TRAPD(err, RemoveAllLmDatabasesL()); |
|
63 if (err != KErrNone) iLog->Log(_L("Problem when removing all lm databases")); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CPosTp133::StartL |
|
68 // |
|
69 // (other items were commented in a header). |
|
70 // --------------------------------------------------------- |
|
71 // |
|
72 void CPosTp133::StartL() |
|
73 { |
|
74 _LIT(KDb20, "EPOSLM_020.LDB"); |
|
75 _LIT(KDb40, "EPOSLM_040.LDB"); |
|
76 _LIT(KDb60, "EPOSLM_060.LDB"); |
|
77 _LIT(KDb80, "EPOSLM_080.LDB"); |
|
78 _LIT(KDb105, "EPOSLM_105.LDB"); |
|
79 |
|
80 // PrepareDatabases |
|
81 RemoveAllLmDatabasesL(); |
|
82 CopyTestDbFileL(KDb20); |
|
83 CopyTestDbFileL(KDb40); |
|
84 CopyTestDbFileL(KDb60); |
|
85 CopyTestDbFileL(KDb80); |
|
86 CopyTestDbFileL(KDb105); |
|
87 |
|
88 iDisplayData = NULL; |
|
89 iLandmarkSearch = NULL; |
|
90 |
|
91 CPosLmDatabaseManager* dbMan = CPosLmDatabaseManager::NewL(); |
|
92 CleanupStack::PushL(dbMan); |
|
93 CDesCArray* dbUris = dbMan->ListDatabasesLC(); |
|
94 CleanupStack::Pop(dbUris); |
|
95 CleanupStack::PopAndDestroy(dbMan); |
|
96 CleanupStack::PushL(dbUris); |
|
97 |
|
98 AssertTrueSecL(dbUris->Count() == KNrOfDatabases, _L("Wrong number of test databases!")); |
|
99 |
|
100 // Use this db as a template for how the result from multiple db search should be sorted |
|
101 // used mostly in LandmarksSortL |
|
102 iDatabase = UseGeneratedDbFileL(); |
|
103 if (iDatabase->IsInitializingNeeded()) |
|
104 { |
|
105 ExecuteAndDeleteLD(iDatabase->InitializeL()); |
|
106 } |
|
107 |
|
108 AppendSearchResultsL(); |
|
109 |
|
110 DoSearchL(iSearchResults, dbUris, ESynchronous); |
|
111 |
|
112 DoSearchL(iSearchResults, dbUris, EAsynchronous); |
|
113 |
|
114 // Test Partial landmarks |
|
115 iLog->Log(_L("Testing search with a defined sortorder for partial landmarks")); |
|
116 |
|
117 // Only do search for index KWhatToSearchFor in lmDbSearchResult.txt |
|
118 // index 11 is MLFW |
|
119 TInt KWhatToSearchFor = 11; |
|
120 SearchPartialLandmarksL(KWhatToSearchFor, iSearchResults, dbUris); |
|
121 |
|
122 // index 20 is x |
|
123 KWhatToSearchFor = 20; |
|
124 SearchPartialLandmarksL(KWhatToSearchFor, iSearchResults, dbUris); |
|
125 |
|
126 iLog->Log(_L("Testing search for partial landmarks without name")); |
|
127 SearchPartialWithoutNameL(iSearchResults, dbUris); |
|
128 |
|
129 iLog->Log(_L("Testing reset of DisplayData")); |
|
130 CheckResetL(iSearchResults, dbUris); |
|
131 |
|
132 iLog->Log(_L("Testing cancel and displaydata, cancel immeditely")); |
|
133 CancelTestL(iSearchResults, dbUris, EFalse); |
|
134 |
|
135 iLog->Log(_L("Testing cancel and displaydata, cancel in callback")); |
|
136 CancelTestL(iSearchResults, dbUris, ETrue); |
|
137 |
|
138 CleanupStack::PopAndDestroy(dbUris); |
|
139 if (iErrorsFound != KErrNone) |
|
140 { |
|
141 iLog->Log(_L("Errors were found in TP133")); |
|
142 User::Leave(-1); |
|
143 |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // CPosTp133::DoSearchL |
|
149 // |
|
150 // (other items were commented in a header). |
|
151 // --------------------------------------------------------- |
|
152 // |
|
153 void CPosTp133::DoSearchL(const RPointerArray<CSearchResult>& aSearchResults, |
|
154 CDesCArray* aDbUris, TExecutionMode aExecutionMode) |
|
155 { |
|
156 iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); |
|
157 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
158 TBuf<150> buf; |
|
159 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
160 |
|
161 // Dont search for all search criteras (see excel file) |
|
162 // takes just too long time on target (approx 1 hour for this test on target) |
|
163 // therefore start at j=2 |
|
164 #ifdef __WINS__ |
|
165 for(TInt j=0; j<aSearchResults.Count(); j++) |
|
166 #else |
|
167 for(TInt j=2; j<aSearchResults.Count(); j++) |
|
168 #endif |
|
169 { |
|
170 textCriteria->SetTextL(aSearchResults[j]->TextCriteria()); |
|
171 textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); |
|
172 if (aSearchResults[j]->PositionFields().Find(803) != KErrNotFound) |
|
173 { |
|
174 // Stupid fix, since the multi dbs have not been re-generated against correct LBSFieldsid.h |
|
175 // they contain the 802 field (instead of 803) so append this id as well |
|
176 RArray<TUint> arr; |
|
177 iLog->Log(_L("Found 803")); |
|
178 arr = aSearchResults[j]->PositionFields(); |
|
179 arr.Append(802); |
|
180 textCriteria->SetPositionFieldsToSearchL(arr); |
|
181 } |
|
182 else |
|
183 { |
|
184 textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); |
|
185 } |
|
186 |
|
187 iLog->Log(_L(">>>>>>Searching for: ")); |
|
188 iLog->Log(aSearchResults[j]->TextCriteria()); |
|
189 |
|
190 // Sort ascended and descended |
|
191 for (TInt sorted=0;sorted<2;sorted++) |
|
192 { |
|
193 iDisplayData = CPosLmDisplayData::NewL(); |
|
194 iMultiLandmarkSearch->SetDisplayData(*iDisplayData); |
|
195 |
|
196 switch (sorted) |
|
197 { |
|
198 case 0: |
|
199 iLog->Log(_L("******Sorting EAscending*******")); |
|
200 iAscendedSorted = ETrue; |
|
201 sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
202 break; |
|
203 case 1: |
|
204 iLog->Log(_L("**********Sorting EDescending**********")); |
|
205 iAscendedSorted = EFalse; |
|
206 sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); |
|
207 break; |
|
208 } |
|
209 |
|
210 iJustNowSearchResults = &aSearchResults[j]->SearchResult(); |
|
211 LandmarksSortL(*iJustNowSearchResults, sortPref); |
|
212 iLastNrOfDisplayData = 0; |
|
213 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); |
|
214 switch (aExecutionMode) |
|
215 { |
|
216 case ESynchronous: |
|
217 iLog->Log(_L("ESynchronous")); |
|
218 ExecuteAndDeleteLD(iOperation); |
|
219 break; |
|
220 case EAsynchronous: |
|
221 iLog->Log(_L("EAsynchronous")); |
|
222 // Also check progress here |
|
223 ExecuteLmOpL(); |
|
224 break; |
|
225 } |
|
226 |
|
227 |
|
228 // Check for any errors when multi searching |
|
229 if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) |
|
230 { |
|
231 iLog->Log(_L("Errors after multi db search")); |
|
232 User::Leave(-1); |
|
233 } |
|
234 |
|
235 TInt number = iDisplayData->Count(); |
|
236 buf.Zero(); |
|
237 buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, iJustNowSearchResults->Count()); |
|
238 iLog->Log(buf); |
|
239 |
|
240 AssertTrueSecL(iDisplayData->Count() == iJustNowSearchResults->Count(),_L("Mismatch in number of matches")); |
|
241 |
|
242 for (TInt i=0;i<iDisplayData->Count();i++) |
|
243 { |
|
244 CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); |
|
245 TInt lmId = item.Landmark().LandmarkId(); |
|
246 CPosLandmark* target = iDatabase->ReadLandmarkLC((*iJustNowSearchResults)[i]); |
|
247 TPtrC sourceName, targetName; |
|
248 |
|
249 item.Landmark().GetLandmarkName(sourceName); |
|
250 target->GetLandmarkName(targetName); |
|
251 buf.Zero(); |
|
252 |
|
253 if (sourceName.CompareC(targetName) != 0) |
|
254 { |
|
255 |
|
256 iLog->Log(_L("Mismatch between landmarks")); |
|
257 User::Leave(-1); |
|
258 } |
|
259 CleanupStack::PopAndDestroy(target); |
|
260 } |
|
261 |
|
262 iMultiLandmarkSearch->UnsetDisplayData(); |
|
263 delete iDisplayData;iDisplayData=NULL; |
|
264 } |
|
265 } |
|
266 CleanupStack::PopAndDestroy(textCriteria); |
|
267 |
|
268 delete iMultiLandmarkSearch; |
|
269 iMultiLandmarkSearch = NULL; |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------- |
|
273 // CPosTp133::CheckPartialLandmarkL |
|
274 // |
|
275 // (other items were commented in a header). |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CPosTp133::CheckPartialLandmarkL(const CPosLandmark& aLandmark, |
|
279 const CPosLandmark::TAttributes& aAttr, const RArray<TUint>& aReqFields) |
|
280 { |
|
281 _LIT(KPartialIdErr, "Incorrect Id when reading from a Partial landmark"); |
|
282 _LIT(KPartialCategoryInfoErr, "Incorrect Category info when reading from a Partial landmark"); |
|
283 |
|
284 TPosLmItemId id = aLandmark.LandmarkId(); |
|
285 AssertTrueSecL(id != 0, KPartialIdErr); |
|
286 |
|
287 AssertTrueSecL(aLandmark.IsPartial(), _L("Landmark is not partial")); |
|
288 |
|
289 TInt err; |
|
290 TPtrC name; |
|
291 err = aLandmark.GetLandmarkName(name); |
|
292 // Name is always included |
|
293 CheckPartialErrorCodeL(aAttr & CPosLandmark::ELandmarkName, err); |
|
294 |
|
295 TBuf<100> buf; |
|
296 buf.Format(_L("Checking LM: %S"), &name); |
|
297 // iLog->Log(buf); |
|
298 |
|
299 TReal32 coverageR; |
|
300 err = aLandmark.GetCoverageRadius(coverageR); |
|
301 CheckPartialErrorCodeL(aAttr & CPosLandmark::ECoverageRadius, err); |
|
302 |
|
303 TPtrC desc; |
|
304 err = aLandmark.GetLandmarkDescription(desc); |
|
305 CheckPartialErrorCodeL(aAttr & CPosLandmark::EDescription, err); |
|
306 |
|
307 TPtrC iconName; |
|
308 TInt iconIndex; |
|
309 TInt iconMaskIndex; |
|
310 err = aLandmark.GetIcon(iconName, iconIndex, iconMaskIndex); |
|
311 CheckPartialErrorCodeL(aAttr & CPosLandmark::EIcon, err); |
|
312 |
|
313 RArray<TPosLmItemId> categories; |
|
314 CleanupClosePushL(categories); |
|
315 |
|
316 aLandmark.GetCategoriesL(categories); |
|
317 if (aAttr & CPosLandmark::ECategoryInfo) |
|
318 { |
|
319 AssertTrueSecL(categories.Count() != 0, KPartialCategoryInfoErr); |
|
320 } |
|
321 else |
|
322 { |
|
323 AssertTrueSecL(categories.Count() == 0, KPartialCategoryInfoErr); |
|
324 } |
|
325 CleanupStack::PopAndDestroy(&categories); |
|
326 |
|
327 TLocality loc; |
|
328 err = aLandmark.GetPosition(loc); |
|
329 CheckPartialErrorCodeL(aAttr & CPosLandmark::EPosition, err); |
|
330 |
|
331 // Check PositionFields |
|
332 // Check fields from EPositionFieldCompassCapabilitiesBegin up to EPositionFieldMediaCapabilitiesBegin+100 |
|
333 // should be enough to also cover URL |
|
334 for (TInt i=EPositionFieldCompassCapabilitiesBegin; i<EPositionFieldMediaCapabilitiesBegin+100; i++) |
|
335 { |
|
336 TBool avail = aLandmark.IsPositionFieldAvailable((TUint16)i); |
|
337 TInt found = aReqFields.Find(i); |
|
338 if (avail && found != KErrNotFound) |
|
339 { |
|
340 TPtrC value; |
|
341 err = aLandmark.GetPositionField((TUint16)aReqFields[found], value); |
|
342 AssertTrueSecL(err == KErrNone, _L("Could not retrieve positionfield value"), err); |
|
343 iLog->Log(value); |
|
344 } |
|
345 else if (!avail && found != KErrNotFound || avail && found == KErrNotFound) |
|
346 { |
|
347 // Fields 405 and 802 are not always set |
|
348 if (i!=405 && i!=802) |
|
349 { |
|
350 TBuf<100> buf; |
|
351 buf.Format(_L("ERROR: Mismatch in positionfields, id %d were not found"), i); |
|
352 iLog->Log(buf); |
|
353 iErrorsFound++; |
|
354 } |
|
355 } |
|
356 } |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------- |
|
360 // CPosTp133::ChechPartialErrorCodeL |
|
361 // |
|
362 // (other items were commented in a header). |
|
363 // --------------------------------------------------------- |
|
364 // |
|
365 void CPosTp133::CheckPartialErrorCodeL(const TBool aPartial, const TInt aErr) |
|
366 { |
|
367 _LIT(KPartialLmErr, "Incorrect error code returned when reading from a Partial landmark"); |
|
368 _LIT(KPartialLmErr2, "Incorrect error code returned when reading from a non-Partial landmark"); |
|
369 |
|
370 if (aPartial) |
|
371 { |
|
372 |
|
373 if (aErr != KErrNone) |
|
374 { |
|
375 iLog->Log(KPartialLmErr); |
|
376 iErrorsFound++; |
|
377 } |
|
378 } |
|
379 else |
|
380 { |
|
381 |
|
382 if (aErr != KErrNotFound) |
|
383 { |
|
384 iLog->Log(KPartialLmErr2); |
|
385 iErrorsFound++; |
|
386 } |
|
387 } |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------- |
|
391 // CPosTp133::SearchPartialWithoutNameL |
|
392 // |
|
393 // (other items were commented in a header). |
|
394 // --------------------------------------------------------- |
|
395 // |
|
396 void CPosTp133::SearchPartialWithoutNameL(const RPointerArray<CSearchResult>& aSearchResults, |
|
397 CDesCArray* aDbUris) |
|
398 { |
|
399 iLog->Log(_L("SearchPartialWithoutNameL")); |
|
400 // Search in all lm dbs |
|
401 iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); |
|
402 // Set DisplayData |
|
403 iDisplayData = CPosLmDisplayData::NewL(); |
|
404 iMultiLandmarkSearch->SetDisplayData(*iDisplayData); |
|
405 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
406 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
407 TBuf<150> buf; |
|
408 |
|
409 CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); |
|
410 |
|
411 // Dont search for all search criteras (see excel file) |
|
412 // takes just too long time on target |
|
413 // therefore start at j=2 |
|
414 #ifdef __WINS__ |
|
415 for(TInt j=0; j<aSearchResults.Count(); j++) |
|
416 #else |
|
417 for(TInt j=2; j<aSearchResults.Count(); j++) |
|
418 #endif |
|
419 { |
|
420 textCriteria->SetTextL(aSearchResults[j]->TextCriteria()); |
|
421 textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); |
|
422 |
|
423 |
|
424 if (aSearchResults[j]->PositionFields().Find(803) != KErrNotFound) |
|
425 { |
|
426 // Stupid fix, since the multi dbs have not been re-generated against correct LBSFieldsid.h |
|
427 // they contain the 802 field (instead of 803) so append this id as well |
|
428 RArray<TUint> arr; |
|
429 iLog->Log(_L("Found 803")); |
|
430 arr = aSearchResults[j]->PositionFields(); |
|
431 arr.Append(802); |
|
432 textCriteria->SetPositionFieldsToSearchL(arr); |
|
433 } |
|
434 else |
|
435 { |
|
436 textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); |
|
437 } |
|
438 |
|
439 RArray<TUint> reqFields; |
|
440 CleanupClosePushL(reqFields); |
|
441 |
|
442 iLog->Log(aSearchResults[j]->TextCriteria()); |
|
443 |
|
444 // Set position and descriptiom |
|
445 //partialParam->SetRequestedAttributes(CPosLandmark::EPosition); |
|
446 partialParam->SetRequestedAttributes(CPosLandmark::EDescription| CPosLandmark::EPosition); |
|
447 |
|
448 iDisplayData->SetPartialReadParametersL(*partialParam); |
|
449 iLastNrOfDisplayData=0; |
|
450 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, aSearchResults[j]->Redefined()); |
|
451 ExecuteLmOpL(); |
|
452 |
|
453 iLog->Log(_L("Search Done, check sorting")); |
|
454 // Check for any errors when multi searching |
|
455 if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) |
|
456 { |
|
457 iLog->Log(_L("Errors after multi db search")); |
|
458 User::Leave(-1); |
|
459 } |
|
460 |
|
461 RArray<TPosLmItemId>* result = &aSearchResults[j]->SearchResult(); |
|
462 |
|
463 TInt number = iDisplayData->Count(); |
|
464 buf.Zero(); |
|
465 buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, result->Count()); |
|
466 iLog->Log(buf); |
|
467 TInt nrOfNoPos = 0; |
|
468 AssertTrueSecL(iDisplayData->Count() == result->Count(),_L("Mismatch in number of matches")); |
|
469 for (TInt i=0;i<iDisplayData->Count();i++) |
|
470 { |
|
471 CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); |
|
472 TInt lmId = item.Landmark().LandmarkId(); |
|
473 |
|
474 TInt err; |
|
475 TPtrC name; |
|
476 err = item.Landmark().GetLandmarkName(name); |
|
477 AssertTrueSecL(err == KErrNotFound,_L("GetLandmarkName returned name")); |
|
478 TReal32 radius; |
|
479 err = item.Landmark().GetCoverageRadius(radius); |
|
480 AssertTrueSecL(err == KErrNotFound,_L("GetLandmarkName returned name")); |
|
481 TPtrC desc; |
|
482 err = item.Landmark().GetLandmarkDescription(desc); |
|
483 AssertTrueSecL(err == KErrNone,_L("GetLandmarkDescription returned error")); |
|
484 TLocality loc; |
|
485 err = item.Landmark().GetPosition(loc); |
|
486 |
|
487 // Should only be three landmarks without position |
|
488 if (err == KErrNotFound) nrOfNoPos++; |
|
489 |
|
490 } |
|
491 |
|
492 if (nrOfNoPos > 3) |
|
493 { |
|
494 iLog->Log(_L("ERROR: GetPosition returned error")); |
|
495 iErrorsFound++; |
|
496 } |
|
497 |
|
498 CleanupStack::PopAndDestroy(&reqFields); |
|
499 } |
|
500 |
|
501 |
|
502 CleanupStack::PopAndDestroy(partialParam); |
|
503 |
|
504 CleanupStack::PopAndDestroy(textCriteria); |
|
505 iMultiLandmarkSearch->UnsetDisplayData(); |
|
506 delete iDisplayData; |
|
507 iDisplayData = NULL; |
|
508 delete iMultiLandmarkSearch; |
|
509 iMultiLandmarkSearch = NULL; |
|
510 |
|
511 } |
|
512 |
|
513 // --------------------------------------------------------- |
|
514 // CPosTp133::SearchPartialLandmarksL |
|
515 // |
|
516 // (other items were commented in a header). |
|
517 // --------------------------------------------------------- |
|
518 // |
|
519 void CPosTp133::SearchPartialLandmarksL(TInt aWhatIndexToSerrachFor, const RPointerArray<CSearchResult>& aSearchResults, |
|
520 CDesCArray* aDbUris) |
|
521 { |
|
522 // Search in all lm dbs |
|
523 iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); |
|
524 // Set DisplayData |
|
525 iDisplayData = CPosLmDisplayData::NewL(); |
|
526 iMultiLandmarkSearch->SetDisplayData(*iDisplayData); |
|
527 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
528 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
529 TBuf<150> buf; |
|
530 |
|
531 textCriteria->SetTextL(aSearchResults[aWhatIndexToSerrachFor]->TextCriteria()); |
|
532 textCriteria->SetAttributesToSearch(aSearchResults[aWhatIndexToSerrachFor]->Attributes()); |
|
533 textCriteria->SetPositionFieldsToSearchL(aSearchResults[aWhatIndexToSerrachFor]->PositionFields()); |
|
534 |
|
535 RArray<TUint> reqFields; |
|
536 CleanupClosePushL(reqFields); |
|
537 |
|
538 iLog->Log(aSearchResults[aWhatIndexToSerrachFor]->TextCriteria()); |
|
539 CPosLmPartialReadParameters* partialParam = CPosLmPartialReadParameters::NewLC(); |
|
540 |
|
541 CPosLmPartialReadParameters* fakePartialParam = CPosLmPartialReadParameters::NewLC(); |
|
542 reqFields.Append(EPositionFieldStreet); |
|
543 fakePartialParam->SetRequestedPositionFields(reqFields); |
|
544 reqFields.Reset(); |
|
545 |
|
546 // Search for all combinations from 0 - CPosLandmark::EDescription |
|
547 // Ex attr=0, attr=1, attr=2, attr=3, .....attr=63, |
|
548 TUint max = CPosLandmark::EDescription; |
|
549 max <<= 1; |
|
550 max -= 1; |
|
551 |
|
552 TUint attr=0; |
|
553 for (attr=0; attr<=max; attr++) |
|
554 { |
|
555 partialParam->SetRequestedAttributes(attr); |
|
556 reqFields.Reset(); |
|
557 |
|
558 if (attr == 5) |
|
559 { |
|
560 // Add EPositionFieldCountry |
|
561 iLog->Log(_L("Also cover EPositionFieldCountry")); |
|
562 reqFields.Append(EPositionFieldCountry); |
|
563 } |
|
564 else if (attr == 12) |
|
565 { |
|
566 // Add EPositionFieldCity, EPositionFieldStreet, EPositionFieldCountry |
|
567 iLog->Log(_L("Also cover EPositionFieldCity, EPositionFieldStreet, EPositionFieldCountry")); |
|
568 reqFields.Append(EPositionFieldCity); |
|
569 reqFields.Append(EPositionFieldStreet); |
|
570 reqFields.Append(EPositionFieldCountry); |
|
571 } |
|
572 else if (attr == 32) |
|
573 { |
|
574 // Add EPositionFieldMediaLinksStart, EPositionFieldDistrict |
|
575 iLog->Log(_L("Also cover EPositionFieldMediaLinksStart, EPositionFieldDistrict")); |
|
576 reqFields.Append(EPositionFieldMediaLinksStart); |
|
577 reqFields.Append(EPositionFieldDistrict); |
|
578 } |
|
579 |
|
580 partialParam->SetRequestedPositionFields(reqFields); |
|
581 iDisplayData->SetPartialReadParametersL(*partialParam); |
|
582 |
|
583 for (TInt i=0; i<2; i++) |
|
584 { |
|
585 switch (i) |
|
586 { |
|
587 case 0: |
|
588 { |
|
589 //**** async |
|
590 iLog->Log(_L("*****Async, EDescending")); |
|
591 sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); |
|
592 iAscendedSorted = EFalse; |
|
593 iLastNrOfDisplayData=0; |
|
594 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[aWhatIndexToSerrachFor]->Redefined()); |
|
595 // Test that if SetPartialReadParametersL is called after search has started it has no affect |
|
596 iDisplayData->SetPartialReadParametersL(*fakePartialParam); |
|
597 ExecuteLmOpL(); |
|
598 } |
|
599 break; |
|
600 case 1: |
|
601 { |
|
602 partialParam->SetRequestedPositionFields(reqFields); |
|
603 iDisplayData->SetPartialReadParametersL(*partialParam); |
|
604 sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
605 iLog->Log(_L("*****Async EAscending")); |
|
606 iAscendedSorted = ETrue; |
|
607 iLastNrOfDisplayData=0; |
|
608 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[aWhatIndexToSerrachFor]->Redefined()); |
|
609 ExecuteLmOpL(); |
|
610 } |
|
611 break; |
|
612 } |
|
613 |
|
614 // Sort correct result |
|
615 iJustNowSearchResults = &aSearchResults[aWhatIndexToSerrachFor]->SearchResult(); |
|
616 LandmarksSortL(*iJustNowSearchResults, sortPref); |
|
617 // |
|
618 iLog->Log(_L("Search Done, check sorting")); |
|
619 // Check for any errors when multi searching |
|
620 if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) |
|
621 { |
|
622 iLog->Log(_L("Errors after multi db search")); |
|
623 User::Leave(-1); |
|
624 } |
|
625 |
|
626 TInt number = iDisplayData->Count(); |
|
627 buf.Zero(); |
|
628 buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, iJustNowSearchResults->Count()); |
|
629 iLog->Log(buf); |
|
630 |
|
631 AssertTrueSecL(iDisplayData->Count() == iJustNowSearchResults->Count(),_L("Mismatch in number of matches")); |
|
632 |
|
633 for (TInt i=0;i<iDisplayData->Count();i++) |
|
634 { |
|
635 CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); |
|
636 TInt lmId = item.Landmark().LandmarkId(); |
|
637 CPosLandmark* target = iDatabase->ReadLandmarkLC((*iJustNowSearchResults)[i]); |
|
638 TPtrC sourceName, targetName; |
|
639 |
|
640 item.Landmark().GetLandmarkName(sourceName); |
|
641 target->GetLandmarkName(targetName); |
|
642 buf.Zero(); |
|
643 |
|
644 if (sourceName.CompareC(targetName) != 0) |
|
645 { |
|
646 |
|
647 iLog->Log(_L("Mismatch between landmarks")); |
|
648 User::Leave(-1); |
|
649 } |
|
650 CleanupStack::PopAndDestroy(target); |
|
651 |
|
652 // Landmarkname is always included when sorting |
|
653 CheckPartialLandmarkL(item.Landmark() , attr | CPosLandmark::ELandmarkName, reqFields); |
|
654 } |
|
655 |
|
656 } |
|
657 } |
|
658 |
|
659 CleanupStack::PopAndDestroy(fakePartialParam); |
|
660 CleanupStack::PopAndDestroy(partialParam); |
|
661 CleanupStack::PopAndDestroy(&reqFields); |
|
662 CleanupStack::PopAndDestroy(textCriteria); |
|
663 iMultiLandmarkSearch->UnsetDisplayData(); |
|
664 delete iDisplayData; |
|
665 iDisplayData = NULL; |
|
666 delete iMultiLandmarkSearch; |
|
667 iMultiLandmarkSearch = NULL; |
|
668 } |
|
669 |
|
670 |
|
671 // --------------------------------------------------------- |
|
672 // CPosTp133::CheckResetL |
|
673 // |
|
674 // (other items were commented in a header). |
|
675 // --------------------------------------------------------- |
|
676 // |
|
677 void CPosTp133::CheckResetL(const RPointerArray<CSearchResult>& aSearchResults, CDesCArray* aDbUris) |
|
678 { |
|
679 iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); |
|
680 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
681 TBuf<150> buf; |
|
682 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
683 |
|
684 iDisplayData = CPosLmDisplayData::NewL(); |
|
685 iMultiLandmarkSearch->SetDisplayData(*iDisplayData); |
|
686 iAscendedSorted = ETrue; |
|
687 |
|
688 for(TInt j=0; j<aSearchResults.Count(); j++) |
|
689 { |
|
690 textCriteria->SetTextL(aSearchResults[j]->TextCriteria()); |
|
691 textCriteria->SetAttributesToSearch(aSearchResults[j]->Attributes()); |
|
692 |
|
693 if (aSearchResults[j]->PositionFields().Find(803) != KErrNotFound) |
|
694 { |
|
695 // Stupid fix, since the multi dbs have not been re-generated against correct LBSFieldsid.h |
|
696 // they contain the 802 field (instead of 803) so append this id as well |
|
697 RArray<TUint> arr; |
|
698 iLog->Log(_L("Found 803")); |
|
699 arr = aSearchResults[j]->PositionFields(); |
|
700 arr.Append(802); |
|
701 textCriteria->SetPositionFieldsToSearchL(arr); |
|
702 } |
|
703 else |
|
704 { |
|
705 textCriteria->SetPositionFieldsToSearchL(aSearchResults[j]->PositionFields()); |
|
706 } |
|
707 |
|
708 iLog->Log(_L(">>>>>>Searching for: ")); |
|
709 iLog->Log(aSearchResults[j]->TextCriteria()); |
|
710 |
|
711 RArray<TPosLmItemId>* result = &aSearchResults[j]->SearchResult(); |
|
712 |
|
713 LandmarksSortL(*result, sortPref); |
|
714 iLastNrOfDisplayData = 0; |
|
715 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); |
|
716 ExecuteAndDeleteLD(iOperation); |
|
717 |
|
718 iLastNrOfDisplayData = 0; |
|
719 iDisplayData->Reset(); |
|
720 AssertTrueSecL(iDisplayData->Count() == 0,_L("DisplayData should have been resetted")); |
|
721 |
|
722 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[j]->Redefined()); |
|
723 // Also check progress here |
|
724 ExecuteLmOpL(); |
|
725 AssertTrueSecL(iDisplayData->Count() == result->Count(),_L("Mismatch in number of matches")); |
|
726 } |
|
727 |
|
728 iMultiLandmarkSearch->UnsetDisplayData(); |
|
729 iDisplayData->Reset(); |
|
730 iMultiLandmarkSearch->SetDisplayData(*iDisplayData); |
|
731 AssertTrueSecL(iDisplayData->Count() == 0,_L("DisplayData should have been resetted")); |
|
732 |
|
733 // Unset display data |
|
734 iMultiLandmarkSearch->UnsetDisplayData(); |
|
735 |
|
736 textCriteria->SetTextL(aSearchResults[0]->TextCriteria()); |
|
737 textCriteria->SetAttributesToSearch(aSearchResults[0]->Attributes()); |
|
738 textCriteria->SetPositionFieldsToSearchL(aSearchResults[0]->PositionFields()); |
|
739 |
|
740 // Check that no result is found in displaydata |
|
741 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[0]->Redefined()); |
|
742 ExecuteAndDeleteLD(iOperation); |
|
743 AssertTrueSecL(iDisplayData->Count() == 0,_L("No matches should be found in DisplayData1")); |
|
744 |
|
745 iMultiLandmarkSearch->SetDisplayData(*iDisplayData); |
|
746 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[0]->Redefined()); |
|
747 ExecuteAndDeleteLD(iOperation); |
|
748 |
|
749 // Check that result is found in displaydata |
|
750 RArray<TPosLmItemId>* searchResults = &aSearchResults[0]->SearchResult(); |
|
751 AssertTrueSecL(iMultiLandmarkSearch->TotalNumOfMatches() == iDisplayData->Count(),_L("Wrong number of matches1")); |
|
752 AssertTrueSecL(iMultiLandmarkSearch->TotalNumOfMatches() == searchResults->Count(),_L("Wrong number of matches2")); |
|
753 |
|
754 CleanupStack::PopAndDestroy(textCriteria); |
|
755 |
|
756 iMultiLandmarkSearch->UnsetDisplayData(); |
|
757 delete iDisplayData;iDisplayData=NULL; |
|
758 |
|
759 delete iMultiLandmarkSearch; |
|
760 iMultiLandmarkSearch = NULL; |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------- |
|
764 // CPosTp133::CancelTestL |
|
765 // |
|
766 // (other items were commented in a header). |
|
767 // --------------------------------------------------------- |
|
768 // |
|
769 void CPosTp133::CancelTestL(const RPointerArray<CSearchResult>& aSearchResults, CDesCArray* aDbUris, |
|
770 TBool aCancelInCallback) |
|
771 { |
|
772 iMultiLandmarkSearch = CPosLmMultiDbSearch::NewL(*aDbUris); |
|
773 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
774 TBuf<150> buf; |
|
775 CPosLmTextCriteria* textCriteria = CPosLmTextCriteria::NewLC(); |
|
776 |
|
777 // Search for wildcard, index 0 in lmdbsearchresult.txt |
|
778 TInt KWhatToSearchForIndex = 0; |
|
779 |
|
780 textCriteria->SetTextL(aSearchResults[KWhatToSearchForIndex]->TextCriteria()); |
|
781 textCriteria->SetAttributesToSearch(aSearchResults[KWhatToSearchForIndex]->Attributes()); |
|
782 textCriteria->SetPositionFieldsToSearchL(aSearchResults[KWhatToSearchForIndex]->PositionFields()); |
|
783 |
|
784 iLog->Log(_L(">>>>>>Searching for: ")); |
|
785 iLog->Log(aSearchResults[KWhatToSearchForIndex]->TextCriteria()); |
|
786 |
|
787 // Sort ascended and descended |
|
788 for (TInt sorted=0;sorted<2;sorted++) |
|
789 { |
|
790 iDisplayData = CPosLmDisplayData::NewL(); |
|
791 iMultiLandmarkSearch->SetDisplayData(*iDisplayData); |
|
792 |
|
793 switch (sorted) |
|
794 { |
|
795 case 0: |
|
796 iLog->Log(_L("******Sorting EAscending*******")); |
|
797 iAscendedSorted = ETrue; |
|
798 sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
799 break; |
|
800 case 1: |
|
801 iLog->Log(_L("**********Sorting EDescending**********")); |
|
802 iAscendedSorted = EFalse; |
|
803 sortPref = TPosLmSortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); |
|
804 break; |
|
805 } |
|
806 |
|
807 iJustNowSearchResults = &aSearchResults[KWhatToSearchForIndex]->SearchResult(); |
|
808 LandmarksSortL(*iJustNowSearchResults, sortPref); |
|
809 iLastNrOfDisplayData = 0; |
|
810 |
|
811 iOperation = iMultiLandmarkSearch->StartLandmarkSearchL(*textCriteria, sortPref, aSearchResults[KWhatToSearchForIndex]->Redefined()); |
|
812 |
|
813 switch (aCancelInCallback) |
|
814 { |
|
815 case EFalse: |
|
816 iLog->Log(_L("Cancel")); |
|
817 RunAsyncOperationAndCancelLD(iOperation); |
|
818 break; |
|
819 case ETrue: |
|
820 iLog->Log(_L("Cancel In Callback")); |
|
821 RunAsyncOperationAndCancelInCallbackLD(iOperation); |
|
822 break; |
|
823 } |
|
824 |
|
825 |
|
826 buf.Format(_L("TotalNumOfMatches returned %d matches and iDisplayData %d matches after cancel"), iMultiLandmarkSearch->TotalNumOfMatches(), iDisplayData->Count()); |
|
827 iLog->Log(buf); |
|
828 |
|
829 iLog->Log(_L("After Cancel, check result")); |
|
830 // Check for any errors when multi searching |
|
831 // XXX Shouldnt error be KErrCancel |
|
832 if (iMultiLandmarkSearch->NumOfSearchErrors() != 0) iLog->Log(_L("Errors after cancel")); |
|
833 for (TInt i=0;i<iMultiLandmarkSearch->NumOfSearchErrors(); i++) |
|
834 { |
|
835 CPosLmMultiDbSearch::TSearchError searchErr; |
|
836 iMultiLandmarkSearch->GetSearchError(i, searchErr); |
|
837 |
|
838 buf.Format(_L("ErrorCode %d returned from db nr %d"),searchErr.iErrorCode, searchErr.iDatabaseIndex); |
|
839 iLog->Log(buf); |
|
840 |
|
841 } |
|
842 |
|
843 TInt number = iDisplayData->Count(); |
|
844 buf.Zero(); |
|
845 buf.Format(_L("Nr in DisplayData: %d Nr in result %d"), number, iJustNowSearchResults->Count()); |
|
846 iLog->Log(buf); |
|
847 |
|
848 if (!aCancelInCallback) |
|
849 { |
|
850 if (iDisplayData->Count() != 0) |
|
851 { |
|
852 iLog->Log(_L("No matches should be found when cancel before search started")); |
|
853 User::Leave(-1); |
|
854 } |
|
855 } |
|
856 else |
|
857 { |
|
858 // XXX maybe check result here |
|
859 } |
|
860 |
|
861 iMultiLandmarkSearch->UnsetDisplayData(); |
|
862 delete iDisplayData;iDisplayData=NULL; |
|
863 } |
|
864 CleanupStack::PopAndDestroy(textCriteria); |
|
865 |
|
866 delete iMultiLandmarkSearch; |
|
867 iMultiLandmarkSearch = NULL; |
|
868 } |
|
869 |
|
870 // --------------------------------------------------------- |
|
871 // Tp133InternalLandmarksSortL |
|
872 // |
|
873 // (other items were commented in a header). |
|
874 // --------------------------------------------------------- |
|
875 // |
|
876 TInt Tp133InternalLandmarksSortL(const CPosLandmark& aSource, const CPosLandmark& aTarget) |
|
877 { |
|
878 TPtrC sourceName, targetName; |
|
879 |
|
880 User::LeaveIfError(aSource.GetLandmarkName(sourceName)); |
|
881 User::LeaveIfError(aTarget.GetLandmarkName(targetName)); |
|
882 |
|
883 return sourceName.CompareC(targetName); |
|
884 } |
|
885 |
|
886 // --------------------------------------------------------- |
|
887 // CPosTp133::LandmarksSortL |
|
888 // |
|
889 // (other items were commented in a header). |
|
890 // --------------------------------------------------------- |
|
891 // |
|
892 void CPosTp133::LandmarksSortL(RArray<TPosLmItemId>& aArray, const TPosLmSortPref& aSortPref) |
|
893 { |
|
894 iLog->Log(_L("LandmarksSortL")); |
|
895 RPointerArray<CPosLandmark> landmarks; |
|
896 CleanupClosePushL(landmarks); |
|
897 |
|
898 for (TInt i=0; i<aArray.Count(); i++) |
|
899 { |
|
900 CPosLandmark* lm = iDatabase->ReadLandmarkLC(aArray[i]); |
|
901 landmarks.Append(lm); |
|
902 CleanupStack::Pop(lm); |
|
903 } |
|
904 |
|
905 TLinearOrder<CPosLandmark> order(Tp133InternalLandmarksSortL); |
|
906 landmarks.Sort(order); |
|
907 |
|
908 aArray.Reset(); |
|
909 |
|
910 if (aSortPref.SortOrder() == TPosLmSortPref::EAscending) |
|
911 { |
|
912 for (TInt j=0; j<landmarks.Count(); j++) |
|
913 { |
|
914 aArray.Append(landmarks[j]->LandmarkId()); |
|
915 } |
|
916 } |
|
917 else |
|
918 { |
|
919 for (TInt k=landmarks.Count()-1; k>=0; k--) |
|
920 { |
|
921 aArray.Append(landmarks[k]->LandmarkId()); |
|
922 } |
|
923 } |
|
924 landmarks.ResetAndDestroy(); |
|
925 CleanupStack::PopAndDestroy(&landmarks); |
|
926 } |
|
927 |
|
928 // --------------------------------------------------------- |
|
929 // CPosTp133::ExecuteLmOpL |
|
930 // |
|
931 // (other items were commented in a header). |
|
932 // --------------------------------------------------------- |
|
933 // |
|
934 void CPosTp133::ExecuteLmOpL() |
|
935 { |
|
936 CActiveLmOperation* operationWrapper = new (ELeave) CActiveLmOperation(iLog); |
|
937 CleanupStack::PushL(operationWrapper); |
|
938 |
|
939 // Start operation with this class as observer |
|
940 operationWrapper->Start(iOperation, this); |
|
941 CActiveScheduler::Start(); |
|
942 |
|
943 operationWrapper->CheckOperationL(); |
|
944 operationWrapper->DeleteOperationD(); |
|
945 |
|
946 CleanupStack::PopAndDestroy(operationWrapper); |
|
947 } |
|
948 |
|
949 // --------------------------------------------------------- |
|
950 // CPosTp133::ExecuteLmOpInCallbackL |
|
951 // |
|
952 // (other items were commented in a header). |
|
953 // --------------------------------------------------------- |
|
954 // |
|
955 void CPosTp133::ExecuteLmOpInCallbackL() |
|
956 { |
|
957 CActiveLmOperation* activeLmOperation = new(ELeave) CActiveLmOperation(iLog, iUseLogFromThreadIsDisabled); |
|
958 CleanupStack::PushL(activeLmOperation); |
|
959 |
|
960 TCallBack callback(CLandmarkTestProcedureBase::CancelTest, activeLmOperation); |
|
961 |
|
962 CPeriodic* periodicTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
963 CleanupStack::PushL(periodicTimer); |
|
964 |
|
965 periodicTimer->Start(1, 1, callback); |
|
966 activeLmOperation->SetCancelTest(); |
|
967 // Start operation with this class as observer |
|
968 activeLmOperation->Start(iOperation, this); |
|
969 |
|
970 CActiveScheduler::Start(); |
|
971 periodicTimer->Cancel(); |
|
972 |
|
973 CleanupStack::PopAndDestroy(2, activeLmOperation); |
|
974 } |
|
975 |
|
976 // --------------------------------------------------------- |
|
977 // CPosTp133::NotifyProgress |
|
978 // |
|
979 // (other items were commented in a header). |
|
980 // --------------------------------------------------------- |
|
981 // |
|
982 void CPosTp133::NotifyProgress(TReal aProgress) |
|
983 { |
|
984 TBuf<100> buf; |
|
985 TInt progress = (TInt) (aProgress * 100); |
|
986 buf.Format(_L("Progress: %d"), progress); |
|
987 TInt nrOfMatches = 0; |
|
988 |
|
989 if (iDisplayData) |
|
990 { |
|
991 buf.Zero(); |
|
992 buf.Format(_L("Progress: %g DisplayData %d"), aProgress * 100, iDisplayData->Count()); |
|
993 |
|
994 // Check that nr of matches never decreases |
|
995 if (iLastNrOfDisplayData>iDisplayData->Count()) |
|
996 { |
|
997 iLog->Log(_L("ERROR: Less nr of mathes than in last search")); |
|
998 iErrorsFound++; |
|
999 } |
|
1000 |
|
1001 if (iDisplayData->Count()>0) |
|
1002 { |
|
1003 TPosLmSortPref sortPref(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
1004 // Check nr of hits for each db using the iterator |
|
1005 for (TInt i=0;i<KNrOfDatabases;i++) |
|
1006 { |
|
1007 CPosLmItemIterator* iter = iMultiLandmarkSearch->MatchIteratorL(i); |
|
1008 CleanupStack::PushL(iter); |
|
1009 if (iter->NumOfItemsL() > 0) |
|
1010 { |
|
1011 buf.Zero(); |
|
1012 buf.Format(_L("Found %d nr of lm in db %d"), iter->NumOfItemsL(), i); |
|
1013 |
|
1014 nrOfMatches+=iter->NumOfItemsL(); |
|
1015 } |
|
1016 CleanupStack::PopAndDestroy(iter); |
|
1017 } |
|
1018 |
|
1019 if (iAscendedSorted) sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EAscending); |
|
1020 else sortPref.SetSortByLandmarkAttribute(CPosLandmark::ELandmarkName, TPosLmSortPref::EDescending); |
|
1021 |
|
1022 for (TInt i=0;i<iDisplayData->Count();i++) |
|
1023 { |
|
1024 // Check for all but first and last |
|
1025 if (i>0 && i<iDisplayData->Count()-1) |
|
1026 { |
|
1027 CPosLmDisplayItem& item = iDisplayData->DisplayItem(i); |
|
1028 TInt lmId = item.Landmark().LandmarkId(); |
|
1029 |
|
1030 CPosLmDisplayItem& nextItem = iDisplayData->DisplayItem(i+1); |
|
1031 TInt nextLmId = item.Landmark().LandmarkId(); |
|
1032 |
|
1033 TPtrC name, nextLmName; |
|
1034 item.Landmark().GetLandmarkName(name); |
|
1035 nextItem.Landmark().GetLandmarkName(nextLmName); |
|
1036 |
|
1037 TInt order = nextLmName.CompareC(name); |
|
1038 if (iAscendedSorted) |
|
1039 { // sorted ascended |
|
1040 if (order < 0) |
|
1041 { |
|
1042 iLog->Log(_L("ERROR: Wrong sortorder when ascended")); |
|
1043 iErrorsFound++; |
|
1044 } |
|
1045 } |
|
1046 else // sorted descended |
|
1047 { |
|
1048 if (order > 0) |
|
1049 { |
|
1050 iLog->Log(_L("ERROR: Wrong sortorder when descended")); |
|
1051 iErrorsFound++; |
|
1052 } |
|
1053 |
|
1054 } |
|
1055 } // if (i>0 && i<iDisplayData->Count()-1) |
|
1056 } // for (TInt i=0;i<iDisplayData->Count();i++) |
|
1057 } // if (iDisplayData->Count()>0) |
|
1058 iLastNrOfDisplayData = iDisplayData->Count(); |
|
1059 } //if (iDisplayData) |
|
1060 } |
|
1061 |
|
1062 |
|
1063 // End of File |