qtmobility/src/location/qgeopositioninfosource_s60.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
--- a/qtmobility/src/location/qgeopositioninfosource_s60.cpp	Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/src/location/qgeopositioninfosource_s60.cpp	Mon May 03 13:18:40 2010 +0300
@@ -167,19 +167,21 @@
 
         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) &&
+            if (!((aFromSatellitePositioningMethodsOnly == TRUE) && typeSet &&
                     (type != SatellitePositioningMethods))) {
                 QGeoCoordinate  coord;
 
                 posInfo.GetPosition(pos);
 
-
                 coord.setLatitude(pos.Latitude());
                 coord.setLongitude(pos.Longitude());
                 coord.setAltitude(pos.Altitude());
@@ -193,7 +195,7 @@
                                    datetime.MicroSecond() / 1000));
 
                 //store the time stamp
-                posUpdate.setDateTime(dt);
+                posUpdate.setTimestamp(dt);
 
                 //store the horizontal accuracy
                 posUpdate.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy());
@@ -297,7 +299,8 @@
 //lesser than timeout
 TInt CQGeoPositionInfoSourceS60::getMoreAccurateMethod(TInt aTimeout, TUint8 aBits)
 {
-    TInt index = -1, temp = INT_MAX;
+    TInt index = -1;
+    double temp = -1.0;
     PositioningMethods posMethods;
     TTimeIntervalMicroSeconds microSeconds;
 
@@ -313,7 +316,7 @@
                 && (mList[i].mStatus != TPositionModuleStatus::EDeviceError)
                 && (((aBits >> i) & 1))
                 && (mList[i].mTimeToFirstFix < microSeconds)) {
-            if (mList[i].mHorizontalAccuracy < temp) {
+            if ((temp == -1.0) || (mList[i].mHorizontalAccuracy < temp)) {
                 index = i;
                 temp = mList[i].mHorizontalAccuracy;
             }
@@ -426,6 +429,8 @@
             if ((ret == KErrNone) && (temp != NULL)) {
                 temp->setUpdateInterval(interval);
 
+                if (mRegUpdateAO)
+                    delete mRegUpdateAO;
                 mRegUpdateAO = temp;
 
                 //to be uncommented when startUpdates are done
@@ -433,7 +438,6 @@
                 if (mStartUpdates)
                     mRegUpdateAO->startUpdates();
 
-
                 mCurrentModuleId = mList[i].mUid;
 
                 mCurrentMethod = mList[i].mPosMethod;
@@ -456,8 +460,8 @@
 
                 interval = QGeoPositionInfoSource::updateInterval();
 
-                delete  mRegUpdateAO;
-
+                if (mRegUpdateAO)
+                    delete  mRegUpdateAO;
 
                 bits = mModuleFlags;
 
@@ -508,7 +512,8 @@
 
             //check if device status of the request update module changed
             if (id == mReqModuleId) {
-                delete mReqUpdateAO;
+                if (mRegUpdateAO)
+                    delete mReqUpdateAO;
                 mReqUpdateAO = NULL;
                 mReqModuleId = TUid::Null();
                 emit updateTimeout();
@@ -543,7 +548,7 @@
         if (error != KErrNone)
             mCurrentModuleId = TUid::Null();
 
-        for (TInt i = 0; i < modCount; i++) {
+        for (TUint i = 0; i < modCount; i++) {
             //get module information
             mPositionServer.GetModuleInfoByIndex(i, moduleInfo);
 
@@ -602,7 +607,7 @@
                        datetime.MicroSecond() / 1000));
 
     //store the time stamp
-    aPosInfo2.setDateTime(dt);
+    aPosInfo2.setTimestamp(dt);
 
     //store the horizontal accuracy
     aPosInfo2.setAttribute(QGeoPositionInfo::HorizontalAccuracy, pos.HorizontalAccuracy());
@@ -683,12 +688,14 @@
     TInt index = -1;
     TUint8 bits;
 
-    CQMLBackendAO *temp;
+    CQMLBackendAO *temp= NULL;
 
     //return if already a request update is pending
     if (mReqUpdateAO && mReqUpdateAO->isRequestPending())
         return;
 
+    if (aTimeout == 0)
+        aTimeout = 20000;
 
     bits = mModuleFlags;
 
@@ -712,7 +719,8 @@
 
         if ((ret == KErrNone) && (temp != NULL)) {
             //delete the old reqest update
-            delete mReqUpdateAO;
+            if (mReqUpdateAO)
+                delete mReqUpdateAO;
 
             //set the requestAO to the newly created AO
             mReqUpdateAO = temp;
@@ -733,6 +741,7 @@
     //cleanup resources if the invalid requpdate is still stored
     if (mReqUpdateAO) {
         delete mReqUpdateAO;
+        mReqUpdateAO = NULL;
         mReqModuleId = TUid::Null();
     }
 
@@ -761,8 +770,8 @@
     // the poistioning methods are not supported
     // if the preferred positioning method is the current poistioning
 
-    if (!(mSupportedMethods & aMethods) || (aMethods == AllPositioningMethods) ||
-            (aMethods == mCurrentMethod))
+    if (!(mSupportedMethods & aMethods) || (aMethods == PositioningMethods(AllPositioningMethods)) ||
+            (aMethods == PositioningMethods(mCurrentMethod)))
 
         return;
 
@@ -786,7 +795,7 @@
 
             TRAPD(error, temp = CQMLBackendAO::NewL(this, RegularUpdate,
                                                     mList[index].mUid));
-            if (temp != NULL)
+            if ((temp != NULL) && (error == KErrNone))
                 break;
 
             bits = bits & (0XFF ^(1 << index));