|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of 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: implements interface class for location sapi |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32base.h> |
|
19 #include <LiwCommon.h> |
|
20 #include <lbs.h> |
|
21 #include <LbsRequestor.h> |
|
22 |
|
23 #include <lbscommon.h> |
|
24 #include <lbssatellite.h> |
|
25 #include "locationinterface.h" |
|
26 #include "locationcb.h" |
|
27 #include "locationservice.h" |
|
28 #include "locationerrormessage.hrh" |
|
29 using namespace LIW; |
|
30 |
|
31 /** |
|
32 * KMAXACTIVEOBJ identifies maximum number of entries in callback registration table |
|
33 * presently it stores only two entries . |
|
34 */ |
|
35 const TInt KMAXACTIVEOBJ = 2; |
|
36 |
|
37 |
|
38 //Error code for bad time |
|
39 const TInt KErrBadTime = -125; |
|
40 |
|
41 /** |
|
42 * destructor |
|
43 */ |
|
44 |
|
45 |
|
46 |
|
47 CLocationInterface :: ~CLocationInterface() |
|
48 { |
|
49 |
|
50 delete iLocationService ; |
|
51 |
|
52 |
|
53 iLocationService = NULL ; |
|
54 |
|
55 for(TInt iter = 0 ; iter < iHandleCB.Count() ; ++iter) |
|
56 { |
|
57 delete iHandleCB[iter] ; |
|
58 } |
|
59 iHandleCB.Close(); |
|
60 delete iGenericPosInfo ; |
|
61 |
|
62 |
|
63 } |
|
64 |
|
65 /** |
|
66 * Default constructor |
|
67 */ |
|
68 |
|
69 CLocationInterface :: CLocationInterface() |
|
70 { |
|
71 iGenericPosInfo = HPositionGenericInfo :: NewL() ; |
|
72 |
|
73 if(!iGenericPosInfo) |
|
74 { |
|
75 User ::Leave(KErrNoMemory) ; |
|
76 } |
|
77 |
|
78 |
|
79 for ( TInt count = 0;count < KMAXACTIVEOBJ ; count++) |
|
80 { |
|
81 iHandleCB.Insert(NULL,count); |
|
82 } |
|
83 |
|
84 |
|
85 } |
|
86 TInt CLocationInterface::ConvertToSapiError(TInt aSymbianErr) |
|
87 { |
|
88 TInt sapiErr(SErrGeneralError); |
|
89 switch (aSymbianErr) |
|
90 { |
|
91 //case EPosLmInvalidArgument: |
|
92 case KErrBadName: |
|
93 case KErrPositionIncalculable : |
|
94 case KErrArgument: |
|
95 { |
|
96 sapiErr = SErrBadArgumentType; |
|
97 break; |
|
98 } |
|
99 case KErrNotSupported: |
|
100 { |
|
101 sapiErr = SErrServiceNotSupported; |
|
102 break; |
|
103 } |
|
104 case KErrInUse: |
|
105 { |
|
106 sapiErr = SErrServiceInUse; |
|
107 break; |
|
108 } |
|
109 case KErrTimedOut: |
|
110 { |
|
111 sapiErr = SErrServiceTimedOut; |
|
112 break; |
|
113 |
|
114 } |
|
115 case KErrAccessDenied: |
|
116 { |
|
117 sapiErr = SErrAccessDenied; |
|
118 break; |
|
119 } |
|
120 case KErrNone: |
|
121 { |
|
122 sapiErr = SErrNone; |
|
123 break; |
|
124 } |
|
125 |
|
126 case KErrNotFound: |
|
127 { |
|
128 sapiErr = SErrNotFound; |
|
129 break; |
|
130 } |
|
131 |
|
132 case SErrMissingArgument: |
|
133 { |
|
134 sapiErr = SErrMissingArgument; |
|
135 break; |
|
136 } |
|
137 } |
|
138 return sapiErr; |
|
139 |
|
140 |
|
141 } |
|
142 /** |
|
143 * CLocationInterface::CmdExecuteL, this method is called by CLocationInterface::HandleCmdL() |
|
144 * to catch any leaves that might occur during execution of a LiwCommand.This is an private |
|
145 * method of this class. |
|
146 */ |
|
147 |
|
148 void CLocationInterface::CmdExecuteL( |
|
149 const TDesC8& aCmdName, |
|
150 const CLiwGenericParamList& aInParamList , |
|
151 CLiwGenericParamList& aOutParamList, |
|
152 TUint aCmdOptions, |
|
153 MLiwNotifyCallback* aCallback ) |
|
154 { |
|
155 |
|
156 |
|
157 aOutParamList.Reset() ; |
|
158 |
|
159 |
|
160 |
|
161 if( aCmdOptions & KLiwOptCancel ) // for cancel asynchronous request |
|
162 { |
|
163 |
|
164 TInt ret = 0 ; |
|
165 |
|
166 const TLiwGenericParam *transidparam = aInParamList.FindFirst(ret , KTransactionId) ; |
|
167 |
|
168 if( !transidparam ) |
|
169 { |
|
170 //Possibility of position based parsing |
|
171 |
|
172 TInt argCount = aInParamList.Count(); |
|
173 if( argCount >= 1 ) |
|
174 { |
|
175 transidparam = &aInParamList[Index0]; |
|
176 } |
|
177 if ( !transidparam ) |
|
178 { |
|
179 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
180 TLiwVariant(KCancelTransactionIdMissing))); |
|
181 User::Leave( KErrArgument ); |
|
182 } |
|
183 |
|
184 } |
|
185 |
|
186 TInt32 transid = (transidparam->Value()).AsTInt32() ; |
|
187 MLiwNotifyCallback* callBack = RequestCancel(transid) ; |
|
188 |
|
189 if (!callBack) |
|
190 { |
|
191 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
192 TLiwVariant(KCancelInvalidTransactionId))); |
|
193 User::Leave(KErrNotFound); |
|
194 } |
|
195 |
|
196 |
|
197 |
|
198 //Send notification about the cancelled state to consumer |
|
199 callBack->HandleNotifyL(transid , KLiwEventCanceled , |
|
200 aOutParamList, aInParamList) ; |
|
201 |
|
202 |
|
203 |
|
204 } |
|
205 |
|
206 |
|
207 //GetLocation request is made by consumer |
|
208 else if(aCmdName == KCmdGetLocation) |
|
209 { |
|
210 TInt ret =KErrNone ; |
|
211 //Extract category of Location Information user is interested in |
|
212 TInt index = 0; |
|
213 TPtrC posInfoCategory(KLocationBasicinfo); |
|
214 TInt32 transid = aCallback->GetTransactionID() ; |
|
215 //This flag indicates whether user has supplied a value for category of |
|
216 //location information or not |
|
217 TBool infoFlag = FALSE; |
|
218 |
|
219 const TLiwGenericParam *smapparam = aInParamList.FindFirst(index , KLocationInfoCategory) ; |
|
220 |
|
221 |
|
222 |
|
223 //if smapparam is NULL still there exist possibility of position based parsing |
|
224 if ( !smapparam ) |
|
225 { |
|
226 TInt count = aInParamList.Count(); |
|
227 if (count >= 1) |
|
228 { |
|
229 smapparam = &aInParamList[Index0]; |
|
230 |
|
231 if (smapparam && ( smapparam->Name() == KNullDesC8 ) ) |
|
232 { |
|
233 TLiwVariant variant = smapparam->Value(); |
|
234 |
|
235 if( variant.TypeId() != LIW::EVariantTypeDesC ) |
|
236 { |
|
237 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
238 TLiwVariant( KGetLocationWrongInfoType ) ) ); |
|
239 User::Leave( KErrArgument ); |
|
240 //Leave with error code |
|
241 } |
|
242 posInfoCategory.Set( variant.AsDes() ); |
|
243 |
|
244 //Set infoFlag to indicate user has supplied category of location information |
|
245 infoFlag = TRUE; |
|
246 |
|
247 |
|
248 } |
|
249 |
|
250 } |
|
251 } |
|
252 if(KErrNotFound != index) |
|
253 { |
|
254 TLiwVariant variant = smapparam->Value(); |
|
255 if( variant.TypeId() != LIW::EVariantTypeDesC ) |
|
256 { |
|
257 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
258 TLiwVariant( KGetLocationWrongInfoType ) ) ); |
|
259 User::Leave( KErrArgument ); |
|
260 //Leave with error code |
|
261 } |
|
262 posInfoCategory.Set( variant.AsDes() ); |
|
263 //Set infoFlag to indicate user has supplied category of location information |
|
264 infoFlag = TRUE; |
|
265 } |
|
266 |
|
267 //if callback is given for this command then it will be a async request |
|
268 if( aCallback && ( KLiwOptASyncronous & aCmdOptions ) ) |
|
269 { |
|
270 LocationInterfaceCB *callback = LocationInterfaceCB :: NewL (aCallback , &aInParamList , |
|
271 &iModuleInfo , transid) ; |
|
272 CleanupStack :: PushL(callback) ; |
|
273 |
|
274 callback->SetRequestType(KGetLocationCB) ; |
|
275 |
|
276 //Extract Update options from input List |
|
277 |
|
278 index = 0; |
|
279 const TLiwGenericParam *smapparam = aInParamList.FindFirst(index , KUpdateOptionMap) ; |
|
280 TPositionUpdateOptions *updateoptions = NULL ; |
|
281 TPositionUpdateOptions updateOptionVal; |
|
282 TUint category = EBasicInfo ; |
|
283 //Check for possibility of position based parsing |
|
284 if ( !smapparam ) |
|
285 { |
|
286 TInt count = aInParamList.Count(); |
|
287 if (count == 2) |
|
288 { |
|
289 smapparam = &aInParamList[Index1]; |
|
290 if (smapparam) |
|
291 { |
|
292 const CLiwMap *updateOptionMap = (smapparam->Value() ).AsMap() ; |
|
293 if( !updateOptionMap ) |
|
294 { |
|
295 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
296 TLiwVariant( KGetLocationWrongupdateMap ) ) ); |
|
297 CleanupStack :: Pop( callback ) ; |
|
298 delete callback; |
|
299 User::Leave( KErrArgument ); |
|
300 } |
|
301 TInt error = SetUpdateOption(updateOptionVal,updateOptionMap); |
|
302 if( KErrBadTime == error ) |
|
303 { |
|
304 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
305 TLiwVariant( KGetLocationNegativeTime ) ) ); |
|
306 CleanupStack :: Pop( callback ) ; |
|
307 delete callback; |
|
308 User::Leave( KErrArgument ); |
|
309 |
|
310 } |
|
311 updateoptions = &updateOptionVal ; |
|
312 |
|
313 |
|
314 } |
|
315 |
|
316 } |
|
317 } |
|
318 |
|
319 if(KErrNotFound != index) |
|
320 { |
|
321 const CLiwMap *updateOptionMap = (smapparam->Value() ).AsMap() ; |
|
322 if( !updateOptionMap ) |
|
323 { |
|
324 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
325 TLiwVariant( KGetLocationWrongupdateMap ) ) ); |
|
326 CleanupStack :: Pop( callback ) ; |
|
327 delete callback; |
|
328 User::Leave( KErrArgument ); |
|
329 } |
|
330 |
|
331 TInt error = SetUpdateOption(updateOptionVal,updateOptionMap); |
|
332 if( KErrBadTime == error ) |
|
333 { |
|
334 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
335 TLiwVariant( KGetLocationNegativeTime ) ) ); |
|
336 CleanupStack :: Pop( callback ) ; |
|
337 delete callback; |
|
338 |
|
339 User::Leave( KErrArgument ); |
|
340 |
|
341 } |
|
342 |
|
343 else if( KErrArgument == error ) |
|
344 { |
|
345 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
346 TLiwVariant( KGetLocationBadUpdateOptions ) ) ); |
|
347 |
|
348 CleanupStack :: Pop( callback ) ; |
|
349 delete callback; |
|
350 |
|
351 User::Leave( KErrArgument ); |
|
352 |
|
353 } |
|
354 |
|
355 |
|
356 updateoptions = &updateOptionVal ; |
|
357 } |
|
358 |
|
359 |
|
360 if ( posInfoCategory == KLocationGenericInfo ) |
|
361 { |
|
362 category = EGenericInfo ; |
|
363 } |
|
364 else if ( ( posInfoCategory != KLocationBasicinfo ) && ( infoFlag ) ) |
|
365 { |
|
366 //this indicates a wrong supplied location info category by the user |
|
367 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
368 TLiwVariant(KGetLocationCategoryInfo))); |
|
369 CleanupStack :: Pop( callback ) ; |
|
370 delete callback; |
|
371 User::Leave(KErrArgument); |
|
372 } |
|
373 |
|
374 //Extraction of update options and information complete so now send the request |
|
375 //To core dll |
|
376 |
|
377 ret = iLocationService->GetLocationL(callback ,category,iFieldList,updateoptions) ; |
|
378 |
|
379 //aOutParamList.AppendL(TLiwGenericParam(KErrorCode , TLiwVariant((TInt32)ret))) ; |
|
380 |
|
381 if(KErrNone != ret) |
|
382 { |
|
383 CleanupStack :: Pop(callback) ; |
|
384 delete callback ; |
|
385 User::Leave(ret); |
|
386 |
|
387 } |
|
388 |
|
389 //Store the allocatioed address |
|
390 iHandleCB[KGetLocationCB] = callback ; |
|
391 //Append Transcationid to out list |
|
392 aOutParamList.AppendL(TLiwGenericParam(KTransactionId, TLiwVariant(transid))); |
|
393 CleanupStack :: Pop(callback) ; |
|
394 |
|
395 } |
|
396 |
|
397 // Command is synchronous GetLocationCall |
|
398 else |
|
399 { |
|
400 TPosition pos ; |
|
401 |
|
402 //Extract Update options from input List |
|
403 |
|
404 index = 0; |
|
405 const TLiwGenericParam *smapparam = aInParamList.FindFirst(index , KUpdateOptionMap) ; |
|
406 TUint category = EBasicInfo ; |
|
407 TPositionUpdateOptions updateOptionVal; |
|
408 const TPositionUpdateOptions* updateOptions = NULL ; |
|
409 //if a smapparam is NULL there exist possibility of position based parsing |
|
410 if ( !smapparam ) |
|
411 { |
|
412 TInt count = aInParamList.Count(); |
|
413 if (count == 2) |
|
414 { |
|
415 smapparam = &aInParamList[Index1]; |
|
416 if (smapparam) |
|
417 { |
|
418 const CLiwMap *updateOptionMap = (smapparam->Value() ).AsMap() ; |
|
419 if( !updateOptionMap ) |
|
420 { |
|
421 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
422 TLiwVariant( KGetLocationWrongupdateMap ) ) ); |
|
423 |
|
424 User::Leave( KErrArgument ); |
|
425 } |
|
426 TInt error = SetUpdateOption(updateOptionVal,updateOptionMap); |
|
427 if( KErrBadTime == error ) |
|
428 { |
|
429 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
430 TLiwVariant( KGetLocationNegativeTime ) ) ); |
|
431 |
|
432 User::Leave( KErrArgument ); |
|
433 |
|
434 } |
|
435 else if( KErrArgument == error ) |
|
436 { |
|
437 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
438 TLiwVariant( KGetLocationBadUpdateOptions ) ) ); |
|
439 |
|
440 User::Leave( KErrArgument ); |
|
441 |
|
442 } |
|
443 |
|
444 |
|
445 updateOptions = &updateOptionVal ; |
|
446 |
|
447 |
|
448 } |
|
449 |
|
450 } |
|
451 } |
|
452 |
|
453 |
|
454 if( KErrNotFound != index) |
|
455 { |
|
456 |
|
457 const CLiwMap *updateOptionMap = (smapparam->Value()).AsMap() ; |
|
458 if( !updateOptionMap ) |
|
459 { |
|
460 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
461 TLiwVariant( KGetLocationWrongupdateMap ) ) ); |
|
462 |
|
463 User::Leave( KErrArgument ); |
|
464 } |
|
465 |
|
466 TInt error = SetUpdateOption(updateOptionVal,updateOptionMap); |
|
467 if( KErrBadTime == error ) |
|
468 { |
|
469 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
470 TLiwVariant( KGetLocationNegativeTime ) ) ); |
|
471 |
|
472 User::Leave( KErrArgument ); |
|
473 |
|
474 } |
|
475 else if( KErrArgument == error ) |
|
476 { |
|
477 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
478 TLiwVariant( KGetLocationBadUpdateOptions ) ) ); |
|
479 |
|
480 User::Leave( KErrArgument ); |
|
481 |
|
482 } |
|
483 updateOptions = &updateOptionVal ; |
|
484 |
|
485 } |
|
486 |
|
487 if ( posInfoCategory == KLocationGenericInfo ) |
|
488 { |
|
489 category = EGenericInfo ; |
|
490 } |
|
491 else if( posInfoCategory != KLocationBasicinfo ) |
|
492 { |
|
493 //this indicates a wrong supplied location info category by the user |
|
494 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
495 TLiwVariant(KGetLocationCategoryInfo))); |
|
496 User::Leave(KErrArgument); |
|
497 } |
|
498 |
|
499 ret = iLocationService->GetLocationL(iGenericPosInfo,updateOptions) ; |
|
500 //aOutParamList.AppendL(TLiwGenericParam (KErrorCode , TLiwVariant((TInt32)ret))) ; |
|
501 |
|
502 if(KErrNone != ret) |
|
503 { |
|
504 User::Leave(ret); |
|
505 |
|
506 } |
|
507 GetLocationInfo(aOutParamList,category) ; |
|
508 |
|
509 |
|
510 |
|
511 } //End of Synchronous getlocationcall |
|
512 |
|
513 |
|
514 |
|
515 } //End of KCmdGetLocation |
|
516 |
|
517 else if( ( aCmdName == KCmdTraceLocation ) && ( aCallback ) && ( KLiwOptASyncronous & aCmdOptions ) ) //Trace request is made by consumer |
|
518 { |
|
519 |
|
520 TInt ret = KErrNone ; |
|
521 TInt32 transid = aCallback->GetTransactionID() ; |
|
522 TInt index = 0; |
|
523 TPtrC posInfoCategory(KLocationBasicinfo); |
|
524 |
|
525 |
|
526 |
|
527 const TLiwGenericParam *smapparam = aInParamList.FindFirst(index , KLocationInfoCategory) ; |
|
528 |
|
529 //if smapparam is NULL still there exist possibility of position based parsing |
|
530 if ( !smapparam ) |
|
531 { |
|
532 TInt count = aInParamList.Count(); |
|
533 if (count >= 1) |
|
534 { |
|
535 smapparam = &aInParamList[Index0]; |
|
536 if (smapparam && ( smapparam->Name() == KNullDesC8 ) ) |
|
537 { |
|
538 TLiwVariant variant = smapparam->Value(); |
|
539 if( variant.TypeId() != LIW::EVariantTypeDesC ) |
|
540 { |
|
541 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
542 TLiwVariant( KTraceWrongInfoType ) ) ); |
|
543 User::Leave( KErrArgument ); |
|
544 //Leave with error code |
|
545 } |
|
546 posInfoCategory.Set( variant.AsDes() ); |
|
547 |
|
548 |
|
549 } |
|
550 |
|
551 } |
|
552 } |
|
553 |
|
554 if(KErrNotFound != index) |
|
555 { |
|
556 //Extract location category information if specified by user |
|
557 TLiwVariant variant = smapparam->Value(); |
|
558 if( variant.TypeId() != LIW::EVariantTypeDesC ) |
|
559 { |
|
560 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
561 TLiwVariant( KTraceWrongInfoType ) ) ); |
|
562 User::Leave( KErrArgument ); |
|
563 //Leave with error code |
|
564 } |
|
565 posInfoCategory.Set( variant.AsDes() ); |
|
566 |
|
567 |
|
568 } |
|
569 |
|
570 |
|
571 LocationInterfaceCB *callback = LocationInterfaceCB :: NewL (aCallback, |
|
572 &aOutParamList, |
|
573 &iModuleInfo, |
|
574 transid ) ; |
|
575 CleanupStack :: PushL(callback) ; |
|
576 callback->SetRequestType(KTraceCB) ; |
|
577 |
|
578 |
|
579 |
|
580 //Default posinfo Category is basic info |
|
581 TUint catergory = EBasicInfo ; |
|
582 TPositionUpdateOptions updateOptionVal; |
|
583 TPositionUpdateOptions* updateOption = NULL ; |
|
584 |
|
585 index = 0; |
|
586 smapparam = aInParamList.FindFirst(index , KUpdateOptionMap) ; |
|
587 //if a smapparam is NULL there exist possibility of position based parsing |
|
588 if ( !smapparam ) |
|
589 { |
|
590 TInt count = aInParamList.Count(); |
|
591 if (count == 2) |
|
592 { |
|
593 smapparam = &aInParamList[Index1]; |
|
594 if (smapparam) |
|
595 { |
|
596 const CLiwMap *updateOptionMap = (smapparam->Value() ).AsMap() ; |
|
597 if( !updateOptionMap ) |
|
598 { |
|
599 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
600 TLiwVariant( KTraceWrongupdateMap ) ) ); |
|
601 CleanupStack :: Pop( callback ) ; |
|
602 delete callback; |
|
603 |
|
604 User::Leave( KErrArgument ); |
|
605 } |
|
606 |
|
607 TInt error = SetUpdateOption(updateOptionVal,updateOptionMap); |
|
608 if( KErrBadTime == error ) |
|
609 { |
|
610 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
611 TLiwVariant( KTraceNegativeTime ) ) ); |
|
612 CleanupStack :: Pop( callback ) ; |
|
613 delete callback; |
|
614 User::Leave( KErrArgument ); |
|
615 |
|
616 } |
|
617 else if( KErrArgument == error ) |
|
618 { |
|
619 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
620 TLiwVariant( KTraceBadUpdateOptions ) ) ); |
|
621 |
|
622 CleanupStack :: Pop( callback ) ; |
|
623 delete callback; |
|
624 |
|
625 |
|
626 User::Leave( KErrArgument ); |
|
627 |
|
628 } |
|
629 updateOption = &updateOptionVal ; |
|
630 |
|
631 |
|
632 } |
|
633 |
|
634 } |
|
635 } |
|
636 |
|
637 |
|
638 //Extract Update options from input List |
|
639 if(KErrNotFound != index) |
|
640 { |
|
641 const CLiwMap *updateOptionMap = (smapparam->Value()).AsMap() ; |
|
642 if( !updateOptionMap ) |
|
643 { |
|
644 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
645 TLiwVariant( KGetLocationWrongupdateMap ) ) ); |
|
646 CleanupStack :: Pop( callback ) ; |
|
647 delete callback; |
|
648 |
|
649 User::Leave( KErrArgument ); |
|
650 } |
|
651 |
|
652 TInt error = SetUpdateOption(updateOptionVal,updateOptionMap); |
|
653 if( KErrBadTime == error ) |
|
654 { |
|
655 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
656 TLiwVariant( KTraceNegativeTime ) ) ); |
|
657 CleanupStack :: Pop( callback ) ; |
|
658 delete callback; |
|
659 User::Leave( KErrArgument ); |
|
660 |
|
661 } |
|
662 else if( KErrArgument == error ) |
|
663 { |
|
664 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
665 TLiwVariant( KTraceBadUpdateOptions ) ) ); |
|
666 |
|
667 User::Leave( KErrArgument ); |
|
668 |
|
669 } |
|
670 |
|
671 updateOption = &updateOptionVal ; |
|
672 } |
|
673 |
|
674 |
|
675 //Now set the category of info required before sending request to core dll |
|
676 |
|
677 if ( posInfoCategory == KLocationGenericInfo ) |
|
678 { |
|
679 catergory = EGenericInfo ; |
|
680 } |
|
681 else if( posInfoCategory != KLocationBasicinfo ) |
|
682 { |
|
683 //this indicates a wrong supplied location info category by the user |
|
684 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
685 TLiwVariant(KTraceCategoryInfo))); |
|
686 |
|
687 CleanupStack::Pop(callback); |
|
688 delete callback; |
|
689 User::Leave(KErrArgument); |
|
690 } |
|
691 |
|
692 ret = iLocationService->TraceL(callback , catergory , iFieldList , updateOption ) ; |
|
693 //TLiwGenericParam errorParm(KErrorCode , TLiwVariant((TInt32)ret)) ; |
|
694 //aOutParamList.AppendL(errorParm) ; |
|
695 |
|
696 if(KErrNone != ret) |
|
697 { |
|
698 CleanupStack :: Pop(callback) ; |
|
699 delete callback ; |
|
700 User::Leave(ret); |
|
701 } |
|
702 |
|
703 |
|
704 iHandleCB[KTraceCB] = callback ; |
|
705 aOutParamList.AppendL(TLiwGenericParam (KTransactionId , TLiwVariant(transid))) ; //Append Transcationid to out list |
|
706 |
|
707 CleanupStack :: Pop(callback) ; |
|
708 |
|
709 } //End of KCmdTraceLocation |
|
710 |
|
711 else if(aCmdName == KCmdCancelRequest) //Cancel request is made by consumer |
|
712 { |
|
713 |
|
714 TInt index = 0 ; |
|
715 TInt count = aInParamList.Count(); |
|
716 |
|
717 const TLiwGenericParam *genericParam = aInParamList.FindFirst(index , KCancelType) ; |
|
718 |
|
719 if(!genericParam) |
|
720 { |
|
721 //still exist possibility of position based parsing |
|
722 |
|
723 if ( count == 1 ) |
|
724 { |
|
725 genericParam = &aInParamList[Index0]; |
|
726 } |
|
727 |
|
728 } |
|
729 |
|
730 //Now genericParam must contain the Canceltype argument |
|
731 if (!genericParam) |
|
732 { |
|
733 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
734 TLiwVariant(KCancelMissingType))); |
|
735 |
|
736 User::Leave(SErrMissingArgument); |
|
737 } |
|
738 |
|
739 |
|
740 TLiwVariant variant = genericParam->Value(); |
|
741 if( variant.TypeId() != LIW::EVariantTypeDesC ) |
|
742 { |
|
743 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
744 TLiwVariant( KCancelTypeMisMatch ) ) ); |
|
745 User::Leave( KErrArgument ); |
|
746 //Leave with error code |
|
747 } |
|
748 TPtrC requesttype = variant.AsDes() ; |
|
749 TInt ret = KErrGeneral ; |
|
750 |
|
751 if(requesttype == KRequestTrace ) |
|
752 { |
|
753 |
|
754 ret = iLocationService->CancelOnGoingService(ECancelTrace) ; |
|
755 |
|
756 if(KErrNone == ret) ; |
|
757 { |
|
758 delete iHandleCB[KTraceCB] ; |
|
759 iHandleCB[KTraceCB] = NULL ; //Mark the slot as free |
|
760 } |
|
761 |
|
762 |
|
763 } |
|
764 |
|
765 else if(requesttype == KRequestGetLoc ) |
|
766 { |
|
767 |
|
768 ret = iLocationService->CancelOnGoingService(ECancelGetLocation) ; |
|
769 |
|
770 if(!ret) |
|
771 { |
|
772 delete iHandleCB[KGetLocationCB] ; |
|
773 iHandleCB[KGetLocationCB] = NULL ; //Mark the slot as free |
|
774 } |
|
775 |
|
776 } |
|
777 |
|
778 else //Invalid command |
|
779 { |
|
780 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
781 TLiwVariant(KCancelWrongType))); |
|
782 |
|
783 User::Leave(KErrArgument); |
|
784 } |
|
785 |
|
786 |
|
787 User::LeaveIfError(ret); |
|
788 |
|
789 } //End of KCmdCancelRequest |
|
790 |
|
791 else if(aCmdName == KRequestCalculate) |
|
792 { |
|
793 TInt index = 0 ; |
|
794 //Flag set to 0 indicate no position based parsing need to be done |
|
795 // for subsequent parameters |
|
796 TInt paramparsingFlag = 0; |
|
797 const TLiwGenericParam *genericParam = aInParamList.FindFirst(index ,KMathRequest) ; |
|
798 |
|
799 if(!genericParam) |
|
800 { |
|
801 |
|
802 genericParam = &aInParamList[Index0]; |
|
803 paramparsingFlag = 1; |
|
804 if( !genericParam ) |
|
805 { |
|
806 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
807 TLiwVariant(KMissingMathrequest))); |
|
808 User::Leave(KErrArgument); |
|
809 } |
|
810 |
|
811 |
|
812 } |
|
813 |
|
814 TLiwVariant variant = genericParam->Value(); |
|
815 if( variant.TypeId() != EVariantTypeDesC ) |
|
816 { |
|
817 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
818 TLiwVariant(KWrongMathrequest))); |
|
819 User::Leave(KErrArgument); |
|
820 |
|
821 } |
|
822 TPtrC requesttype = variant.AsDes() ; |
|
823 TInt ret ; |
|
824 |
|
825 |
|
826 if( requesttype == KRequestDistance ) |
|
827 { |
|
828 TInt mathindex = 0 ; |
|
829 |
|
830 // calculation |
|
831 const TLiwGenericParam *smapparam = aInParamList.FindFirst(mathindex , KDistanceParmSource) ; |
|
832 //if smapparam is NULL still exist possibility of position based parsing |
|
833 if ( (!smapparam) && (paramparsingFlag) ) |
|
834 { |
|
835 smapparam = &aInParamList[Index1]; |
|
836 } |
|
837 |
|
838 |
|
839 mathindex = 0 ; |
|
840 const TLiwGenericParam *dmapparam = aInParamList.FindFirst(mathindex , KDistanceParmDestination) ; |
|
841 if ( (!dmapparam) && (paramparsingFlag) ) |
|
842 { |
|
843 dmapparam = &aInParamList[Index2]; |
|
844 } |
|
845 if(!smapparam || !dmapparam) |
|
846 { |
|
847 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
848 TLiwVariant(KMissingParamCord))); |
|
849 User::Leave(KErrArgument); |
|
850 } |
|
851 |
|
852 TLiwVariant mapVariant= smapparam->Value() ; |
|
853 const CLiwMap *map = mapVariant.AsMap() ; |
|
854 if( !map ) |
|
855 { |
|
856 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
857 TLiwVariant( KCalWrongSource ) ) ); |
|
858 |
|
859 |
|
860 User::Leave( KErrArgument ); |
|
861 } |
|
862 TCoordinate source , destination ; |
|
863 |
|
864 FillCoordinatesL(source , map) ; //Extract source coordinates |
|
865 |
|
866 mapVariant = dmapparam->Value() ; |
|
867 map = mapVariant.AsMap() ; |
|
868 if( !map ) |
|
869 { |
|
870 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
871 TLiwVariant( KCalWrongDest ) ) ); |
|
872 |
|
873 |
|
874 User::Leave( KErrArgument ); |
|
875 } |
|
876 |
|
877 FillCoordinatesL(destination , map) ; |
|
878 |
|
879 inpparam distance ; |
|
880 |
|
881 distance.source = source ; |
|
882 distance.destination = destination ; |
|
883 distance.servicechoice = EDistance ; |
|
884 |
|
885 |
|
886 ret = iLocationService->MathOperation(distance) ; //Calculate distance using core class |
|
887 |
|
888 |
|
889 //success/failure code to the outputlist |
|
890 //TLiwGenericParam errorParm(KErrorCode , TLiwVariant((TInt32)ret)) ; |
|
891 //aOutParamList.AppendL(errorParm) ; |
|
892 User::LeaveIfError(ret); |
|
893 TReal32 resultvalue = distance.result; |
|
894 |
|
895 if ( KErrNone == ret ) |
|
896 { |
|
897 TLiwGenericParam opresult(KMathOpResult,TLiwVariant((TReal)resultvalue)); |
|
898 aOutParamList.AppendL(opresult) ; |
|
899 } |
|
900 |
|
901 } //End of KRequestDistance |
|
902 |
|
903 else if ( requesttype == KRequestBearingTo) |
|
904 { |
|
905 TInt mathindex = 0 ; |
|
906 |
|
907 // calculation |
|
908 const TLiwGenericParam *smapparam = aInParamList.FindFirst(mathindex , KDistanceParmSource) ; |
|
909 //if smapparam is NULL still exist possibility of position based parsing |
|
910 if ( (!smapparam) && (paramparsingFlag) ) |
|
911 { |
|
912 smapparam = &aInParamList[Index1]; |
|
913 } |
|
914 |
|
915 mathindex = 0 ; |
|
916 const TLiwGenericParam *dmapparam = aInParamList.FindFirst(mathindex , KDistanceParmDestination) ; |
|
917 if ( (!dmapparam) && (paramparsingFlag) ) |
|
918 { |
|
919 dmapparam = &aInParamList[Index2]; |
|
920 } |
|
921 |
|
922 if(!smapparam || !dmapparam) |
|
923 { |
|
924 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
925 TLiwVariant(KMissingParamCord))); |
|
926 User::Leave(KErrArgument); |
|
927 } |
|
928 |
|
929 TLiwVariant mapVariant= smapparam->Value() ; |
|
930 const CLiwMap *map = mapVariant.AsMap() ; |
|
931 if( !map ) |
|
932 { |
|
933 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
934 TLiwVariant( KCalWrongSource ) ) ); |
|
935 |
|
936 |
|
937 User::Leave( KErrArgument ); |
|
938 } |
|
939 TCoordinate source , destination ; |
|
940 |
|
941 FillCoordinatesL(source , map) ; //Extract source coordinates |
|
942 |
|
943 mapVariant = dmapparam->Value() ; |
|
944 map = mapVariant.AsMap() ; |
|
945 if( !map ) |
|
946 { |
|
947 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
948 TLiwVariant( KCalWrongDest ) ) ); |
|
949 |
|
950 |
|
951 User::Leave( KErrArgument ); |
|
952 } |
|
953 |
|
954 FillCoordinatesL(destination , map) ; |
|
955 |
|
956 inpparam bearingTo ; |
|
957 |
|
958 bearingTo.source = source ; |
|
959 bearingTo.destination = destination ; |
|
960 bearingTo.servicechoice = EBearingTo ; |
|
961 |
|
962 ret = iLocationService->MathOperation(bearingTo) ; |
|
963 |
|
964 |
|
965 |
|
966 User::LeaveIfError(ret); |
|
967 TReal32 resultvalue = bearingTo.result; |
|
968 |
|
969 if ( KErrNone == ret ) |
|
970 { |
|
971 TLiwGenericParam opresult(KMathOpResult,TLiwVariant((TReal)resultvalue)); |
|
972 aOutParamList.AppendL(opresult) ; |
|
973 } |
|
974 } //End of KRequestBearingto |
|
975 else if ( requesttype == KRequestMove ) |
|
976 { |
|
977 TInt mathindex = 0; |
|
978 |
|
979 // Extracting source coordinate from input parameter List |
|
980 const TLiwGenericParam *smapparam = aInParamList.FindFirst(mathindex , KDistanceParmSource) ; |
|
981 if ( (!smapparam) && (paramparsingFlag) ) |
|
982 { |
|
983 smapparam = &aInParamList[Index1]; |
|
984 } |
|
985 |
|
986 |
|
987 |
|
988 if( !smapparam ) |
|
989 { |
|
990 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
991 TLiwVariant(KMissingParamCord))); |
|
992 User::Leave( SErrMissingArgument ); |
|
993 } |
|
994 |
|
995 TLiwVariant mapVariant= smapparam->Value() ; |
|
996 const CLiwMap *map = mapVariant.AsMap() ; |
|
997 if( !map ) |
|
998 { |
|
999 aOutParamList.AppendL( TLiwGenericParam( KErrorMessage, |
|
1000 TLiwVariant( KCalWrongSource ) ) ); |
|
1001 |
|
1002 |
|
1003 User::Leave( KErrArgument ); |
|
1004 } |
|
1005 TCoordinate source ; |
|
1006 |
|
1007 FillCoordinatesL(source , map) ; |
|
1008 |
|
1009 mathindex = 0; |
|
1010 //Extracting distance by which coordinate should be moved |
|
1011 const TLiwGenericParam *distanceParam = aInParamList.FindFirst(mathindex,KDistanceMove) ; |
|
1012 if ( (!distanceParam) && (paramparsingFlag) ) |
|
1013 { |
|
1014 distanceParam = &aInParamList[Index2]; |
|
1015 if ( !distanceParam ) |
|
1016 { |
|
1017 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1018 TLiwVariant(KMissingDistanceParam))); |
|
1019 User::Leave( SErrMissingArgument ); |
|
1020 } |
|
1021 } |
|
1022 if( !distanceParam ) |
|
1023 { |
|
1024 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1025 TLiwVariant(KMissingDistanceParam))); |
|
1026 User::Leave( SErrMissingArgument ); |
|
1027 } |
|
1028 TLiwVariant distanceVariant = distanceParam->Value(); |
|
1029 if( ( distanceVariant.TypeId() != EVariantTypeTReal ) ) |
|
1030 { |
|
1031 if ( ( distanceVariant.TypeId() != EVariantTypeTInt32 ) ) |
|
1032 { |
|
1033 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1034 TLiwVariant(KCaluclateMoveDistance))); |
|
1035 User::Leave(KErrArgument); |
|
1036 } |
|
1037 |
|
1038 } |
|
1039 |
|
1040 const TReal64 distanceValue = distanceVariant.AsTReal(); |
|
1041 |
|
1042 |
|
1043 //Extracting bearing by which coordinate should be moved |
|
1044 mathindex = 0; |
|
1045 |
|
1046 const TLiwGenericParam *bearingParam = aInParamList.FindFirst(mathindex,KBearingMove); |
|
1047 if ( (!bearingParam) && (paramparsingFlag) ) |
|
1048 { |
|
1049 bearingParam = &aInParamList[Index3]; |
|
1050 if ( !bearingParam ) |
|
1051 { |
|
1052 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1053 TLiwVariant(KMissingBearingParam))); |
|
1054 User::Leave( SErrMissingArgument ); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 if( !bearingParam ) |
|
1059 { |
|
1060 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1061 TLiwVariant(KMissingBearingParam))); |
|
1062 User::Leave( SErrMissingArgument ); |
|
1063 |
|
1064 } |
|
1065 TLiwVariant bearingVariant = bearingParam->Value(); |
|
1066 if( ( bearingVariant.TypeId() != EVariantTypeTReal ) ) |
|
1067 { |
|
1068 if ( ( bearingVariant.TypeId() != EVariantTypeTInt32 ) ) |
|
1069 { |
|
1070 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1071 TLiwVariant(KCaluclateMoveBearing))); |
|
1072 User::Leave(KErrArgument); |
|
1073 } |
|
1074 |
|
1075 } |
|
1076 |
|
1077 const TReal32 bearingValue = bearingVariant.AsTReal(); |
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 inpparam moveParam ; |
|
1084 |
|
1085 moveParam.source = source ; |
|
1086 |
|
1087 |
|
1088 moveParam.servicechoice = EMove ; |
|
1089 |
|
1090 moveParam.bearing = bearingValue; |
|
1091 moveParam.distance = distanceValue; |
|
1092 |
|
1093 //Move Coordinates |
|
1094 ret = iLocationService->MathOperation(moveParam) ; |
|
1095 |
|
1096 if ( KErrNone == ret ) |
|
1097 { |
|
1098 TReal64 inputParamLongitude = moveParam.source.Longitude(); |
|
1099 TReal64 inputParamLatitude = moveParam.source.Latitude(); |
|
1100 TReal64 inputParamAltitude = moveParam.source.Altitude(); |
|
1101 |
|
1102 //Appending translated coordinate to outputParamList |
|
1103 CLiwDefaultMap *result = CLiwDefaultMap::NewL() ; |
|
1104 CleanupStack :: PushL(result) ; |
|
1105 |
|
1106 //Inserting longitude, Latitude and altitude |
|
1107 result->InsertL(KLongitudeKey , TLiwVariant((TReal)inputParamLongitude )) ; |
|
1108 result->InsertL(KLatitudeKey , TLiwVariant((TReal)inputParamLatitude)) ; |
|
1109 result->InsertL(KAltitudeKey , TLiwVariant((TReal)inputParamAltitude)) ; |
|
1110 TLiwVariant resVar(result) ; |
|
1111 |
|
1112 TLiwGenericParam outParm(KLocationMap , TLiwVariant(result)) ; |
|
1113 |
|
1114 aOutParamList.AppendL(outParm) ; |
|
1115 result->DecRef(); |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 //success/failure code to the outputlist |
|
1121 TLiwGenericParam errorParm(KErrorCode , TLiwVariant((TInt32)ret)) ; |
|
1122 aOutParamList.AppendL(errorParm) ; |
|
1123 CleanupStack :: Pop(result) ; |
|
1124 |
|
1125 }//End of Move |
|
1126 else |
|
1127 { |
|
1128 /*TLiwGenericParam errorParm(KErrorCode , TLiwVariant((TInt32)ret)) ; |
|
1129 aOutParamList.AppendL(errorParm) ;*/ |
|
1130 User::LeaveIfError(ret); |
|
1131 |
|
1132 } |
|
1133 |
|
1134 } |
|
1135 |
|
1136 |
|
1137 else |
|
1138 { |
|
1139 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1140 TLiwVariant(KWrongMathrequest))); |
|
1141 User::Leave(KErrArgument); |
|
1142 } |
|
1143 |
|
1144 } |
|
1145 else//bad command |
|
1146 { |
|
1147 aOutParamList.AppendL(TLiwGenericParam(KErrorMessage, |
|
1148 TLiwVariant(KCmdNotFound))); |
|
1149 User::Leave(KErrNotSupported); |
|
1150 |
|
1151 } |
|
1152 |
|
1153 |
|
1154 |
|
1155 } |
|
1156 |
|
1157 /** |
|
1158 * CLocationInterface :: SetSupportedFields fills iGenericPosInfo as per the capability of the |
|
1159 * positioning module used |
|
1160 */ |
|
1161 |
|
1162 TInt CLocationInterface :: SetSupportedFields() |
|
1163 { |
|
1164 //Extract all the information Accuracy, timestamp, satellite and course info and append |
|
1165 // to out parmlist |
|
1166 |
|
1167 |
|
1168 |
|
1169 TUint fieldIter = 0 ; |
|
1170 |
|
1171 TPositionModuleInfo :: TCapabilities currCapability = iModuleInfo.Capabilities() ; |
|
1172 |
|
1173 if(currCapability & TPositionModuleInfo :: ECapabilitySpeed) //set horizontal,vertical speeds along with errros |
|
1174 { |
|
1175 iFieldList[fieldIter++] = EPositionFieldHorizontalSpeed ; |
|
1176 iFieldList[fieldIter++] = EPositionFieldHorizontalSpeedError ; |
|
1177 iFieldList[fieldIter++] = EPositionFieldVerticalSpeed ; |
|
1178 iFieldList[fieldIter++] = EPositionFieldVerticalSpeedError ; |
|
1179 } |
|
1180 |
|
1181 if(currCapability & TPositionModuleInfo :: ECapabilitySatellite) //Set satellite info fields if positioning module supports |
|
1182 { // |
|
1183 |
|
1184 iFieldList[fieldIter++] = EPositionFieldSatelliteNumInView ; |
|
1185 iFieldList[fieldIter++] = EPositionFieldSatelliteNumUsed ; |
|
1186 iFieldList[fieldIter++] = EPositionFieldSatelliteTime ; |
|
1187 iFieldList[fieldIter++] = EPositionFieldSatelliteHorizontalDoP ; |
|
1188 iFieldList[fieldIter++] = EPositionFieldSatelliteVerticalDoP ; |
|
1189 |
|
1190 } |
|
1191 |
|
1192 if(currCapability & TPositionModuleInfo :: ECapabilityDirection) //Set Direction info fields if positioning module supports |
|
1193 { |
|
1194 |
|
1195 iFieldList[fieldIter++] = EPositionFieldTrueCourse ; |
|
1196 iFieldList[fieldIter++] = EPositionFieldTrueCourseError ; |
|
1197 iFieldList[fieldIter++] = EPositionFieldMagneticCourse ; |
|
1198 iFieldList[fieldIter++] = EPositionFieldMagneticCourseError ; |
|
1199 |
|
1200 } |
|
1201 |
|
1202 |
|
1203 if(currCapability & TPositionModuleInfo :: ECapabilityCompass) //Set NMEA fields if positioning module supports |
|
1204 { |
|
1205 |
|
1206 iFieldList[fieldIter++] = EPositionFieldHeading ; |
|
1207 iFieldList[fieldIter++] = EPositionFieldHeadingError ; |
|
1208 iFieldList[fieldIter++] = EPositionFieldMagneticHeading ; |
|
1209 iFieldList[fieldIter++] = EPositionFieldMagneticHeadingError ; |
|
1210 |
|
1211 } |
|
1212 |
|
1213 /*if(currCapability & TPositionModuleInfo :: ECapabilityNmea) |
|
1214 { |
|
1215 |
|
1216 iFieldList[fieldIter++] = EPositionFieldNMEASentences ; |
|
1217 iFieldList[fieldIter++] = EPositionFieldNMEASentencesStart ; |
|
1218 |
|
1219 }*/ |
|
1220 iFieldList[fieldIter] = EPositionFieldNone ; //Field Termination |
|
1221 iGenericPosInfo->ClearRequestedFields() ; |
|
1222 iGenericPosInfo->SetRequestedFields(iFieldList) ; |
|
1223 |
|
1224 |
|
1225 return KErrNone ; |
|
1226 } |
|
1227 |
|
1228 /** |
|
1229 * CLocationInterface :: GetLocationInfo an internal utility funtionin, gets all the location information |
|
1230 * which is supported by this Module |
|
1231 */ |
|
1232 |
|
1233 |
|
1234 void CLocationInterface :: GetLocationInfo( CLiwGenericParamList& aOutParamList,TInt aPosInfoCategory) |
|
1235 { |
|
1236 TPosition pos ; |
|
1237 iGenericPosInfo->GetPosition(pos) ; //Now populate outparam list with latitude, longitude and altitude data |
|
1238 |
|
1239 CLiwDefaultMap *Result = CLiwDefaultMap::NewL() ; |
|
1240 |
|
1241 CleanupStack :: PushL(Result) ; |
|
1242 TReal64 Val = pos.Longitude() ; |
|
1243 |
|
1244 //Inserting latitude , longitude , altitude . |
|
1245 Result->InsertL(KLongitudeKey , TLiwVariant((TReal)Val)) ; |
|
1246 |
|
1247 Val = pos.Latitude() ; |
|
1248 Result->InsertL(KLatitudeKey , TLiwVariant((TReal)Val)) ; |
|
1249 |
|
1250 TReal32 altitude = pos.Altitude() ; |
|
1251 |
|
1252 |
|
1253 Result->InsertL(KAltitudeKey , TLiwVariant((TReal)altitude)) ; |
|
1254 |
|
1255 |
|
1256 TLiwVariant MapVariant(Result) ; |
|
1257 |
|
1258 |
|
1259 TPositionModuleInfo :: TCapabilities currCapability = iModuleInfo.Capabilities() ; |
|
1260 |
|
1261 if ( aPosInfoCategory == EGenericPositionInfo ) |
|
1262 { |
|
1263 if(currCapability & TPositionModuleInfo :: ECapabilitySpeed) //Populate output param with speed info |
|
1264 { |
|
1265 TReal32 speedinfo = 0 ; |
|
1266 |
|
1267 if(!iGenericPosInfo->GetValue(EPositionFieldHorizontalSpeed , speedinfo)) //Extract speed |
|
1268 { |
|
1269 Result->InsertL(KPositionFieldHorizontalSpeed ,TLiwVariant((TReal) speedinfo)) ; |
|
1270 } |
|
1271 |
|
1272 |
|
1273 |
|
1274 if(!iGenericPosInfo->GetValue(EPositionFieldHorizontalSpeedError , speedinfo) ) |
|
1275 { |
|
1276 Result->InsertL(KPositionFieldHorizontalSpeedError ,TLiwVariant((TReal) speedinfo)) ; |
|
1277 } |
|
1278 |
|
1279 /*if(!iGenericPosInfo->GetValue(EPositionFieldVerticalSpeed , speedinfo)) |
|
1280 { |
|
1281 Result->InsertL(KPositionFieldVerticalSpeed ,TLiwVariant((TReal) speedinfo)) ; |
|
1282 |
|
1283 } |
|
1284 |
|
1285 if(!iGenericPosInfo->GetValue(EPositionFieldVerticalSpeedError ,speedinfo)) |
|
1286 { |
|
1287 Result->InsertL(KPositionFieldVerticalSpeedError ,TLiwVariant((TReal) speedinfo)) ; |
|
1288 }*/ |
|
1289 |
|
1290 |
|
1291 } //End of EcapabilitySpeed |
|
1292 |
|
1293 |
|
1294 if(currCapability & TPositionModuleInfo :: ECapabilitySatellite) //Extract satellitinfo if any and append it |
|
1295 { //as part of out parm list |
|
1296 TInt8 satinfo = 0; |
|
1297 |
|
1298 if(!iGenericPosInfo->GetValue(EPositionFieldSatelliteNumInView , satinfo)) |
|
1299 { |
|
1300 Result->InsertL(KPositionFieldSatelliteNumInView ,TLiwVariant((TReal) satinfo)) ; |
|
1301 } |
|
1302 if(!iGenericPosInfo->GetValue(EPositionFieldSatelliteNumUsed , satinfo)) |
|
1303 { |
|
1304 Result->InsertL(KPositionFieldSatelliteNumUsed ,TLiwVariant((TReal) satinfo)) ; |
|
1305 } |
|
1306 } //End of ECapabilitySatellite |
|
1307 |
|
1308 if(currCapability & TPositionModuleInfo :: ECapabilityDirection) //Extract direction info if any and append it |
|
1309 { // as part of out parm list |
|
1310 TReal32 direcinfo = 0; |
|
1311 |
|
1312 |
|
1313 if(!iGenericPosInfo->GetValue(EPositionFieldTrueCourse , direcinfo) ) |
|
1314 { |
|
1315 Result->InsertL(KPositionFieldTrueCourse ,TLiwVariant((TReal) direcinfo)) ; |
|
1316 } |
|
1317 |
|
1318 |
|
1319 if(!iGenericPosInfo->GetValue(EPositionFieldTrueCourseError , direcinfo) ) |
|
1320 { |
|
1321 Result->InsertL(KPositionFieldTrueCourseError ,TLiwVariant((TReal) direcinfo)) ; |
|
1322 } |
|
1323 |
|
1324 |
|
1325 if(!iGenericPosInfo->GetValue(EPositionFieldMagneticCourseError , direcinfo) ) |
|
1326 { |
|
1327 Result->InsertL(KPositionFieldMagneticCourseError ,TLiwVariant((TReal) direcinfo)) ; |
|
1328 } |
|
1329 |
|
1330 |
|
1331 if(!iGenericPosInfo->GetValue(EPositionFieldMagneticCourse , direcinfo) ) |
|
1332 { |
|
1333 Result->InsertL(KPositionFieldMagneticCourse ,TLiwVariant((TReal) direcinfo)) ; |
|
1334 } |
|
1335 } // End of ECapabilityDirection |
|
1336 |
|
1337 |
|
1338 if(currCapability & TPositionModuleInfo :: ECapabilityCompass) //Extract compass info if any and append it |
|
1339 { // as part of out parm list |
|
1340 TReal32 compassinfo ; |
|
1341 |
|
1342 |
|
1343 if(!iGenericPosInfo->GetValue(EPositionFieldHeading , compassinfo) ) |
|
1344 { |
|
1345 Result->InsertL(KPositionFieldHeading ,TLiwVariant((TReal) compassinfo)) ; |
|
1346 } |
|
1347 |
|
1348 |
|
1349 if(!iGenericPosInfo->GetValue(EPositionFieldHeadingError , compassinfo) ) |
|
1350 { |
|
1351 Result->InsertL(KPositionFieldHeadingError ,TLiwVariant((TReal) compassinfo)) ; |
|
1352 } |
|
1353 |
|
1354 |
|
1355 if(!iGenericPosInfo->GetValue(EPositionFieldMagneticHeading , compassinfo) ) |
|
1356 { |
|
1357 Result->InsertL(KPositionFieldMagneticHeading ,TLiwVariant((TReal) compassinfo)) ; |
|
1358 } |
|
1359 |
|
1360 |
|
1361 |
|
1362 if(!iGenericPosInfo->GetValue(EPositionFieldMagneticHeadingError , compassinfo) ) |
|
1363 { |
|
1364 Result->InsertL(KPositionFieldMagneticHeadingError ,TLiwVariant((TReal) compassinfo)) ; |
|
1365 |
|
1366 } |
|
1367 |
|
1368 |
|
1369 } //End of ECapabilityCompass |
|
1370 |
|
1371 /*if( currCapability & TPositionModuleInfo :: ECapabilityNmea ) //Extract Nmea info if any and append it |
|
1372 { //as part of out param list |
|
1373 TUint8 numSentences ; |
|
1374 |
|
1375 if(!iGenericPosInfo->GetValue(EPositionFieldNMEASentences , numSentences) ) |
|
1376 { |
|
1377 Result->InsertL(KPositionFieldNMEASentences ,TLiwVariant((TReal) numSentences)) ; |
|
1378 } |
|
1379 |
|
1380 |
|
1381 TBuf8 <20> nmeaSentences ; |
|
1382 if(!iGenericPosInfo->GetValue(EPositionFieldNMEASentencesStart , nmeaSentences) ) |
|
1383 { |
|
1384 Result->InsertL(KPositionFieldNMEASentencesStart ,TLiwVariant( numSentences)) ; |
|
1385 } |
|
1386 }*/ //End of ECapabilityNmea |
|
1387 |
|
1388 } |
|
1389 aOutParamList.AppendL(TLiwGenericParam ( KLocationMap, TLiwVariant(Result))) ; |
|
1390 Result->DecRef(); |
|
1391 CleanupStack :: Pop(Result) ; |
|
1392 |
|
1393 } |
|
1394 |
|
1395 |
|
1396 /** |
|
1397 * Function CLocationInterface :: RequestCancel is used to cancel the pending async request if |
|
1398 * returns the cancell status success if transaction id is valid else KErrGeneral error. |
|
1399 */ |
|
1400 |
|
1401 MLiwNotifyCallback* CLocationInterface :: RequestCancel(TInt32 aTranactionId/*,MLiwNotifyCallback** aCallBack*/) |
|
1402 { |
|
1403 TInt ncalls = iHandleCB.Count() ; |
|
1404 |
|
1405 for(TInt iter = 0 ; iter < ncalls ; ++iter ) |
|
1406 { |
|
1407 |
|
1408 if( iHandleCB[iter] ) |
|
1409 { |
|
1410 if(iHandleCB[iter]->GetTransactionId() == aTranactionId) |
|
1411 { |
|
1412 TInt requestType = iHandleCB[iter]->GetRequestType() ; |
|
1413 TInt cancelType = ECancelGetLocation ; |
|
1414 |
|
1415 |
|
1416 if(requestType == KTraceCB) |
|
1417 { |
|
1418 cancelType = ECancelTrace ; |
|
1419 } |
|
1420 iLocationService->CancelOnGoingService(cancelType ) ; |
|
1421 |
|
1422 MLiwNotifyCallback* callobj = iHandleCB[iter]->GetCallBackobj(); |
|
1423 |
|
1424 return( callobj ) ; |
|
1425 } |
|
1426 } |
|
1427 |
|
1428 } |
|
1429 |
|
1430 //No TransactionId Match found, return Error |
|
1431 return NULL ; |
|
1432 } |
|
1433 |
|
1434 /** |
|
1435 * This function is a static method to create iLocatinInterface object |
|
1436 * return pointer to constructed object else paincs with symbian painc |
|
1437 * code |
|
1438 */ |
|
1439 |
|
1440 CLocationInterface * CLocationInterface :: NewL() |
|
1441 { |
|
1442 CLocationInterface *self = new(ELeave)CLocationInterface() ; |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 CleanupStack :: PushL(self) ; |
|
1448 self->iLocationService = CLocationService :: NewL() ; |
|
1449 TInt error = (self->iLocationService)->GetModuleInfo(self->iModuleInfo) ; |
|
1450 |
|
1451 |
|
1452 User :: LeaveIfError(error) ; |
|
1453 |
|
1454 error = (self->SetSupportedFields()) ; |
|
1455 |
|
1456 User :: LeaveIfError(error) ; |
|
1457 CleanupStack :: Pop(self) ; |
|
1458 return self ; |
|
1459 |
|
1460 } |
|
1461 |
|
1462 /** |
|
1463 * Function : ExecuteCmdL , called directly by consumer, parses the input parameters and |
|
1464 * then calls appropriate method on iLocationService object |
|
1465 */ |
|
1466 |
|
1467 |
|
1468 void CLocationInterface :: ExecuteCmdL( const TDesC8& aCmdName, |
|
1469 const CLiwGenericParamList& aInParamList , |
|
1470 CLiwGenericParamList& aOutParamList, |
|
1471 TUint aCmdOptions, |
|
1472 MLiwNotifyCallback* aCallback ) |
|
1473 { |
|
1474 |
|
1475 TRAPD(error , CmdExecuteL(aCmdName , aInParamList , aOutParamList , aCmdOptions , aCallback)) ; |
|
1476 |
|
1477 |
|
1478 TInt sapierror = ConvertToSapiError(error); |
|
1479 aOutParamList.AppendL(TLiwGenericParam(KErrorCode , TLiwVariant((TInt32)sapierror))) ; |
|
1480 |
|
1481 |
|
1482 |
|
1483 } |
|
1484 |
|
1485 |
|
1486 |
|
1487 /** |
|
1488 * Function: ConvertPosToGenricList puts the latitude, longitude and altitude information |
|
1489 * into generic parmater list |
|
1490 * This is an internal utility function |
|
1491 */ |
|
1492 |
|
1493 void CLocationInterface :: ConvertPosToGenricListL( TPosition& aPos , CLiwGenericParamList& aOutList ) |
|
1494 { |
|
1495 CLiwDefaultMap *Result = CLiwDefaultMap::NewL() ; |
|
1496 TReal64 Val = aPos.Longitude() ; |
|
1497 |
|
1498 Result->InsertL(KLongitudeKey , TLiwVariant((TReal)Val)) ; //Inserting latitude |
|
1499 |
|
1500 Val = aPos.Latitude() ; |
|
1501 Result->InsertL(KLatitudeKey , TLiwVariant((TReal)Val)) ; //Inserting latitude |
|
1502 |
|
1503 TReal32 altitude = aPos.Altitude() ; |
|
1504 |
|
1505 |
|
1506 Result->InsertL(KAltitudeKey , TLiwVariant((TReal)altitude)) ; //Inserting altitude |
|
1507 |
|
1508 //Now Push this map into outparm list |
|
1509 TLiwVariant MapVariant(Result) ; |
|
1510 |
|
1511 TLiwGenericParam outParm(KLocationMap , TLiwVariant(MapVariant)) ; |
|
1512 // outParm.SetSemanticId(EGenericParamLocation) ; |
|
1513 aOutList.AppendL(outParm) ; |
|
1514 Result->DecRef(); |
|
1515 |
|
1516 } |
|
1517 |
|
1518 /** |
|
1519 * Internal function which is used to extract the coordinates from CLiwMap passed by consumer |
|
1520 */ |
|
1521 |
|
1522 void CLocationInterface :: FillCoordinatesL ( TCoordinate& aCoordinate , const CLiwMap* aMap ) |
|
1523 { |
|
1524 TLiwVariant longitudevar ; |
|
1525 TLiwVariant latitudevar ; |
|
1526 TLiwVariant altitudevar ; |
|
1527 |
|
1528 |
|
1529 |
|
1530 if( !aMap->FindL(KLongitudeKey , longitudevar) ) |
|
1531 User::Leave( SErrMissingArgument ); |
|
1532 |
|
1533 if( !aMap->FindL(KLatitudeKey , latitudevar) ) |
|
1534 User::Leave( SErrMissingArgument ); |
|
1535 |
|
1536 |
|
1537 if( !aMap->FindL(KAltitudeKey , altitudevar ) ) |
|
1538 User::Leave( SErrMissingArgument ); |
|
1539 |
|
1540 |
|
1541 TReal64 latitude = 0,longitude = 0,altitude = 0; |
|
1542 if ( ( latitudevar.TypeId() == EVariantTypeTReal ) || ( latitudevar.TypeId() == EVariantTypeTInt32 ) ) |
|
1543 { |
|
1544 latitude = (TReal64)latitudevar.AsTReal() ; |
|
1545 } |
|
1546 else |
|
1547 User::Leave( KErrArgument ); |
|
1548 |
|
1549 if ( ( longitudevar.TypeId() == EVariantTypeTReal ) || ( longitudevar.TypeId() == EVariantTypeTInt32 ) ) |
|
1550 { |
|
1551 longitude = (TReal64)longitudevar.AsTReal() ; |
|
1552 } |
|
1553 else |
|
1554 User::Leave( KErrArgument ); |
|
1555 |
|
1556 if ( ( altitudevar.TypeId() == EVariantTypeTReal ) || ( altitudevar.TypeId() == EVariantTypeTInt32 ) ) |
|
1557 { |
|
1558 altitude = (TReal64)altitudevar.AsTReal() ; |
|
1559 } |
|
1560 else |
|
1561 User::Leave( KErrArgument ); |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 aCoordinate.SetCoordinate( latitude , longitude , altitude) ; |
|
1567 |
|
1568 |
|
1569 } |
|
1570 |
|
1571 /** |
|
1572 * CLocationInterface ::SetUpdateOption extracts updates options from input CLiwMap into TpositonUpdatedOptions |
|
1573 * This is an internal utility function |
|
1574 */ |
|
1575 TInt CLocationInterface ::SetUpdateOption(TPositionUpdateOptions& aPositionUpdateoption,const CLiwMap* aUpdatemap) |
|
1576 { |
|
1577 |
|
1578 TLiwVariant options ; |
|
1579 |
|
1580 |
|
1581 |
|
1582 //Extrace Update interval |
|
1583 if(aUpdatemap->FindL(KUpdateOptionInterval,options)) |
|
1584 { |
|
1585 if( ( options.TypeId() == LIW::EVariantTypeTInt32 ) || ( options.TypeId() == LIW::EVariantTypeTReal ) ) |
|
1586 { |
|
1587 TInt interval = options.AsTInt32(); |
|
1588 if( interval < 0 ) |
|
1589 { |
|
1590 return KErrBadTime; |
|
1591 } |
|
1592 aPositionUpdateoption.SetUpdateInterval(TTimeIntervalMicroSeconds(interval)); |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 return KErrArgument; |
|
1597 |
|
1598 } |
|
1599 |
|
1600 } |
|
1601 else//set the default value |
|
1602 { |
|
1603 aPositionUpdateoption.SetUpdateInterval(TTimeIntervalMicroSeconds(KLocUpdateInterval)); |
|
1604 |
|
1605 } |
|
1606 |
|
1607 //Update time out |
|
1608 if(aUpdatemap->FindL(KUpdateOptionTimeOut,options)) |
|
1609 { |
|
1610 if( ( options.TypeId() == LIW::EVariantTypeTInt32 ) || ( options.TypeId() == LIW::EVariantTypeTReal ) ) |
|
1611 { |
|
1612 TInt timeOut = options.AsTInt32(); |
|
1613 if( timeOut < 0 ) |
|
1614 { |
|
1615 return KErrBadTime; |
|
1616 } |
|
1617 aPositionUpdateoption.SetUpdateTimeOut(TTimeIntervalMicroSeconds(timeOut)); |
|
1618 } |
|
1619 else |
|
1620 { |
|
1621 return KErrArgument; |
|
1622 } |
|
1623 |
|
1624 } |
|
1625 else//set the default value |
|
1626 { |
|
1627 aPositionUpdateoption.SetUpdateTimeOut(TTimeIntervalMicroSeconds(KLocUpdateTimeOut)); |
|
1628 |
|
1629 } |
|
1630 |
|
1631 //Update maxage specifies |
|
1632 if(aUpdatemap->FindL(KUpdateOptionMaxAge,options)) |
|
1633 { |
|
1634 if( ( options.TypeId() == LIW::EVariantTypeTInt32 ) || ( options.TypeId() == LIW::EVariantTypeTReal ) ) |
|
1635 { |
|
1636 TInt maxAge = options.AsTInt32(); |
|
1637 if( maxAge < 0 ) |
|
1638 { |
|
1639 return KErrBadTime; |
|
1640 } |
|
1641 |
|
1642 aPositionUpdateoption.SetMaxUpdateAge(TTimeIntervalMicroSeconds(maxAge)); |
|
1643 } |
|
1644 else |
|
1645 { |
|
1646 return KErrArgument; |
|
1647 } |
|
1648 |
|
1649 } |
|
1650 else//set the default value |
|
1651 { |
|
1652 aPositionUpdateoption.SetMaxUpdateAge(TTimeIntervalMicroSeconds(KLocMaxAge)); |
|
1653 |
|
1654 } |
|
1655 //Partial Updates |
|
1656 if(aUpdatemap->FindL(KPartialUpdates , options )) |
|
1657 { |
|
1658 if( options.TypeId() != LIW::EVariantTypeTBool ) |
|
1659 { |
|
1660 return KErrArgument; |
|
1661 } |
|
1662 |
|
1663 TBool partialUpdates = options.AsTBool() ; |
|
1664 aPositionUpdateoption.SetAcceptPartialUpdates(partialUpdates) ; |
|
1665 } |
|
1666 else//set the default value |
|
1667 { |
|
1668 aPositionUpdateoption.SetAcceptPartialUpdates(FALSE) ; |
|
1669 |
|
1670 |
|
1671 } |
|
1672 |
|
1673 return KErrNone; |
|
1674 |
|
1675 } |
|
1676 |