supl/locationomasuplprotocolhandler/protocolhandlerver1/src/epos_comasuplconnrequestor.cpp
branchRCL_3
changeset 55 ea98413ce11f
parent 49 10852b179f64
equal deleted inserted replaced
49:10852b179f64 55:ea98413ce11f
    14  * Description:   Class for doing asynchronous service.
    14  * Description:   Class for doing asynchronous service.
    15  *
    15  *
    16  */
    16  */
    17 
    17 
    18 
    18 
    19 #include <centralrepository.h>
       
    20 
    19 
    21 #include "epos_comasuplprotocolmanager1.h"
    20 #include "epos_comasuplprotocolmanager1.h"
    22 #include "epos_csuplcommunicationmanager.h"
    21 #include "epos_csuplcommunicationmanager.h"
    23 #include "epos_csuplsettingsinternal.h"
    22 #include "epos_csuplsettingsinternal.h"
    24 
    23 #include "epos_csuplsettingparams.h"
    25 #include "epos_omasuplconstants.h"
    24 #include "epos_omasuplconstants.h"
    26 #include "epos_comasuplconnrequestor.h"
    25 #include "epos_comasuplconnrequestor.h"
    27 #include "epos_momasuplconnobserver.h"
    26 #include "epos_momasuplconnobserver.h"
    28 #include "epos_comasupltrace.h"
    27 #include "epos_comasupltrace.h"
    29 #include "epos_comasuplfallbackhandler.h"
    28 #include "epos_comasuplfallbackhandler.h"
    30 #include "epos_csuplsettingsinternalcrkeys.h"
       
    31 
       
    32 
    29 
    33 #include "epos_comasupldialogtimer.h"
    30 #include "epos_comasupldialogtimer.h"
    34 _LIT(KTraceFileName,"SUPL_OMA_SESSION::epos_comasuplconnrequestor.cpp");
    31 _LIT(KTraceFileName,"SUPL_OMA_SESSION::epos_comasuplconnrequestor.cpp");
    35 
    32 
       
    33 const TInt KStringLength = 100;
    36 
    34 
    37 
    35 
    38 // ============================ MEMBER FUNCTIONS ===============================
    36 // ============================ MEMBER FUNCTIONS ===============================
    39 
    37 
    40 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    41 // COMASuplConnRequestor::COMASuplConnRequestor
    39 // COMASuplConnRequestor::COMASuplConnRequestor
    42 // C++ constructor can NOT contain any code, that might leave.
    40 // C++ constructor can NOT contain any code, that might leave.
    43 // -----------------------------------------------------------------------------
    41 // -----------------------------------------------------------------------------
    44 //
    42 //
    45 COMASuplConnRequestor::COMASuplConnRequestor(CSuplCommunicationManager& aCommMgr,
    43 COMASuplConnRequestor::COMASuplConnRequestor(
    46         COMASUPLProtocolManager1& aProtoMgr, 
    44         CSuplCommunicationManager& aCommMgr,
    47         TUint aPort, 
    45         COMASUPLProtocolManager1& aProtoMgr, TUint aPort,
    48         MOMASuplConnObserver& aObserver):
    46         MOMASuplConnObserver& aObserver) :
    49         CActive( EPriorityStandard ),
    47     CActive(EPriorityStandard), iCommMgr(aCommMgr), iProtocolManager(
    50         iCommMgr(aCommMgr), 
    48             aProtoMgr),iConnection(NULL), iPort(aPort), iObserver(aObserver), iIapDialogShown(
    51         iProtocolManager(aProtoMgr),
    49             EFalse), iIapDlgTimerExpired(EFalse),
    52         iPort(aPort),
    50             iIsTimeoutDialogTimerStarted(EFalse)
    53         iObserver( aObserver),iPrompt(EFalse),iWlanOnly(EFalse),iIsStaleLocIdPresent(EFalse)
    51     {
    54         {
    52 
    55 
    53     }
    56         }
       
    57 
    54 
    58 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    59 // COMASuplConnRequestor::ConstructL
    56 // COMASuplConnRequestor::ConstructL
    60 // Symbian 2nd phase constructor can leave.
    57 // Symbian 2nd phase constructor can leave.
    61 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    70     iTrace = COMASuplTrace::NewL();
    67     iTrace = COMASuplTrace::NewL();
    71     iIsHSLPGenerated = EFalse;
    68     iIsHSLPGenerated = EFalse;
    72     iHslpAddrFromImsiUsed = EFalse;
    69     iHslpAddrFromImsiUsed = EFalse;
    73 
    70 
    74     iFallBackHandler = COMASuplFallBackHandler::NewL(*iSuplSettings);
    71     iFallBackHandler = COMASuplFallBackHandler::NewL(*iSuplSettings);
    75     iRepository = CRepository::NewL(KCRUidSuplSettings);
    72 
    76     iLastConnectionError = KErrNone;
    73     iLastConnectionError = KErrNone;
    77 
    74 
    78     iCurrentSLPId = KErrNotFound;
    75     iCurrentSLPId = KErrNotFound;
    79 
    76 
       
    77     iDialogTimer = COMASuplDialogTimer::NewL(*this);
    80     }
    78     }
    81 
    79 
    82 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    83 // COMASuplConnRequestor::NewL
    81 // COMASuplConnRequestor::NewL
    84 // Two-phased constructor.
    82 // Two-phased constructor.
   104 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   105 //
   103 //
   106 COMASuplConnRequestor::~COMASuplConnRequestor()
   104 COMASuplConnRequestor::~COMASuplConnRequestor()
   107     {
   105     {
   108     Cancel();
   106     Cancel();
   109   
   107     if(iDialogTimer)
       
   108         {
       
   109         iDialogTimer->Cancel();
       
   110         delete iDialogTimer;
       
   111         iDialogTimer = NULL;
       
   112         }
   110     delete iSuplSettings;
   113     delete iSuplSettings;
   111     delete iTrace;
   114     delete iTrace;
   112     delete iFallBackHandler;
   115     delete iFallBackHandler;
   113     delete iRepository;
       
   114         iRepository = NULL;
       
   115     }
   116     }
   116 
   117 
   117 // -----------------------------------------------------------------------------
   118 // -----------------------------------------------------------------------------
   118 // COMASuplConnRequestor::OpenConnection
   119 // COMASuplConnRequestor::OpenConnection
   119 // -----------------------------------------------------------------------------
   120 // -----------------------------------------------------------------------------
   133 		TBool isIapDialogShown = EFalse;
   134 		TBool isIapDialogShown = EFalse;
   134 		TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown);
   135 		TInt errorCode = iFallBackHandler->GetNextSLPAddressL(iCurrentSLPId,iHostAddress,iapName,iTls,iPskTls,iLastConnectionError,isIapDialogShown);
   135 		
   136 		
   136 		if(errorCode == KErrNone)
   137 		if(errorCode == KErrNone)
   137 			{
   138 			{
   138 				TBool ret = ConvertIAPNameToIdL(iapName,iIAPId);
   139 			TBool ret = ConvertIAPNameToIdL(iapName,iIAPId);
   139 				if(!ret)
   140 			if(!ret)
   140 					{
   141 				{
   141 						buffer.Copy(_L("No access point configured for "));
   142 					buffer.Copy(_L("No access point configured for "));
   142 						buffer.Append(iHostAddress);
   143 					buffer.Append(iHostAddress);
   143 						iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   144 					iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   144 						buffer.Copy(_L("Calling CreateConnection with no IAP"));
   145 					if( isIapDialogShown )
   145 						iTrace->Trace(buffer,KTraceFileName, __LINE__);
   146 						{
   146 						iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,-1);
   147 						TInt err = iProtocolManager.LaunchSettingsUI(this,iHostAddress);
   147 						OpenConnection();
   148 						if(err != KErrNone)
   148 						
   149 							{
   149 					}
   150 							buffer.Copy(_L("Error in launching UI : "));
   150         else
   151 							buffer.AppendNum(err);
   151             {
   152 							iTrace->Trace(buffer,KTraceFileName, __LINE__);                 
   152             buffer.Copy(_L("Connecting to "));
   153 							iHostAddress.Zero();
   153             buffer.Append(iHostAddress);
   154 							iObserver.OperationCompleteL(err);
   154             iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
   155 							}
   155             iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
   156 							else
   156             OpenConnection();
   157 							iIapDialogShown = ETrue;
   157             }	
   158 						}
   158         }
   159 					
   159     else
   160 					
   160         {
   161 				}
   161         iHostAddress.Zero();
   162 			else
   162         iObserver.OperationCompleteL(errorCode);
   163 	            {
   163         }
   164 	            iIsTimeoutDialogTimerStarted = EFalse;
       
   165 	            iDialogTimer->Cancel();
       
   166 	            buffer.Copy(_L("Connecting to "));
       
   167 	            buffer.Append(iHostAddress);
       
   168 	            iTrace->Trace(buffer,KTraceFileName, __LINE__); 				
       
   169 	            iConnection = iCommMgr.CreateConnectionL(iHostAddress,iTls,iPskTls,iPort,iIAPId);
       
   170 	            OpenConnection();
       
   171 	            }	
       
   172 			}
       
   173 	    else
       
   174 	        {
       
   175 	        iHostAddress.Zero();
       
   176 	        iObserver.OperationCompleteL(errorCode);
       
   177 	        }
   164 		}
   178 		}
   165     }
   179     }
   166     
   180 
   167  
   181 // -----------------------------------------------------------------------------
   168  // -----------------------------------------------------------------------------
   182 // COMASuplConnRequestor::OpenConnection
   169 // COMASuplConnRequestor::CreateConnection for OCC
       
   170 // -----------------------------------------------------------------------------
   183 // -----------------------------------------------------------------------------
   171 //    
   184 //    
   172 void COMASuplConnRequestor::CreateConnectionL(TBool aPrompt,TBool aWlanOnly)
   185 void COMASuplConnRequestor::CreateConnectionL(TInt aDialogTimeOutDelay)
   173     {
   186     {
   174         TBuf<30> GeoTagServerName;
   187     iIsTimeoutDialogTimerStarted = ETrue;
   175         TBuf<128> buffer;
   188 
   176         iState = EConnecting;  
   189     iDialogTimer->StartTimer(aDialogTimeOutDelay); 
   177        
       
   178         iPrompt = aPrompt;
       
   179         iWlanOnly = aWlanOnly;
       
   180         iIsStaleLocIdPresent = ETrue;
       
   181                
       
   182         TInt err;
       
   183         err = iRepository->Get(KSuplGeoInfoConvServerName, GeoTagServerName);
       
   184         User::LeaveIfError(err);
       
   185         buffer.Copy(_L("Connecting to"));
       
   186         buffer.Append(GeoTagServerName);
       
   187         iTrace->Trace(buffer,KTraceFileName, __LINE__);                 
       
   188         iTls = ETrue;
       
   189         iPskTls = EFalse;
       
   190         iIAPId = 0;
       
   191         
       
   192         
       
   193         iConnection = iCommMgr.CreateConnectionL(GeoTagServerName,iTls,iPskTls,iPort,iIAPId);
       
   194        
       
   195         OpenConnection();
       
   196         
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // COMASuplConnRequestor::OpenConnection
       
   201 // -----------------------------------------------------------------------------
       
   202  
       
   203 void COMASuplConnRequestor::CreateConnectionL(TInt /*aDialogTimeOutDelay*/)
       
   204     {
       
   205     CreateConnectionL();
   190     CreateConnectionL();
   206     }
   191     }
   207 // -----------------------------------------------------------------------------
   192 // -----------------------------------------------------------------------------
   208 // COMASuplConnRequestor::OpenConnection
   193 // COMASuplConnRequestor::OpenConnection
   209 // -----------------------------------------------------------------------------
   194 // -----------------------------------------------------------------------------
   243     if(iIsSettingInitilized)
   228     if(iIsSettingInitilized)
   244         {
   229         {
   245         if(iConnection)
   230         if(iConnection)
   246             {
   231             {
   247             iState = EConnecting;
   232             iState = EConnecting;
   248             if(iIsStaleLocIdPresent)
   233             iConnection->Connect(iStatus);
   249                 {
   234             SetActive();
   250                 iTrace->Trace(_L("OpenConnection OCC"),KTraceFileName, __LINE__);
       
   251                 iConnection->Connect(iStatus,iPrompt,iWlanOnly);
       
   252                 }
       
   253             else
       
   254                 {
       
   255                 iConnection->Connect(iStatus);
       
   256                 }
       
   257            SetActive();
       
   258            
       
   259             }
   235             }
   260         }
   236         }
   261     else
   237     else
   262         {
   238         {
   263 		iState = EInitilizeSetting;
   239 		iState = EInitilizeSetting;
   322             {
   298             {
   323             if(iLastConnectionError < 0)
   299             if(iLastConnectionError < 0)
   324                 {
   300                 {
   325                 iHostAddress.Zero();
   301                 iHostAddress.Zero();
   326                 CloseConnection();
   302                 CloseConnection();
   327                 if(iIsStaleLocIdPresent)
   303                 CreateConnectionL();
   328                     {
       
   329                     iTrace->Trace(_L("Request completed with error..."), KTraceFileName, __LINE__);       
       
   330                     iObserver.OperationCompleteL(iLastConnectionError);
       
   331                     }
       
   332                 else
       
   333                     {
       
   334                     iTrace->Trace(_L("Setting API Initilizing Completed..."), KTraceFileName, __LINE__);       
       
   335                     CreateConnectionL();
       
   336                     }
       
   337                 
       
   338                 }
   304                 }
   339             else
   305             else
   340                 {
   306                 {
   341                 ListenToMessages();                            
   307                 ListenToMessages();                            
   342                 iObserver.OperationCompleteL(iLastConnectionError);
   308                 iObserver.OperationCompleteL(iLastConnectionError);
   427 // -----------------------------------------------------------------------------
   393 // -----------------------------------------------------------------------------
   428 //
   394 //
   429 void COMASuplConnRequestor::InitilizeSetting()
   395 void COMASuplConnRequestor::InitilizeSetting()
   430     {
   396     {
   431     iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
   397     iTrace->Trace(_L("Intilizing Setting API..."), KTraceFileName, __LINE__); 				
   432     
       
   433     iSuplSettings->Initialize(iStatus);
   398     iSuplSettings->Initialize(iStatus);
   434     SetActive();
   399     SetActive();
   435     }
   400     }
   436 
   401 
   437 // -----------------------------------------------------------------------------
   402 // -----------------------------------------------------------------------------
   451     {
   416     {
   452     return iHslpAddrFromImsiUsed;
   417     return iHslpAddrFromImsiUsed;
   453     }	
   418     }	
   454 
   419 
   455 TUint COMASuplConnRequestor::GetPortNumber()
   420 TUint COMASuplConnRequestor::GetPortNumber()
   456 	{
   421     {
   457 	if(iConnection)
   422     if (iConnection)
   458 		return iConnection->GetPortNumberUsed();
   423         {
   459 	else 
   424         return iConnection->GetPortNumberUsed();
   460 		return 0;
   425         }
   461 	}
   426     else
   462 	
   427         return 0;
       
   428     }
       
   429 
   463 // -----------------------------------------------------------------------------
   430 // -----------------------------------------------------------------------------
   464 // COMASuplConnRequestor::SetDefaultParametersL
   431 // COMASuplConnRequestor::SetDefaultParametersL
   465 // -----------------------------------------------------------------------------
   432 // -----------------------------------------------------------------------------
   466 //
   433 //
   467 void COMASuplConnRequestor::SetDefaultParametersL(const TDesC& aClientProvidedHSLPAddress,TBool aFallBackAllowed)	
   434 void COMASuplConnRequestor::SetDefaultParametersL(const TDesC& aClientProvidedHSLPAddress,TBool aFallBackAllowed)	
   505         }
   472         }
   506     CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   473     CleanupStack::PopAndDestroy(2);//delete tableView and commDb
   507     return result;
   474     return result;
   508     }
   475     }
   509 
   476 
   510 
   477 // -----------------------------------------------------------------------------
       
   478 // COMASuplConnRequestor::SettingsUICompleted
       
   479 // 
       
   480 // -----------------------------------------------------------------------------
       
   481 
       
   482 void COMASuplConnRequestor::SettingsUICompletedL(TInt aError)
       
   483     {
       
   484 		TBuf<128> buffer(_L("COMASuplConnRequestor:SettingsUICompleted Error: "));
       
   485     buffer.AppendNum(aError);
       
   486     iTrace->Trace(buffer,KTraceFileName, __LINE__); 
       
   487 
       
   488     if (iIsTimeoutDialogTimerStarted)
       
   489         {                
       
   490         iTrace->Trace(_L("COMASuplSession::SettingsUICompleted, stopping timer "), KTraceFileName, __LINE__);
       
   491         iIsTimeoutDialogTimerStarted = EFalse;                    
       
   492         iDialogTimer->StopTimer();
       
   493         }
       
   494     if (iIapDlgTimerExpired)
       
   495         {
       
   496         iIapDlgTimerExpired = EFalse;
       
   497         iIapDialogShown = EFalse;
       
   498         iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
   499         iObserver.OperationCompleteL(KErrNone);
       
   500         return;
       
   501         }
       
   502     if(aError == KErrNone)
       
   503         {
       
   504         TInt err = KErrGeneral;
       
   505         iTrace->Trace(
       
   506                 _L("COMASuplConnRequestor::SettingsUICompletedL KErrNone"),
       
   507                 KTraceFileName, __LINE__);
       
   508         TBuf<100> IapName, buffer;
       
   509         CServerParams* params = CServerParams::NewL();
       
   510 
       
   511         err = iSuplSettings->GetSlpInfoAddress(iHostAddress, params);
       
   512         iTrace->Trace(_L("iSuplSettings->GetSlpInfoAddress returned : "),
       
   513                 KTraceFileName, __LINE__);
       
   514         buffer.AppendNum(err);
       
   515         iTrace->Trace(buffer, KTraceFileName, __LINE__);
       
   516 
       
   517         // Fix for ou1cimx#475026 and ou1cimx#471138
       
   518         // When there are no access points defined for any SUPL server, the user is asked to
       
   519         // select the access point only once and same access point is used for the following servers.
       
   520         if (err == KErrNone)
       
   521             {
       
   522             HBufC* aServerAddress = HBufC::NewL(KStringLength);
       
   523             HBufC* aIapName = HBufC::NewL(KStringLength);
       
   524             TInt64 aSlpId;
       
   525             TBool aServerEnabled, aSimChangeRemove, aUsageInHomeNw, aEditable;
       
   526 
       
   527             err = params->Get(aSlpId, aServerAddress->Des(), aIapName->Des(),
       
   528                     aServerEnabled, aSimChangeRemove, aUsageInHomeNw,
       
   529                     aEditable);
       
   530 
       
   531             iTrace->Trace(_L("params->Get() returned: "), KTraceFileName,
       
   532                     __LINE__);
       
   533             buffer.Zero();
       
   534             buffer.AppendNum(err);
       
   535             iTrace->Trace(buffer, KTraceFileName, __LINE__);
       
   536             IapName.Copy(*aIapName);
       
   537             IapName.LowerCase();
       
   538 
       
   539             //converting the iap name to id.
       
   540             ConvertIAPNameToIdL(IapName, iIAPId);
       
   541             //updating the list of SLP with the chosen access point
       
   542             iFallBackHandler->UpdateSLPListWithAccessPoint(IapName);
       
   543 
       
   544             delete aServerAddress;
       
   545             delete aIapName;
       
   546             delete params;
       
   547 
       
   548             // if the getting the list parameters is success opening the connection with the chosen access point
       
   549             if (err == KErrNone)
       
   550                 {
       
   551                 buffer.Copy(_L("Connecting to "));
       
   552                 buffer.Append(iHostAddress);
       
   553                 buffer.Append(_L(" using IAP "));
       
   554                 buffer.Append(IapName);
       
   555                 iTrace->Trace(buffer, KTraceFileName, __LINE__);
       
   556                 iConnection = iCommMgr.CreateConnectionL(iHostAddress, iTls,
       
   557                         iPskTls, iPort, iIAPId);
       
   558                 OpenConnection();
       
   559                 }
       
   560             else
       
   561                 {
       
   562                 iObserver.OperationCompleteL(err);
       
   563                 }
       
   564             }
       
   565         else
       
   566             {
       
   567             delete params;
       
   568             iObserver.OperationCompleteL(err);
       
   569             }
       
   570         }
       
   571     else
       
   572         {
       
   573         iObserver.OperationCompleteL(aError);
       
   574         }
       
   575 
       
   576     }
   511 
   577 
   512 // -----------------------------------------------------------------------------
   578 // -----------------------------------------------------------------------------
   513 // COMASuplConnRequestor::SaveAccessPoint
   579 // COMASuplConnRequestor::SaveAccessPoint
   514 // 
   580 // 
   515 // -----------------------------------------------------------------------------
   581 // -----------------------------------------------------------------------------
   571 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   637 void COMASuplConnRequestor::UpdateSLPListForHomeUsage(TBool aHomeNetwork)
   572     {
   638     {
   573     iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   639     iFallBackHandler->UpdateSLPListForHomeUsage(aHomeNetwork);
   574     }
   640     }
   575 
   641 
   576 
   642 // -----------------------------------------------------------------------------
       
   643 // COMASuplConnRequestor::DialogTimerExpiredL
       
   644 // Checks whether UI is displayed or not previously
       
   645 // 
       
   646 // -----------------------------------------------------------------------------
       
   647 void COMASuplConnRequestor::DialogTimerExpiredL()
       
   648     {
       
   649     iTrace->Trace(_L("COMASuplConnRequestor:Timer Expired for SUPL IAP Dialog"), KTraceFileName, __LINE__); 
       
   650 
       
   651     if (!iIapDialogShown)
       
   652         iProtocolManager.LaunchSuplDialogTimeoutUI(this);
       
   653     else
       
   654         iIapDlgTimerExpired = ETrue;  
       
   655     return; 
       
   656     }
   577 //  End of File
   657 //  End of File