void
CConnectionManager::OpenLinkLayerConnectionL()
{
#ifdef USE_RCONNECTION
   User::LeaveIfError(iSocketServ->Connect());
   User::LeaveIfError(iConnection->Open(*iSocketServ));
   TCommDbConnPref prefs = TCommDbConnPref();

   if (iIAP >= 0) {
      prefs.SetIapId(iIAP);
      prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
      iConnection->Start(prefs, iStatus);
   } else if (iIAP == -2) {
      // Debug mode - use system default
      iConnection->Start(iStatus);
   } else {
      // Use Always ask
      prefs.SetDialogPreference(ECommDbDialogPrefPrompt);
      prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
# ifdef NAV2_CLIENT_SERIES60_V2
      prefs.SetBearerSet( EApBearerTypeGPRS | EApBearerTypeHSCSD );
# else //s80, s90
      prefs.SetBearerSet( ECommDbBearerCSD | ECommDbBearerWcdma |
            ECommDbBearerCdma2000 | ECommDbBearerPSD );

# endif
      iConnection->Start(prefs, iStatus);
   }
   SetActive();

#endif
}
void UT_CNATFWUNSAFServerQuery::SetupL()
    {
    iResultArray = new (ELeave) RArray<TInetAddr>;
    User::LeaveIfError(iServer.Connect(KESockDefaultMessageSlots));
    User::LeaveIfError(iConnection.Open(iServer, KConnectionTypeDefault));
    TCommDbConnPref prefs;
    prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
    prefs.SetIapId(10);
    User::LeaveIfError(iConnection.Start(prefs));

    iHostResolver = CNATFWUNSAFHostResolver::NewL(iServer, iConnection);

    iObserver = UT_CNATFWUNSAFServerResolverObserverStub::NewL();
    CNATFWUNSAFQueryData* query = CNATFWUNSAFQueryData::NewL(
                               iObserver,
                               5060,
                               _L8("udp"),
                               _L8("testi.net"),
                               _L8("stun"),
                               *iHostResolver,
                               *iResultArray );
    CleanupStack::PushL(query);
    iServerQuery = CNATFWUNSAFServerQuery::NewL( iObserver, query );
    CleanupStack::Pop( query );
    }
void UT_CNATFWUNSAFUdpSender::SetupL()
    {
    User::LeaveIfError( iServer.Connect( 8 ) );
    User::LeaveIfError( iConn.Open( iServer, KConnectionTypeDefault ) );

    TCommDbConnPref prefs;
    prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
    prefs.SetDirection( ECommDbConnectionDirectionOutgoing );
    prefs.SetIapId(10);
    User::LeaveIfError( iConn.Start( prefs ) );

    User::LeaveIfError( iSocket.Open( iServer,
                                      KAfInet,
                                      KSockDatagram,
                                      KProtocolInetUdp,
                                      iConn ) );

    iMsg = NATFWUNSAFTransportTestUtils::CreateUNSAFBindingRequestL();

    iAddr = TInetAddr( INET_ADDR( 127, 0, 0, 1 ) );

    iSender = CNATFWUNSAFUdpSender::NewL( iSocket, *this );

    iIsMsgSent = EFalse;
    }
TInt CResourceManager::SetIap(TUint32 aIapId, TBool aIsWap)
{
    m_bUseOutNetSettting = false;

    m_socketServ.Connect();
    m_connection.Open(m_socketServ);

    m_iapId = aIapId;
    m_isWap = aIsWap;

    TInt err = KErrNone;

    // Now we have the iap Id. Use it to connect for the connection.
    // Create a connection preference variable.
    TCommDbConnPref connectPref;

    // setup preferences 
    connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
    connectPref.SetBearerSet(ECommDbBearerGPRS | ECommDbBearerWLAN | ECommDbBearerLAN);
    //Sets the CommDb ID of the IAP to use for this connection
    connectPref.SetIapId(aIapId);

    err = m_connection.Start(connectPref);

    if (err == KErrNone) {
        m_IAPSeted = true;
        m_IAPReady = true;
        ResendRequest();
    }

    return err;
}
void UT_CRtpComm::SetupL(  )
    {
	iTimer = CPeriodic::NewL( EPriorityNormal );
	iErr=0;
	TCommDbConnPref prefs;
    prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );	
	prefs.SetDirection( ECommDbConnectionDirectionOutgoing );
    prefs.SetIapId( KDefaultIap );//6
	
    
    TInt err( KErrCouldNotConnect );
        
    // Opens a session to the socket server
    // i.e. creates an IPC communication channel to the socket server
    if ( ( err = iSocketServ.Connect() ) != KErrNone )
    	{
    	EUNIT_ASSERT( err==KErrNone );
    	}
    // Opens a new RConnection instance
    else if (( err = iConnection.Open( iSocketServ )) != KErrNone )
       	{
		iConnection.Close(); 
		EUNIT_ASSERT( err==KErrNone );
        }
    else if (( err = iConnection.Start( prefs )) != KErrNone )
        {	
        iConnection.Close();
        EUNIT_ASSERT( err==KErrNone );
        }
    }
// -----------------------------------------------------------------------------
// CSIPExSocketEngine::StartInterfaceL
// Activates PDP ctx
// -----------------------------------------------------------------------------
//
void CSIPExSocketEngine::StartInterfaceL( const TUint32 aIapId )
    {
    if( !iConnection.SubSessionHandle() )
        { 
        User::LeaveIfError( iConnection.Open( iSocketServer ) );
        }

    TCommDbConnPref prefs;
    prefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
    prefs.SetDirection( ECommDbConnectionDirectionOutgoing );
    prefs.SetIapId( aIapId );

    User::LeaveIfError( iConnection.Start( prefs ) );
    }
void UT_CNATFWUNSAFServerResolver::SetupL()
    {
    iResultArray = new (ELeave) RArray<TInetAddr>;
    User::LeaveIfError(iServer.Connect(KESockDefaultMessageSlots));
    User::LeaveIfError(iConnection.Open(iServer, KConnectionTypeDefault));
    TCommDbConnPref prefs;
    prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
    prefs.SetIapId(10);
    User::LeaveIfError(iConnection.Start(prefs));
    iObserver = UT_CNATFWUNSAFServerResolverObserverStub::NewL();
    iServerResolver = CNATFWUNSAFServerResolver::NewL(iServer,
                                                        iConnection,
                                                      *iObserver,
                                                      EFalse);

    }
/**
 * Connect to the network using this IAP ID
 */
TInt CRconn::Start(TUint32 aIapId, TBool aPrompt)
{
	DEBUG_INFO("CRconn::Start: IAP id %u\n", aIapId);

	Cancel();

	TCommDbConnPref prefs;
	prefs.SetIapId(aIapId);
	if (aPrompt)
		prefs.SetDialogPreference(ECommDbDialogPrefPrompt);
	else
		prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	prefs.SetDirection(ECommDbConnectionDirectionOutgoing);

	iConn.Start(prefs, iStatus);
	SetActive();

	return 0;
}
void UT_CNATTraversalController::SetupL()
    {
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    TCommDbConnPref prefs;
    prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
    prefs.SetIapId(KIapId);
    User::LeaveIfError(iConnection.Start(prefs));
    User::LeaveIfError(iSocket.Open(iSocketServ,
                                    KAfInet,
                                    KSockDatagram,
                                    KProtocolInetUdp,
                                    iConnection));

    User::LeaveIfError(iLocalAddr.Input(KLocalAddr));
    User::LeaveIfError(iNextHopAddr.Input(KNextHopAddr));

    TSIPNATTraversalControllerInitParams initParams(iSocketServ);
    iController = CNATTraversalController::NewL(&initParams);
    }
void CommonSocketConnection::SetupConnectionL()
{
	iSocketServ.Connect();
	iSocketServ.ShareAuto();
	iConnection.Open(iSocketServ);
	iStatus = KRequestPending;
	TCommDbConnPref pref;	
	pref.SetDirection(ECommDbConnectionDirectionOutgoing);
	if(iAccessPointId!=INVALID_IAPID)
	{
		pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);	
		pref.SetIapId(iAccessPointId);  
		iConnection.Start(pref,iStatus);		
	}
	else
	{
	    //SetDefaultIap(0); //cmnet
		pref.SetDialogPreference(ECommDbDialogPrefPrompt);	
		iConnection.Start(pref,iStatus); 		
	}
	iConnectionState = EConnecting;
	SetActive();
}
void FConnection::ConstructL()
{
    iLastError = KErrNone;
    StringBuffer errMsg;
    TCommDbConnPref prefs;

    // Connect SocketServer session
    iLastError = iSession.Connect();
    if (iLastError != KErrNone) {
        errMsg.sprintf("FConnection error: unable to connect SocketServ (code %d)", iLastError);
        goto error;
    }

    // *Note*: THIS IS MANDATORY TO USE THE SAME SESSION FROM DIFFERENT THREADS!
    // After calling this function the RSocketServ object
    // may be used by threads other than than the one that created it.
    iLastError = iSession.ShareAuto();
    if (iLastError != KErrNone) {
        errMsg.sprintf("FConnection error: unable to share SocketServ (code %d)", iLastError);
        goto error;
    }

    //
    // Default preferences: no prompt, just to initialize the connection object
    //
    prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    prefs.SetDirection(ECommDbConnectionDirectionUnknown);
    prefs.SetIapId(0);

    // Opens the connection
    openConnection();

    return;

error:
    LOG.error("%s", errMsg.c_str());
}
TBool CConnectionManager::SetupConnection()
	{
		TInt iCurrentProfileId;    
		iBearerFilter = EApBearerTypeAllBearers;

		ASSERT(iRepository);

		// Check whether we are offline or online
		iRepository->Get(KProEngActiveProfile, iCurrentProfileId);
		
	    // Close the connection only if
	    // a) this is not the first time and
	    // b) the profile has changed and
	    // c) either the previous or the current profile is Offline (5 = Offline)
	    if (iPreviousProfileId != -1 && iPreviousProfileId != iCurrentProfileId &&
	            (iPreviousProfileId == EConnectionStatus::Disconnected || iCurrentProfileId == EConnectionStatus::Disconnected))
	    {
	        // Close and uninitialize
	        iConnectionSetup = EFalse;
	        iSessionHttp .Close();
	        iConnection  .Close();
	        iServerSocket.Close();
	    }

	    // Save current profile id
	    iPreviousProfileId = iCurrentProfileId;

	    // Try to find an existing connection. If connection has not been set up,
	    // iConnection is not initialized and FindExistingConnection() fails.
	    // Thus, in that case, finding must not be carried out.
	    if (iConnectionSetup && !FindExistingConnection())
	    {
	        iConnectionSetup = EFalse;
	    }

	    if (iConnectionSetup)
	    {
	        // Connection setup is done
	    	iNewConnection = EFalse;
	        return ETrue;
	    }

	    // Open RHTTPSession with default protocol ("HTTP/TCP")
	    iSessionHttp.OpenL();

	    // Install this class as the callback for authentication requests. When
	    // page requires authentication the framework calls GetCredentialsL to get
	    // user name and password.
	    InstallAuthenticationL(iSessionHttp);

	    // In offline, only WLAN connections are available
	    if (iCurrentProfileId == EConnectionStatus::Disconnected)
	    {
	        iBearerFilter = EApBearerTypeWLAN;
	    }

	    // Show IAP selection dialog
	    /*CActiveApDb* aDb = CActiveApDb::NewL();
	    CleanupStack::PushL(aDb);

	    CApSettingsHandler* settings = CApSettingsHandler::NewLC
	        (
	           *aDb
	         , ETrue
	         , EApSettingsSelListIsPopUp
	         , EApSettingsSelMenuSelectNormal
	         , KEApIspTypeAll
	         , iBearerFilter
	         , KEApSortNameAscending
	         , 0
	         , EVpnFilterBoth
	         , ETrue
	        );

	    TInt iapRet = settings->RunSettingsL(0, iSelectedConnectionId);
	    CleanupStack::PopAndDestroy(settings);
	    CleanupStack::PopAndDestroy(aDb);

	    if (iapRet != KApUiEventSelected)
	    {
	        // Exit no selection
	        User::Leave(KErrNotReady);
	    }
	    else*/

	    // open the IAP communications database 
		CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
		CleanupStack::PushL(commDB);

		// initialize a view 
		CCommsDbConnectionPrefTableView* commDBView = 
		commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);

		// go to the first record 
		User::LeaveIfError(commDBView->GotoFirstRecord());

		CCommsDbConnectionPrefTableView::TCommDbIapBearer bearer;
		bearer.iBearerSet = iBearerFilter;
		
		// Declare a prefTableView Object.
		CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;

		pref.iBearer = bearer;
		pref.iDirection = ECommDbConnectionDirectionOutgoing;
		
		// read the connection preferences 
		commDBView->ReadConnectionPreferenceL(pref);

		iSelectedConnectionId = pref.iBearer.iIapId; 
		
		// pop and destroy the IAP View 
		CleanupStack::PopAndDestroy(commDBView);

		// pop and destroy the database object
		CleanupStack::PopAndDestroy(commDB);

    	iNewConnection = ETrue;
    	
        // IAP Selected
        // Open socket server and start the connection
        User::LeaveIfError(iServerSocket.Connect(KESockDefaultMessageSlots));
        User::LeaveIfError(iConnection.Open(iServerSocket, KConnectionTypeDefault));
        // Now we have the iap Id. Use it to connect for the connection
        TCommDbConnPref connectPref;
        // Setup preferences 
        connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
        // Sets the CommDb ID of the IAP to use for this connection
        connectPref.SetIapId(iSelectedConnectionId);
        // Sets direction
        connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
        
        connectPref.SetBearerSet(iBearerFilter);
        
        // Start connection
        User::LeaveIfError(iConnection.Start(connectPref));
        
        //TInt retval = iConnection.Start();
        //User::LeaveIfError(retval);
	        
        // Set the sessions connection info...
        RStringPool strPool = iSessionHttp.StringPool();
        RHTTPConnectionInfo connInfo = iSessionHttp.ConnectionInfo();
        // ...to use our socket server and connection
        connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal (iServerSocket.Handle()));
        // ...to use our connection
        connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))));

        iConnectionSetup = ETrue;
	
	    return ETrue;
}
Exemple #13
0
// ----------------------------------------------------------------------------
// CClientEngine::SetupConnectionL()
//
// The method set the internet access point and connection setups.
// ----------------------------------------------------------------------------	
void CClientEngine::SetupConnectionL()
    {
    if( iConnectionSetupDone )
        return;
    
    iConnectionSetupDone = ETrue;
    //open socket server and start the connection
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    
    TCommDbConnPref connectPref;
    TUint32 iapID;

    if(iSetIap == EFalse)
	{
    // open the IAP communications database 
	CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(commDB);

	// initialize a view 
	CCommsDbConnectionPrefTableView* commDBView = 
	commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);

	// go to the first record 
	User::LeaveIfError(commDBView->GotoFirstRecord());

	// Declare a prefTableView Object.
	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
	// read the connection preferences 
	commDBView->ReadConnectionPreferenceL(pref);

	iapID = pref.iBearer.iIapId;

	// pop and destroy the IAP View 
	CleanupStack::PopAndDestroy(commDBView);

	// pop and destroy the database object
	CleanupStack::PopAndDestroy(commDB);

	// setup preferences 
	connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
	connectPref.SetBearerSet(ECommDbBearerGPRS);
	//Sets the CommDb ID of the IAP to use for this connection
	connectPref.SetIapId(iapID);
	}else{
	connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
	connectPref.SetBearerSet(ECommDbBearerGPRS);
	//Sets the CommDb ID of the IAP to use for this connection
	connectPref.SetIapId(iIapId);
	}
    
    User::LeaveIfError(iConnection.Start(connectPref));
	
    //set the sessions connection info
    RStringPool strPool = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    
    //to use our socket server and connection
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,
        RHTTPSession::GetTable() ), THTTPHdrVal (iSocketServ.Handle()) );

    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,
        RHTTPSession::GetTable() ), 
        THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))) );
    }
const int FConnection::startConnection(const StringBuffer& aIAPName)
{
    LOG.info("Starting new connection...");
    LOG.debug("Looking for '%s' IAP name", aIAPName.c_str());

    iLastError = KErrNone;
    StringBuffer errMsg;
    TCommDbConnPref prefs;

    prefs.SetDirection(ECommDbConnectionDirectionUnknown);


    if (aIAPName == "Default") {
        //
        // Use the default IAP without prompting the user
        //
        prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
        prefs.SetIapId(0);
    }
    else if (aIAPName.empty() || aIAPName == "Ask") {
        //
        // Prompt user for IAP selection
        //
    }
    else {
        //
        // Search for the desired IAP. If not found, will prompt the user.
        //
        TInt iapID = GetIAPIDFromName(aIAPName);
        if (iapID >= 0) {
            LOG.debug("SetDialogPreference");
            prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
            prefs.SetIapId(iapID);
        }
        else {
            LOG.debug("IAP '%s' not found!", aIAPName.c_str());
        }
    }


/*
 * **** TODO: check if we need this! ****
 In S60 3rd Edition, enabling/disabling the inactivity timer will require
 the NetworkControl capability, which is only accessed via Symbian
 partner.
 */
//#if !defined(__SERIES60_3X__) || defined(__S60_3X_NET_CTRL__)
//    // Disable inactivity timer, otherwise inactive connection is closed
//    // within few seconds if there are no activity (e.g sockets)
//    iConnection.SetOpt(KCOLProvider, KConnDisableTimers, ETrue);
//#endif


    // Opens the connection
    openConnection();

    // Start connection
    iLastError = iConnection.Start(prefs);
    if (iLastError != KErrNone) {
        errMsg.sprintf("FConnection error: unable to start connection (code %d)", iLastError);
        LOG.debug("Goto retry");
        goto retry;
    }

    // Save the IAP ID & name of the active connection.
    // Query the CommDb database for the IAP ID in use.
    _LIT(KIAPSettingName, "IAP\\Id");
    iConnection.GetIntSetting(KIAPSettingName, iIAP);
    iIAPName = GetIAPNameFromID(iIAP);
    LOG.debug("Current active IAP ID = %d, name = '%s'", iIAP, iIAPName.c_str());
    //
    // TODO: should we persist the iIAPName in the config, here?
    //

    iRetryConnection = 0;
    return 0;


retry:

    LOG.error("%s", errMsg.c_str());

    if (iIAPName.empty() || iIAPName == "Ask") {
        LOG.debug("Connection error and no IAP stored: don't retry");
        return iLastError;
    }

    LOG.debug("About to retry...");
    if (iRetryConnection < MAX_RETRY_CONNECTION) {
        iRetryConnection ++;
        LOG.info("Retry connection (%d time)...", iRetryConnection);
        startConnection(iIAPName);
    }
    else {
        LOG.error("FConnection: %d connection failed", iRetryConnection);
    }
    return iLastError;
}
Exemple #15
0
TBool CConnectionManager::SetupConnection()
	{
		TInt iCurrentProfileId;    
		iBearerFilter = EApBearerTypeAllBearers;

		ASSERT(iRepository);

		// Check whether we are offline or online
		iRepository->Get(KProEngActiveProfile, iCurrentProfileId);
		
	    // Close the connection only if
	    // a) this is not the first time and
	    // b) the profile has changed and
	    // c) either the previous or the current profile is Offline (5 = Offline)
	    if (iPreviousProfileId != -1 && iPreviousProfileId != iCurrentProfileId &&
	            (iPreviousProfileId == EConnectionStatus::Disconnected || iCurrentProfileId == EConnectionStatus::Disconnected))
	    {
	        // Close and uninitialize
	        iConnectionSetup = EFalse;
	        iSessionHttp .Close();
	        iConnection  .Close();
	        iServerSocket.Close();
	    }

	    // Save current profile id
	    iPreviousProfileId = iCurrentProfileId;

	    // Try to find an existing connection. If connection has not been set up,
	    // iConnection is not initialized and FindExistingConnection() fails.
	    // Thus, in that case, finding must not be carried out.
	    if (iConnectionSetup && !FindExistingConnection())
	    {
	        iConnectionSetup = EFalse;
	    }

	    if (iConnectionSetup)
	    {
	        // Connection setup is done
	    	iNewConnection = EFalse;
	        return ETrue;
	    }

	    // Open RHTTPSession with default protocol ("HTTP/TCP")
	    iSessionHttp.OpenL();

	    // Install this class as the callback for authentication requests. When
	    // page requires authentication the framework calls GetCredentialsL to get
	    // user name and password.
	    InstallAuthenticationL(iSessionHttp);

	    // In offline, only WLAN connections are available
	    if (iCurrentProfileId == EConnectionStatus::Disconnected)
	    {
	        iBearerFilter = EApBearerTypeWLAN;
	    }


	    // Show IAP selection dialog
	    if ( gSelectedConnectionId == -1 )
	    	gSelectedConnectionId = SelectIAP();
	    
	    iSelectedConnectionId =  gSelectedConnectionId;
	    
    	iNewConnection = ETrue;
    	
        // IAP Selected
        // Open socket server and start the connection
        User::LeaveIfError(iServerSocket.Connect(KESockDefaultMessageSlots));
        User::LeaveIfError(iConnection.Open(iServerSocket, KConnectionTypeDefault));
        // Now we have the iap Id. Use it to connect for the connection
        TCommDbConnPref connectPref;
		// Setup preferences 
		connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
		
		// Sets the CommDb ID of the IAP to use for this connection
        connectPref.SetIapId(iSelectedConnectionId);
        // Sets direction
        connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
        
        connectPref.SetBearerSet(iBearerFilter);
        
        // Start connection
        User::LeaveIfError(iConnection.Start(connectPref));
        
        //TInt retval = iConnection.Start();
        //User::LeaveIfError(retval);
	        
        // Set the sessions connection info...
        RStringPool strPool = iSessionHttp.StringPool();
        RHTTPConnectionInfo connInfo = iSessionHttp.ConnectionInfo();
        // ...to use our socket server and connection
        connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal (iServerSocket.Handle()));
        // ...to use our connection
        connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))));

        iConnectionSetup = ETrue;
	
	    return ETrue;
}
TVerdict CTestConnectStep::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Demonstrates reading configuration parameters fom an ini file section
 */
	{
	if(TestStepResult()==EPass)
		{
		INFO_PRINTF1(_L("In Test Step ConnectWithOverrides"));
		// When bootstrapping C32 we have to avoid the PhBkSyncServer being started, since
 		// it needs a different CommDB
		TInt ret = StartC32WithCMISuppressions(KPhbkSyncCMI);
		
		if((ret!=KErrNone) && (ret!=KErrAlreadyExists))
			{
			INFO_PRINTF2(_L("error is : %d \n"),ret);
			}
		else
			{
			INFO_PRINTF1(_L("Started C32\n"));
			}

		RHostResolver hr;

		INFO_PRINTF1(_L("Connect to RSocketServ"));			
		User::LeaveIfError(iSocketServ.Connect());

		// Set up the connections, both overridden as host resolver won't work 
		// on the default interface
		INFO_PRINTF1(_L("Open the RConnection interface"));			
		User::LeaveIfError(iConnection.Open(iSocketServ));

		// get the IapNumber value from the ini file
		if(!GetIntFromConfig(ConfigSection(), KIapNumber, iIapNumber))
			{
			if(!GetIntFromConfig(KIap, KIapNumber, iIapNumber))
				{
				iIapNumber=1;
				INFO_PRINTF1(_L("Failed to read Iap from ini file, using default"));
				}
			}
		INFO_PRINTF2((_L("IapNumber = %d")), iIapNumber);

		TRequestStatus status;
#ifdef SIROCCO_CODE_MIGRATION
	TCommDbConnPref prefs;
	prefs.SetIapId(iIapNumber);
	prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
		const TUid KMyPropertyCat = {0x101FD9C5};
        const TUint32 KMyPropertyDestPortv4 = 67;
        TInt err = RProperty::Define(KMyPropertyCat, KMyPropertyDestPortv4, RProperty::EInt, TSecurityPolicy(TSecurityPolicy::EAlwaysPass),
		     TSecurityPolicy(ECapabilityWriteDeviceData));
        User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv4, 93));
#else

		TInt rank = 1;

		// Create a multiple connection preference object
		TCommDbMultiConnPref prefs;

		for(TInt i=0;i<iapCount;i++)
			{
			TCommDbConnPref pref;
			// Set the direction
			pref.SetDirection(ECommDbConnectionDirectionOutgoing);
			// Set the bear ser
			pref.SetBearerSet(KCommDbBearerPSD | KCommDbBearerCSD);
			// Set the IAP
			pref.SetIapId(iIapNumber + i);
			// Set the dialog preference to Do Not Prompt
			pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
			// Set the rank
			User::LeaveIfError(prefs.SetPreference(rank, pref));

			rank++;
			}

		prefs.SetConnectionAttempts(rank-1);
#endif 

		// Start the connection
		iConnection.Start(prefs, status);

		
		User::WaitForRequest(status);

		TInt result = status.Int();

		if(result!=KErrNone)
			{
			ERR_PRINTF2(_L("Failed to start connection. Error %d"), result);
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		else
			{
			INFO_PRINTF1(_L("Connection started with overrides"));
			}

		// Set up the host resolver
		INFO_PRINTF1(_L("Initialise a host resolver service"));			
		User::LeaveIfError(hr.Open(iSocketServ, KAfInet, KProtocolInetTcp, iConnection));
		CleanupClosePushL(hr);


		// Test the interfaces conn, host resolution should work ok
		TBuf<64> hostname;
		TRequestStatus status1;
		TNameEntry nameEntry;

		TPtrC temphost;
		if(GetStringFromConfig(KTCPConfig, KHostName, temphost))
			{
			INFO_PRINTF2(_L("Hostname is : %S"), &temphost);
			}
		else
			{
			ERR_PRINTF1(_L("No hostname"));
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		hostname = temphost;

		hr.GetByName(hostname, nameEntry, status1);
		User::WaitForRequest(status1);

		TInt result1 = status1.Int();

		if(result1!=KErrNone)
			{
			ERR_PRINTF2(_L("Failed to resolve the name. Error %d"), result1);
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		else
			{
			INFO_PRINTF1(_L("Resolved the name successfully"));
			}

		// open socket
		INFO_PRINTF1(_L("Open the socket"));			
		User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp, iConnection));
		CleanupClosePushL(iSocket);

		// print the host resolver's ip address
		TInetAddr inetAddr;
		inetAddr = TInetAddr(nameEntry().iAddr);
		TBuf<50> addr;
		inetAddr.Output(addr);
		INFO_PRINTF2(_L("The host resolver's ip address is: %S"), &addr);
		
		// get the port number from the ini file
		if(!GetIntFromConfig(KTCPConfig, KPort, iPort))
			{
			ERR_PRINTF1(_L("Failed to read Port from ini file"));
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		INFO_PRINTF2((_L("Port = %d")), iPort);

		// connect to the socket
		inetAddr.SetPort(iPort);
		//nameEntry().iAddr.SetPort(iPort);
		TRequestStatus status2;
		//iSocket.Connect(nameEntry().iAddr,status2);
		iSocket.Connect(inetAddr,status2);
		User::WaitForRequest(status2);

		TInt result2 = status2.Int();

		if(result2!=KErrNone)
			{
			ERR_PRINTF2(_L("Failed to connect to the socket. Error %d"), result2);
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		else
			{
			INFO_PRINTF1(_L("Connect to the socket successfully"));
			}


		TPtrC ptrDNSName;
		if(GetStringFromConfig(KTCPConfig, KDNSName, ptrDNSName))
			{
			INFO_PRINTF2(_L("DNSName is : %S"), &ptrDNSName);
			}
		else
			{
			ERR_PRINTF1(_L("No DNSName"));
			SetTestStepResult(EFail);
			User::Leave(EFail);
			}
		TBuf8<256>	bufDnsName;
		bufDnsName.Copy(ptrDNSName);

		// connect to the secure socket
		CTestSecureSocket* iTestSecureSocket = CTestSecureSocket::NewL(*this, iSocket, bufDnsName);
		CleanupStack::PushL(iTestSecureSocket);
		iTestSecureSocket->StartHandshake();
		CActiveScheduler::Start();

		CleanupStack::PopAndDestroy(3); //iTestSecureSocket, iSocket, hr
		}
	
	return TestStepResult();
	}