|
1 /* |
|
2 * Copyright (c) 2002-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: Landmark iterator. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <epos_cposlmlocaldbaccess.h> |
|
22 #include <epos_poslmlandmarkhandler.h> |
|
23 |
|
24 #include "epos_cposlmlocaldatabase.h" |
|
25 #include "EPos_CPosLmLocalGetSortedIdsOp.h" |
|
26 #include "EPos_CPosLmLocalLandmarkIterator.h" |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CPosLmLocalLandmarkIterator::CPosLmLocalLandmarkIterator() : |
|
34 CPosLmLocalIterator(), |
|
35 iSortPref(CPosLandmark::ELandmarkName), |
|
36 iUseSort(EFalse) |
|
37 { |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CPosLmLocalLandmarkIterator::CPosLmLocalLandmarkIterator( |
|
44 TPosLmSortPref aSortPref) : |
|
45 CPosLmLocalIterator(), |
|
46 iSortPref(aSortPref), |
|
47 iUseSort(ETrue) |
|
48 { |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CPosLmLocalLandmarkIterator::ConstructL( |
|
55 CPosLmLocalDatabase& aDb, TBool aAlreadyHasLock ) |
|
56 { |
|
57 if (iUseSort && iSortPref.LandmarkAttributeToSortBy() != |
|
58 CPosLandmark::ELandmarkName) |
|
59 { |
|
60 User::Leave(KErrNotSupported); |
|
61 } |
|
62 |
|
63 if ( iUseSort ) |
|
64 { |
|
65 CPosLmLocalGetSortedIdsOp* op = CPosLmLocalGetSortedIdsOp::NewL( aDb, iSortPref ); |
|
66 CleanupStack::PushL( op ); |
|
67 op->ExecuteL(); |
|
68 op->GetResultL( iIdArray ); |
|
69 CleanupStack::PopAndDestroy( op ); |
|
70 } |
|
71 else |
|
72 { |
|
73 if (!aAlreadyHasLock) |
|
74 { |
|
75 aDb.AquireLockLC(CPosLmLocalDatabase::EReadLock); |
|
76 } |
|
77 |
|
78 PosLmLandmarkHandler::GetAllLandmarkIdsL( |
|
79 *aDb.DatabaseAccess(), |
|
80 EFalse, EFalse, |
|
81 iIdArray ); |
|
82 |
|
83 if (!aAlreadyHasLock) |
|
84 { |
|
85 CleanupStack::PopAndDestroy(); // DbLock |
|
86 } |
|
87 } |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CPosLmLocalLandmarkIterator* CPosLmLocalLandmarkIterator::NewL( |
|
94 CPosLmLocalDatabase& aDb, TBool aAlreadyHasLock) |
|
95 { |
|
96 CPosLmLocalLandmarkIterator* self = |
|
97 new(ELeave) CPosLmLocalLandmarkIterator(); |
|
98 CleanupStack::PushL(self); |
|
99 self->ConstructL(aDb, aAlreadyHasLock); |
|
100 CleanupStack::Pop(self); |
|
101 return self; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 CPosLmLocalLandmarkIterator* CPosLmLocalLandmarkIterator::NewL( |
|
108 CPosLmLocalDatabase& aDb, |
|
109 TPosLmSortPref aSortPref) |
|
110 { |
|
111 CPosLmLocalLandmarkIterator* self = new(ELeave) CPosLmLocalLandmarkIterator( |
|
112 aSortPref); |
|
113 CleanupStack::PushL(self); |
|
114 self->ConstructL(aDb); |
|
115 CleanupStack::Pop(self); |
|
116 return self; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 CPosLmLocalLandmarkIterator::~CPosLmLocalLandmarkIterator() |
|
123 { |
|
124 } |
|
125 |
|
126 |
|
127 |