|
1 // lbs.cpp |
|
2 // |
|
3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <fshell/common.mmh> |
|
14 |
|
15 #include <lbs.h> |
|
16 #include <lbssatellite.h> |
|
17 #include <LbsErrors.h> |
|
18 |
|
19 #if defined (FSHELL_PLATFORM_S60) || defined (FSHELL_PLATFORM_FOUNDATION) |
|
20 #include <EPos_CPosModules.h> |
|
21 #include <EPos_CPosModuleUpdate.h> |
|
22 #include <EPos_CPosModuleIdList.h> |
|
23 #endif |
|
24 |
|
25 #if !defined (FSHELL_PLATFORM_S60) && !defined (FSHELL_PLATFORM_FOUNDATION) |
|
26 #include <lbs/lbsadmin.h> |
|
27 #endif |
|
28 |
|
29 #include <fshell/ioutils.h> |
|
30 using namespace IoUtils; |
|
31 |
|
32 class CCmdLbs : public CCommandBase |
|
33 { |
|
34 public: |
|
35 void PrintTime(const TTime& aTime, TBool aNewline); |
|
36 static const TDesC* TechnologyTypeToString(TPositionModuleInfo::TTechnologyType aType); |
|
37 static const TDesC* DeviceLocationToString(TPositionModuleInfo::TDeviceLocation aLoc); |
|
38 static const TDesC* CostIndicatorToString(TPositionQuality::TCostIndicator aCost); |
|
39 static const TDesC* PowerConsumptionToString(TPositionQuality::TPowerConsumption aPower); |
|
40 static void CapabilitiesToString(TPositionModuleInfo::TCapabilities aCap, TDes &aDes); |
|
41 |
|
42 static CCommandBase* NewLC(); |
|
43 ~CCmdLbs(); |
|
44 private: |
|
45 CCmdLbs(); |
|
46 void PrintModuleDetail(TPositionModuleInfo& aModInfo); |
|
47 void DoListModuleL(); |
|
48 void DoListModuleS60L(); |
|
49 void DoLocation(); |
|
50 void DoEnableModuleL(TBool aEnable = ETrue); |
|
51 #if !defined (FSHELL_PLATFORM_S60) |
|
52 void DoSynchTimeL(); |
|
53 #endif |
|
54 |
|
55 private: // From CCommandBase. |
|
56 virtual const TDesC& Name() const; |
|
57 virtual void DoRunL(); |
|
58 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
59 virtual void OptionsL(RCommandOptionList& aOptions); |
|
60 |
|
61 private: |
|
62 CActiveSchedulerWait* iActiveWait; |
|
63 RPositionServer iPosSrv; |
|
64 RPositioner iPos; |
|
65 TPositionSatelliteInfo iSatelliteInfo; //NOT all LBS modules accept satellite info |
|
66 TPositionInfo iPosInfo; |
|
67 TPositionInfoBase* ipPosInfo; //point to appropriate structure |
|
68 |
|
69 RArray<TBool> iVerbose; |
|
70 TInt iOptModuleIndex; //which module to use (module index, not id) |
|
71 TInt iOptTimeoutSec; //timeout in second, default is 60 second |
|
72 TInt iOptLoops; //how many loops (default 1) |
|
73 |
|
74 enum TLbsCmd |
|
75 { |
|
76 ECmdLocation, |
|
77 ECmdListModule, |
|
78 ECmdListModuleS60, |
|
79 ECmdEnableModule, |
|
80 ECmdDisableModule, |
|
81 ECmdSynchTime //synchronise system time with GPS timestamp |
|
82 }; |
|
83 |
|
84 |
|
85 TLbsCmd iCommand; |
|
86 }; |
|
87 |
|
88 CCommandBase* CCmdLbs::NewLC() |
|
89 { |
|
90 CCmdLbs* self = new(ELeave) CCmdLbs(); |
|
91 CleanupStack::PushL(self); |
|
92 self->BaseConstructL(); |
|
93 return self; |
|
94 } |
|
95 |
|
96 CCmdLbs::CCmdLbs() |
|
97 { |
|
98 iOptModuleIndex = -1; |
|
99 iOptTimeoutSec = 300; |
|
100 iOptLoops = 1; |
|
101 iActiveWait = new (ELeave) CActiveSchedulerWait; |
|
102 } |
|
103 |
|
104 |
|
105 CCmdLbs::~CCmdLbs() |
|
106 { |
|
107 iPos.Close(); |
|
108 iPosSrv.Close(); |
|
109 |
|
110 iVerbose.Close(); |
|
111 delete iActiveWait; |
|
112 } |
|
113 |
|
114 ////////////////////////////////////////////////////// |
|
115 |
|
116 |
|
117 ////////////////////////////////////////////////////// |
|
118 |
|
119 const TDesC& CCmdLbs::Name() const |
|
120 { |
|
121 _LIT(KName, "lbs"); |
|
122 return KName; |
|
123 } |
|
124 |
|
125 void CCmdLbs::ArgumentsL(RCommandArgumentList& aArguments) |
|
126 { |
|
127 _LIT(KArgCommand, "command"); |
|
128 aArguments.AppendEnumL((TInt&)iCommand, KArgCommand); |
|
129 } |
|
130 |
|
131 void CCmdLbs::OptionsL(RCommandOptionList& aOptions) |
|
132 { |
|
133 _LIT(KOptVerbose, "verbose"); |
|
134 aOptions.AppendBoolL(iVerbose, KOptVerbose); |
|
135 |
|
136 _LIT(KOptModuleIndex, "module-index"); |
|
137 aOptions.AppendUintL((TUint&)iOptModuleIndex, KOptModuleIndex); |
|
138 |
|
139 _LIT(KOptLoops, "loops"); |
|
140 aOptions.AppendUintL((TUint&)iOptLoops, KOptLoops); |
|
141 |
|
142 _LIT(KOptTimeout, "timeout"); |
|
143 aOptions.AppendUintL((TUint&)iOptTimeoutSec, KOptTimeout); |
|
144 } |
|
145 |
|
146 void CCmdLbs::DoRunL() |
|
147 { |
|
148 Printf(_L("Connecting to RPositionServer...\r\n")); |
|
149 TInt err = iPosSrv.Connect(); |
|
150 LeaveIfErr(err, _L("Cannot connect to position server")); |
|
151 |
|
152 switch(iCommand) |
|
153 { |
|
154 case ECmdLocation: |
|
155 DoLocation(); |
|
156 break; |
|
157 case ECmdListModule: |
|
158 DoListModuleL(); |
|
159 break; |
|
160 case ECmdListModuleS60: |
|
161 DoListModuleS60L(); |
|
162 break; |
|
163 case ECmdEnableModule: |
|
164 DoEnableModuleL(ETrue); |
|
165 break; |
|
166 case ECmdDisableModule: |
|
167 DoEnableModuleL(EFalse); |
|
168 break; |
|
169 case ECmdSynchTime: |
|
170 //TODO There's no way of actually specifying this command |
|
171 #if !defined (FSHELL_PLATFORM_S60) |
|
172 DoSynchTimeL(); |
|
173 #else |
|
174 LeaveIfErr(KErrNotSupported, _L("SynchTime not supported on S60")); |
|
175 #endif |
|
176 break; |
|
177 } |
|
178 |
|
179 } |
|
180 |
|
181 void CCmdLbs::DoLocation() |
|
182 { |
|
183 TInt VerboseLevel = iVerbose.Count(); |
|
184 TInt err; |
|
185 TBool bSatelliteCapable = EFalse; |
|
186 TPositionModuleId modId; //which module to use |
|
187 if (iOptModuleIndex != -1) |
|
188 { |
|
189 TPositionModuleInfo modInfo; |
|
190 err = iPosSrv.GetModuleInfoByIndex(iOptModuleIndex, modInfo); |
|
191 LeaveIfErr(err, _L("invalid module index")); |
|
192 modId = modInfo.ModuleId(); |
|
193 } |
|
194 else |
|
195 { //use the default module |
|
196 err = iPosSrv.GetDefaultModuleId(modId); |
|
197 LeaveIfErr(err, _L("Invalid default module")); |
|
198 } |
|
199 |
|
200 TPositionModuleInfo modInfo; |
|
201 err = iPosSrv.GetModuleInfoById(modId, modInfo); |
|
202 TBuf<128> modName; |
|
203 modInfo.GetModuleName(modName); |
|
204 |
|
205 Printf(_L("Openning RPositioner...(Module ID: 0x%X \"%S\")\r\n"), modId.iUid, &modName); |
|
206 err = iPos.Open(iPosSrv, modId); |
|
207 LeaveIfErr(err, _L("Cannot open positioner")); |
|
208 |
|
209 // Set position requestor, it is compulsory on S60 only |
|
210 err = iPos.SetRequestor( CRequestor::ERequestorService , |
|
211 CRequestor::EFormatApplication , _L("FSHELL FLBS COMMAND") ); |
|
212 LeaveIfErr(err, _L("Cannot set requestor")); |
|
213 |
|
214 TPositionUpdateOptions UpdateOption; |
|
215 TTimeIntervalMicroSeconds TimeoutMs = (TInt64)iOptTimeoutSec * (TInt64)1000000; |
|
216 UpdateOption.SetUpdateTimeOut(TimeoutMs); |
|
217 |
|
218 Printf(_L("SetUpdateOptions... Timeout = %d seconds\r\n"), iOptTimeoutSec); |
|
219 err = iPos.SetUpdateOptions(UpdateOption); |
|
220 LeaveIfErr(err, _L("Cannot set update options")); |
|
221 |
|
222 //check if the module is capable of satellite info |
|
223 { |
|
224 TPositionModuleInfo::TCapabilities modCap = modInfo.Capabilities(); |
|
225 bSatelliteCapable = modCap & TPositionModuleInfo::ECapabilitySatellite; |
|
226 if (bSatelliteCapable) |
|
227 { |
|
228 ipPosInfo = &iSatelliteInfo; |
|
229 Printf(_L("This module is capable of receiving satellite information\r\n")); |
|
230 } |
|
231 else |
|
232 ipPosInfo = &iPosInfo; |
|
233 } |
|
234 |
|
235 for (TInt i=0; i<iOptLoops; i++) |
|
236 { |
|
237 TRequestStatus status; |
|
238 TPosition pos; |
|
239 Printf(_L("Calling RPositioner::NotifyPositionUpdate...\r\n")); |
|
240 iPos.NotifyPositionUpdate(*ipPosInfo, status); |
|
241 User::WaitForRequest(status); |
|
242 |
|
243 err = status.Int(); |
|
244 if (err != KErrNone) |
|
245 LeaveIfErr(err, _L("NotifyPositionUpdate encountered an error")); |
|
246 |
|
247 static_cast <TPositionInfo*>(ipPosInfo) -> GetPosition(pos); |
|
248 TTime LocTime = pos.Time(); |
|
249 TReal32 HorizontalAccuracy = pos.HorizontalAccuracy(); |
|
250 TReal32 VerticalAccuracy = pos.VerticalAccuracy(); |
|
251 //print current location information |
|
252 Printf(_L("Altit:%f Latit:%f Longt:%f HAccu:%.2f VAccu:%.2f\r\n"), |
|
253 pos.Altitude(), pos.Latitude(), pos.Longitude(), |
|
254 HorizontalAccuracy, VerticalAccuracy); |
|
255 |
|
256 Printf(_L("Location Signal Time:")); |
|
257 PrintTime(LocTime, ETrue); |
|
258 |
|
259 //if there is satellite information, optionally print it out |
|
260 if (bSatelliteCapable && (VerboseLevel>0) ) |
|
261 { |
|
262 TPositionSatelliteInfo* pSateInfo = static_cast <TPositionSatelliteInfo*> (ipPosInfo); |
|
263 |
|
264 TInt NumSatellitesInView = pSateInfo->NumSatellitesInView(); |
|
265 TInt NumSatellitesUsed = pSateInfo->NumSatellitesUsed(); |
|
266 TTime SatelliteTime = pSateInfo->SatelliteTime(); |
|
267 TReal32 HorizontalDoP = pSateInfo->HorizontalDoP(); |
|
268 TReal32 VerticalDoP = pSateInfo->VerticalDoP(); |
|
269 TReal32 TimeDoP = pSateInfo->TimeDoP(); |
|
270 Printf(_L("Satellite In View:%d Used:%d Time:"), |
|
271 NumSatellitesInView, NumSatellitesUsed ); |
|
272 PrintTime(SatelliteTime, ETrue); |
|
273 Printf(_L("HoriDop:%f VertDop:%f TimeDop:%f \r\n"), |
|
274 HorizontalDoP, VerticalDoP, TimeDoP); |
|
275 |
|
276 //Print each satellite info |
|
277 for (TInt i=0; i<NumSatellitesInView; i++ ) |
|
278 { |
|
279 TSatelliteData SatellliteData; |
|
280 err = pSateInfo->GetSatelliteData((TUint)i, SatellliteData); |
|
281 if (err == KErrNotFound) |
|
282 { |
|
283 Printf(_L("Satellite #%d Not Found\r\n"), i); |
|
284 continue; |
|
285 } |
|
286 else |
|
287 { |
|
288 User::LeaveIfError(err); |
|
289 } |
|
290 |
|
291 TInt SatelliteId = SatellliteData.SatelliteId(); |
|
292 TReal32 Azimuth = SatellliteData.Azimuth(); |
|
293 TReal32 Elevation = SatellliteData.Elevation(); |
|
294 TBool IsUsed = SatellliteData.IsUsed(); |
|
295 TInt SignalStrength = SatellliteData.SignalStrength(); |
|
296 |
|
297 Printf(_L("Satellite #%d, ID:%d Azimuth %.2f Elevation %.2f IsUsed:%d Strenth:%d\r\n"), |
|
298 i, SatelliteId, Azimuth, Elevation, IsUsed, SignalStrength); |
|
299 |
|
300 } |
|
301 } |
|
302 } |
|
303 } |
|
304 |
|
305 void CCmdLbs::DoListModuleL() |
|
306 { |
|
307 TInt err; |
|
308 TUint numModules; |
|
309 TPositionModuleInfo modInfo; |
|
310 |
|
311 err = iPosSrv.GetNumModules(numModules); |
|
312 User::LeaveIfError(err); |
|
313 |
|
314 Printf(_L("%d Modules found\r\n"), |
|
315 numModules); |
|
316 |
|
317 for (TUint i=0 ; i < numModules ; i++) |
|
318 { |
|
319 Printf(_L("============================\r\n")); |
|
320 err = iPosSrv.GetModuleInfoByIndex(i, modInfo); |
|
321 User::LeaveIfError(err); |
|
322 |
|
323 Printf(_L("Module Index: %d\r\n"), i); |
|
324 |
|
325 PrintModuleDetail(modInfo); |
|
326 } |
|
327 |
|
328 Printf(_L("=================================\r\n")); |
|
329 //print default module ID |
|
330 TPositionModuleId DefaultId; |
|
331 err = iPosSrv.GetDefaultModuleId(DefaultId); |
|
332 Printf(_L("Default Module ID 0x%X\r\n"), DefaultId.iUid ); |
|
333 } |
|
334 |
|
335 //S60 proprietary |
|
336 //similar to DoListModuleL, but list module based on S60 API, |
|
337 //and sometimes it gives different results than symbain API |
|
338 void CCmdLbs::DoListModuleS60L() |
|
339 { |
|
340 #ifdef FSHELL_PLATFORM_S60 |
|
341 //TInt err; |
|
342 TUint numModules; |
|
343 CPosModules* pModHand = CPosModules::OpenL(); |
|
344 CleanupStack::PushL(pModHand); |
|
345 |
|
346 CPosModuleIdList* pIdList = pModHand->ModuleIdListL(); |
|
347 CleanupStack::PushL(pIdList); |
|
348 |
|
349 numModules = pIdList->Count(); |
|
350 Printf(_L("%d Modules found\r\n"), |
|
351 numModules); |
|
352 |
|
353 for (TUint i=0 ; i < numModules ; i++) |
|
354 { |
|
355 Printf(_L("============================\r\n")); |
|
356 TPositionModuleId S60modId = (*pIdList) [i]; |
|
357 TPositionModuleInfo S60modInfo; |
|
358 TBuf<128> S60modName; //to store module name |
|
359 |
|
360 pModHand->GetModuleInfoL(S60modId, S60modInfo); |
|
361 S60modInfo.GetModuleName(S60modName); |
|
362 |
|
363 Printf(_L("Module Index: %d\r\n"), i); |
|
364 |
|
365 PrintModuleDetail(S60modInfo); |
|
366 } |
|
367 |
|
368 Printf(_L("=================================\r\n")); |
|
369 |
|
370 CleanupStack::PopAndDestroy(pIdList); |
|
371 CleanupStack::PopAndDestroy(pModHand); |
|
372 #endif |
|
373 } |
|
374 |
|
375 void CCmdLbs::PrintModuleDetail(TPositionModuleInfo& aModInfo) |
|
376 { |
|
377 //TInt err; |
|
378 TBool bAvailable = aModInfo.IsAvailable(); |
|
379 |
|
380 TPositionModuleId modId; |
|
381 modId = aModInfo.ModuleId(); |
|
382 |
|
383 TBuf<128> modName; |
|
384 aModInfo.GetModuleName(modName); |
|
385 |
|
386 //==quality |
|
387 TPositionQuality modQuality; |
|
388 aModInfo.GetPositionQuality(modQuality); |
|
389 TTimeIntervalMicroSeconds firstFix = modQuality.TimeToFirstFix(); |
|
390 TTimeIntervalMicroSeconds nextFix = modQuality.TimeToNextFix(); |
|
391 TReal32 horiAccu = modQuality.HorizontalAccuracy(); |
|
392 TReal32 vertAccu = modQuality.VerticalAccuracy(); |
|
393 TPositionQuality::TCostIndicator cost = modQuality.CostIndicator(); |
|
394 TPositionQuality::TPowerConsumption power = modQuality.PowerConsumption(); |
|
395 //////////////////////////////////////////////////////////////// |
|
396 TPositionModuleInfo::TTechnologyType modType = aModInfo.TechnologyType(); |
|
397 TPositionModuleInfo::TDeviceLocation modLoc = aModInfo.DeviceLocation(); |
|
398 TPositionModuleInfo::TCapabilities modCap = aModInfo.Capabilities(); |
|
399 TVersion modVersion = aModInfo.Version(); |
|
400 TVersionName VersionName = modVersion.Name(); |
|
401 |
|
402 //TPositionClassFamily aClassType; |
|
403 //modInfo.ClassesSupported(aClassType); |
|
404 |
|
405 Printf(_L("Module Id:0x%X, Name:\"%S\" Available:%d \r\n"), |
|
406 modId.iUid, &modName, bAvailable); |
|
407 Printf(_L("Type:%S Version:%S\r\n"), |
|
408 TechnologyTypeToString(modType), &VersionName ); |
|
409 Printf(_L("Location:%S\r\n"), DeviceLocationToString (modLoc)); |
|
410 |
|
411 Printf(_L("Quality first fix:%Ld next fix:%Ld \r\n"), |
|
412 firstFix.Int64(), nextFix.Int64()); |
|
413 Printf(_L("Horizontal Accuracy:%f Vertical Accuray:%f \r\n"), |
|
414 horiAccu, vertAccu); |
|
415 Printf(_L("Cost Indicator:%S\r\n"), CostIndicatorToString(cost)); |
|
416 Printf(_L("Power Consumption:%S\r\n"), PowerConsumptionToString(power)); |
|
417 |
|
418 TBuf<256> CapString; |
|
419 CapabilitiesToString(modCap, CapString); |
|
420 Printf(_L("Capabilities:%S\r\n"), &CapString); |
|
421 } |
|
422 |
|
423 //it is a S60 proprietary function |
|
424 // |
|
425 void CCmdLbs::DoEnableModuleL(TBool aEnable) |
|
426 { |
|
427 TInt err; |
|
428 TBuf<128> modName; //to store module name |
|
429 TPositionModuleInfo modInfo; |
|
430 TPositionModuleId modId = TUid::Null(); //which module to use |
|
431 TBool bIsCurAvail; |
|
432 |
|
433 if (iOptModuleIndex != -1) |
|
434 { |
|
435 err = iPosSrv.GetModuleInfoByIndex(iOptModuleIndex, modInfo); |
|
436 LeaveIfErr(err, _L("invalid module index")); |
|
437 modId = modInfo.ModuleId(); |
|
438 } |
|
439 else |
|
440 { |
|
441 LeaveIfErr(KErrArgument, _L("Need to specify a module")); |
|
442 } |
|
443 |
|
444 bIsCurAvail = modInfo.IsAvailable(); |
|
445 modInfo.GetModuleName(modName); |
|
446 |
|
447 TPtrC AvailNow = (bIsCurAvail)?_L("Yes"):_L("No"); |
|
448 Printf(_L("Module Id=0x%08x Name:\"%S\" Current Availability:%S \r\n"), |
|
449 modId.iUid, &modName, &AvailNow); |
|
450 |
|
451 //modInfo.SetIsAvailable(ETrue); //Note: this has no effect on S60 platform |
|
452 |
|
453 #ifdef FSHELL_PLATFORM_S60 |
|
454 CPosModules* pModHand = CPosModules::OpenL(); |
|
455 CleanupStack::PushL(pModHand); |
|
456 |
|
457 //diagnosis code: to verify the information given by S60 API matches Symbian API |
|
458 { |
|
459 CPosModuleIdList* pIdList = pModHand->ModuleIdListL(); |
|
460 CleanupStack::PushL(pIdList); |
|
461 |
|
462 TPositionModuleId S60modId = (*pIdList) [iOptModuleIndex]; |
|
463 TPositionModuleInfo S60modInfo; |
|
464 TBuf<128> S60modName; //to store module name |
|
465 |
|
466 pModHand->GetModuleInfoL(S60modId, S60modInfo); |
|
467 S60modInfo.GetModuleName(S60modName); |
|
468 RDebug::Print(_L("S60 LBS module name:%S"), &S60modName); |
|
469 |
|
470 CleanupStack::PopAndDestroy(pIdList); |
|
471 } |
|
472 |
|
473 |
|
474 CPosModuleUpdate* pModUpdate = CPosModuleUpdate::NewLC(); |
|
475 TBool bNewAvail = aEnable; |
|
476 pModUpdate->SetUpdateAvailability(bNewAvail); |
|
477 TRAP(err, pModHand->UpdateModuleL(modId, *pModUpdate)); |
|
478 LeaveIfErr(err, _L("Could not update module information") ); |
|
479 |
|
480 CleanupStack::PopAndDestroy(pModUpdate); |
|
481 CleanupStack::PopAndDestroy(pModHand); |
|
482 #endif |
|
483 |
|
484 //verify if the change has take effect |
|
485 { |
|
486 err = iPosSrv.GetModuleInfoByIndex(iOptModuleIndex, modInfo); |
|
487 LeaveIfErr(err, _L("invalid module index")); |
|
488 modId = modInfo.ModuleId(); |
|
489 bIsCurAvail = modInfo.IsAvailable(); |
|
490 TPtrC NewAvail = (bIsCurAvail)?_L("Yes"):_L("No"); |
|
491 Printf(_L("Module Id=0x%08x Name:\"%S\" New Availability:%S \r\n"), |
|
492 modId.iUid, &modName, &NewAvail); |
|
493 } |
|
494 |
|
495 } |
|
496 |
|
497 #if !defined (FSHELL_PLATFORM_S60) |
|
498 void CCmdLbs::DoSynchTimeL() |
|
499 { |
|
500 // Set LBS setting to allow manual clock adjustment |
|
501 //This may not be set by default |
|
502 CLbsAdmin* admin = CLbsAdmin::NewL(); |
|
503 CleanupStack::PushL(admin); |
|
504 CLbsAdmin::TClockAdjust clockAdjust; |
|
505 User::LeaveIfError(admin->Get(KLbsSettingAllowManualClockAdjust,clockAdjust)); |
|
506 admin->Set(KLbsSettingAllowManualClockAdjust,CLbsAdmin::EClockAdjustOn); |
|
507 CleanupStack::PopAndDestroy(admin); |
|
508 } |
|
509 #endif |
|
510 |
|
511 EXE_BOILER_PLATE(CCmdLbs) |
|
512 |
|
513 void CCmdLbs::PrintTime(const TTime& aTime, TBool aNewline) |
|
514 { |
|
515 |
|
516 TTime NullTime = Time::NullTTime(); |
|
517 if (aTime == NullTime) |
|
518 { |
|
519 Printf(_L("(NullTime)")); |
|
520 } |
|
521 else |
|
522 { |
|
523 _LIT8(KDateTimeFormat, "%d-%02d-%02d %02d:%02d:%02d"); |
|
524 TDateTime dt = aTime.DateTime(); |
|
525 Printf(KDateTimeFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second()); |
|
526 } |
|
527 |
|
528 if (aNewline) Printf(_L("\r\n")); |
|
529 } |
|
530 |
|
531 |
|
532 #define CASE_LIT(x) case x: { _LIT(KName, #x); return &KName; } |
|
533 |
|
534 const TDesC* CCmdLbs::TechnologyTypeToString(TPositionModuleInfo::TTechnologyType aType) |
|
535 { |
|
536 switch(aType) |
|
537 { |
|
538 CASE_LIT(TPositionModuleInfo::ETechnologyUnknown); |
|
539 CASE_LIT(TPositionModuleInfo::ETechnologyTerminal); |
|
540 CASE_LIT(TPositionModuleInfo::ETechnologyNetwork); |
|
541 CASE_LIT(TPositionModuleInfo::ETechnologyAssisted); |
|
542 default: |
|
543 { |
|
544 _LIT(KUnknown, "Unknown"); |
|
545 return &KUnknown; |
|
546 } |
|
547 } |
|
548 } |
|
549 |
|
550 |
|
551 const TDesC* CCmdLbs::DeviceLocationToString(TPositionModuleInfo::TDeviceLocation aLoc) |
|
552 { |
|
553 switch(aLoc) |
|
554 { |
|
555 CASE_LIT(TPositionModuleInfo::EDeviceUnknown); |
|
556 CASE_LIT(TPositionModuleInfo::EDeviceInternal); |
|
557 CASE_LIT(TPositionModuleInfo::EDeviceExternal); |
|
558 default: |
|
559 { |
|
560 _LIT(KUnknown, "Unknown"); |
|
561 return &KUnknown; |
|
562 } |
|
563 } |
|
564 } |
|
565 |
|
566 |
|
567 const TDesC* CCmdLbs::CostIndicatorToString(TPositionQuality::TCostIndicator aCost) |
|
568 { |
|
569 switch(aCost) |
|
570 { |
|
571 CASE_LIT(TPositionQuality::ECostUnknown); |
|
572 CASE_LIT(TPositionQuality::ECostZero); |
|
573 CASE_LIT(TPositionQuality::ECostPossible); |
|
574 CASE_LIT(TPositionQuality::ECostCharge); |
|
575 default: |
|
576 { |
|
577 _LIT(KUnknown, "Unknown"); |
|
578 return &KUnknown; |
|
579 } |
|
580 } |
|
581 } |
|
582 |
|
583 const TDesC* CCmdLbs::PowerConsumptionToString(TPositionQuality::TPowerConsumption aPower) |
|
584 { |
|
585 switch(aPower) |
|
586 { |
|
587 CASE_LIT(TPositionQuality::EPowerUnknown); |
|
588 CASE_LIT(TPositionQuality::EPowerZero); |
|
589 CASE_LIT(TPositionQuality::EPowerLow); |
|
590 CASE_LIT(TPositionQuality::EPowerMedium); |
|
591 CASE_LIT(TPositionQuality::EPowerHigh); |
|
592 default: |
|
593 { |
|
594 _LIT(KUnknown, "Unknown"); |
|
595 return &KUnknown; |
|
596 } |
|
597 } |
|
598 } |
|
599 #define CAPFLAG(x) if (aCap & TPositionModuleInfo::x) { aDes += _L(#x); aDes += _L("|");} |
|
600 |
|
601 void CCmdLbs::CapabilitiesToString(TPositionModuleInfo::TCapabilities aCap, TDes &aDes) |
|
602 { |
|
603 aDes.SetLength(0); |
|
604 //if (aCap & TPositionModuleInfo::ECapabilityNone) aDes += _L("ECapabilityNone|"); |
|
605 CAPFLAG(ECapabilityNone); |
|
606 CAPFLAG(ECapabilityHorizontal); |
|
607 CAPFLAG(ECapabilityVertical); |
|
608 CAPFLAG(ECapabilitySpeed); |
|
609 CAPFLAG(ECapabilityDirection); |
|
610 CAPFLAG(ECapabilitySatellite); |
|
611 CAPFLAG(ECapabilityCompass); |
|
612 CAPFLAG(ECapabilityNmea); |
|
613 CAPFLAG(ECapabilityAddress); |
|
614 CAPFLAG(ECapabilityBuilding); |
|
615 CAPFLAG(ECapabilityMedia); |
|
616 } |
|
617 |