browserutilities/connectionmanager/Src/InternetConnectionManager.cpp
branchRCL_3
changeset 49 919f36ff910f
parent 48 79859ed3eea9
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
    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 
    26 #include <browser_platform_variant.hrh>
    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 
    78 #ifdef BRDO_OCC_ENABLED_FF
       
    79 //As per OCC, number of Connection observer states
       
    80 const TInt KMaxOccStages = 1;
       
    81 #endif
    79 // ============================ MEMBER FUNCTIONS ===============================
    82 // ============================ MEMBER FUNCTIONS ===============================
    80 //--------------------------------------------------------------------------
    83 //--------------------------------------------------------------------------
    81 //CInternetConnectionManager::ConnectL( TUint32 aIAPId1, TUint32 aIAPId2 )
    84 //CInternetConnectionManager::ConnectL( TUint32 aIAPId1, TUint32 aIAPId2 )
    82 //--------------------------------------------------------------------------
    85 //--------------------------------------------------------------------------
    83 EXPORT_C TInt CInternetConnectionManager::ConnectL(  TUint32 /*aIAPId1*/, TUint32 /*aIAPId2*/ )
    86 EXPORT_C TInt CInternetConnectionManager::ConnectL(  TUint32 /*aIAPId1*/, TUint32 /*aIAPId2*/ )
   205 
   208 
   206             query.Format(_L("%s\\%s"), IAP, COMMDB_NAME);
   209             query.Format(_L("%s\\%s"), IAP, COMMDB_NAME);
   207             User::LeaveIfError( iConnection.GetDesSetting( query, val ) );
   210             User::LeaveIfError( iConnection.GetDesSetting( query, val ) );
   208 
   211 
   209             iConnName = val.AllocL();
   212             iConnName = val.AllocL();
       
   213             CLOG_WRITE_1( "Iap id used : %d", iapId );
       
   214             CLOG_WRITE_1( "Conn name   : %S", iConnName);
   210             }
   215             }
   211         else if( !iRequestedAPIds.iFirstPreference )
   216         else if( !iRequestedAPIds.iFirstPreference )
   212             {
   217             {
   213             TBuf<20> query;
   218             TBuf<20> query;
   214             TBuf<40> val;
   219             TBuf<40> val;
   450 			{
   455 			{
   451 			connErr = KErrCancel;
   456 			connErr = KErrCancel;
   452 			}
   457 			}
   453 		else
   458 		else
   454 			{               
   459 			{               
       
   460             if(iConnection.SubSessionHandle() <= 0)
       
   461                 {
       
   462 				//  RConnection handle is invalid, we haven't opened the RConnection yet.
   455 		        connErr = iConnection.Open( iServ, KAfInet );
   463 		        connErr = iConnection.Open( iServ, KAfInet );
       
   464 		       	}
   456 		        CLOG_WRITE_1( "RConnection: %d", connErr );
   465 		        CLOG_WRITE_1( "RConnection: %d", connErr );
   457 		        if( connErr == KErrNone )
   466 		        if( connErr == KErrNone )
   458 		            {
   467 		            {
   459 		            // Always pass the IAP Id to RConnection even in silent mode
   468 		            // Always pass the IAP Id to RConnection even in silent mode
   460 		            connErr = iSyncConnector->Connect( overrides );
   469 		            connErr = iSyncConnector->Connect( overrides );
   461 		            }
       
   462 		        if( connErr != KErrNone )
       
   463 		            {
       
   464 		            CLOG_WRITE( "Closing all" );
       
   465 		            iConnection.Close();
       
   466 		            }
   470 		            }
   467 			}
   471 			}
   468 		}
   472 		}
   469 	if ( iWaitDialog )
   473 	if ( iWaitDialog )
   470 		{
   474 		{
   511 	if ( iCommsDbOwned )
   515 	if ( iCommsDbOwned )
   512 		{
   516 		{
   513 		delete iCommsDb;
   517 		delete iCommsDb;
   514 		}
   518 		}
   515 
   519 
   516     if( iConnected )
       
   517         {
       
   518         iConnection.Close();
       
   519         }
       
   520 
       
   521     if( !iSilentMode )
   520     if( !iSilentMode )
   522         // Temp fix for CDMA
   521         // Temp fix for CDMA
   523         {
   522         {
   524         delete iCurrentAP;
   523         delete iCurrentAP;
   525         }
   524         }
   530     delete iConnName;
   529     delete iConnName;
   531 	delete iWaitDialog;
   530 	delete iWaitDialog;
   532 	delete iNoteDialog;
   531 	delete iNoteDialog;
   533 	delete iSyncConnector;
   532 	delete iSyncConnector;
   534 	iRFs.Close();
   533 	iRFs.Close();
   535 
   534 	iConnection.Close();
   536     iServ.Close();
   535 	iServ.Close();
   537     
   536     
   538 	CLOG_CLOSE;
   537 	CLOG_CLOSE;
   539 	}
   538 	}
   540 	
   539 	
   541 //--------------------------------------------------------------------------
   540 //--------------------------------------------------------------------------
   580 //CInternetConnectionManager::BearerTypeL
   579 //CInternetConnectionManager::BearerTypeL
   581 //--------------------------------------------------------------------------
   580 //--------------------------------------------------------------------------
   582 TApBearerType CInternetConnectionManager::BearerTypeL( TUint32 aIAPId )
   581 TApBearerType CInternetConnectionManager::BearerTypeL( TUint32 aIAPId )
   583 	{
   582 	{
   584 	TApBearerType apbearerType = EApBearerTypeAllBearers;
   583 	TApBearerType apbearerType = EApBearerTypeAllBearers;
   585     if( iSilentMode || !iRequestedAPIds.iFirstPreference )
   584 #ifdef BRDO_OCC_ENABLED_FF
       
   585 	if( !iRequestedAPIds.iFirstPreference )
       
   586 #else
       
   587 	if( iSilentMode || !iRequestedAPIds.iFirstPreference )
       
   588 #endif
   586         // Temp fix for CDMA 
   589         // Temp fix for CDMA 
   587         {
   590         {
   588         return EApBearerTypeAllBearers;
   591         return EApBearerTypeAllBearers;
   589         }
   592         }
   590 
   593 
   641 EXPORT_C void CInternetConnectionManager::StopConnectionL()
   644 EXPORT_C void CInternetConnectionManager::StopConnectionL()
   642 	{
   645 	{
   643     CLOG_ENTERFN( "StopConnectionL()" );
   646     CLOG_ENTERFN( "StopConnectionL()" );
   644 
   647 
   645     StopConnectionObserving();
   648     StopConnectionObserving();
   646     iConnection.Close();
   649     
       
   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     
   647 //    iServ.Close();
   662 //    iServ.Close();
   648     iConnected = EFalse;
   663     iConnected = EFalse;
   649     iEasyWlan = EFalse;
   664     iEasyWlan = EFalse;
   650 
   665 
   651     if( !iSilentMode )
   666     if( !iSilentMode )
  1039     
  1054     
  1040     //Connect with Snap Id if the connection type is Destination Nw
  1055     //Connect with Snap Id if the connection type is Destination Nw
  1041     
  1056     
  1042     if (iConnectionType == EDestination)
  1057     if (iConnectionType == EDestination)
  1043     	{
  1058     	{
  1044     	err = ConnectWithSnapId(iRequestedSnapId);	
  1059     	err = ConnectWithSnapIdL(iRequestedSnapId);	
  1045     	return err;
  1060     	return err;
  1046     	}
  1061     	}
  1047     	else
  1062     	else
  1048     		{
  1063     		{
  1049     			
  1064     			
  1323     CLOG_ENTERFN( "StartConnectionObservingL()" );
  1338     CLOG_ENTERFN( "StartConnectionObservingL()" );
  1324 
  1339 
  1325     TName* name = ConnectionNameL();
  1340     TName* name = ConnectionNameL();
  1326     __ASSERT_DEBUG( name, User::Panic( KNullDesC, KErrCorrupt ) );
  1341     __ASSERT_DEBUG( name, User::Panic( KNullDesC, KErrCorrupt ) );
  1327     CleanupStack::PushL( name );
  1342     CleanupStack::PushL( name );
  1328     
  1343 
       
  1344 #ifdef BRDO_OCC_ENABLED_FF
       
  1345     iSatges[0] = KLinkLayerClosed;
       
  1346     iStageNotifier->StartNotificationL( name,iSatges,KMaxOccStages,this, ETrue );
       
  1347 #else
  1329     iSatges[0] = KConnectionUninitialised;
  1348     iSatges[0] = KConnectionUninitialised;
  1330     iSatges[1] = KConnectionClosed;
  1349     iSatges[1] = KConnectionClosed;
  1331     iSatges[2] = KLinkLayerClosed;
  1350     iSatges[2] = KLinkLayerClosed;
  1332 
  1351 
  1333     iStageNotifier->StartNotificationL( name,iSatges,KMaxStages,this, ETrue );
  1352     iStageNotifier->StartNotificationL( name,iSatges,KMaxStages,this, ETrue );
       
  1353 #endif
  1334 
  1354 
  1335     CleanupStack::PopAndDestroy( name );
  1355     CleanupStack::PopAndDestroy( name );
  1336     }
  1356     }
  1337 
  1357 
  1338 //-------------------------------------------------------------------
  1358 //-------------------------------------------------------------------
  1358  //   CLOG_WRITE_1( "ConnectionStageAchievedL() Stage = %d ", aStage);
  1378  //   CLOG_WRITE_1( "ConnectionStageAchievedL() Stage = %d ", aStage);
  1359      if(iConnected) 
  1379      if(iConnected) 
  1360      {
  1380      {
  1361      	// this is a connection closed event
  1381      	// this is a connection closed event
  1362         CLOG_WRITE( "ConnectionStageAchievedL() Stoping the connection instead of closing" );
  1382         CLOG_WRITE( "ConnectionStageAchievedL() Stoping the connection instead of closing" );
  1363         iConnection.Stop();
       
  1364     	iConnected = EFalse;
  1383     	iConnected = EFalse;
  1365 
  1384 
  1366     	if( !iSilentMode )
  1385     	if( !iSilentMode )
  1367         // Temp fix for CDMA
  1386         // Temp fix for CDMA
  1368         {
  1387         {
  1640     {
  1659     {
  1641     TRAP_IGNORE( DoShowConnectionChangedDlgL() );
  1660     TRAP_IGNORE( DoShowConnectionChangedDlgL() );
  1642     }
  1661     }
  1643     
  1662     
  1644 //------------------------------------------------------------------------
  1663 //------------------------------------------------------------------------
       
  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 //------------------------------------------------------------------------
  1645 //CInternetConnectionManager::AskIap
  1677 //CInternetConnectionManager::AskIap
  1646 //------------------------------------------------------------------------
  1678 //------------------------------------------------------------------------
  1647 EXPORT_C TInt CInternetConnectionManager::AskIap( TUint32& aNewIap )
  1679 EXPORT_C TInt CInternetConnectionManager::AskIap( TUint32& aNewIap )
  1648     {
  1680     {
  1649     CLOG_ENTERFN("AskIap");
  1681     CLOG_ENTERFN("AskIap");
  1677 	{
  1709 	{
  1678 	CLOG_ENTERFN("CInternetConnectionManager::SetConnectionType");
  1710 	CLOG_ENTERFN("CInternetConnectionManager::SetConnectionType");
  1679 	CLOG_WRITE_1( "CInternetConnectionManager::SetConnectionType - %d", aConnectionType );
  1711 	CLOG_WRITE_1( "CInternetConnectionManager::SetConnectionType - %d", aConnectionType );
  1680 	iConnectionType = aConnectionType;
  1712 	iConnectionType = aConnectionType;
  1681 	}
  1713 	}
  1682     
       
  1683 //-------------------------------------------------------------------
  1714 //-------------------------------------------------------------------
  1684 //CInternetConnectionManager::SetRequestedSnap
  1715 //CInternetConnectionManager::SetRequestedSnap
  1685 //-------------------------------------------------------------------
  1716 //-------------------------------------------------------------------
  1686 //    
  1717 //    
  1687 EXPORT_C void CInternetConnectionManager::SetRequestedSnap (TUint32 aRequestedSnapId)
  1718 EXPORT_C void CInternetConnectionManager::SetRequestedSnap (TUint32 aRequestedSnapId)
  1992 
  2023 
  1993     if( !iServ.Handle() )
  2024     if( !iServ.Handle() )
  1994         {
  2025         {
  1995         User::LeaveIfError( iServ.Connect() );
  2026         User::LeaveIfError( iServ.Connect() );
  1996         }
  2027         }
  1997 
       
  1998     CLOG_WRITE( "Fully initialized" );
  2028     CLOG_WRITE( "Fully initialized" );
  1999     iInitialized = ETrue;    
  2029     iInitialized = ETrue;    
  2000     }
  2030     }
  2001     
  2031     
  2002 //------------------------------------------------------------------------
  2032 //------------------------------------------------------------------------
  2003 //CInternetConnectionManager::ConnectWithSnapId
  2033 //CInternetConnectionManager::ConnectWithSnapIdL
  2004 //------------------------------------------------------------------------    
  2034 //------------------------------------------------------------------------    
  2005 TInt CInternetConnectionManager::ConnectWithSnapId(TUint32 aRequestedSnapId)
  2035 TInt CInternetConnectionManager::ConnectWithSnapIdL(TUint32 aRequestedSnapId)
  2006 	{
  2036 	{
  2007 
  2037 
  2008     CLOG_WRITE_1( "CInternetConnectionManager::ConnectWithSnapId - %d", aRequestedSnapId );
  2038     CLOG_WRITE_1( "CInternetConnectionManager::ConnectWithSnapId - %d", aRequestedSnapId );
  2009 
  2039 
  2010 	iInternalError = KErrNone;
  2040 	iInternalError = KErrNone;
  2015 	
  2045 	
  2016     DisplayConnErrorL();
  2046     DisplayConnErrorL();
  2017 #ifndef __WINS__
  2047 #ifndef __WINS__
  2018     if( KErrNone == connErr )
  2048     if( KErrNone == connErr )
  2019         {
  2049         {
  2020         TUint32 iIapID;
  2050         if( iSilentMode )
  2021         TBuf<20> query;
  2051         // Temp fix for CDMA
  2022         query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
  2052            {
  2023         if( iConnection.GetIntSetting( query, iIapID ) == KErrNone )
  2053            TUint32 iapId;
  2024             {
  2054            TBuf<20> query;
  2025             CLOG_WRITE_1( "ConnectWithSnapId::AccessPoint - %d", iIapID );
  2055            TBuf<40> val;
  2026             CApAccessPointItem* ap = APItemFromIAPIdLC( iIapID );
  2056         
  2027             UpdateCurrentAPL( *ap, EFalse );
  2057            query.Format( _L("%s\\%s"), IAP, COMMDB_ID );
  2028             CleanupStack::PopAndDestroy();  // ap
  2058            User::LeaveIfError( iConnection.GetIntSetting( query, iapId ) );
  2029             }
  2059            iCurrentAP = (CApAccessPointItem*)iapId;
       
  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            }
  2030         }
  2081         }
  2031             
  2082             
  2032 #endif
  2083 #endif
  2033 
  2084 
  2034 	return connErr;
  2085 	return connErr;
  2099 
  2150 
  2100 	CLOG_WRITE( "ConnMan Overrides set"  );
  2151 	CLOG_WRITE( "ConnMan Overrides set"  );
  2101 
  2152 
  2102 	if ( !connErr )
  2153 	if ( !connErr )
  2103 		{
  2154 		{
       
  2155 		if(iConnection.SubSessionHandle() <= 0)
       
  2156 			{
       
  2157 			//  RConnection handle is invalid, we haven't opened the RConnection yet.
  2104         connErr = iConnection.Open( iServ, KAfInet );
  2158         connErr = iConnection.Open( iServ, KAfInet );
       
  2159         	}
  2105         CLOG_WRITE_1( "RConnection: %d", connErr );
  2160         CLOG_WRITE_1( "RConnection: %d", connErr );
  2106         if( connErr == KErrNone )
  2161         if( connErr == KErrNone )
  2107             {
  2162             {
  2108            //connect with snap id
  2163            //connect with snap id
  2109             connErr = iSyncConnector->ConnectSnap( overrides );
  2164             connErr = iSyncConnector->ConnectSnap( overrides );
  2110             }
       
  2111         if( connErr != KErrNone )
       
  2112             {
       
  2113             CLOG_WRITE( "Closing all" );
       
  2114             iConnection.Close();
       
  2115             }
  2165             }
  2116 		}
  2166 		}
  2117 	
  2167 	
  2118 	CleanupStack::PopAndDestroy();//overrides
  2168 	CleanupStack::PopAndDestroy();//overrides
  2119     iInternalError = connErr;
  2169     iInternalError = connErr;
  2152         {
  2202         {
  2153         iWaitDialog->SetTextL( aLabel->Des() );
  2203         iWaitDialog->SetTextL( aLabel->Des() );
  2154         }
  2204         }
  2155     iWaitDialog->RunLD();
  2205     iWaitDialog->RunLD();
  2156     }
  2206     }
       
  2207 
       
  2208 //-------------------------------------------------------------------
       
  2209 //CInternetConnectionManager::SetOccPreferences
       
  2210 //-------------------------------------------------------------------
       
  2211 
       
  2212 void CInternetConnectionManager::SetOccPreferences( TSetOCCPreferences aOCCPreferences)
       
  2213     {
       
  2214     if( iSyncConnector )
       
  2215        iSyncConnector->SetOccPreferences(aOCCPreferences);
       
  2216     }
  2157     
  2217     
  2158 // End of File
  2218 // End of File