|
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 "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: Operation to search for landmarks or landmark categories from |
|
15 * multiple databases |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32std.h> |
|
23 #include <e32debug.h> |
|
24 #include <EPos_Landmarks.h> |
|
25 #include <EPos_LandmarksErrors.h> |
|
26 #include <EPos_CPosLandmarkSearch.h> |
|
27 #include <EPos_CPosLmSearchCriteria.h> |
|
28 #include <EPos_CPosLmMultiDbSearch.h> |
|
29 |
|
30 #include "EPos_CPosLmMultiDbSearchOperation.h" |
|
31 #include "EPos_CPosLmActiveOperation.h" |
|
32 #include "EPos_PosLmCriteriaHelper.h" |
|
33 |
|
34 // CONSTANTS |
|
35 const TReal32 KPosProgressShareOpenDbs = 0.05; |
|
36 const TReal32 KPosProgressShareInitDbs = 0.10; |
|
37 const TReal32 KPosProgressShareCreateSearchOps = 0.05; |
|
38 const TReal32 KPosProgressShareSearchDbs = 0.80; |
|
39 const TReal32 KPosProgressComplete = 1.0; |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CPosLmMultiDbSearchOperation::CPosLmMultiDbSearchOperation |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 |
|
50 CPosLmMultiDbSearchOperation::CPosLmMultiDbSearchOperation( |
|
51 CPosLmMultiDbSearch* aMultiDbSearch, |
|
52 TBool aSearchOnlyPreviousMatches) |
|
53 : iMultiDbSearch(aMultiDbSearch), |
|
54 iSearchOnlyPreviousMatches(aSearchOnlyPreviousMatches), |
|
55 iOperationStatus(EOperationNotStarted), |
|
56 iSearchStatus(ESearchNotStarted) |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CPosLmMultiDbSearchOperation::ConstructL |
|
62 // Symbian 2nd phase constructor can leave. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CPosLmMultiDbSearchOperation::ConstructL( |
|
66 const CPosLmSearchCriteria& aCriteria, |
|
67 CPosLmMultiDbSortPref* aSortPref) |
|
68 { |
|
69 TBool isLmSearch = |
|
70 aSortPref->SortType() != CPosLmMultiDbSortPref::ECategorySorting; |
|
71 |
|
72 TBool useDistanceSorting; |
|
73 iCriteria = PosLmCriteriaHelper::ValidateAndCopyL( |
|
74 aCriteria, isLmSearch, useDistanceSorting); |
|
75 |
|
76 if (useDistanceSorting && |
|
77 aSortPref->SortType() == CPosLmMultiDbSortPref::ELandmarkNoSorting) |
|
78 { |
|
79 aSortPref->SetDistanceSorting(); |
|
80 } |
|
81 |
|
82 iSortPref = aSortPref; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CPosLmMultiDbSearchOperation::NewL |
|
87 // Two-phased constructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CPosLmMultiDbSearchOperation* CPosLmMultiDbSearchOperation::NewL( |
|
91 CPosLmMultiDbSearch* aMultiDbSearch, |
|
92 const CPosLmSearchCriteria& aCriteria, |
|
93 CPosLmMultiDbSortPref* aSortPref, |
|
94 TBool aSearchOnlyPreviousMatches) |
|
95 { |
|
96 CPosLmMultiDbSearchOperation* self = new (ELeave) |
|
97 CPosLmMultiDbSearchOperation(aMultiDbSearch, |
|
98 aSearchOnlyPreviousMatches); |
|
99 |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL(aCriteria, aSortPref); |
|
102 CleanupStack::Pop(self); |
|
103 return self; |
|
104 } |
|
105 |
|
106 // Destructor |
|
107 CPosLmMultiDbSearchOperation::~CPosLmMultiDbSearchOperation() |
|
108 { |
|
109 if (iClientStatus) |
|
110 { |
|
111 User::RequestComplete(iClientStatus, KErrCancel); |
|
112 } |
|
113 |
|
114 if (iMultiDbSearch) |
|
115 { |
|
116 iMultiDbSearch->HandleSearchOperationCompleted(); |
|
117 } |
|
118 |
|
119 delete iCriteria; |
|
120 delete iSortPref; |
|
121 |
|
122 iActiveOperations.ResetAndDestroy(); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CPosLmMultiDbSearchOperation::HandleMultiDbSearchDeleted |
|
127 // |
|
128 // (other items were commented in a header). |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CPosLmMultiDbSearchOperation::HandleMultiDbSearchDeleted() |
|
132 { |
|
133 iMultiDbSearch = NULL; |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CPosLmMultiDbSearchOperation::OperationCallBack |
|
138 // |
|
139 // (other items were commented in a header). |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 TInt CPosLmMultiDbSearchOperation::OperationCallBack(TAny* aPtr) |
|
143 { |
|
144 CPosLmActiveOperation* activeOp = static_cast<CPosLmActiveOperation*>(aPtr); |
|
145 |
|
146 CPosLmMultiDbSearchOperation* thisOp = |
|
147 static_cast<CPosLmMultiDbSearchOperation*>(activeOp->Owner()); |
|
148 |
|
149 return thisOp->DoOperationCallBack(activeOp); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CPosLmMultiDbSearchOperation::NextStep |
|
154 // |
|
155 // (other items were commented in a header). |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CPosLmMultiDbSearchOperation::NextStep( |
|
159 TRequestStatus& aStatus, |
|
160 TReal32& aProgress) |
|
161 { |
|
162 if (iOperationStatus == ESyncStarted || |
|
163 iOperationStatus == EOperationCompleted || |
|
164 iClientStatus) |
|
165 { |
|
166 Panic(KPosLandmarksClientPanic, EPosInvalidOperationMode); |
|
167 } |
|
168 iOperationStatus = EAsyncStarted; |
|
169 |
|
170 aStatus = KRequestPending; |
|
171 aProgress = iProgress; |
|
172 iClientStatus = &aStatus; |
|
173 iClientProgress = &aProgress; |
|
174 |
|
175 // We can't continue if client has deleted iMultiDbSearch. |
|
176 if (!iMultiDbSearch) |
|
177 { |
|
178 CompleteClientRequest(); |
|
179 return; |
|
180 } |
|
181 |
|
182 if (iSearchStatus == ESearchNotStarted) |
|
183 { |
|
184 IncrementSearchStep(); |
|
185 } |
|
186 |
|
187 if (iSearchStatus == EInitDbs || iSearchStatus == ESearchDbs) |
|
188 { |
|
189 ExecuteAsyncStep(); |
|
190 } |
|
191 else |
|
192 { |
|
193 ExecuteSyncStep(); |
|
194 IncrementSearchStep(); |
|
195 CompleteClientRequest(); |
|
196 } |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CPosLmMultiDbSearchOperation::ExecuteL |
|
201 // |
|
202 // (other items were commented in a header). |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CPosLmMultiDbSearchOperation::ExecuteL() |
|
206 { |
|
207 if (iOperationStatus != EOperationNotStarted) |
|
208 { |
|
209 Panic(KPosLandmarksClientPanic, EPosInvalidOperationMode); |
|
210 } |
|
211 iOperationStatus = ESyncStarted; |
|
212 |
|
213 // We can't continue if client has deleted iMultiDbSearch. |
|
214 if (!iMultiDbSearch) |
|
215 { |
|
216 return; |
|
217 } |
|
218 |
|
219 while (iCurrentDbIndex < iMultiDbSearch->NumOfDatabasesToSearch()) |
|
220 { |
|
221 if (iMultiDbSearch->ToBeSearched(iCurrentDbIndex)) |
|
222 { |
|
223 ExecuteSyncStep(); |
|
224 } |
|
225 |
|
226 iCurrentDbIndex++; |
|
227 } |
|
228 |
|
229 iOperationStatus = EOperationCompleted; |
|
230 HandleOperationCompleted(); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CPosLmMultiDbSearchOperation::HandleOperationCompleted |
|
235 // |
|
236 // (other items were commented in a header). |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CPosLmMultiDbSearchOperation::HandleOperationCompleted() |
|
240 { |
|
241 if (iMultiDbSearch) |
|
242 { |
|
243 iMultiDbSearch->HandleSearchOperationCompleted(); |
|
244 iMultiDbSearch = NULL; |
|
245 } |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CPosLmMultiDbSearchOperation::CompleteClientRequest |
|
250 // |
|
251 // (other items were commented in a header). |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 void CPosLmMultiDbSearchOperation::CompleteClientRequest() |
|
255 { |
|
256 if (!iClientStatus) |
|
257 { |
|
258 return; |
|
259 } |
|
260 |
|
261 if (!iMultiDbSearch) |
|
262 { |
|
263 iSearchStatus = ESearchCompleted; |
|
264 } |
|
265 |
|
266 TInt status = KPosLmOperationNotComplete; |
|
267 if (iSearchStatus == ESearchCompleted) |
|
268 { |
|
269 status = KErrNone; |
|
270 |
|
271 iOperationStatus = EOperationCompleted; |
|
272 HandleOperationCompleted(); |
|
273 } |
|
274 |
|
275 CalculateProgress(); |
|
276 *iClientProgress = iProgress; |
|
277 |
|
278 User::RequestComplete(iClientStatus, status); |
|
279 } |
|
280 |
|
281 // ----------------------------------------------------------------------------- |
|
282 // CPosLmMultiDbSearchOperation::IncrementSearchStep |
|
283 // |
|
284 // (other items were commented in a header). |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 void CPosLmMultiDbSearchOperation::IncrementSearchStep() |
|
288 { |
|
289 IncrementIndexAndSearchStatus(); |
|
290 |
|
291 while (((iSearchStatus == EOpenDbs || iSearchStatus == ECreateSearchOps) && |
|
292 !iMultiDbSearch->ToBeSearched(iCurrentDbIndex)) || |
|
293 ((iSearchStatus == EInitDbs || iSearchStatus == ESearchDbs) && |
|
294 iActiveOperations.Count() == 0)) |
|
295 { |
|
296 IncrementIndexAndSearchStatus(); |
|
297 } |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CPosLmMultiDbSearchOperation::IncrementIndexAndSearchStatus |
|
302 // |
|
303 // (other items were commented in a header). |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 void CPosLmMultiDbSearchOperation::IncrementIndexAndSearchStatus() |
|
307 { |
|
308 switch (iSearchStatus) |
|
309 { |
|
310 case ESearchNotStarted: |
|
311 case EInitDbs: |
|
312 case ESearchDbs: |
|
313 iCurrentDbIndex = 0; |
|
314 IncrementSearchStatus(); |
|
315 break; |
|
316 |
|
317 case EOpenDbs: |
|
318 case ECreateSearchOps: |
|
319 iCurrentDbIndex++; |
|
320 if (iCurrentDbIndex == iMultiDbSearch->NumOfDatabasesToSearch()) |
|
321 { |
|
322 iCurrentDbIndex = 0; |
|
323 IncrementSearchStatus(); |
|
324 } |
|
325 break; |
|
326 } |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CPosLmMultiDbSearchOperation::IncrementSearchStatus |
|
331 // |
|
332 // (other items were commented in a header). |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CPosLmMultiDbSearchOperation::IncrementSearchStatus() |
|
336 { |
|
337 switch (iSearchStatus) |
|
338 { |
|
339 case ESearchNotStarted: |
|
340 iSearchStatus = EOpenDbs; |
|
341 break; |
|
342 |
|
343 case EOpenDbs: |
|
344 iSearchStatus = EInitDbs; |
|
345 break; |
|
346 |
|
347 case EInitDbs: |
|
348 iSearchStatus = ECreateSearchOps; |
|
349 break; |
|
350 |
|
351 case ECreateSearchOps: |
|
352 iSearchStatus = ESearchDbs; |
|
353 break; |
|
354 |
|
355 case ESearchDbs: |
|
356 iSearchStatus = ESearchCompleted; |
|
357 break; |
|
358 } |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CPosLmMultiDbSearchOperation::ExecuteSyncStep |
|
363 // |
|
364 // (other items were commented in a header). |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 void CPosLmMultiDbSearchOperation::ExecuteSyncStep() |
|
368 { |
|
369 TRAPD(error, ExecuteSyncStepL()); |
|
370 if (error != KErrNone) |
|
371 { |
|
372 iMultiDbSearch->AddSearchError(iCurrentDbIndex, error); |
|
373 } |
|
374 } |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // CPosLmMultiDbSearchOperation::ExecuteSyncStepL |
|
378 // |
|
379 // (other items were commented in a header). |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 void CPosLmMultiDbSearchOperation::ExecuteSyncStepL() |
|
383 { |
|
384 CPosLmOperation* initOp; |
|
385 if (iOperationStatus == ESyncStarted) |
|
386 { |
|
387 initOp = OpenDbAndCreateInitOpL(); |
|
388 if (initOp) |
|
389 { |
|
390 ExecuteAndDeleteLD(initOp); |
|
391 } |
|
392 |
|
393 ExecuteAndDeleteLD(CreateSearchOpL()); |
|
394 |
|
395 iMultiDbSearch->SearchExecutedL(iCurrentDbIndex, *iSortPref); |
|
396 } |
|
397 else |
|
398 { |
|
399 switch (iSearchStatus) |
|
400 { |
|
401 case EOpenDbs: |
|
402 initOp = OpenDbAndCreateInitOpL(); |
|
403 if (initOp) |
|
404 { |
|
405 AppendAsActiveOperationL(initOp); |
|
406 } |
|
407 break; |
|
408 |
|
409 case ECreateSearchOps: |
|
410 AppendAsActiveOperationL(CreateSearchOpL()); |
|
411 break; |
|
412 |
|
413 default: |
|
414 break; |
|
415 } |
|
416 } |
|
417 } |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // CPosLmMultiDbSearchOperation::OpenDbAndCreateInitOpL |
|
421 // |
|
422 // (other items were commented in a header). |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 CPosLmOperation* CPosLmMultiDbSearchOperation::OpenDbAndCreateInitOpL() |
|
426 { |
|
427 CPosLandmarkDatabase* db = iMultiDbSearch->DatabaseL(iCurrentDbIndex); |
|
428 |
|
429 CPosLmOperation* initOp = NULL; |
|
430 if (db->IsInitializingNeeded()) |
|
431 { |
|
432 initOp = db->InitializeL(); |
|
433 } |
|
434 |
|
435 return initOp; |
|
436 } |
|
437 |
|
438 // ----------------------------------------------------------------------------- |
|
439 // CPosLmMultiDbSearchOperation::CreateSearchOpL |
|
440 // |
|
441 // (other items were commented in a header). |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 CPosLmOperation* CPosLmMultiDbSearchOperation::CreateSearchOpL() |
|
445 { |
|
446 CPosLandmarkSearch* searcher = iMultiDbSearch->SearcherL(iCurrentDbIndex); |
|
447 CPosLmOperation* searchOp; |
|
448 |
|
449 if (iSortPref->SortType() == CPosLmMultiDbSortPref::ECategorySorting) |
|
450 { |
|
451 searchOp = searcher->StartCategorySearchL( |
|
452 *iCriteria, iSortPref->CategorySortPref(), |
|
453 iSearchOnlyPreviousMatches); |
|
454 } |
|
455 else if (iSortPref->SortType() == CPosLmMultiDbSortPref::ELandmarkSorting) |
|
456 { |
|
457 searchOp = searcher->StartLandmarkSearchL( |
|
458 *iCriteria, iSortPref->LandmarkSortPref(), |
|
459 iSearchOnlyPreviousMatches); |
|
460 } |
|
461 else |
|
462 { |
|
463 searchOp = searcher->StartLandmarkSearchL( |
|
464 *iCriteria, iSearchOnlyPreviousMatches); |
|
465 } |
|
466 |
|
467 iMultiDbSearch->SearchStarted(iCurrentDbIndex); |
|
468 |
|
469 return searchOp; |
|
470 } |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CPosLmMultiDbSearchOperation::AppendAsActiveOperationL |
|
474 // |
|
475 // (other items were commented in a header). |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 void CPosLmMultiDbSearchOperation::AppendAsActiveOperationL( |
|
479 CPosLmOperation* aOperation) |
|
480 { |
|
481 CleanupStack::PushL(aOperation); |
|
482 CPosLmActiveOperation* activeOp = |
|
483 CPosLmActiveOperation::NewL(aOperation, iCurrentDbIndex, this); |
|
484 CleanupStack::Pop(aOperation); |
|
485 |
|
486 CleanupStack::PushL(activeOp); |
|
487 iActiveOperations.AppendL(activeOp); |
|
488 CleanupStack::Pop(activeOp); |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CPosLmMultiDbSearchOperation::ExecuteAsyncStep |
|
493 // |
|
494 // (other items were commented in a header). |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 void CPosLmMultiDbSearchOperation::ExecuteAsyncStep() |
|
498 { |
|
499 for (TInt i = 0; i < iActiveOperations.Count(); i++) |
|
500 { |
|
501 CPosLmActiveOperation* activeOp = iActiveOperations[i]; |
|
502 if (!activeOp->IsActive()) |
|
503 { |
|
504 TCallBack callback(OperationCallBack, activeOp); |
|
505 activeOp->ExecuteStep(callback); |
|
506 } |
|
507 } |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // CPosLmMultiDbSearchOperation::DoOperationCallBack |
|
512 // |
|
513 // (other items were commented in a header). |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 TInt CPosLmMultiDbSearchOperation::DoOperationCallBack( |
|
517 CPosLmActiveOperation* aActiveOp) |
|
518 { |
|
519 // We can't continue if client has deleted iMultiDbSearch. |
|
520 if (!iMultiDbSearch) |
|
521 { |
|
522 CompleteClientRequest(); |
|
523 return 0; |
|
524 } |
|
525 |
|
526 TInt status = aActiveOp->Status(); |
|
527 if (status != KErrNone && status != KPosLmOperationNotComplete) |
|
528 { |
|
529 iMultiDbSearch->AddSearchError(aActiveOp->DatabaseIndex(), status); |
|
530 } |
|
531 else if (iSearchStatus == ESearchDbs) |
|
532 { |
|
533 TRAPD(err, iMultiDbSearch->SearchExecutedL(aActiveOp->DatabaseIndex(), |
|
534 *iSortPref)); |
|
535 if (err != KErrNone) |
|
536 { |
|
537 iMultiDbSearch->AddSearchError(aActiveOp->DatabaseIndex(), err); |
|
538 status = err; |
|
539 } |
|
540 } |
|
541 |
|
542 if (status == KPosLmOperationNotComplete) |
|
543 { |
|
544 CompleteClientRequest(); |
|
545 } |
|
546 else |
|
547 { |
|
548 TInt index = iActiveOperations.Find(aActiveOp); |
|
549 __ASSERT_DEBUG(index != KErrNotFound, |
|
550 Panic(KPosLandmarksClientPanic, EPosInvalidIndex)); |
|
551 iActiveOperations.Remove(index); |
|
552 delete aActiveOp; |
|
553 |
|
554 if (iActiveOperations.Count() == 0) |
|
555 { |
|
556 IncrementSearchStep(); |
|
557 CompleteClientRequest(); |
|
558 } |
|
559 } |
|
560 |
|
561 return 0; // Do not call again |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // CPosLmMultiDbSearchOperation::CalculateProgress |
|
566 // |
|
567 // (other items were commented in a header). |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 void CPosLmMultiDbSearchOperation::CalculateProgress() |
|
571 { |
|
572 switch (iSearchStatus) |
|
573 { |
|
574 case ESearchNotStarted: |
|
575 iProgress = 0; |
|
576 break; |
|
577 |
|
578 case EOpenDbs: |
|
579 iProgress = KPosProgressShareOpenDbs * |
|
580 CalculateSyncStepProgress(); |
|
581 break; |
|
582 |
|
583 case EInitDbs: |
|
584 iProgress = KPosProgressShareOpenDbs + |
|
585 KPosProgressShareInitDbs * |
|
586 CalculateAsyncStepProgress(); |
|
587 break; |
|
588 |
|
589 case ECreateSearchOps: |
|
590 iProgress = KPosProgressShareOpenDbs + |
|
591 KPosProgressShareInitDbs + |
|
592 KPosProgressShareCreateSearchOps * |
|
593 CalculateSyncStepProgress(); |
|
594 break; |
|
595 |
|
596 case ESearchDbs: |
|
597 iProgress = KPosProgressShareOpenDbs + |
|
598 KPosProgressShareInitDbs + |
|
599 KPosProgressShareCreateSearchOps + |
|
600 KPosProgressShareSearchDbs * |
|
601 CalculateAsyncStepProgress(); |
|
602 break; |
|
603 |
|
604 case ESearchCompleted: |
|
605 iProgress = KPosProgressComplete; |
|
606 break; |
|
607 } |
|
608 } |
|
609 |
|
610 // ----------------------------------------------------------------------------- |
|
611 // CPosLmMultiDbSearchOperation::CalculateSyncStepProgress |
|
612 // |
|
613 // (other items were commented in a header). |
|
614 // ----------------------------------------------------------------------------- |
|
615 // |
|
616 TReal32 CPosLmMultiDbSearchOperation::CalculateSyncStepProgress() |
|
617 { |
|
618 return TReal32(iCurrentDbIndex) / |
|
619 TReal32(iMultiDbSearch->NumOfDatabasesToSearch()); |
|
620 } |
|
621 |
|
622 // ----------------------------------------------------------------------------- |
|
623 // CPosLmMultiDbSearchOperation::CalculateAsyncStepProgress |
|
624 // |
|
625 // (other items were commented in a header). |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 TReal32 CPosLmMultiDbSearchOperation::CalculateAsyncStepProgress() |
|
629 { |
|
630 TUint numOfDbs = iMultiDbSearch->NumOfDatabasesToSearch(); |
|
631 |
|
632 TReal32 stepProgress = TReal32(numOfDbs - iActiveOperations.Count()) / |
|
633 TReal32(numOfDbs); |
|
634 |
|
635 for (TInt i = 0; i < iActiveOperations.Count(); i++) |
|
636 { |
|
637 CPosLmActiveOperation* activeOp = iActiveOperations[i]; |
|
638 stepProgress += activeOp->Progress() / TReal32(numOfDbs); |
|
639 } |
|
640 |
|
641 return stepProgress; |
|
642 } |
|
643 |
|
644 // End of File |