×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    User prompted twice for APN selection

    The following code ends up prompting the user for APN selection twice consecutively. I can't find why:

    Code:
    void CHTTPEngine::RunL()
        {
        TInt statusCode = iStatus.Int();
    
        if (!iConnectionSetupDone && statusCode == KErrNone)
            {
            // Connection done ok
            iConnectionSetupDone = ETrue;
            // Start selected HTTP action
            switch (iEngineState)
               {
               case EPost:
                   {
                   DoHTTPPostL();
                   break;
                   }
               ................
               };
            }
        }
    
    void CHTTPEngine::SetupConnectionL()
        {
        if (iConnectionSetupDone)
            {
            // Connection setup is done
            User::Leave(KErrAlreadyExists);
            }
        if (IsActive())
            {
            User::Leave(KErrInUse);
            }
    
        // Open HTTP Session
        iSession.OpenL();
        	
        // Open socket server and start the connection
        User::LeaveIfError(iSocketServ.Connect());
        User::LeaveIfError(iConnection.Open(iSocketServ));
        iConnection.Start(iStatus);
        SetActive();
        }
    
    void CHTTPEngine::IssueHTTPPostL(const TDesC8& aUri,
                     const TDesC8& aContentType,
                     const TDesC8& aBody)
      {
      if (IsActive())
          {
          return;
          }
    
      iEngineState = EPost;
    
      delete iUri; 
      iUri = NULL;
      delete iContentType; 
      iContentType = NULL;
      delete iBody; 
      iBody = NULL;
      
      iUri = aUri.AllocL();
      iContentType = aContentType.AllocL();
      iBody = aBody.AllocL();
    
      // Create HTTP connection
      TRAPD(err, SetupConnectionL());
      if (err == KErrAlreadyExists)
          {
          DoHTTPPostL();
          }
      else
          {
          if (err != KErrNone)
    	  {
    	  iObserver->HTTPEvent(MHTTPObserver::ETxCancelled);
    	  return;
    	  }
          else
    	  {
    	  if(err == KErrCouldNotConnect)
    		  {
    		  iObserver->HTTPEvent(MHTTPObserver::EHTTPEng_Offline);
    		  return;
    		  }
    	  }
          }
       }
    
    void CHTTPEngine::DoHTTPPostL()
      {
      // Parse string to URI
      TUriParser8 uri;
      uri.Parse(*iUri);
    
      // Copy data to be posted into member variable; iPostData is used later in
      // methods inherited from MHTTPDataSupplier.
      delete iPostData;
      iPostData = 0;
      iPostData = iBody->AllocL();
    
      // Get request method string for HTTP POST
      RStringF method = iSession.StringPool().StringF(HTTP::EPOST, 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);
      iTransactionOpen = ETrue;
    
      // Set headers for request; user agent, accepted content type and body's
      // content type.
      RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
      SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
      SetHeaderL(hdr, HTTP::EAccept, KAccept);
      SetHeaderL(hdr, HTTP::EContentType, *iContentType);
    
      // Set this class as an data supplier. Inherited MHTTPDataSupplier methods
      // are called when framework needs to send body data.
      MHTTPDataSupplier* dataSupplier = this;
      iTransaction.Request().SetBody(*dataSupplier);
    
      // Submit the transaction. After this the framework will give transaction
      // events via MHFRunL and MHFRunError.
      iTransaction.SubmitL();
    
      iObserver->HTTPEvent(MHTTPObserver::EConnecting);
      }
    (I only included the part of the code that I think is relevant in the HTTPEngine class).

    The application calls IssueHTTPPostL() to send data to the server.
    If iConnection is not established then, the red line is executed. At that point, the user is prompted to select IAP for the first time.
    The, Run() and DoHTTPPostL() are executed. just after DoHTTPPostL() exits, the user is prompted a second time to select IAP.

    As far as I can see from logs and from hits to MHFRunL() (MHTTPSessionEventCallback observer), the user seems to be prompted twice before anything is sent to server. And I am sure that SetupConnectionL() is only entered once.

    Please, help!
    ----------------------------------------------
    Every journey starts with a small step.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,698

    Re: User prompted twice for APN selection

    Search for HTTP RConnection in the Wiki.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    Albacete, Spain
    Posts
    380

    Re: User prompted twice for APN selection

    Probably the only entry in the wiki that I had not read because it was marked as 2nd Edition contained the solution (http://wiki.forum.nokia.com/index.ph...th_RConnection).
    In any case, for any one having the same problem as me, I just modified CHTTPEngine:oHTTPPostL() to add a the blue lines bellow:

    Code:
    void CHTTPEngine::DoHTTPPostL()
      {
      // Parse string to URI
      TUriParser8 uri;
      uri.Parse(*iUri);
    
      // Copy data to be posted into member variable; iPostData is used later in
      // methods inherited from MHTTPDataSupplier.
      delete iPostData;
      iPostData = 0;
      iPostData = iBody->AllocL();
    
      
      RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
      RStringPool pool = iSession.StringPool();
       
      // Attach to socket server
      connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal(iSocketServ.Handle()));
       
      // Attach to connection
      TInt connPtr = REINTERPRET_CAST(TInt, &iConnection);
      connInfo.SetPropertyL(pool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal(connPtr));
       
      // Open transaction...
      iTransaction = iSession.OpenTransactionL(uri, *this, pool.StringF(HTTP::EPOST, RHTTPSession::GetTable()));   
      iTransactionOpen = ETrue;
    
      // Set headers for request; user agent, accepted content type and body's
      // content type.
      RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
      SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
      SetHeaderL(hdr, HTTP::EAccept, KAccept);
      SetHeaderL(hdr, HTTP::EContentType, *iContentType);
    
      // Set this class as an data supplier. Inherited MHTTPDataSupplier methods
      // are called when framework needs to send body data.
      MHTTPDataSupplier* dataSupplier = this;
      iTransaction.Request().SetBody(*dataSupplier);
    
      // Submit the transaction. After this the framework will give transaction
      // events via MHFRunL and MHFRunError.
      iTransaction.SubmitL();
    
      iObserver->HTTPEvent(MHTTPObserver::EConnecting);
      }
    ----------------------------------------------
    Every journey starts with a small step.

  4. #4
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: User prompted twice for APN selection

    Quote Originally Posted by juannoguera View Post
    Probably the only entry in the wiki that I had not read because it was marked as 2nd Edition contained the solution (http://wiki.forum.nokia.com/index.ph...th_RConnection).
    Wiki page fixed.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

Similar Threads

  1. KERN-EXEC 3 Panic/OK for the same call
    By PACALA_BA in forum Symbian
    Replies: 8
    Last Post: 2009-12-01, 01:02
  2. Connect as master with N82?
    By mikrodidakt1 in forum Bluetooth Technology
    Replies: 5
    Last Post: 2009-05-01, 11:09
  3. Replies: 0
    Last Post: 2008-12-29, 16:15
  4. How to Prompt the user for IAP selection only if the wrong IAP is currently selected
    By kaiser_20 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-10-26, 15:19
  5. a question about the user agent string
    By jackchang1@gmail.com in forum Mobile Java General
    Replies: 3
    Last Post: 2005-09-19, 12:06

Posting Permissions

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