supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplconnrequestor.cpp
branchRCL_3
changeset 21 6b6920c56e2f
parent 20 2b4ea9893b66
equal deleted inserted replaced
20:2b4ea9893b66 21:6b6920c56e2f
    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),iPrompt(EFalse),iWlanOnly(EFalse),iIsStaleLocIdPresent(EFalse)
    53         iObserver( aObserver),    				 						  
       
    54         iIapDialogShown(EFalse),
       
    55         iIapDlgTimerExpired(EFalse),    				 			            
       
    56         iIsTimeoutDialogTimerStarted(EFalse),iPrompt(EFalse),iWlanOnly(EFalse),iIsStaleLocIdPresent(EFalse)
    54         {
    57         {
    55 
    58 
    56         }
    59         }
    57 
    60 
    58 // -----------------------------------------------------------------------------
    61 // -----------------------------------------------------------------------------
    75     iRepository = CRepository::NewL(KCRUidSuplSettings);
    78     iRepository = CRepository::NewL(KCRUidSuplSettings);
    76     iLastConnectionError = KErrNone;
    79     iLastConnectionError = KErrNone;
    77 
    80 
    78     iCurrentSLPId = KErrNotFound;
    81     iCurrentSLPId = KErrNotFound;
    79 
    82 
       
    83     iDialogTimer = COMASuplDialogTimer::NewL(*this);
    80     }
    84     }
    81 
    85 
    82 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
    83 // COMASuplConnRequestor::NewL
    87 // COMASuplConnRequestor::NewL
    84 // Two-phased constructor.
    88 // Two-phased constructor.
   104 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
   105 //
   109 //
   106 COMASuplConnRequestor::~COMASuplConnRequestor()
   110 COMASuplConnRequestor::~COMASuplConnRequestor()
   107     {
   111     {
   108     Cancel();
   112     Cancel();
   109   
   113     if(iDialogTimer)
       
   114         {
       
   115         iDialogTimer->Cancel();
       
   116         delete iDialogTimer;
       
   117         iDialogTimer = NULL;
       
   118         }
   110     delete iSuplSettings;
   119     delete iSuplSettings;
   111     delete iTrace;
   120     delete iTrace;
   112     delete iFallBackHandler;
   121     delete iFallBackHandler;
   113     delete iRepository;
   122     delete iRepository;
   114         iRepository = NULL;
   123         iRepository = NULL;
   127         }
   136         }
   128     else
   137     else
   129         {
   138         {
   130 		TBuf<100> iapName;
   139 		TBuf<100> iapName;
   131 		TBuf<128> buffer;
   140 		TBuf<128> buffer;
   132     iState = EConnecting;  
   141 		iState = EConnecting;  
   133 		TBool isIapDialogShown = EFalse;
   142 		TBool isIapDialogShown = EFalse;
   134 		TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown);
   143 		TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown);
   135 		
   144 		
   136 		if(errorCode == KErrNone)
   145 		if(errorCode == KErrNone)
   137 			{
   146 			{
   138 				TBool ret = ConvertIAPNameToIdL(iapName,iIAPId);
   147 			TBool ret = ConvertIAPNameToIdL(iapName,iIAPId);
   139 				if(!ret)
   148 			if(!ret)
   140 					{
   149 				{
   141 						buffer.Copy(_L("No access point configured for "));
   150 					buffer.Copy(_L("No access point configured for "));
   142 						buffer.Append(iHostAddress);
   151 					buffer.Append(iHostAddress);
   143 						iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   152 					iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   144 						buffer.Copy(_L("Calling CreateConnection with no IAP"));
   153 					if( isIapDialogShown )
   145 						iTrace->Trace(buffer,KTraceFileName, __LINE__);
   154 						{
   146 						iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,-1);
   155 						TInt err = iProtocolManager.LaunchSettingsUI(this,iHostAddress);
   147 						OpenConnection();
   156 						if(err != KErrNone)
   148 						
   157 							{
   149 					}
   158 							buffer.Copy(_L("Error in launching UI : "));
   150         else
   159 							buffer.AppendNum(err);
   151             {
   160 							iTrace->Trace(buffer,KTraceFileName, __LINE__);                 
   152             buffer.Copy(_L("Connecting to "));
   161 							iHostAddress.Zero();
   153             buffer.Append(iHostAddress);
   162 							iObserver.OperationCompleteL(err);
   154             iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   163 							}
   155             iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
   164 							else
   156             OpenConnection();
   165 							iIapDialogShown = ETrue;
   157             }	
   166 						}
   158         }
   167 					
   159     else
   168 					
   160         {
   169 				}
   161         iHostAddress.Zero();
   170 			else
   162         iObserver.OperationCompleteL(errorCode);
   171 	            {
   163         }
   172 	            iIsTimeoutDialogTimerStarted = EFalse;
       
   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 	        }
   164 		}
   186 		}
   165     }
   187     }
   166     
   188 
   167  
       
   168  // -----------------------------------------------------------------------------
   189  // -----------------------------------------------------------------------------
   169 // COMASuplConnRequestor::CreateConnection for OCC
   190 // COMASuplConnRequestor::CreateConnection for OCC
   170 // -----------------------------------------------------------------------------
   191 // -----------------------------------------------------------------------------
   171 //    
   192 //    
   172 void COMASuplConnRequestor::CreateConnectionL(TBool aPrompt,TBool aWlanOnly)
   193 void COMASuplConnRequestor::CreateConnectionL(TBool aPrompt,TBool aWlanOnly)
   176         iState = EConnecting;  
   197         iState = EConnecting;  
   177        
   198        
   178         iPrompt = aPrompt;
   199         iPrompt = aPrompt;
   179         iWlanOnly = aWlanOnly;
   200         iWlanOnly = aWlanOnly;
   180         iIsStaleLocIdPresent = ETrue;
   201         iIsStaleLocIdPresent = ETrue;
   181                
   202         iIsTimeoutDialogTimerStarted = EFalse;
       
   203         iDialogTimer->Cancel();
       
   204         
   182         TInt err;
   205         TInt err;
   183         err = iRepository->Get(KSuplGeoInfoConvServerName, GeoTagServerName);
   206         err = iRepository->Get(KSuplGeoInfoConvServerName, GeoTagServerName);
   184         User::LeaveIfError(err);
   207         User::LeaveIfError(err);
   185         buffer.Copy(_L("Connecting to"));
   208         buffer.Copy(_L("Connecting to"));
   186         buffer.Append(GeoTagServerName);
   209         buffer.Append(GeoTagServerName);
   197     }
   220     }
   198 
   221 
   199 // -----------------------------------------------------------------------------
   222 // -----------------------------------------------------------------------------
   200 // COMASuplConnRequestor::OpenConnection
   223 // COMASuplConnRequestor::OpenConnection
   201 // -----------------------------------------------------------------------------
   224 // -----------------------------------------------------------------------------
   202 //  TODO : Remove this method  
   225 //    
   203 void COMASuplConnRequestor::CreateConnectionL(TInt /*aDialogTimeOutDelay*/)
   226 void COMASuplConnRequestor::CreateConnectionL(TInt aDialogTimeOutDelay)
   204     {
   227     {
       
   228     iIsTimeoutDialogTimerStarted = ETrue;
       
   229 
       
   230     iDialogTimer->StartTimer(aDialogTimeOutDelay); 
   205     CreateConnectionL();
   231     CreateConnectionL();
   206     }
   232     }
   207 // -----------------------------------------------------------------------------
   233 // -----------------------------------------------------------------------------
   208 // COMASuplConnRequestor::OpenConnection
   234 // COMASuplConnRequestor::OpenConnection
   209 // -----------------------------------------------------------------------------
   235 // -----------------------------------------------------------------------------
   240 void COMASuplConnRequestor::OpenConnection()
   266 void COMASuplConnRequestor::OpenConnection()
   241     {
   267     {
   242 
   268 
   243     if(iIsSettingInitilized)
   269     if(iIsSettingInitilized)
   244         {
   270         {
   245         if(iConnection)
   271         
       
   272            if(iConnection)
   246             {
   273             {
   247             iState = EConnecting;
   274             iState = EConnecting;
   248             if(iIsStaleLocIdPresent)
   275             if(iIsStaleLocIdPresent)
   249                 {
   276                 {
   250                 iTrace->Trace(_L("OpenConnection OCC"),KTraceFileName, __LINE__);
   277                 iTrace->Trace(_L("OpenConnection OCC"),KTraceFileName, __LINE__);
   427 // -----------------------------------------------------------------------------
   454 // -----------------------------------------------------------------------------
   428 //
   455 //
   429 void COMASuplConnRequestor::InitilizeSetting()
   456 void COMASuplConnRequestor::InitilizeSetting()
   430     {
   457     {
   431     iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
   458     iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
   432     
       
   433     iSuplSettings->Initialize(iStatus);
   459     iSuplSettings->Initialize(iStatus);
   434     SetActive();
   460     SetActive();
   435     }
   461     }
   436 
   462 
   437 // -----------------------------------------------------------------------------
   463 // -----------------------------------------------------------------------------
   452     return iHslpAddrFromImsiUsed;
   478     return iHslpAddrFromImsiUsed;
   453     }	
   479     }	
   454 
   480 
   455 TUint COMASuplConnRequestor::GetPortNumber()
   481 TUint COMASuplConnRequestor::GetPortNumber()
   456 	{
   482 	{
   457 	if(iConnection)
   483 	return iConnection->GetPortNumberUsed();
   458 		return iConnection->GetPortNumberUsed();
       
   459 	else 
       
   460 		return 0;
       
   461 	}
   484 	}
   462 	
   485 	
   463 // -----------------------------------------------------------------------------
   486 // -----------------------------------------------------------------------------
   464 // COMASuplConnRequestor::SetDefaultParametersL
   487 // COMASuplConnRequestor::SetDefaultParametersL
   465 // -----------------------------------------------------------------------------
   488 // -----------------------------------------------------------------------------
   505         }
   528         }
   506     CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   529     CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   507     return result;
   530     return result;
   508     }
   531     }
   509 
   532 
   510 
   533 // -----------------------------------------------------------------------------
       
   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     }
   511 
   584 
   512 // -----------------------------------------------------------------------------
   585 // -----------------------------------------------------------------------------
   513 // COMASuplConnRequestor::SaveAccessPoint
   586 // COMASuplConnRequestor::SaveAccessPoint
   514 // 
   587 // 
   515 // -----------------------------------------------------------------------------
   588 // -----------------------------------------------------------------------------
   571 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   644 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   572     {
   645     {
   573     iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   646     iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   574     }
   647     }
   575 
   648 
   576 
   649 // -----------------------------------------------------------------------------
       
   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     }
   577 //  End of File
   664 //  End of File