supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp
branchRCL_3
changeset 55 ea98413ce11f
parent 49 10852b179f64
equal deleted inserted replaced
49:10852b179f64 55:ea98413ce11f
   126 																iUsageHomeNW(EFalse),
   126 																iUsageHomeNW(EFalse),
   127 																iEtelNotify(EFalse),
   127 																iEtelNotify(EFalse),
   128 																iEtelRoamingCheck(EFalse),
   128 																iEtelRoamingCheck(EFalse),
   129 																iIapDialogShown(EFalse),
   129 																iIapDialogShown(EFalse),
   130 																iIapDlgTimerExpired(EFalse),
   130 																iIapDlgTimerExpired(EFalse),
   131 																iOMASuplAsnHandlerBaseImpl(aOMASuplAsnHandlerBase),iWlanOnly(EFalse)
   131 																iOMASuplAsnHandlerBaseImpl(aOMASuplAsnHandlerBase)
   132 																
   132 																
   133     { 
   133     { 
   134     }
   134     }
   135  
   135  
   136 //2 nd Phase construction
   136 //2 nd Phase construction
   191 		iTimer = COMASuplTimeoutTimer::NewL(*this);
   191 		iTimer = COMASuplTimeoutTimer::NewL(*this);
   192 
   192 
   193 
   193 
   194     	iIapNotifier = COMASuplIapNotifier::NewL(*this);
   194     	iIapNotifier = COMASuplIapNotifier::NewL(*this);
   195 
   195 
       
   196 			
       
   197 		iDialogTimer = COMASuplDialogTimer::NewL(*this);
   196 		
   198 		
   197 		iIsQoPPresent = EFalse;	
   199 		iIsQoPPresent = EFalse;	
   198 		iIsFirstPOSMessage = ETrue;
   200 		iIsFirstPOSMessage = ETrue;
   199 		isTimeoutDialogTimerStarted = EFalse;
   201 		isTimeoutDialogTimerStarted = EFalse;
   200 
   202 
   249 		{
   251 		{
   250 			CancelRunSession();
   252 			CancelRunSession();
   251 			SessionEnd();
   253 			SessionEnd();
   252 			CompleteSession(KErrCancel);
   254 			CompleteSession(KErrCancel);
   253 		}
   255 		}
       
   256 		iProtocolManager.CancelUiLaunch();
   254 		delete this;
   257 		delete this;
   255 	}
   258 	}
   256 
   259 
   257 // -----------------------------------------------------------------------------
   260 // -----------------------------------------------------------------------------
   258 // COMASuplSession::PosPlugInUnloaded
   261 // COMASuplSession::PosPlugInUnloaded
   308     	delete iPOSSession;
   311     	delete iPOSSession;
   309     	iPOSSession = NULL;
   312     	iPOSSession = NULL;
   310     	delete iTimer;
   313     	delete iTimer;
   311         delete iIapNotifier;
   314         delete iIapNotifier;
   312     	iIMSI.Close();
   315     	iIMSI.Close();
       
   316         delete iDialogTimer;
   313         
   317         
   314         delete iNetworkPrivacy;
   318         delete iNetworkPrivacy;
   315 
       
   316 	if(iStaleLocationId)
       
   317     	  {
       
   318     	  delete iStaleLocationId;
       
   319     	  iStaleLocationId = NULL;
       
   320     	  }  
       
   321     	
   319     	
   322     	if(iTrace)
   320     	if(iTrace)
   323     		iTrace->Trace(_L("End of ~COMASuplSession::COMASuplSession"), KTraceFileName, __LINE__); 
   321     		iTrace->Trace(_L("End of ~COMASuplSession::COMASuplSession"), KTraceFileName, __LINE__); 
   324 		    	
   322 		    	
   325     	delete iTrace;
   323     	delete iTrace;
   424 // (other items were commented in a header).
   422 // (other items were commented in a header).
   425 // -----------------------------------------------------------------------------
   423 // -----------------------------------------------------------------------------
   426 //
   424 //
   427  void COMASuplSession::RunSuplSessionL(TRequestStatus& aStatus, TBool aFirstReq, const TDesC& aHslpAddress, 
   425  void COMASuplSession::RunSuplSessionL(TRequestStatus& aStatus, TBool aFirstReq, const TDesC& aHslpAddress, 
   428                                        TBool aFallBack, TInt aAllowedCapabilities,
   426                                        TBool aFallBack, TInt aAllowedCapabilities,
   429  									  TInt aSessionIdSeed,TInt aRequestID,TBool aIsStaleCellId,COMASuplLocationId* aLocationId,TBool aPrompt,TBool aWlanOnly)
   427  									  TInt aSessionIdSeed,TInt aRequestID)
   430     {
   428     {
   431 	    iRunRequestStatus = & aStatus;
   429 	    iRunRequestStatus = & aStatus;
   432 	    *iRunRequestStatus = KRequestPending;
   430 	    *iRunRequestStatus = KRequestPending;
   433 
   431 
   434         iRequestID = aRequestID;
   432         iRequestID = aRequestID;
   435 
   433 
   436     	iTrace->Trace(_L("Start COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); 
   434     	iTrace->Trace(_L("Start COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); 
   437 
   435     	
   438     	if(aIsStaleCellId)
       
   439     	    {
       
   440     	    iTrace->Trace(_L("Start COMASuplSession::RunSuplSession for Stale Cell Id"), KTraceFileName, __LINE__); 
       
   441     	    iIsStaleLocIdPresent = ETrue;
       
   442 
       
   443      	    
       
   444     	    if(iStaleLocationId)
       
   445     	        {
       
   446     	        delete iStaleLocationId;
       
   447     	        iStaleLocationId = NULL;
       
   448     	        }   	        
       
   449 
       
   450     	    iStaleLocationId = aLocationId;
       
   451     	    iStaleLocIdPrompt = aPrompt;
       
   452     	    iWlanOnly = aWlanOnly; //OCC
       
   453     	    
       
   454     	    iTrace->Trace(_L("Deleting pos requestor as session is for Stale Cell Id"), KTraceFileName, __LINE__); 
       
   455             delete iOMASuplPOSRequestor;
       
   456              iOMASuplPOSRequestor = NULL;
       
   457              
       
   458     	    // Delete the POS Session
       
   459     	     delete iPOSSession;
       
   460     	     iPOSSession = NULL;    	     
       
   461 
       
   462     	    }
       
   463     	// Log Session Id
   436     	// Log Session Id
   464     	TBuf<64> id;
   437     	TBuf<64> id;
   465     	id.Append(_L("Session  Id is "));
   438     	id.Append(_L("Session  Id is "));
   466     	id.AppendNum(aSessionIdSeed);
   439     	id.AppendNum(aSessionIdSeed);
   467     	iTrace->Trace(id,KTraceFileName, __LINE__); 
   440     	iTrace->Trace(id,KTraceFileName, __LINE__); 
   470     	id.Copy(_L("Received Capability is "));
   443     	id.Copy(_L("Received Capability is "));
   471     	id.AppendNum(aAllowedCapabilities);
   444     	id.AppendNum(aAllowedCapabilities);
   472     	iTrace->Trace(id,KTraceFileName, __LINE__); 
   445     	iTrace->Trace(id,KTraceFileName, __LINE__); 
   473     	
   446     	
   474     	iSETSessionUniqueId = aSessionIdSeed;
   447     	iSETSessionUniqueId = aSessionIdSeed;
   475     	
   448 
   476 		iIhaveLaunchedUsagedialog = EFalse;
       
   477 		
   449 		
   478 		TInt networkMode = 1;
   450 		TInt networkMode = 1;
   479 		networkMode = GetNetworkModeL();
   451 		networkMode = GetNetworkModeL();
   480 		
   452 		
   481 	 if(!iWlanOnly)	//OCC	
   453 		if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed )
   482             {
   454 			{
   483             if ( networkMode == ECoreAppUIsNetworkConnectionNotAllowed )
   455 				id.Copy(_L("The device is in OFFLINE mode."));
   484                 {
   456 				iTrace->Trace(id,KTraceFileName, __LINE__); 
   485                     id.Copy(_L("The device is in OFFLINE mode."));
   457 				iSessionObserver.TerminateSession(this, KErrGeneral);
   486                     iTrace->Trace(id,KTraceFileName, __LINE__); 
   458 				return;
   487                     iSessionObserver.TerminateSession(this, KErrGeneral);
   459 			}
   488                     return;
   460 		else
   489                 }
   461 			{
   490             else
   462 				id.Copy(_L("The device is in ON LINE mode."));
   491                 {
   463 				iTrace->Trace(id,KTraceFileName, __LINE__); 
   492                     id.Copy(_L("The device is in ON LINE mode."));
   464 			}
   493                     iTrace->Trace(id,KTraceFileName, __LINE__); 
       
   494                 }
       
   495             } //OCC
       
   496 
   465 
   497     	if(aAllowedCapabilities == 0)
   466     	if(aAllowedCapabilities == 0)
   498     		{
   467     		{
   499 				iAllowedCapabilities = KGpsSETBased | KAutonomousGps| KAFLT | KECID | KEOTD | KOTDOA | KCID; 
   468 				iAllowedCapabilities = KGpsSETBased | KAutonomousGps| KAFLT | KECID | KEOTD | KOTDOA | KCID; 
   500     		}
   469     		}
   505     		
   474     		
   506    		//Ownership transfer to iSuplSessionId
   475    		//Ownership transfer to iSuplSessionId
   507 		iSuplSessionId->SetSLPSessionID(NULL); 	
   476 		iSuplSessionId->SetSLPSessionID(NULL); 	
   508 		
   477 		
   509 		iConnRequestor->SetDefaultParametersL(aHslpAddress,aFallBack);
   478 		iConnRequestor->SetDefaultParametersL(aHslpAddress,aFallBack);
   510 		
   479 
   511 		 id.Copy(_L("aFallBack value is "));
   480         if (aFirstReq)
   512 		 id.AppendNum(aFallBack);
   481             CheckForSuplUsageL();
   513 		 iTrace->Trace(id,KTraceFileName, __LINE__);
   482         else
   514 
   483             CheckForPreviousResultL();        
   515        if(!iWlanOnly) //OCC
       
   516 		    {
       
   517             iTrace->Trace(_L("iWLANOnly false COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__);
       
   518            
       
   519             id.Copy(_L("aFirstReq value is "));
       
   520             id.AppendNum(aFirstReq);
       
   521             iTrace->Trace(id,KTraceFileName, __LINE__);
       
   522             
       
   523             if (aFirstReq)
       
   524                 {
       
   525                 iTrace->Trace(_L("start CheckForSuplUsageL COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__);
       
   526                 CheckForSuplUsageL();
       
   527                 }
       
   528             else
       
   529                 {
       
   530                 iTrace->Trace(_L("start CheckForPreviousResultL COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__);
       
   531                 CheckForPreviousResultL();  
       
   532                 }
       
   533             }
       
   534 		else
       
   535 		    {
       
   536 		    iTrace->Trace(_L("iWLANOnly true COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); 
       
   537             InitializeL(iRequestID);
       
   538 		    } //OCC     
       
   539 
   484 
   540 	    
   485 	    
   541 		// Clear  Position....
   486 		// Clear  Position....
   542 		delete iPosition;
   487 		delete iPosition;
   543 		iPosition = NULL;
   488 		iPosition = NULL;
   544 
   489 		
   545 	    
   490 	    
   546 		iTrace->Trace(_L("End of COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); 
   491 		iTrace->Trace(_L("End of COMASuplSession::RunSuplSession"), KTraceFileName, __LINE__); 
   547     }
   492     }
   548 
   493 
   549 // -----------------------------------------------------------------------------
   494 // -----------------------------------------------------------------------------
   558                                         const TDesC& aHslpAddress, TBool aFallBack,
   503                                         const TDesC& aHslpAddress, TBool aFallBack,
   559   										TInt aAllowedCapabilities,TInt aSessionIdSeed,
   504   										TInt aAllowedCapabilities,TInt aSessionIdSeed,
   560   										TSuplTerminalQop& aQop, TInt aRequestID)
   505   										TSuplTerminalQop& aQop, TInt aRequestID)
   561   	{
   506   	{
   562   	
   507   	
   563         iIhaveLaunchedUsagedialog = EFalse;
       
   564   		
   508   		
   565 	  	iClientQop = aQop;
   509 	  	iClientQop = aQop;
   566 	  	
   510 	  	
   567 		TInt delay;
   511 		TInt delay;
   568 		if(iClientQop.GetDelay(delay) != KErrNotFound)
   512 		if(iClientQop.GetDelay(delay) != KErrNotFound)
   707 		if(iIsQoPPresent)
   651 		if(iIsQoPPresent)
   708 			{
   652 			{
   709 				COMASuplStartState* startSuplState =  static_cast <COMASuplPosInitState *>(iSuplState);
   653 				COMASuplStartState* startSuplState =  static_cast <COMASuplPosInitState *>(iSuplState);
   710 				startSuplState->SetQop(iClientQop);
   654 				startSuplState->SetQop(iClientQop);
   711 			}
   655 			}
   712 		if(iIsStaleLocIdPresent)
   656 		//SMP Changes
   713 		    {
   657 		iSuplMsgType = ESUPL_START;
   714 		    iTrace->Trace(_L("GenerateSuplStartL setting stale location id in supl start"), KTraceFileName, __LINE__);
   658 		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating); 	
   715 		    COMASuplStartState* startSuplState =  static_cast <COMASuplPosInitState *>(iSuplState);
       
   716 		    startSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL());
       
   717 		    }
       
   718         iSuplSessionState = ESUPL_GENERATE;
       
   719         iSuplMsgType = ESUPL_START;
       
   720 		TInt err = iSuplState->GenerateMessageL();
   659 		TInt err = iSuplState->GenerateMessageL();
   721 	
   660 
   722 
       
   723 		SetPOSMsgPluginState(COMASuplPosSessionBase::EOMASuplCreating);	
       
   724 	}  
   661 	}  
   725 	 
   662 	 
   726 
   663 
   727 // -----------------------------------------------------------------------------
   664 // -----------------------------------------------------------------------------
   728 // COMASuplSession::GenerateSuplPosInitL
   665 // COMASuplSession::GenerateSuplPosInitL
   761 			TBuf<128> msg(_L("COMASuplSession::GenerateSuplPosInitL() without last 2 params : "));
   698 			TBuf<128> msg(_L("COMASuplSession::GenerateSuplPosInitL() without last 2 params : "));
   762 			msg.AppendNum(iPosMethod);
   699 			msg.AppendNum(iPosMethod);
   763 			iTrace->Trace(msg, KTraceFileName, __LINE__);
   700 			iTrace->Trace(msg, KTraceFileName, __LINE__);
   764 			iSuplState = COMASuplPosInitState::NewL(iSETCapabilities, iMobilePhone, iUT2_PosInitTimer,
   701 			iSuplState = COMASuplPosInitState::NewL(iSETCapabilities, iMobilePhone, iUT2_PosInitTimer,
   765  						 iOMASuplPOSRequestor,iAllowedCapabilities,iRequestType, iPosMethod,iOMASuplAsnHandlerBaseImpl);
   702  						 iOMASuplPOSRequestor,iAllowedCapabilities,iRequestType, iPosMethod,iOMASuplAsnHandlerBaseImpl);
   766 			if(iIsStaleLocIdPresent)
       
   767 			    {
       
   768 			    iTrace->Trace(_L("COMASuplSession::GenerateSuplPosInitL() Setting Stale Location Id "), KTraceFileName, __LINE__);
       
   769 			    COMASuplPosInitState* posInitSuplState =  static_cast <COMASuplPosInitState *>(iSuplState);
       
   770 			    posInitSuplState->SetStaleCellIdToUse(iStaleLocationId->CloneL());
       
   771 			    }
       
   772 		
   703 		
   773 		}
   704 		}
   774 		iSuplState->SetMsgStateObserver(this);
   705 		iSuplState->SetMsgStateObserver(this);
   775 		
   706 		
   776 		//SMP Changes
   707 		//SMP Changes
   882 // (other items were commented in a header).
   813 // (other items were commented in a header).
   883 // -----------------------------------------------------------------------------
   814 // -----------------------------------------------------------------------------
   884 //
   815 //
   885 void COMASuplSession::OperationCompleteL(TInt aErrorCode)
   816 void COMASuplSession::OperationCompleteL(TInt aErrorCode)
   886 	{
   817 	{
   887 	iTrace->Trace(_L("COMASuplSession::OperationCompleteL"), KTraceFileName, __LINE__); 
       
   888 	TBuf<256> msg;
   818 	TBuf<256> msg;
   889 	if(KErrNone != aErrorCode)
   819 	if(KErrNone != aErrorCode)
   890 		{
   820 		{
   891 			msg.Copy(_L("Actual Error Code : "));
   821 			msg.Copy(_L("Actual Error Code : "));
   892 			msg.AppendNum(aErrorCode);
   822 			msg.AppendNum(aErrorCode);
   895             if (iSuplSessionState == ESUPL_CONNECTING)
   825             if (iSuplSessionState == ESUPL_CONNECTING)
   896                 CheckForPersistentFailure(aErrorCode);                    
   826                 CheckForPersistentFailure(aErrorCode);                    
   897 			HandleSuplErrorL(aErrorCode);
   827 			HandleSuplErrorL(aErrorCode);
   898 			return;
   828 			return;
   899 		}
   829 		}
   900 	
       
   901 	msg.Copy(_L("iSuplSessionState : "));
       
   902 	msg.AppendNum(iSuplSessionState);
       
   903 	iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
   904 		
   830 		
   905 	TInt err = KErrNone;
   831 	TInt err = KErrNone;
   906 	
   832 	
   907 	switch(iSuplSessionState)
   833 	switch(iSuplSessionState)
   908 	{
   834 	{
   960 					              }                                                
   886 					              }                                                
   961 				 TRAP( err, iConnRequestor->CreateConnectionL(delay) );
   887 				 TRAP( err, iConnRequestor->CreateConnectionL(delay) );
   962 				 }
   888 				 }
   963 		     else //terminal initiated case
   889 		     else //terminal initiated case
   964 		         {
   890 		         {
   965                  iTrace->Trace(_L("Connection block."), KTraceFileName, __LINE__);
   891             	TRAP( err, iConnRequestor->CreateConnectionL() );
   966             	if(iIsStaleLocIdPresent)
       
   967                      {
       
   968                      TRAP( err, iConnRequestor->CreateConnectionL(iStaleLocIdPrompt,iWlanOnly) );
       
   969                      }
       
   970                  else
       
   971                      {
       
   972                      TRAP( err, iConnRequestor->CreateConnectionL() );
       
   973                      }
       
   974 		         }
   892 		         }
   975 			        if(KErrNone != err)
   893 			        if(KErrNone != err)
   976 				        {
   894 				        {
   977 						    HandleSuplErrorL(err);
   895 						    HandleSuplErrorL(err);
   978 						    break;
   896 						    break;
  2054 		{
  1972 		{
  2055 		msg.Copy(_L("The device is in ON LINE mode."));
  1973 		msg.Copy(_L("The device is in ON LINE mode."));
  2056 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  1974 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2057 		}
  1975 		}
  2058 
  1976 
  2059    
  1977     CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
       
  1978 
       
  1979     if (usage == CSuplSettings::ESuplUsageDisabled)
       
  1980         {                
       
  1981 		msg.Copy(_L("SUPL Usage is disabled"));
       
  1982 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
       
  1983 	    iSessionObserver.TerminateSession(this, KErrGeneral);	
       
  1984 		return;
       
  1985         }
  2060 	    
  1986 	    
  2061 	COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  1987 	COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2062 	    
  1988 	    
  2063 	if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
  1989 	if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
  2064 		{
  1990 		{
  3806         return EFalse;    
  3732         return EFalse;    
  3807         }
  3733         }
  3808     }
  3734     }
  3809 
  3735 
  3810 
  3736 
       
  3737 // -----------------------------------------------------------------------------
       
  3738 // COMASuplSession::SettingsUICompleted
       
  3739 // 
       
  3740 // -----------------------------------------------------------------------------
       
  3741 
       
  3742 void COMASuplSession::SettingsUICompletedL(TInt /*aError*/)
       
  3743 	{
       
  3744 	
       
  3745 	}
       
  3746 
  3811 
  3747 
  3812 // -----------------------------------------------------------------------------
  3748 // -----------------------------------------------------------------------------
  3813 // COMASuplSession::HandleInvalidMessageL
  3749 // COMASuplSession::HandleInvalidMessageL
  3814 // Sends SUPL_END with status code with wrong message
  3750 // Sends SUPL_END with status code with wrong message
  3815 // -----------------------------------------------------------------------------
  3751 // -----------------------------------------------------------------------------
  4107 {
  4043 {
  4108     iTrace->Trace(_L("Timer Expired for SUPL_POSINIT"), KTraceFileName, __LINE__); 
  4044     iTrace->Trace(_L("Timer Expired for SUPL_POSINIT"), KTraceFileName, __LINE__); 
  4109     OperationCompleteL(KErrTimedOut);
  4045     OperationCompleteL(KErrTimedOut);
  4110 }
  4046 }
  4111 
  4047 
  4112 
  4048 // -----------------------------------------------------------------------------
       
  4049 // COMASuplSession::SettingsUsageUICompletedL
       
  4050 // 
       
  4051 // -----------------------------------------------------------------------------
       
  4052 void COMASuplSession::SettingsUsageUICompletedL(TInt aError)
       
  4053 	{
       
  4054 	iUIFlag = EFalse;
       
  4055     TBuf<64> msg;	
       
  4056     msg.Copy(_L("SUPL Usage UI completed with ... "));
       
  4057     msg.AppendNum(aError);
       
  4058     iTrace->Trace(msg,KTraceFileName, __LINE__); 
       
  4059 
       
  4060     iPrevUsageResult = aError;                    
       
  4061 
       
  4062 
       
  4063     if (aError == KErrNone)
       
  4064         {
       
  4065         iProtocolManager.UpdateAllSubSessnsInSameSession(iIpcSessionId);                
       
  4066 
       
  4067         if (isTimeoutDialogTimerStarted)
       
  4068             {                
       
  4069 		    iTrace->Trace(_L("COMASuplSession::SettingsUsageUICompletedL, stopping timer "), KTraceFileName, __LINE__);
       
  4070             isTimeoutDialogTimerStarted = EFalse;                    
       
  4071             iDialogTimer->StopTimer();
       
  4072 
       
  4073             //Compute how log the dialog was on
       
  4074             TTime nowTime;
       
  4075             nowTime.HomeTime();
       
  4076             nowTime.SecondsFrom(iDlgStartTime, iDiffTime);	
       
  4077             }
       
  4078         if (iNwInitError)
       
  4079             {
       
  4080             iNwInitError = EFalse;                    
       
  4081             HandleSuplInitErrorL(iNwInitCompletionCode);                             
       
  4082             }                
       
  4083         else
       
  4084 	        InitializeL(iRequestID); 
       
  4085         }            
       
  4086     else if (aError == KErrCompletion)
       
  4087         CheckForSuplUsageL();
       
  4088     else 
       
  4089 		{
       
  4090 			TBuf<64> msg;	
       
  4091 			msg.Copy(_L("Error after SUPL Usage Popup... "));
       
  4092 			msg.AppendNum(aError);
       
  4093 			iTrace->Trace(msg,KTraceFileName, __LINE__); 
       
  4094 			iSessionObserver.TerminateSession(this, KErrGeneral);	
       
  4095 			return;
       
  4096 		}
       
  4097 	}
  4113 
  4098 
  4114 // -----------------------------------------------------------------------------
  4099 // -----------------------------------------------------------------------------
  4115 // COMASuplSession::CheckForSuplUsageL
  4100 // COMASuplSession::CheckForSuplUsageL
  4116 // 
  4101 // 
  4117 // -----------------------------------------------------------------------------
  4102 // -----------------------------------------------------------------------------
  4118 void COMASuplSession::CheckForSuplUsageL()
  4103 void COMASuplSession::CheckForSuplUsageL()
  4119     {
  4104     {
  4120 
  4105 
  4121              
  4106     if (iSuplUsage >= 1)
       
  4107         {            
       
  4108         CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
       
  4109         if (usage == CSuplSettings::ESuplUsageDisabled)
       
  4110             {            
       
  4111 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
       
  4112             }
       
  4113         else if (usage == CSuplSettings::ESuplUsageAutomatic)
       
  4114             {            
  4122             if (iNwInitError)
  4115             if (iNwInitError)
  4123                 {
  4116                 {
  4124                 iNwInitError = EFalse;                    
  4117                 iNwInitError = EFalse;                    
  4125                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4118                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4126                 }                
  4119                 }                
  4127             else
  4120             else
  4128             	{
  4121 	            InitializeL(iRequestID); 
  4129             		if (iRoaming)                
  4122             }
       
  4123 
       
  4124             else if (usage == CSuplSettings::ESuplUsageHomeAutomatic || usage == CSuplSettings::ESuplUsageAlwaysAsk)
       
  4125             {
       
  4126                 if (iRoaming)                
  4130                     HandleRoamingCheckCompleteL(KErrNone, EFalse);                    
  4127                     HandleRoamingCheckCompleteL(KErrNone, EFalse);                    
  4131                 else
  4128                 else
  4132                     {                        
  4129                     {                        
  4133                     iEtelRoamingCheck = ETrue;
  4130                     iEtelRoamingCheck = ETrue;
  4134                     iProtocolManager.CheckForRoaming();
  4131                     iProtocolManager.CheckForRoaming();
  4135                     }
  4132                     }
  4136 	          	}
  4133             }            
  4137            
  4134         }            
       
  4135         else
       
  4136 	        InitializeL(iRequestID); 
  4138 
  4137 
  4139     }        
  4138     }        
  4140 
  4139 
  4141 // -----------------------------------------------------------------------------
  4140 // -----------------------------------------------------------------------------
  4142 // COMASuplSession::CheckForTimerExpiry
  4141 // COMASuplSession::CheckForTimerExpiry
  4215     iEtelRoamingCheck = EFalse;            
  4214     iEtelRoamingCheck = EFalse;            
  4216     if (aErrorCode == KErrNone)            
  4215     if (aErrorCode == KErrNone)            
  4217         {            
  4216         {            
  4218             iUsageHomeNW = aHomeNw;   
  4217             iUsageHomeNW = aHomeNw;   
  4219             iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW);             
  4218             iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW);             
  4220                  
  4219             CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
       
  4220             
       
  4221             if (usage == CSuplSettings::ESuplUsageAlwaysAsk)
       
  4222                 {
       
  4223                 TInt err;                
       
  4224                     if (!aHomeNw)
       
  4225                         {                            
       
  4226                         iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4227                         err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4228                         }
       
  4229                     else
       
  4230                         {                            
       
  4231                         iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__);
       
  4232                         err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse);        
       
  4233                         }
       
  4234 
       
  4235                 if(KErrNone != err && KErrInUse == err)
       
  4236                     {
       
  4237                         iTrace->Trace(_L("Dialog in use, setting flag"), KTraceFileName, __LINE__);
       
  4238                         SetSuplUsageFlag();                            
       
  4239                     }
       
  4240                 if( KErrNone == err  && iRequestType == ESUPL_NETWORK )
       
  4241                     {
       
  4242                     iTrace->Trace(_L("Network Session , starting timer"), KTraceFileName, __LINE__);
       
  4243                     COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4244                     TOMASuplQop qop;
       
  4245                     TInt retVal = suplInit->Qop(qop);
       
  4246                     TInt delay;
       
  4247                     qop.Delay(delay);
       
  4248                     //if delay is > 7, it is not valid
       
  4249                     if (delay > 7)
       
  4250                         delay = 0;                                
       
  4251                     if(retVal == KErrNone && delay > 0)
       
  4252                         {
       
  4253                         TReal delayReal;
       
  4254                         Math::Pow(delayReal, 2, (TReal)delay);
       
  4255                         delay = (TInt) delayReal;
       
  4256                         TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4257                         msg.AppendNum(delay);
       
  4258                         iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4259                         isTimeoutDialogTimerStarted = ETrue;
       
  4260                         iDialogTimer->StartTimer(delay);
       
  4261                         }  	
       
  4262                     else
       
  4263                         {
       
  4264                         if (iSuplInitTimeOut > 0)
       
  4265                             {                                                        
       
  4266                             TBuf<256> msg(_L("Delay value in CR is"));
       
  4267                             msg.AppendNum(iSuplInitTimeOut);
       
  4268                             iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4269                             iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4270                             isTimeoutDialogTimerStarted = ETrue;
       
  4271                             }
       
  4272                         else
       
  4273                             iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4274                         }
       
  4275                     iDlgStartTime.HomeTime();
       
  4276                     }
       
  4277                 else if (KErrNone != err)
       
  4278                     {
       
  4279                     iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4280                     HandleSuplErrorL(err);
       
  4281                     }
       
  4282 
       
  4283                 }
       
  4284             else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) 
       
  4285             {                
       
  4286             if (!aHomeNw)
       
  4287                 {                
       
  4288                 TInt err;                
       
  4289                 //if (!iSuplSettings->IsUIActive() )
       
  4290                     {
       
  4291                     iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4292                     err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
  4221 
  4293 
  4222                     if(iSuplMsgType == ESUPL_INIT)
  4294                     if(iSuplMsgType == ESUPL_INIT)
  4223                         {
  4295                         {
  4224                         iTrace->Trace(_L("Dialog timer started"), KTraceFileName, __LINE__);
  4296                         iTrace->Trace(_L("Dialog timer started"), KTraceFileName, __LINE__);
  4225 				     
  4297 				     
  4238                             delay = (TInt) delayReal;
  4310                             delay = (TInt) delayReal;
  4239                             TBuf<128> msg(_L("Delay present in message, value is = "));
  4311                             TBuf<128> msg(_L("Delay present in message, value is = "));
  4240                             msg.AppendNum(delay);
  4312                             msg.AppendNum(delay);
  4241                             iTrace->Trace(msg, KTraceFileName, __LINE__); 
  4313                             iTrace->Trace(msg, KTraceFileName, __LINE__); 
  4242                             isTimeoutDialogTimerStarted = ETrue;
  4314                             isTimeoutDialogTimerStarted = ETrue;
  4243                             
  4315                             iDialogTimer->StartTimer(delay);
  4244                             }  	
  4316                             }  	
  4245                         else
  4317                         else
  4246                             {
  4318                             {
  4247                             if (iSuplInitTimeOut > 0)
  4319                             if (iSuplInitTimeOut > 0)
  4248                                 {                                                        
  4320                                 {                                                        
  4249                                 isTimeoutDialogTimerStarted = ETrue;
  4321                                 isTimeoutDialogTimerStarted = ETrue;
  4250                                 
  4322                                 iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
  4251                                 }
  4323                                 }
  4252                             else
  4324                             else
  4253                                 iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
  4325                                 iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
  4254                             }
  4326                             }
  4255                         }
  4327                         }
  4256                                 
  4328                     }
       
  4329 
       
  4330                 if(!iSuplSettings->IsUIActive() && KErrNone != err)
       
  4331                     {
       
  4332                         SetSuplUsageFlag();                            
       
  4333                     }
       
  4334                 else
       
  4335                     {
       
  4336                     iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4337                     HandleSuplErrorL(err);
       
  4338                     }
       
  4339                 }
       
  4340             else            
       
  4341                 {                
  4257                 if (iNwInitError)
  4342                 if (iNwInitError)
  4258                     {
  4343                     {
  4259                     iNwInitError = EFalse;                    
  4344                     iNwInitError = EFalse;                    
  4260                     HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4345                     HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4261                     }                
  4346                     }                
  4262                 else
  4347                 else
  4263                 {
  4348 	                InitializeL(iRequestID); 
  4264                 	iTrace->Trace(_L("COMASuplSession::InitializeL called after roaming check"), KTraceFileName, __LINE__);
  4349                 }                
  4265 	                InitializeL(iRequestID);  
  4350             }                
  4266 	              }  
       
  4267         }
  4351         }
  4268    else
  4352         else
  4269         {
  4353             {
  4270       	iSessionObserver.TerminateSession(this, KErrGeneral);	
  4354 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
  4271         }                
  4355             }                
  4272     }            
  4356     }            
  4273 TInt COMASuplSession::SuplIpcSessionID() 
  4357 TInt COMASuplSession::SuplIpcSessionID() 
  4274     {
  4358     {
  4275     return iIpcSessionId;
  4359     return iIpcSessionId;
  4276     }    
  4360     }    
  4331 TBool COMASuplSession::GetSuplUsageFlag()
  4415 TBool COMASuplSession::GetSuplUsageFlag()
  4332     {
  4416     {
  4333     return iUsageDialog;
  4417     return iUsageDialog;
  4334     }        
  4418     }        
  4335 
  4419 
  4336 
  4420 void COMASuplSession::StartUsageDialogLaunchL()
       
  4421     {
       
  4422     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL"), KTraceFileName, __LINE__);
       
  4423     ReSetSuplUsageFlag();            
       
  4424     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL, flag reset done"), KTraceFileName, __LINE__);
       
  4425 
       
  4426     CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
       
  4427     if (usage == CSuplSettings::ESuplUsageAlwaysAsk)
       
  4428         {
       
  4429         TInt err;                
       
  4430         if (!iUsageHomeNW)
       
  4431             {                            
       
  4432             iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4433             err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4434 
       
  4435             if(iRequestType == ESUPL_NETWORK && err == KErrNone)
       
  4436                 {
       
  4437                 iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__);
       
  4438 				     
       
  4439                 COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4440                 TOMASuplQop qop;
       
  4441                 TInt retVal = suplInit->Qop(qop);
       
  4442                 TInt delay;
       
  4443                 qop.Delay(delay);
       
  4444                 //if delay is > 7, it is not valid
       
  4445                 if (delay > 7)
       
  4446                     delay = 0;                                
       
  4447                 if(retVal == KErrNone && delay > 0)
       
  4448                     {
       
  4449                     TReal delayReal;
       
  4450                     Math::Pow(delayReal, 2, (TReal)delay);
       
  4451                     delay = (TInt) delayReal;
       
  4452                     TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4453                     msg.AppendNum(delay);
       
  4454                     iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4455                     isTimeoutDialogTimerStarted = ETrue;
       
  4456                     iDialogTimer->StartTimer(delay);
       
  4457                     }  	
       
  4458                 else
       
  4459                     {
       
  4460                     if (iSuplInitTimeOut > 0)
       
  4461                         {                                                        
       
  4462                         iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__);
       
  4463                         TBuf<256> msg(_L("Delay value in CR is "));
       
  4464                         msg.AppendNum(iSuplInitTimeOut);
       
  4465                         iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4466                         isTimeoutDialogTimerStarted = ETrue;
       
  4467                         }
       
  4468                     else
       
  4469                         iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4470                     }
       
  4471                 }
       
  4472             }
       
  4473         else
       
  4474             {                            
       
  4475             iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__);
       
  4476             err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse);        
       
  4477 
       
  4478             if( iRequestType == ESUPL_NETWORK && err == KErrNone)
       
  4479                 {    
       
  4480                 iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__);
       
  4481 				     
       
  4482                 COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4483                 TOMASuplQop qop;
       
  4484                 TInt retVal = suplInit->Qop(qop);
       
  4485                 TInt delay;
       
  4486                 qop.Delay(delay);
       
  4487                 //if delay is > 7, it is not valid
       
  4488                 if (delay > 7)
       
  4489                     delay = 0;                                
       
  4490                 if(retVal == KErrNone && delay > 0)
       
  4491                     {
       
  4492                     TReal delayReal;
       
  4493                     Math::Pow(delayReal, 2, (TReal)delay);
       
  4494                     delay = (TInt) delayReal;
       
  4495                     TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4496                     msg.AppendNum(delay);
       
  4497                     iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4498                     isTimeoutDialogTimerStarted = ETrue;
       
  4499                     iDialogTimer->StartTimer(delay);
       
  4500                     }  	
       
  4501                 else
       
  4502                     {
       
  4503                     if (iSuplInitTimeOut > 0)
       
  4504                         {                                                        
       
  4505                         iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__);
       
  4506                         TBuf<256> msg(_L("Delay value in CR is"));
       
  4507                         msg.AppendNum(iSuplInitTimeOut);
       
  4508                         iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4509                         isTimeoutDialogTimerStarted = ETrue;
       
  4510                         }
       
  4511                     else
       
  4512                         iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4513                     }
       
  4514                 }
       
  4515             }
       
  4516 
       
  4517         if(KErrNone != err)
       
  4518             {                        
       
  4519             iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4520             HandleSuplErrorL(err);
       
  4521             }
       
  4522         }
       
  4523     else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) 
       
  4524         {                
       
  4525         if (!iUsageHomeNW)
       
  4526             {                
       
  4527             TInt err;                
       
  4528             iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4529             err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4530 
       
  4531             if(KErrNone != err)
       
  4532                 {
       
  4533                 iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4534                 HandleSuplErrorL(err);
       
  4535                 }
       
  4536 
       
  4537             if(iRequestType == ESUPL_NETWORK && err == KErrNone)
       
  4538                 {    
       
  4539                 iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__);
       
  4540 				     
       
  4541                 COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4542                 TOMASuplQop qop;
       
  4543                 TInt retVal = suplInit->Qop(qop);
       
  4544                 TInt delay;
       
  4545                 qop.Delay(delay);
       
  4546                 //if delay is > 7, it is not valid
       
  4547                 if (delay > 7)
       
  4548                     delay = 0;                                
       
  4549                 if(retVal == KErrNone && delay > 0)
       
  4550                     {
       
  4551                     TReal delayReal;
       
  4552                     Math::Pow(delayReal, 2, (TReal)delay);
       
  4553                     delay = (TInt) delayReal;
       
  4554                     TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4555                     msg.AppendNum(delay);
       
  4556                     iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4557                     isTimeoutDialogTimerStarted = ETrue;
       
  4558                     iDialogTimer->StartTimer(delay);
       
  4559                     }  	
       
  4560                 else
       
  4561                     {
       
  4562                     if (iSuplInitTimeOut > 0)
       
  4563                         {                                                        
       
  4564                         iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__);
       
  4565                         TBuf<256> msg(_L("Delay value in CR is"));
       
  4566                         msg.AppendNum(iSuplInitTimeOut);
       
  4567                         iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4568                         isTimeoutDialogTimerStarted = ETrue;
       
  4569                         }
       
  4570                     else
       
  4571                         iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4572                     }
       
  4573                 }
       
  4574             }
       
  4575         else            
       
  4576             {                
       
  4577             if (iNwInitError)
       
  4578                 {
       
  4579                 iNwInitError = EFalse;                    
       
  4580                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
       
  4581                 }                
       
  4582             else
       
  4583 	            InitializeL(iRequestID); 
       
  4584             }                
       
  4585         }                
       
  4586     }
  4337 
  4587 
  4338 TBool COMASuplSession::IsEtelNotifySet()
  4588 TBool COMASuplSession::IsEtelNotifySet()
  4339     {
  4589     {
  4340     iTrace->Trace(_L("COMASuplSession::IsEtelNotifySet"), KTraceFileName, __LINE__); 
  4590     iTrace->Trace(_L("COMASuplSession::IsEtelNotifySet"), KTraceFileName, __LINE__); 
  4341     return iEtelNotify;            
  4591     return iEtelNotify;            
  4344 TBool COMASuplSession::IsEtelRoamingSet()
  4594 TBool COMASuplSession::IsEtelRoamingSet()
  4345     {
  4595     {
  4346     iTrace->Trace(_L("COMASuplSession::IsEtelRoamingSet"), KTraceFileName, __LINE__); 
  4596     iTrace->Trace(_L("COMASuplSession::IsEtelRoamingSet"), KTraceFileName, __LINE__); 
  4347     return iEtelRoamingCheck;
  4597     return iEtelRoamingCheck;
  4348     }        
  4598     }        
       
  4599 
       
  4600 // -----------------------------------------------------------------------------
       
  4601 // COMASuplSession::DialogTimerExpiredL
       
  4602 // Checks whether UI is displayed or not previously
       
  4603 // 
       
  4604 // -----------------------------------------------------------------------------
       
  4605 void COMASuplSession::DialogTimerExpiredL()
       
  4606 {
       
  4607    iTrace->Trace(_L("Timer Expired for SUPL Dialog"), KTraceFileName, __LINE__); 
       
  4608   
       
  4609     if (!iIapDialogShown)
       
  4610 	    iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
  4611     else
       
  4612         iIapDlgTimerExpired = ETrue;            
       
  4613 
       
  4614     return;	
       
  4615 }
       
  4616 
       
  4617 // -----------------------------------------------------------------------------
       
  4618 // COMASuplSession::SettingsTimeOutUICompletedL
       
  4619 // 
       
  4620 // -----------------------------------------------------------------------------
       
  4621 void COMASuplSession::SettingsTimeOutUICompletedL(TInt aError)
       
  4622 	{
  4349 	
  4623 	
  4350 TBool COMASuplSession::HasMeLaunchedUsageDialog()
  4624 	    TBuf<64> msg;	
  4351 {
  4625 	    msg.Copy(_L("SUPL Timeout UI completed with ... "));
  4352 	return iIhaveLaunchedUsagedialog; 
  4626 	    msg.AppendNum(aError);
  4353 }
  4627 	    iTrace->Trace(msg,KTraceFileName, __LINE__); 
  4354 
  4628 	    iSessionObserver.TerminateSession(this, KErrGeneral);	
  4355 
  4629 	    return;
       
  4630 	    
       
  4631 	}
  4356 	
  4632 	
  4357 // -----------------------------------------------------------------------------
  4633 // -----------------------------------------------------------------------------
  4358 // COMASuplSession::StoreCurrentCellIDL
  4634 // COMASuplSession::StoreCurrentCellIDL
  4359 // Stores current cell id in CR
  4635 // Stores current cell id in CR
  4360 // 
  4636 //