supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplposinitstate.cpp
changeset 40 16118e24b93b
parent 32 b12ea03c50a3
--- a/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplposinitstate.cpp	Tue Jul 06 14:44:11 2010 +0300
+++ b/supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplposinitstate.cpp	Wed Aug 18 10:11:45 2010 +0300
@@ -384,34 +384,34 @@
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 //
-void COMASuplPosInitState::GetPosParamsL() 
-	{
-	
-	iGenerationStatus = ETrue;
-	
-	// Re-initialize the POS Requestor
-	if(iPosRequestor)
-		iPosRequestor->DestroyList();
-	//Comment to ignore coverity forward NULL stack error
-    //coverity[FORWARD_NULL   :FALSE]
-	iPosRequestor->CreateListL();
-	
-	// Create SET capabilities object
-	iCurSetCapabilities = COMASuplSETCapabilities::NewL();
-	
-	// Create the Request Assistance data object
-	iReqAsstData = COMASuplReqAsstData::NewL();
-	
-	// Create Position
-	iPosition = COMASuplPosition::NewL();
+void COMASuplPosInitState::GetPosParamsL()
+    {
+
+    iGenerationStatus = ETrue;
+
+    // Re-initialize the POS Requestor
+    if (iPosRequestor)
+        {
+        iPosRequestor->DestroyList();
+        iPosRequestor->CreateListL();
+        }
 
-	// Create POS Payload
-	iPosPayload = COMASuplPosPayload::NewL();
+    // Create SET capabilities object
+    iCurSetCapabilities = COMASuplSETCapabilities::NewL();
+
+    // Create the Request Assistance data object
+    iReqAsstData = COMASuplReqAsstData::NewL();
 
-	// Create Velocity
-	iVelocity = COMASuplVelocity::NewL();
-	
-    if(iPosRequestor)
+    // Create Position
+    iPosition = COMASuplPosition::NewL();
+
+    // Create POS Payload
+    iPosPayload = COMASuplPosPayload::NewL();
+
+    // Create Velocity
+    iVelocity = COMASuplVelocity::NewL();
+
+    if (iPosRequestor)
         {
         // Append the SUPL POS INIT optional parameters to the list
         // in POS Requestor
@@ -420,32 +420,32 @@
         iPosRequestor->AppendInfoRequest(iPosition);
         iPosRequestor->AppendInfoRequest(iPosPayload);
         iPosRequestor->AppendInfoRequest(iVelocity);
-	
 
-	
         TBuf<128> msg(_L("Filling iPosMethod in iPosRequestor: "));
-        iTrace->Trace(msg, KTraceFileName, __LINE__); 
+        iTrace->Trace(msg, KTraceFileName, __LINE__);
 
         // Set self as Observer to POS Requestor
-		//Comment to ignore coverity reverse NULL error
+        //Comment to ignore coverity reverse NULL error
         //coverity[REVERSE_INULL :FALSE]
         iPosRequestor->SetObserver(this);
-        iAllowedCapabilitiesforPOS.SetAllowedCapabilities(EFalse, EFalse, EFalse, EFalse, EFalse, EFalse, EFalse, EFalse);
-        iPosRequestor->SetPosMethodAndAllowedCapabilities (iAllowedCapabilitiesforPOS,iPosMethod ); 
-        if(iHSLPAddress)
+        iAllowedCapabilitiesforPOS.SetAllowedCapabilities(EFalse, EFalse,
+                EFalse, EFalse, EFalse, EFalse, EFalse, EFalse);
+        iPosRequestor->SetPosMethodAndAllowedCapabilities(
+                iAllowedCapabilitiesforPOS, iPosMethod);
+        if (iHSLPAddress)
             {
-            HBufC* slpAddress = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*iHSLPAddress);
+            HBufC* slpAddress = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                    *iHSLPAddress);
             msg.Copy(_L("Filling iHSLPAddress in iPosRequestor: "));
             msg.Append(*slpAddress);
-            iTrace->Trace(msg, KTraceFileName, __LINE__); 
+            iTrace->Trace(msg, KTraceFileName, __LINE__);
             iPosRequestor->SetSLPAddressUsed(*slpAddress);
             }
-		}
-	// Get the information from POS
-	if(iPosRequestor)
-	User::LeaveIfError(iPosRequestor->GetSuplInfoL());
-	
-	}
+        // Get the information from POS
+        User::LeaveIfError(iPosRequestor->GetSuplInfoL());
+        }
+
+    }
 // -----------------------------------------------------------------------------
 // COMASuplPosInitState::OperationCompleteL
 // An observer method that indicates the completion of
@@ -747,15 +747,19 @@
         }
     //if the current Cell id is the same as the Cell id when we made the request for assistance data then use the assistance data
     //and we have not already repeated a request before
-    if(!iRepeatedPosDataFetch && iLocationId->GetCellId() == aLocationId->GetCellId()) 
+    if (!iRepeatedPosDataFetch && iLocationId->GetCellId()
+            == aLocationId->GetCellId())
         {
-        iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL Cell Id not changed since making last request, so continuing"), KTraceFileName, __LINE__); 
-        if(iLocationId)
-            delete iLocationId;
-        //coverity[REVERSE_INULL  :FALSE]
+        //deleting locationId before assigning it again
+        delete iLocationId;
+        iLocationId = NULL;
         iLocationId = aLocationId;
-        if(iMsgStateObserver)
-        iMsgStateObserver->OperationCompleteL(aErrorCode);
+
+        iTrace->Trace(
+                _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL Cell Id not changed since making last request, so continuing"),
+                KTraceFileName, __LINE__);
+        if (iMsgStateObserver)
+            iMsgStateObserver->OperationCompleteL(aErrorCode);
         }
     else // Cell id has changed since previous request so assistance data may be invalid
         {
@@ -770,33 +774,36 @@
                 iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. getting  pos data again"), KTraceFileName, __LINE__);
                 if(!iRepeatedPosDataFetch)//if cell id changed and we have not already repeated fetching pos data
                     {
+                    iLocationId = aLocationId; //update the location id member for the next request as we are making a request again
                     iRepeatedPosDataFetch = ETrue;
-                    if(iLocationId)
-                        delete iLocationId;                    
-                    iLocationId = aLocationId; //update the location id member for the next request as we are making a request again
-                    iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. getting  pos data again"), KTraceFileName, __LINE__);
+
+                    iTrace->Trace(
+                            _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. getting  pos data again"),
+                            KTraceFileName, __LINE__);
                     GetPosParamsL();
                     }
                 else
                     {
+                    iLocationId = aLocationId;
                     iRepeatedPosDataFetch = EFalse; //reset the status
-                    if(iLocationId)
-                       delete iLocationId;
-                    iLocationId = aLocationId;
-                    iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. But repeated a pos fetch already so continuing"), KTraceFileName, __LINE__);
-                    if(iMsgStateObserver)
+
+                    iTrace->Trace(
+                            _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. But repeated a pos fetch already so continuing"),
+                            KTraceFileName, __LINE__);
+                    if (iMsgStateObserver)
                         iMsgStateObserver->OperationCompleteL(aErrorCode);//use the pos data as it is
                     }
                 }
             else //ignore the position data
                 {
+                iLocationId = aLocationId;
                 iIgnorePosData = ETrue;
-                iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit less than KMaxCellIdChangeToeLimit. Ignoring pos data"), KTraceFileName, __LINE__);
+                iTrace->Trace(
+                        _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit less than KMaxCellIdChangeToeLimit. Ignoring pos data"),
+                        KTraceFileName, __LINE__);
                 iRepeatedPosDataFetch = EFalse; //reset the status
-                if(iLocationId)
-                	delete iLocationId;
-                iLocationId = aLocationId;
-                if(iMsgStateObserver)
+
+                if (iMsgStateObserver)
                     iMsgStateObserver->OperationCompleteL(aErrorCode);
                 }
             }