1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the Qt Mobility Components. |
7 ** This file is part of the Qt Mobility Components. |
8 ** |
8 ** |
140 QGeoPositionInfo CQGeoPositionInfoSourceS60::lastKnownPosition(bool aFromSatellitePositioningMethodsOnly) const |
143 QGeoPositionInfo CQGeoPositionInfoSourceS60::lastKnownPosition(bool aFromSatellitePositioningMethodsOnly) const |
141 { |
144 { |
142 |
145 |
143 QGeoPositionInfo posUpdate; |
146 QGeoPositionInfo posUpdate; |
144 TPosition pos; |
147 TPosition pos; |
145 PositioningMethod type; |
|
146 TInt error = KErrNone; |
148 TInt error = KErrNone; |
147 RPositioner iLastKnownpositioner; |
149 RPositioner iLastKnownpositioner; |
148 TRequestStatus status; |
150 TRequestStatus status; |
149 |
151 |
150 error = iLastKnownpositioner.Open(*const_cast<RPositionServer*>(&mPositionServer)); |
152 error = iLastKnownpositioner.Open(*const_cast<RPositionServer*>(&mPositionServer)); |
164 error = status.Int(); |
166 error = status.Int(); |
165 |
167 |
166 iLastKnownpositioner.Close(); |
168 iLastKnownpositioner.Close(); |
167 |
169 |
168 if ((error == KErrNone) || (error == KPositionPartialUpdate)) { |
170 if ((error == KErrNone) || (error == KPositionPartialUpdate)) { |
169 |
171 |
170 bool typeSet = false; |
172 TPositionModuleInfo modInfo; |
171 for (int i = 0;i < mListSize ;i++) { |
173 mPositionServer.GetModuleInfoById(posInfo.ModuleId(), modInfo); |
172 if (mList[i].mUid == posInfo.ModuleId()) { |
174 |
173 type = mList[i].mPosMethod; |
175 if(!aFromSatellitePositioningMethodsOnly || (aFromSatellitePositioningMethodsOnly && (modInfo.Capabilities() & TPositionModuleInfo::ECapabilitySatellite))){ |
174 typeSet = true; |
|
175 break; |
|
176 } |
|
177 } |
|
178 |
|
179 if (!((aFromSatellitePositioningMethodsOnly == TRUE) && typeSet && |
|
180 (type != SatellitePositioningMethods))) { |
|
181 QGeoCoordinate coord; |
176 QGeoCoordinate coord; |
182 |
177 |
183 posInfo.GetPosition(pos); |
178 posInfo.GetPosition(pos); |
184 |
179 |
185 coord.setLatitude(pos.Latitude()); |
180 coord.setLatitude(pos.Latitude()); |
383 //time taken for the subsequent fix |
378 //time taken for the subsequent fix |
384 time_to_next_fix = quality.TimeToNextFix(); |
379 time_to_next_fix = quality.TimeToNextFix(); |
385 |
380 |
386 |
381 |
387 if ((i = checkModule(id)) == -1) { |
382 if ((i = checkModule(id)) == -1) { |
|
383 //update the properties of the module |
|
384 |
|
385 //TPositionModuleId of the module |
|
386 mList[mListSize].mUid = id; |
|
387 |
|
388 //positioning method method type |
|
389 mList[mListSize].mPosMethod = method; |
|
390 |
|
391 //status of the device |
|
392 mList[mListSize].mStatus = aStatus; |
|
393 |
|
394 //availablility of the module |
|
395 mList[mListSize].mIsAvailable = available; |
|
396 |
|
397 //horizontal accuracy of the module |
|
398 mList[mListSize].mHorizontalAccuracy = accuracy; |
|
399 |
|
400 //time required to get the first fix |
|
401 mList[mListSize].mTimeToFirstFix = time_to_first_fix; |
|
402 |
|
403 //time required for subsequent fix |
|
404 mList[mListSize].mTimeToNextFix = time_to_next_fix; |
|
405 |
|
406 //count on the mList array size |
|
407 mListSize++; |
|
408 |
|
409 //update the supported source types based on the device status |
|
410 updateAvailableTypes(); |
|
411 |
388 //store the correct method in use from the mCurrentModuleId retireved earlier |
412 //store the correct method in use from the mCurrentModuleId retireved earlier |
389 if (id == mCurrentModuleId) { |
413 if (id == mCurrentModuleId) { |
390 mCurrentMethod = method; |
414 mCurrentMethod = method; |
391 QGeoPositionInfoSource::setPreferredPositioningMethods(mCurrentMethod); |
415 } |
392 } |
|
393 //update the properties of the module |
|
394 |
|
395 //TPositionModuleId of the module |
|
396 mList[mListSize].mUid = id; |
|
397 |
|
398 //positioning method method type |
|
399 mList[mListSize].mPosMethod = method; |
|
400 |
|
401 //status of the device |
|
402 mList[mListSize].mStatus = aStatus; |
|
403 |
|
404 //availablility of the module |
|
405 mList[mListSize].mIsAvailable = available; |
|
406 |
|
407 //horizontal accuracy of the module |
|
408 mList[mListSize].mHorizontalAccuracy = accuracy; |
|
409 |
|
410 //time required to get the first fix |
|
411 mList[mListSize].mTimeToFirstFix = time_to_first_fix; |
|
412 |
|
413 //time required for subsequent fix |
|
414 mList[mListSize].mTimeToNextFix = time_to_next_fix; |
|
415 |
|
416 //count on the mList array size |
|
417 mListSize++; |
|
418 } else { |
416 } else { |
419 //module's status has changed |
417 //module's status has changed |
420 if (mList[i].mStatus != aStatus) |
418 if (mList[i].mStatus != aStatus) |
421 mList[i].mStatus = aStatus; |
419 mList[i].mStatus = aStatus; |
422 |
420 |
433 mList[i].mTimeToFirstFix = time_to_first_fix; |
431 mList[i].mTimeToFirstFix = time_to_first_fix; |
434 |
432 |
435 //module's time to subsequent fix has changed |
433 //module's time to subsequent fix has changed |
436 if (mList[i].mTimeToNextFix != time_to_next_fix) |
434 if (mList[i].mTimeToNextFix != time_to_next_fix) |
437 mList[i].mTimeToFirstFix = time_to_next_fix; |
435 mList[i].mTimeToFirstFix = time_to_next_fix; |
|
436 |
|
437 //update the supported source types based on the device status |
|
438 updateAvailableTypes(); |
438 |
439 |
439 //if the mCurrentModuleId is NULL, try updating the reg update with the available |
440 //if the mCurrentModuleId is NULL, try updating the reg update with the available |
440 //positioning method |
441 //positioning method |
441 if (mCurrentModuleId == TUid::Null() && (available == TRUE) && |
442 if (mCurrentModuleId == TUid::Null() && (available == TRUE) && |
442 (aStatus != TPositionModuleStatus::EDeviceUnknown) && |
443 (aStatus != TPositionModuleStatus::EDeviceUnknown) && |
581 updateStatus(moduleInfo, moduleStatus.DeviceStatus()); |
578 updateStatus(moduleInfo, moduleStatus.DeviceStatus()); |
582 |
579 |
583 mModuleFlags |= (1 << i); |
580 mModuleFlags |= (1 << i); |
584 } |
581 } |
585 } else { |
582 } else { |
586 //UpdateDeviceStatus() called afetr registering for NotifyModuleStatusEvent |
583 //UpdateDeviceStatus() called after registering for NotifyModuleStatusEvent |
587 |
584 |
588 //get the module id from the status event |
585 //get the module id from the status event |
589 TPositionModuleId id = mStatusEvent.ModuleId(); |
586 TPositionModuleId id = mStatusEvent.ModuleId(); |
590 |
587 |
591 //get module information |
588 //get module information |
790 mRegUpdateAO->cancelUpdate(); |
787 mRegUpdateAO->cancelUpdate(); |
791 } |
788 } |
792 |
789 |
793 void CQGeoPositionInfoSourceS60::setPreferredPositioningMethods(PositioningMethods aMethods) |
790 void CQGeoPositionInfoSourceS60::setPreferredPositioningMethods(PositioningMethods aMethods) |
794 { |
791 { |
|
792 QGeoPositionInfoSource::setPreferredPositioningMethods(aMethods); |
|
793 |
795 PositioningMethods preferredMethod(PositioningMethods(0)); |
794 PositioningMethods preferredMethod(PositioningMethods(0)); |
796 TInt index = -1; |
795 TInt index = -1; |
797 // the poistioning methods are not supported |
796 // the poistioning methods are not supported |
798 // if the preferred positioning method is the current poistioning |
797 // if the preferred positioning method is the current poistioning |
799 |
798 |