supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplposinitstate.cpp
branchRCL_3
changeset 20 2b4ea9893b66
parent 19 02ba3f1733c6
child 21 6b6920c56e2f
equal deleted inserted replaced
19:02ba3f1733c6 20:2b4ea9893b66
   240 		iGenerationStatus = ETrue;
   240 		iGenerationStatus = ETrue;
   241 		iTrace->Trace(_L("Start of COMASuplPosInitState::GenerateMessage"), KTraceFileName, __LINE__); 					
   241 		iTrace->Trace(_L("Start of COMASuplPosInitState::GenerateMessage"), KTraceFileName, __LINE__); 					
   242 		iVerPresent = ComputeSuplInitVerL();
   242 		iVerPresent = ComputeSuplInitVerL();
   243 		if(iVerPresent)
   243 		if(iVerPresent)
   244 			{
   244 			{
   245 			if(!iIsStaleCellId) // if this request is for a stale cell id conversion then do not retrieve current location id
   245 				iLocationIDRequestor->GetLocationID();		
   246 				iLocationIDRequestor->GetLocationID();
       
   247 			else
       
   248 			    iMsgStateObserver->OperationCompleteL(KErrNone);
       
   249 			}
   246 			}
   250 		else
   247 		else
   251 			{
   248 			{
   252 				iMsgStateObserver->OperationCompleteL(KErrGeneral);
   249 				iMsgStateObserver->OperationCompleteL(KErrGeneral);
   253 			}
   250 			}
   385 // Collects the optional parameters for SUPL_POS_INIT 
   382 // Collects the optional parameters for SUPL_POS_INIT 
   386 // message from POS Message plugin
   383 // message from POS Message plugin
   387 // (other items were commented in a header).
   384 // (other items were commented in a header).
   388 // -----------------------------------------------------------------------------
   385 // -----------------------------------------------------------------------------
   389 //
   386 //
   390 void COMASuplPosInitState::GetPosParamsL() 
   387 void COMASuplPosInitState::GetPosParamsL()
   391 	{
   388     {
   392 	
   389 
   393 	iGenerationStatus = ETrue;
   390     iGenerationStatus = ETrue;
   394 	
   391 
   395 	// Re-initialize the POS Requestor
   392     // Re-initialize the POS Requestor
   396 	if(iPosRequestor)
   393     if (iPosRequestor)
   397 		iPosRequestor->DestroyList();
   394         {
   398 	iPosRequestor->CreateListL();
   395         iPosRequestor->DestroyList();
   399 	
   396         iPosRequestor->CreateListL();
   400 	// Create SET capabilities object
   397         }
   401 	iCurSetCapabilities = COMASuplSETCapabilities::NewL();
   398 
   402 	
   399     // Create SET capabilities object
   403 	// Create the Request Assistance data object
   400     iCurSetCapabilities = COMASuplSETCapabilities::NewL();
   404 	iReqAsstData = COMASuplReqAsstData::NewL();
   401 
   405 	
   402     // Create the Request Assistance data object
   406 	// Create Position
   403     iReqAsstData = COMASuplReqAsstData::NewL();
   407 	iPosition = COMASuplPosition::NewL();
   404 
   408 
   405     // Create Position
   409 	// Create POS Payload
   406     iPosition = COMASuplPosition::NewL();
   410 	iPosPayload = COMASuplPosPayload::NewL();
   407 
   411 
   408     // Create POS Payload
   412 	// Create Velocity
   409     iPosPayload = COMASuplPosPayload::NewL();
   413 	iVelocity = COMASuplVelocity::NewL();
   410 
   414 	
   411     // Create Velocity
   415 
   412     iVelocity = COMASuplVelocity::NewL();
   416 	// Append the SUPL POS INIT optional parameters to the list
   413 
   417 	// in POS Requestor
   414     if (iPosRequestor)
   418 	iPosRequestor->AppendInfoRequest(iCurSetCapabilities);
   415         {
   419 	iPosRequestor->AppendInfoRequest(iReqAsstData);
   416         // Append the SUPL POS INIT optional parameters to the list
   420 	iPosRequestor->AppendInfoRequest(iPosition);
   417         // in POS Requestor
   421 	iPosRequestor->AppendInfoRequest(iPosPayload);
   418         iPosRequestor->AppendInfoRequest(iCurSetCapabilities);
   422 	iPosRequestor->AppendInfoRequest(iVelocity);
   419         iPosRequestor->AppendInfoRequest(iReqAsstData);
   423 	
   420         iPosRequestor->AppendInfoRequest(iPosition);
   424 	// Set self as Observer to POS Requestor
   421         iPosRequestor->AppendInfoRequest(iPosPayload);
   425 	iPosRequestor->SetObserver(this);
   422         iPosRequestor->AppendInfoRequest(iVelocity);
   426 	
   423 
   427 	TBuf<128> msg(_L("Filling iPosMethod in iPosRequestor: "));
   424         TBuf<128> msg(_L("Filling iPosMethod in iPosRequestor: "));
   428 	iTrace->Trace(msg, KTraceFileName, __LINE__); 
   425         iTrace->Trace(msg, KTraceFileName, __LINE__);
   429 	if(iPosRequestor)
   426 
   430 		{
   427         // Set self as Observer to POS Requestor
   431 		iAllowedCapabilitiesforPOS.SetAllowedCapabilities(EFalse, EFalse, EFalse, EFalse, EFalse, EFalse, EFalse, EFalse);
   428         //Comment to ignore coverity reverse NULL error
   432 		iPosRequestor->SetPosMethodAndAllowedCapabilities (iAllowedCapabilitiesforPOS,iPosMethod ); 
   429         //coverity[REVERSE_INULL :FALSE]
   433         if(iHSLPAddress)
   430         iPosRequestor->SetObserver(this);
       
   431         iAllowedCapabilitiesforPOS.SetAllowedCapabilities(EFalse, EFalse,
       
   432                 EFalse, EFalse, EFalse, EFalse, EFalse, EFalse);
       
   433         iPosRequestor->SetPosMethodAndAllowedCapabilities(
       
   434                 iAllowedCapabilitiesforPOS, iPosMethod);
       
   435         if (iHSLPAddress)
   434             {
   436             {
   435             HBufC* slpAddress = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*iHSLPAddress);
   437             HBufC* slpAddress = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
       
   438                     *iHSLPAddress);
   436             msg.Copy(_L("Filling iHSLPAddress in iPosRequestor: "));
   439             msg.Copy(_L("Filling iHSLPAddress in iPosRequestor: "));
   437             msg.Append(*slpAddress);
   440             msg.Append(*slpAddress);
   438             iTrace->Trace(msg, KTraceFileName, __LINE__); 
   441             iTrace->Trace(msg, KTraceFileName, __LINE__);
   439             iPosRequestor->SetSLPAddressUsed(*slpAddress);
   442             iPosRequestor->SetSLPAddressUsed(*slpAddress);
   440             }
   443             }
   441 		}
   444         // Get the information from POS
   442 	// Get the information from POS
   445         User::LeaveIfError(iPosRequestor->GetSuplInfoL());
   443 	if(iPosRequestor)
   446         }
   444 	User::LeaveIfError(iPosRequestor->GetSuplInfoL());
   447 
   445 	
   448     }
   446 	}
       
   447 // -----------------------------------------------------------------------------
   449 // -----------------------------------------------------------------------------
   448 // COMASuplPosInitState::OperationCompleteL
   450 // COMASuplPosInitState::OperationCompleteL
   449 // An observer method that indicates the completion of
   451 // An observer method that indicates the completion of
   450 // data retrieval from POS Message plugin
   452 // data retrieval from POS Message plugin
   451 // (other items were commented in a header).
   453 // (other items were commented in a header).
   586 
   588 
   587             iAllowedCapabilitiesforPOS.SetAllowedCapabilities(aGpsSetAssisted, aGpsSetBased, autonomousGps, AFLT, EOTD, OTDOA, ETrue, ETrue);
   589             iAllowedCapabilitiesforPOS.SetAllowedCapabilities(aGpsSetAssisted, aGpsSetBased, autonomousGps, AFLT, EOTD, OTDOA, ETrue, ETrue);
   588 
   590 
   589 		    iPosRequestor->SetPosMethodAndAllowedCapabilities (iAllowedCapabilitiesforPOS,iPosMethod  ); 
   591 		    iPosRequestor->SetPosMethodAndAllowedCapabilities (iAllowedCapabilitiesforPOS,iPosMethod  ); 
   590         }
   592         }
   591 		
   593 		if(iOldCapabilities)
   592 		OMASuplPosInit->SetSuplPosInit(static_cast<COMASuplSETCapabilities*>(iOldCapabilities->CloneL()),static_cast<COMASuplLocationId*>(iLocationId->CloneL()),iECId);
   594 		    OMASuplPosInit->SetSuplPosInit(static_cast<COMASuplSETCapabilities*>(iOldCapabilities->CloneL()),static_cast<COMASuplLocationId*>(iLocationId->CloneL()),iECId);
   593 		if(iECId)
   595 		if(iECId)
   594 			{
   596 			{
   595 				OMASuplPosInit->SetECellId(iMmCellInfo);
   597 				OMASuplPosInit->SetECellId(iMmCellInfo);
   596 			}
   598 			}
   597 		
   599 		
   606 						OMASuplPosInit->SetRequestAssistanceData(reqAsstData);
   608 						OMASuplPosInit->SetRequestAssistanceData(reqAsstData);
   607 					}
   609 					}
   608 			}
   610 			}
   609 
   611 
   610 		// Position
   612 		// Position
   611 		if(iPosition && iRequestType == COMASuplSession::ESUPL_TERMINAL)
   613 		if(iPosition)
   612 			{
   614 			{
   613 			if(KErrNone == iPosition->Status() && !iIgnorePosData) //if iIgnorePosData is set do not use the pos data
   615 			if(KErrNone == iPosition->Status() && !iIgnorePosData) //if iIgnorePosData is set do not use the pos data
   614 				{
   616 				{
   615 					COMASuplPosition* position =static_cast <COMASuplPosition *>(iPosition->CloneL());
   617 					COMASuplPosition* position =static_cast <COMASuplPosition *>(iPosition->CloneL());
   616 					position->SetType(COMASuplInfoRequest::EOMASuplPosition);
   618 					position->SetType(COMASuplInfoRequest::EOMASuplPosition);
   743             return;
   745             return;
   744             }
   746             }
   745         }
   747         }
   746     //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
   748     //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
   747     //and we have not already repeated a request before
   749     //and we have not already repeated a request before
   748     if(!iRepeatedPosDataFetch && iLocationId->GetCellId() == aLocationId->GetCellId()) 
   750     if (!iRepeatedPosDataFetch && iLocationId->GetCellId()
       
   751             == aLocationId->GetCellId())
   749         {
   752         {
   750         iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL Cell Id not changed since making last request, so continuing"), KTraceFileName, __LINE__); 
   753         //deleting locationId before assigning it again
   751         if(iLocationId)
   754         delete iLocationId;
   752             delete iLocationId;
   755         iLocationId = NULL;
   753         iLocationId = aLocationId;
   756         iLocationId = aLocationId;
   754         if(iMsgStateObserver)
   757 
   755         iMsgStateObserver->OperationCompleteL(aErrorCode);
   758         iTrace->Trace(
       
   759                 _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL Cell Id not changed since making last request, so continuing"),
       
   760                 KTraceFileName, __LINE__);
       
   761         if (iMsgStateObserver)
       
   762             iMsgStateObserver->OperationCompleteL(aErrorCode);
   756         }
   763         }
   757     else // Cell id has changed since previous request so assistance data may be invalid
   764     else // Cell id has changed since previous request so assistance data may be invalid
   758         {
   765         {
   759         iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL Cell Id changed since making last request, retrieving toe limit"), KTraceFileName, __LINE__);
   766         iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL Cell Id changed since making last request, retrieving toe limit"), KTraceFileName, __LINE__);
   760         TOMASuplNavigationModel navModel;
   767         TOMASuplNavigationModel navModel;
   765             if(toeLimit >= KMaxCellIdChangeToeLimit) 
   772             if(toeLimit >= KMaxCellIdChangeToeLimit) 
   766                 {
   773                 {
   767                 iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. getting  pos data again"), KTraceFileName, __LINE__);
   774                 iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. getting  pos data again"), KTraceFileName, __LINE__);
   768                 if(!iRepeatedPosDataFetch)//if cell id changed and we have not already repeated fetching pos data
   775                 if(!iRepeatedPosDataFetch)//if cell id changed and we have not already repeated fetching pos data
   769                     {
   776                     {
       
   777                     iLocationId = aLocationId; //update the location id member for the next request as we are making a request again
   770                     iRepeatedPosDataFetch = ETrue;
   778                     iRepeatedPosDataFetch = ETrue;
   771                     if(iLocationId)
   779 
   772                         delete iLocationId;                    
   780                     iTrace->Trace(
   773                     iLocationId = aLocationId; //update the location id member for the next request as we are making a request again
   781                             _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. getting  pos data again"),
   774                     iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. getting  pos data again"), KTraceFileName, __LINE__);
   782                             KTraceFileName, __LINE__);
   775                     GetPosParamsL();
   783                     GetPosParamsL();
   776                     }
   784                     }
   777                 else
   785                 else
   778                     {
   786                     {
       
   787                     iLocationId = aLocationId;
   779                     iRepeatedPosDataFetch = EFalse; //reset the status
   788                     iRepeatedPosDataFetch = EFalse; //reset the status
   780                     if(iLocationId)
   789 
   781                        delete iLocationId;
   790                     iTrace->Trace(
   782                     iLocationId = aLocationId;
   791                             _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. But repeated a pos fetch already so continuing"),
   783                     iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit greater than KMaxCellIdChangeToeLimit. But repeated a pos fetch already so continuing"), KTraceFileName, __LINE__);
   792                             KTraceFileName, __LINE__);
   784                     iMsgStateObserver->OperationCompleteL(aErrorCode);//use the pos data as it is
   793                     if (iMsgStateObserver)
       
   794                         iMsgStateObserver->OperationCompleteL(aErrorCode);//use the pos data as it is
   785                     }
   795                     }
   786                 }
   796                 }
   787             else //ignore the position data
   797             else //ignore the position data
   788                 {
   798                 {
       
   799                 iLocationId = aLocationId;
   789                 iIgnorePosData = ETrue;
   800                 iIgnorePosData = ETrue;
   790                 iTrace->Trace(_L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit less than KMaxCellIdChangeToeLimit. Ignoring pos data"), KTraceFileName, __LINE__);
   801                 iTrace->Trace(
       
   802                         _L("COMASuplPosInitState::ComparisionLocationIDRequestCompletedL toe limit less than KMaxCellIdChangeToeLimit. Ignoring pos data"),
       
   803                         KTraceFileName, __LINE__);
   791                 iRepeatedPosDataFetch = EFalse; //reset the status
   804                 iRepeatedPosDataFetch = EFalse; //reset the status
   792                 if(iLocationId)
   805 
   793                 	delete iLocationId;
   806                 if (iMsgStateObserver)
   794                 iLocationId = aLocationId;
   807                     iMsgStateObserver->OperationCompleteL(aErrorCode);
   795                 iMsgStateObserver->OperationCompleteL(aErrorCode);
       
   796                 }
   808                 }
   797             }
   809             }
   798         }
   810         }
   799     }
   811     }
   800 
   812