×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Bangalore,India
    Posts
    129

    Unable to connect to GPRS using IAP

    Hi ,

    I want to hide the pop up asking for IAP.

    I've referred to HTTPTaskManager example that is available in wiki.
    But i coundt connect to GPRS.

    calling query from Appui and i have implemented query in responseview in y project
    Code:
    if (iResponseView->QueryIapL(iap, 0))
    		{
    		iEngine->SetIap(iap);
    		iEngine->ConnectL();
    		}

    Code:
    
    
    void CBlueIdClientEngine::ConstructL()
    	{
    	User::LeaveIfError(iSockServ.Connect());
    	User::LeaveIfError(iConnection.Open(iSockServ));
    	// Open RHTTPSession with default protocol ("HTTP/TCP")
    	TRAPD( err, iSession.OpenL() );
    	if (err != KErrNone)
    		{
    
    		HBufC* textResource = StringLoader::LoadLC(R_WEBCLIENT_IAP_CONF_ERR,
    		err);
    		CAknErrorNote* errorNote;
    		errorNote = new (ELeave) CAknErrorNote;
    		// Show the error Note with textResource loaded with StringLoader.
    		errorNote->ExecuteLD(*textResource);
    		// Pop HBuf from CleanUpStack and Destroy it.
    		CleanupStack::PopAndDestroy(textResource);
    		User::Leave(err);
    		}
    	LoadIapsL();
    	//CBlueIdClientEngine* iEngine = CBlueIdClientEngine::NewL(*this);
    
    	// Install this class as the callback for authentication requests. When 
    	// page requires authentication the framework calls GetCredentialsL to get 
    	// user name and password.
    	InstallAuthenticationL(iSession);
    	}
    
    void CBlueIdClientEngine::LoadIapsL()
    	{
    	// open commdb
    	CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
    	CleanupStack::PushL(commDb);
    
    	// open IAP table
    	CCommsDbTableView* commView = commDb->OpenIAPTableViewMatchingBearerSetLC(
    			ECommDbBearerCSD | ECommDbBearerGPRS,
    			ECommDbConnectionDirectionOutgoing);
    
    	// search all IAPs
    	if (commView->GotoFirstRecord() == KErrNone)
    		{
    		do
    			{
    			TIap iap;
    			commView->ReadTextL(TPtrC(COMMDB_NAME), iap.iName);
    			commView->ReadUintL(TPtrC(COMMDB_ID), iap.iId);
    			User::LeaveIfError(iIAPs.Append(iap));
    			}
    		while (commView->GotoNextRecord() == KErrNone);
    		}
    
    	CleanupStack::PopAndDestroy(/*commView*/);
    	CleanupStack::PopAndDestroy(/*commDb*/);
    
    	}
    
    void CBlueIdClientEngine::SetIap(const TUint32& aId)
    	{
    	iIap = aId;
    	}
    TBool CBlueIdClientEngine::IapSet() const
    	{
    	if (iIap == 0)
    		{
    		return EFalse;
    		}
    	else
    		{
    		return ETrue;
    		}
    	}
    
    RArray<TIap>& CBlueIdClientEngine::Iaps()
    	{
    	return iIAPs;
    	}
    
    void CBlueIdClientEngine::ConnectL()
    	{
    	// this functionality is not applicable for the emulator
    #ifndef __WINS__ 
    	TBool connected = EFalse;
    
    	// Lets first check are we already connected.
    	TUint connectionCount;
    	User::LeaveIfError(iConnection.EnumerateConnections(connectionCount));
    	TPckgBuf<TConnectionInfoV2> connectionInfo;
    	for (TUint i = 1; i <= connectionCount; i++)
    		{
    		User::LeaveIfError(iConnection.GetConnectionInfo(i, connectionInfo));
    		if (connectionInfo().iIapId == iIap)
    			{	
    			connected = ETrue;
    			break;
    			}
    		}
    
    	// Not yet connected, start connection
    	if (!connected)
    		{
    		//Define preferences for connection
    		TCommDbConnPref prefs;
    		prefs.SetIapId(/*iIap*/ 2);
    		prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    
    		//Start Connection
    		iOpeningConnection = ETrue;
    		ConnectionCreated();		return;
    		}
    
    	//Set properties for the HTTP session
    	RStringPool strP = iSession.StringPool();
    	RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    	connInfo.SetPropertyL(strP.StringF(HTTP::EHttpSocketServ,
    			RHTTPSession::GetTable()), THTTPHdrVal(iSockServ.Handle()));
    	TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
    	connInfo.SetPropertyL(strP.StringF(HTTP::EHttpSocketConnection,
    			RHTTPSession::GetTable()), THTTPHdrVal(connPtr));
    
    #endif // __WINS__
    	}
    
    void CBlueIdClientEngine::ConnectionCreated()
    	{
    	iOpeningConnection = EFalse;
    	TRAPD(error,
    			//Set properties for the HTTP session
    			RStringPool strP = iSession.StringPool();
    			RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    			connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable() ), THTTPHdrVal (iSockServ.Handle()) );
    			TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
    			connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), THTTPHdrVal (connPtr) );
    	)
    }
    
    
    calling connectL() from IssueHTTPGetL
    void CBlueIdClientEngine::IssueHTTPGetL(const TDesC8& aUri) { ConnectL(); TUriParser8 uri; uri.Parse(aUri); // Get request method string for HTTP GET RStringF method = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable()); // Open transaction with previous method and parsed uri. This class will // receive transaction events in MHFRunL and MHFRunError. iTransaction = iSession.OpenTransactionL(uri, *this, method); // Set headers for request; user agent and accepted content type RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); SetHeaderL(hdr, HTTP::EAccept, KAccept); // Submit the transaction. After this the framework will give transaction // events via MHFRunL and MHFRunError. iTransaction.SubmitL(); iRunning = ETrue; // Load a string from the resource file HBufC* textResource = StringLoader::LoadLC(R_WEBCLIENT_CONNECTING); iObserver.ClientEvent(*textResource); CleanupStack::PopAndDestroy(textResource); }

    Thanks,
    kusuma

  2. #2
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Unable to connect to GPRS using IAP

    //set up connection like this

    iSession.OpenL();
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(commDB);
    CCommsDbConnectionPrefTableView* commDBView =
    commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);
    User::LeaveIfError(commDBView->GotoFirstRecord());
    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
    commDBView->ReadConnectionPreferenceL(pref);
    TUint32 iapID = pref.iBearer.iIapId;
    CleanupStack::PopAndDestroy(commDBView);
    CleanupStack::PopAndDestroy(commDB);
    TCommDbConnPref connectPref;
    connectPref.SetIapId(iapID);
    connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
    connectPref.SetBearerSet( ECommDbBearerGPRS | ECommDbBearerCdma2000 | ECommDbBearerLAN | ECommDbBearerCSD );
    TInt errConnect = iConnection.Start(connectPref);

    RStringPool strP = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ,
    RHTTPSession::GetTable() ),

    THTTPHdrVal (iSocketServ.Handle()) );
    TInt connPtr = REINTERPRET_CAST(TInt, &(iConnection));
    connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection,
    RHTTPSession::GetTable() ),
    THTTPHdrVal (connPtr) );
    if(errConnect!=KErrNone)
    {

    TBuf<100> errMsg;
    errMsg.Copy(_L("Unable to connect to server."));
    iObserver.ClientEvent(errMsg);
    return;
    }

    iConnectionSetupDone = ETrue;
    Regards,
    Shafali

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Bangalore,India
    Posts
    129

    Re: Unable to connect to GPRS using IAP

    Hi shafali gupta,

    So i need not to worry about all these function
    can i directly put this in ConstructL of the httpengine class?
    Thanks
    Kusuma

  4. #4
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: Unable to connect to GPRS using IAP

    Quote Originally Posted by kusumat View Post
    Hi shafali gupta,

    So i need not to worry about all these function
    can i directly put this in ConstructL of the httpengine class?
    Thanks
    Kusuma
    Above code that i have posted is for setting up the connection only. You can craete the cnnection in your constructL() itslef as it is required to be done only once.
    Regards,
    Shafali

  5. #5
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Bangalore,India
    Posts
    129

    Re: Unable to connect to GPRS using IAP

    Hi,
    when i set up the connection using th code below
    it was working fine earlier.
    but the same code not working.
    when i debug point coes


    iSession.OpenL();
    it is giving HTTP-CORE 0 error

    i have closed like this before opening
    Code:
    if(iSession)
    	iSession.Close();
    but still the first ref to iSession closes app


    Code:
    iSession.OpenL();
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
    CleanupStack::PushL(commDB);
    CCommsDbConnectionPrefTableView* commDBView =
    commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);
    User::LeaveIfError(commDBView->GotoFirstRecord());
    CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
    commDBView->ReadConnectionPreferenceL(pref);
    TUint32 iapID = pref.iBearer.iIapId;
    CleanupStack::PopAndDestroy(commDBView);
    CleanupStack::PopAndDestroy(commDB);
    TCommDbConnPref connectPref;
    connectPref.SetIapId(iapID);
    connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
    connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
    connectPref.SetBearerSet( ECommDbBearerGPRS | ECommDbBearerCdma2000 | ECommDbBearerLAN | ECommDbBearerCSD );
    TInt errConnect = iConnection.Start(connectPref);
    
    RStringPool strP = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketServ,
    RHTTPSession::GetTable() ),
    
    THTTPHdrVal (iSocketServ.Handle()) );
    TInt connPtr = REINTERPRET_CAST(TInt, &(iConnection));
    connInfo.SetPropertyL ( strP.StringF(HTTP::EHttpSocketConnection,
    RHTTPSession::GetTable() ),
    THTTPHdrVal (connPtr) );
    if(errConnect!=KErrNone)
    {
    
    TBuf<100> errMsg;
    errMsg.Copy(_L("Unable to connect to server."));
    iObserver.ClientEvent(errMsg);
    return;
    }
    
    iConnectionSetupDone = ETrue;
    need help

    thanks,
    kusuma

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: Unable to connect to GPRS using IAP

    Apparently people jumped on your newer thread, so stick with that one: http://discussion.forum.nokia.com/fo...d.php?t=181776

Similar Threads

  1. Replies: 2
    Last Post: 2009-01-13, 09:17
  2. A series 40 connectivity problem : unable to connect using SocketConnection
    By dakots in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2006-03-08, 05:14
  3. it s possible to connect gprs automatically??
    By msudan in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2005-03-23, 03:29
  4. Connect to GPRS, please help
    By hishamabdo in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2005-02-24, 11:53
  5. IAP Connect v2.0
    By stenlik in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-02-22, 08:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×