Results 1 to 4 of 4

Thread: XP/Qt 4.1.4 qhttp

  1. #1
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default XP/Qt 4.1.4 qhttp

    I have the following code that usually works fine :
    Qt Code:
    1. //*****************************************************************************
    2. void ApplicationWindow::creditUrl()
    3. //*****************************************************************************
    4. {
    5. // target url
    6. QUrl url("http://api.smsbox.fr/index.php?");
    7. url.addQueryItem("login", iniGet( "Login" ));
    8. url.addQueryItem("pass", iniGet( "Password" ));
    9. url.addQueryItem("action", iniGet( "Action" ));
    10.  
    11. http = new QHttp(this);
    12. connect(http, SIGNAL(done(bool)), this, SLOT(defineSMSCredit(bool)));
    13.  
    14. // remember to set the host
    15. http->setHost(url.host());
    16.  
    17. // the resulting data will be stored in the buffer
    18. buffer = new QBuffer(this);
    19. http->get(url.toString(), buffer);
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 

    But right now I am on a friend's network that is loaded with BitTorrents.
    And now here the program just goes away, leaving a useless TrayIcon icon that also goes away as soon as you hover on it.

    Is there a sort of time out somewhere ?
    I would have thought the connect would wait, whatever time it takes...
    Firefox or IE do wait.

    Any hint ?

  2. #2
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default Re: XP/Qt 4.1.4 qhttp

    I edited the code a bit (i was showing the wrong proc, but it is the same code, just a ditfferent outbound slot) to trace it a bit :
    Qt Code:
    1. //*****************************************************************************
    2. void ApplicationWindow::creditUrl()
    3. //*****************************************************************************
    4. {
    5. // target url
    6. QMessageBox::warning( this, "creditUrl", "start" );
    7. QUrl url("http://api.smsbox.fr/index.php?");
    8. url.addQueryItem("login", iniGet( "Login" ));
    9. url.addQueryItem("pass", iniGet( "Password" ));
    10. url.addQueryItem("action", iniGet( "Action" ));
    11.  
    12. http = new QHttp(this);
    13. QMessageBox::warning( this, "creditUrl", "connect" );
    14. connect(http, SIGNAL(done(bool)), this, SLOT(defineSMSCredit(bool)));
    15.  
    16. // remember to set the host
    17. http->setHost(url.host());
    18.  
    19. // the resulting data will be stored in the buffer
    20. buffer = new QBuffer(this);
    21. QMessageBox::warning( this, "creditUrl", "get" );
    22. http->get(url.toString(), buffer);
    23.  
    24. }
    To copy to clipboard, switch view to plain text mode 


    The the slot proc :
    Qt Code:
    1. //*****************************************************************************
    2. void ApplicationWindow::defineSMSCredit( bool error )
    3. //*****************************************************************************
    4. {
    5. QMessageBox::warning( this, "defineSMSCredit", "before handle" );
    6. // handle http reply for credit request
    7. handleSMSCredit( error );
    8. QMessageBox::warning( this, "defineSMSCredit", "after handle" );
    9. etc...
    To copy to clipboard, switch view to plain text mode 

    When I run that I see:
    start
    connect
    before handle
    and then it goes away...

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: XP/Qt 4.1.4 qhttp

    Quote Originally Posted by incapacitant
    When I run that I see:
    start
    connect
    before handle
    and then it goes away...
    Well... it works until handleSMSCredit() is invoked. What does it do?

  4. #4
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    106

    Default Re: XP/Qt 4.1.4 qhttp

    Yes, it does this :
    Qt Code:
    1. //*****************************************************************************
    2. void ApplicationWindow::handleSMSCredit( bool error )
    3. //*****************************************************************************
    4. {
    5. // by default there is no credit, but qsLCredit and intCredit should be
    6. // defini. This is in the case where the credit cannot be retrieved
    7. // after a http problem (like no connection to server)
    8. // "Bidon 0" ensures intCredit is defaulted to 0, and qslCredit|1] = "0"
    9. QMessageBox::warning( this, "handleSMSCredit", "start" );
    10. qsCredit = "Bidon 0";
    11. qslCredit = qsCredit.split( " " );
    12. intCredit = qslCredit[1].toInt( &ok, 10 );
    13.  
    14. // si pas d'erreur http
    15. if ( !error ) {
    16. QMessageBox::warning( this, "handleSMSCredit", "no error" );
    17. // get credit info returned by http slot
    18. qsCredit = QString(buffer->data());
    19. QMessageBox::warning( this, "handleSMSCredit", qsCredit );
    20.  
    21. // parse buffer
    22. qslCredit = qsCredit.split( " " );
    23. QMessageBox::warning( this, "handleSMSCredit", "parse buffer data" );
    24.  
    25. // check what server replied (ie "ERROR xx" or "CREDIT xxx")
    26. TxtError = iniGet( "TxtError1" );
    27.  
    28. QMessageBox::warning( this, "handleSMSCredit", qslCredit[0] );
    To copy to clipboard, switch view to plain text mode 

    When I run I see:
    Credit...
    start
    connect
    DefineSMS...
    before handle
    handleSMLSCredit
    start
    no error
    a "get" appears and disapears in less than half a second
    shows the value of qsCredit as empty
    parse buffer data
    a new "get" appears and disapears in less than half a second
    show the value of qslCredit[0] as empty (as qsCredit)

    So I paused the torrents to see. But somehow this application used to work.
    And with the torrents paused it won't : qsCredit is returned empty !

    It is a programming issue, because the previous version works despite the torrents.
    I must have done something while trying to improve things and now I will investigate
    what I did between the 2 versions.
    Qt works, my new code does not.

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.