author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 22:59:08 +0300 | |
branch | RCL_3 |
changeset 46 | 5146369cfdc9 |
parent 26 | 5d0ec8b709be |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 2002 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 "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: CLandmarkService class implementation |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
23
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
19 |
#include <EPos_HPosLmDatabaseInfo.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
20 |
#include <EPos_CPosLmDatabaseManager.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
21 |
#include <EPos_CPosLandmarkParser.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
22 |
#include <EPos_CPosLandmarkEncoder.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
23 |
#include <EPos_CPosLmItemIterator.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
24 |
#include <EPos_CPosLandmarkDatabase.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
25 |
#include <EPos_CPosLandmarkSearch.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
26 |
#include <EPos_CPosLmCategoryManager.h> |
5 | 27 |
#include "landmarkservice.h" |
28 |
#include "clandmarkcmdgetcategories.h" |
|
29 |
#include "clandmarkcmdgetlandmarks.h" |
|
30 |
#include "clandmarkmanagehandlers.h" |
|
31 |
#include "clandmarkfilter.h" |
|
32 |
#include "clandmarkmanageobjects.h" |
|
33 |
#include "mlandmarkobserver.h" |
|
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
34 |
#include "clandmarkdummyao.h" |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
35 |
#include "clandmarkoperation.h" |
5 | 36 |
//CONSTANTS |
37 |
_LIT(KProtocolSeparator, "://"); |
|
38 |
_LIT(KLocalProtocol, "file"); |
|
39 |
||
40 |
// ============================ MEMBER FUNCTIONS =============================== |
|
41 |
||
42 |
// ----------------------------------------------------------------------------- |
|
43 |
// CLandmarkService::NewL() |
|
44 |
// Two-phased constructor. |
|
45 |
// ----------------------------------------------------------------------------- |
|
46 |
// |
|
47 |
EXPORT_C CLandmarkService* CLandmarkService::NewL() |
|
48 |
{ |
|
49 |
CLandmarkService* self = CLandmarkService::NewLC(); |
|
50 |
CleanupStack::Pop( self ); |
|
51 |
return self; |
|
52 |
} |
|
53 |
||
54 |
// ----------------------------------------------------------------------------- |
|
55 |
// CLandmarkService::NewL() |
|
56 |
// Two-phased constructor. |
|
57 |
// ----------------------------------------------------------------------------- |
|
58 |
// |
|
59 |
EXPORT_C CLandmarkService* CLandmarkService::NewLC() |
|
60 |
{ |
|
61 |
CLandmarkService* self = new (ELeave) CLandmarkService(); |
|
62 |
CleanupStack::PushL( self ); |
|
63 |
self->ConstructL(); |
|
64 |
return self; |
|
65 |
} |
|
66 |
||
67 |
// ----------------------------------------------------------------------------- |
|
68 |
// CLandmarkService::ConstructL() |
|
69 |
// Symbian 2nd phase constructor can leave. |
|
70 |
// ----------------------------------------------------------------------------- |
|
71 |
// |
|
72 |
void CLandmarkService::ConstructL( ) |
|
73 |
{ |
|
74 |
#ifdef _DEBUG |
|
75 |
User::LeaveIfError (iLog.Connect ( ) ); |
|
76 |
iLog.CreateLog (_L("landmarks"),_L("log.txt"),EFileLoggingModeOverwrite ); |
|
77 |
iLog.Write (_L("CLandmarkService::ConstructL()") ); |
|
78 |
#endif |
|
79 |
||
80 |
iDatabaseManager = CPosLmDatabaseManager::NewL ( ); |
|
81 |
iManageHandler = CLandmarkManageHandlers::NewL ( ); |
|
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
82 |
iManageObjects = CLandmarkManageObjects::NewL(); |
5 | 83 |
SetActiveL(KNullDesC); |
84 |
} |
|
85 |
||
86 |
// ----------------------------------------------------------------------------- |
|
87 |
// CLandmarkService::CLandmarkService() |
|
88 |
// C++ default constructor can NOT contain any code, that might leave. |
|
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
CLandmarkService::CLandmarkService( ) |
|
92 |
{ |
|
93 |
} |
|
94 |
||
95 |
// ----------------------------------------------------------------------------- |
|
96 |
// CLandmarkService::~CLandmarkService() |
|
97 |
// Destructor. |
|
98 |
// ----------------------------------------------------------------------------- |
|
99 |
// |
|
100 |
CLandmarkService::~CLandmarkService( ) |
|
101 |
{ |
|
102 |
#ifdef _DEBUG |
|
103 |
iLog.Write (_L("CLandmarkService::~CLandmarkService()") ); |
|
104 |
iLog.CloseLog ( ); |
|
105 |
iLog.Close ( ); |
|
106 |
#endif |
|
107 |
||
108 |
delete iManageObjects; |
|
109 |
delete iDatabaseManager; |
|
110 |
delete iManageHandler; |
|
111 |
ReleaseLandmarkResources ( ); |
|
112 |
} |
|
113 |
||
114 |
// ----------------------------------------------------------------------------- |
|
115 |
// CLandmarkService::ImportL( CPosLmItemIterator*& aIterator, |
|
116 |
// CPosLandmarkParser& aLandmarkParser, TDesC& aDatabaseUri ) const |
|
117 |
// Imports landmarks parsed from the input file to the given database. |
|
118 |
// ----------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
EXPORT_C void CLandmarkService::ImportL( CPosLmItemIterator*& aIterator, |
|
121 |
CPosLandmarkParser& aLandmarkParser, const TDesC& aDatabaseUri ) |
|
122 |
{ |
|
123 |
#ifdef _DEBUG |
|
124 |
iLog.Write(_L("CLandmarkService::ImportL")); |
|
125 |
#endif |
|
126 |
||
127 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
128 |
if ( !handler ) |
|
129 |
{ |
|
130 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
131 |
} |
|
132 |
CPosLandmarkDatabase* db = handler->LandmarkDatabaseHandle(); |
|
133 |
CPosLmOperation* op = db->ImportLandmarksL(aLandmarkParser, |
|
134 |
CPosLandmarkDatabase::EDefaultOptions); |
|
135 |
CleanupStack::PushL(op); |
|
136 |
op->ExecuteL(); |
|
137 |
aIterator = db->ImportedLandmarksIteratorL(op); |
|
138 |
CleanupStack::PopAndDestroy(op); |
|
139 |
||
140 |
#ifdef _DEBUG |
|
141 |
iLog.Write(_L("CLandmarkService::ImportL:Exit")); |
|
142 |
#endif |
|
143 |
} |
|
144 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
145 |
EXPORT_C void CLandmarkService::ImportL( TInt32 aTransactionId, CPosLandmarkParser& aLandmarkParser, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
146 |
const TDesC& aDatabaseUri ) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
147 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
148 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
149 |
iLog.Write(_L("CLandmarkService::ImportL: Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
150 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
151 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
152 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
153 |
if ( !handler ) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
154 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
155 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
156 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
157 |
CLandmarkOperation* import = CLandmarkOperation::NewLC(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
158 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
159 |
import->ImportL(aTransactionId,handler,aLandmarkParser); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
160 |
iManageObjects->AppendL(import); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
161 |
CleanupStack::Pop(import); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
162 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
163 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
164 |
iLog.Write(_L("CLandmarkService::ImportL:Async:Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
165 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
166 |
} |
5 | 167 |
// ----------------------------------------------------------------------------- |
168 |
// CLandmarkService::ExportL( CPosLandmarkEncoder* aLandmarkEncoder, |
|
169 |
// const RArray<TPosLmItemId>& aLandmarkIdArray, const TDesC& aDatabaseUri ) |
|
170 |
// Exports a list of landmarks from database to a file. |
|
171 |
// ----------------------------------------------------------------------------- |
|
172 |
// |
|
173 |
EXPORT_C void CLandmarkService::ExportL( CPosLandmarkEncoder& aLandmarkEncoder, |
|
174 |
const RArray<TPosLmItemId>& aLandmarkIdArray, const TDesC& aDatabaseUri ) const |
|
175 |
{ |
|
176 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
177 |
if (!handler) |
|
178 |
{ |
|
179 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
180 |
} |
|
181 |
CPosLandmarkDatabase* db = handler->LandmarkDatabaseHandle(); |
|
182 |
ExecuteAndDeleteLD(db->ExportLandmarksL(aLandmarkEncoder,aLandmarkIdArray, |
|
183 |
CPosLandmarkDatabase::EIncludeCategories)); |
|
184 |
} |
|
185 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
186 |
EXPORT_C void CLandmarkService::ExportL( TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
187 |
CPosLandmarkEncoder& aLandmarkEncoder, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
188 |
const RArray<TPosLmItemId>& aLandmarkIdArray, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
189 |
const TDesC& aDestinationFile, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
190 |
const TDesC& aDatabaseUri ) const |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
191 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
192 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
193 |
if (!handler) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
194 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
195 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
196 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
197 |
CPosLandmarkDatabase* db = handler->LandmarkDatabaseHandle(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
198 |
CLandmarkOperation* exportAO = CLandmarkOperation::NewLC(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
199 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
200 |
exportAO->ExportL(aTransactionId,db,aLandmarkEncoder,aLandmarkIdArray,aDestinationFile); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
201 |
iManageObjects->AppendL(exportAO); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
202 |
CleanupStack::Pop(exportAO); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
203 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
204 |
|
5 | 205 |
// ----------------------------------------------------------------------------- |
206 |
// CLandmarkService::GetListL( CPosLmItemIterator*& aIterator, |
|
207 |
// const CLandmarkFilter* aFilter, const TDesC& aDatabaseUri ) const |
|
208 |
// Get a list of Landmarks/Categories from Database synchronously based on filter. |
|
209 |
// ----------------------------------------------------------------------------- |
|
210 |
// |
|
211 |
EXPORT_C void CLandmarkService::GetListL( CPosLmItemIterator*& aIterator, |
|
212 |
CLandmarkFilter& aFilter, const TDesC& aDatabaseUri ) const |
|
213 |
{ |
|
214 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
215 |
if ( !handler ) |
|
216 |
{ |
|
217 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
218 |
} |
|
219 |
CPosLandmarkSearch* search = handler->LandmarkSearchHandle(); |
|
220 |
search->SetMaxNumOfMatches(aFilter.MaximumMatches()); |
|
221 |
if ( aFilter.IsLandmark() ) |
|
222 |
{ |
|
223 |
ExecuteAndDeleteLD(search->StartLandmarkSearchL(aFilter.Criteria(), |
|
224 |
aFilter.LmSortPref(),aFilter.PreviousMatches())); |
|
225 |
} |
|
226 |
else |
|
227 |
{ |
|
228 |
ExecuteAndDeleteLD(search->StartCategorySearchL(aFilter.Criteria(), |
|
229 |
aFilter.CatSortPref(),aFilter.PreviousMatches())); |
|
230 |
} |
|
231 |
aIterator = search->MatchIteratorL(); |
|
232 |
} |
|
233 |
||
234 |
// ----------------------------------------------------------------------------- |
|
235 |
// CLandmarkService::GetListL( CDesCArray*& aDatabaseList, |
|
236 |
// const TDesC& aProtocol ) const |
|
237 |
// Get a list of Landmark databases. |
|
238 |
// ----------------------------------------------------------------------------- |
|
239 |
// |
|
240 |
EXPORT_C void CLandmarkService::GetListL (CDesCArray*& aDatabaseList, |
|
241 |
const TDesC& aProtocol) const |
|
242 |
{ |
|
243 |
if ( aProtocol != KNullDesC ) |
|
244 |
{ |
|
245 |
aDatabaseList = iDatabaseManager->ListDatabasesLC(aProtocol); |
|
246 |
} |
|
247 |
else |
|
248 |
{ |
|
249 |
aDatabaseList = iDatabaseManager->ListDatabasesLC(); |
|
250 |
} |
|
251 |
CleanupStack::Pop(aDatabaseList); |
|
252 |
} |
|
253 |
||
254 |
// ----------------------------------------------------------------------------- |
|
255 |
// CLandmarkService::GetListL( TInt32 aTransactionId, |
|
256 |
// CLandmarkFilter* aFilter,const TDesC & aDatabaseUri ) |
|
257 |
// Get a list of Landmarks/catgeories from Database asynchronously based on filter. |
|
258 |
// ----------------------------------------------------------------------------- |
|
259 |
// |
|
260 |
EXPORT_C void CLandmarkService::GetListL( TInt32 aTransactionId, |
|
261 |
CLandmarkFilter& aFilter, const TDesC& aDatabaseUri ) |
|
262 |
{ |
|
263 |
#ifdef _DEBUG |
|
264 |
iLog.Write(_L("CLandmarkService::GetListL: Landmark: Async")); |
|
265 |
#endif |
|
266 |
||
267 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
268 |
if ( !handler ) |
|
269 |
{ |
|
270 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
271 |
} |
|
272 |
||
273 |
//Leave if observer has not been set for the async call. |
|
274 |
if ( !iObserver ) |
|
275 |
{ |
|
276 |
User::Leave(KErrGeneral); |
|
277 |
} |
|
278 |
||
279 |
if ( aFilter.IsLandmark() ) |
|
280 |
{ |
|
281 |
CLandmarkCmdBase* getLm = CLandmarkCmdGetLandmarks::NewLC(iObserver, |
|
282 |
iManageObjects); |
|
283 |
getLm->StartL(handler,aTransactionId,aFilter); |
|
284 |
iManageObjects->AppendL(getLm); |
|
285 |
CleanupStack::Pop(getLm); |
|
286 |
#ifdef _DEBUG |
|
287 |
iLog.Write(_L("CLandmarkService::GetListL: Landmark: Async: Exit")); |
|
288 |
#endif |
|
289 |
} |
|
290 |
else |
|
291 |
{ |
|
292 |
CLandmarkCmdBase* getCat = CLandmarkCmdGetCategories::NewLC(iObserver, |
|
293 |
iManageObjects); |
|
294 |
getCat->StartL(handler,aTransactionId,aFilter); |
|
295 |
iManageObjects->AppendL(getCat); |
|
296 |
CleanupStack::Pop(getCat); |
|
297 |
#ifdef _DEBUG |
|
298 |
iLog.Write(_L("CLandmarkService::GetListL: Category: Async: Exit")); |
|
299 |
#endif |
|
300 |
} |
|
301 |
} |
|
302 |
||
303 |
// ----------------------------------------------------------------------------- |
|
304 |
// CLandmarkService::AddItemL( CPosLandmark& aLandmark,const TDesC& aDatabaseUri) |
|
305 |
// Adds a landmark to the given database. |
|
306 |
// ----------------------------------------------------------------------------- |
|
307 |
// |
|
308 |
EXPORT_C TPosLmItemId CLandmarkService::AddItemL( CPosLandmark& aLandmark, |
|
309 |
const TDesC& aDatabaseUri ) |
|
310 |
{ |
|
311 |
#ifdef _DEBUG |
|
312 |
iLog.Write(_L("CLandmarkService::AddItemL: Landmark")); |
|
313 |
#endif |
|
314 |
||
315 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
316 |
if ( !handler ) |
|
317 |
{ |
|
318 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
319 |
} |
|
320 |
CPosLandmarkDatabase* db = handler->LandmarkDatabaseHandle(); |
|
321 |
||
322 |
#ifdef _DEBUG |
|
323 |
iLog.Write(_L("CLandmarkService::AddItemL: Landmark:Exit")); |
|
324 |
#endif |
|
325 |
||
326 |
return db->AddLandmarkL(aLandmark); |
|
327 |
} |
|
328 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
329 |
EXPORT_C void CLandmarkService::AddItemL(TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
330 |
CPosLandmark& aLandmark, const TDesC& aDatabaseUri) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
331 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
332 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
333 |
iLog.Write(_L("CLandmarkService::AddItemL: Landmark: Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
334 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
335 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
336 |
//Leave if observer has not been set for the async call. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
337 |
if (!iObserver) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
338 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
339 |
User::Leave(KErrGeneral); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
340 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
341 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
342 |
TPosLmItemId id = 0; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
343 |
TRAPD(err,id = AddItemL(aLandmark,aDatabaseUri)); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
344 |
CLandmarkDummyAO* addLm = new (ELeave) CLandmarkDummyAO(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
345 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
346 |
CleanupStack::PushL(addLm); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
347 |
addLm->Start(aTransactionId, CLandmarkDummyAO::EAdd, id, err); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
348 |
iManageObjects->AppendL(addLm); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
349 |
CleanupStack::Pop(addLm); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
350 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
351 |
iLog.Write(_L("CLandmarkService::AddItemL: Landmark: Async: Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
352 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
353 |
} |
5 | 354 |
// ----------------------------------------------------------------------------- |
355 |
// CLandmarkService::AddItemL( CPosLandmarkCategory& aCategory,const TDesC& aDatabaseUri ) |
|
356 |
// Adds a landmark category to the given database. |
|
357 |
// ----------------------------------------------------------------------------- |
|
358 |
// |
|
359 |
EXPORT_C TPosLmItemId CLandmarkService::AddItemL( CPosLandmarkCategory& aCategory, |
|
360 |
const TDesC& aDatabaseUri ) |
|
361 |
{ |
|
362 |
#ifdef _DEBUG |
|
363 |
iLog.Write(_L("CLandmarkService::AddItemL: Category")); |
|
364 |
#endif |
|
365 |
||
366 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
367 |
if ( !handler ) |
|
368 |
{ |
|
369 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
370 |
} |
|
371 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
|
372 |
||
373 |
#ifdef _DEBUG |
|
374 |
iLog.Write(_L("CLandmarkService::AddItemL: Category: Exit")); |
|
375 |
#endif |
|
376 |
||
377 |
return cat->AddCategoryL(aCategory); |
|
378 |
} |
|
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
379 |
EXPORT_C void CLandmarkService::AddItemL(TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
380 |
CPosLandmarkCategory& aCategory, const TDesC& aDatabaseUri) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
381 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
382 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
383 |
iLog.Write(_L("CLandmarkService::AddItemL: Category: Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
384 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
385 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
386 |
//Leave if observer has not been set for the async call. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
387 |
if (!iObserver) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
388 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
389 |
User::Leave(KErrGeneral); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
390 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
391 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
392 |
TPosLmItemId id = 0; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
393 |
TRAPD(err,id = AddItemL(aCategory,aDatabaseUri)); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
394 |
CLandmarkDummyAO* addCat = new (ELeave) CLandmarkDummyAO(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
395 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
396 |
CleanupStack::PushL(addCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
397 |
addCat->Start(aTransactionId, CLandmarkDummyAO::EAdd, id, err); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
398 |
iManageObjects->AppendL(addCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
399 |
CleanupStack::Pop(addCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
400 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
401 |
iLog.Write(_L("CLandmarkService::AddItemL: Category: Async: Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
402 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
403 |
} |
5 | 404 |
// ----------------------------------------------------------------------------- |
405 |
// CLandmarkService::AddItemL( CPosLandmarkCategory& aCategory,const TDesC& aDatabaseUri ) |
|
406 |
// Adds a landmark category to the given database. |
|
407 |
// ----------------------------------------------------------------------------- |
|
408 |
// |
|
409 |
EXPORT_C void CLandmarkService::AddItemL( const TDesC& aDatabaseUri ) |
|
410 |
{ |
|
411 |
#ifdef _DEBUG |
|
412 |
iLog.Write(_L("CLandmarkService::AddItemL: Database")); |
|
413 |
#endif |
|
414 |
||
415 |
HPosLmDatabaseInfo* dbInfo = HPosLmDatabaseInfo::NewLC(aDatabaseUri); |
|
416 |
if ( ELocalDatabase == GetDbTypeFromUri ( aDatabaseUri ) ) |
|
417 |
{ |
|
418 |
iDatabaseManager->CreateDatabaseL(*dbInfo); |
|
419 |
} |
|
420 |
else |
|
421 |
{ |
|
422 |
iDatabaseManager->RegisterDatabaseL(*dbInfo); |
|
423 |
} |
|
424 |
CleanupStack::PopAndDestroy(dbInfo); |
|
425 |
||
426 |
#ifdef _DEBUG |
|
427 |
iLog.Write(_L("CLandmarkService::AddItemL: Database: Exit")); |
|
428 |
#endif |
|
429 |
} |
|
430 |
||
431 |
// ----------------------------------------------------------------------------- |
|
432 |
// CLandmarkService::UpdateItemL( const CPosLandmark& aLandmark, |
|
433 |
// const TDesC& aDatabaseUri ) |
|
434 |
// Updates a landmark in the given database. |
|
435 |
// ----------------------------------------------------------------------------- |
|
436 |
// |
|
437 |
EXPORT_C void CLandmarkService::UpdateItemL( const CPosLandmark& aLandmark, |
|
438 |
const TDesC& aDatabaseUri ) |
|
439 |
{ |
|
440 |
#ifdef _DEBUG |
|
441 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Landmark")); |
|
442 |
#endif |
|
443 |
||
444 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
445 |
if ( !handler ) |
|
446 |
{ |
|
447 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
448 |
} |
|
449 |
CPosLandmarkDatabase* db = handler->LandmarkDatabaseHandle(); |
|
450 |
db->UpdateLandmarkL(aLandmark); |
|
451 |
||
452 |
#ifdef _DEBUG |
|
453 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Landmark:Exit")); |
|
454 |
#endif |
|
455 |
} |
|
456 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
457 |
EXPORT_C void CLandmarkService::UpdateItemL(TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
458 |
const CPosLandmark& aLandmark, const TDesC& aDatabaseUri) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
459 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
460 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
461 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Landmark: Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
462 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
463 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
464 |
//Leave if observer has not been set for the async call. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
465 |
if (!iObserver) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
466 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
467 |
User::Leave(KErrGeneral); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
468 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
469 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
470 |
//start async now |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
471 |
TPosLmItemId id = 0; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
472 |
TRAPD(err,UpdateItemL(aLandmark,aDatabaseUri)); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
473 |
CLandmarkDummyAO* updateLm = new (ELeave) CLandmarkDummyAO(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
474 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
475 |
CleanupStack::PushL(updateLm); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
476 |
updateLm->Start(aTransactionId, CLandmarkDummyAO::EUpdate, id, err); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
477 |
iManageObjects->AppendL(updateLm); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
478 |
CleanupStack::Pop(updateLm); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
479 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
480 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Landmark: Async: Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
481 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
482 |
} |
5 | 483 |
// ----------------------------------------------------------------------------- |
484 |
// CLandmarkService::UpdateItemL( const CPosLandmarkCategory& aCategory, |
|
485 |
// const TDesC& aDatabaseUri ) |
|
486 |
// Updates a landmark Category in the given database. |
|
487 |
// ----------------------------------------------------------------------------- |
|
488 |
// |
|
489 |
EXPORT_C void CLandmarkService::UpdateItemL( const CPosLandmarkCategory& aCategory, |
|
490 |
const TDesC& aDatabaseUri ) |
|
491 |
{ |
|
492 |
#ifdef _DEBUG |
|
493 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Category")); |
|
494 |
#endif |
|
495 |
||
496 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
497 |
if ( !handler ) |
|
498 |
{ |
|
499 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
500 |
} |
|
501 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
|
502 |
cat->UpdateCategoryL(aCategory); |
|
503 |
||
504 |
#ifdef _DEBUG |
|
505 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Category; Exit")); |
|
506 |
#endif |
|
507 |
} |
|
508 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
509 |
EXPORT_C void CLandmarkService::UpdateItemL(TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
510 |
const CPosLandmarkCategory& aCategory, const TDesC& aDatabaseUri) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
511 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
512 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
513 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Landmark: Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
514 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
515 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
516 |
//Leave if observer has not been set for the async call. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
517 |
if (!iObserver) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
518 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
519 |
User::Leave(KErrGeneral); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
520 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
521 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
522 |
//start async now |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
523 |
TPosLmItemId id = 0; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
524 |
TRAPD(err,UpdateItemL(aCategory,aDatabaseUri)); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
525 |
CLandmarkDummyAO* updateCat = new (ELeave) CLandmarkDummyAO(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
526 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
527 |
CleanupStack::PushL(updateCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
528 |
updateCat->Start(aTransactionId, CLandmarkDummyAO::EUpdate, id, err); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
529 |
iManageObjects->AppendL(updateCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
530 |
CleanupStack::Pop(updateCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
531 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
532 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Landmark: Async: Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
533 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
534 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
535 |
|
5 | 536 |
// ----------------------------------------------------------------------------- |
537 |
// CLandmarkService::UpdateItemL( TPosLmDatabaseSettings aSettings, const TDesC& aDatabaseUri ) |
|
538 |
// Updates the database information in the given database. |
|
539 |
// ----------------------------------------------------------------------------- |
|
540 |
// |
|
541 |
EXPORT_C void CLandmarkService::UpdateItemL( TPosLmDatabaseSettings aSettings, |
|
542 |
const TDesC& aDatabaseUri ) |
|
543 |
{ |
|
544 |
#ifdef _DEBUG |
|
545 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Database")); |
|
546 |
#endif |
|
547 |
||
548 |
//while modifying database settings drive letter in database uri |
|
549 |
//should always be specified in uppercase. |
|
550 |
HBufC* dburi = aDatabaseUri.AllocLC(); |
|
551 |
//set modifiable pointer. |
|
552 |
TPtr modifyuri = dburi->Des(); |
|
553 |
||
554 |
TInt offset = aDatabaseUri.Find(KProtocolSeparator); |
|
555 |
if(offset>=0) |
|
556 |
{ |
|
557 |
//get drive letter |
|
558 |
TChar drive = modifyuri[offset+KProtocolSeparator.iTypeLength]; |
|
559 |
//make drive uppercase. |
|
560 |
drive.UpperCase(); |
|
561 |
modifyuri[offset+KProtocolSeparator.iTypeLength] = drive; |
|
562 |
} |
|
563 |
else |
|
564 |
{ |
|
565 |
//get drive letter at index-0 |
|
566 |
TChar drive = modifyuri[0]; |
|
567 |
//make drive uppercase. |
|
568 |
drive.UpperCase(); |
|
569 |
modifyuri[0] = drive; |
|
570 |
} |
|
571 |
||
572 |
iDatabaseManager->ModifyDatabaseSettingsL(*dburi,aSettings); |
|
573 |
CleanupStack::PopAndDestroy(dburi); |
|
574 |
#ifdef _DEBUG |
|
575 |
iLog.Write(_L("CLandmarkService::UpdateItemL: Database: Exit")); |
|
576 |
#endif |
|
577 |
} |
|
578 |
||
579 |
// ----------------------------------------------------------------------------- |
|
580 |
// CLandmarkService::LandmarkLC( const TPosLmItemId& aLandmarkId, |
|
581 |
// const TDesC& aDatabaseUri ) |
|
582 |
// Retrieves a landmark from the database. |
|
583 |
// ----------------------------------------------------------------------------- |
|
584 |
// |
|
585 |
EXPORT_C CPosLandmark* CLandmarkService::LandmarkLC( const TPosLmItemId& aLandmarkId, |
|
586 |
const TDesC& aDatabaseUri ) const |
|
587 |
{ |
|
588 |
CPosLandmark* landmark = NULL; |
|
589 |
CleanupStack::PushL(landmark); |
|
590 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
591 |
if ( !handler ) |
|
592 |
{ |
|
593 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
594 |
} |
|
595 |
CPosLandmarkDatabase* db = handler->LandmarkDatabaseHandle(); |
|
596 |
CPosLmItemIterator* iterator = db->LandmarkIteratorL(); |
|
597 |
CleanupStack::PushL(iterator); |
|
598 |
TPosLmItemId lmId; |
|
599 |
while ( (lmId = iterator->NextL()) != KPosLmNullItemId ) |
|
600 |
{ |
|
601 |
if ( aLandmarkId == lmId ) |
|
602 |
{ |
|
603 |
CleanupStack::PopAndDestroy(iterator); |
|
604 |
CleanupStack::Pop(landmark); |
|
605 |
return db->ReadLandmarkLC(lmId); |
|
606 |
} |
|
607 |
} |
|
608 |
CleanupStack::PopAndDestroy(iterator); |
|
609 |
return landmark; |
|
610 |
} |
|
611 |
||
612 |
// ----------------------------------------------------------------------------- |
|
613 |
// CLandmarkService::CategoryLC( const TPosLmItemId& aCategoryId, |
|
614 |
// const TDesC& aDatabaseUri ) |
|
615 |
// Retrieves a category from the database. |
|
616 |
// ----------------------------------------------------------------------------- |
|
617 |
// |
|
618 |
EXPORT_C CPosLandmarkCategory* CLandmarkService::CategoryLC( |
|
619 |
const TPosLmItemId& aCategoryId, const TDesC& aDatabaseUri ) const |
|
620 |
{ |
|
621 |
CPosLandmarkCategory* category = NULL; |
|
622 |
CleanupStack::PushL(category); |
|
623 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
624 |
if ( !handler ) |
|
625 |
{ |
|
626 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
627 |
} |
|
628 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
|
629 |
CPosLmItemIterator* iterator = cat->CategoryIteratorL(); |
|
630 |
CleanupStack::PushL(iterator); |
|
631 |
TPosLmItemId catId; |
|
632 |
while ( (catId = iterator->NextL()) != KPosLmNullItemId ) |
|
633 |
{ |
|
634 |
if ( aCategoryId == catId ) |
|
635 |
{ |
|
636 |
CleanupStack::PopAndDestroy(iterator); |
|
637 |
CleanupStack::Pop(category); |
|
638 |
return cat->ReadCategoryLC(catId); |
|
639 |
} |
|
640 |
} |
|
641 |
CleanupStack::PopAndDestroy(iterator); |
|
642 |
return category; |
|
643 |
} |
|
644 |
||
645 |
// ----------------------------------------------------------------------------- |
|
646 |
// CLandmarkService::RemoveItemL( TPosLmItemId aItemId, |
|
647 |
// TBool aItemIsLandmark, const TDesC& aDatabaseUri ) |
|
648 |
// Removes a landmark/ landmark category from the given database |
|
649 |
// ----------------------------------------------------------------------------- |
|
650 |
// |
|
651 |
EXPORT_C void CLandmarkService::RemoveItemL( TPosLmItemId aItemId, |
|
652 |
TPosItem aItemIsLandmark, const TDesC& aDatabaseUri ) |
|
653 |
{ |
|
654 |
#ifdef _DEBUG |
|
655 |
iLog.Write(_L("CLandmarkService::RemoveItemL")); |
|
656 |
#endif |
|
657 |
||
658 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
659 |
if ( !handler ) |
|
660 |
{ |
|
661 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
662 |
} |
|
663 |
if ( aItemIsLandmark ) |
|
664 |
{ |
|
665 |
CPosLandmarkDatabase* db = handler->LandmarkDatabaseHandle(); |
|
666 |
db->RemoveLandmarkL(aItemId); |
|
667 |
} |
|
668 |
else |
|
669 |
{ |
|
670 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
|
671 |
ExecuteAndDeleteLD(cat->RemoveCategoryL(aItemId)); |
|
672 |
} |
|
673 |
||
674 |
#ifdef _DEBUG |
|
675 |
iLog.Write(_L("CLandmarkService::RemoveItemL:exit")); |
|
676 |
#endif |
|
677 |
} |
|
678 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
679 |
EXPORT_C void CLandmarkService::RemoveItemL(TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
680 |
TPosLmItemId aItemId, TPosItem aItemIsLandmark, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
681 |
const TDesC& aDatabaseUri) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
682 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
683 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
684 |
iLog.Write(_L("CLandmarkService::RemoveItemL: Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
685 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
686 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
687 |
//Leave if observer has not been set for the async call. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
688 |
if (!iObserver) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
689 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
690 |
User::Leave(KErrGeneral); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
691 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
692 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
693 |
TPosLmItemId id = 0; |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
694 |
TRAPD(err,RemoveItemL(aItemId,aItemIsLandmark,aDatabaseUri)); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
695 |
CLandmarkDummyAO* rem = new (ELeave) CLandmarkDummyAO(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
696 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
697 |
CleanupStack::PushL(rem); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
698 |
rem->Start(aTransactionId, CLandmarkDummyAO::ERemove, id, err); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
699 |
iManageObjects->AppendL(rem); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
700 |
CleanupStack::Pop(rem); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
701 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
702 |
iLog.Write(_L("CLandmarkService::RemoveItemL: Async: Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
703 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
704 |
} |
5 | 705 |
// ----------------------------------------------------------------------------- |
706 |
// CLandmarkService::RemoveItemL( const TDesC& aDatabaseUri ) |
|
707 |
// Removes the given database. |
|
708 |
// ----------------------------------------------------------------------------- |
|
709 |
// |
|
710 |
EXPORT_C void CLandmarkService::RemoveItemL( const TDesC& aDatabaseUri ) |
|
711 |
{ |
|
712 |
#ifdef _DEBUG |
|
713 |
iLog.Write(_L("CLandmarkService::RemoveItemL: Database")); |
|
714 |
#endif |
|
715 |
||
716 |
if ( ELocalDatabase == GetDbTypeFromUri (aDatabaseUri) ) |
|
717 |
{ |
|
718 |
// will leave with KErrInUse if it is in use. |
|
719 |
iDatabaseManager->DeleteDatabaseL(aDatabaseUri); |
|
720 |
} |
|
721 |
else |
|
722 |
{ |
|
723 |
// this is for remote databases and it will remove this |
|
724 |
// database from being listed. |
|
725 |
iDatabaseManager->UnregisterDatabaseL(aDatabaseUri); |
|
726 |
} |
|
727 |
||
728 |
#ifdef _DEBUG |
|
729 |
iLog.Write(_L("CLandmarkService::RemoveItemL: Database: Exit")); |
|
730 |
#endif |
|
731 |
} |
|
732 |
||
733 |
// ----------------------------------------------------------------------------- |
|
734 |
// CLandmarkService::SetActiveL( const TDesC& aDatabaseUri ) |
|
735 |
// sets the given database as default. |
|
736 |
// ----------------------------------------------------------------------------- |
|
737 |
// |
|
738 |
EXPORT_C void CLandmarkService::SetActiveL( const TDesC& aDatabaseUri ) |
|
739 |
{ |
|
740 |
#ifdef _DEBUG |
|
741 |
iLog.Write(_L("CLandmarkService::SetActiveL: Database")); |
|
742 |
#endif |
|
743 |
||
744 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
745 |
if ( !handler ) |
|
746 |
{ |
|
747 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
748 |
} |
|
749 |
iManageHandler->SetDefaultHandler(handler); |
|
750 |
||
751 |
#ifdef _DEBUG |
|
752 |
iLog.Write(_L("CLandmarkService::SetActiveL: Database: Exit")); |
|
753 |
#endif |
|
754 |
} |
|
755 |
||
756 |
// ----------------------------------------------------------------------------- |
|
757 |
// CLandmarkService::LinkCategoryToLandmarksL( TPosLmItemId aCategoryId, |
|
758 |
// RArray< TPosLmItemId >& aLandmarkIdArray, const TDesC& aDatabaseUri ) |
|
759 |
// associates a category to a set of landmarks. |
|
760 |
// ----------------------------------------------------------------------------- |
|
761 |
// |
|
762 |
EXPORT_C void CLandmarkService::LinkCategoryToLandmarksL ( TPosLmItemId aCategoryId, |
|
763 |
RArray<TPosLmItemId>& aLandmarkIdArray, const TDesC& aDatabaseUri ) |
|
764 |
{ |
|
765 |
#ifdef _DEBUG |
|
766 |
iLog.Write(_L("CLandmarkService::LinkCategoryToLandmarksL")); |
|
767 |
#endif |
|
768 |
||
769 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
770 |
if ( !handler ) |
|
771 |
{ |
|
772 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
773 |
} |
|
774 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
|
775 |
ExecuteAndDeleteLD(cat->AddCategoryToLandmarksL(aCategoryId,aLandmarkIdArray)); |
|
776 |
||
777 |
#ifdef _DEBUG |
|
778 |
iLog.Write(_L("CLandmarkService::LinkCategoryToLandmarksL: Exit")); |
|
779 |
#endif |
|
780 |
} |
|
781 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
782 |
EXPORT_C void CLandmarkService::LinkCategoryToLandmarksL(TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
783 |
TPosLmItemId aCategoryId, RArray<TPosLmItemId>& aLandmarkIdArray, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
784 |
const TDesC& aDatabaseUri) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
785 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
786 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
787 |
iLog.Write(_L("CLandmarkService::LinkCategoryToLandmarksL :Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
788 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
789 |
//Leave if observer has not been set for the async call. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
790 |
if (!iObserver) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
791 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
792 |
User::Leave(KErrGeneral); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
793 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
794 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
795 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
796 |
if (!handler) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
797 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
798 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
799 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
800 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
801 |
CLandmarkOperation* linkCat = CLandmarkOperation::NewLC(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
802 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
803 |
linkCat->LinkL(aTransactionId,aCategoryId,aLandmarkIdArray,cat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
804 |
iManageObjects->AppendL(linkCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
805 |
CleanupStack::Pop(linkCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
806 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
807 |
iLog.Write(_L("CLandmarkService::LinkCategoryToLandmarksL: Async: Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
808 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
809 |
} |
5 | 810 |
// ----------------------------------------------------------------------------- |
811 |
// CLandmarkService::UnlinkCategoryToLandmarksL( TPosLmItemId aCategoryId, |
|
812 |
// RArray< TPosLmItemId >& aLandmarkIdArray, const TDesC& aDatabaseUri ) |
|
813 |
// associates a category to a set of landmarks. |
|
814 |
// ----------------------------------------------------------------------------- |
|
815 |
// |
|
816 |
EXPORT_C void CLandmarkService::UnlinkCategoryToLandmarksL ( |
|
817 |
TPosLmItemId aCategoryId, RArray<TPosLmItemId>& aLandmarkIdArray, |
|
818 |
const TDesC& aDatabaseUri ) |
|
819 |
{ |
|
820 |
#ifdef _DEBUG |
|
821 |
iLog.Write(_L("CLandmarkService::UnlinkCategoryToLandmarksL")); |
|
822 |
#endif |
|
823 |
||
824 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
|
825 |
if ( !handler ) |
|
826 |
{ |
|
827 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
|
828 |
} |
|
829 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
|
830 |
ExecuteAndDeleteLD(cat->RemoveCategoryFromLandmarksL(aCategoryId,aLandmarkIdArray)); |
|
831 |
||
832 |
#ifdef _DEBUG |
|
833 |
iLog.Write(_L("CLandmarkService::UnlinkCategoryToLandmarksL: Exit")); |
|
834 |
#endif |
|
835 |
} |
|
836 |
||
26
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
837 |
EXPORT_C void CLandmarkService::UnlinkCategoryToLandmarksL(TInt32 aTransactionId, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
838 |
TPosLmItemId aCategoryId, RArray<TPosLmItemId>& aLandmarkIdArray, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
839 |
const TDesC& aDatabaseUri) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
840 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
841 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
842 |
iLog.Write(_L("CLandmarkService::UnlinkCategoryToLandmarksL :Async")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
843 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
844 |
//Leave if observer has not been set for the async call. |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
845 |
if (!iObserver) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
846 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
847 |
User::Leave(KErrGeneral); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
848 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
849 |
|
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
850 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
851 |
if (!handler) |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
852 |
{ |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
853 |
handler = iManageHandler->CreateHandlerL(aDatabaseUri); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
854 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
855 |
CPosLmCategoryManager* cat = handler->CategoryManagerHandle(); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
856 |
CLandmarkOperation* linkCat = CLandmarkOperation::NewLC(iObserver, |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
857 |
iManageObjects); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
858 |
linkCat->UnLinkL(aTransactionId,aCategoryId,aLandmarkIdArray,cat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
859 |
iManageObjects->AppendL(linkCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
860 |
CleanupStack::Pop(linkCat); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
861 |
#ifdef _DEBUG |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
862 |
iLog.Write(_L("CLandmarkService::UnlinkCategoryToLandmarksL: Async: Exit")); |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
863 |
#endif |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
864 |
} |
5d0ec8b709be
Revision: 200949
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
23
diff
changeset
|
865 |
|
5 | 866 |
// ----------------------------------------------------------------------------- |
867 |
// CLandmarkService::RegisterObserver( MLandmarkObserver* aObserver ) |
|
868 |
// Register an observer for aynsc method. |
|
869 |
// ----------------------------------------------------------------------------- |
|
870 |
// |
|
871 |
EXPORT_C void CLandmarkService::RegisterObserver( MLandmarkObserver* aObserver ) |
|
872 |
{ |
|
873 |
if ( iObserver ) |
|
874 |
{ |
|
875 |
delete iObserver; |
|
876 |
iObserver = NULL; |
|
877 |
} |
|
878 |
iObserver = aObserver; |
|
879 |
} |
|
880 |
||
881 |
// ----------------------------------------------------------------------------- |
|
882 |
// CLandmarkService::Cancel( TInt32 aTransactionId ) |
|
883 |
// Cancel an ongoing async request. |
|
884 |
// ----------------------------------------------------------------------------- |
|
885 |
// |
|
886 |
EXPORT_C void CLandmarkService::Cancel( TInt32 aTransactionId ) const |
|
887 |
{ |
|
888 |
if ( iManageObjects ) |
|
889 |
{ |
|
890 |
iManageObjects->CancelObject(aTransactionId); |
|
891 |
} |
|
892 |
} |
|
893 |
||
894 |
// ----------------------------------------------------------------------------- |
|
895 |
// CLandmarkService::GetDefaultDbUri( TPtrC& aDefaultDbUri ) const |
|
896 |
// Gets the deafult Database URI. |
|
897 |
// ----------------------------------------------------------------------------- |
|
898 |
// |
|
899 |
EXPORT_C void CLandmarkService::GetDefaultDbUriL( TPtrC& aDefaultDbUri ) const |
|
900 |
{ |
|
901 |
CLandmarkHandler* handler = iManageHandler->GetHandlerL(KNullDesC); |
|
902 |
if ( handler ) |
|
903 |
{ |
|
904 |
handler->GetDatabaseUri(aDefaultDbUri); |
|
905 |
} |
|
906 |
} |
|
907 |
// ----------------------------------------------------------------------------- |
|
908 |
// CLandmarkService::GetDbTypeFromUri( const TDesC& aDbUri ) |
|
909 |
// returns type of database. |
|
910 |
// ----------------------------------------------------------------------------- |
|
911 |
// |
|
912 |
CLandmarkService::TDatabaseType CLandmarkService::GetDbTypeFromUri( |
|
913 |
const TDesC& aDbUri ) const |
|
914 |
{ |
|
915 |
CLandmarkService::TDatabaseType type = ERemoteDatabase; |
|
916 |
TInt offset = aDbUri.Find (KProtocolSeparator ); |
|
917 |
if ( KErrNotFound == offset ) |
|
918 |
{ |
|
919 |
type = ELocalDatabase; |
|
920 |
} |
|
921 |
else |
|
922 |
{ |
|
923 |
const TPtrC DbProtocol = aDbUri.Left (offset ); |
|
924 |
if ( DbProtocol == KLocalProtocol ) |
|
925 |
{ |
|
926 |
type = ELocalDatabase; |
|
927 |
} |
|
928 |
} |
|
929 |
return type; |
|
930 |
} |
|
931 |
||
932 |
// End of File |