qtmobility/src/location/qgeopositioninfosource_s60.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
--- a/qtmobility/src/location/qgeopositioninfosource_s60.cpp	Fri Jun 11 14:26:25 2010 +0300
+++ b/qtmobility/src/location/qgeopositioninfosource_s60.cpp	Wed Jun 23 19:08:38 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -124,6 +124,9 @@
 
         //update the list array with the available method initially
         updateDeviceStatus();
+        
+        // Set the PreferredPositioningMethods based on Supported methods
+        QGeoPositionInfoSource::setPreferredPositioningMethods( mSupportedMethods );
 
         //devStatusUpdateAO->NotifyDeviceStatus(mStatusEvent);
 
@@ -142,7 +145,6 @@
 
     QGeoPositionInfo posUpdate;
     TPosition pos;
-    PositioningMethod type;
     TInt error = KErrNone;
     RPositioner iLastKnownpositioner;
     TRequestStatus status;
@@ -166,18 +168,11 @@
         iLastKnownpositioner.Close();
 
         if ((error == KErrNone) || (error == KPositionPartialUpdate)) {
-
-            bool typeSet = false;
-            for (int i = 0;i < mListSize ;i++) {
-                if (mList[i].mUid == posInfo.ModuleId()) {
-                    type = mList[i].mPosMethod;
-                    typeSet = true;
-                    break;
-                }
-            }
-
-            if (!((aFromSatellitePositioningMethodsOnly == TRUE) && typeSet &&
-                    (type != SatellitePositioningMethods))) {
+        
+            TPositionModuleInfo modInfo;
+            mPositionServer.GetModuleInfoById(posInfo.ModuleId(), modInfo);
+            
+            if(!aFromSatellitePositioningMethodsOnly || (aFromSatellitePositioningMethodsOnly && (modInfo.Capabilities() & TPositionModuleInfo::ECapabilitySatellite))){
                 QGeoCoordinate  coord;
 
                 posInfo.GetPosition(pos);
@@ -385,11 +380,6 @@
 
 
     if ((i = checkModule(id)) == -1) {
-        //store the correct method in use from the mCurrentModuleId retireved earlier
-        if (id == mCurrentModuleId) {
-            mCurrentMethod = method;
-            QGeoPositionInfoSource::setPreferredPositioningMethods(mCurrentMethod);
-        }
         //update the properties of the module
 
         //TPositionModuleId of the module
@@ -415,6 +405,14 @@
 
         //count on the mList array size
         mListSize++;
+        
+        //update the supported source types based on the device status
+        updateAvailableTypes();
+        
+        //store the correct method in use from the mCurrentModuleId retireved earlier
+        if (id == mCurrentModuleId) {
+            mCurrentMethod = method;
+        }
     } else {
         //module's status has changed
         if (mList[i].mStatus != aStatus)
@@ -435,6 +433,9 @@
         //module's time to subsequent fix has changed
         if (mList[i].mTimeToNextFix != time_to_next_fix)
             mList[i].mTimeToFirstFix = time_to_next_fix;
+        
+        //update the supported source types based on the device status
+        updateAvailableTypes();
 
         //if the mCurrentModuleId is NULL, try updating the reg update with the available
         //positioning method
@@ -464,7 +465,6 @@
 
                 mCurrentMethod = mList[i].mPosMethod;
 
-                QGeoPositionInfoSource::setPreferredPositioningMethods(mCurrentMethod);
             }
         }
 
@@ -512,7 +512,6 @@
 
                     mCurrentModuleId = mList[index].mUid;
                     mCurrentMethod = mList[index].mPosMethod;
-                    QGeoPositionInfoSource::setPreferredPositioningMethods(mCurrentMethod);
 
                     mRegUpdateAO->setUpdateInterval(interval);
 
@@ -526,7 +525,7 @@
                     mRegUpdateAO = NULL;
                     mCurrentModuleId = TUid::Null();
                     mCurrentMethod = PositioningMethod(0);
-                    QGeoPositionInfoSource::setPreferredPositioningMethods(mCurrentMethod);
+                    
                     emit updateTimeout();
                 }
 
@@ -545,8 +544,6 @@
 
     }   //end else
 
-    //update the supported source types based on the device status
-    updateAvailableTypes();
 }
 
 
@@ -583,7 +580,7 @@
             mModuleFlags |= (1 << i);
         }
     } else {
-        //UpdateDeviceStatus() called afetr registering for NotifyModuleStatusEvent
+        //UpdateDeviceStatus() called after registering for NotifyModuleStatusEvent
 
         //get the module id from the status event
         TPositionModuleId id = mStatusEvent.ModuleId();
@@ -792,6 +789,8 @@
 
 void CQGeoPositionInfoSourceS60::setPreferredPositioningMethods(PositioningMethods aMethods)
 {
+    QGeoPositionInfoSource::setPreferredPositioningMethods(aMethods);
+    
     PositioningMethods preferredMethod(PositioningMethods(0));
     TInt index = -1;
     // the poistioning methods are not supported
@@ -851,7 +850,6 @@
                 QGeoPositionInfoSource::setUpdateInterval(value);
 
         }
-        QGeoPositionInfoSource::setPreferredPositioningMethods(mCurrentMethod);
     }
 
 }