supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplconnrequestor.cpp
branchRCL_3
changeset 49 10852b179f64
parent 45 6b6920c56e2f
child 55 ea98413ce11f
equal deleted inserted replaced
47:fce0ae2e4223 49:10852b179f64
    48         MOMASuplConnObserver& aObserver):
    48         MOMASuplConnObserver& aObserver):
    49         CActive( EPriorityStandard ),
    49         CActive( EPriorityStandard ),
    50         iCommMgr(aCommMgr), 
    50         iCommMgr(aCommMgr), 
    51         iProtocolManager(aProtoMgr),
    51         iProtocolManager(aProtoMgr),
    52         iPort(aPort),
    52         iPort(aPort),
    53         iObserver( aObserver),    				 						  
    53         iObserver( aObserver),iPrompt(EFalse),iWlanOnly(EFalse),iIsStaleLocIdPresent(EFalse)
    54         iIapDialogShown(EFalse),
       
    55         iIapDlgTimerExpired(EFalse),    				 			            
       
    56         iIsTimeoutDialogTimerStarted(EFalse),iPrompt(EFalse),iWlanOnly(EFalse),iIsStaleLocIdPresent(EFalse)
       
    57         {
    54         {
    58 
    55 
    59         }
    56         }
    60 
    57 
    61 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    78     iRepository = CRepository::NewL(KCRUidSuplSettings);
    75     iRepository = CRepository::NewL(KCRUidSuplSettings);
    79     iLastConnectionError = KErrNone;
    76     iLastConnectionError = KErrNone;
    80 
    77 
    81     iCurrentSLPId = KErrNotFound;
    78     iCurrentSLPId = KErrNotFound;
    82 
    79 
    83     iDialogTimer = COMASuplDialogTimer::NewL(*this);
       
    84     }
    80     }
    85 
    81 
    86 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    87 // COMASuplConnRequestor::NewL
    83 // COMASuplConnRequestor::NewL
    88 // Two-phased constructor.
    84 // Two-phased constructor.
   108 // -----------------------------------------------------------------------------
   104 // -----------------------------------------------------------------------------
   109 //
   105 //
   110 COMASuplConnRequestor::~COMASuplConnRequestor()
   106 COMASuplConnRequestor::~COMASuplConnRequestor()
   111     {
   107     {
   112     Cancel();
   108     Cancel();
   113     if(iDialogTimer)
   109   
   114         {
       
   115         iDialogTimer->Cancel();
       
   116         delete iDialogTimer;
       
   117         iDialogTimer = NULL;
       
   118         }
       
   119     delete iSuplSettings;
   110     delete iSuplSettings;
   120     delete iTrace;
   111     delete iTrace;
   121     delete iFallBackHandler;
   112     delete iFallBackHandler;
   122     delete iRepository;
   113     delete iRepository;
   123         iRepository = NULL;
   114         iRepository = NULL;
   142 		TBool isIapDialogShown = EFalse;
   133 		TBool isIapDialogShown = EFalse;
   143 		TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown);
   134 		TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown);
   144 		
   135 		
   145 		if(errorCode == KErrNone)
   136 		if(errorCode == KErrNone)
   146 			{
   137 			{
   147 			TBool ret = ConvertIAPNameToIdL(iapName,iIAPId);
   138 				TBool ret = ConvertIAPNameToIdL(iapName,iIAPId);
   148 			if(!ret)
   139 				if(!ret)
   149 				{
   140 					{
   150 					buffer.Copy(_L("No access point configured for "));
   141 						buffer.Copy(_L("No access point configured for "));
   151 					buffer.Append(iHostAddress);
   142 						buffer.Append(iHostAddress);
   152 					iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   143 						iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   153 					if( isIapDialogShown )
   144 						buffer.Copy(_L("Calling CreateConnection with no IAP"));
   154 						{
   145 						iTrace->Trace(buffer,KTraceFileName, __LINE__);
   155 						TInt err = iProtocolManager.LaunchSettingsUI(this,iHostAddress);
   146 						iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,-1);
   156 						if(err != KErrNone)
   147 						OpenConnection();
   157 							{
   148 						
   158 							buffer.Copy(_L("Error in launching UI : "));
   149 					}
   159 							buffer.AppendNum(err);
   150         else
   160 							iTrace->Trace(buffer,KTraceFileName, __LINE__);                 
   151             {
   161 							iHostAddress.Zero();
   152             buffer.Copy(_L("Connecting to "));
   162 							iObserver.OperationCompleteL(err);
   153             buffer.Append(iHostAddress);
   163 							}
   154             iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   164 							else
   155             iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
   165 							iIapDialogShown = ETrue;
   156             OpenConnection();
   166 						}
   157             }	
   167 					
   158         }
   168 					
   159     else
   169 				}
   160         {
   170 			else
   161         iHostAddress.Zero();
   171 	            {
   162         iObserver.OperationCompleteL(errorCode);
   172 	            iIsTimeoutDialogTimerStarted = EFalse;
   163         }
   173 	            iDialogTimer->Cancel();
       
   174 	            buffer.Copy(_L("Connecting to "));
       
   175 	            buffer.Append(iHostAddress);
       
   176 	            iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
       
   177 	            iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
       
   178 	            OpenConnection();
       
   179 	            }	
       
   180 			}
       
   181 	    else
       
   182 	        {
       
   183 	        iHostAddress.Zero();
       
   184 	        iObserver.OperationCompleteL(errorCode);
       
   185 	        }
       
   186 		}
   164 		}
   187     }
   165     }
   188 
   166     
       
   167  
   189  // -----------------------------------------------------------------------------
   168  // -----------------------------------------------------------------------------
   190 // COMASuplConnRequestor::CreateConnection for OCC
   169 // COMASuplConnRequestor::CreateConnection for OCC
   191 // -----------------------------------------------------------------------------
   170 // -----------------------------------------------------------------------------
   192 //    
   171 //    
   193 void COMASuplConnRequestor::CreateConnectionL(TBool aPrompt,TBool aWlanOnly)
   172 void COMASuplConnRequestor::CreateConnectionL(TBool aPrompt,TBool aWlanOnly)
   197         iState = EConnecting;  
   176         iState = EConnecting;  
   198        
   177        
   199         iPrompt = aPrompt;
   178         iPrompt = aPrompt;
   200         iWlanOnly = aWlanOnly;
   179         iWlanOnly = aWlanOnly;
   201         iIsStaleLocIdPresent = ETrue;
   180         iIsStaleLocIdPresent = ETrue;
   202         iIsTimeoutDialogTimerStarted = EFalse;
   181                
   203         iDialogTimer->Cancel();
       
   204         
       
   205         TInt err;
   182         TInt err;
   206         err = iRepository->Get(KSuplGeoInfoConvServerName, GeoTagServerName);
   183         err = iRepository->Get(KSuplGeoInfoConvServerName, GeoTagServerName);
   207         User::LeaveIfError(err);
   184         User::LeaveIfError(err);
   208         buffer.Copy(_L("Connecting to"));
   185         buffer.Copy(_L("Connecting to"));
   209         buffer.Append(GeoTagServerName);
   186         buffer.Append(GeoTagServerName);
   220     }
   197     }
   221 
   198 
   222 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   223 // COMASuplConnRequestor::OpenConnection
   200 // COMASuplConnRequestor::OpenConnection
   224 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   225 //    
   202  
   226 void COMASuplConnRequestor::CreateConnectionL(TInt aDialogTimeOutDelay)
   203 void COMASuplConnRequestor::CreateConnectionL(TInt /*aDialogTimeOutDelay*/)
   227     {
   204     {
   228     iIsTimeoutDialogTimerStarted = ETrue;
       
   229 
       
   230     iDialogTimer->StartTimer(aDialogTimeOutDelay); 
       
   231     CreateConnectionL();
   205     CreateConnectionL();
   232     }
   206     }
   233 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   234 // COMASuplConnRequestor::OpenConnection
   208 // COMASuplConnRequestor::OpenConnection
   235 // -----------------------------------------------------------------------------
   209 // -----------------------------------------------------------------------------
   266 void COMASuplConnRequestor::OpenConnection()
   240 void COMASuplConnRequestor::OpenConnection()
   267     {
   241     {
   268 
   242 
   269     if(iIsSettingInitilized)
   243     if(iIsSettingInitilized)
   270         {
   244         {
   271         
   245         if(iConnection)
   272            if(iConnection)
       
   273             {
   246             {
   274             iState = EConnecting;
   247             iState = EConnecting;
   275             if(iIsStaleLocIdPresent)
   248             if(iIsStaleLocIdPresent)
   276                 {
   249                 {
   277                 iTrace->Trace(_L("OpenConnection OCC"),KTraceFileName, __LINE__);
   250                 iTrace->Trace(_L("OpenConnection OCC"),KTraceFileName, __LINE__);
   454 // -----------------------------------------------------------------------------
   427 // -----------------------------------------------------------------------------
   455 //
   428 //
   456 void COMASuplConnRequestor::InitilizeSetting()
   429 void COMASuplConnRequestor::InitilizeSetting()
   457     {
   430     {
   458     iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
   431     iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
       
   432     
   459     iSuplSettings->Initialize(iStatus);
   433     iSuplSettings->Initialize(iStatus);
   460     SetActive();
   434     SetActive();
   461     }
   435     }
   462 
   436 
   463 // -----------------------------------------------------------------------------
   437 // -----------------------------------------------------------------------------
   478     return iHslpAddrFromImsiUsed;
   452     return iHslpAddrFromImsiUsed;
   479     }	
   453     }	
   480 
   454 
   481 TUint COMASuplConnRequestor::GetPortNumber()
   455 TUint COMASuplConnRequestor::GetPortNumber()
   482 	{
   456 	{
   483 	return iConnection->GetPortNumberUsed();
   457 	if(iConnection)
       
   458 		return iConnection->GetPortNumberUsed();
       
   459 	else 
       
   460 		return 0;
   484 	}
   461 	}
   485 	
   462 	
   486 // -----------------------------------------------------------------------------
   463 // -----------------------------------------------------------------------------
   487 // COMASuplConnRequestor::SetDefaultParametersL
   464 // COMASuplConnRequestor::SetDefaultParametersL
   488 // -----------------------------------------------------------------------------
   465 // -----------------------------------------------------------------------------
   528         }
   505         }
   529     CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   506     CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   530     return result;
   507     return result;
   531     }
   508     }
   532 
   509 
   533 // -----------------------------------------------------------------------------
   510 
   534 // COMASuplConnRequestor::SettingsUICompleted
       
   535 // 
       
   536 // -----------------------------------------------------------------------------
       
   537 
       
   538 void COMASuplConnRequestor::SettingsUICompletedL(TInt aError)
       
   539     {
       
   540 		TBuf<128> buffer(_L("COMASuplConnRequestor:SettingsUICompleted Error: "));
       
   541     buffer.AppendNum(aError);
       
   542     iTrace->Trace(buffer,KTraceFileName, __LINE__); 
       
   543 
       
   544     if (iIsTimeoutDialogTimerStarted)
       
   545         {                
       
   546         iTrace->Trace(_L("COMASuplSession::SettingsUICompleted, stopping timer "), KTraceFileName, __LINE__);
       
   547         iIsTimeoutDialogTimerStarted = EFalse;                    
       
   548         iDialogTimer->StopTimer();
       
   549         }
       
   550     if (iIapDlgTimerExpired)
       
   551         {
       
   552         iIapDlgTimerExpired = EFalse;
       
   553         iIapDialogShown = EFalse;
       
   554         iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
   555         iObserver.OperationCompleteL(KErrNone);
       
   556         return;
       
   557         }
       
   558     if(aError == KErrNone)
       
   559         {
       
   560         TBuf<100> IapName;
       
   561         TInt err = iProtocolManager.GetLastUsedAccessPoint(IapName,iIAPId);
       
   562         if(err == KErrNone)
       
   563             {
       
   564             buffer.Copy(_L("Connecting to "));
       
   565             buffer.Append(iHostAddress);
       
   566             buffer.Append(_L(" using IAP "));
       
   567             buffer.Append(IapName);
       
   568             iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
       
   569             iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
       
   570             SaveAccessPoint(IapName);
       
   571             OpenConnection();
       
   572             }
       
   573         else
       
   574             {
       
   575             iObserver.OperationCompleteL(err);	
       
   576             }	
       
   577         }
       
   578     else
       
   579         {
       
   580         iObserver.OperationCompleteL(aError);	
       
   581         }	
       
   582 
       
   583     }
       
   584 
   511 
   585 // -----------------------------------------------------------------------------
   512 // -----------------------------------------------------------------------------
   586 // COMASuplConnRequestor::SaveAccessPoint
   513 // COMASuplConnRequestor::SaveAccessPoint
   587 // 
   514 // 
   588 // -----------------------------------------------------------------------------
   515 // -----------------------------------------------------------------------------
   644 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   571 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   645     {
   572     {
   646     iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   573     iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   647     }
   574     }
   648 
   575 
   649 // -----------------------------------------------------------------------------
   576 
   650 // COMASuplConnRequestor::DialogTimerExpiredL
       
   651 // Checks whether UI is displayed or not previously
       
   652 // 
       
   653 // -----------------------------------------------------------------------------
       
   654 void COMASuplConnRequestor::DialogTimerExpiredL()
       
   655     {
       
   656     iTrace->Trace(_L("COMASuplConnRequestor:Timer Expired for SUPL IAP Dialog"), KTraceFileName, __LINE__); 
       
   657 
       
   658     if (!iIapDialogShown)
       
   659         iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
   660     else
       
   661         iIapDlgTimerExpired = ETrue;  
       
   662     return; 
       
   663     }
       
   664 //  End of File
   577 //  End of File