supl/locationomasuplprotocolhandler/protocolhandlerver2/src/epos_comasuplconnrequestor.cpp
branchRCL_3
changeset 45 6b6920c56e2f
parent 44 2b4ea9893b66
child 49 10852b179f64
equal deleted inserted replaced
44:2b4ea9893b66 45:6b6920c56e2f
    45 											 MOMASuplConnObserver& aObserver):
    45 											 MOMASuplConnObserver& aObserver):
    46     				 						 CActive( EPriorityStandard ),
    46     				 						 CActive( EPriorityStandard ),
    47     				 						 iCommMgr(aCommMgr), 
    47     				 						 iCommMgr(aCommMgr), 
    48     				 						 iProtocolManager(aProtoMgr),
    48     				 						 iProtocolManager(aProtoMgr),
    49     				 						 iPort(aPort),
    49     				 						 iPort(aPort),
    50     				 						 iObserver( aObserver),
    50     				 						 iObserver( aObserver),    				 						  
    51     				 						 iTriggerSession(EFalse)
    51     				 						 iIapDialogShown(EFalse),
       
    52     				 						 iIapDlgTimerExpired(EFalse),    				 			            
       
    53     				 			             iIsTimeoutDialogTimerStarted(EFalse),
       
    54 											 iTriggerSession(EFalse)
    52     {
    55     {
    53 			
    56 			
    54     }
    57     }
    55 
    58 
    56 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    73     	
    76     	
    74     	iLastConnectionError = KErrNone;
    77     	iLastConnectionError = KErrNone;
    75     	
    78     	
    76     	iCurrentSLPId = KErrNotFound;
    79     	iCurrentSLPId = KErrNotFound;
    77     	
    80     	
    78     
    81     	iDialogTimer = COMASuplDialogTimer::NewL(*this);
    79     }
    82     }
    80 
    83 
    81 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    82 // COMASuplConnRequestor::NewL
    85 // COMASuplConnRequestor::NewL
    83 // Two-phased constructor.
    86 // Two-phased constructor.
   103 // -----------------------------------------------------------------------------
   106 // -----------------------------------------------------------------------------
   104 //
   107 //
   105 COMASuplConnRequestor::~COMASuplConnRequestor()
   108 COMASuplConnRequestor::~COMASuplConnRequestor()
   106     {
   109     {
   107     	Cancel();
   110     	Cancel();
   108     
   111     	if(iDialogTimer)
   109 	  	delete iSuplSettings;
   112     	    {
       
   113     	    iDialogTimer->Cancel();
       
   114     	    delete iDialogTimer;
       
   115     	    iDialogTimer = NULL;
       
   116     	    }
       
   117     	delete iSuplSettings;
   110     	delete iTrace;
   118     	delete iTrace;
   111     	delete iFallBackHandler;
   119     	delete iFallBackHandler;
   112     }
   120     }
   113 
   121 
   114 // -----------------------------------------------------------------------------
   122 // -----------------------------------------------------------------------------
   117 //    
   125 //    
   118 void COMASuplConnRequestor::CreateConnectionL(TBool aTriggerSession)
   126 void COMASuplConnRequestor::CreateConnectionL(TBool aTriggerSession)
   119 	{
   127 	{
   120 	if(!iIsSettingInitilized)
   128 	if(!iIsSettingInitilized)
   121         {
   129         {
   122         iTriggerSession = aTriggerSession;
   130 		iTriggerSession = aTriggerSession;
   123 				iState = EInitialState;
   131 		iState = EInitialState;
   124         InitilizeSetting();
   132         InitilizeSetting();
   125         }
   133         }
   126     else
   134     else
   127         {
   135         {
   128 		TBuf<100> iapName;
   136 		TBuf<100> iapName;
   145                 if(!ret)
   153                 if(!ret)
   146 					{
   154 					{
   147 						buffer.Copy(_L("No access point configured for "));
   155 						buffer.Copy(_L("No access point configured for "));
   148 						buffer.Append(iHostAddress);
   156 						buffer.Append(iHostAddress);
   149 						iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   157 						iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   150 						buffer.Copy(_L("Calling CreateConnection with no IAP"));
   158 						if( isIapDialogShown )
   151 						iTrace->Trace(buffer,KTraceFileName, __LINE__);
   159 						    {
   152 						iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,-1);
   160 						    TInt err = iProtocolManager.LaunchSettingsUI(this,iHostAddress);
   153 						OpenConnection();
   161 						    if(err != KErrNone)
       
   162                                 {
       
   163                                 buffer.Copy(_L("Error in launching UI : "));
       
   164                                 buffer.AppendNum(err);
       
   165                                 iTrace->Trace(buffer,KTraceFileName, __LINE__);                 
       
   166                                 iHostAddress.Zero();
       
   167                                 iObserver.OperationCompleteL(err);
       
   168                                 }
       
   169 						        else
       
   170 						        iIapDialogShown = ETrue;
       
   171 						    }
       
   172 						
   154 						
   173 						
   155 					}
   174 					}
   156 				else
   175 				else
   157 				    {
   176 				    {
       
   177 				    iIsTimeoutDialogTimerStarted = EFalse;
       
   178     			    iDialogTimer->Cancel();
   158 				    buffer.Copy(_L("Connecting to "));
   179 				    buffer.Copy(_L("Connecting to "));
   159 				    buffer.Append(iHostAddress);
   180 				    buffer.Append(iHostAddress);
   160 				    iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   181 				    iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   161 				    iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
   182 				    iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
   162 				    OpenConnection();
   183 				    OpenConnection();
   165 		else
   186 		else
   166 			{
   187 			{
   167 				iHostAddress.Zero();
   188 				iHostAddress.Zero();
   168 				iObserver.OperationCompleteL(errorCode);
   189 				iObserver.OperationCompleteL(errorCode);
   169 			}
   190 			}
   170 	}
   191 		}
   171     }
   192 	}
   172 
   193 
   173 // -----------------------------------------------------------------------------
   194 // -----------------------------------------------------------------------------
   174 // COMASuplConnRequestor::OpenConnection
   195 // COMASuplConnRequestor::OpenConnection
   175 // -----------------------------------------------------------------------------
   196 // -----------------------------------------------------------------------------
   176 //  TODO : Remove this method  
   197 //    
   177 void COMASuplConnRequestor::CreateConnectionL(TInt /*aDialogTimeOutDelay*/, TBool aTriggerSession)
   198 void COMASuplConnRequestor::CreateConnectionL(TInt aDialogTimeOutDelay, TBool aTriggerSession)
   178     {
   199     {
       
   200     iIsTimeoutDialogTimerStarted = ETrue;
       
   201     
       
   202     iDialogTimer->StartTimer(aDialogTimeOutDelay); 
   179     CreateConnectionL(aTriggerSession);
   203     CreateConnectionL(aTriggerSession);
   180     }
   204     }
   181 // -----------------------------------------------------------------------------
   205 // -----------------------------------------------------------------------------
   182 // COMASuplConnRequestor::OpenConnection
   206 // COMASuplConnRequestor::OpenConnection
   183 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   221 				iState = EConnecting;
   245 				iState = EConnecting;
   222 				iConnection->Connect(iStatus);
   246 				iConnection->Connect(iStatus);
   223 				SetActive();
   247 				SetActive();
   224 			}
   248 			}
   225 		}
   249 		}
   226 		else
   250 	else
   227 		{
   251 		{
   228 		iState = EInitilizeSetting;
   252 		iState = EInitilizeSetting;
   229 			InitilizeSetting();
   253 		InitilizeSetting();
   230 		}
   254 		}
   231 	}
   255 	}
   232     
   256     
   233 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   234 // COMASuplConnRequestor::ListenToMessages
   258 // COMASuplConnRequestor::ListenToMessages
   269 			buffer.AppendNum(iLastConnectionError);
   293 			buffer.AppendNum(iLastConnectionError);
   270 			iTrace->Trace(buffer,KTraceFileName, __LINE__); 					
   294 			iTrace->Trace(buffer,KTraceFileName, __LINE__); 					
   271     	
   295     	
   272     	switch(iState)
   296     	switch(iState)
   273     		{
   297     		{
       
   298 			
       
   299 			case EInitialState:
       
   300 	            {
       
   301 	            iIsSettingInitilized = ETrue;
       
   302 	            iTrace->Trace(_L("Setting API Initilizing Completed..."), KTraceFileName, __LINE__);
       
   303 	            CreateConnectionL(iTriggerSession);
       
   304 	            
       
   305 	            break;
       
   306 	            }
   274     		
   307     		
   275 		case EInitialState:
       
   276             {
       
   277             iIsSettingInitilized = ETrue;
       
   278             iTrace->Trace(_L("Setting API Initilizing Completed..."), KTraceFileName, __LINE__);
       
   279             CreateConnectionL(iTriggerSession);
       
   280             
       
   281             break;
       
   282             }
       
   283 			case  EConnecting:
   308 			case  EConnecting:
   284 				{
   309 				{
   285 					if(iLastConnectionError < 0)
   310 					if(iLastConnectionError < 0)
   286 					{
   311 					{
   287 						iHostAddress.Zero();
   312 						iHostAddress.Zero();
   379 // -----------------------------------------------------------------------------
   404 // -----------------------------------------------------------------------------
   380 //
   405 //
   381 void COMASuplConnRequestor::InitilizeSetting()
   406 void COMASuplConnRequestor::InitilizeSetting()
   382 	{
   407 	{
   383 			iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
   408 			iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
   384 			
       
   385 			iSuplSettings->Initialize(iStatus);
   409 			iSuplSettings->Initialize(iStatus);
   386 			SetActive();
   410 			SetActive();
   387 	}
   411 	}
   388 
   412 
   389 // -----------------------------------------------------------------------------
   413 // -----------------------------------------------------------------------------
   450 	   	}
   474 	   	}
   451 		CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   475 		CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   452 		return result;
   476 		return result;
   453 	}
   477 	}
   454 	
   478 	
   455 
   479 // -----------------------------------------------------------------------------
       
   480 // COMASuplConnRequestor::SettingsUICompleted
       
   481 // 
       
   482 // -----------------------------------------------------------------------------
       
   483 
       
   484 void COMASuplConnRequestor::SettingsUICompletedL(TInt aError)
       
   485 	{
       
   486 		TBuf<128> buffer(_L("COMASuplConnRequestor:SettingsUICompleted Error: "));
       
   487 		buffer.AppendNum(aError);
       
   488 		iTrace->Trace(buffer,KTraceFileName, __LINE__); 
       
   489 		
       
   490 		if (iIsTimeoutDialogTimerStarted)
       
   491 		    {                
       
   492 		    iTrace->Trace(_L("COMASuplSession::SettingsUICompleted, stopping timer "), KTraceFileName, __LINE__);
       
   493 		    iIsTimeoutDialogTimerStarted = EFalse;                    
       
   494 		    iDialogTimer->StopTimer();
       
   495 		    }
       
   496 		if (iIapDlgTimerExpired)
       
   497 		    {
       
   498 		    iIapDlgTimerExpired = EFalse;
       
   499 		    iIapDialogShown = EFalse;
       
   500 		    iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
   501 		    iObserver.OperationCompleteL(KErrNone);
       
   502 		    return;
       
   503 		    }
       
   504 		if(aError == KErrNone)
       
   505 			{
       
   506 				TBuf<100> IapName;
       
   507 				TInt err = iProtocolManager.GetLastUsedAccessPoint(IapName,iIAPId);
       
   508 				 if(err == KErrNone)
       
   509 					{
       
   510 						buffer.Copy(_L("Connecting to "));
       
   511 						buffer.Append(iHostAddress);
       
   512 						buffer.Append(_L(" using IAP "));
       
   513 						buffer.Append(IapName);
       
   514 						iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
       
   515 						iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
       
   516 						SaveAccessPoint(IapName);
       
   517 						OpenConnection();
       
   518 					}
       
   519 				 else
       
   520 				 	{
       
   521 				 		iObserver.OperationCompleteL(err);	
       
   522 				 	}	
       
   523 			}
       
   524 		else
       
   525 			{
       
   526 				iObserver.OperationCompleteL(aError);	
       
   527 			}	
       
   528 		
       
   529 	}
   456 
   530 
   457 // -----------------------------------------------------------------------------
   531 // -----------------------------------------------------------------------------
   458 // COMASuplConnRequestor::SaveAccessPoint
   532 // COMASuplConnRequestor::SaveAccessPoint
   459 // 
   533 // 
   460 // -----------------------------------------------------------------------------
   534 // -----------------------------------------------------------------------------
   518 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   592 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   519 {
   593 {
   520 			iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   594 			iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   521 }
   595 }
   522 
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 // COMASuplConnRequestor::DialogTimerExpiredL
       
   599 // Checks whether UI is displayed or not previously
       
   600 // 
       
   601 // -----------------------------------------------------------------------------
       
   602 void COMASuplConnRequestor::DialogTimerExpiredL()
       
   603 {
       
   604    iTrace->Trace(_L("COMASuplConnRequestor:Timer Expired for SUPL IAP Dialog"), KTraceFileName, __LINE__); 
       
   605 
       
   606     if (!iIapDialogShown)
       
   607         iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
   608     else
       
   609         iIapDlgTimerExpired = ETrue;  
       
   610     return; 
       
   611 }
   523 
   612 
   524 TUint COMASuplConnRequestor::GetPortNumber()
   613 TUint COMASuplConnRequestor::GetPortNumber()
   525 	{
   614 	{
   526 		if(iConnection)
   615 	return iConnection->GetPortNumberUsed();
   527 			return iConnection->GetPortNumberUsed();
       
   528 		else 
       
   529 			return 0;
       
   530 	}
   616 	}
   531 	
   617 	
   532 	
   618 	
   533 //  End of File
   619 //  End of File