author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 19 | 989d2f495d90 |
permissions | -rw-r--r-- |
19 | 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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
// INCLUDE FILES |
|
22 |
#include <e32svr.h> |
|
23 |
#include <f32file.h> |
|
24 |
#include <StifParser.h> |
|
25 |
#include <e32std.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
26 |
#include <StifTestInterface.h> |
19 | 27 |
#include <liwgenericparam.h> |
28 |
#include <liwservicehandler.h> |
|
29 |
#include <liwvariant.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
30 |
#include <EPos_CPosLandmarkDatabase.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
31 |
#include <EPos_CPosLandmark.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
32 |
#include <EPos_CPosLandmarkEncoder.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
33 |
#include <EPos_CPosLmCategoryManager.h> |
19 | 34 |
#include <EPos_HPosLmDatabaseInfo.h> |
35 |
#include <EPos_CPosLmDatabaseManager.h> |
|
36 |
#include <lbsposition.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
37 |
#include "tlandmarkprovider.h" |
19 | 38 |
#include "landmarkliwparams.hrh" |
39 |
||
40 |
// EXTERNAL DATA STRUCTURES |
|
41 |
//extern ?external_data; |
|
42 |
||
43 |
// EXTERNAL FUNCTION PROTOTYPES |
|
44 |
//extern ?external_function( ?arg_type,?arg_type ); |
|
45 |
||
46 |
// CONSTANTS |
|
47 |
//const ?type ?constant_var = ?constant; |
|
48 |
_LIT(KLmName1, "lm1"); |
|
49 |
_LIT(KLmName2, "lma2"); |
|
50 |
_LIT(KLmName3, "lma3"); |
|
51 |
_LIT(KLmName4, "landmark1"); |
|
52 |
_LIT(KLmName5, "landmark2"); |
|
53 |
_LIT(KLmName6, "landmark3"); |
|
54 |
||
55 |
_LIT(KLmSearchString, "lm*"); |
|
56 |
_LIT(KLmSearchString1, "lma*"); |
|
57 |
||
58 |
// MACROS |
|
59 |
//#define ?macro ?macro_def |
|
60 |
#define PASS TInt(0) |
|
61 |
#define FAIL (!PASS) |
|
62 |
||
63 |
||
64 |
// ============================ MEMBER FUNCTIONS =============================== |
|
65 |
||
66 |
// ----------------------------------------------------------------------------- |
|
67 |
// CTLandmarkProvider::Delete |
|
68 |
// Delete here all resources allocated and opened from test methods. |
|
69 |
// Called from destructor. |
|
70 |
// ----------------------------------------------------------------------------- |
|
71 |
// |
|
72 |
void CTLandmarkProvider::Delete() |
|
73 |
{ |
|
74 |
||
75 |
} |
|
76 |
||
77 |
// ----------------------------------------------------------------------------- |
|
78 |
// CTLandmarkProvider::RunMethodL |
|
79 |
// Run specified method. Contains also table of test mothods and their names. |
|
80 |
// ----------------------------------------------------------------------------- |
|
81 |
// |
|
82 |
TInt CTLandmarkProvider::RunMethodL( |
|
83 |
CStifItemParser& aItem ) |
|
84 |
{ |
|
85 |
||
86 |
static TStifFunctionInfo const KFunctions[] = |
|
87 |
{ |
|
88 |
// Copy this line for every implemented function. |
|
89 |
// First string is the function name used in TestScripter script file. |
|
90 |
// Second is the actual implementation member function. |
|
91 |
ENTRY( "AddLandmark", CTLandmarkProvider::AddLandmarkL ), |
|
92 |
ENTRY( "UpdateLandmark", CTLandmarkProvider::UpdateLandmarkL ), |
|
93 |
ENTRY( "RemoveLandmark", CTLandmarkProvider::RemoveLandmarkL ), |
|
94 |
ENTRY( "ImportLandmark", CTLandmarkProvider::ImportLandmarkL ), |
|
95 |
ENTRY( "ExportLandmark", CTLandmarkProvider::ExportLandmarkL ), |
|
96 |
ENTRY("LinkCategory", CTLandmarkProvider :: LinkCategoryL ), |
|
97 |
ENTRY("UnLinkCategory", CTLandmarkProvider :: UnLinkCategoryL ), |
|
98 |
ENTRY("LandmarksAsyncTest1", CTLandmarkProvider :: LandmarksAsyncTest1L ), |
|
99 |
ENTRY("LandmarksSyncTest1", CTLandmarkProvider :: LandmarksSyncTest1L ), |
|
100 |
ENTRY( "AddLandmarkDb", CTLandmarkProvider::AddLandmarkDbL ), |
|
101 |
ENTRY( "UpdateLandmarkDb", CTLandmarkProvider::UpdateLandmarkDbL ), |
|
102 |
ENTRY( "RemoveLandmarkDb", CTLandmarkProvider::RemoveLandmarkDbL ), |
|
103 |
ENTRY( "ImportLandmarkDb", CTLandmarkProvider::ImportLandmarkDbL ), |
|
104 |
ENTRY( "ExportLandmarkDb", CTLandmarkProvider::ExportLandmarkDbL ), |
|
105 |
ENTRY("LinkCategoryDb", CTLandmarkProvider :: LinkCategoryDbL ), |
|
106 |
ENTRY("UnLinkCategoryDb", CTLandmarkProvider :: UnLinkCategoryDbL ), |
|
107 |
ENTRY("LandmarksAsyncTest1Db", CTLandmarkProvider :: LandmarksAsyncTest1DbL ), |
|
108 |
ENTRY("LandmarksSyncTest1Db", CTLandmarkProvider :: LandmarksSyncTest1DbL ), |
|
109 |
ENTRY("GetLandmarkGtk", CTLandmarkProvider :: LandmarksGtkL ), |
|
110 |
ENTRY( "AddLandmarkPos", CTLandmarkProvider::AddLandmarkPosL ), |
|
111 |
ENTRY( "UpdateLandmarkPos", CTLandmarkProvider::UpdateLandmarkPosL ), |
|
112 |
ENTRY( "RemoveLandmarkPos", CTLandmarkProvider::RemoveLandmarkPosL ), |
|
113 |
ENTRY( "ImportLandmarkPos", CTLandmarkProvider::ImportLandmarkPosL ), |
|
114 |
ENTRY( "ExportLandmarkPos", CTLandmarkProvider::ExportLandmarkPosL ), |
|
115 |
ENTRY("LinkCategoryPos", CTLandmarkProvider :: LinkCategoryPosL ), |
|
116 |
ENTRY("UnLinkCategoryPos", CTLandmarkProvider :: UnLinkCategoryPosL ), |
|
117 |
ENTRY("LandmarksAsyncTestPos1", CTLandmarkProvider :: LandmarksAsyncTestPos1L ), |
|
118 |
ENTRY("LandmarksSyncTestPos1", CTLandmarkProvider :: LandmarksSyncTestPos1L ), |
|
119 |
}; |
|
120 |
||
121 |
const TInt count = sizeof( KFunctions ) / |
|
122 |
sizeof( TStifFunctionInfo ); |
|
123 |
||
124 |
return RunInternalL( KFunctions, count, aItem ); |
|
125 |
||
126 |
} |
|
127 |
||
128 |
// ----------------------------------------------------------------------------- |
|
129 |
// CTLandmarkProvider::ExampleL |
|
130 |
// Example test method function. |
|
131 |
// (other items were commented in a header). |
|
132 |
// ----------------------------------------------------------------------------- |
|
133 |
// |
|
134 |
TInt CTLandmarkProvider::ExampleL( CStifItemParser& aItem ) |
|
135 |
{ |
|
136 |
||
137 |
// Print to UI |
|
138 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
139 |
_LIT( KExample, "In Example" ); |
|
140 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
141 |
// Print to log file |
|
142 |
iLog->Log( KExample ); |
|
143 |
||
144 |
TInt i = 0; |
|
145 |
TPtrC string; |
|
146 |
_LIT( KParam, "Param[%i]: %S" ); |
|
147 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
148 |
{ |
|
149 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
150 |
KParam, i, &string ); |
|
151 |
i++; |
|
152 |
} |
|
153 |
||
154 |
return KErrNone; |
|
155 |
} |
|
156 |
||
157 |
// ----------------------------------------------------------------------------- |
|
158 |
// CTLandmarkProvider::AddLandmarkL |
|
159 |
// Example test method function. |
|
160 |
// (other items were commented in a header). |
|
161 |
// ----------------------------------------------------------------------------- |
|
162 |
// |
|
163 |
TInt CTLandmarkProvider::AddLandmarkL( CStifItemParser& aItem ) |
|
164 |
{ |
|
165 |
// Print to UI |
|
166 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
167 |
_LIT( KExample, "In AddLandmarkL" ); |
|
168 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
169 |
// Print to log file |
|
170 |
iLog->Log( KExample ); |
|
171 |
||
172 |
__UHEAP_MARK; |
|
173 |
||
174 |
CLiwServiceHandler* ServiceHandler; |
|
175 |
CLiwGenericParamList* inps,*outps; |
|
176 |
MLiwInterface* iIflandmarks; |
|
177 |
||
178 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
179 |
CleanupStack::PushL(ServiceHandler); |
|
180 |
CleanupClosePushL(*iIflandmarks); |
|
181 |
||
182 |
inps = &(ServiceHandler->InParamListL()); |
|
183 |
outps = &(ServiceHandler->OutParamListL()); |
|
184 |
||
185 |
inps->Reset(); |
|
186 |
outps->Reset(); |
|
187 |
||
188 |
TInt i = 0; |
|
189 |
TPtrC string; |
|
190 |
_LIT( KParam, "Param[%i]: %S" ); |
|
191 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
192 |
{ |
|
193 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
194 |
KParam, i, &string ); |
|
195 |
i++; |
|
196 |
} |
|
197 |
||
198 |
TLiwGenericParam param; |
|
199 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
200 |
inps->AppendL(param); |
|
201 |
param.Reset(); |
|
202 |
||
203 |
_LIT(KName,"Mainland China"); |
|
204 |
_LIT(KDescription,"Extremely good chinese food"); |
|
205 |
_LIT(KPhone1,"123456"); |
|
206 |
_LIT(KOffice1,"eat"); |
|
207 |
_LIT(KOffice2,"sleep"); |
|
208 |
_LIT(KOffice3,"drink"); |
|
209 |
TReal64 latitude = 45.1122; |
|
210 |
TReal64 longitude = 34.0099; |
|
211 |
TReal32 altitude = 41.0022; |
|
212 |
TReal32 hacc = 0.1234; |
|
213 |
TReal32 vacc = 0.3456; |
|
214 |
TPosition locale; |
|
215 |
locale.SetCurrentTime(); |
|
216 |
||
217 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
218 |
//uncomment after LIW changes |
|
219 |
CleanupClosePushL(*landmarkMap); |
|
220 |
inps->AppendL(TLiwGenericParam(KDataFields,TLiwVariant(landmarkMap))); |
|
221 |
iIflandmarks->ExecuteCmdL(KAdd,*inps,*outps,0,0); |
|
222 |
||
223 |
CleanupStack::PopAndDestroy(landmarkMap); |
|
224 |
||
225 |
TInt index1 = 0; |
|
226 |
TInt32 err1 = -1; |
|
227 |
const TLiwGenericParam* outParam1 = outps->FindFirst(index1,KErrorCode); |
|
228 |
if( outParam1 ) |
|
229 |
{ |
|
230 |
outParam1->Value().Get(err1); |
|
231 |
} |
|
232 |
inps->Reset(); |
|
233 |
outps->Reset(); |
|
234 |
||
235 |
landmarkMap = CLiwDefaultMap::NewL(); |
|
236 |
||
237 |
//name |
|
238 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KName)); |
|
239 |
//position |
|
240 |
CLiwMap* position = CLiwDefaultMap::NewL(); |
|
241 |
||
242 |
position->InsertL(KLatitude,TLiwVariant(latitude)); |
|
243 |
position->InsertL(KLongitude,TLiwVariant(longitude)); |
|
244 |
position->InsertL(KAltitude,TLiwVariant(altitude)); |
|
245 |
position->InsertL(KHAccuracy,TLiwVariant(hacc)); |
|
246 |
position->InsertL(KVAccuracy,TLiwVariant(vacc)); |
|
247 |
position->InsertL(KTStamp,TLiwVariant(locale.Time())); |
|
248 |
landmarkMap->InsertL(KLandmarkPosition,TLiwVariant(position)); |
|
249 |
||
250 |
position->DecRef(); |
|
251 |
//coverage radius |
|
252 |
TReal32 covRad = 12.3456; |
|
253 |
landmarkMap->InsertL(KCoverageRadius,TLiwVariant(covRad)); |
|
254 |
//categoryInfo |
|
255 |
CLiwList* catList = CLiwDefaultList::NewL(); |
|
256 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase ::OpenL(KTestDbUri1); |
|
257 |
CleanupStack::PushL(db); |
|
258 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
259 |
CPosLmCategoryManager* catMan = CPosLmCategoryManager::NewL(*db); |
|
260 |
CleanupStack::PushL(catMan); |
|
261 |
RemoveAllCategories(catMan); |
|
262 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
263 |
TPosLmItemId catId; |
|
264 |
category->SetCategoryNameL(KOffice1); |
|
265 |
catId = catMan->AddCategoryL(*category); |
|
266 |
TBuf<5> catIdString; |
|
267 |
catIdString.Num(catId,EDecimal); |
|
268 |
||
269 |
catList->AppendL(TLiwVariant(catIdString)); |
|
270 |
category->SetCategoryNameL(KOffice2); |
|
271 |
catId = catMan->AddCategoryL(*category); |
|
272 |
TBuf<5> catIdString1; |
|
273 |
catIdString1.Num(catId,EDecimal); |
|
274 |
catList->AppendL(TLiwVariant(catIdString1)); |
|
275 |
category->SetCategoryNameL(KOffice3); |
|
276 |
catId = catMan->AddCategoryL(*category); |
|
277 |
TBuf<5> catIdString2; |
|
278 |
catIdString2.Num(catId,EDecimal); |
|
279 |
catList->AppendL(TLiwVariant(catIdString2)); |
|
280 |
CleanupStack::PopAndDestroy(3,db); |
|
281 |
landmarkMap->InsertL(KCategoryInfo,TLiwVariant(catList)); |
|
282 |
catList->DecRef(); |
|
283 |
//icon |
|
284 |
_LIT(KFileName,"//s60//icons//qgn_graf_s60_logo.svg"); |
|
285 |
landmarkMap->InsertL(KIconFile,TLiwVariant(KFileName)); |
|
286 |
landmarkMap->InsertL(KIconIndex,TLiwVariant((TInt32)17)); |
|
287 |
landmarkMap->InsertL(KIconMaskIndex,TLiwVariant((TInt32)17)); |
|
288 |
//description |
|
289 |
landmarkMap->InsertL(KLandmarkDesc,TLiwVariant(KDescription)); |
|
290 |
//lm fields |
|
291 |
CLiwMap* landmarkFields = CLiwDefaultMap::NewL(); |
|
292 |
||
293 |
landmarkFields->InsertL(KLandmarkTelephone,TLiwVariant(KPhone1)); |
|
294 |
landmarkMap->InsertL(KLandmarkFields,TLiwVariant(landmarkFields)); |
|
295 |
landmarkFields->DecRef(); |
|
296 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
297 |
inps->AppendL(param); |
|
298 |
param.Reset(); |
|
299 |
landmarkMap->DecRef(); |
|
300 |
||
301 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
302 |
inps->AppendL(param); |
|
303 |
param.Reset(); |
|
304 |
||
305 |
iIflandmarks->ExecuteCmdL(KAdd,*inps,*outps,0,0); |
|
306 |
TInt index = 0; |
|
307 |
TInt32 err = -1; |
|
308 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
309 |
//log data |
|
310 |
RFile LogResult; |
|
311 |
RFs LogResultSession; |
|
312 |
User::LeaveIfError(LogResultSession.Connect()); |
|
313 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
314 |
{ |
|
315 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
316 |
} |
|
317 |
TInt End = 0 ; |
|
318 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
319 |
if( outParam ) |
|
320 |
{ |
|
321 |
outParam->Value().Get(err); |
|
322 |
TBuf8<50> error; |
|
323 |
TRealFormat format; |
|
324 |
error.Num(err,format) ; |
|
325 |
LogResult.Write(_L8("AddLandmarkL Error=")); |
|
326 |
LogResult.Write(error); |
|
327 |
LogResult.Write(_L8("\n")); |
|
328 |
} |
|
329 |
LogResult.Close(); |
|
330 |
LogResultSession.Close(); |
|
331 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
332 |
__UHEAP_MARKEND; |
|
333 |
||
334 |
return err; |
|
335 |
||
336 |
} |
|
337 |
||
338 |
// ----------------------------------------------------------------------------- |
|
339 |
// CTLandmarkProvider::AddLandmarkPosL |
|
340 |
// Example test method function. |
|
341 |
// (other items were commented in a header). |
|
342 |
// ----------------------------------------------------------------------------- |
|
343 |
// |
|
344 |
TInt CTLandmarkProvider::AddLandmarkPosL( CStifItemParser& aItem ) |
|
345 |
{ |
|
346 |
// Print to UI |
|
347 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
348 |
_LIT( KExample, "In AddLandmarkPosL" ); |
|
349 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
350 |
// Print to log file |
|
351 |
iLog->Log( KExample ); |
|
352 |
||
353 |
__UHEAP_MARK; |
|
354 |
CLiwServiceHandler* ServiceHandler; |
|
355 |
CLiwGenericParamList* inps,*outps; |
|
356 |
MLiwInterface* iIflandmarks; |
|
357 |
||
358 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
359 |
CleanupStack::PushL(ServiceHandler); |
|
360 |
CleanupClosePushL(*iIflandmarks); |
|
361 |
||
362 |
inps = &(ServiceHandler->InParamListL()); |
|
363 |
outps = &(ServiceHandler->OutParamListL()); |
|
364 |
||
365 |
inps->Reset(); |
|
366 |
outps->Reset(); |
|
367 |
||
368 |
TInt i = 0; |
|
369 |
TPtrC string; |
|
370 |
_LIT( KParam, "Param[%i]: %S" ); |
|
371 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
372 |
{ |
|
373 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
374 |
KParam, i, &string ); |
|
375 |
i++; |
|
376 |
} |
|
377 |
||
378 |
TLiwGenericParam param; |
|
379 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
380 |
inps->AppendL(param); |
|
381 |
param.Reset(); |
|
382 |
||
383 |
TPosition locale; |
|
384 |
locale.SetCurrentTime(); |
|
385 |
||
386 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
387 |
inps->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(landmarkMap))); |
|
388 |
iIflandmarks->ExecuteCmdL(KAdd,*inps,*outps,0,0); |
|
389 |
landmarkMap->DecRef(); |
|
390 |
TInt index = 0; |
|
391 |
TInt32 err = KErrGeneral; |
|
392 |
||
393 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
394 |
//log data |
|
395 |
RFile LogResult; |
|
396 |
RFs LogResultSession; |
|
397 |
User::LeaveIfError(LogResultSession.Connect()); |
|
398 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
399 |
{ |
|
400 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
401 |
} |
|
402 |
TInt End = 0 ; |
|
403 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
404 |
if( outParam ) |
|
405 |
{ |
|
406 |
outParam->Value().Get(err); |
|
407 |
TBuf8<50> error; |
|
408 |
TRealFormat format; |
|
409 |
error.Num(err,format) ; |
|
410 |
LogResult.Write(_L8("AddLandmarPoskL Error=")); |
|
411 |
LogResult.Write(error); |
|
412 |
LogResult.Write(_L8("\n")); |
|
413 |
} |
|
414 |
LogResult.Close(); |
|
415 |
LogResultSession.Close(); |
|
416 |
||
417 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
418 |
__UHEAP_MARKEND; |
|
419 |
return err; |
|
420 |
} |
|
421 |
||
422 |
// ----------------------------------------------------------------------------- |
|
423 |
// CTLandmarkProvider::UpdateLandmarkL |
|
424 |
// Example test method function. |
|
425 |
// (other items were commented in a header). |
|
426 |
// ----------------------------------------------------------------------------- |
|
427 |
// |
|
428 |
TInt CTLandmarkProvider::UpdateLandmarkL( CStifItemParser& aItem ) |
|
429 |
{ |
|
430 |
||
431 |
// Print to UI |
|
432 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
433 |
_LIT( KExample, "In Example" ); |
|
434 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
435 |
// Print to log file |
|
436 |
iLog->Log( KExample ); |
|
437 |
||
438 |
__UHEAP_MARK; |
|
439 |
CLiwServiceHandler* ServiceHandler; |
|
440 |
CLiwGenericParamList* inps,*outps; |
|
441 |
MLiwInterface* iIflandmarks; |
|
442 |
||
443 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
444 |
CleanupStack::PushL(ServiceHandler); |
|
445 |
CleanupClosePushL(*iIflandmarks); |
|
446 |
||
447 |
inps = &(ServiceHandler->InParamListL()); |
|
448 |
outps = &(ServiceHandler->OutParamListL()); |
|
449 |
||
450 |
inps->Reset(); |
|
451 |
outps->Reset(); |
|
452 |
||
453 |
TInt i = 0; |
|
454 |
TPtrC string; |
|
455 |
_LIT( KParam, "Param[%i]: %S" ); |
|
456 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
457 |
{ |
|
458 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
459 |
KParam, i, &string ); |
|
460 |
i++; |
|
461 |
} |
|
462 |
/*Preconditions*/ |
|
463 |
_LIT(KName,"3QC"); |
|
464 |
_LIT(KName1,"Mainland China"); |
|
465 |
||
466 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
467 |
CleanupStack::PushL(db); |
|
468 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
469 |
RemoveAllLandmarks(db); |
|
470 |
||
471 |
TPosLmItemId lmId; |
|
472 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
473 |
lm->SetLandmarkNameL(KName1); |
|
474 |
lmId = db->AddLandmarkL(*lm); |
|
475 |
||
476 |
lm = db->ReadLandmarkLC(lmId); |
|
477 |
||
478 |
TLiwGenericParam param; |
|
479 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
480 |
inps->AppendL(param); |
|
481 |
param.Reset(); |
|
482 |
||
483 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
484 |
TBuf<5> lmIdString; |
|
485 |
lmIdString.Num(lm->LandmarkId(),EDecimal); |
|
486 |
landmarkMap->InsertL(KId,TLiwVariant(lmIdString)); |
|
487 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KName)); |
|
488 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
489 |
inps->AppendL(param); |
|
490 |
landmarkMap->DecRef(); |
|
491 |
param.Reset(); |
|
492 |
||
493 |
iIflandmarks->ExecuteCmdL(KAdd,*inps,*outps,0,0); |
|
494 |
TInt index = 0; |
|
495 |
TInt32 err = -1; |
|
496 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
497 |
//log data |
|
498 |
RFile LogResult; |
|
499 |
RFs LogResultSession; |
|
500 |
User::LeaveIfError(LogResultSession.Connect()); |
|
501 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
502 |
{ |
|
503 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
504 |
} |
|
505 |
TInt End = 0 ; |
|
506 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
507 |
if( outParam ) |
|
508 |
{ |
|
509 |
outParam->Value().Get(err); |
|
510 |
TBuf8<50> error; |
|
511 |
TRealFormat format; |
|
512 |
error.Num(err,format) ; |
|
513 |
LogResult.Write(_L8("UpdateLandmarkL Error=")); |
|
514 |
LogResult.Write(error); |
|
515 |
LogResult.Write(_L8("\n")); |
|
516 |
} |
|
517 |
LogResult.Close(); |
|
518 |
LogResultSession.Close(); |
|
519 |
||
520 |
||
521 |
CleanupStack::PopAndDestroy(lm); |
|
522 |
||
523 |
CleanupStack::PopAndDestroy(2,db); |
|
524 |
||
525 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
526 |
ReleaseLandmarkResources(); |
|
527 |
||
528 |
__UHEAP_MARKEND; |
|
529 |
||
530 |
return err; |
|
531 |
} |
|
532 |
||
533 |
// ----------------------------------------------------------------------------- |
|
534 |
// CTLandmarkProvider::UpdateLandmarkPosL |
|
535 |
// Example test method function. |
|
536 |
// (other items were commented in a header). |
|
537 |
// ----------------------------------------------------------------------------- |
|
538 |
// |
|
539 |
TInt CTLandmarkProvider::UpdateLandmarkPosL( CStifItemParser& aItem ) |
|
540 |
{ |
|
541 |
||
542 |
// Print to UI |
|
543 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
544 |
_LIT( KExample, "In UpdateLandmarkPosL" ); |
|
545 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
546 |
// Print to log file |
|
547 |
iLog->Log( KExample ); |
|
548 |
||
549 |
__UHEAP_MARK; |
|
550 |
CLiwServiceHandler* ServiceHandler; |
|
551 |
CLiwGenericParamList* inps,*outps; |
|
552 |
MLiwInterface* iIflandmarks; |
|
553 |
||
554 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
555 |
CleanupStack::PushL(ServiceHandler); |
|
556 |
CleanupClosePushL(*iIflandmarks); |
|
557 |
||
558 |
inps = &(ServiceHandler->InParamListL()); |
|
559 |
outps = &(ServiceHandler->OutParamListL()); |
|
560 |
||
561 |
inps->Reset(); |
|
562 |
outps->Reset(); |
|
563 |
||
564 |
TInt i = 0; |
|
565 |
TPtrC string; |
|
566 |
_LIT( KParam, "Param[%i]: %S" ); |
|
567 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
568 |
{ |
|
569 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
570 |
KParam, i, &string ); |
|
571 |
i++; |
|
572 |
} |
|
573 |
/*Preconditions*/ |
|
574 |
_LIT(KName,"3QC"); |
|
575 |
_LIT(KName1,"Mainland China"); |
|
576 |
||
577 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
578 |
CleanupStack::PushL(db); |
|
579 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
580 |
RemoveAllLandmarks(db); |
|
581 |
||
582 |
TPosLmItemId lmId; |
|
583 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
584 |
lm->SetLandmarkNameL(KName1); |
|
585 |
lmId = db->AddLandmarkL(*lm); |
|
586 |
||
587 |
lm = db->ReadLandmarkLC(lmId); |
|
588 |
||
589 |
TLiwGenericParam param; |
|
590 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
591 |
inps->AppendL(param); |
|
592 |
param.Reset(); |
|
593 |
||
594 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
595 |
TBuf<5> lmIdString; |
|
596 |
lmIdString.Num(lm->LandmarkId(),EDecimal); |
|
597 |
landmarkMap->InsertL(KId,TLiwVariant(lmIdString)); |
|
598 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KName)); |
|
599 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(landmarkMap)); |
|
600 |
inps->AppendL(param); |
|
601 |
landmarkMap->DecRef(); |
|
602 |
param.Reset(); |
|
603 |
||
604 |
iIflandmarks->ExecuteCmdL(KAdd,*inps,*outps,0,0); |
|
605 |
TInt index = 0; |
|
606 |
TInt32 err = -1; |
|
607 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
608 |
//log data |
|
609 |
RFile LogResult; |
|
610 |
RFs LogResultSession; |
|
611 |
User::LeaveIfError(LogResultSession.Connect()); |
|
612 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
613 |
{ |
|
614 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
615 |
} |
|
616 |
TInt End = 0 ; |
|
617 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
618 |
if( outParam ) |
|
619 |
{ |
|
620 |
outParam->Value().Get(err); |
|
621 |
TBuf8<50> error; |
|
622 |
TRealFormat format; |
|
623 |
error.Num(err,format) ; |
|
624 |
LogResult.Write(_L8("UpdateLandmarkL Error=")); |
|
625 |
LogResult.Write(error); |
|
626 |
LogResult.Write(_L8("\n")); |
|
627 |
} |
|
628 |
LogResult.Close(); |
|
629 |
LogResultSession.Close(); |
|
630 |
||
631 |
||
632 |
CleanupStack::PopAndDestroy(lm); |
|
633 |
||
634 |
CleanupStack::PopAndDestroy(2,db); |
|
635 |
ReleaseLandmarkResources(); |
|
636 |
||
637 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
638 |
ReleaseLandmarkResources(); |
|
639 |
__UHEAP_MARKEND; |
|
640 |
||
641 |
return err; |
|
642 |
} |
|
643 |
||
644 |
// ----------------------------------------------------------------------------- |
|
645 |
// CTLandmarkProvider::RemoveLandmarkL |
|
646 |
// Example test method function. |
|
647 |
// (other items were commented in a header). |
|
648 |
// ----------------------------------------------------------------------------- |
|
649 |
// |
|
650 |
TInt CTLandmarkProvider::RemoveLandmarkL( CStifItemParser& aItem ) |
|
651 |
{ |
|
652 |
||
653 |
// Print to UI |
|
654 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
655 |
_LIT( KExample, "In Example" ); |
|
656 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
657 |
// Print to log file |
|
658 |
iLog->Log( KExample ); |
|
659 |
||
660 |
__UHEAP_MARK; |
|
661 |
CLiwServiceHandler* ServiceHandler; |
|
662 |
CLiwGenericParamList* inps,*outps; |
|
663 |
MLiwInterface* iIflandmarks; |
|
664 |
||
665 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
666 |
CleanupStack::PushL(ServiceHandler); |
|
667 |
CleanupClosePushL(*iIflandmarks); |
|
668 |
||
669 |
inps = &(ServiceHandler->InParamListL()); |
|
670 |
outps = &(ServiceHandler->OutParamListL()); |
|
671 |
||
672 |
inps->Reset(); |
|
673 |
outps->Reset(); |
|
674 |
||
675 |
TInt i = 0; |
|
676 |
TPtrC string; |
|
677 |
_LIT( KParam, "Param[%i]: %S" ); |
|
678 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
679 |
{ |
|
680 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
681 |
KParam, i, &string ); |
|
682 |
i++; |
|
683 |
} |
|
684 |
//preconditions |
|
685 |
_LIT(KName1,"Mainland China"); |
|
686 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
687 |
CleanupStack::PushL(db); |
|
688 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
689 |
RemoveAllLandmarks(db); |
|
690 |
||
691 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
692 |
lm->SetLandmarkNameL(KName1); |
|
693 |
db->AddLandmarkL(*lm); |
|
694 |
||
695 |
TLiwGenericParam param; |
|
696 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
697 |
inps->AppendL(param); |
|
698 |
param.Reset(); |
|
699 |
||
700 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
701 |
//landmarkMap->InsertL(KId,TLiwVariant((TInt32)lm->LandmarkId())); |
|
702 |
TBuf<5> lmIdString; |
|
703 |
lmIdString.Num(lm->LandmarkId(),EDecimal); |
|
704 |
landmarkMap->InsertL(KId,TLiwVariant(lmIdString)); |
|
705 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
706 |
inps->AppendL(param); |
|
707 |
landmarkMap->DecRef(); |
|
708 |
param.Reset(); |
|
709 |
||
710 |
iIflandmarks->ExecuteCmdL(KRemove,*inps,*outps,0,0); |
|
711 |
TInt index = 0; |
|
712 |
TInt32 err = -1; |
|
713 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
714 |
//log data |
|
715 |
RFile LogResult; |
|
716 |
RFs LogResultSession; |
|
717 |
User::LeaveIfError(LogResultSession.Connect()); |
|
718 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
719 |
{ |
|
720 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
721 |
} |
|
722 |
TInt End = 0 ; |
|
723 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
724 |
if( outParam ) |
|
725 |
{ |
|
726 |
outParam->Value().Get(err); |
|
727 |
TBuf8<50> error; |
|
728 |
TRealFormat format; |
|
729 |
error.Num(err,format) ; |
|
730 |
LogResult.Write(_L8("RemoveLandmarkL Error=")); |
|
731 |
LogResult.Write(error); |
|
732 |
LogResult.Write(_L8("\n")); |
|
733 |
} |
|
734 |
LogResult.Close(); |
|
735 |
LogResultSession.Close(); |
|
736 |
||
737 |
||
738 |
||
739 |
CleanupStack::PopAndDestroy(2,db); |
|
740 |
ReleaseLandmarkResources(); |
|
741 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
742 |
ReleaseLandmarkResources(); |
|
743 |
__UHEAP_MARKEND; |
|
744 |
return err; |
|
745 |
||
746 |
} |
|
747 |
||
748 |
// ----------------------------------------------------------------------------- |
|
749 |
// CTLandmarkProvider::RemoveLandmarkPosL |
|
750 |
// Example test method function. |
|
751 |
// (other items were commented in a header). |
|
752 |
// ----------------------------------------------------------------------------- |
|
753 |
// |
|
754 |
TInt CTLandmarkProvider::RemoveLandmarkPosL( CStifItemParser& aItem ) |
|
755 |
{ |
|
756 |
||
757 |
// Print to UI |
|
758 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
759 |
_LIT( KExample, "In RemoveLandmarkPosL" ); |
|
760 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
761 |
// Print to log file |
|
762 |
iLog->Log( KExample ); |
|
763 |
||
764 |
__UHEAP_MARK; |
|
765 |
CLiwServiceHandler* ServiceHandler; |
|
766 |
CLiwGenericParamList* inps,*outps; |
|
767 |
MLiwInterface* iIflandmarks; |
|
768 |
||
769 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
770 |
CleanupStack::PushL(ServiceHandler); |
|
771 |
CleanupClosePushL(*iIflandmarks); |
|
772 |
||
773 |
inps = &(ServiceHandler->InParamListL()); |
|
774 |
outps = &(ServiceHandler->OutParamListL()); |
|
775 |
||
776 |
inps->Reset(); |
|
777 |
outps->Reset(); |
|
778 |
TInt i = 0; |
|
779 |
TPtrC string; |
|
780 |
_LIT( KParam, "Param[%i]: %S" ); |
|
781 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
782 |
{ |
|
783 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
784 |
KParam, i, &string ); |
|
785 |
i++; |
|
786 |
} |
|
787 |
//preconditions |
|
788 |
_LIT(KName1,"Mainland China"); |
|
789 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
790 |
CleanupStack::PushL(db); |
|
791 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
792 |
RemoveAllLandmarks(db); |
|
793 |
||
794 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
795 |
lm->SetLandmarkNameL(KName1); |
|
796 |
db->AddLandmarkL(*lm); |
|
797 |
||
798 |
TLiwGenericParam param; |
|
799 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
800 |
inps->AppendL(param); |
|
801 |
param.Reset(); |
|
802 |
||
803 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
804 |
// landmarkMap->InsertL(KId,TLiwVariant((TInt32)lm->LandmarkId())); |
|
805 |
TBuf<5> lmIdString; |
|
806 |
lmIdString.Num(lm->LandmarkId(),EDecimal); |
|
807 |
landmarkMap->InsertL(KId,TLiwVariant(lmIdString)); |
|
808 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(landmarkMap)); |
|
809 |
inps->AppendL(param); |
|
810 |
landmarkMap->DecRef(); |
|
811 |
param.Reset(); |
|
812 |
||
813 |
iIflandmarks->ExecuteCmdL(KRemove,*inps,*outps,0,0); |
|
814 |
TInt index = 0; |
|
815 |
TInt32 err = -1; |
|
816 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
817 |
//log data |
|
818 |
RFile LogResult; |
|
819 |
RFs LogResultSession; |
|
820 |
User::LeaveIfError(LogResultSession.Connect()); |
|
821 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
822 |
{ |
|
823 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
824 |
} |
|
825 |
TInt End = 0 ; |
|
826 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
827 |
if( outParam ) |
|
828 |
{ |
|
829 |
outParam->Value().Get(err); |
|
830 |
TBuf8<50> error; |
|
831 |
TRealFormat format; |
|
832 |
error.Num(err,format) ; |
|
833 |
LogResult.Write(_L8("RemoveLandmarkL Error=")); |
|
834 |
LogResult.Write(error); |
|
835 |
LogResult.Write(_L8("\n")); |
|
836 |
} |
|
837 |
LogResult.Close(); |
|
838 |
LogResultSession.Close(); |
|
839 |
||
840 |
||
841 |
CleanupStack::PopAndDestroy(2,db); |
|
842 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
843 |
ReleaseLandmarkResources(); |
|
844 |
||
845 |
__UHEAP_MARKEND; |
|
846 |
return err; |
|
847 |
||
848 |
} |
|
849 |
||
850 |
// ----------------------------------------------------------------------------- |
|
851 |
// CTLandmarkProvider::ImportLandmarkL |
|
852 |
// Example test method function. |
|
853 |
// (other items were commented in a header). |
|
854 |
// ----------------------------------------------------------------------------- |
|
855 |
// |
|
856 |
TInt CTLandmarkProvider::ImportLandmarkL( CStifItemParser& aItem ) |
|
857 |
{ |
|
858 |
||
859 |
// Print to UI |
|
860 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
861 |
_LIT( KExample, "In Example" ); |
|
862 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
863 |
// Print to log file |
|
864 |
iLog->Log( KExample ); |
|
865 |
||
866 |
__UHEAP_MARK; |
|
867 |
CLiwServiceHandler* ServiceHandler; |
|
868 |
CLiwGenericParamList* inps,*outps; |
|
869 |
MLiwInterface* iIflandmarks; |
|
870 |
||
871 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
872 |
CleanupStack::PushL(ServiceHandler); |
|
873 |
CleanupClosePushL(*iIflandmarks); |
|
874 |
||
875 |
inps = &(ServiceHandler->InParamListL()); |
|
876 |
outps = &(ServiceHandler->OutParamListL()); |
|
877 |
||
878 |
inps->Reset(); |
|
879 |
outps->Reset(); |
|
880 |
||
881 |
TInt i = 0; |
|
882 |
TPtrC string; |
|
883 |
_LIT( KParam, "Param[%i]: %S" ); |
|
884 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
885 |
{ |
|
886 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
887 |
KParam, i, &string ); |
|
888 |
i++; |
|
889 |
} |
|
890 |
//preconditions |
|
891 |
_LIT(KFilePath, "c:\\eposLm.lmx"); |
|
892 |
_LIT8(KPosMimeType, "application/vnd.nokia.landmarkcollection+xml"); |
|
893 |
_LIT(KPosMimeType1, "application/vnd.nokia.landmarkcollection+xml"); |
|
894 |
_LIT(KName1,"Mainland China"); |
|
895 |
_LIT(KName2,"Chung Wah"); |
|
896 |
_LIT(KName3,"Aromas of China"); |
|
897 |
||
898 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
899 |
CleanupStack::PushL(db); |
|
900 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
901 |
RemoveAllLandmarks(db); |
|
902 |
||
903 |
TPosLmItemId lmId; |
|
904 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
905 |
lm->SetLandmarkNameL(KName1); |
|
906 |
db->AddLandmarkL(*lm); |
|
907 |
lm->SetLandmarkNameL(KName2); |
|
908 |
db->AddLandmarkL(*lm); |
|
909 |
lm->SetLandmarkNameL(KName3); |
|
910 |
db->AddLandmarkL(*lm); |
|
911 |
||
912 |
CPosLmItemIterator* iterLm = db->LandmarkIteratorL(); |
|
913 |
CleanupStack::PushL(iterLm); |
|
914 |
||
915 |
CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KPosMimeType); |
|
916 |
CleanupStack::PushL(encoder); |
|
917 |
TRAPD(err,encoder->SetOutputFileL(KFilePath)); |
|
918 |
if(KErrAlreadyExists == err) |
|
919 |
{ |
|
920 |
RFs fs; |
|
921 |
CleanupClosePushL(fs); |
|
922 |
User::LeaveIfError(fs.Connect()); |
|
923 |
fs.Delete(KFilePath); |
|
924 |
encoder->SetOutputFileL(KFilePath); |
|
925 |
CleanupStack::PopAndDestroy(); |
|
926 |
} |
|
927 |
||
928 |
RArray<TPosLmItemId> landmarks; |
|
929 |
CleanupClosePushL(landmarks); |
|
930 |
||
931 |
||
932 |
while ((lmId = iterLm->NextL()) != KPosLmNullItemId) |
|
933 |
{ |
|
934 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
935 |
} |
|
936 |
||
937 |
ExecuteAndDeleteLD(db->ExportLandmarksL(*encoder,landmarks,CPosLandmarkDatabase::EIncludeCategories)); |
|
938 |
ExecuteAndDeleteLD(encoder->FinalizeEncodingL()); |
|
939 |
CleanupStack::PopAndDestroy(5,db); |
|
940 |
ReleaseLandmarkResources(); |
|
941 |
||
942 |
inps->AppendL(TLiwGenericParam(KContentType,TLiwVariant(KLandmark))); |
|
943 |
||
944 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
945 |
landmarkMap->InsertL(KSourceFile,TLiwVariant(KFilePath)); |
|
946 |
landmarkMap->InsertL(KMimeType,TLiwVariant(KPosMimeType1)); |
|
947 |
inps->AppendL(TLiwGenericParam(KDataFields,TLiwVariant(landmarkMap))); |
|
948 |
landmarkMap->DecRef(); |
|
949 |
iIflandmarks->ExecuteCmdL(KImport,*inps,*outps,0,0); |
|
950 |
TInt index = 0; |
|
951 |
TInt32 err2 = -1; |
|
952 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
953 |
//log data |
|
954 |
RFile LogResult; |
|
955 |
RFs LogResultSession; |
|
956 |
User::LeaveIfError(LogResultSession.Connect()); |
|
957 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
958 |
{ |
|
959 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
960 |
} |
|
961 |
TInt End = 0 ; |
|
962 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
963 |
if( outParam ) |
|
964 |
{ |
|
965 |
outParam->Value().Get(err2); |
|
966 |
TBuf8<50> error; |
|
967 |
TRealFormat format; |
|
968 |
error.Num(err2,format) ; |
|
969 |
LogResult.Write(_L8("ImportLandmarkL Error=")); |
|
970 |
LogResult.Write(error); |
|
971 |
LogResult.Write(_L8("\n")); |
|
972 |
index = 0; |
|
973 |
outParam = outps->FindFirst(index,KReturnValue); |
|
974 |
if( outParam ) |
|
975 |
{ |
|
976 |
CLiwIterable* iterable = outParam->Value().AsIterable(); |
|
977 |
if( iterable ) |
|
978 |
{ |
|
979 |
TLiwVariant lmVariant; |
|
980 |
while( iterable->NextL(lmVariant) ) |
|
981 |
{ |
|
982 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
983 |
TLiwVariant variantField; |
|
984 |
TPtrC landmarkName; |
|
985 |
if( landmark ) |
|
986 |
{ |
|
987 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
988 |
{ |
|
989 |
variantField.Get(landmarkName); |
|
990 |
LogResult.Write(_L8("in iter")); |
|
991 |
LogResult.Write(_L8("\n")); |
|
992 |
} |
|
993 |
} |
|
994 |
variantField.Reset(); |
|
995 |
lmVariant.Reset(); |
|
996 |
} |
|
997 |
} |
|
998 |
||
999 |
} |
|
1000 |
} |
|
1001 |
||
1002 |
inps->Reset(); |
|
1003 |
outps->Reset(); |
|
1004 |
LogResult.Write(_L8("End of Import")); |
|
1005 |
LogResult.Close(); |
|
1006 |
LogResultSession.Close(); |
|
1007 |
||
1008 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1009 |
ReleaseLandmarkResources(); |
|
1010 |
__UHEAP_MARKEND; |
|
1011 |
return err2; |
|
1012 |
} |
|
1013 |
||
1014 |
// ----------------------------------------------------------------------------- |
|
1015 |
// CTLandmarkProvider::ImportLandmarkPosL |
|
1016 |
// Example test method function. |
|
1017 |
// (other items were commented in a header). |
|
1018 |
// ----------------------------------------------------------------------------- |
|
1019 |
// |
|
1020 |
TInt CTLandmarkProvider::ImportLandmarkPosL( CStifItemParser& aItem ) |
|
1021 |
{ |
|
1022 |
||
1023 |
// Print to UI |
|
1024 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
1025 |
_LIT( KExample, "In ImportLandmarkPosL" ); |
|
1026 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
1027 |
// Print to log file |
|
1028 |
iLog->Log( KExample ); |
|
1029 |
||
1030 |
__UHEAP_MARK; |
|
1031 |
CLiwServiceHandler* ServiceHandler; |
|
1032 |
CLiwGenericParamList* inps,*outps; |
|
1033 |
MLiwInterface* iIflandmarks; |
|
1034 |
||
1035 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
1036 |
CleanupStack::PushL(ServiceHandler); |
|
1037 |
CleanupClosePushL(*iIflandmarks); |
|
1038 |
||
1039 |
inps = &(ServiceHandler->InParamListL()); |
|
1040 |
outps = &(ServiceHandler->OutParamListL()); |
|
1041 |
||
1042 |
inps->Reset(); |
|
1043 |
outps->Reset(); |
|
1044 |
||
1045 |
TInt i = 0; |
|
1046 |
TPtrC string; |
|
1047 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1048 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1049 |
{ |
|
1050 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
1051 |
KParam, i, &string ); |
|
1052 |
i++; |
|
1053 |
} |
|
1054 |
//preconditions |
|
1055 |
_LIT(KFilePath, "c:\\eposLm.lmx"); |
|
1056 |
_LIT8(KPosMimeType, "application/vnd.nokia.landmarkcollection+xml"); |
|
1057 |
_LIT(KPosMimeType1, "application/vnd.nokia.landmarkcollection+xml"); |
|
1058 |
_LIT(KName1,"Mainland China"); |
|
1059 |
_LIT(KName2,"Chung Wah"); |
|
1060 |
_LIT(KName3,"Aromas of China"); |
|
1061 |
||
1062 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
1063 |
CleanupStack::PushL(db); |
|
1064 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1065 |
RemoveAllLandmarks(db); |
|
1066 |
||
1067 |
TPosLmItemId lmId; |
|
1068 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
1069 |
lm->SetLandmarkNameL(KName1); |
|
1070 |
db->AddLandmarkL(*lm); |
|
1071 |
lm->SetLandmarkNameL(KName2); |
|
1072 |
db->AddLandmarkL(*lm); |
|
1073 |
lm->SetLandmarkNameL(KName3); |
|
1074 |
db->AddLandmarkL(*lm); |
|
1075 |
||
1076 |
CPosLmItemIterator* iterLm = db->LandmarkIteratorL(); |
|
1077 |
CleanupStack::PushL(iterLm); |
|
1078 |
||
1079 |
CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KPosMimeType); |
|
1080 |
CleanupStack::PushL(encoder); |
|
1081 |
TRAPD(err,encoder->SetOutputFileL(KFilePath)); |
|
1082 |
if(KErrAlreadyExists == err) |
|
1083 |
{ |
|
1084 |
RFs fs; |
|
1085 |
CleanupClosePushL(fs); |
|
1086 |
User::LeaveIfError(fs.Connect()); |
|
1087 |
fs.Delete(KFilePath); |
|
1088 |
encoder->SetOutputFileL(KFilePath); |
|
1089 |
CleanupStack::PopAndDestroy(); |
|
1090 |
} |
|
1091 |
||
1092 |
RArray<TPosLmItemId> landmarks; |
|
1093 |
CleanupClosePushL(landmarks); |
|
1094 |
||
1095 |
||
1096 |
while ((lmId = iterLm->NextL()) != KPosLmNullItemId) |
|
1097 |
{ |
|
1098 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
1099 |
} |
|
1100 |
||
1101 |
ExecuteAndDeleteLD(db->ExportLandmarksL(*encoder,landmarks,CPosLandmarkDatabase::EIncludeCategories)); |
|
1102 |
ExecuteAndDeleteLD(encoder->FinalizeEncodingL()); |
|
1103 |
CleanupStack::PopAndDestroy(5,db); |
|
1104 |
ReleaseLandmarkResources(); |
|
1105 |
||
1106 |
inps->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(KLandmark))); |
|
1107 |
||
1108 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
1109 |
landmarkMap->InsertL(KSourceFile,TLiwVariant(KFilePath)); |
|
1110 |
landmarkMap->InsertL(KMimeType,TLiwVariant(KPosMimeType1)); |
|
1111 |
inps->AppendL(TLiwGenericParam(KNullDesC8,TLiwVariant(landmarkMap))); |
|
1112 |
landmarkMap->DecRef(); |
|
1113 |
iIflandmarks->ExecuteCmdL(KImport,*inps,*outps,0,0); |
|
1114 |
TInt index = 0; |
|
1115 |
TInt32 err2 = -1; |
|
1116 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
1117 |
//log data |
|
1118 |
RFile LogResult; |
|
1119 |
RFs LogResultSession; |
|
1120 |
User::LeaveIfError(LogResultSession.Connect()); |
|
1121 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
1122 |
{ |
|
1123 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
1124 |
} |
|
1125 |
TInt End = 0 ; |
|
1126 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
1127 |
if( outParam ) |
|
1128 |
{ |
|
1129 |
outParam->Value().Get(err2); |
|
1130 |
TBuf8<50> error; |
|
1131 |
TRealFormat format; |
|
1132 |
error.Num(err2,format) ; |
|
1133 |
LogResult.Write(_L8("ImportLandmarkL Error=")); |
|
1134 |
LogResult.Write(error); |
|
1135 |
LogResult.Write(_L8("\n")); |
|
1136 |
index = 0; |
|
1137 |
outParam = outps->FindFirst(index,KReturnValue); |
|
1138 |
if( outParam ) |
|
1139 |
{ |
|
1140 |
CLiwIterable* iterable = outParam->Value().AsIterable(); |
|
1141 |
if( iterable ) |
|
1142 |
{ |
|
1143 |
TLiwVariant lmVariant; |
|
1144 |
while( iterable->NextL(lmVariant) ) |
|
1145 |
{ |
|
1146 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
1147 |
TLiwVariant variantField; |
|
1148 |
TPtrC landmarkName; |
|
1149 |
if( landmark ) |
|
1150 |
{ |
|
1151 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
1152 |
{ |
|
1153 |
variantField.Get(landmarkName); |
|
1154 |
LogResult.Write(_L8("in iter")); |
|
1155 |
LogResult.Write(_L8("\n")); |
|
1156 |
} |
|
1157 |
} |
|
1158 |
variantField.Reset(); |
|
1159 |
lmVariant.Reset(); |
|
1160 |
} |
|
1161 |
} |
|
1162 |
||
1163 |
} |
|
1164 |
} |
|
1165 |
||
1166 |
||
1167 |
inps->Reset(); |
|
1168 |
outps->Reset(); |
|
1169 |
LogResult.Write(_L8("End of Import")); |
|
1170 |
LogResult.Close(); |
|
1171 |
LogResultSession.Close(); |
|
1172 |
||
1173 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1174 |
ReleaseLandmarkResources(); |
|
1175 |
||
1176 |
__UHEAP_MARKEND; |
|
1177 |
return err2; |
|
1178 |
} |
|
1179 |
||
1180 |
// ----------------------------------------------------------------------------- |
|
1181 |
// CTLandmarkProvider::ExportLandmarkL |
|
1182 |
// Example test method function. |
|
1183 |
// (other items were commented in a header). |
|
1184 |
// ----------------------------------------------------------------------------- |
|
1185 |
// |
|
1186 |
TInt CTLandmarkProvider::ExportLandmarkL( CStifItemParser& aItem ) |
|
1187 |
{ |
|
1188 |
||
1189 |
// Print to UI |
|
1190 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
1191 |
_LIT( KExample, "In Example" ); |
|
1192 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
1193 |
// Print to log file |
|
1194 |
iLog->Log( KExample ); |
|
1195 |
||
1196 |
__UHEAP_MARK; |
|
1197 |
CLiwServiceHandler* ServiceHandler; |
|
1198 |
CLiwGenericParamList* inps,*outps; |
|
1199 |
MLiwInterface* iIflandmarks; |
|
1200 |
||
1201 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
1202 |
CleanupStack::PushL(ServiceHandler); |
|
1203 |
CleanupClosePushL(*iIflandmarks); |
|
1204 |
||
1205 |
inps = &(ServiceHandler->InParamListL()); |
|
1206 |
outps = &(ServiceHandler->OutParamListL()); |
|
1207 |
||
1208 |
inps->Reset(); |
|
1209 |
outps->Reset(); |
|
1210 |
||
1211 |
TInt i = 0; |
|
1212 |
TPtrC string; |
|
1213 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1214 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1215 |
{ |
|
1216 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
1217 |
KParam, i, &string ); |
|
1218 |
i++; |
|
1219 |
} |
|
1220 |
//preconditions |
|
1221 |
_LIT(KFilePath, "c:\\eposLmTest.lmx"); |
|
1222 |
_LIT(KPosMimeType, "application/vnd.nokia.landmarkcollection+xml"); |
|
1223 |
_LIT(KName1,"Mainland China"); |
|
1224 |
_LIT(KName2,"Chung Wah"); |
|
1225 |
_LIT(KName3,"Aromas of China"); |
|
1226 |
||
1227 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
1228 |
CleanupStack::PushL(db); |
|
1229 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1230 |
RemoveAllLandmarks(db); |
|
1231 |
||
1232 |
TPosLmItemId lmId; |
|
1233 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
1234 |
lm->SetLandmarkNameL(KName1); |
|
1235 |
db->AddLandmarkL(*lm); |
|
1236 |
lm->SetLandmarkNameL(KName2); |
|
1237 |
db->AddLandmarkL(*lm); |
|
1238 |
lm->SetLandmarkNameL(KName3); |
|
1239 |
db->AddLandmarkL(*lm); |
|
1240 |
||
1241 |
CPosLmItemIterator* iterLm = db->LandmarkIteratorL(); |
|
1242 |
CleanupStack::PushL(iterLm); |
|
1243 |
||
1244 |
RFs fs; |
|
1245 |
CleanupClosePushL(fs); |
|
1246 |
User::LeaveIfError(fs.Connect()); |
|
1247 |
fs.Delete(KFilePath); |
|
1248 |
CleanupStack::PopAndDestroy(); |
|
1249 |
||
1250 |
||
1251 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
1252 |
||
1253 |
RPointerArray<HBufC> lmIdArray; |
|
1254 |
//CleanupClosePushL(lmIdArray); |
|
1255 |
while ((lmId = iterLm->NextL()) != KPosLmNullItemId) |
|
1256 |
{ |
|
1257 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1258 |
HBufC* lmIdString = HBufC::NewLC(5); |
|
1259 |
lmIdArray.AppendL(lmIdString); |
|
1260 |
CleanupStack::Pop(lmIdString); |
|
1261 |
lmIdString->Des().Num(lmId,EDecimal); |
|
1262 |
landmarkIdList->AppendL(TLiwVariant(lmIdString)); |
|
1263 |
} |
|
1264 |
||
1265 |
CleanupStack::PopAndDestroy(3,db); |
|
1266 |
ReleaseLandmarkResources(); |
|
1267 |
||
1268 |
||
1269 |
TLiwGenericParam param; |
|
1270 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
1271 |
inps->AppendL(param); |
|
1272 |
param.Reset(); |
|
1273 |
||
1274 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
1275 |
landmarkMap->InsertL(KDestinationFile,TLiwVariant(KFilePath)); |
|
1276 |
landmarkMap->InsertL(KMimeType,TLiwVariant(KPosMimeType)); |
|
1277 |
||
1278 |
landmarkMap->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
1279 |
landmarkIdList->DecRef(); |
|
1280 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
1281 |
inps->AppendL(param); |
|
1282 |
landmarkMap->DecRef(); |
|
1283 |
param.Reset(); |
|
1284 |
||
1285 |
iIflandmarks->ExecuteCmdL(KExport,*inps,*outps,0,0); |
|
1286 |
lmIdArray.ResetAndDestroy(); |
|
1287 |
lmIdArray.Close(); |
|
1288 |
TInt index = 0; |
|
1289 |
TInt32 err = -1; |
|
1290 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
1291 |
//log data |
|
1292 |
RFile LogResult; |
|
1293 |
RFs LogResultSession; |
|
1294 |
User::LeaveIfError(LogResultSession.Connect()); |
|
1295 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
1296 |
{ |
|
1297 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
1298 |
} |
|
1299 |
TInt End = 0 ; |
|
1300 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
1301 |
if( outParam ) |
|
1302 |
{ |
|
1303 |
outParam->Value().Get(err); |
|
1304 |
TBuf8<50> error; |
|
1305 |
TRealFormat format; |
|
1306 |
error.Num(err,format) ; |
|
1307 |
LogResult.Write(_L8("ExportLandmarkL Error=")); |
|
1308 |
LogResult.Write(error); |
|
1309 |
LogResult.Write(_L8("\n")); |
|
1310 |
} |
|
1311 |
||
1312 |
LogResult.Close(); |
|
1313 |
LogResultSession.Close(); |
|
1314 |
||
1315 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1316 |
ReleaseLandmarkResources(); |
|
1317 |
__UHEAP_MARKEND; |
|
1318 |
return err; |
|
1319 |
||
1320 |
} |
|
1321 |
||
1322 |
// ----------------------------------------------------------------------------- |
|
1323 |
// CTLandmarkProvider::ExportLandmarkPosL |
|
1324 |
// Example test method function. |
|
1325 |
// (other items were commented in a header). |
|
1326 |
// ----------------------------------------------------------------------------- |
|
1327 |
// |
|
1328 |
TInt CTLandmarkProvider::ExportLandmarkPosL( CStifItemParser& aItem ) |
|
1329 |
{ |
|
1330 |
||
1331 |
// Print to UI |
|
1332 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
1333 |
_LIT( KExample, "In ExportLandmarkPosL" ); |
|
1334 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
1335 |
// Print to log file |
|
1336 |
iLog->Log( KExample ); |
|
1337 |
||
1338 |
__UHEAP_MARK; |
|
1339 |
CLiwServiceHandler* ServiceHandler; |
|
1340 |
CLiwGenericParamList* inps,*outps; |
|
1341 |
MLiwInterface* iIflandmarks; |
|
1342 |
||
1343 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
1344 |
CleanupStack::PushL(ServiceHandler); |
|
1345 |
CleanupClosePushL(*iIflandmarks); |
|
1346 |
||
1347 |
inps = &(ServiceHandler->InParamListL()); |
|
1348 |
outps = &(ServiceHandler->OutParamListL()); |
|
1349 |
||
1350 |
inps->Reset(); |
|
1351 |
outps->Reset(); |
|
1352 |
TInt i = 0; |
|
1353 |
TPtrC string; |
|
1354 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1355 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1356 |
{ |
|
1357 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
1358 |
KParam, i, &string ); |
|
1359 |
i++; |
|
1360 |
} |
|
1361 |
//preconditions |
|
1362 |
_LIT(KFilePath, "c:\\eposLmTest.lmx"); |
|
1363 |
_LIT(KPosMimeType, "application/vnd.nokia.landmarkcollection+xml"); |
|
1364 |
_LIT(KName1,"Mainland China"); |
|
1365 |
_LIT(KName2,"Chung Wah"); |
|
1366 |
_LIT(KName3,"Aromas of China"); |
|
1367 |
||
1368 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
1369 |
CleanupStack::PushL(db); |
|
1370 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1371 |
RemoveAllLandmarks(db); |
|
1372 |
||
1373 |
TPosLmItemId lmId; |
|
1374 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
1375 |
lm->SetLandmarkNameL(KName1); |
|
1376 |
db->AddLandmarkL(*lm); |
|
1377 |
lm->SetLandmarkNameL(KName2); |
|
1378 |
db->AddLandmarkL(*lm); |
|
1379 |
lm->SetLandmarkNameL(KName3); |
|
1380 |
db->AddLandmarkL(*lm); |
|
1381 |
||
1382 |
CPosLmItemIterator* iterLm = db->LandmarkIteratorL(); |
|
1383 |
CleanupStack::PushL(iterLm); |
|
1384 |
||
1385 |
RFs fs; |
|
1386 |
CleanupClosePushL(fs); |
|
1387 |
User::LeaveIfError(fs.Connect()); |
|
1388 |
fs.Delete(KFilePath); |
|
1389 |
CleanupStack::PopAndDestroy(); |
|
1390 |
||
1391 |
||
1392 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
1393 |
RPointerArray<HBufC> lmIdArray; |
|
1394 |
while ((lmId = iterLm->NextL()) != KPosLmNullItemId) |
|
1395 |
{ |
|
1396 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1397 |
HBufC* lmIdString = HBufC::NewLC(5); |
|
1398 |
lmIdArray.AppendL(lmIdString); |
|
1399 |
CleanupStack::Pop(lmIdString); |
|
1400 |
lmIdString->Des().Num(lmId,EDecimal); |
|
1401 |
landmarkIdList->AppendL(TLiwVariant(lmIdString)); |
|
1402 |
} |
|
1403 |
||
1404 |
CleanupStack::PopAndDestroy(3,db); |
|
1405 |
ReleaseLandmarkResources(); |
|
1406 |
||
1407 |
||
1408 |
TLiwGenericParam param; |
|
1409 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
1410 |
inps->AppendL(param); |
|
1411 |
param.Reset(); |
|
1412 |
||
1413 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
1414 |
landmarkMap->InsertL(KDestinationFile,TLiwVariant(KFilePath)); |
|
1415 |
landmarkMap->InsertL(KMimeType,TLiwVariant(KPosMimeType)); |
|
1416 |
||
1417 |
landmarkMap->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
1418 |
landmarkIdList->DecRef(); |
|
1419 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(landmarkMap)); |
|
1420 |
inps->AppendL(param); |
|
1421 |
landmarkMap->DecRef(); |
|
1422 |
param.Reset(); |
|
1423 |
||
1424 |
iIflandmarks->ExecuteCmdL(KExport,*inps,*outps,0,0); |
|
1425 |
lmIdArray.ResetAndDestroy(); |
|
1426 |
lmIdArray.Close(); |
|
1427 |
TInt index = 0; |
|
1428 |
TInt32 err = -1; |
|
1429 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
1430 |
//log data |
|
1431 |
RFile LogResult; |
|
1432 |
RFs LogResultSession; |
|
1433 |
User::LeaveIfError(LogResultSession.Connect()); |
|
1434 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
1435 |
{ |
|
1436 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
1437 |
} |
|
1438 |
TInt End = 0 ; |
|
1439 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
1440 |
if( outParam ) |
|
1441 |
{ |
|
1442 |
outParam->Value().Get(err); |
|
1443 |
TBuf8<50> error; |
|
1444 |
TRealFormat format; |
|
1445 |
error.Num(err,format) ; |
|
1446 |
LogResult.Write(_L8("ExportLandmarkL Error=")); |
|
1447 |
LogResult.Write(error); |
|
1448 |
LogResult.Write(_L8("\n")); |
|
1449 |
} |
|
1450 |
||
1451 |
LogResult.Close(); |
|
1452 |
LogResultSession.Close(); |
|
1453 |
||
1454 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1455 |
ReleaseLandmarkResources(); |
|
1456 |
__UHEAP_MARKEND; |
|
1457 |
return err; |
|
1458 |
||
1459 |
} |
|
1460 |
||
1461 |
||
1462 |
// ----------------------------------------------------------------------------- |
|
1463 |
// CTLandmarkProvider::LinkCategoryL |
|
1464 |
// Example test method function. |
|
1465 |
// (other items were commented in a header). |
|
1466 |
// ----------------------------------------------------------------------------- |
|
1467 |
// |
|
1468 |
TInt CTLandmarkProvider::LinkCategoryL( CStifItemParser& aItem ) |
|
1469 |
{ |
|
1470 |
||
1471 |
// Print to UI |
|
1472 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
1473 |
_LIT( KExample, "In Example" ); |
|
1474 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
1475 |
// Print to log file |
|
1476 |
iLog->Log( KExample ); |
|
1477 |
||
1478 |
__UHEAP_MARK; |
|
1479 |
CLiwServiceHandler* ServiceHandler; |
|
1480 |
CLiwGenericParamList* inps,*outps; |
|
1481 |
MLiwInterface* iIflandmarks; |
|
1482 |
||
1483 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
1484 |
CleanupStack::PushL(ServiceHandler); |
|
1485 |
CleanupClosePushL(*iIflandmarks); |
|
1486 |
||
1487 |
inps = &(ServiceHandler->InParamListL()); |
|
1488 |
outps = &(ServiceHandler->OutParamListL()); |
|
1489 |
||
1490 |
inps->Reset(); |
|
1491 |
outps->Reset(); |
|
1492 |
||
1493 |
TInt i = 0; |
|
1494 |
TPtrC string; |
|
1495 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1496 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1497 |
{ |
|
1498 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
1499 |
KParam, i, &string ); |
|
1500 |
i++; |
|
1501 |
} |
|
1502 |
/*Preconditions*/ |
|
1503 |
_LIT(KOffice1,"NokiaPrevious"); |
|
1504 |
_LIT(KName1,"Mainland China"); |
|
1505 |
_LIT(KName2,"Chung Wah"); |
|
1506 |
_LIT(KName3,"Aromas of China"); |
|
1507 |
||
1508 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
1509 |
CleanupStack::PushL(db); |
|
1510 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1511 |
||
1512 |
TPosLmItemId lmId; |
|
1513 |
//RArray<TPosLmItemId> landmarks; |
|
1514 |
//CleanupClosePushL(landmarks); |
|
1515 |
||
1516 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
1517 |
||
1518 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
1519 |
lm->SetLandmarkNameL(KName1); |
|
1520 |
lmId = db->AddLandmarkL(*lm); |
|
1521 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1522 |
TBuf<5> lmIdString1; |
|
1523 |
lmIdString1.Num(lmId,EDecimal); |
|
1524 |
landmarkIdList->AppendL(TLiwVariant(lmIdString1)); |
|
1525 |
lm->SetLandmarkNameL(KName2); |
|
1526 |
lmId = db->AddLandmarkL(*lm); |
|
1527 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1528 |
TBuf<5> lmIdString2; |
|
1529 |
lmIdString2.Num(lmId,EDecimal); |
|
1530 |
landmarkIdList->AppendL(TLiwVariant(lmIdString2)); |
|
1531 |
lm->SetLandmarkNameL(KName3); |
|
1532 |
lmId = db->AddLandmarkL(*lm); |
|
1533 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1534 |
TBuf<5> lmIdString3; |
|
1535 |
lmIdString3.Num(lmId,EDecimal); |
|
1536 |
landmarkIdList->AppendL(TLiwVariant(lmIdString3)); |
|
1537 |
||
1538 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1539 |
CleanupStack::PushL(catManager); |
|
1540 |
RemoveAllCategories(catManager); |
|
1541 |
||
1542 |
TPosLmItemId catId; |
|
1543 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1544 |
category->SetCategoryNameL(KOffice1); |
|
1545 |
catId = catManager->AddCategoryL(*category); |
|
1546 |
TBuf<5> catIdString; |
|
1547 |
catIdString.Num(catId,EDecimal); |
|
1548 |
||
1549 |
CleanupStack::PopAndDestroy(4,db); |
|
1550 |
ReleaseLandmarkResources(); |
|
1551 |
||
1552 |
TLiwGenericParam param; |
|
1553 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
1554 |
inps->AppendL(param); |
|
1555 |
param.Reset(); |
|
1556 |
||
1557 |
CLiwMap* map = CLiwDefaultMap::NewL(); |
|
1558 |
||
1559 |
map->InsertL(KId,TLiwVariant(catIdString)); |
|
1560 |
map->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
1561 |
landmarkIdList->DecRef(); |
|
1562 |
param.SetNameAndValueL(KDataFields,TLiwVariant(map)); |
|
1563 |
inps->AppendL(param); |
|
1564 |
map->DecRef(); |
|
1565 |
param.Reset(); |
|
1566 |
||
1567 |
param.SetNameAndValueL(KOperationType,TLiwVariant(KAssociate)); |
|
1568 |
inps->AppendL(param); |
|
1569 |
param.Reset(); |
|
1570 |
||
1571 |
iIflandmarks->ExecuteCmdL(KOrganise,*inps,*outps,0,0); |
|
1572 |
TInt index = 0; |
|
1573 |
TInt32 err = -1; |
|
1574 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
1575 |
//log data |
|
1576 |
RFile LogResult; |
|
1577 |
RFs LogResultSession; |
|
1578 |
User::LeaveIfError(LogResultSession.Connect()); |
|
1579 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
1580 |
{ |
|
1581 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
1582 |
} |
|
1583 |
TInt End = 0 ; |
|
1584 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
1585 |
if( outParam ) |
|
1586 |
{ |
|
1587 |
outParam->Value().Get(err); |
|
1588 |
TBuf8<50> error; |
|
1589 |
TRealFormat format; |
|
1590 |
error.Num(err,format) ; |
|
1591 |
LogResult.Write(_L8("LinkCategoryL Error=")); |
|
1592 |
LogResult.Write(error); |
|
1593 |
LogResult.Write(_L8("\n")); |
|
1594 |
} |
|
1595 |
LogResult.Close(); |
|
1596 |
LogResultSession.Close(); |
|
1597 |
||
1598 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1599 |
ReleaseLandmarkResources(); |
|
1600 |
__UHEAP_MARKEND; |
|
1601 |
||
1602 |
return err; |
|
1603 |
} |
|
1604 |
||
1605 |
// ----------------------------------------------------------------------------- |
|
1606 |
// CTLandmarkProvider::LinkCategoryPosL |
|
1607 |
// Example test method function. |
|
1608 |
// (other items were commented in a header). |
|
1609 |
// ----------------------------------------------------------------------------- |
|
1610 |
// |
|
1611 |
TInt CTLandmarkProvider::LinkCategoryPosL( CStifItemParser& aItem ) |
|
1612 |
{ |
|
1613 |
||
1614 |
// Print to UI |
|
1615 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
1616 |
_LIT( KExample, "In LinkCategoryPosL" ); |
|
1617 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
1618 |
// Print to log file |
|
1619 |
iLog->Log( KExample ); |
|
1620 |
__UHEAP_MARK; |
|
1621 |
CLiwServiceHandler* ServiceHandler; |
|
1622 |
CLiwGenericParamList* inps,*outps; |
|
1623 |
MLiwInterface* iIflandmarks; |
|
1624 |
||
1625 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
1626 |
CleanupStack::PushL(ServiceHandler); |
|
1627 |
CleanupClosePushL(*iIflandmarks); |
|
1628 |
||
1629 |
inps = &(ServiceHandler->InParamListL()); |
|
1630 |
outps = &(ServiceHandler->OutParamListL()); |
|
1631 |
||
1632 |
inps->Reset(); |
|
1633 |
outps->Reset(); |
|
1634 |
||
1635 |
TInt i = 0; |
|
1636 |
TPtrC string; |
|
1637 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1638 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1639 |
{ |
|
1640 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
1641 |
KParam, i, &string ); |
|
1642 |
i++; |
|
1643 |
} |
|
1644 |
/*Preconditions*/ |
|
1645 |
_LIT(KOffice1,"NokiaPrevious"); |
|
1646 |
_LIT(KName1,"Mainland China"); |
|
1647 |
_LIT(KName2,"Chung Wah"); |
|
1648 |
_LIT(KName3,"Aromas of China"); |
|
1649 |
||
1650 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
1651 |
CleanupStack::PushL(db); |
|
1652 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1653 |
||
1654 |
TPosLmItemId lmId; |
|
1655 |
//RArray<TPosLmItemId> landmarks; |
|
1656 |
//CleanupClosePushL(landmarks); |
|
1657 |
||
1658 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
1659 |
||
1660 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
1661 |
lm->SetLandmarkNameL(KName1); |
|
1662 |
lmId = db->AddLandmarkL(*lm); |
|
1663 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1664 |
TBuf<5> lmIdString1; |
|
1665 |
lmIdString1.Num(lmId,EDecimal); |
|
1666 |
landmarkIdList->AppendL(TLiwVariant(lmIdString1)); |
|
1667 |
lm->SetLandmarkNameL(KName2); |
|
1668 |
lmId = db->AddLandmarkL(*lm); |
|
1669 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1670 |
TBuf<5> lmIdString2; |
|
1671 |
lmIdString2.Num(lmId,EDecimal); |
|
1672 |
landmarkIdList->AppendL(TLiwVariant(lmIdString2)); |
|
1673 |
lm->SetLandmarkNameL(KName3); |
|
1674 |
lmId = db->AddLandmarkL(*lm); |
|
1675 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
1676 |
TBuf<5> lmIdString3; |
|
1677 |
lmIdString3.Num(lmId,EDecimal); |
|
1678 |
landmarkIdList->AppendL(TLiwVariant(lmIdString3)); |
|
1679 |
||
1680 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1681 |
CleanupStack::PushL(catManager); |
|
1682 |
RemoveAllCategories(catManager); |
|
1683 |
||
1684 |
TPosLmItemId catId; |
|
1685 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1686 |
category->SetCategoryNameL(KOffice1); |
|
1687 |
catId = catManager->AddCategoryL(*category); |
|
1688 |
TBuf<5> catIdString; |
|
1689 |
catIdString.Num(catId,EDecimal); |
|
1690 |
||
1691 |
CleanupStack::PopAndDestroy(4,db); |
|
1692 |
ReleaseLandmarkResources(); |
|
1693 |
||
1694 |
TLiwGenericParam param; |
|
1695 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
1696 |
inps->AppendL(param); |
|
1697 |
param.Reset(); |
|
1698 |
||
1699 |
CLiwMap* map = CLiwDefaultMap::NewL(); |
|
1700 |
map->InsertL(KId,TLiwVariant(catIdString)); |
|
1701 |
map->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
1702 |
landmarkIdList->DecRef(); |
|
1703 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(map)); |
|
1704 |
inps->AppendL(param); |
|
1705 |
map->DecRef(); |
|
1706 |
param.Reset(); |
|
1707 |
||
1708 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KAssociate)); |
|
1709 |
inps->AppendL(param); |
|
1710 |
param.Reset(); |
|
1711 |
||
1712 |
iIflandmarks->ExecuteCmdL(KOrganise,*inps,*outps,0,0); |
|
1713 |
TInt index = 0; |
|
1714 |
TInt32 err = -1; |
|
1715 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
1716 |
//log data |
|
1717 |
RFile LogResult; |
|
1718 |
RFs LogResultSession; |
|
1719 |
User::LeaveIfError(LogResultSession.Connect()); |
|
1720 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
1721 |
{ |
|
1722 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
1723 |
} |
|
1724 |
TInt End = 0 ; |
|
1725 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
1726 |
if( outParam ) |
|
1727 |
{ |
|
1728 |
outParam->Value().Get(err); |
|
1729 |
TBuf8<50> error; |
|
1730 |
TRealFormat format; |
|
1731 |
error.Num(err,format) ; |
|
1732 |
LogResult.Write(_L8("LinkCategoryL Error=")); |
|
1733 |
LogResult.Write(error); |
|
1734 |
LogResult.Write(_L8("\n")); |
|
1735 |
} |
|
1736 |
LogResult.Close(); |
|
1737 |
LogResultSession.Close(); |
|
1738 |
||
1739 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1740 |
ReleaseLandmarkResources(); |
|
1741 |
__UHEAP_MARKEND; |
|
1742 |
return err; |
|
1743 |
} |
|
1744 |
||
1745 |
||
1746 |
// ----------------------------------------------------------------------------- |
|
1747 |
// CTLandmarkProvider::UnLinkCategoryL |
|
1748 |
// Example test method function. |
|
1749 |
// (other items were commented in a header). |
|
1750 |
// ----------------------------------------------------------------------------- |
|
1751 |
// |
|
1752 |
TInt CTLandmarkProvider::UnLinkCategoryL( CStifItemParser& aItem ) |
|
1753 |
{ |
|
1754 |
||
1755 |
// Print to UI |
|
1756 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
1757 |
_LIT( KExample, "In Example" ); |
|
1758 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
1759 |
// Print to log file |
|
1760 |
iLog->Log( KExample ); |
|
1761 |
__UHEAP_MARK; |
|
1762 |
CLiwServiceHandler* ServiceHandler; |
|
1763 |
CLiwGenericParamList* inps,*outps; |
|
1764 |
MLiwInterface* iIflandmarks; |
|
1765 |
||
1766 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
1767 |
CleanupStack::PushL(ServiceHandler); |
|
1768 |
CleanupClosePushL(*iIflandmarks); |
|
1769 |
||
1770 |
inps = &(ServiceHandler->InParamListL()); |
|
1771 |
outps = &(ServiceHandler->OutParamListL()); |
|
1772 |
||
1773 |
inps->Reset(); |
|
1774 |
outps->Reset(); |
|
1775 |
||
1776 |
TInt i = 0; |
|
1777 |
TPtrC string; |
|
1778 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1779 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1780 |
{ |
|
1781 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
1782 |
KParam, i, &string ); |
|
1783 |
i++; |
|
1784 |
} |
|
1785 |
/*Preconditions*/ |
|
1786 |
_LIT(KOffice1,"NokiaPrevious"); |
|
1787 |
_LIT(KName1,"Mainland China"); |
|
1788 |
_LIT(KName2,"Chung Wah"); |
|
1789 |
_LIT(KName3,"Aromas of China"); |
|
1790 |
||
1791 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
1792 |
CleanupStack::PushL(db); |
|
1793 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1794 |
||
1795 |
TPosLmItemId lmId; |
|
1796 |
RArray<TPosLmItemId> landmarks; |
|
1797 |
CleanupClosePushL(landmarks); |
|
1798 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
1799 |
||
1800 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
1801 |
lm->SetLandmarkNameL(KName1); |
|
1802 |
lmId = db->AddLandmarkL(*lm); |
|
1803 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
1804 |
TBuf<5> lmIdString1; |
|
1805 |
lmIdString1.Num(lmId,EDecimal); |
|
1806 |
landmarkIdList->AppendL(TLiwVariant(lmIdString1)); |
|
1807 |
lm->SetLandmarkNameL(KName2); |
|
1808 |
lmId = db->AddLandmarkL(*lm); |
|
1809 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
1810 |
TBuf<5> lmIdString2; |
|
1811 |
lmIdString2.Num(lmId,EDecimal); |
|
1812 |
landmarkIdList->AppendL(TLiwVariant(lmIdString2)); |
|
1813 |
lm->SetLandmarkNameL(KName3); |
|
1814 |
lmId = db->AddLandmarkL(*lm); |
|
1815 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
1816 |
TBuf<5> lmIdString3; |
|
1817 |
lmIdString3.Num(lmId,EDecimal); |
|
1818 |
landmarkIdList->AppendL(TLiwVariant(lmIdString3)); |
|
1819 |
||
1820 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1821 |
CleanupStack::PushL(catManager); |
|
1822 |
RemoveAllCategories(catManager); |
|
1823 |
||
1824 |
TPosLmItemId catId; |
|
1825 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1826 |
category->SetCategoryNameL(KOffice1); |
|
1827 |
catId = catManager->AddCategoryL(*category); |
|
1828 |
ExecuteAndDeleteLD(catManager->AddCategoryToLandmarksL(catId,landmarks)); |
|
1829 |
TBuf<5> catIdString; |
|
1830 |
catIdString.Num(catId,EDecimal); |
|
1831 |
||
1832 |
CleanupStack::PopAndDestroy(5,db); |
|
1833 |
ReleaseLandmarkResources(); |
|
1834 |
||
1835 |
TLiwGenericParam param; |
|
1836 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
1837 |
inps->AppendL(param); |
|
1838 |
param.Reset(); |
|
1839 |
||
1840 |
CLiwMap* map = CLiwDefaultMap::NewL(); |
|
1841 |
map->InsertL(KId,TLiwVariant(catIdString)); |
|
1842 |
map->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
1843 |
landmarkIdList->DecRef(); |
|
1844 |
param.SetNameAndValueL(KDataFields,TLiwVariant(map)); |
|
1845 |
inps->AppendL(param); |
|
1846 |
map->DecRef(); |
|
1847 |
param.Reset(); |
|
1848 |
||
1849 |
param.SetNameAndValueL(KOperationType,TLiwVariant(KDisassociate)); |
|
1850 |
inps->AppendL(param); |
|
1851 |
param.Reset(); |
|
1852 |
||
1853 |
iIflandmarks->ExecuteCmdL(KOrganise,*inps,*outps,0,0); |
|
1854 |
TInt index = 0; |
|
1855 |
TInt32 err = -1; |
|
1856 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
1857 |
//log data |
|
1858 |
RFile LogResult; |
|
1859 |
RFs LogResultSession; |
|
1860 |
User::LeaveIfError(LogResultSession.Connect()); |
|
1861 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
1862 |
{ |
|
1863 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
1864 |
} |
|
1865 |
TInt End = 0 ; |
|
1866 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
1867 |
if( outParam ) |
|
1868 |
{ |
|
1869 |
outParam->Value().Get(err); |
|
1870 |
TBuf8<50> error; |
|
1871 |
TRealFormat format; |
|
1872 |
error.Num(err,format) ; |
|
1873 |
LogResult.Write(_L8("UnLinkCategoryL Error=")); |
|
1874 |
LogResult.Write(error); |
|
1875 |
LogResult.Write(_L8("\n")); |
|
1876 |
} |
|
1877 |
LogResult.Close(); |
|
1878 |
LogResultSession.Close(); |
|
1879 |
||
1880 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
1881 |
ReleaseLandmarkResources(); |
|
1882 |
__UHEAP_MARKEND; |
|
1883 |
return err; |
|
1884 |
} |
|
1885 |
||
1886 |
// ----------------------------------------------------------------------------- |
|
1887 |
// CTLandmarkProvider::UnLinkCategoryPosL |
|
1888 |
// Example test method function. |
|
1889 |
// (other items were commented in a header). |
|
1890 |
// ----------------------------------------------------------------------------- |
|
1891 |
// |
|
1892 |
TInt CTLandmarkProvider::UnLinkCategoryPosL( CStifItemParser& aItem ) |
|
1893 |
{ |
|
1894 |
||
1895 |
// Print to UI |
|
1896 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
1897 |
_LIT( KExample, "In UnLinkCategoryPosL" ); |
|
1898 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
1899 |
// Print to log file |
|
1900 |
iLog->Log( KExample ); |
|
1901 |
||
1902 |
__UHEAP_MARK; |
|
1903 |
CLiwServiceHandler* ServiceHandler; |
|
1904 |
CLiwGenericParamList* inps,*outps; |
|
1905 |
MLiwInterface* iIflandmarks; |
|
1906 |
||
1907 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
1908 |
CleanupStack::PushL(ServiceHandler); |
|
1909 |
CleanupClosePushL(*iIflandmarks); |
|
1910 |
||
1911 |
inps = &(ServiceHandler->InParamListL()); |
|
1912 |
outps = &(ServiceHandler->OutParamListL()); |
|
1913 |
||
1914 |
inps->Reset(); |
|
1915 |
outps->Reset(); |
|
1916 |
||
1917 |
TInt i = 0; |
|
1918 |
TPtrC string; |
|
1919 |
_LIT( KParam, "Param[%i]: %S" ); |
|
1920 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
1921 |
{ |
|
1922 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
1923 |
KParam, i, &string ); |
|
1924 |
i++; |
|
1925 |
} |
|
1926 |
/*Preconditions*/ |
|
1927 |
_LIT(KOffice1,"NokiaPrevious"); |
|
1928 |
_LIT(KName1,"Mainland China"); |
|
1929 |
_LIT(KName2,"Chung Wah"); |
|
1930 |
_LIT(KName3,"Aromas of China"); |
|
1931 |
||
1932 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
1933 |
CleanupStack::PushL(db); |
|
1934 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
1935 |
||
1936 |
TPosLmItemId lmId; |
|
1937 |
RArray<TPosLmItemId> landmarks; |
|
1938 |
CleanupClosePushL(landmarks); |
|
1939 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
1940 |
||
1941 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
1942 |
lm->SetLandmarkNameL(KName1); |
|
1943 |
lmId = db->AddLandmarkL(*lm); |
|
1944 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
1945 |
TBuf<5> lmIdString1; |
|
1946 |
lmIdString1.Num(lmId,EDecimal); |
|
1947 |
landmarkIdList->AppendL(TLiwVariant(lmIdString1)); |
|
1948 |
lm->SetLandmarkNameL(KName2); |
|
1949 |
lmId = db->AddLandmarkL(*lm); |
|
1950 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
1951 |
TBuf<5> lmIdString2; |
|
1952 |
lmIdString2.Num(lmId,EDecimal); |
|
1953 |
landmarkIdList->AppendL(TLiwVariant(lmIdString2)); |
|
1954 |
lm->SetLandmarkNameL(KName3); |
|
1955 |
lmId = db->AddLandmarkL(*lm); |
|
1956 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
1957 |
TBuf<5> lmIdString3; |
|
1958 |
lmIdString3.Num(lmId,EDecimal); |
|
1959 |
landmarkIdList->AppendL(TLiwVariant(lmIdString3)); |
|
1960 |
||
1961 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
1962 |
CleanupStack::PushL(catManager); |
|
1963 |
RemoveAllCategories(catManager); |
|
1964 |
||
1965 |
TPosLmItemId catId; |
|
1966 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
1967 |
category->SetCategoryNameL(KOffice1); |
|
1968 |
catId = catManager->AddCategoryL(*category); |
|
1969 |
ExecuteAndDeleteLD(catManager->AddCategoryToLandmarksL(catId,landmarks)); |
|
1970 |
TBuf<5> catIdString; |
|
1971 |
catIdString.Num(catId,EDecimal); |
|
1972 |
||
1973 |
CleanupStack::PopAndDestroy(5,db); |
|
1974 |
ReleaseLandmarkResources(); |
|
1975 |
||
1976 |
TLiwGenericParam param; |
|
1977 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
1978 |
inps->AppendL(param); |
|
1979 |
param.Reset(); |
|
1980 |
||
1981 |
CLiwMap* map = CLiwDefaultMap::NewL(); |
|
1982 |
map->InsertL(KId,TLiwVariant(catIdString)); |
|
1983 |
map->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
1984 |
landmarkIdList->DecRef(); |
|
1985 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(map)); |
|
1986 |
inps->AppendL(param); |
|
1987 |
map->DecRef(); |
|
1988 |
param.Reset(); |
|
1989 |
||
1990 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KDisassociate)); |
|
1991 |
inps->AppendL(param); |
|
1992 |
param.Reset(); |
|
1993 |
||
1994 |
iIflandmarks->ExecuteCmdL(KOrganise,*inps,*outps,0,0); |
|
1995 |
TInt index = 0; |
|
1996 |
TInt32 err = -1; |
|
1997 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
1998 |
//log data |
|
1999 |
RFile LogResult; |
|
2000 |
RFs LogResultSession; |
|
2001 |
User::LeaveIfError(LogResultSession.Connect()); |
|
2002 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
2003 |
{ |
|
2004 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
2005 |
} |
|
2006 |
TInt End = 0 ; |
|
2007 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
2008 |
if( outParam ) |
|
2009 |
{ |
|
2010 |
outParam->Value().Get(err); |
|
2011 |
TBuf8<50> error; |
|
2012 |
TRealFormat format; |
|
2013 |
error.Num(err,format) ; |
|
2014 |
LogResult.Write(_L8("UnLinkCategoryL Error=")); |
|
2015 |
LogResult.Write(error); |
|
2016 |
LogResult.Write(_L8("\n")); |
|
2017 |
} |
|
2018 |
LogResult.Close(); |
|
2019 |
LogResultSession.Close(); |
|
2020 |
||
2021 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2022 |
ReleaseLandmarkResources(); |
|
2023 |
__UHEAP_MARKEND; |
|
2024 |
return err; |
|
2025 |
} |
|
2026 |
||
2027 |
||
2028 |
// ----------------------------------------------------------------------------- |
|
2029 |
// CTLandmarkProvider::LandmarksSyncTest1 |
|
2030 |
// Helper method to remove all landmarks for preconditional tests. |
|
2031 |
// ----------------------------------------------------------------------------- |
|
2032 |
// |
|
2033 |
struct landmark |
|
2034 |
{ |
|
2035 |
TUint id; |
|
2036 |
HBufC* name; |
|
2037 |
HBufC* desc; |
|
2038 |
TReal64 latitude; |
|
2039 |
TReal64 longitude; |
|
2040 |
TReal32 altitude; |
|
2041 |
TReal32 haccuracy; |
|
2042 |
TReal32 vaccuracy; |
|
2043 |
TReal32 covrad; |
|
2044 |
landmark* next; |
|
2045 |
}; |
|
2046 |
TInt CTLandmarkProvider::LandmarksGtkL ( CStifItemParser& /*aItem*/ ) |
|
2047 |
{ |
|
2048 |
_LIT( KExample, "LandmarksGtkL" ); |
|
2049 |
iLog->Log( KExample ); |
|
2050 |
||
2051 |
TInt32 err; |
|
2052 |
TInt ret = 0; |
|
2053 |
||
2054 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
2055 |
CleanupStack::PushL(db); |
|
2056 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
2057 |
RemoveAllLandmarks(db); |
|
2058 |
CreateLandmarksL(db); |
|
2059 |
CleanupStack::PopAndDestroy(db); |
|
2060 |
||
2061 |
CLiwGenericParamList* inps = &(iServiceHandler->InParamListL()); |
|
2062 |
CLiwGenericParamList* outps = &(iServiceHandler->OutParamListL()); |
|
2063 |
||
2064 |
TLiwGenericParam param; |
|
2065 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
2066 |
inps->AppendL(param); |
|
2067 |
param.Reset(); |
|
2068 |
||
2069 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
2070 |
ret |= CheckErrorCode (*outps,err); |
|
2071 |
if ( err != KErrNone ) |
|
2072 |
{ |
|
2073 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2074 |
ret |= FAIL; |
|
2075 |
} |
|
2076 |
||
2077 |
landmark* new_node = NULL; |
|
2078 |
landmark* cur_node = NULL; |
|
2079 |
landmark* lm_head = NULL; |
|
2080 |
const TInt NAME_MAX = 255; |
|
2081 |
TInt Index = 0; |
|
2082 |
const TLiwGenericParam* itr = outps->FindFirst(Index,KReturnValue); |
|
2083 |
if ( Index > 0 || (0 == Index) ) |
|
2084 |
{ |
|
2085 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2086 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
2087 |
if( iter ) |
|
2088 |
{ |
|
2089 |
TLiwVariant lmVariant; |
|
2090 |
while( iter->NextL(lmVariant) ) |
|
2091 |
{ |
|
2092 |
TRAPD(err,new_node = (landmark*) User::AllocL(sizeof(landmark))); |
|
2093 |
User::LeaveIfError(err); |
|
2094 |
new_node->next = lm_head; |
|
2095 |
lm_head = new_node; |
|
2096 |
||
2097 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
2098 |
TLiwVariant variantField; |
|
2099 |
TPtrC landmarkName; |
|
2100 |
TPtrC landmarkDesc; |
|
2101 |
if( landmark ) |
|
2102 |
{ |
|
2103 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
2104 |
{ |
|
2105 |
variantField.Get(landmarkName); |
|
2106 |
new_node->name = HBufC::NewL(NAME_MAX); |
|
2107 |
(new_node->name->Des()).Copy(landmarkName); |
|
2108 |
} |
|
2109 |
if( landmark->FindL(KLandmarkDesc,variantField) ) |
|
2110 |
{ |
|
2111 |
variantField.Get(landmarkDesc); |
|
2112 |
/*new_node->desc = HBufC::NewL(NAME_MAX); |
|
2113 |
(new_node->desc->Des()).Copy(landmarkDesc); */ |
|
2114 |
} |
|
2115 |
if( landmark->FindL(KLandmarkPosition,variantField) ) |
|
2116 |
{ |
|
2117 |
const CLiwMap* landmarkPos = variantField.AsMap(); |
|
2118 |
TLiwVariant variantPos; |
|
2119 |
TReal coord; |
|
2120 |
if( landmarkPos->FindL(KLatitude,variantPos) ) |
|
2121 |
{ |
|
2122 |
variantPos.Get(coord); |
|
2123 |
new_node->latitude = coord; |
|
2124 |
} |
|
2125 |
if( landmarkPos->FindL(KLongitude,variantPos) ) |
|
2126 |
{ |
|
2127 |
variantPos.Get(coord); |
|
2128 |
new_node->longitude = coord; |
|
2129 |
} |
|
2130 |
variantPos.Reset(); |
|
2131 |
} |
|
2132 |
||
2133 |
} |
|
2134 |
variantField.Reset(); |
|
2135 |
lmVariant.Reset(); |
|
2136 |
} |
|
2137 |
} |
|
2138 |
} |
|
2139 |
outps->Reset(); |
|
2140 |
cur_node = lm_head; |
|
2141 |
while(cur_node) |
|
2142 |
{ |
|
2143 |
lm_head = cur_node->next; |
|
2144 |
User::Free(cur_node->name); |
|
2145 |
User::Free(cur_node->desc); |
|
2146 |
User::Free(cur_node); |
|
2147 |
cur_node = lm_head; |
|
2148 |
} |
|
2149 |
return KErrNone; |
|
2150 |
} |
|
2151 |
// ----------------------------------------------------------------------------- |
|
2152 |
// CTLandmarkProvider::LandmarksSyncTest1 |
|
2153 |
// Helper method to remove all landmarks for preconditional tests. |
|
2154 |
// ----------------------------------------------------------------------------- |
|
2155 |
// |
|
2156 |
TInt CTLandmarkProvider::LandmarksSyncTest1L ( CStifItemParser& /*aItem*/ ) |
|
2157 |
{ |
|
2158 |
_LIT( KExample, "LandmarksSyncTest1" ); |
|
2159 |
iLog->Log( KExample ); |
|
2160 |
||
2161 |
TInt32 err; |
|
2162 |
TInt ret = 0; |
|
2163 |
||
2164 |
__UHEAP_MARK; |
|
2165 |
CLiwServiceHandler* ServiceHandler; |
|
2166 |
CLiwGenericParamList* inps,*outps; |
|
2167 |
MLiwInterface* iIflandmarks; |
|
2168 |
||
2169 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
2170 |
CleanupStack::PushL(ServiceHandler); |
|
2171 |
CleanupClosePushL(*iIflandmarks); |
|
2172 |
||
2173 |
inps = &(ServiceHandler->InParamListL()); |
|
2174 |
outps = &(ServiceHandler->OutParamListL()); |
|
2175 |
||
2176 |
inps->Reset(); |
|
2177 |
outps->Reset(); |
|
2178 |
||
2179 |
||
2180 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
2181 |
CleanupStack::PushL(db); |
|
2182 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
2183 |
RemoveAllLandmarks(db); |
|
2184 |
CreateLandmarksL(db); |
|
2185 |
CleanupStack::PopAndDestroy(db); |
|
2186 |
||
2187 |
TLiwGenericParam param; |
|
2188 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
2189 |
inps->AppendL(param); |
|
2190 |
param.Reset(); |
|
2191 |
||
2192 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
2193 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString)); |
|
2194 |
landmarkMap->InsertL(KMaximumMatches,TLiwVariant((TInt32)2)); |
|
2195 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2196 |
inps->AppendL(param); |
|
2197 |
param.Reset(); |
|
2198 |
landmarkMap->DecRef(); |
|
2199 |
||
2200 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
2201 |
ret |= CheckErrorCode (*outps,err); |
|
2202 |
if ( err != KErrNone ) |
|
2203 |
{ |
|
2204 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2205 |
ret |= FAIL; |
|
2206 |
} |
|
2207 |
||
2208 |
TInt Index = 0; |
|
2209 |
const TLiwGenericParam* itr = outps->FindFirst(Index,KReturnValue); |
|
2210 |
if ( Index > 0 || (0 == Index) ) |
|
2211 |
{ |
|
2212 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2213 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
2214 |
if( iter ) |
|
2215 |
{ |
|
2216 |
TLiwVariant lmVariant; |
|
2217 |
while( iter->NextL(lmVariant) ) |
|
2218 |
{ |
|
2219 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
2220 |
TLiwVariant variantField; |
|
2221 |
TPtrC landmarkName; |
|
2222 |
if( landmark ) |
|
2223 |
{ |
|
2224 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
2225 |
{ |
|
2226 |
variantField.Get(landmarkName); |
|
2227 |
} |
|
2228 |
if( landmark->FindL(KLandmarkPosition,variantField) ) |
|
2229 |
{ |
|
2230 |
const CLiwMap* landmarkPos = variantField.AsMap(); |
|
2231 |
TLiwVariant variantPos; |
|
2232 |
TReal coord; |
|
2233 |
if( landmarkPos->FindL(KLatitude,variantPos) ) |
|
2234 |
{ |
|
2235 |
variantPos.Get(coord); |
|
2236 |
} |
|
2237 |
if( landmarkPos->FindL(KLongitude,variantPos) ) |
|
2238 |
{ |
|
2239 |
variantPos.Get(coord); |
|
2240 |
} |
|
2241 |
variantPos.Reset(); |
|
2242 |
} |
|
2243 |
} |
|
2244 |
variantField.Reset(); |
|
2245 |
lmVariant.Reset(); |
|
2246 |
} |
|
2247 |
} |
|
2248 |
||
2249 |
} |
|
2250 |
//test prev match |
|
2251 |
inps->Reset(); |
|
2252 |
outps->Reset(); |
|
2253 |
inps->AppendL(TLiwGenericParam(KContentType,TLiwVariant(KLandmark))); |
|
2254 |
param.Reset(); |
|
2255 |
//try for previous matches |
|
2256 |
landmarkMap = CLiwDefaultMap::NewL(); |
|
2257 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString1)); |
|
2258 |
landmarkMap->InsertL(KPrevMatchesOnly,TLiwVariant((TBool)ETrue)); |
|
2259 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2260 |
inps->AppendL(param); |
|
2261 |
landmarkMap->DecRef(); |
|
2262 |
param.Reset(); |
|
2263 |
||
2264 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
2265 |
ret |= CheckErrorCode (*outps,err); |
|
2266 |
if ( err != KErrNone ) |
|
2267 |
{ |
|
2268 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2269 |
ret |= FAIL; |
|
2270 |
} |
|
2271 |
||
2272 |
Index = 0; |
|
2273 |
itr = outps->FindFirst(Index,KReturnValue); |
|
2274 |
if ( Index > 0 || (0 == Index) ) |
|
2275 |
{ |
|
2276 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2277 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
2278 |
if( iter ) |
|
2279 |
{ |
|
2280 |
TLiwVariant lmVariant; |
|
2281 |
while( iter->NextL(lmVariant) ) |
|
2282 |
{ |
|
2283 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
2284 |
TLiwVariant variantField; |
|
2285 |
TPtrC landmarkName; |
|
2286 |
if( landmark ) |
|
2287 |
{ |
|
2288 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
2289 |
{ |
|
2290 |
variantField.Get(landmarkName); |
|
2291 |
} |
|
2292 |
||
2293 |
} |
|
2294 |
variantField.Reset(); |
|
2295 |
lmVariant.Reset(); |
|
2296 |
} |
|
2297 |
} |
|
2298 |
||
2299 |
} |
|
2300 |
||
2301 |
//test landmark desc |
|
2302 |
_LIT(KLmDesSearchString,"welc*"); |
|
2303 |
inps->Reset(); |
|
2304 |
outps->Reset(); |
|
2305 |
inps->AppendL(TLiwGenericParam(KContentType,TLiwVariant(KLandmark))); |
|
2306 |
param.Reset(); |
|
2307 |
landmarkMap = CLiwDefaultMap::NewL(); |
|
2308 |
landmarkMap->InsertL(KLandmarkDesc,TLiwVariant(KLmDesSearchString)); |
|
2309 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2310 |
inps->AppendL(param); |
|
2311 |
landmarkMap->DecRef(); |
|
2312 |
param.Reset(); |
|
2313 |
||
2314 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
2315 |
ret |= CheckErrorCode (*outps,err); |
|
2316 |
if ( err != KErrNone ) |
|
2317 |
{ |
|
2318 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2319 |
ret |= FAIL; |
|
2320 |
} |
|
2321 |
||
2322 |
Index = 0; |
|
2323 |
itr = outps->FindFirst(Index,KReturnValue); |
|
2324 |
if ( Index > 0 || (0 == Index) ) |
|
2325 |
{ |
|
2326 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2327 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
2328 |
if( iter ) |
|
2329 |
{ |
|
2330 |
TLiwVariant lmVariant; |
|
2331 |
while( iter->NextL(lmVariant) ) |
|
2332 |
{ |
|
2333 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
2334 |
TLiwVariant variantField; |
|
2335 |
TPtrC landmarkName; |
|
2336 |
if( landmark ) |
|
2337 |
{ |
|
2338 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
2339 |
{ |
|
2340 |
variantField.Get(landmarkName); |
|
2341 |
} |
|
2342 |
||
2343 |
} |
|
2344 |
variantField.Reset(); |
|
2345 |
lmVariant.Reset(); |
|
2346 |
} |
|
2347 |
} |
|
2348 |
||
2349 |
} |
|
2350 |
||
2351 |
//test nearest |
|
2352 |
inps->Reset(); |
|
2353 |
outps->Reset(); |
|
2354 |
inps->AppendL(TLiwGenericParam(KContentType,TLiwVariant(KLandmark))); |
|
2355 |
param.Reset(); |
|
2356 |
landmarkMap = CLiwDefaultMap::NewL(); |
|
2357 |
CLiwDefaultMap* positionMap = CLiwDefaultMap::NewL(); |
|
2358 |
positionMap->InsertL(KLatitude,TLiwVariant((TReal)12.0)); |
|
2359 |
positionMap->InsertL(KLongitude,TLiwVariant((TReal)67.0)); |
|
2360 |
positionMap->InsertL(KCoverageRadiusOption,TLiwVariant(EFalse)); |
|
2361 |
positionMap->InsertL(KMaximumDistance,TLiwVariant((TReal)30.0)); |
|
2362 |
landmarkMap->InsertL(KLandmarkPosition,TLiwVariant(positionMap)); |
|
2363 |
positionMap->DecRef(); |
|
2364 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2365 |
inps->AppendL(param); |
|
2366 |
landmarkMap->DecRef(); |
|
2367 |
param.Reset(); |
|
2368 |
||
2369 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
2370 |
ret |= CheckErrorCode (*outps,err); |
|
2371 |
if ( err != KErrNone ) |
|
2372 |
{ |
|
2373 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2374 |
ret |= FAIL; |
|
2375 |
} |
|
2376 |
||
2377 |
Index = 0; |
|
2378 |
itr = outps->FindFirst(Index,KReturnValue); |
|
2379 |
if ( Index > 0 || (0 == Index) ) |
|
2380 |
{ |
|
2381 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2382 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
2383 |
if( iter ) |
|
2384 |
{ |
|
2385 |
TLiwVariant lmVariant; |
|
2386 |
while( iter->NextL(lmVariant) ) |
|
2387 |
{ |
|
2388 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
2389 |
TLiwVariant variantField; |
|
2390 |
TPtrC landmarkName; |
|
2391 |
if( landmark ) |
|
2392 |
{ |
|
2393 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
2394 |
{ |
|
2395 |
variantField.Get(landmarkName); |
|
2396 |
} |
|
2397 |
} |
|
2398 |
variantField.Reset(); |
|
2399 |
lmVariant.Reset(); |
|
2400 |
} |
|
2401 |
} |
|
2402 |
||
2403 |
} |
|
2404 |
||
2405 |
//area criteria |
|
2406 |
inps->Reset(); |
|
2407 |
outps->Reset(); |
|
2408 |
inps->AppendL(TLiwGenericParam(KContentType,TLiwVariant(KLandmark))); |
|
2409 |
param.Reset(); |
|
2410 |
landmarkMap = CLiwDefaultMap::NewL(); |
|
2411 |
CLiwDefaultMap* areaMap = CLiwDefaultMap::NewL(); |
|
2412 |
areaMap->InsertL(KSouthLatitude,TLiwVariant((TReal)10.0)); |
|
2413 |
areaMap->InsertL(KNorthLatitude,TLiwVariant((TReal)15.0)); |
|
2414 |
areaMap->InsertL(KWestLongitude,TLiwVariant((TReal)60.0)); |
|
2415 |
areaMap->InsertL(KEastLongitude,TLiwVariant((TReal)70.0)); |
|
2416 |
landmarkMap->InsertL(KBoundedArea,TLiwVariant(areaMap)); |
|
2417 |
areaMap->DecRef(); |
|
2418 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2419 |
inps->AppendL(param); |
|
2420 |
landmarkMap->DecRef(); |
|
2421 |
param.Reset(); |
|
2422 |
||
2423 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
2424 |
ret |= CheckErrorCode (*outps,err); |
|
2425 |
if ( err != KErrNone ) |
|
2426 |
{ |
|
2427 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2428 |
ret |= FAIL; |
|
2429 |
} |
|
2430 |
||
2431 |
Index = 0; |
|
2432 |
itr = outps->FindFirst(Index,KReturnValue); |
|
2433 |
if ( Index > 0 || (0 == Index) ) |
|
2434 |
{ |
|
2435 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2436 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
2437 |
if( iter ) |
|
2438 |
{ |
|
2439 |
TLiwVariant lmVariant; |
|
2440 |
while( iter->NextL(lmVariant) ) |
|
2441 |
{ |
|
2442 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
2443 |
TLiwVariant variantField; |
|
2444 |
TPtrC landmarkName; |
|
2445 |
if( landmark ) |
|
2446 |
{ |
|
2447 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
2448 |
{ |
|
2449 |
variantField.Get(landmarkName); |
|
2450 |
} |
|
2451 |
||
2452 |
} |
|
2453 |
variantField.Reset(); |
|
2454 |
lmVariant.Reset(); |
|
2455 |
} |
|
2456 |
} |
|
2457 |
||
2458 |
} |
|
2459 |
inps->Reset(); |
|
2460 |
outps->Reset(); |
|
2461 |
||
2462 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2463 |
ReleaseLandmarkResources(); |
|
2464 |
__UHEAP_MARKEND; |
|
2465 |
||
2466 |
return err; |
|
2467 |
} |
|
2468 |
||
2469 |
// ----------------------------------------------------------------------------- |
|
2470 |
// CTLandmarkProvider::LandmarksSyncTest1 |
|
2471 |
// Helper method to remove all landmarks for preconditional tests. |
|
2472 |
// ----------------------------------------------------------------------------- |
|
2473 |
// |
|
2474 |
TInt CTLandmarkProvider::LandmarksSyncTestPos1L ( CStifItemParser& /*aItem*/ ) |
|
2475 |
{ |
|
2476 |
_LIT( KExample, "LandmarksSyncTestPos1L" ); |
|
2477 |
iLog->Log( KExample ); |
|
2478 |
||
2479 |
TInt32 err; |
|
2480 |
TInt ret = 0; |
|
2481 |
||
2482 |
__UHEAP_MARK; |
|
2483 |
CLiwServiceHandler* ServiceHandler; |
|
2484 |
CLiwGenericParamList* inps,*outps; |
|
2485 |
MLiwInterface* iIflandmarks; |
|
2486 |
||
2487 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
2488 |
CleanupStack::PushL(ServiceHandler); |
|
2489 |
CleanupClosePushL(*iIflandmarks); |
|
2490 |
||
2491 |
inps = &(ServiceHandler->InParamListL()); |
|
2492 |
outps = &(ServiceHandler->OutParamListL()); |
|
2493 |
||
2494 |
inps->Reset(); |
|
2495 |
outps->Reset(); |
|
2496 |
||
2497 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
2498 |
CleanupStack::PushL(db); |
|
2499 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
2500 |
RemoveAllLandmarks(db); |
|
2501 |
CreateLandmarksL(db); |
|
2502 |
CleanupStack::PopAndDestroy(db); |
|
2503 |
||
2504 |
TLiwGenericParam param; |
|
2505 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
2506 |
inps->AppendL(param); |
|
2507 |
param.Reset(); |
|
2508 |
||
2509 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
2510 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString)); |
|
2511 |
landmarkMap->InsertL(KMaximumMatches,TLiwVariant((TInt32)2)); |
|
2512 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(landmarkMap)); |
|
2513 |
inps->AppendL(param); |
|
2514 |
param.Reset(); |
|
2515 |
landmarkMap->DecRef(); |
|
2516 |
||
2517 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
2518 |
ret |= CheckErrorCode (*outps,err); |
|
2519 |
if ( err != KErrNone ) |
|
2520 |
{ |
|
2521 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2522 |
ret |= FAIL; |
|
2523 |
} |
|
2524 |
||
2525 |
TInt Index = 0; |
|
2526 |
const TLiwGenericParam* itr = outps->FindFirst(Index,KReturnValue); |
|
2527 |
if ( Index > 0 || (0 == Index) ) |
|
2528 |
{ |
|
2529 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
2530 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
2531 |
if( iter ) |
|
2532 |
{ |
|
2533 |
TLiwVariant lmVariant; |
|
2534 |
while( iter->NextL(lmVariant) ) |
|
2535 |
{ |
|
2536 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
2537 |
TLiwVariant variantField; |
|
2538 |
TPtrC landmarkName; |
|
2539 |
if( landmark ) |
|
2540 |
{ |
|
2541 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
2542 |
{ |
|
2543 |
variantField.Get(landmarkName); |
|
2544 |
} |
|
2545 |
if( landmark->FindL(KLandmarkPosition,variantField) ) |
|
2546 |
{ |
|
2547 |
const CLiwMap* landmarkPos = variantField.AsMap(); |
|
2548 |
TLiwVariant variantPos; |
|
2549 |
TReal coord; |
|
2550 |
if( landmarkPos->FindL(KLatitude,variantPos) ) |
|
2551 |
{ |
|
2552 |
variantPos.Get(coord); |
|
2553 |
} |
|
2554 |
if( landmarkPos->FindL(KLongitude,variantPos) ) |
|
2555 |
{ |
|
2556 |
variantPos.Get(coord); |
|
2557 |
} |
|
2558 |
variantPos.Reset(); |
|
2559 |
} |
|
2560 |
} |
|
2561 |
variantField.Reset(); |
|
2562 |
lmVariant.Reset(); |
|
2563 |
} |
|
2564 |
} |
|
2565 |
||
2566 |
} |
|
2567 |
||
2568 |
inps->Reset(); |
|
2569 |
outps->Reset(); |
|
2570 |
||
2571 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2572 |
ReleaseLandmarkResources(); |
|
2573 |
__UHEAP_MARKEND; |
|
2574 |
return err; |
|
2575 |
} |
|
2576 |
||
2577 |
// ----------------------------------------------------------------------------- |
|
2578 |
// CTLandmarkProvider::LandmarksAsyncTest1 |
|
2579 |
// Helper method to remove all landmarks for preconditional tests. |
|
2580 |
// ----------------------------------------------------------------------------- |
|
2581 |
// |
|
2582 |
TInt CTLandmarkProvider::LandmarksAsyncTest1L ( CStifItemParser& /*aItem*/ ) |
|
2583 |
{ |
|
2584 |
_LIT( KExample, "LandmarksAsyncTest1" ); |
|
2585 |
iLog->Log( KExample ); |
|
2586 |
||
2587 |
TInt32 err; |
|
2588 |
TInt ret = 0; |
|
2589 |
||
2590 |
__UHEAP_MARK; |
|
2591 |
CLiwServiceHandler* ServiceHandler; |
|
2592 |
CLiwGenericParamList* inps,*outps; |
|
2593 |
MLiwInterface* iIflandmarks; |
|
2594 |
||
2595 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
2596 |
CleanupStack::PushL(ServiceHandler); |
|
2597 |
CleanupClosePushL(*iIflandmarks); |
|
2598 |
||
2599 |
inps = &(ServiceHandler->InParamListL()); |
|
2600 |
outps = &(ServiceHandler->OutParamListL()); |
|
2601 |
||
2602 |
inps->Reset(); |
|
2603 |
outps->Reset(); |
|
2604 |
||
2605 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
2606 |
CleanupStack::PushL(db); |
|
2607 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
2608 |
RemoveAllLandmarks(db); |
|
2609 |
CreateLandmarksL(db); |
|
2610 |
CleanupStack::PopAndDestroy(db); |
|
2611 |
||
2612 |
TLiwGenericParam param; |
|
2613 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
2614 |
inps->AppendL(param); |
|
2615 |
param.Reset(); |
|
2616 |
||
2617 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
2618 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString)); |
|
2619 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2620 |
inps->AppendL(param); |
|
2621 |
landmarkMap->DecRef(); |
|
2622 |
param.Reset(); |
|
2623 |
||
2624 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,KLiwOptASyncronous,this); |
|
2625 |
ret |= CheckErrorCode (*outps,err); |
|
2626 |
if ( err != KErrNone ) |
|
2627 |
{ |
|
2628 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2629 |
ret |= FAIL; |
|
2630 |
} |
|
2631 |
||
2632 |
if ( !ret ) |
|
2633 |
CActiveScheduler::Start(); |
|
2634 |
||
2635 |
landmarkMap->Remove(KLandmarkName); |
|
2636 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString1)); |
|
2637 |
landmarkMap->InsertL(KMaximumMatches,TLiwVariant((TInt32)2)); |
|
2638 |
landmarkMap->InsertL(KPrevMatchesOnly,TLiwVariant((TBool)ETrue)); |
|
2639 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2640 |
inps->AppendL(param); |
|
2641 |
landmarkMap->DecRef(); |
|
2642 |
param.Reset(); |
|
2643 |
||
2644 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,KLiwOptASyncronous,this); |
|
2645 |
ret |= CheckErrorCode (*outps,err); |
|
2646 |
if ( err != KErrNone ) |
|
2647 |
{ |
|
2648 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2649 |
ret |= FAIL; |
|
2650 |
} |
|
2651 |
||
2652 |
if ( !ret ) |
|
2653 |
CActiveScheduler::Start(); |
|
2654 |
||
2655 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2656 |
ReleaseLandmarkResources(); |
|
2657 |
__UHEAP_MARKEND; |
|
2658 |
||
2659 |
return ret; |
|
2660 |
} |
|
2661 |
||
2662 |
// ----------------------------------------------------------------------------- |
|
2663 |
// CTLandmarkProvider::LandmarksAsyncTest1 |
|
2664 |
// Helper method to remove all landmarks for preconditional tests. |
|
2665 |
// ----------------------------------------------------------------------------- |
|
2666 |
// |
|
2667 |
TInt CTLandmarkProvider::LandmarksAsyncTestPos1L ( CStifItemParser& /*aItem*/ ) |
|
2668 |
{ |
|
2669 |
_LIT( KExample, "LandmarksAsyncTestPos1L" ); |
|
2670 |
iLog->Log( KExample ); |
|
2671 |
||
2672 |
TInt32 err; |
|
2673 |
TInt ret = 0; |
|
2674 |
||
2675 |
__UHEAP_MARK; |
|
2676 |
CLiwServiceHandler* ServiceHandler; |
|
2677 |
CLiwGenericParamList* inps,*outps; |
|
2678 |
MLiwInterface* iIflandmarks; |
|
2679 |
||
2680 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
2681 |
CleanupStack::PushL(ServiceHandler); |
|
2682 |
CleanupClosePushL(*iIflandmarks); |
|
2683 |
||
2684 |
inps = &(ServiceHandler->InParamListL()); |
|
2685 |
outps = &(ServiceHandler->OutParamListL()); |
|
2686 |
||
2687 |
inps->Reset(); |
|
2688 |
outps->Reset(); |
|
2689 |
||
2690 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri1); |
|
2691 |
CleanupStack::PushL(db); |
|
2692 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
2693 |
RemoveAllLandmarks(db); |
|
2694 |
CreateLandmarksL(db); |
|
2695 |
CleanupStack::PopAndDestroy(db); |
|
2696 |
||
2697 |
TLiwGenericParam param; |
|
2698 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
2699 |
inps->AppendL(param); |
|
2700 |
param.Reset(); |
|
2701 |
||
2702 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
2703 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString)); |
|
2704 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(landmarkMap)); |
|
2705 |
inps->AppendL(param); |
|
2706 |
param.Reset(); |
|
2707 |
||
2708 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,KLiwOptASyncronous,this); |
|
2709 |
ret |= CheckErrorCode (*outps,err); |
|
2710 |
if ( err != KErrNone ) |
|
2711 |
{ |
|
2712 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2713 |
ret |= FAIL; |
|
2714 |
} |
|
2715 |
||
2716 |
if ( !ret ) |
|
2717 |
CActiveScheduler::Start(); |
|
2718 |
||
2719 |
inps->Reset(); |
|
2720 |
outps->Reset(); |
|
2721 |
||
2722 |
param.SetNameAndValueL(KNullDesC8,TLiwVariant(KLandmark)); |
|
2723 |
inps->AppendL(param); |
|
2724 |
param.Reset(); |
|
2725 |
||
2726 |
landmarkMap->Remove(KLandmarkName); |
|
2727 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString1)); |
|
2728 |
landmarkMap->InsertL(KMaximumMatches,TLiwVariant((TInt32)2)); |
|
2729 |
landmarkMap->InsertL(KPrevMatchesOnly,TLiwVariant((TBool)ETrue)); |
|
2730 |
||
2731 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
2732 |
inps->AppendL(param); |
|
2733 |
landmarkMap->DecRef(); |
|
2734 |
param.Reset(); |
|
2735 |
||
2736 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,KLiwOptASyncronous,this); |
|
2737 |
ret |= CheckErrorCode (*outps,err); |
|
2738 |
if ( err != KErrNone ) |
|
2739 |
{ |
|
2740 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
2741 |
ret |= FAIL; |
|
2742 |
} |
|
2743 |
||
2744 |
if ( !ret ) |
|
2745 |
CActiveScheduler::Start(); |
|
2746 |
||
2747 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2748 |
ReleaseLandmarkResources(); |
|
2749 |
__UHEAP_MARKEND; |
|
2750 |
return ret; |
|
2751 |
} |
|
2752 |
||
2753 |
// ----------------------------------------------------------------------------- |
|
2754 |
// CTLandmarkProvider::AddLandmarkL |
|
2755 |
// Example test method function. |
|
2756 |
// (other items were commented in a header). |
|
2757 |
// ----------------------------------------------------------------------------- |
|
2758 |
// |
|
2759 |
TInt CTLandmarkProvider::AddLandmarkDbL( CStifItemParser& aItem ) |
|
2760 |
{ |
|
2761 |
// Print to UI |
|
2762 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
2763 |
_LIT( KExample, "In AddLandmarkL" ); |
|
2764 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
2765 |
// Print to log file |
|
2766 |
iLog->Log( KExample ); |
|
2767 |
||
2768 |
__UHEAP_MARK; |
|
2769 |
CLiwServiceHandler* ServiceHandler; |
|
2770 |
CLiwGenericParamList* inps,*outps; |
|
2771 |
MLiwInterface* iIflandmarks; |
|
2772 |
||
2773 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
2774 |
CleanupStack::PushL(ServiceHandler); |
|
2775 |
CleanupClosePushL(*iIflandmarks); |
|
2776 |
||
2777 |
inps = &(ServiceHandler->InParamListL()); |
|
2778 |
outps = &(ServiceHandler->OutParamListL()); |
|
2779 |
||
2780 |
inps->Reset(); |
|
2781 |
outps->Reset(); |
|
2782 |
TInt i = 0; |
|
2783 |
TPtrC string; |
|
2784 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2785 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2786 |
{ |
|
2787 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
2788 |
KParam, i, &string ); |
|
2789 |
i++; |
|
2790 |
} |
|
2791 |
||
2792 |
TLiwGenericParam param; |
|
2793 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
2794 |
inps->AppendL(param); |
|
2795 |
param.Reset(); |
|
2796 |
||
2797 |
_LIT(KName,"Mainland China"); |
|
2798 |
_LIT(KDescription,"Extremely good chinese food"); |
|
2799 |
_LIT(KPhone1,"123456"); |
|
2800 |
TReal64 latitude = 45.1122; |
|
2801 |
TReal64 longitude = 34.0099; |
|
2802 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
2803 |
//db |
|
2804 |
landmarkMap->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
2805 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KName)); |
|
2806 |
CLiwMap* position = CLiwDefaultMap::NewL(); |
|
2807 |
position->InsertL(KLatitude,TLiwVariant(latitude)); |
|
2808 |
position->InsertL(KLongitude,TLiwVariant(longitude)); |
|
2809 |
landmarkMap->InsertL(KLandmarkPosition,TLiwVariant(position)); |
|
2810 |
landmarkMap->InsertL(KLandmarkDesc,TLiwVariant(KDescription)); |
|
2811 |
CLiwMap* landmarkFields = CLiwDefaultMap::NewL(); |
|
2812 |
landmarkFields->InsertL(KLandmarkTelephone,TLiwVariant(KPhone1)); |
|
2813 |
landmarkMap->InsertL(KLandmarkFields,TLiwVariant(landmarkFields)); |
|
2814 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
2815 |
inps->AppendL(param); |
|
2816 |
param.Reset(); |
|
2817 |
landmarkFields->DecRef(); |
|
2818 |
position->DecRef(); |
|
2819 |
landmarkMap->DecRef(); |
|
2820 |
||
2821 |
iIflandmarks->ExecuteCmdL(KAdd,*inps,*outps,0,0); |
|
2822 |
TInt index = 0; |
|
2823 |
TInt32 err = -1; |
|
2824 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
2825 |
//log data |
|
2826 |
RFile LogResult; |
|
2827 |
RFs LogResultSession; |
|
2828 |
User::LeaveIfError(LogResultSession.Connect()); |
|
2829 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
2830 |
{ |
|
2831 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
2832 |
} |
|
2833 |
TInt End = 0 ; |
|
2834 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
2835 |
if( outParam ) |
|
2836 |
{ |
|
2837 |
outParam->Value().Get(err); |
|
2838 |
TBuf8<50> error; |
|
2839 |
TRealFormat format; |
|
2840 |
error.Num(err,format) ; |
|
2841 |
LogResult.Write(_L8("AddLandmarkL Error=")); |
|
2842 |
LogResult.Write(error); |
|
2843 |
LogResult.Write(_L8("\n")); |
|
2844 |
} |
|
2845 |
LogResult.Close(); |
|
2846 |
LogResultSession.Close(); |
|
2847 |
position->DecRef(); |
|
2848 |
landmarkMap->DecRef(); |
|
2849 |
||
2850 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2851 |
ReleaseLandmarkResources(); |
|
2852 |
__UHEAP_MARKEND; |
|
2853 |
return err; |
|
2854 |
||
2855 |
} |
|
2856 |
||
2857 |
// ----------------------------------------------------------------------------- |
|
2858 |
// CTLandmarkProvider::UpdateLandmarkL |
|
2859 |
// Example test method function. |
|
2860 |
// (other items were commented in a header). |
|
2861 |
// ----------------------------------------------------------------------------- |
|
2862 |
// |
|
2863 |
TInt CTLandmarkProvider::UpdateLandmarkDbL( CStifItemParser& aItem ) |
|
2864 |
{ |
|
2865 |
||
2866 |
// Print to UI |
|
2867 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
2868 |
_LIT( KExample, "In Example" ); |
|
2869 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
2870 |
// Print to log file |
|
2871 |
iLog->Log( KExample ); |
|
2872 |
||
2873 |
__UHEAP_MARK; |
|
2874 |
CLiwServiceHandler* ServiceHandler; |
|
2875 |
CLiwGenericParamList* inps,*outps; |
|
2876 |
MLiwInterface* iIflandmarks; |
|
2877 |
||
2878 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
2879 |
CleanupStack::PushL(ServiceHandler); |
|
2880 |
CleanupClosePushL(*iIflandmarks); |
|
2881 |
||
2882 |
inps = &(ServiceHandler->InParamListL()); |
|
2883 |
outps = &(ServiceHandler->OutParamListL()); |
|
2884 |
||
2885 |
inps->Reset(); |
|
2886 |
outps->Reset(); |
|
2887 |
||
2888 |
TInt i = 0; |
|
2889 |
TPtrC string; |
|
2890 |
_LIT( KParam, "Param[%i]: %S" ); |
|
2891 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
2892 |
{ |
|
2893 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
2894 |
KParam, i, &string ); |
|
2895 |
i++; |
|
2896 |
} |
|
2897 |
/*Preconditions*/ |
|
2898 |
_LIT(KName,"3QC"); |
|
2899 |
_LIT(KName1,"Mainland China"); |
|
2900 |
||
2901 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
2902 |
CleanupStack::PushL(db); |
|
2903 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
2904 |
RemoveAllLandmarks(db); |
|
2905 |
||
2906 |
TPosLmItemId lmId; |
|
2907 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
2908 |
lm->SetLandmarkNameL(KName1); |
|
2909 |
lmId = db->AddLandmarkL(*lm); |
|
2910 |
||
2911 |
lm = db->ReadLandmarkLC(lmId); |
|
2912 |
||
2913 |
||
2914 |
TLiwGenericParam param; |
|
2915 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
2916 |
inps->AppendL(param); |
|
2917 |
param.Reset(); |
|
2918 |
||
2919 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
2920 |
//db |
|
2921 |
landmarkMap->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
2922 |
TBuf<5> lmIdString1; |
|
2923 |
lmIdString1.Num(lm->LandmarkId(),EDecimal); |
|
2924 |
landmarkMap->InsertL(KId,TLiwVariant(lmIdString1)); |
|
2925 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KName)); |
|
2926 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
2927 |
inps->AppendL(param); |
|
2928 |
landmarkMap->DecRef(); |
|
2929 |
param.Reset(); |
|
2930 |
||
2931 |
iIflandmarks->ExecuteCmdL(KAdd,*inps,*outps,0,0); |
|
2932 |
TInt index = 0; |
|
2933 |
TInt32 err = -1; |
|
2934 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
2935 |
//log data |
|
2936 |
RFile LogResult; |
|
2937 |
RFs LogResultSession; |
|
2938 |
User::LeaveIfError(LogResultSession.Connect()); |
|
2939 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
2940 |
{ |
|
2941 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
2942 |
} |
|
2943 |
TInt End = 0 ; |
|
2944 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
2945 |
if( outParam ) |
|
2946 |
{ |
|
2947 |
outParam->Value().Get(err); |
|
2948 |
TBuf8<50> error; |
|
2949 |
TRealFormat format; |
|
2950 |
error.Num(err,format) ; |
|
2951 |
LogResult.Write(_L8("UpdateLandmarkL Error=")); |
|
2952 |
LogResult.Write(error); |
|
2953 |
LogResult.Write(_L8("\n")); |
|
2954 |
} |
|
2955 |
LogResult.Close(); |
|
2956 |
LogResultSession.Close(); |
|
2957 |
||
2958 |
||
2959 |
CleanupStack::PopAndDestroy(lm); |
|
2960 |
||
2961 |
CleanupStack::PopAndDestroy(2,db); |
|
2962 |
||
2963 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
2964 |
ReleaseLandmarkResources(); |
|
2965 |
__UHEAP_MARKEND; |
|
2966 |
return err; |
|
2967 |
} |
|
2968 |
||
2969 |
// ----------------------------------------------------------------------------- |
|
2970 |
// CTLandmarkProvider::RemoveLandmarkL |
|
2971 |
// Example test method function. |
|
2972 |
// (other items were commented in a header). |
|
2973 |
// ----------------------------------------------------------------------------- |
|
2974 |
// |
|
2975 |
TInt CTLandmarkProvider::RemoveLandmarkDbL( CStifItemParser& aItem ) |
|
2976 |
{ |
|
2977 |
||
2978 |
// Print to UI |
|
2979 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
2980 |
_LIT( KExample, "In Example" ); |
|
2981 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
2982 |
// Print to log file |
|
2983 |
iLog->Log( KExample ); |
|
2984 |
||
2985 |
__UHEAP_MARK; |
|
2986 |
CLiwServiceHandler* ServiceHandler; |
|
2987 |
CLiwGenericParamList* inps,*outps; |
|
2988 |
MLiwInterface* iIflandmarks; |
|
2989 |
||
2990 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
2991 |
CleanupStack::PushL(ServiceHandler); |
|
2992 |
CleanupClosePushL(*iIflandmarks); |
|
2993 |
||
2994 |
inps = &(ServiceHandler->InParamListL()); |
|
2995 |
outps = &(ServiceHandler->OutParamListL()); |
|
2996 |
||
2997 |
inps->Reset(); |
|
2998 |
outps->Reset(); |
|
2999 |
||
3000 |
TInt i = 0; |
|
3001 |
TPtrC string; |
|
3002 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3003 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3004 |
{ |
|
3005 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
3006 |
KParam, i, &string ); |
|
3007 |
i++; |
|
3008 |
} |
|
3009 |
//preconditions |
|
3010 |
_LIT(KName1,"Mainland China"); |
|
3011 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
3012 |
CleanupStack::PushL(db); |
|
3013 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
3014 |
RemoveAllLandmarks(db); |
|
3015 |
||
3016 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
3017 |
lm->SetLandmarkNameL(KName1); |
|
3018 |
db->AddLandmarkL(*lm); |
|
3019 |
||
3020 |
TLiwGenericParam param; |
|
3021 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
3022 |
inps->AppendL(param); |
|
3023 |
param.Reset(); |
|
3024 |
||
3025 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
3026 |
landmarkMap->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
3027 |
TBuf<5> lmIdString1; |
|
3028 |
lmIdString1.Num(lm->LandmarkId(),EDecimal); |
|
3029 |
landmarkMap->InsertL(KId,TLiwVariant(lmIdString1)); |
|
3030 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
3031 |
inps->AppendL(param); |
|
3032 |
landmarkMap->DecRef(); |
|
3033 |
param.Reset(); |
|
3034 |
||
3035 |
iIflandmarks->ExecuteCmdL(KRemove,*inps,*outps,0,0); |
|
3036 |
TInt index = 0; |
|
3037 |
TInt32 err = -1; |
|
3038 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
3039 |
//log data |
|
3040 |
RFile LogResult; |
|
3041 |
RFs LogResultSession; |
|
3042 |
User::LeaveIfError(LogResultSession.Connect()); |
|
3043 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
3044 |
{ |
|
3045 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
3046 |
} |
|
3047 |
TInt End = 0 ; |
|
3048 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
3049 |
if( outParam ) |
|
3050 |
{ |
|
3051 |
outParam->Value().Get(err); |
|
3052 |
TBuf8<50> error; |
|
3053 |
TRealFormat format; |
|
3054 |
error.Num(err,format) ; |
|
3055 |
LogResult.Write(_L8("RemoveLandmarkL Error=")); |
|
3056 |
LogResult.Write(error); |
|
3057 |
LogResult.Write(_L8("\n")); |
|
3058 |
} |
|
3059 |
LogResult.Close(); |
|
3060 |
LogResultSession.Close(); |
|
3061 |
||
3062 |
||
3063 |
||
3064 |
CleanupStack::PopAndDestroy(2,db); |
|
3065 |
||
3066 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
3067 |
ReleaseLandmarkResources(); |
|
3068 |
__UHEAP_MARKEND; |
|
3069 |
||
3070 |
return err; |
|
3071 |
||
3072 |
} |
|
3073 |
||
3074 |
// ----------------------------------------------------------------------------- |
|
3075 |
// CTLandmarkProvider::ImportLandmarkL |
|
3076 |
// Example test method function. |
|
3077 |
// (other items were commented in a header). |
|
3078 |
// ----------------------------------------------------------------------------- |
|
3079 |
// |
|
3080 |
TInt CTLandmarkProvider::ImportLandmarkDbL( CStifItemParser& aItem ) |
|
3081 |
{ |
|
3082 |
||
3083 |
// Print to UI |
|
3084 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
3085 |
_LIT( KExample, "In Example" ); |
|
3086 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
3087 |
// Print to log file |
|
3088 |
iLog->Log( KExample ); |
|
3089 |
||
3090 |
__UHEAP_MARK; |
|
3091 |
CLiwServiceHandler* ServiceHandler; |
|
3092 |
CLiwGenericParamList* inps,*outps; |
|
3093 |
MLiwInterface* iIflandmarks; |
|
3094 |
||
3095 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
3096 |
CleanupStack::PushL(ServiceHandler); |
|
3097 |
CleanupClosePushL(*iIflandmarks); |
|
3098 |
||
3099 |
inps = &(ServiceHandler->InParamListL()); |
|
3100 |
outps = &(ServiceHandler->OutParamListL()); |
|
3101 |
||
3102 |
inps->Reset(); |
|
3103 |
outps->Reset(); |
|
3104 |
||
3105 |
TInt i = 0; |
|
3106 |
TPtrC string; |
|
3107 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3108 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3109 |
{ |
|
3110 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
3111 |
KParam, i, &string ); |
|
3112 |
i++; |
|
3113 |
} |
|
3114 |
//preconditions |
|
3115 |
_LIT(KFilePath, "c:\\eposLm.lmx"); |
|
3116 |
_LIT8(KPosMimeType, "application/vnd.nokia.landmarkcollection+xml"); |
|
3117 |
_LIT(KPosMimeType1, "application/vnd.nokia.landmarkcollection+xml"); |
|
3118 |
_LIT(KName1,"Mainland China"); |
|
3119 |
_LIT(KName2,"Chung Wah"); |
|
3120 |
_LIT(KName3,"Aromas of China"); |
|
3121 |
||
3122 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
3123 |
CleanupStack::PushL(db); |
|
3124 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
3125 |
RemoveAllLandmarks(db); |
|
3126 |
||
3127 |
TPosLmItemId lmId; |
|
3128 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
3129 |
lm->SetLandmarkNameL(KName1); |
|
3130 |
db->AddLandmarkL(*lm); |
|
3131 |
lm->SetLandmarkNameL(KName2); |
|
3132 |
db->AddLandmarkL(*lm); |
|
3133 |
lm->SetLandmarkNameL(KName3); |
|
3134 |
db->AddLandmarkL(*lm); |
|
3135 |
||
3136 |
CPosLmItemIterator* iterLm = db->LandmarkIteratorL(); |
|
3137 |
CleanupStack::PushL(iterLm); |
|
3138 |
||
3139 |
CPosLandmarkEncoder* encoder = CPosLandmarkEncoder::NewL(KPosMimeType); |
|
3140 |
CleanupStack::PushL(encoder); |
|
3141 |
TRAPD(err,encoder->SetOutputFileL(KFilePath)); |
|
3142 |
if(KErrAlreadyExists == err) |
|
3143 |
{ |
|
3144 |
RFs fs; |
|
3145 |
CleanupClosePushL(fs); |
|
3146 |
User::LeaveIfError(fs.Connect()); |
|
3147 |
fs.Delete(KFilePath); |
|
3148 |
encoder->SetOutputFileL(KFilePath); |
|
3149 |
CleanupStack::PopAndDestroy(); |
|
3150 |
} |
|
3151 |
||
3152 |
RArray<TPosLmItemId> landmarks; |
|
3153 |
CleanupClosePushL(landmarks); |
|
3154 |
||
3155 |
||
3156 |
while ((lmId = iterLm->NextL()) != KPosLmNullItemId) |
|
3157 |
{ |
|
3158 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
3159 |
} |
|
3160 |
||
3161 |
ExecuteAndDeleteLD(db->ExportLandmarksL(*encoder,landmarks,CPosLandmarkDatabase::EIncludeCategories)); |
|
3162 |
ExecuteAndDeleteLD(encoder->FinalizeEncodingL()); |
|
3163 |
CleanupStack::PopAndDestroy(3,iterLm); |
|
3164 |
||
3165 |
||
3166 |
TLiwGenericParam param; |
|
3167 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
3168 |
inps->AppendL(param); |
|
3169 |
param.Reset(); |
|
3170 |
||
3171 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
3172 |
landmarkMap->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
3173 |
landmarkMap->InsertL(KSourceFile,TLiwVariant(KFilePath)); |
|
3174 |
landmarkMap->InsertL(KMimeType,TLiwVariant(KPosMimeType1)); |
|
3175 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
3176 |
inps->AppendL(param); |
|
3177 |
landmarkMap->DecRef(); |
|
3178 |
param.Reset(); |
|
3179 |
||
3180 |
iIflandmarks->ExecuteCmdL(KImport,*inps,*outps,0,0); |
|
3181 |
TInt index = 0; |
|
3182 |
TInt32 err2 = -1; |
|
3183 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
3184 |
//log data |
|
3185 |
RFile LogResult; |
|
3186 |
RFs LogResultSession; |
|
3187 |
User::LeaveIfError(LogResultSession.Connect()); |
|
3188 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
3189 |
{ |
|
3190 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
3191 |
} |
|
3192 |
TInt End = 0 ; |
|
3193 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
3194 |
if( outParam ) |
|
3195 |
{ |
|
3196 |
outParam->Value().Get(err2); |
|
3197 |
TBuf8<50> error; |
|
3198 |
TRealFormat format; |
|
3199 |
error.Num(err2,format) ; |
|
3200 |
LogResult.Write(_L8("ImportLandmarkL Error=")); |
|
3201 |
LogResult.Write(error); |
|
3202 |
LogResult.Write(_L8("\n")); |
|
3203 |
index = 0; |
|
3204 |
outParam = outps->FindFirst(index,KReturnValue); |
|
3205 |
if( outParam ) |
|
3206 |
{ |
|
3207 |
CLiwIterable* iterable = outParam->Value().AsIterable(); |
|
3208 |
if( iterable ) |
|
3209 |
{ |
|
3210 |
TLiwVariant lmVariant; |
|
3211 |
while( iterable->NextL(lmVariant) ) |
|
3212 |
{ |
|
3213 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
3214 |
TLiwVariant variantField; |
|
3215 |
TPtrC landmarkName; |
|
3216 |
if( landmark ) |
|
3217 |
{ |
|
3218 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
3219 |
{ |
|
3220 |
variantField.Get(landmarkName); |
|
3221 |
} |
|
3222 |
} |
|
3223 |
variantField.Reset(); |
|
3224 |
lmVariant.Reset(); |
|
3225 |
} |
|
3226 |
} |
|
3227 |
||
3228 |
} |
|
3229 |
} |
|
3230 |
LogResult.Close(); |
|
3231 |
LogResultSession.Close(); |
|
3232 |
CleanupStack::PopAndDestroy(2,db); |
|
3233 |
ReleaseLandmarkResources(); |
|
3234 |
inps->Reset(); |
|
3235 |
outps->Reset(); |
|
3236 |
||
3237 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
3238 |
ReleaseLandmarkResources(); |
|
3239 |
__UHEAP_MARKEND; |
|
3240 |
return err2; |
|
3241 |
||
3242 |
} |
|
3243 |
||
3244 |
// ----------------------------------------------------------------------------- |
|
3245 |
// CTLandmarkProvider::ExportLandmarkL |
|
3246 |
// Example test method function. |
|
3247 |
// (other items were commented in a header). |
|
3248 |
// ----------------------------------------------------------------------------- |
|
3249 |
// |
|
3250 |
TInt CTLandmarkProvider::ExportLandmarkDbL( CStifItemParser& aItem ) |
|
3251 |
{ |
|
3252 |
||
3253 |
// Print to UI |
|
3254 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
3255 |
_LIT( KExample, "In Example" ); |
|
3256 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
3257 |
// Print to log file |
|
3258 |
iLog->Log( KExample ); |
|
3259 |
||
3260 |
__UHEAP_MARK; |
|
3261 |
CLiwServiceHandler* ServiceHandler; |
|
3262 |
CLiwGenericParamList* inps,*outps; |
|
3263 |
MLiwInterface* iIflandmarks; |
|
3264 |
||
3265 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
3266 |
CleanupStack::PushL(ServiceHandler); |
|
3267 |
CleanupClosePushL(*iIflandmarks); |
|
3268 |
||
3269 |
inps = &(ServiceHandler->InParamListL()); |
|
3270 |
outps = &(ServiceHandler->OutParamListL()); |
|
3271 |
||
3272 |
inps->Reset(); |
|
3273 |
outps->Reset(); |
|
3274 |
||
3275 |
TInt i = 0; |
|
3276 |
TPtrC string; |
|
3277 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3278 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3279 |
{ |
|
3280 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
3281 |
KParam, i, &string ); |
|
3282 |
i++; |
|
3283 |
} |
|
3284 |
//preconditions |
|
3285 |
_LIT(KFilePath, "c:\\eposLmTest.lmx"); |
|
3286 |
_LIT(KPosMimeType, "application/vnd.nokia.landmarkcollection+xml"); |
|
3287 |
_LIT(KName1,"Mainland China"); |
|
3288 |
_LIT(KName2,"Chung Wah"); |
|
3289 |
_LIT(KName3,"Aromas of China"); |
|
3290 |
||
3291 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
3292 |
CleanupStack::PushL(db); |
|
3293 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
3294 |
RemoveAllLandmarks(db); |
|
3295 |
||
3296 |
TPosLmItemId lmId; |
|
3297 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
3298 |
lm->SetLandmarkNameL(KName1); |
|
3299 |
db->AddLandmarkL(*lm); |
|
3300 |
lm->SetLandmarkNameL(KName2); |
|
3301 |
db->AddLandmarkL(*lm); |
|
3302 |
lm->SetLandmarkNameL(KName3); |
|
3303 |
db->AddLandmarkL(*lm); |
|
3304 |
||
3305 |
CPosLmItemIterator* iterLm = db->LandmarkIteratorL(); |
|
3306 |
CleanupStack::PushL(iterLm); |
|
3307 |
||
3308 |
RFs fs; |
|
3309 |
CleanupClosePushL(fs); |
|
3310 |
User::LeaveIfError(fs.Connect()); |
|
3311 |
fs.Delete(KFilePath); |
|
3312 |
CleanupStack::PopAndDestroy(); |
|
3313 |
||
3314 |
||
3315 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
3316 |
RPointerArray<HBufC> lmIdArray; |
|
3317 |
while ((lmId = iterLm->NextL()) != KPosLmNullItemId) |
|
3318 |
{ |
|
3319 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
3320 |
HBufC* lmIdString = HBufC::NewLC(5); |
|
3321 |
lmIdArray.AppendL(lmIdString); |
|
3322 |
CleanupStack::Pop(lmIdString); |
|
3323 |
lmIdString->Des().Num(lmId,EDecimal); |
|
3324 |
landmarkIdList->AppendL(TLiwVariant(lmIdString)); |
|
3325 |
} |
|
3326 |
||
3327 |
CleanupStack::PopAndDestroy(3,db); |
|
3328 |
ReleaseLandmarkResources(); |
|
3329 |
||
3330 |
||
3331 |
||
3332 |
TLiwGenericParam param; |
|
3333 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
3334 |
inps->AppendL(param); |
|
3335 |
param.Reset(); |
|
3336 |
||
3337 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
3338 |
landmarkMap->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
3339 |
landmarkMap->InsertL(KDestinationFile,TLiwVariant(KFilePath)); |
|
3340 |
landmarkMap->InsertL(KMimeType,TLiwVariant(KPosMimeType)); |
|
3341 |
||
3342 |
landmarkMap->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
3343 |
landmarkIdList->DecRef(); |
|
3344 |
param.SetNameAndValueL(KDataFields,TLiwVariant(landmarkMap)); |
|
3345 |
inps->AppendL(param); |
|
3346 |
landmarkMap->DecRef(); |
|
3347 |
param.Reset(); |
|
3348 |
||
3349 |
iIflandmarks->ExecuteCmdL(KExport,*inps,*outps,0,0); |
|
3350 |
lmIdArray.ResetAndDestroy(); |
|
3351 |
lmIdArray.Close(); |
|
3352 |
TInt index = 0; |
|
3353 |
TInt32 err = -1; |
|
3354 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
3355 |
//log data |
|
3356 |
RFile LogResult; |
|
3357 |
RFs LogResultSession; |
|
3358 |
User::LeaveIfError(LogResultSession.Connect()); |
|
3359 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
3360 |
{ |
|
3361 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
3362 |
} |
|
3363 |
TInt End = 0 ; |
|
3364 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
3365 |
if( outParam ) |
|
3366 |
{ |
|
3367 |
outParam->Value().Get(err); |
|
3368 |
TBuf8<50> error; |
|
3369 |
TRealFormat format; |
|
3370 |
error.Num(err,format) ; |
|
3371 |
LogResult.Write(_L8("ExportLandmarkL Error=")); |
|
3372 |
LogResult.Write(error); |
|
3373 |
LogResult.Write(_L8("\n")); |
|
3374 |
} |
|
3375 |
||
3376 |
LogResult.Close(); |
|
3377 |
LogResultSession.Close(); |
|
3378 |
||
3379 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
3380 |
ReleaseLandmarkResources(); |
|
3381 |
__UHEAP_MARKEND; |
|
3382 |
||
3383 |
return err; |
|
3384 |
||
3385 |
} |
|
3386 |
||
3387 |
// ----------------------------------------------------------------------------- |
|
3388 |
// CTLandmarkProvider::LinkCategoryL |
|
3389 |
// Example test method function. |
|
3390 |
// (other items were commented in a header). |
|
3391 |
// ----------------------------------------------------------------------------- |
|
3392 |
// |
|
3393 |
TInt CTLandmarkProvider::LinkCategoryDbL( CStifItemParser& aItem ) |
|
3394 |
{ |
|
3395 |
||
3396 |
// Print to UI |
|
3397 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
3398 |
_LIT( KExample, "In Example" ); |
|
3399 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
3400 |
// Print to log file |
|
3401 |
iLog->Log( KExample ); |
|
3402 |
||
3403 |
__UHEAP_MARK; |
|
3404 |
CLiwServiceHandler* ServiceHandler; |
|
3405 |
CLiwGenericParamList* inps,*outps; |
|
3406 |
MLiwInterface* iIflandmarks; |
|
3407 |
||
3408 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
3409 |
CleanupStack::PushL(ServiceHandler); |
|
3410 |
CleanupClosePushL(*iIflandmarks); |
|
3411 |
||
3412 |
inps = &(ServiceHandler->InParamListL()); |
|
3413 |
outps = &(ServiceHandler->OutParamListL()); |
|
3414 |
||
3415 |
inps->Reset(); |
|
3416 |
outps->Reset(); |
|
3417 |
TInt i = 0; |
|
3418 |
TPtrC string; |
|
3419 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3420 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3421 |
{ |
|
3422 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
3423 |
KParam, i, &string ); |
|
3424 |
i++; |
|
3425 |
} |
|
3426 |
/*Preconditions*/ |
|
3427 |
_LIT(KOffice1,"NokiaPrevious"); |
|
3428 |
_LIT(KName1,"Mainland China"); |
|
3429 |
_LIT(KName2,"Chung Wah"); |
|
3430 |
_LIT(KName3,"Aromas of China"); |
|
3431 |
||
3432 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
3433 |
CleanupStack::PushL(db); |
|
3434 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
3435 |
||
3436 |
TPosLmItemId lmId; |
|
3437 |
//RArray<TPosLmItemId> landmarks; |
|
3438 |
//CleanupClosePushL(landmarks); |
|
3439 |
||
3440 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
3441 |
||
3442 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
3443 |
lm->SetLandmarkNameL(KName1); |
|
3444 |
lmId = db->AddLandmarkL(*lm); |
|
3445 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
3446 |
TBuf<5> lmIdString1; |
|
3447 |
lmIdString1.Num(lmId,EDecimal); |
|
3448 |
landmarkIdList->AppendL(TLiwVariant(lmIdString1)); |
|
3449 |
lm->SetLandmarkNameL(KName2); |
|
3450 |
lmId = db->AddLandmarkL(*lm); |
|
3451 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
3452 |
TBuf<5> lmIdString2; |
|
3453 |
lmIdString2.Num(lmId,EDecimal); |
|
3454 |
landmarkIdList->AppendL(TLiwVariant(lmIdString2)); |
|
3455 |
lm->SetLandmarkNameL(KName3); |
|
3456 |
lmId = db->AddLandmarkL(*lm); |
|
3457 |
//User::LeaveIfError(landmarks.Append(lmId)); |
|
3458 |
TBuf<5> lmIdString3; |
|
3459 |
lmIdString3.Num(lmId,EDecimal); |
|
3460 |
landmarkIdList->AppendL(TLiwVariant(lmIdString3)); |
|
3461 |
||
3462 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
3463 |
CleanupStack::PushL(catManager); |
|
3464 |
RemoveAllCategories(catManager); |
|
3465 |
||
3466 |
TPosLmItemId catId; |
|
3467 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
3468 |
category->SetCategoryNameL(KOffice1); |
|
3469 |
catId = catManager->AddCategoryL(*category); |
|
3470 |
TBuf<5> catIdString; |
|
3471 |
catIdString.Num(catId,EDecimal); |
|
3472 |
CleanupStack::PopAndDestroy(4,db); |
|
3473 |
ReleaseLandmarkResources(); |
|
3474 |
||
3475 |
||
3476 |
TLiwGenericParam param; |
|
3477 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
3478 |
inps->AppendL(param); |
|
3479 |
param.Reset(); |
|
3480 |
||
3481 |
CLiwMap* map = CLiwDefaultMap::NewL(); |
|
3482 |
map->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
3483 |
map->InsertL(KId,TLiwVariant(catIdString)); |
|
3484 |
map->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
3485 |
landmarkIdList->DecRef(); |
|
3486 |
param.SetNameAndValueL(KDataFields,TLiwVariant(map)); |
|
3487 |
inps->AppendL(param); |
|
3488 |
map->DecRef(); |
|
3489 |
param.Reset(); |
|
3490 |
||
3491 |
param.SetNameAndValueL(KOperationType,TLiwVariant(KAssociate)); |
|
3492 |
inps->AppendL(param); |
|
3493 |
param.Reset(); |
|
3494 |
||
3495 |
iIflandmarks->ExecuteCmdL(KOrganise,*inps,*outps,0,0); |
|
3496 |
TInt index = 0; |
|
3497 |
TInt32 err = -1; |
|
3498 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
3499 |
//log data |
|
3500 |
RFile LogResult; |
|
3501 |
RFs LogResultSession; |
|
3502 |
User::LeaveIfError(LogResultSession.Connect()); |
|
3503 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
3504 |
{ |
|
3505 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
3506 |
} |
|
3507 |
TInt End = 0 ; |
|
3508 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
3509 |
if( outParam ) |
|
3510 |
{ |
|
3511 |
outParam->Value().Get(err); |
|
3512 |
TBuf8<50> error; |
|
3513 |
TRealFormat format; |
|
3514 |
error.Num(err,format) ; |
|
3515 |
LogResult.Write(_L8("LinkCategoryL Error=")); |
|
3516 |
LogResult.Write(error); |
|
3517 |
LogResult.Write(_L8("\n")); |
|
3518 |
} |
|
3519 |
LogResult.Close(); |
|
3520 |
LogResultSession.Close(); |
|
3521 |
||
3522 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
3523 |
ReleaseLandmarkResources(); |
|
3524 |
__UHEAP_MARKEND; |
|
3525 |
||
3526 |
return err; |
|
3527 |
} |
|
3528 |
||
3529 |
// ----------------------------------------------------------------------------- |
|
3530 |
// CTLandmarkProvider::UnLinkCategoryL |
|
3531 |
// Example test method function. |
|
3532 |
// (other items were commented in a header). |
|
3533 |
// ----------------------------------------------------------------------------- |
|
3534 |
// |
|
3535 |
TInt CTLandmarkProvider::UnLinkCategoryDbL( CStifItemParser& aItem ) |
|
3536 |
{ |
|
3537 |
||
3538 |
// Print to UI |
|
3539 |
_LIT( KTLandmarkProvider, "TLandmarkProvider" ); |
|
3540 |
_LIT( KExample, "In Example" ); |
|
3541 |
TestModuleIf().Printf( 0, KTLandmarkProvider, KExample ); |
|
3542 |
// Print to log file |
|
3543 |
iLog->Log( KExample ); |
|
3544 |
||
3545 |
__UHEAP_MARK; |
|
3546 |
CLiwServiceHandler* ServiceHandler; |
|
3547 |
CLiwGenericParamList* inps,*outps; |
|
3548 |
MLiwInterface* iIflandmarks; |
|
3549 |
||
3550 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
3551 |
CleanupStack::PushL(ServiceHandler); |
|
3552 |
CleanupClosePushL(*iIflandmarks); |
|
3553 |
||
3554 |
inps = &(ServiceHandler->InParamListL()); |
|
3555 |
outps = &(ServiceHandler->OutParamListL()); |
|
3556 |
||
3557 |
inps->Reset(); |
|
3558 |
outps->Reset(); |
|
3559 |
||
3560 |
TInt i = 0; |
|
3561 |
TPtrC string; |
|
3562 |
_LIT( KParam, "Param[%i]: %S" ); |
|
3563 |
while ( aItem.GetNextString ( string ) == KErrNone ) |
|
3564 |
{ |
|
3565 |
TestModuleIf().Printf( i, KTLandmarkProvider, |
|
3566 |
KParam, i, &string ); |
|
3567 |
i++; |
|
3568 |
} |
|
3569 |
/*Preconditions*/ |
|
3570 |
_LIT(KOffice1,"NokiaPrevious"); |
|
3571 |
_LIT(KName1,"Mainland China"); |
|
3572 |
_LIT(KName2,"Chung Wah"); |
|
3573 |
_LIT(KName3,"Aromas of China"); |
|
3574 |
||
3575 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
3576 |
CleanupStack::PushL(db); |
|
3577 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
3578 |
||
3579 |
TPosLmItemId lmId; |
|
3580 |
RArray<TPosLmItemId> landmarks; |
|
3581 |
CleanupClosePushL(landmarks); |
|
3582 |
CLiwList* landmarkIdList = CLiwDefaultList::NewL(); |
|
3583 |
||
3584 |
CPosLandmark* lm = CPosLandmark::NewLC(); |
|
3585 |
lm->SetLandmarkNameL(KName1); |
|
3586 |
lmId = db->AddLandmarkL(*lm); |
|
3587 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
3588 |
TBuf<5> lmIdString1; |
|
3589 |
lmIdString1.Num(lmId,EDecimal); |
|
3590 |
landmarkIdList->AppendL(TLiwVariant(lmIdString1)); |
|
3591 |
lm->SetLandmarkNameL(KName2); |
|
3592 |
lmId = db->AddLandmarkL(*lm); |
|
3593 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
3594 |
TBuf<5> lmIdString2; |
|
3595 |
lmIdString2.Num(lmId,EDecimal); |
|
3596 |
landmarkIdList->AppendL(TLiwVariant(lmIdString2)); |
|
3597 |
lm->SetLandmarkNameL(KName3); |
|
3598 |
lmId = db->AddLandmarkL(*lm); |
|
3599 |
User::LeaveIfError(landmarks.Append(lmId)); |
|
3600 |
TBuf<5> lmIdString3; |
|
3601 |
lmIdString3.Num(lmId,EDecimal); |
|
3602 |
landmarkIdList->AppendL(TLiwVariant(lmIdString3)); |
|
3603 |
CPosLmCategoryManager* catManager= CPosLmCategoryManager::NewL(*db); |
|
3604 |
CleanupStack::PushL(catManager); |
|
3605 |
RemoveAllCategories(catManager); |
|
3606 |
||
3607 |
TPosLmItemId catId; |
|
3608 |
CPosLandmarkCategory* category = CPosLandmarkCategory::NewLC(); |
|
3609 |
category->SetCategoryNameL(KOffice1); |
|
3610 |
catId = catManager->AddCategoryL(*category); |
|
3611 |
ExecuteAndDeleteLD(catManager->AddCategoryToLandmarksL(catId,landmarks)); |
|
3612 |
TBuf<5> catIdString; |
|
3613 |
catIdString.Num(catId,EDecimal); |
|
3614 |
||
3615 |
CleanupStack::PopAndDestroy(5,db); |
|
3616 |
ReleaseLandmarkResources(); |
|
3617 |
||
3618 |
||
3619 |
TLiwGenericParam param; |
|
3620 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
3621 |
inps->AppendL(param); |
|
3622 |
param.Reset(); |
|
3623 |
||
3624 |
CLiwMap* map = CLiwDefaultMap::NewL(); |
|
3625 |
map->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
3626 |
map->InsertL(KId,TLiwVariant(catIdString)); |
|
3627 |
map->InsertL(KIdList,TLiwVariant(landmarkIdList)); |
|
3628 |
landmarkIdList->DecRef(); |
|
3629 |
param.SetNameAndValueL(KDataFields,TLiwVariant(map)); |
|
3630 |
inps->AppendL(param); |
|
3631 |
map->DecRef(); |
|
3632 |
param.Reset(); |
|
3633 |
||
3634 |
param.SetNameAndValueL(KOperationType,TLiwVariant(KDisassociate)); |
|
3635 |
inps->AppendL(param); |
|
3636 |
param.Reset(); |
|
3637 |
||
3638 |
iIflandmarks->ExecuteCmdL(KOrganise,*inps,*outps,0,0); |
|
3639 |
TInt index = 0; |
|
3640 |
TInt32 err = -1; |
|
3641 |
const TLiwGenericParam* outParam = outps->FindFirst(index,KErrorCode); |
|
3642 |
//log data |
|
3643 |
RFile LogResult; |
|
3644 |
RFs LogResultSession; |
|
3645 |
User::LeaveIfError(LogResultSession.Connect()); |
|
3646 |
if(LogResult.Open(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) == KErrNotFound) |
|
3647 |
{ |
|
3648 |
TInt err1 = LogResult.Create(LogResultSession ,_L("c:\\testlog1.txt") , EFileWrite | EFileShareAny ) ; |
|
3649 |
} |
|
3650 |
TInt End = 0 ; |
|
3651 |
LogResult.Seek(ESeekEnd , End) ; //Seek to end of the file before writing |
|
3652 |
if( outParam ) |
|
3653 |
{ |
|
3654 |
outParam->Value().Get(err); |
|
3655 |
TBuf8<50> error; |
|
3656 |
TRealFormat format; |
|
3657 |
error.Num(err,format) ; |
|
3658 |
LogResult.Write(_L8("UnLinkCategoryL Error=")); |
|
3659 |
LogResult.Write(error); |
|
3660 |
LogResult.Write(_L8("\n")); |
|
3661 |
} |
|
3662 |
LogResult.Close(); |
|
3663 |
LogResultSession.Close(); |
|
3664 |
||
3665 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
3666 |
ReleaseLandmarkResources(); |
|
3667 |
__UHEAP_MARKEND; |
|
3668 |
return err; |
|
3669 |
} |
|
3670 |
||
3671 |
// ----------------------------------------------------------------------------- |
|
3672 |
// CTLandmarkProvider::LandmarksSyncTest1 |
|
3673 |
// Helper method to remove all landmarks for preconditional tests. |
|
3674 |
// ----------------------------------------------------------------------------- |
|
3675 |
// |
|
3676 |
TInt CTLandmarkProvider::LandmarksSyncTest1DbL ( CStifItemParser& /*aItem*/ ) |
|
3677 |
{ |
|
3678 |
_LIT( KExample, "LandmarksSyncTest1" ); |
|
3679 |
iLog->Log( KExample ); |
|
3680 |
||
3681 |
__UHEAP_MARK; |
|
3682 |
CLiwServiceHandler* ServiceHandler; |
|
3683 |
CLiwGenericParamList* inps,*outps; |
|
3684 |
MLiwInterface* iIflandmarks; |
|
3685 |
||
3686 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
3687 |
CleanupStack::PushL(ServiceHandler); |
|
3688 |
CleanupClosePushL(*iIflandmarks); |
|
3689 |
||
3690 |
inps = &(ServiceHandler->InParamListL()); |
|
3691 |
outps = &(ServiceHandler->OutParamListL()); |
|
3692 |
||
3693 |
inps->Reset(); |
|
3694 |
outps->Reset(); |
|
3695 |
||
3696 |
TInt32 err; |
|
3697 |
TInt ret = 0; |
|
3698 |
||
3699 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
3700 |
CleanupStack::PushL(db); |
|
3701 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
3702 |
RemoveAllLandmarks(db); |
|
3703 |
CreateLandmarksL(db); |
|
3704 |
CleanupStack::PopAndDestroy(db); |
|
3705 |
||
3706 |
||
3707 |
TLiwGenericParam param; |
|
3708 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
3709 |
inps->AppendL(param); |
|
3710 |
param.Reset(); |
|
3711 |
||
3712 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
3713 |
landmarkMap->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
3714 |
landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString)); |
|
3715 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
3716 |
inps->AppendL(param); |
|
3717 |
landmarkMap->DecRef(); |
|
3718 |
param.Reset(); |
|
3719 |
||
3720 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,0,0); |
|
3721 |
ret |= CheckErrorCode (*outps,err); |
|
3722 |
if ( err != KErrNone ) |
|
3723 |
{ |
|
3724 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
3725 |
ret |= FAIL; |
|
3726 |
} |
|
3727 |
||
3728 |
TInt Index = 0; |
|
3729 |
const TLiwGenericParam* itr = outps->FindFirst(Index,KReturnValue); |
|
3730 |
if ( Index > 0 || (0 == Index) ) |
|
3731 |
{ |
|
3732 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
3733 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
3734 |
if( iter ) |
|
3735 |
{ |
|
3736 |
TLiwVariant lmVariant; |
|
3737 |
while( iter->NextL(lmVariant) ) |
|
3738 |
{ |
|
3739 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
3740 |
TLiwVariant variantField; |
|
3741 |
TPtrC landmarkName; |
|
3742 |
if( landmark ) |
|
3743 |
{ |
|
3744 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
3745 |
{ |
|
3746 |
variantField.Get(landmarkName); |
|
3747 |
} |
|
3748 |
||
3749 |
} |
|
3750 |
variantField.Reset(); |
|
3751 |
lmVariant.Reset(); |
|
3752 |
} |
|
3753 |
} |
|
3754 |
||
3755 |
} |
|
3756 |
inps->Reset(); |
|
3757 |
outps->Reset(); |
|
3758 |
||
3759 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
3760 |
ReleaseLandmarkResources(); |
|
3761 |
__UHEAP_MARKEND; |
|
3762 |
return err; |
|
3763 |
} |
|
3764 |
||
3765 |
// ----------------------------------------------------------------------------- |
|
3766 |
// CTLandmarkProvider::LandmarksAsyncTest1 |
|
3767 |
// Helper method to remove all landmarks for preconditional tests. |
|
3768 |
// ----------------------------------------------------------------------------- |
|
3769 |
// |
|
3770 |
TInt CTLandmarkProvider::LandmarksAsyncTest1DbL ( CStifItemParser& /*aItem*/ ) |
|
3771 |
{ |
|
3772 |
_LIT( KExample, "LandmarksAsyncTest1" ); |
|
3773 |
iLog->Log( KExample ); |
|
3774 |
||
3775 |
TInt32 err; |
|
3776 |
TInt ret = 0; |
|
3777 |
||
3778 |
__UHEAP_MARK; |
|
3779 |
CLiwServiceHandler* ServiceHandler; |
|
3780 |
CLiwGenericParamList* inps,*outps; |
|
3781 |
MLiwInterface* iIflandmarks; |
|
3782 |
||
3783 |
CreateInterfaceL(ServiceHandler,iIflandmarks); |
|
3784 |
CleanupStack::PushL(ServiceHandler); |
|
3785 |
CleanupClosePushL(*iIflandmarks); |
|
3786 |
||
3787 |
inps = &(ServiceHandler->InParamListL()); |
|
3788 |
outps = &(ServiceHandler->OutParamListL()); |
|
3789 |
||
3790 |
inps->Reset(); |
|
3791 |
outps->Reset(); |
|
3792 |
||
3793 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(KTestDbUri); |
|
3794 |
CleanupStack::PushL(db); |
|
3795 |
ExecuteAndDeleteLD(db->InitializeL()); |
|
3796 |
RemoveAllLandmarks(db); |
|
3797 |
CreateLandmarksL(db); |
|
3798 |
CleanupStack::PopAndDestroy(db); |
|
3799 |
||
3800 |
||
3801 |
TLiwGenericParam param; |
|
3802 |
param.SetNameAndValueL(KContentType,TLiwVariant(KLandmark)); |
|
3803 |
inps->AppendL(param); |
|
3804 |
param.Reset(); |
|
3805 |
||
3806 |
CLiwMap* landmarkMap = CLiwDefaultMap::NewL(); |
|
3807 |
landmarkMap->InsertL(KDbUri,TLiwVariant(KTestDbUri)); |
|
3808 |
// landmarkMap->InsertL(KLandmarkName,TLiwVariant(KLmSearchString)); |
|
3809 |
param.SetNameAndValueL(KFilter,TLiwVariant(landmarkMap)); |
|
3810 |
inps->AppendL(param); |
|
3811 |
landmarkMap->DecRef(); |
|
3812 |
param.Reset(); |
|
3813 |
||
3814 |
iIflandmarks->ExecuteCmdL(KGetList,*inps,*outps,KLiwOptASyncronous,this); |
|
3815 |
ret |= CheckErrorCode (*outps,err); |
|
3816 |
if ( err != KErrNone ) |
|
3817 |
{ |
|
3818 |
iLog->Log( _L(" Getlist on database failed wiht err...") ); |
|
3819 |
ret |= FAIL; |
|
3820 |
} |
|
3821 |
||
3822 |
if ( !ret ) |
|
3823 |
CActiveScheduler::Start(); |
|
3824 |
||
3825 |
CleanupStack::PopAndDestroy(2,ServiceHandler); |
|
3826 |
ReleaseLandmarkResources(); |
|
3827 |
__UHEAP_MARKEND; |
|
3828 |
return ret; |
|
3829 |
} |
|
3830 |
// ----------------------------------------------------------------------------- |
|
3831 |
// CTLandmarkProvider::HandleNotifyL |
|
3832 |
// This gets called on completion of async request. |
|
3833 |
// ----------------------------------------------------------------------------- |
|
3834 |
// |
|
3835 |
TInt CTLandmarkProvider::HandleNotifyL( |
|
3836 |
TInt /*aCmdId*/, |
|
3837 |
TInt /*aEventId*/, |
|
3838 |
CLiwGenericParamList& aEventParamList, |
|
3839 |
const CLiwGenericParamList& /*aInputParam*/) |
|
3840 |
{ |
|
3841 |
TInt Index = 0; |
|
3842 |
const TLiwGenericParam* itr = aEventParamList.FindFirst(Index,KReturnValue); |
|
3843 |
if ( Index > 0 || (0 == Index) ) |
|
3844 |
{ |
|
3845 |
iLog->Log( _L("Database iterator found in output ArgList") ); |
|
3846 |
CLiwIterable* iter = itr->Value().AsIterable(); |
|
3847 |
if( iter ) |
|
3848 |
{ |
|
3849 |
TLiwVariant lmVariant; |
|
3850 |
while( iter->NextL(lmVariant) ) |
|
3851 |
{ |
|
3852 |
const CLiwMap* landmark = lmVariant.AsMap(); |
|
3853 |
TLiwVariant variantField; |
|
3854 |
TPtrC landmarkName; |
|
3855 |
if( landmark ) |
|
3856 |
{ |
|
3857 |
if( landmark->FindL(KLandmarkName,variantField) ) |
|
3858 |
{ |
|
3859 |
variantField.Get(landmarkName); |
|
3860 |
} |
|
3861 |
} |
|
3862 |
variantField.Reset(); |
|
3863 |
lmVariant.Reset(); |
|
3864 |
} |
|
3865 |
} |
|
3866 |
iter->DecRef(); |
|
3867 |
} |
|
3868 |
||
3869 |
CActiveScheduler::Stop(); |
|
3870 |
return KErrNone; |
|
3871 |
} |
|
3872 |
||
3873 |
// ----------------------------------------------------------------------------- |
|
3874 |
// CTLandmarkProvider::CreateLandmarksL |
|
3875 |
// Helper method to add landmarks to a default database. |
|
3876 |
// ----------------------------------------------------------------------------- |
|
3877 |
// |
|
3878 |
void CTLandmarkProvider::CreateLandmarksL (CPosLandmarkDatabase* aLandmarkHandle) |
|
3879 |
{ |
|
3880 |
CPosLandmark* lm = CPosLandmark::NewLC (); |
|
3881 |
_LIT(KStreet,"broadway"); |
|
3882 |
// _LIT(KIconFile,"//s60//icons//qgn_graf_s60_logo.svg"); |
|
3883 |
_LIT(KDesc,"welcome to galactica"); |
|
3884 |
TPosition locale; |
|
3885 |
locale.SetCoordinate(12.345,67.89); |
|
3886 |
lm->SetLandmarkNameL(KLmName1); |
|
3887 |
lm->SetPositionL(locale); |
|
3888 |
lm->SetCoverageRadius(12.345); |
|
3889 |
lm->SetPositionFieldL(EPositionFieldStreet,KStreet); |
|
3890 |
lm->SetLandmarkDescriptionL(KDesc); |
|
3891 |
aLandmarkHandle->AddLandmarkL(*lm); |
|
3892 |
CleanupStack::PopAndDestroy(lm); |
|
3893 |
lm = CPosLandmark::NewLC (); |
|
3894 |
lm->SetLandmarkNameL (KLmName2); |
|
3895 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
3896 |
||
3897 |
lm->SetLandmarkNameL (KLmName3); |
|
3898 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
3899 |
||
3900 |
lm->SetLandmarkNameL (KLmName4); |
|
3901 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
3902 |
||
3903 |
lm->SetLandmarkNameL (KLmName5); |
|
3904 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
3905 |
||
3906 |
lm->SetLandmarkNameL (KLmName6); |
|
3907 |
aLandmarkHandle->AddLandmarkL (*lm); |
|
3908 |
||
3909 |
CleanupStack::PopAndDestroy(lm); |
|
3910 |
} |
|
3911 |
||
3912 |
// ----------------------------------------------------------------------------- |
|
3913 |
// CTLandmarkProvider::CheckErrorCode |
|
3914 |
// checks error code e |
|
3915 |
// called by all testcases. |
|
3916 |
// ----------------------------------------------------------------------------- |
|
3917 |
// |
|
3918 |
TInt CTLandmarkProvider::CheckErrorCode( const CLiwGenericParamList& aOutList, TInt32& aError ) const |
|
3919 |
{ |
|
3920 |
TInt Index = 0; |
|
3921 |
const TLiwGenericParam* errcode = aOutList.FindFirst(Index,KErrorCode); |
|
3922 |
if ( KErrNotFound == Index ) |
|
3923 |
{ |
|
3924 |
iLog->Log( _L("ErrorCode not found in output ArgList") ); |
|
3925 |
return FAIL; |
|
3926 |
} |
|
3927 |
else |
|
3928 |
{ |
|
3929 |
aError = errcode->Value().AsTInt32(); |
|
3930 |
return PASS; |
|
3931 |
} |
|
3932 |
||
3933 |
} |
|
3934 |
||
3935 |
// ----------------------------------------------------------------------------- |
|
3936 |
// CTLandmarkProvider::RemoveAllLandmarks |
|
3937 |
// Helper method to remove all landmarks for preconditional tests. |
|
3938 |
// ----------------------------------------------------------------------------- |
|
3939 |
// |
|
3940 |
||
3941 |
void CTLandmarkProvider::RemoveAllLandmarks (CPosLandmarkDatabase* aLandmarkHandle) |
|
3942 |
{ |
|
3943 |
ExecuteAndDeleteLD(aLandmarkHandle->RemoveAllLandmarksL()); |
|
3944 |
} |
|
3945 |
// ----------------------------------------------------------------------------- |
|
3946 |
// CTLmAsyncTest::RemoveAllLandmarks |
|
3947 |
// Helper method to remove all categories for preconditional tests. |
|
3948 |
// ----------------------------------------------------------------------------- |
|
3949 |
// |
|
3950 |
void CTLandmarkProvider::RemoveAllCategories (CPosLmCategoryManager* aHandle) |
|
3951 |
{ |
|
3952 |
TPosLmItemId catID; |
|
3953 |
CPosLmItemIterator*iterator = aHandle->CategoryIteratorL(); |
|
3954 |
CleanupStack::PushL(iterator); |
|
3955 |
||
3956 |
while ((catID = iterator->NextL()) != KPosLmNullItemId) |
|
3957 |
{ |
|
3958 |
TRAPD(err,ExecuteAndDeleteLD(aHandle->RemoveCategoryL( catID ))); |
|
3959 |
TBuf8<50> error; |
|
3960 |
TRealFormat format; |
|
3961 |
error.Num(err,format) ; |
|
3962 |
iLog->Log( error ); |
|
3963 |
} |
|
3964 |
CleanupStack::PopAndDestroy(iterator); |
|
3965 |
} |
|
3966 |
||
3967 |
void CTLandmarkProvider::CreateInterfaceL(CLiwServiceHandler*& aHandler, |
|
3968 |
MLiwInterface*& aInterface) |
|
3969 |
{ |
|
3970 |
iLog->Log( _L("In CreateInterfaceL") ); |
|
3971 |
CLiwGenericParamList* InParamList,*OutParamList; |
|
3972 |
||
3973 |
TRAPD(Err,aHandler = CLiwServiceHandler::NewL()); |
|
3974 |
if(Err) |
|
3975 |
{ |
|
3976 |
iLog->Log( _L("CLiwServiceHandler Created %d"),Err ); |
|
3977 |
User::Leave(Err); |
|
3978 |
} |
|
3979 |
||
3980 |
CleanupStack::PushL(aHandler); |
|
3981 |
||
3982 |
InParamList = &(aHandler->InParamListL()); |
|
3983 |
OutParamList = &(aHandler->OutParamListL()); |
|
3984 |
||
3985 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL(1,KIDataSource,KService); |
|
3986 |
CleanupStack::PushL(crit); |
|
3987 |
crit->SetServiceClass(TUid::Uid(KLiwClassBase)); |
|
3988 |
RCriteriaArray a; |
|
3989 |
CleanupClosePushL(a); |
|
3990 |
a.AppendL(crit); |
|
3991 |
||
3992 |
aHandler->AttachL(a); |
|
3993 |
||
3994 |
InParamList->AppendL(TLiwGenericParam(KDbUri,TLiwVariant(KTestDbUri1))); |
|
3995 |
||
3996 |
aHandler->ExecuteServiceCmdL(*crit,*InParamList,*OutParamList); |
|
3997 |
||
3998 |
TInt Index = 0; |
|
3999 |
const TLiwGenericParam* param = OutParamList->FindFirst(Index,KIDataSource); |
|
4000 |
if(!param) |
|
4001 |
{ |
|
4002 |
iLog->Log( _L("Interface Not found ")); |
|
4003 |
User::Leave(KErrGeneral); |
|
4004 |
} |
|
4005 |
||
4006 |
aInterface = param->Value().AsInterface(); |
|
4007 |
CleanupStack::PopAndDestroy(&a); |
|
4008 |
CleanupStack::PopAndDestroy (crit); |
|
4009 |
||
4010 |
CleanupStack::Pop (aHandler); |
|
4011 |
iLog->Log( _L("End of CreateInterfaceL") ); |
|
4012 |
} |
|
4013 |
||
4014 |
// ----------------------------------------------------------------------------- |
|
4015 |
// CTLandmarkProvider::DeleteAllDatabases |
|
4016 |
// removes all local databases from the terminal |
|
4017 |
// called by all testcases. |
|
4018 |
// ----------------------------------------------------------------------------- |
|
4019 |
// |
|
4020 |
void CTLandmarkProvider::DeleteAllLocalDatabasesL() |
|
4021 |
{ |
|
4022 |
TInt count; |
|
4023 |
||
4024 |
CDesCArray* dbList = iDatabaseManager->ListDatabasesLC(_L("file")); |
|
4025 |
count = dbList->Count(); |
|
4026 |
||
4027 |
for ( TInt i = 0; i < count; i++ ) |
|
4028 |
{ |
|
4029 |
TPtrC db = (*dbList)[i]; |
|
4030 |
iDatabaseManager->DeleteDatabaseL ( db ); |
|
4031 |
} |
|
4032 |
CleanupStack::PopAndDestroy (1); |
|
4033 |
} |
|
4034 |
||
4035 |
||
4036 |
// ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
4037 |
// None |
|
4038 |
||
4039 |
// End of File |