supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplsession.cpp
branchRCL_3
changeset 49 10852b179f64
parent 45 6b6920c56e2f
child 55 ea98413ce11f
equal deleted inserted replaced
47:fce0ae2e4223 49:10852b179f64
   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);
       
   198 		
   196 		
   199 		iIsQoPPresent = EFalse;	
   197 		iIsQoPPresent = EFalse;	
   200 		iIsFirstPOSMessage = ETrue;
   198 		iIsFirstPOSMessage = ETrue;
   201 		isTimeoutDialogTimerStarted = EFalse;
   199 		isTimeoutDialogTimerStarted = EFalse;
   202 
   200 
   251 		{
   249 		{
   252 			CancelRunSession();
   250 			CancelRunSession();
   253 			SessionEnd();
   251 			SessionEnd();
   254 			CompleteSession(KErrCancel);
   252 			CompleteSession(KErrCancel);
   255 		}
   253 		}
   256 		iProtocolManager.CancelUiLaunch();
       
   257 		delete this;
   254 		delete this;
   258 	}
   255 	}
   259 
   256 
   260 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   261 // COMASuplSession::PosPlugInUnloaded
   258 // COMASuplSession::PosPlugInUnloaded
   311     	delete iPOSSession;
   308     	delete iPOSSession;
   312     	iPOSSession = NULL;
   309     	iPOSSession = NULL;
   313     	delete iTimer;
   310     	delete iTimer;
   314         delete iIapNotifier;
   311         delete iIapNotifier;
   315     	iIMSI.Close();
   312     	iIMSI.Close();
   316         delete iDialogTimer;
       
   317         
   313         
   318         delete iNetworkPrivacy;
   314         delete iNetworkPrivacy;
   319 
   315 
   320 	if(iStaleLocationId)
   316 	if(iStaleLocationId)
   321     	  {
   317     	  {
  2058 		{
  2054 		{
  2059 		msg.Copy(_L("The device is in ON LINE mode."));
  2055 		msg.Copy(_L("The device is in ON LINE mode."));
  2060 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2056 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
  2061 		}
  2057 		}
  2062 
  2058 
  2063     CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  2059    
  2064 
       
  2065     if (usage == CSuplSettings::ESuplUsageDisabled)
       
  2066         {                
       
  2067 		msg.Copy(_L("SUPL Usage is disabled"));
       
  2068 		iTrace->Trace(msg,KTraceFileName, __LINE__); 
       
  2069 	    iSessionObserver.TerminateSession(this, KErrGeneral);	
       
  2070 		return;
       
  2071         }
       
  2072 	    
  2060 	    
  2073 	COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2061 	COMASuplAsnMessageBase::TSuplMessageType messageType = aDecodedAsnMessage->MessageType();
  2074 	    
  2062 	    
  2075 	if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
  2063 	if(messageType == COMASuplAsnMessageBase::ESUPL_INIT && aErrorCode == KErrNone)
  2076 		{
  2064 		{
  3818         return EFalse;    
  3806         return EFalse;    
  3819         }
  3807         }
  3820     }
  3808     }
  3821 
  3809 
  3822 
  3810 
  3823 // -----------------------------------------------------------------------------
       
  3824 // COMASuplSession::SettingsUICompleted
       
  3825 // 
       
  3826 // -----------------------------------------------------------------------------
       
  3827 
       
  3828 void COMASuplSession::SettingsUICompletedL(TInt /*aError*/)
       
  3829 	{
       
  3830 	
       
  3831 	}
       
  3832 
       
  3833 
  3811 
  3834 // -----------------------------------------------------------------------------
  3812 // -----------------------------------------------------------------------------
  3835 // COMASuplSession::HandleInvalidMessageL
  3813 // COMASuplSession::HandleInvalidMessageL
  3836 // Sends SUPL_END with status code with wrong message
  3814 // Sends SUPL_END with status code with wrong message
  3837 // -----------------------------------------------------------------------------
  3815 // -----------------------------------------------------------------------------
  4129 {
  4107 {
  4130     iTrace->Trace(_L("Timer Expired for SUPL_POSINIT"), KTraceFileName, __LINE__); 
  4108     iTrace->Trace(_L("Timer Expired for SUPL_POSINIT"), KTraceFileName, __LINE__); 
  4131     OperationCompleteL(KErrTimedOut);
  4109     OperationCompleteL(KErrTimedOut);
  4132 }
  4110 }
  4133 
  4111 
  4134 // -----------------------------------------------------------------------------
  4112 
  4135 // COMASuplSession::SettingsUsageUICompletedL
       
  4136 // 
       
  4137 // -----------------------------------------------------------------------------
       
  4138 void COMASuplSession::SettingsUsageUICompletedL(TInt aError)
       
  4139 	{
       
  4140 	iUIFlag = EFalse;
       
  4141     TBuf<64> msg;	
       
  4142     msg.Copy(_L("SUPL Usage UI completed with ... "));
       
  4143     msg.AppendNum(aError);
       
  4144     iTrace->Trace(msg,KTraceFileName, __LINE__); 
       
  4145 
       
  4146     iPrevUsageResult = aError;                    
       
  4147     iIhaveLaunchedUsagedialog = EFalse;                 
       
  4148 
       
  4149 
       
  4150     if (aError == KErrNone)
       
  4151         {
       
  4152         iProtocolManager.UpdateAllSubSessnsInSameSession(iIpcSessionId);                
       
  4153 
       
  4154         if (isTimeoutDialogTimerStarted)
       
  4155             {                
       
  4156 		    iTrace->Trace(_L("COMASuplSession::SettingsUsageUICompletedL, stopping timer "), KTraceFileName, __LINE__);
       
  4157             isTimeoutDialogTimerStarted = EFalse;                    
       
  4158             iDialogTimer->StopTimer();
       
  4159 
       
  4160             //Compute how log the dialog was on
       
  4161             TTime nowTime;
       
  4162             nowTime.HomeTime();
       
  4163             nowTime.SecondsFrom(iDlgStartTime, iDiffTime);	
       
  4164             }
       
  4165         if (iNwInitError)
       
  4166             {
       
  4167             iNwInitError = EFalse;                    
       
  4168             HandleSuplInitErrorL(iNwInitCompletionCode);                             
       
  4169             }                
       
  4170         else
       
  4171 	        InitializeL(iRequestID); 
       
  4172         }            
       
  4173     else if (aError == KErrCompletion)
       
  4174         CheckForSuplUsageL();
       
  4175     else 
       
  4176 		{
       
  4177 			TBuf<64> msg;	
       
  4178 			msg.Copy(_L("Error after SUPL Usage Popup... "));
       
  4179 			msg.AppendNum(aError);
       
  4180 			iTrace->Trace(msg,KTraceFileName, __LINE__); 
       
  4181 			iSessionObserver.TerminateSession(this, KErrGeneral);	
       
  4182 			return;
       
  4183 		}
       
  4184 	}
       
  4185 
  4113 
  4186 // -----------------------------------------------------------------------------
  4114 // -----------------------------------------------------------------------------
  4187 // COMASuplSession::CheckForSuplUsageL
  4115 // COMASuplSession::CheckForSuplUsageL
  4188 // 
  4116 // 
  4189 // -----------------------------------------------------------------------------
  4117 // -----------------------------------------------------------------------------
  4190 void COMASuplSession::CheckForSuplUsageL()
  4118 void COMASuplSession::CheckForSuplUsageL()
  4191     {
  4119     {
  4192 
  4120 
  4193     if (iSuplUsage >= 1)
  4121              
  4194         {            
       
  4195         CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
       
  4196         if (usage == CSuplSettings::ESuplUsageDisabled)
       
  4197             {            
       
  4198 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
       
  4199             }
       
  4200         else if (usage == CSuplSettings::ESuplUsageAutomatic)
       
  4201             {            
       
  4202             if (iNwInitError)
  4122             if (iNwInitError)
  4203                 {
  4123                 {
  4204                 iNwInitError = EFalse;                    
  4124                 iNwInitError = EFalse;                    
  4205                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4125                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4206                 }                
  4126                 }                
  4207             else
  4127             else
  4208 	            InitializeL(iRequestID); 
  4128             	{
  4209             }
  4129             		if (iRoaming)                
  4210 
       
  4211             else if (usage == CSuplSettings::ESuplUsageHomeAutomatic || usage == CSuplSettings::ESuplUsageAlwaysAsk)
       
  4212             {
       
  4213                 if (iRoaming)                
       
  4214                     HandleRoamingCheckCompleteL(KErrNone, EFalse);                    
  4130                     HandleRoamingCheckCompleteL(KErrNone, EFalse);                    
  4215                 else
  4131                 else
  4216                     {                        
  4132                     {                        
  4217                     iEtelRoamingCheck = ETrue;
  4133                     iEtelRoamingCheck = ETrue;
  4218                     iProtocolManager.CheckForRoaming();
  4134                     iProtocolManager.CheckForRoaming();
  4219                     }
  4135                     }
  4220             }            
  4136 	          	}
  4221         }            
  4137            
  4222         else
       
  4223 	        InitializeL(iRequestID); 
       
  4224 
  4138 
  4225     }        
  4139     }        
  4226 
  4140 
  4227 // -----------------------------------------------------------------------------
  4141 // -----------------------------------------------------------------------------
  4228 // COMASuplSession::CheckForTimerExpiry
  4142 // COMASuplSession::CheckForTimerExpiry
  4301     iEtelRoamingCheck = EFalse;            
  4215     iEtelRoamingCheck = EFalse;            
  4302     if (aErrorCode == KErrNone)            
  4216     if (aErrorCode == KErrNone)            
  4303         {            
  4217         {            
  4304             iUsageHomeNW = aHomeNw;   
  4218             iUsageHomeNW = aHomeNw;   
  4305             iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW);             
  4219             iConnRequestor->UpdateSLPListForHomeUsage(iUsageHomeNW);             
  4306             CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
  4220                  
  4307             
       
  4308             if (usage == CSuplSettings::ESuplUsageAlwaysAsk || iStaleLocIdPrompt)
       
  4309                 {
       
  4310                 TInt err;                
       
  4311                 if (!iSuplSettings->IsUIActive() )
       
  4312                     {                        
       
  4313                     if (!aHomeNw)
       
  4314                         {                            
       
  4315                         iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4316                         iIhaveLaunchedUsagedialog = ETrue;                 
       
  4317                         err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4318                         }
       
  4319                     else
       
  4320                         {                            
       
  4321                         iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__);
       
  4322                         iIhaveLaunchedUsagedialog = ETrue;                 
       
  4323                         err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse);        
       
  4324                         }
       
  4325                     }
       
  4326                 else
       
  4327                     err = KErrInUse;                        
       
  4328 
       
  4329                 if(KErrNone != err && KErrInUse == err)
       
  4330                     {
       
  4331                         iTrace->Trace(_L("Dialog in use, setting flag"), KTraceFileName, __LINE__);
       
  4332                         SetSuplUsageFlag();                            
       
  4333                     }
       
  4334                 if( KErrNone == err  && iRequestType == ESUPL_NETWORK )
       
  4335                     {
       
  4336                     iTrace->Trace(_L("Network Session , starting timer"), KTraceFileName, __LINE__);
       
  4337                     COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4338                     TOMASuplQop qop;
       
  4339                     TInt retVal = suplInit->Qop(qop);
       
  4340                     TInt delay;
       
  4341                     qop.Delay(delay);
       
  4342                     //if delay is > 7, it is not valid
       
  4343                     if (delay > 7)
       
  4344                         delay = 0;                                
       
  4345                     if(retVal == KErrNone && delay > 0)
       
  4346                         {
       
  4347                         TReal delayReal;
       
  4348                         Math::Pow(delayReal, 2, (TReal)delay);
       
  4349                         delay = (TInt) delayReal;
       
  4350                         TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4351                         msg.AppendNum(delay);
       
  4352                         iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4353                         isTimeoutDialogTimerStarted = ETrue;
       
  4354                         iDialogTimer->StartTimer(delay);
       
  4355                         }  	
       
  4356                     else
       
  4357                         {
       
  4358                         if (iSuplInitTimeOut > 0)
       
  4359                             {                                                        
       
  4360                             TBuf<256> msg(_L("Delay value in CR is"));
       
  4361                             msg.AppendNum(iSuplInitTimeOut);
       
  4362                             iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4363                             iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4364                             isTimeoutDialogTimerStarted = ETrue;
       
  4365                             }
       
  4366                         else
       
  4367                             iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4368                         }
       
  4369                     iDlgStartTime.HomeTime();
       
  4370                     }
       
  4371                 else if (KErrNone != err)
       
  4372                     {
       
  4373                     iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4374                     HandleSuplErrorL(err);
       
  4375                     }
       
  4376 
       
  4377                 }
       
  4378             else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) 
       
  4379             {                
       
  4380             if (!aHomeNw)
       
  4381                 {                
       
  4382                 TInt err;                
       
  4383                 //if (!iSuplSettings->IsUIActive() )
       
  4384                     {
       
  4385                     iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4386                     err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4387 
  4221 
  4388                     if(iSuplMsgType == ESUPL_INIT)
  4222                     if(iSuplMsgType == ESUPL_INIT)
  4389                         {
  4223                         {
  4390                         iTrace->Trace(_L("Dialog timer started"), KTraceFileName, __LINE__);
  4224                         iTrace->Trace(_L("Dialog timer started"), KTraceFileName, __LINE__);
  4391 				     
  4225 				     
  4404                             delay = (TInt) delayReal;
  4238                             delay = (TInt) delayReal;
  4405                             TBuf<128> msg(_L("Delay present in message, value is = "));
  4239                             TBuf<128> msg(_L("Delay present in message, value is = "));
  4406                             msg.AppendNum(delay);
  4240                             msg.AppendNum(delay);
  4407                             iTrace->Trace(msg, KTraceFileName, __LINE__); 
  4241                             iTrace->Trace(msg, KTraceFileName, __LINE__); 
  4408                             isTimeoutDialogTimerStarted = ETrue;
  4242                             isTimeoutDialogTimerStarted = ETrue;
  4409                             iDialogTimer->StartTimer(delay);
  4243                             
  4410                             }  	
  4244                             }  	
  4411                         else
  4245                         else
  4412                             {
  4246                             {
  4413                             if (iSuplInitTimeOut > 0)
  4247                             if (iSuplInitTimeOut > 0)
  4414                                 {                                                        
  4248                                 {                                                        
  4415                                 isTimeoutDialogTimerStarted = ETrue;
  4249                                 isTimeoutDialogTimerStarted = ETrue;
  4416                                 iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
  4250                                 
  4417                                 }
  4251                                 }
  4418                             else
  4252                             else
  4419                                 iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
  4253                                 iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
  4420                             }
  4254                             }
  4421                         }
  4255                         }
  4422                     }
  4256                                 
  4423 
       
  4424                 if(!iSuplSettings->IsUIActive() && KErrNone != err)
       
  4425                     {
       
  4426                         SetSuplUsageFlag();                            
       
  4427                     }
       
  4428                 else
       
  4429                     {
       
  4430                     iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4431                     HandleSuplErrorL(err);
       
  4432                     }
       
  4433                 }
       
  4434             else            
       
  4435                 {                
       
  4436                 if (iNwInitError)
  4257                 if (iNwInitError)
  4437                     {
  4258                     {
  4438                     iNwInitError = EFalse;                    
  4259                     iNwInitError = EFalse;                    
  4439                     HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4260                     HandleSuplInitErrorL(iNwInitCompletionCode);                             
  4440                     }                
  4261                     }                
  4441                 else
  4262                 else
  4442 	                InitializeL(iRequestID); 
  4263                 {
  4443                 }                
  4264                 	iTrace->Trace(_L("COMASuplSession::InitializeL called after roaming check"), KTraceFileName, __LINE__);
  4444             }                
  4265 	                InitializeL(iRequestID);  
       
  4266 	              }  
  4445         }
  4267         }
  4446         else
  4268    else
  4447             {
  4269         {
  4448 	        iSessionObserver.TerminateSession(this, KErrGeneral);	
  4270       	iSessionObserver.TerminateSession(this, KErrGeneral);	
  4449             }                
  4271         }                
  4450     }            
  4272     }            
  4451 TInt COMASuplSession::SuplIpcSessionID() 
  4273 TInt COMASuplSession::SuplIpcSessionID() 
  4452     {
  4274     {
  4453     return iIpcSessionId;
  4275     return iIpcSessionId;
  4454     }    
  4276     }    
  4509 TBool COMASuplSession::GetSuplUsageFlag()
  4331 TBool COMASuplSession::GetSuplUsageFlag()
  4510     {
  4332     {
  4511     return iUsageDialog;
  4333     return iUsageDialog;
  4512     }        
  4334     }        
  4513 
  4335 
  4514 void COMASuplSession::StartUsageDialogLaunchL()
  4336 
  4515     {
       
  4516     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL"), KTraceFileName, __LINE__);
       
  4517     ReSetSuplUsageFlag();            
       
  4518     iTrace->Trace(_L("COMASuplSession::StartUsageDialogLaunchL, flag reset done"), KTraceFileName, __LINE__);
       
  4519 
       
  4520     CSuplSettings::TSuplSettingsUsage usage = iSuplSettings->SUPLUsage();
       
  4521     if (usage == CSuplSettings::ESuplUsageAlwaysAsk)
       
  4522         {
       
  4523         TInt err;                
       
  4524         if (!iUsageHomeNW)
       
  4525             {                            
       
  4526             iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4527             err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4528 
       
  4529             if(iRequestType == ESUPL_NETWORK && err == KErrNone)
       
  4530                 {
       
  4531                 iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__);
       
  4532 				     
       
  4533                 COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4534                 TOMASuplQop qop;
       
  4535                 TInt retVal = suplInit->Qop(qop);
       
  4536                 TInt delay;
       
  4537                 qop.Delay(delay);
       
  4538                 //if delay is > 7, it is not valid
       
  4539                 if (delay > 7)
       
  4540                     delay = 0;                                
       
  4541                 if(retVal == KErrNone && delay > 0)
       
  4542                     {
       
  4543                     TReal delayReal;
       
  4544                     Math::Pow(delayReal, 2, (TReal)delay);
       
  4545                     delay = (TInt) delayReal;
       
  4546                     TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4547                     msg.AppendNum(delay);
       
  4548                     iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4549                     isTimeoutDialogTimerStarted = ETrue;
       
  4550                     iDialogTimer->StartTimer(delay);
       
  4551                     }  	
       
  4552                 else
       
  4553                     {
       
  4554                     if (iSuplInitTimeOut > 0)
       
  4555                         {                                                        
       
  4556                         iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__);
       
  4557                         TBuf<256> msg(_L("Delay value in CR is "));
       
  4558                         msg.AppendNum(iSuplInitTimeOut);
       
  4559                         iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4560                         isTimeoutDialogTimerStarted = ETrue;
       
  4561                         }
       
  4562                     else
       
  4563                         iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4564                     }
       
  4565                 }
       
  4566             }
       
  4567         else
       
  4568             {                            
       
  4569             iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is not roaming"), KTraceFileName, __LINE__);
       
  4570             err = iProtocolManager.LaunchSuplUsageSettingsUI(this, EFalse);        
       
  4571 
       
  4572             if( iRequestType == ESUPL_NETWORK && err == KErrNone)
       
  4573                 {    
       
  4574                 iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__);
       
  4575 				     
       
  4576                 COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4577                 TOMASuplQop qop;
       
  4578                 TInt retVal = suplInit->Qop(qop);
       
  4579                 TInt delay;
       
  4580                 qop.Delay(delay);
       
  4581                 //if delay is > 7, it is not valid
       
  4582                 if (delay > 7)
       
  4583                     delay = 0;                                
       
  4584                 if(retVal == KErrNone && delay > 0)
       
  4585                     {
       
  4586                     TReal delayReal;
       
  4587                     Math::Pow(delayReal, 2, (TReal)delay);
       
  4588                     delay = (TInt) delayReal;
       
  4589                     TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4590                     msg.AppendNum(delay);
       
  4591                     iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4592                     isTimeoutDialogTimerStarted = ETrue;
       
  4593                     iDialogTimer->StartTimer(delay);
       
  4594                     }  	
       
  4595                 else
       
  4596                     {
       
  4597                     if (iSuplInitTimeOut > 0)
       
  4598                         {                                                        
       
  4599                         iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__);
       
  4600                         TBuf<256> msg(_L("Delay value in CR is"));
       
  4601                         msg.AppendNum(iSuplInitTimeOut);
       
  4602                         iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4603                         isTimeoutDialogTimerStarted = ETrue;
       
  4604                         }
       
  4605                     else
       
  4606                         iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4607                     }
       
  4608                 }
       
  4609             }
       
  4610 
       
  4611         if(KErrNone != err)
       
  4612             {                        
       
  4613             iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4614             HandleSuplErrorL(err);
       
  4615             }
       
  4616         }
       
  4617     else if (usage == CSuplSettings::ESuplUsageHomeAutomatic) 
       
  4618         {                
       
  4619         if (!iUsageHomeNW)
       
  4620             {                
       
  4621             TInt err;                
       
  4622             iTrace->Trace(_L("Invoking LaunchSuplUsageSettingsUI, user is roaming"), KTraceFileName, __LINE__);
       
  4623             err = iProtocolManager.LaunchSuplUsageSettingsUI(this, ETrue);        
       
  4624 
       
  4625             if(KErrNone != err)
       
  4626                 {
       
  4627                 iTrace->Trace(_L("Invoking HandleSuplErrorL"), KTraceFileName, __LINE__);
       
  4628                 HandleSuplErrorL(err);
       
  4629                 }
       
  4630 
       
  4631             if(iRequestType == ESUPL_NETWORK && err == KErrNone)
       
  4632                 {    
       
  4633                 iTrace->Trace(_L("starting Dialog timer "), KTraceFileName, __LINE__);
       
  4634 				     
       
  4635                 COMASuplInit* suplInit = static_cast <COMASuplInit*> (iDecodedAsnMessage);
       
  4636                 TOMASuplQop qop;
       
  4637                 TInt retVal = suplInit->Qop(qop);
       
  4638                 TInt delay;
       
  4639                 qop.Delay(delay);
       
  4640                 //if delay is > 7, it is not valid
       
  4641                 if (delay > 7)
       
  4642                     delay = 0;                                
       
  4643                 if(retVal == KErrNone && delay > 0)
       
  4644                     {
       
  4645                     TReal delayReal;
       
  4646                     Math::Pow(delayReal, 2, (TReal)delay);
       
  4647                     delay = (TInt) delayReal;
       
  4648                     TBuf<128> msg(_L("Delay present in message, value is = "));
       
  4649                     msg.AppendNum(delay);
       
  4650                     iTrace->Trace(msg, KTraceFileName, __LINE__); 
       
  4651                     isTimeoutDialogTimerStarted = ETrue;
       
  4652                     iDialogTimer->StartTimer(delay);
       
  4653                     }  	
       
  4654                 else
       
  4655                     {
       
  4656                     if (iSuplInitTimeOut > 0)
       
  4657                         {                                                        
       
  4658                         iTrace->Trace(_L("Delay not present in message"), KTraceFileName, __LINE__);
       
  4659                         TBuf<256> msg(_L("Delay value in CR is"));
       
  4660                         msg.AppendNum(iSuplInitTimeOut);
       
  4661                         iDialogTimer->StartTimer(iSuplInitTimeOut * KSecond);
       
  4662                         isTimeoutDialogTimerStarted = ETrue;
       
  4663                         }
       
  4664                     else
       
  4665                         iTrace->Trace(_L("Timeout is <= 0"), KTraceFileName, __LINE__);
       
  4666                     }
       
  4667                 }
       
  4668             }
       
  4669         else            
       
  4670             {                
       
  4671             if (iNwInitError)
       
  4672                 {
       
  4673                 iNwInitError = EFalse;                    
       
  4674                 HandleSuplInitErrorL(iNwInitCompletionCode);                             
       
  4675                 }                
       
  4676             else
       
  4677 	            InitializeL(iRequestID); 
       
  4678             }                
       
  4679         }                
       
  4680     }
       
  4681 
  4337 
  4682 TBool COMASuplSession::IsEtelNotifySet()
  4338 TBool COMASuplSession::IsEtelNotifySet()
  4683     {
  4339     {
  4684     iTrace->Trace(_L("COMASuplSession::IsEtelNotifySet"), KTraceFileName, __LINE__); 
  4340     iTrace->Trace(_L("COMASuplSession::IsEtelNotifySet"), KTraceFileName, __LINE__); 
  4685     return iEtelNotify;            
  4341     return iEtelNotify;            
  4695 {
  4351 {
  4696 	return iIhaveLaunchedUsagedialog; 
  4352 	return iIhaveLaunchedUsagedialog; 
  4697 }
  4353 }
  4698 
  4354 
  4699 
  4355 
  4700 // -----------------------------------------------------------------------------
       
  4701 // COMASuplSession::DialogTimerExpiredL
       
  4702 // Checks whether UI is displayed or not previously
       
  4703 // 
       
  4704 // -----------------------------------------------------------------------------
       
  4705 void COMASuplSession::DialogTimerExpiredL()
       
  4706 {
       
  4707    iTrace->Trace(_L("Timer Expired for SUPL Dialog"), KTraceFileName, __LINE__); 
       
  4708   
       
  4709     if (!iIapDialogShown)
       
  4710 	    iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
  4711     else
       
  4712         iIapDlgTimerExpired = ETrue;            
       
  4713 
       
  4714     return;	
       
  4715 }
       
  4716 
       
  4717 // -----------------------------------------------------------------------------
       
  4718 // COMASuplSession::SettingsTimeOutUICompletedL
       
  4719 // 
       
  4720 // -----------------------------------------------------------------------------
       
  4721 void COMASuplSession::SettingsTimeOutUICompletedL(TInt aError)
       
  4722 	{
       
  4723 	
       
  4724 	    TBuf<64> msg;	
       
  4725 	    msg.Copy(_L("SUPL Timeout UI completed with ... "));
       
  4726 	    msg.AppendNum(aError);
       
  4727 	    iTrace->Trace(msg,KTraceFileName, __LINE__); 
       
  4728 	    iSessionObserver.TerminateSession(this, KErrGeneral);	
       
  4729 	    return;
       
  4730 	    
       
  4731 	}
       
  4732 	
  4356 	
  4733 // -----------------------------------------------------------------------------
  4357 // -----------------------------------------------------------------------------
  4734 // COMASuplSession::StoreCurrentCellIDL
  4358 // COMASuplSession::StoreCurrentCellIDL
  4735 // Stores current cell id in CR
  4359 // Stores current cell id in CR
  4736 // 
  4360 //