browserutilities/connectionmanager/Src/InternetConnectionManager.cpp
branchRCL_3
changeset 48 79859ed3eea9
parent 41 4bd5176e1bc8
child 49 919f36ff910f
equal deleted inserted replaced
47:e1bea15f9a39 48:79859ed3eea9
    21 
    21 
    22 //INCLUDE FILES
    22 //INCLUDE FILES
    23 
    23 
    24 	//System Includes
    24 	//System Includes
    25 #include <bldvariant.hrh>
    25 #include <bldvariant.hrh>
    26 #include <browser_platform_variant.hrh>
    26 
    27 #include <ApAccessPointItem.h>
    27 #include <ApAccessPointItem.h>
    28 #include <VpnAPEngine.h>
    28 #include <VpnApEngine.h>
    29 #include <AknNotifyStd.h>
    29 #include <AknNotifyStd.h>
    30 #include <AknGlobalNote.h>
    30 #include <AknGlobalNote.h>
    31 #include <e32std.h>
    31 #include <e32std.h>
    32 #include <ApUtils.h>
    32 #include <ApUtils.h>
    33 #include <ApDataHandler.h>
    33 #include <ApDataHandler.h>
    34 #include <cdbstore.h>
    34 #include <cdbstore.h>
    35 #include <coemain.h>
    35 #include <coemain.h>
    36 #include <bautils.h>
    36 #include <bautils.h>
    37 #include <connectionmanager.rsg>
    37 #include <connectionmanager.rsg>
    38 #include <BARSREAD.H>
    38 #include <barsread.h>
    39 #include <Avkon.rsg>
    39 #include <Avkon.rsg>
    40 #include <errorui.h>
    40 #include <ErrorUI.h>
    41 #include <aknglobalconfirmationquery.h>
    41 #include <AknGlobalConfirmationQuery.h>
    42 #include <aknquerydialog.h>
    42 #include <AknQueryDialog.h>
    43 #include <aknwaitdialog.h>
    43 #include <AknWaitDialog.h>
    44 #include <cdblen.h>
    44 #include <cdblen.h>
    45 #include <StringLoader.h>
    45 #include <StringLoader.h>
    46 #include <connectprog.h>
    46 #include <connectprog.h>
    47 #include <nd_err.h>
    47 #include <nd_err.h>
    48 #include <CommDbConnPref.h>
    48 #include <commdbconnpref.h>
    49 #include <MmTsy_names.h>
    49 #include <mmtsy_names.h>
    50 #include <etelmm.h>
    50 #include <etelmm.h>
    51 #include <data_caging_path_literals.hrh>
    51 #include <data_caging_path_literals.hrh>
    52 #include <AknsUtils.h> 
    52 #include <AknsUtils.h> 
    53 #include <avkon.mbg>
    53 #include <avkon.mbg>
    54 #include <ConnMan.mbg>
    54 #include <ConnMan.mbg>
    55 #include <rconnmon.h>
    55 #include <rconnmon.h>
    56 #include <AgentDialog.h>
    56 #include <agentdialog.h>
    57 #include <ConnectionUiUtilities.h>
    57 #include <ConnectionUiUtilities.h>
    58 #include <AknQueryDialog.h>
    58 #include <AknQueryDialog.h>
    59 #include <WlanCdbCols.h>
    59 #include <WlanCdbCols.h>
    60 #include <etelpckt.h>
    60 #include <etelpckt.h>
    61 #include <FeatMgr.h>
    61 #include <featmgr.h>
    62 #include <cmmanagerext.h>
    62 #include <cmmanagerext.h>
    63 #include <cmdestinationext.h>
    63 #include <cmdestinationext.h>
    64 #include <commsdat.h>
    64 #include <commsdat.h>
    65 #include <CommsDatTypeInfoV1_1.h>
    65 #include <commsdattypeinfov1_1.h>
    66 
    66 
    67 	//User Includes
    67 	//User Includes
    68 #include <internetconnectionmanager.h>
    68 #include "InternetConnectionManager.h"
    69 #include "connman.hrh"
    69 #include "ConnMan.hrh"
    70 #include "connectionmanagerlogger.h"
    70 #include "ConnectionManagerLogger.h"
    71 #include <connectionobservers.h>
    71 #include "ConnectionObservers.h"
    72 #include "connmanactiveconnector.h"
    72 #include "ConnManActiveConnector.h"
    73 
    73 
    74 using namespace CMManager;
    74 using namespace CMManager;
    75 
    75 
    76 // CONSTANTS
    76 // CONSTANTS
    77 _LIT(KConnectionResourceFile, "\\resource\\ConnectionManager.rsc");
    77 _LIT(KConnectionResourceFile, "\\resource\\ConnectionManager.rsc");
    78 #ifdef BRDO_OCC_ENABLED_FF
    78 
    79 //As per OCC, number of Connection observer states
       
    80 const TInt KMaxOccStages = 1;
       
    81 #endif
       
    82 // ============================ MEMBER FUNCTIONS ===============================
    79 // ============================ MEMBER FUNCTIONS ===============================
    83 //--------------------------------------------------------------------------
    80 //--------------------------------------------------------------------------
    84 //CInternetConnectionManager::ConnectL( TUint32 aIAPId1, TUint32 aIAPId2 )
    81 //CInternetConnectionManager::ConnectL( TUint32 aIAPId1, TUint32 aIAPId2 )
    85 //--------------------------------------------------------------------------
    82 //--------------------------------------------------------------------------
    86 EXPORT_C TInt CInternetConnectionManager::ConnectL(  TUint32 /*aIAPId1*/, TUint32 /*aIAPId2*/ )
    83 EXPORT_C TInt CInternetConnectionManager::ConnectL(  TUint32 /*aIAPId1*/, TUint32 /*aIAPId2*/ )
   208 
   205 
   209             query.Format(_L("%s\\%s"), IAP, COMMDB_NAME);
   206             query.Format(_L("%s\\%s"), IAP, COMMDB_NAME);
   210             User::LeaveIfError( iConnection.GetDesSetting( query, val ) );
   207             User::LeaveIfError( iConnection.GetDesSetting( query, val ) );
   211 
   208 
   212             iConnName = val.AllocL();
   209             iConnName = val.AllocL();
   213             CLOG_WRITE_1( "Iap id used : %d", iapId );
       
   214             CLOG_WRITE_1( "Conn name   : %S", iConnName);
       
   215             }
   210             }
   216         else if( !iRequestedAPIds.iFirstPreference )
   211         else if( !iRequestedAPIds.iFirstPreference )
   217             {
   212             {
   218             TBuf<20> query;
   213             TBuf<20> query;
   219             TBuf<40> val;
   214             TBuf<40> val;
   455 			{
   450 			{
   456 			connErr = KErrCancel;
   451 			connErr = KErrCancel;
   457 			}
   452 			}
   458 		else
   453 		else
   459 			{               
   454 			{               
   460             if(iConnection.SubSessionHandle() <= 0)
       
   461                 {
       
   462 				//  RConnection handle is invalid, we haven't opened the RConnection yet.
       
   463 		        connErr = iConnection.Open( iServ, KAfInet );
   455 		        connErr = iConnection.Open( iServ, KAfInet );
   464 		       	}
       
   465 		        CLOG_WRITE_1( "RConnection: %d", connErr );
   456 		        CLOG_WRITE_1( "RConnection: %d", connErr );
   466 		        if( connErr == KErrNone )
   457 		        if( connErr == KErrNone )
   467 		            {
   458 		            {
   468 		            // Always pass the IAP Id to RConnection even in silent mode
   459 		            // Always pass the IAP Id to RConnection even in silent mode
   469 		            connErr = iSyncConnector->Connect( overrides );
   460 		            connErr = iSyncConnector->Connect( overrides );
       
   461 		            }
       
   462 		        if( connErr != KErrNone )
       
   463 		            {
       
   464 		            CLOG_WRITE( "Closing all" );
       
   465 		            iConnection.Close();
   470 		            }
   466 		            }
   471 			}
   467 			}
   472 		}
   468 		}
   473 	if ( iWaitDialog )
   469 	if ( iWaitDialog )
   474 		{
   470 		{
   515 	if ( iCommsDbOwned )
   511 	if ( iCommsDbOwned )
   516 		{
   512 		{
   517 		delete iCommsDb;
   513 		delete iCommsDb;
   518 		}
   514 		}
   519 
   515 
       
   516     if( iConnected )
       
   517         {
       
   518         iConnection.Close();
       
   519         }
       
   520 
   520     if( !iSilentMode )
   521     if( !iSilentMode )
   521         // Temp fix for CDMA
   522         // Temp fix for CDMA
   522         {
   523         {
   523         delete iCurrentAP;
   524         delete iCurrentAP;
   524         }
   525         }
   529     delete iConnName;
   530     delete iConnName;
   530 	delete iWaitDialog;
   531 	delete iWaitDialog;
   531 	delete iNoteDialog;
   532 	delete iNoteDialog;
   532 	delete iSyncConnector;
   533 	delete iSyncConnector;
   533 	iRFs.Close();
   534 	iRFs.Close();
   534 	iConnection.Close();
   535 
   535 	iServ.Close();
   536     iServ.Close();
   536     
   537     
   537 	CLOG_CLOSE;
   538 	CLOG_CLOSE;
   538 	}
   539 	}
   539 	
   540 	
   540 //--------------------------------------------------------------------------
   541 //--------------------------------------------------------------------------
   579 //CInternetConnectionManager::BearerTypeL
   580 //CInternetConnectionManager::BearerTypeL
   580 //--------------------------------------------------------------------------
   581 //--------------------------------------------------------------------------
   581 TApBearerType CInternetConnectionManager::BearerTypeL( TUint32 aIAPId )
   582 TApBearerType CInternetConnectionManager::BearerTypeL( TUint32 aIAPId )
   582 	{
   583 	{
   583 	TApBearerType apbearerType = EApBearerTypeAllBearers;
   584 	TApBearerType apbearerType = EApBearerTypeAllBearers;
   584 #ifdef BRDO_OCC_ENABLED_FF
   585     if( iSilentMode || !iRequestedAPIds.iFirstPreference )
   585 	if( !iRequestedAPIds.iFirstPreference )
       
   586 #else
       
   587 	if( iSilentMode || !iRequestedAPIds.iFirstPreference )
       
   588 #endif
       
   589         // Temp fix for CDMA 
   586         // Temp fix for CDMA 
   590         {
   587         {
   591         return EApBearerTypeAllBearers;
   588         return EApBearerTypeAllBearers;
   592         }
   589         }
   593 
   590 
   644 EXPORT_C void CInternetConnectionManager::StopConnectionL()
   641 EXPORT_C void CInternetConnectionManager::StopConnectionL()
   645 	{
   642 	{
   646     CLOG_ENTERFN( "StopConnectionL()" );
   643     CLOG_ENTERFN( "StopConnectionL()" );
   647 
   644 
   648     StopConnectionObserving();
   645     StopConnectionObserving();
   649     
   646     iConnection.Close();
   650     if( iConnected )
       
   651         {
       
   652         CLOG_WRITE( "StopConnectionL() Stop the Connection" );        
       
   653         iConnection.Close();
       
   654         TInt err = iConnection.Open( iServ, KAfInet );        
       
   655         }    
       
   656     else
       
   657         {
       
   658         CLOG_WRITE( "Cancel the Connection" );
       
   659         CancelConnection();
       
   660         }
       
   661     
       
   662 //    iServ.Close();
   647 //    iServ.Close();
   663     iConnected = EFalse;
   648     iConnected = EFalse;
   664     iEasyWlan = EFalse;
   649     iEasyWlan = EFalse;
   665 
   650 
   666     if( !iSilentMode )
   651     if( !iSilentMode )
  1054     
  1039     
  1055     //Connect with Snap Id if the connection type is Destination Nw
  1040     //Connect with Snap Id if the connection type is Destination Nw
  1056     
  1041     
  1057     if (iConnectionType == EDestination)
  1042     if (iConnectionType == EDestination)
  1058     	{
  1043     	{
  1059     	err = ConnectWithSnapIdL(iRequestedSnapId);	
  1044     	err = ConnectWithSnapId(iRequestedSnapId);	
  1060     	return err;
  1045     	return err;
  1061     	}
  1046     	}
  1062     	else
  1047     	else
  1063     		{
  1048     		{
  1064     			
  1049     			
  1338     CLOG_ENTERFN( "StartConnectionObservingL()" );
  1323     CLOG_ENTERFN( "StartConnectionObservingL()" );
  1339 
  1324 
  1340     TName* name = ConnectionNameL();
  1325     TName* name = ConnectionNameL();
  1341     __ASSERT_DEBUG( name, User::Panic( KNullDesC, KErrCorrupt ) );
  1326     __ASSERT_DEBUG( name, User::Panic( KNullDesC, KErrCorrupt ) );
  1342     CleanupStack::PushL( name );
  1327     CleanupStack::PushL( name );
  1343 
  1328     
  1344 #ifdef BRDO_OCC_ENABLED_FF
       
  1345     iSatges[0] = KLinkLayerClosed;
       
  1346     iStageNotifier->StartNotificationL( name,iSatges,KMaxOccStages,this, ETrue );
       
  1347 #else
       
  1348     iSatges[0] = KConnectionUninitialised;
  1329     iSatges[0] = KConnectionUninitialised;
  1349     iSatges[1] = KConnectionClosed;
  1330     iSatges[1] = KConnectionClosed;
  1350     iSatges[2] = KLinkLayerClosed;
  1331     iSatges[2] = KLinkLayerClosed;
  1351 
  1332 
  1352     iStageNotifier->StartNotificationL( name,iSatges,KMaxStages,this, ETrue );
  1333     iStageNotifier->StartNotificationL( name,iSatges,KMaxStages,this, ETrue );
  1353 #endif
       
  1354 
  1334 
  1355     CleanupStack::PopAndDestroy( name );
  1335     CleanupStack::PopAndDestroy( name );
  1356     }
  1336     }
  1357 
  1337 
  1358 //-------------------------------------------------------------------
  1338 //-------------------------------------------------------------------
  1378  //   CLOG_WRITE_1( "ConnectionStageAchievedL() Stage = %d ", aStage);
  1358  //   CLOG_WRITE_1( "ConnectionStageAchievedL() Stage = %d ", aStage);
  1379      if(iConnected) 
  1359      if(iConnected) 
  1380      {
  1360      {
  1381      	// this is a connection closed event
  1361      	// this is a connection closed event
  1382         CLOG_WRITE( "ConnectionStageAchievedL() Stoping the connection instead of closing" );
  1362         CLOG_WRITE( "ConnectionStageAchievedL() Stoping the connection instead of closing" );
       
  1363         iConnection.Stop();
  1383     	iConnected = EFalse;
  1364     	iConnected = EFalse;
  1384 
  1365 
  1385     	if( !iSilentMode )
  1366     	if( !iSilentMode )
  1386         // Temp fix for CDMA
  1367         // Temp fix for CDMA
  1387         {
  1368         {
  1659     {
  1640     {
  1660     TRAP_IGNORE( DoShowConnectionChangedDlgL() );
  1641     TRAP_IGNORE( DoShowConnectionChangedDlgL() );
  1661     }
  1642     }
  1662     
  1643     
  1663 //------------------------------------------------------------------------
  1644 //------------------------------------------------------------------------
  1664 //CInternetConnectionManager::CancelConnection
       
  1665 //    
       
  1666  void CInternetConnectionManager::CancelConnection()
       
  1667     {
       
  1668     CLOG_ENTERFN("CInternetConnectionManager::CancelConnection");
       
  1669     if(iSyncConnector && iSyncConnector->IsActive()) 
       
  1670         {
       
  1671         CLOG_WRITE( "Connection is cancelled" );        
       
  1672         iSyncConnector->Cancel();
       
  1673         }
       
  1674 	}
       
  1675 		
       
  1676 //------------------------------------------------------------------------
       
  1677 //CInternetConnectionManager::AskIap
  1645 //CInternetConnectionManager::AskIap
  1678 //------------------------------------------------------------------------
  1646 //------------------------------------------------------------------------
  1679 EXPORT_C TInt CInternetConnectionManager::AskIap( TUint32& aNewIap )
  1647 EXPORT_C TInt CInternetConnectionManager::AskIap( TUint32& aNewIap )
  1680     {
  1648     {
  1681     CLOG_ENTERFN("AskIap");
  1649     CLOG_ENTERFN("AskIap");
  1709 	{
  1677 	{
  1710 	CLOG_ENTERFN("CInternetConnectionManager::SetConnectionType");
  1678 	CLOG_ENTERFN("CInternetConnectionManager::SetConnectionType");
  1711 	CLOG_WRITE_1( "CInternetConnectionManager::SetConnectionType - %d", aConnectionType );
  1679 	CLOG_WRITE_1( "CInternetConnectionManager::SetConnectionType - %d", aConnectionType );
  1712 	iConnectionType = aConnectionType;
  1680 	iConnectionType = aConnectionType;
  1713 	}
  1681 	}
       
  1682     
  1714 //-------------------------------------------------------------------
  1683 //-------------------------------------------------------------------
  1715 //CInternetConnectionManager::SetRequestedSnap
  1684 //CInternetConnectionManager::SetRequestedSnap
  1716 //-------------------------------------------------------------------
  1685 //-------------------------------------------------------------------
  1717 //    
  1686 //    
  1718 EXPORT_C void CInternetConnectionManager::SetRequestedSnap (TUint32 aRequestedSnapId)
  1687 EXPORT_C void CInternetConnectionManager::SetRequestedSnap (TUint32 aRequestedSnapId)
  2023 
  1992 
  2024     if( !iServ.Handle() )
  1993     if( !iServ.Handle() )
  2025         {
  1994         {
  2026         User::LeaveIfError( iServ.Connect() );
  1995         User::LeaveIfError( iServ.Connect() );
  2027         }
  1996         }
       
  1997 
  2028     CLOG_WRITE( "Fully initialized" );
  1998     CLOG_WRITE( "Fully initialized" );
  2029     iInitialized = ETrue;    
  1999     iInitialized = ETrue;    
  2030     }
  2000     }
  2031     
  2001     
  2032 //------------------------------------------------------------------------
  2002 //------------------------------------------------------------------------
  2033 //CInternetConnectionManager::ConnectWithSnapIdL
  2003 //CInternetConnectionManager::ConnectWithSnapId
  2034 //------------------------------------------------------------------------    
  2004 //------------------------------------------------------------------------    
  2035 TInt CInternetConnectionManager::ConnectWithSnapIdL(TUint32 aRequestedSnapId)
  2005 TInt CInternetConnectionManager::ConnectWithSnapId(TUint32 aRequestedSnapId)
  2036 	{
  2006 	{
  2037 
  2007 
  2038     CLOG_WRITE_1( "CInternetConnectionManager::ConnectWithSnapId - %d", aRequestedSnapId );
  2008     CLOG_WRITE_1( "CInternetConnectionManager::ConnectWithSnapId - %d", aRequestedSnapId );
  2039 
  2009 
  2040 	iInternalError = KErrNone;
  2010 	iInternalError = KErrNone;
  2045 	
  2015 	
  2046     DisplayConnErrorL();
  2016     DisplayConnErrorL();
  2047 #ifndef __WINS__
  2017 #ifndef __WINS__
  2048     if( KErrNone == connErr )
  2018     if( KErrNone == connErr )
  2049         {
  2019         {
  2050         if( iSilentMode )
  2020         TUint32 iIapID;
  2051         // Temp fix for CDMA
  2021         TBuf<20> query;
  2052            {
  2022         query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
  2053            TUint32 iapId;
  2023         if( iConnection.GetIntSetting( query, iIapID ) == KErrNone )
  2054            TBuf<20> query;
  2024             {
  2055            TBuf<40> val;
  2025             CLOG_WRITE_1( "ConnectWithSnapId::AccessPoint - %d", iIapID );
  2056         
  2026             CApAccessPointItem* ap = APItemFromIAPIdLC( iIapID );
  2057            query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
  2027             UpdateCurrentAPL( *ap, EFalse );
  2058            User::LeaveIfError( iConnection.GetIntSetting( query, iapId ) );
  2028             CleanupStack::PopAndDestroy();  // ap
  2059            iCurrentAP = (CApAccessPointItem*)iapId;
  2029             }
  2060         
       
  2061            query.Format(_L("%s\\%s"), IAP, COMMDB_NAME);
       
  2062            User::LeaveIfError( iConnection.GetDesSetting( query, val ) );
       
  2063         
       
  2064            iConnName = val.AllocL();
       
  2065            CLOG_WRITE_1( "Iap id used : %d", iapId );
       
  2066            CLOG_WRITE_1( "Conn name   : %S", iConnName);
       
  2067            }
       
  2068         else
       
  2069            {
       
  2070            TUint32 iIapID;
       
  2071            TBuf<20> query;
       
  2072            query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
       
  2073            if( iConnection.GetIntSetting( query, iIapID ) == KErrNone )
       
  2074                {
       
  2075                CLOG_WRITE_1( "ConnectWithSnapId::AccessPoint - %d", iIapID );
       
  2076                CApAccessPointItem* ap = APItemFromIAPIdLC( iIapID );
       
  2077                UpdateCurrentAPL( *ap, EFalse );
       
  2078                CleanupStack::PopAndDestroy();  // ap
       
  2079                }
       
  2080            }
       
  2081         }
  2030         }
  2082             
  2031             
  2083 #endif
  2032 #endif
  2084 
  2033 
  2085 	return connErr;
  2034 	return connErr;
  2150 
  2099 
  2151 	CLOG_WRITE( "ConnMan Overrides set"  );
  2100 	CLOG_WRITE( "ConnMan Overrides set"  );
  2152 
  2101 
  2153 	if ( !connErr )
  2102 	if ( !connErr )
  2154 		{
  2103 		{
  2155 		if(iConnection.SubSessionHandle() <= 0)
       
  2156 			{
       
  2157 			//  RConnection handle is invalid, we haven't opened the RConnection yet.
       
  2158         connErr = iConnection.Open( iServ, KAfInet );
  2104         connErr = iConnection.Open( iServ, KAfInet );
  2159         	}
       
  2160         CLOG_WRITE_1( "RConnection: %d", connErr );
  2105         CLOG_WRITE_1( "RConnection: %d", connErr );
  2161         if( connErr == KErrNone )
  2106         if( connErr == KErrNone )
  2162             {
  2107             {
  2163            //connect with snap id
  2108            //connect with snap id
  2164             connErr = iSyncConnector->ConnectSnap( overrides );
  2109             connErr = iSyncConnector->ConnectSnap( overrides );
       
  2110             }
       
  2111         if( connErr != KErrNone )
       
  2112             {
       
  2113             CLOG_WRITE( "Closing all" );
       
  2114             iConnection.Close();
  2165             }
  2115             }
  2166 		}
  2116 		}
  2167 	
  2117 	
  2168 	CleanupStack::PopAndDestroy();//overrides
  2118 	CleanupStack::PopAndDestroy();//overrides
  2169     iInternalError = connErr;
  2119     iInternalError = connErr;
  2202         {
  2152         {
  2203         iWaitDialog->SetTextL( aLabel->Des() );
  2153         iWaitDialog->SetTextL( aLabel->Des() );
  2204         }
  2154         }
  2205     iWaitDialog->RunLD();
  2155     iWaitDialog->RunLD();
  2206     }
  2156     }
  2207 
       
  2208 //-------------------------------------------------------------------
       
  2209 //CInternetConnectionManager::SetOccPreferences
       
  2210 //-------------------------------------------------------------------
       
  2211 
       
  2212 void CInternetConnectionManager::SetOccPreferences( TSetOCCPreferences aOCCPreferences)
       
  2213     {
       
  2214     if( iSyncConnector )
       
  2215        iSyncConnector->SetOccPreferences(aOCCPreferences);
       
  2216     }
       
  2217     
  2157     
  2218 // End of File
  2158 // End of File