×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    20

    what is header file required for HTTP::EuserAgent?

    what is header file required for HTTP::EuserAgent?

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: what is header file required for HTTP::EuserAgent?

    You could maybe check the docs: http://library.developer.nokia.com/i...7C7752639.html there is attached example applciation which is using this class as well, so you could see what headers are included in there.

    Or search the include folder in your SDK.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    20

    Re: what is header file required for HTTP::EuserAgent?

    yse I got it in a link below this post. <http.h>
    I have a series of other issues.
    i have a function
    void ChelloHTTPEngine::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod);
    what is the value with which i should call this function
    TRAPD(err, iHTTPEngine->InvokeHttpMethodL(aUri, HTTP::EGET));--> does not accept
    My project is yet to begin, I am developing prototype.. So, can I get address of some server so that I can test my HTTP Code.
    Last edited by abhinavnishantintg; 2012-10-05 at 08:08.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: what is header file required for HTTP::EuserAgent?

    I would suggest you do check the full exanmple for HTTP available at the examples section: https://www.developer.nokia.com/Deve...tworking.xhtml in general its easier to check exiting and working code. Just see how its done there, and copy-paste the code segment..

  5. #5
    Registered User
    Join Date
    Sep 2012
    Posts
    20

    Re: what is header file required for HTTP::EuserAgent?

    yes I have this code, and I have read the SDK, I have developed the code.
    pasting below->
    appui-> handle commandl--------
    _LIT(KAddress,"https://www.google.co.in/#hl=en&sugexp=les%3B&gs_nf=1&tok=wmCW2k6BCJLQ_tLRmmiTEA&cp=3&gs_id=1i0&xhr=t&q=wikipedia&pf=p&output=search&sclient=psy-ab&oq=wik&gs_l=&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=7830c53aba414a9f&biw=1366&bih=665");
    TBuf8<20>aUri;
    TRAPD(err, iHTTPEngine->InvokeHttpMethod(aUri,EGet ));
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    class ChelloHTTPEngine : public CBase,MHTTPTransactionCallback
    {
    .............
    void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
    TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
    void InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod);
    void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue);
    RHTTPSession iSession;
    };
    ----------------------------------------------------------------------------------------------------------------------------------------------------------

    void ChelloHTTPEngine::ConstructL()
    {
    iSession.OpenL();

    }

    void ChelloHTTPEngine::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent)
    {
    switch (aEvent.iStatus)
    {
    case THTTPEvent::EGotResponseHeaders:
    {

    }
    break;
    case THTTPEvent::EGotResponseBodyData:
    {

    }
    break;
    case THTTPEvent::EResponseComplete:
    {

    }
    break;
    case THTTPEvent::ESucceeded:
    {

    }
    break;
    case THTTPEvent::EFailed:
    {

    }
    break;
    default:
    {

    }
    break;
    }

    }

    void ChelloHTTPEngine::InvokeHttpMethod(const TDesC8& aUri, TMethod aMethod)
    {
    if(aMethod==EGet)
    InvokeHttpMethodL(aUri,iSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable())) ;
    if(aMethod==EPost)
    InvokeHttpMethodL(aUri,iSession.StringPool().StringF(HTTP::EPOST,RHTTPSession::GetTable())) ;

    }

    void ChelloHTTPEngine::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod)
    {
    //const TDesC8& aUri;

    TUriParser8 uri;
    uri.Parse(aUri);
    RHTTPTransaction trans = iSession.OpenTransactionL(uri, *this, aMethod);
    RHTTPHeaders hdr = trans.Request().GetHeaderCollection();
    // Add headers appropriate to all methods
    SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    SetHeaderL(hdr, HTTP::EAccept, KAccept);
    // submit the transaction
    trans.SubmitL();
    // Start the scheduler, once the transaction completes or is cancelled on an error the scheduler will be
    // stopped in the event handler
    CActiveScheduler::Start();

    };
    TInt ChelloHTTPEngine::MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent)
    {

    }
    void ChelloHTTPEngine::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
    {
    RStringF valStr = iSession.StringPool().OpenFStringL(aHdrValue);
    THTTPHdrVal val(valStr);
    aHeaders.SetFieldL(iSession.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
    valStr.Close();
    }


    I have just one compilation error-------------
    have a function
    void ChelloHTTPEngine::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod);
    what is the value with which i should call this function
    TRAPD(err, iHTTPEngine->InvokeHttpMethodL(aUri, HTTP::EGET));--> does not accept


    Rest of the code.....does it look ok..
    Last edited by abhinavnishantintg; 2012-10-05 at 13:42.

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: what is header file required for HTTP::EuserAgent?

    Quote Originally Posted by abhinavnishantintg View Post
    ...
    TRAPD(err, iHTTPEngine->InvokeHttpMethodL(aUri, HTTP::EGET));--> does not accept
    ...
    Are you sure its written like that in the example ?
    Also you might want to share more information , like what kind of error it generates and when.. Anyway, please do check the example and see how its handled in there first.

  7. #7
    Registered User
    Join Date
    Sep 2012
    Posts
    20

    Re: what is header file required for HTTP::EuserAgent?

    may be i should use
    iSession.StringPool().StringF(HTTP::EGET,RHTTPSession::GetTable())
    instead of (HTTP::EGET)
    as I am using the function from appui where there is no RHTTPSession, I may take help of enums.
    let me take a try...

  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: what is header file required for HTTP::EuserAgent?

    please, I don't want to repeat myself, but as the example has perfectly working code snipped included in it, I do suggest you to copy-paste it from there. If you would have done this when I asked first time, we would have been over this issue already, so what about trying what has been suggested.

  9. #9
    Registered User
    Join Date
    Sep 2012
    Posts
    20

    Re: what is header file required for HTTP::EuserAgent?

    hi,
    I am trying to run the code,
    (I have included the google url )
    but in mhfrunl()
    THTTPEvent::EGotResponseBodyData: and THTTPEvent::EGotResponseHeaders: are not getting executed
    instead
    control goes to default: and THTTPEvent::EFailed:


    then i tried changing code

    void ChelloHTTPEngine::InvokeHttpMethodL(const TDesC8& aUri, RStringF aMethod)
    {
    //const TDesC8& aUri;
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    iConnection.Start(/*iStatus*/);
    TUriParser8 uri;
    uri.Parse(aUri);
    RHTTPTransaction trans = iSession.OpenTransactionL(uri, *this, aMethod);
    RHTTPHeaders hdr = trans.Request().GetHeaderCollection();
    // Add headers appropriate to all methods
    SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    SetHeaderL(hdr, HTTP::EAccept, KAccept);
    // submit the transaction
    trans.SubmitL();
    // Start the scheduler, once the transaction completes or is cancelled on an error the scheduler will be
    // stopped in the event handler
    CActiveScheduler::Start();

    };
    still result is the same

  10. #10
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: what is header file required for HTTP::EuserAgent?

    I'm rather sure that the original example has pretty different coding, so please do check it. At least I can not remember it having nested Active schedulers etc.

  11. #11
    Registered User
    Join Date
    Sep 2012
    Posts
    20

    Re: what is header file required for HTTP::EuserAgent?

    Hi,
    I have changed the code, copied most of the lines from the example but i get the same error as previous>>>> default and failed in MHFRUNL()
    (By the way I am not using MHTTPDATASUPPLIER now, ithink I should check response in MHFRUNL first)


    void ChelloHTTPEngine::ConstructL()
    {
    //iSession.OpenL();
    gConsole=((ChelloAppUi *)(CEikonEnv::Static()->AppUi()))->gConsole2;
    CActiveScheduler::Add(this);

    }
    void ChelloHTTPEngine::SetupConnectionL()
    {
    if (iConnectionSetupDone)
    {
    // Connection setup is done
    User::Leave(KErrAlreadyExists);
    }
    if (IsActive())
    {
    User::Leave(KErrInUse);
    }

    // Open HTTP Session
    iSession.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(iSession);

    // Open CCmApplicationSettingsUi
    TCmSettingSelection userSelection;
    CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL();
    CleanupStack::PushL(settings);
    TUint listedItems = CMManager::EShowAlwaysAsk |
    CMManager::EShowDefaultConnection |
    CMManager::EShowDestinations |
    CMManager::EShowConnectionMethods;
    TBearerFilterArray filter;
    TBool selected = settings->RunApplicationSettingsL(userSelection,listedItems,filter);
    CleanupStack::PopAndDestroy(settings);

    // Check selection
    if (selected) {
    switch (userSelection.iResult)
    {
    case CMManager::EDestination:
    {
    TConnSnapPref prefs;
    prefs.SetSnap(userSelection.iId);

    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    iConnection.Start(prefs, iStatus);
    break;
    }
    case CMManager::EConnectionMethod:
    {
    TCommDbConnPref prefs;
    prefs.SetIapId(userSelection.iId);
    prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);

    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    iConnection.Start(prefs, iStatus);
    break;
    }
    case CMManager::EDefaultConnection:
    {
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    iConnection.Start(iStatus);
    break;
    }
    default: // EAlwaysAsk
    {
    TCommDbConnPref prefs;
    prefs.SetDialogPreference(ECommDbDialogPrefPrompt);

    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    iConnection.Start(prefs, iStatus);
    }
    }

    SetActive();
    }
    }
    void ChelloHTTPEngine::IssueHTTPGetL(const TDesC8& aUri)
    {
    if (IsActive())
    {
    return;
    }

    iEngineState = EGet;

    delete iUri; iUri = NULL;
    delete iContentType; iContentType = NULL;
    delete iBody; iBody = NULL;

    iUri = aUri.AllocL();

    // Create HTTP connection
    TRAPD(err, SetupConnectionL());
    if (err == KErrAlreadyExists)
    {
    DoHTTPGetL();
    }
    else if (err != KErrNone)
    {
    /*HBufC* resTxCancelled = StringLoader::LoadLC(R_HTTP_TX_CANCELLED);
    iObserver.ClientEvent(*resTxCancelled);
    CleanupStack::PopAndDestroy(resTxCancelled);*/
    return;
    }
    }
    TBool ChelloHTTPEngine::GetCredentialsL( const TUriC8& aURI,
    RString aRealm,
    RStringF aAuthenticationType,
    RString& aUsername,
    RString& aPassword)
    {
    // aURI, aReal and aAuthenticationType are informational only. We only need
    // to set aUsername and aPassword and return ETrue, if aUsername and
    // aPassword are provided by user.

    // Buffer for string parameters that may change order
    CDesCArrayFlat* strings = new CDesCArrayFlat(2);
    CleanupStack::PushL(strings);

    // Initialize parameter buffer

    // First parameter
    HBufC* uri16 = HBufC::NewLC(aURI.UriDes().Length());
    uri16->Des().Copy(aURI.UriDes());
    strings->AppendL(*uri16);
    CleanupStack::PopAndDestroy(uri16);

    // Second parameter
    HBufC* authType16 = HBufC::NewLC(aAuthenticationType.DesC().Length());
    authType16->Des().Copy(aAuthenticationType.DesC());
    strings->AppendL(*authType16);
    CleanupStack::PopAndDestroy(authType16);

    HBufC* resAuthNote = StringLoader::LoadLC(R_HTTP_AUTH_NOTE, *strings);
    HBufC* resAuthRequired = StringLoader::LoadLC(R_HTTP_AUTH_REQUIRED);
    CEikonEnv::Static()->InfoWinL(*resAuthRequired, *resAuthNote);

    CleanupStack::PopAndDestroy(resAuthNote);
    CleanupStack::PopAndDestroy(resAuthRequired);

    // Query user name and password
    TBuf<KDefaultBufferSize> userName;
    TBuf<KDefaultBufferSize> password;
    CAknMultiLineDataQueryDialog* dlg =
    CAknMultiLineDataQueryDialog::NewL(userName, password);

    if (!dlg->ExecuteLD(R_DIALOG_USER_PASSWORD_QUERY))
    return EFalse; // No credentials given; must return EFalse

    // Set aUsername and aPassword
    TBuf8<KDefaultBufferSize> temp;
    temp.Copy(userName);
    TRAPD(err, aUsername = aRealm.Pool().OpenStringL(temp));
    if (!err)
    {
    temp.Copy(password);
    TRAP(err, aPassword = aRealm.Pool().OpenStringL(temp));
    if (!err) return ETrue;
    }

    // Return ETrue if user has given credentials (username and password),
    // otherwise EFlase
    return EFalse;
    }

    void ChelloHTTPEngine:oHTTPGetL()
    {
    // Parse string to URI (as defined in RFC2396)
    TUriParser8 uri;
    uri.Parse(*iUri);

    // 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);
    iTransactionOpen = ETrue;

    // 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();

    /*HBufC* resConnecting = StringLoader::LoadLC(R_HTTP_CONNECTING);
    iObserver.ClientEvent(*resConnecting);
    CleanupStack::PopAndDestroy(resConnecting)*/;
    }
    void ChelloHTTPEngine::CancelTransaction()
    {
    iEngineState = EIdle;
    delete iUri; iUri = NULL;
    delete iContentType; iContentType = NULL;
    delete iBody; iBody = NULL;

    // Close() also cancels transaction (Cancel() can also be used but
    // resources allocated by transaction must be still freed with Close())
    if (iTransactionOpen)
    {
    iTransaction.Close();
    iTransactionOpen = EFalse;
    }
    }

    void ChelloHTTPEngine::RunL()
    {
    TInt statusCode = iStatus.Int();

    if (!iConnectionSetupDone && statusCode == KErrNone)
    {
    // Connection done ok
    iConnectionSetupDone = ETrue;
    // Register for mobility API
    //iMobility = CActiveCommsMobilityApiExt::NewL(iConnection, *this);
    // Start selected HTTP action
    switch (iEngineState)
    {
    case EIdle:
    {
    CancelTransaction();
    break;
    }
    case EGet:
    {
    DoHTTPGetL();
    break;
    }
    case EPost:
    {
    //DoHTTPPostL();
    break;
    }
    };
    }
    }
    void ChelloHTTPEngine:oCancel()
    {
    iConnection.Stop();
    }
    Last edited by abhinavnishantintg; 2012-10-08 at 08:46.

  12. #12
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: what is header file required for HTTP::EuserAgent?

    Can you please try the original example with your Url ? and if it works, could you simply copy the h & cpp files with HTTP code into your project, that way you could get code which has been working into your project, and you could get it working as well.

  13. #13
    Registered User
    Join Date
    Sep 2012
    Posts
    20

    Re: what is header file required for HTTP::EuserAgent?

    I can not make a build for the example code. error shown->BLDMAKE ERROR: directory "\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32" does not exist

  14. #14
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,091

    Re: what is header file required for HTTP::EuserAgent?

    Does the example code's location & SDK's location are on same drive on you pc?

  15. #15
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: what is header file required for HTTP::EuserAgent?

    Quote Originally Posted by vineet.jain View Post
    Does the example code's location & SDK's location are on same drive on you pc?
    Yep, Symbian tools are often not taking account the drive letter, best option would be to put all parts (SDKs, IDE, code etc.) in C-Drive, though in theory it should work as long as all parts are at the same local-drive.

Similar Threads

  1. [help]#error "The header file 'http.h' doesn't include <QObject>,for help me....
    By yangkaiye in forum [Archived] Qt General ( Qt技术)
    Replies: 0
    Last Post: 2010-12-23, 02:42
  2. Replies: 0
    Last Post: 2010-08-23, 05:02
  3. header files required
    By mobileteam in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2007-08-08, 06:48
  4. Header files required?
    By sreenivasuluy in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2003-10-14, 14:46
  5. HTTP header and WAP209 header equivalence/precedence/conf licts
    By mobilecohesion in forum General Messaging
    Replies: 0
    Last Post: 2002-12-03, 11:49

Posting Permissions

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