// ------------------------------------------------------------------------------------------------
// CHttpFilterConnHandler::MHFRunL
// Process a transaction event.
// ------------------------------------------------------------------------------------------------
//
void CHttpFilterConnHandler::MHFRunL(RHTTPTransaction aTransaction,
                                     const THTTPEvent& aEvent)
{
    TInt state = 0;
    TInt gprsState = 0;
    TInt wcdmaState = 0;
    TApBearerType bearerType;

    if (aEvent.iStatus == THTTPEvent::ESubmit)
    {
        THTTPHdrVal isNewConn;
        RHTTPConnectionInfo	connInfo = iSession->ConnectionInfo();
        RStringPool strPool = aTransaction.Session().StringPool();
        TBool ret = connInfo.Property (strPool.StringF(HttpFilterCommonStringsExt::EHttpNewConnFlag,
                                       HttpFilterCommonStringsExt::GetTable()), isNewConn);

        if ( LocalHostCheckL(aTransaction) && !( ret && isNewConn.Type() == THTTPHdrVal::KTIntVal ) )
            {
            return;
            }

        THTTPHdrVal callback;
        RHTTPTransactionPropertySet propSet = aTransaction.PropertySet();
        RStringF callbackStr = strPool.StringF( HttpFilterCommonStringsExt::EConnectionCallback, 
            HttpFilterCommonStringsExt::GetTable() );

        MConnectionCallback* callbackPtr = NULL;
    
        // this is a transaction, already forwarded to download manager
        if( propSet.Property( callbackStr, callback ) )
        {
            callbackPtr = REINTERPRET_CAST( MConnectionCallback*, callback.Int() );
        }        
Esempio n. 2
0
void CHttpTestCaseGet12::LogConnectionProperties()
	{
	RHTTPConnectionInfo	connectionInfo = iSession.ConnectionInfo();
	RStringPool stringPool = iSession.StringPool();
	THTTPHdrVal value;
	TBool hasValue = connectionInfo.Property (stringPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), value);
	if (hasValue)
		{
		RConnection* conn = REINTERPRET_CAST(RConnection*, value.Int());
		TUint count;
		//get the no of active connections
		TInt err = conn->EnumerateConnections(count);
		if(err==KErrNone)
			{
			for (TUint i=1; i<=count; ++i)
				{
				TPckgBuf<TConnectionInfo> connInfo;
				conn->GetConnectionInfo(i, connInfo);
				iEngine->Utils().LogIt(_L("Connection %d: IapId=%d, NetId=%d\n"),i, connInfo().iIapId, connInfo().iNetId);
				}
			}
		else
			{
			iEngine->Utils().LogIt(_L("Unable to enumerate number of connections, Error: %d"), err);
			}
		}
	}
void CPipeliningConfigTest::CheckAndSetSessionSettingsL(RHTTPSession aSession)
{
    RStringPool stringPool = aSession.StringPool();
    RHTTPConnectionInfo sessionSettings = aSession.ConnectionInfo();

    if (iMaxNumberTransactionsToPipeline > 0)
    {
        RStringF maxToPipelineSetting = stringPool.StringF(HTTP::EMaxNumTransactionsToPipeline,
                                        aSession.GetTable());
        THTTPHdrVal value;
        if (sessionSettings.Property(maxToPipelineSetting, value) == EFalse)
        {
            value.SetInt(iMaxNumberTransactionsToPipeline);
            sessionSettings.SetPropertyL(maxToPipelineSetting,value);
        }
    }


    if (iMaxNumberTransportHandlers > 0)
    {
        RStringF maxTransportHandlers = stringPool.StringF(HTTP::EMaxNumTransportHandlers,
                                        aSession.GetTable());
        THTTPHdrVal value;
        if (sessionSettings.Property(maxTransportHandlers, value) == EFalse)
        {
            value.SetInt(iMaxNumberTransportHandlers);
            sessionSettings.SetPropertyL(maxTransportHandlers,value);
        }
    }
}
Esempio n. 4
0
AMInt32 SetSessionConnectionInfo(AMPVoid session)
	{
	REINTERPRET( RHTTPSession*, temp, session );
    // Set the sessions connection info...
    RStringPool strPool = temp->StringPool();
    RHTTPConnectionInfo connInfo = temp->ConnectionInfo();
    
    REINTERPRET( CNetworkAccessPoint*, NetworkAccessPoint, AMSocketIAPGet() );
    
    // ...to use our socket server and connection
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,
        RHTTPSession::GetTable() ), THTTPHdrVal (NetworkAccessPoint->GetRSocketServ().Handle()) );
    // ...to use our connection
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,
        RHTTPSession::GetTable() ), 
        THTTPHdrVal (REINTERPRET_CAST(TInt, &(NetworkAccessPoint->GetRConnection()))) );
	}
// -----------------------------------------------------------------------------
// CHttpConnHandler::SetConnectionInfoL
// ?implementation_description
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CHttpConnHandler::SetConnectionInfoL()
    {
    RStringPool strPool = iHttpSession.StringPool();

    // Remove first session properties just in case.
    RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
    
    // Clear RConnection and Socket Server instances
    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable()));
    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable()));
    
    // Clear the proxy settings
//    THTTPHdrVal proxyUsage(strPool.StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()));
    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()));
    
    // RConnection and Socket Server
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ, 
                                    RHTTPSession::GetTable()), 
                            THTTPHdrVal (iClientApp->Engine()->SocketServ().Handle()) );
    
    TInt connPtr1 = REINTERPRET_CAST(TInt, &iConnection);
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection, 
                            RHTTPSession::GetTable() ), THTTPHdrVal (connPtr1) );    
    }
Esempio n. 6
0
RHTTPTransaction CTestCase21::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient)
	{
	__ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant());
	
	RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable());
	_LIT8(KTxtUri, "http://127.0.0.1");
	TUriParser8 uri; 
	uri.Parse(KTxtUri());
	
	// Buffer size needs to be reduced in the session property before the first transaction.
	if( aIndex == 0 )
		{
		RHTTPConnectionInfo connInfo = aSession.ConnectionInfo();
		connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), KBufferSize);
		}
		
	return aSession.OpenTransactionL(uri, aClient, method);
	}
void UPPayHttpConnection::SetupConnectionL()
{
	//		iTimer.After(iStatus,10); 
	//		SetActive();
	if ( iSocketConnection->OpenConnection())
	{
#ifdef F_ENCODE_URI
		if(iUriParser->Uri().Validate())
#else
		if (iUriParser.Validate())
#endif
		{
			RStringPool strPool = iSession.StringPool();
			RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
			TInt err = 0;
			//to use our socket server and connection
			TRAP(err,connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()),
					THTTPHdrVal(iSocketConnection->iSocketServ.Handle())));
			if (!err)
			{
				TRAP(err,connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()),
						THTTPHdrVal(REINTERPRET_CAST(TInt, &(iSocketConnection->iConnection)))));
				if (!err)
				{
					TRAP(err,openConnection());
					if (!err)
					{
						return;
					}
					else
					{
						//CommonUtils::WriteLogL(_L("openConnection() false err = "), err);
					}
				}
			}

		}
	}
	//CommonUtils::WriteLogL(_L("OpenConnection false "), _L("EHttpError"));
	if (iObserver)
	{
		iObserver->StateChange(EHttpError);
	}
}
Esempio n. 8
0
RHTTPTransaction CTestCase9::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient)
	{
	__ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant());
	
	// Change the session properties to be a HTTP/1.0 client
	if( aIndex == 0 )
		{
		RHTTPConnectionInfo connInfo = aSession.ConnectionInfo();
		RStringPool strPool = aSession.StringPool();
		THTTPHdrVal http10( strPool.StringF( HTTP::EHttp10, RHTTPSession::GetTable() ) );
		connInfo.SetPropertyL( strPool.StringF( HTTP::EHTTPVersion,RHTTPSession::GetTable() ), http10 );
		}

	RStringF method = aSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable());
	_LIT8(KTxtUri, "http://127.0.0.1");
	TUriParser8 uri; 
	uri.Parse(KTxtUri());
	return aSession.OpenTransactionL(uri, aClient, method);
	}
/**
	Set HTTP proxy information for the session.
	
	@param aProxyAddr [in] Proxy address to set for the session
 */	
void CTestWebBrowser::SetProxyL ( const TDesC8& aProxyAddr )
	{
	
	RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
	
	// Set the proxy usage property.
	THTTPHdrVal proxyUsage( iHttpSession.StringPool().StringF( HTTP::EUseProxy, RHTTPSession::GetTable() ) );
	connInfo.SetPropertyL( iHttpSession.StringPool().StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), proxyUsage );
	
	RStringF proxyAddr = iHttpSession.StringPool ().OpenFStringL ( aProxyAddr );
	CleanupClosePushL ( proxyAddr );
	
	// Set the proxy address property.
	THTTPHdrVal proxyAddrHdr( proxyAddr );
    connInfo.SetPropertyL( iHttpSession.StringPool().StringF( HTTP::EProxyAddress, RHTTPSession::GetTable() ), proxyAddrHdr );
    
    CleanupStack::PopAndDestroy (); // Pop and destroy proxyAddr
	return;		
	}
/**
 * CSymbianTransportAgent::ConstructL()
 * Second phase construction.
 */
void CSymbianTransportAgent::ConstructL(URL& /* aUrl */)
{
    
    // Open RHTTPSession with default protocol ("HTTP/TCP")
    // Note that RHTTPSession (and consequently the whole 
    // of HTTP) depends on the active scheduler; a scheduler 
    // must be installed when the session is opened and it 
    // must be running if a transaction is actually to do anything. 
    
    // Get the connection manager instance
    FConnection* connection = FConnection::getInstance();
    if (!connection) {
        LOG.error("TransportAgent: no active connection; exiting");
        setError(ERR_HTTP, "No active connection");
        return;
    }
    
    // Session is owned by FConnection!
    RSocketServ* socketServ = connection->getSession();
    RConnection* rConnection = connection->getConnection();
    // reuse active connection, please see:
    // http://wiki.forum.nokia.com/index.php/CS000825_-_Using_an_already_active_connection
    TInt err;
    TRAP( err, iHttpSession.OpenL() );
    User::LeaveIfError( err );

    // Set the session's connection info...
    RStringPool strPool = iHttpSession.StringPool();
    RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
    // ...to use the socket server
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable() ),
                            THTTPHdrVal (socketServ->Handle()) );
    // ...to use the connection
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable() ),
                            THTTPHdrVal (REINTERPRET_CAST(TInt, rConnection)) );
     
    // Create the nested active scheduler
    // please see » Symbian OS v9.1 » Symbian OS reference » C++ component
    // reference » Base E32 » CActiveSchedulerWait
    iASWait = new (ELeave) CActiveSchedulerWait();
}
Esempio n. 11
0
void CHttpTestSingleTrans::OpenTestSessionL()
	{
	iSession.OpenL();
	CleanupClosePushL ( iSession );
	SetProxyL(0); // 0 is the start item to look for it in the param list for the test in the ini file
	SetMaxRedirectsL(0);
	MHTTPAuthenticationCallback::InstallAuthenticationL(iSession);
	iMyStrP = iSession.StringPool();
	TPtrC testName = CHttpTestTransactions::TestName();
	if (testName.CompareF(_L("SSL9"))==0)
		{
		RHTTPConnectionInfo	connInfo = iSession.ConnectionInfo();
		connInfo.SetPropertyL( 
							 iMyStrP.StringF(HTTP::ESecureDialog, RHTTPSession::GetTable() ),
							 iMyStrP.StringF(HTTP::EDialogNoPrompt, RHTTPSession::GetTable() )
							 );
		iEngine->Utils().LogIt(_L("Secure Dialog session property set\n"));
		}
	CreateSingleTransactionL();
	CleanupStack::Pop (&iSession);
	}
Esempio n. 12
0
RHTTPTransaction CTestCase15::GetTransactionL(TInt aIndex, RHTTPSession aSession, MHTTPTransactionCallback& aClient)
	{
	__ASSERT_ALWAYS(aIndex<KTransactionCount, User::Invariant());
	
	RStringF method = aSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable());
	_LIT8(KTxtUri, "http://127.0.0.1");
	TUriParser8 uri; 
	uri.Parse(KTxtUri());
	
	// Buffer size needs to be reduced in the session property before the first transaction.
	if( aIndex == 0 )
		{
		RHTTPConnectionInfo connInfo = aSession.ConnectionInfo();
		connInfo.SetPropertyL(aSession.StringPool().StringF(HTTP::EBatchingBufferSize,RHTTPSession::GetTable()), KBufferSize);
		}
		
	// If this is the 2nd request add large amount of header data to make the request
	// larger than the buffer size
	if( aIndex == 2 )
		{
		// Add a fairly large header
		RHTTPTransaction trans = aSession.OpenTransactionL(uri, aClient, method);
		RHTTPHeaders headers = trans.Request().GetHeaderCollection();
		
		_LIT8(KTxtHeaderName, "This_Is_A_Long_Header_Name");
		_LIT8(KTxtHeaderValue, "This_Is_A_Long_Header_Value_abcdefghijklmnopqrstuvwxyz1234567890");
		RStringF headerStrName = aSession.StringPool().OpenFStringL(KTxtHeaderName());
		CleanupClosePushL(headerStrName);
		RStringF headerStrValue = aSession.StringPool().OpenFStringL(KTxtHeaderValue());
		CleanupClosePushL(headerStrValue);
		THTTPHdrVal headerValue(headerStrValue);
		headers.SetFieldL(headerStrName, headerValue);
		CleanupStack::PopAndDestroy(2, &headerStrName);
		
		return trans;
		}
		
	return aSession.OpenTransactionL(uri, aClient, method);
	}
void CHttpController::ConstructL( RConnection& aConnection, RSocketServ& aSocketServ )
	{
	iPersistentHeaders = CHttpHeaders::NewL();
	iSession.OpenL();
	RHTTPConnectionInfo connectionInfo = iSession.ConnectionInfo();
	RStringPool pool = iSession.StringPool();

	connectionInfo.SetPropertyL( pool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
			THTTPHdrVal( aSocketServ.Handle() ) );

	TInt connectionPtr = REINTERPRET_CAST(TInt, &aConnection);
	connectionInfo.SetPropertyL( pool.StringF( HTTP::EHttpSocketConnection,
			RHTTPSession::GetTable() ), THTTPHdrVal( connectionPtr ) );
	iSession.FilterCollection().RemoveFilter( iSession.StringPool().StringF( HTTP::ERedirect,
			RHTTPSession::GetTable() ) );

	iTimeoutTimer = CPeriodic::NewL( CActive::EPriorityIdle );

	if ( !iOutputEncoder )
		{
		//default content encoder
		iOutputEncoder = CMultipartEncoder::NewL();
		}
	}
Esempio n. 14
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
	    /*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;
}
Esempio n. 15
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))) );
    }
Esempio n. 16
0
// ---------------------------------------------------------
// CMmsSession::OpenL
// ---------------------------------------------------------
//
EXPORT_C void CMmsSession::OpenL( 
    const TDesC8& aProxyAddress,
    const TBool aUseProxy,  
    const TInt32 aMaxReceiveSize,
    const TInt32 aMaxSendSize,
    TRequestStatus& aStatus )
    {
    LOG( _L("CMmsSession::OpenL") );
    __ASSERT_DEBUG( iSessionStatus == ESessionIdle, gPanic( EMmsAlreadyBusy ) );

    iError = KErrNone;
    iRequestStatus = &aStatus;

    // 
    // Setting max send/receive sizes. 0 means not limited.
    // Values always come from CMmsSettings.
    // 
    iMaxReceiveSize = aMaxReceiveSize;
    iMaxSendSize = aMaxSendSize;
  
    // Get pointer HTTP session headers
    iSessionHeaders = iHTTPSession.RequestSessionHeadersL();
    iHeadersCreated = ETrue;

    // Check if we are connected already
    if ( iConnected )
        {
        aStatus = KRequestPending;                             
        User::RequestComplete( iRequestStatus, KMmsErrorSessionAlreadyOpen );
        }
    else 
        {

        // set the session properties
        // the handle comes from iHTTP session. I think we should not close it.
        RStringPool strPool = iHTTPSession.StringPool();
        RHTTPConnectionInfo connInfo = iHTTPSession.ConnectionInfo();
        connInfo.SetPropertyL( strPool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
            THTTPHdrVal( iSocketServ->Handle() ) );
        TInt connPtr = REINTERPRET_CAST( TInt, iConnection );
        connInfo.SetPropertyL(
            strPool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ),
            THTTPHdrVal( connPtr ) );

        // Add proxy usage if requested
        if ( aUseProxy )
            {
            THTTPHdrVal proxyUsage( strPool.StringF( HTTP::EUseProxy, RHTTPSession::GetTable() ) );
            connInfo.SetPropertyL(
                strPool.StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), proxyUsage );
        
            RStringF proxyString = strPool.OpenFStringL( aProxyAddress );
            CleanupClosePushL( proxyString );
            THTTPHdrVal proxyAddr( proxyString );
            connInfo.SetPropertyL(
                strPool.StringF( HTTP::EProxyAddress, RHTTPSession::GetTable() ), proxyAddr );
            CleanupStack::PopAndDestroy( &proxyString );
            }
            
		// Install MMS X-id header filter if required
    	FeatureManager::InitializeLibL();
    	if ( FeatureManager::FeatureSupported( KFeatureIdMmsXidHeaderHttpFilter ) )  
	        {
	        // Install the MMS X-id header filter explicitly, since only MMS requires this filter.
			const TUid KHttpFilterMmsXidHeaderImplementationUid = { 0x1020738D };
			CEComFilter::InstallFilterL(iHTTPSession, KHttpFilterMmsXidHeaderImplementationUid);
	        }
    	FeatureManager::UnInitializeLib();
    	
        // Install UAProf filter
        TInt error = KErrNotFound;
        TRAP( error, CHttpUAProfFilterInterface::InstallFilterL( iHTTPSession ) );
        if ( error != KErrNone )
            {
            LOG2( _L("ERROR: UAProf filter left with code %d. Using hardcoded UserAgent string.."), error );
            
            // Manually set UA string
            SetFixedUserAgentL();

            // UserAgent header must be added always - either hard coded string or string from ini file
            SetHeaderL( iSessionHeaders, HTTP::EUserAgent, iUserAgent->Des() );

            // Add UAProf if available
            if ( iUaProf && iUaProf->Length() > 0 )
                {
                RStringF tempString = strPool.OpenFStringL( iUaProf->Des() );
                CleanupClosePushL( tempString );
                RStringF tempString2 = strPool.OpenFStringL( KXProfile );
                CleanupClosePushL( tempString2 );
                iSessionHeaders.SetFieldL( tempString2, tempString );
                CleanupStack::PopAndDestroy( &tempString2 );
                CleanupStack::PopAndDestroy( &tempString );
                }
            }

        // Accept headers moved to transaction as global filter overrides
        // session headers

        // HTTP session, no need for separate connect procedure
        iConnected = ETrue;
        // We may or may not get
        iHTTPSession.SetSessionEventCallback( this );
        aStatus = KRequestPending;
        User::RequestComplete( iRequestStatus, KErrNone );
        }
    }
Esempio n. 17
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;
}
Esempio n. 18
0
CResourceManager::EHttpSessionState CResourceManager::OpenHttpSessionIfNeededL(void* aKernel)
{
    if (!m_IAPSeted || !m_IAPReady) {
        ((CNBrKernel*)aKernel)->RequestAP();

        if (!m_IAPSeted)
            return ENotSetIAP;

        if (m_IAPSeted && !m_IAPReady)
            return ENotReady;
    }

    if (!m_sessionRunning) {

        m_httpSession.OpenL(KHttpProtString);
        m_sessionRunning = true;

        RStringPool strP = m_httpSession.StringPool();
        const TStringTable& stringTable = RHTTPSession::GetTable();
        RHTTPConnectionInfo connInfo = m_httpSession.ConnectionInfo();

        if (m_bUseOutNetSettting) {
            // 使用外壳提供的连接
            if (iSocketServ)
                connInfo.SetPropertyL(
                    strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()),
                    THTTPHdrVal(iSocketServ->Handle()) );
            if (iConnection)
                connInfo.SetPropertyL(
                    strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()),
                    THTTPHdrVal(REINTERPRET_CAST(TInt, iConnection)) );
        }
        else {
            // 使用内部连接
            connInfo.SetPropertyL(
                strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()),
                THTTPHdrVal(m_socketServ.Handle()));

            connInfo.SetPropertyL(
                strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()),
                THTTPHdrVal(REINTERPRET_CAST(TInt, &(m_connection))));
        }

        if (m_isWap) {
            RStringF iPrxAddr = strP.OpenFStringL(KHttpProxy);
            CleanupClosePushL(iPrxAddr);

            THTTPHdrVal iPrxUsage(strP.StringF(HTTP::EUseProxy, RHTTPSession::GetTable()));
            connInfo.SetPropertyL(strP.StringF(HTTP::EProxyUsage, RHTTPSession::GetTable()), iPrxUsage);
            connInfo.SetPropertyL(strP.StringF(HTTP::EProxyAddress, RHTTPSession::GetTable()), iPrxAddr);
            CleanupStack::PopAndDestroy();
        }

        // set shutdown
        THTTPHdrVal immediateShutdown = strP.StringF(HTTP::ESocketShutdownImmediate, stringTable);
        connInfo.SetPropertyL(strP.StringF(HTTP::ESocketShutdownMode, stringTable), immediateShutdown);
        
//        // set pipelining
//        RStringF maxConnection = strP.StringF(HTTP::EMaxNumTransportHandlers, stringTable);
//        connInfo.SetPropertyL(maxConnection, THTTPHdrVal(KHttpMaxConnectionNum));
//
//        RStringF maxToPipeline = strP.StringF(HTTP::EMaxNumTransactionsToPipeline, stringTable);
//        connInfo.SetPropertyL(maxToPipeline, THTTPHdrVal(KHttpMaxTransactionNumPerConnection));

//        // Set optimal pipelining
//        RStringF strOptimalPipelineVal = strP.StringF(HTTP::EHttpEnableOptimalPipelining, RHTTPSession::GetTable());
//        connInfo.SetPropertyL(strP.StringF(HTTP::EHttpOptimalPipelining, RHTTPSession::GetTable()), strOptimalPipelineVal);

        // set HTTP receive Buffer Size property
//        RStringF receiveBuffSize = strP.StringF(HTTP::ERecvBufferSize, stringTable);
//        connInfo.SetPropertyL(receiveBuffSize, THTTPHdrVal(KHttpReceiveBuffSize));

//        // set HTTP batching enable
//        THTTPHdrVal batchingSupport(strP.StringF(HTTP::EEnableBatching, RHTTPSession::GetTable()));
//        connInfo.SetPropertyL(strP.StringF(HTTP::EHttpBatching, RHTTPSession::GetTable()), batchingSupport);

//        // set HTTP batching Buffer Size property
//        RStringF batchingBuffSize = strP.StringF(HTTP::EBatchingBufferSize, stringTable);
//        connInfo.SetPropertyL(batchingBuffSize, THTTPHdrVal(KHttpBatchingBuffSize));
        
        RHTTPFilterCollection filtColl = m_httpSession.FilterCollection();
        RStringF filterName = m_httpSession.StringPool().StringF(HTTP::ERedirect,RHTTPSession::GetTable());
        filtColl.RemoveFilter(filterName);
    }

    return EReady;
}