Changeset 3bd4a93


Ignore:
Timestamp:
2010-04-13T17:36:16Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3254c12
Parents:
3e69802
Message:

Suppress HTTP error messages unless we get five or more in a row.

Location:
protocols/twitter
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/twitter/twitter.c

    r3e69802 r3bd4a93  
    3636       
    3737        // Check if we are still logged in...
    38         // We are logged in if the flag says so and the connection is still in the connections list.
    39         if (!g_slist_find( twitter_connections, ic ) ||
    40             (ic->flags & OPT_LOGGED_IN) != OPT_LOGGED_IN)
     38        if (!g_slist_find( twitter_connections, ic ))
    4139                return 0;
    4240
     
    7977
    8078        imcb_log( ic, "Connecting to Twitter" );
    81         imcb_connected(ic);
    8279
    8380        // Run this once. After this queue the main loop function.
  • protocols/twitter/twitter.h

    r3e69802 r3bd4a93  
    4040        gint main_loop_id;
    4141        struct groupchat *home_timeline_gc;
     42        gint http_fails;
    4243};
    4344
  • protocols/twitter/twitter_lib.c

    r3e69802 r3bd4a93  
    180180        struct xt_parser *parser;
    181181        struct twitter_xml_list *txl;
     182        struct twitter_data *td;
    182183
    183184        ic = req->data;
     185        td = ic->proto_data;
    184186
    185187        // Check if the connection is still active.
     
    190192        if (req->status_code != 200) {
    191193                // It didn't go well, output the error and return.
    192                 imcb_error(ic, "Could not retrieve friends. HTTP STATUS: %d", req->status_code);
    193                 return;
     194                if (++td->http_fails >= 5)
     195                        imcb_error(ic, "Could not retrieve friends. HTTP STATUS: %d", req->status_code);
     196               
     197                return;
     198        } else {
     199                td->http_fails = 0;
    194200        }
    195201
     
    462468{
    463469        struct im_connection *ic = req->data;
     470        struct twitter_data *td = ic->proto_data;
    464471        struct xt_parser *parser;
    465472        struct twitter_xml_list *txl;
     
    470477
    471478        // Check if the HTTP request went well.
    472         if (req->status_code != 200) {
     479        if (req->status_code == 200)
     480        {
     481                td->http_fails = 0;
     482                if (!ic->flags & OPT_LOGGED_IN)
     483                        imcb_connected(ic);
     484        }
     485        else if (req->status_code == 401)
     486        {
     487                imcb_error( ic, "Authentication failure" );
     488                imc_logout( ic, FALSE );
     489                return;
     490        }
     491        else
     492        {
    473493                // It didn't go well, output the error and return.
    474                 imcb_error(ic, "Could not retrieve " TWITTER_HOME_TIMELINE_URL ". HTTP STATUS: %d", req->status_code);
     494                if (++td->http_fails >= 5)
     495                        imcb_error(ic, "Could not retrieve " TWITTER_HOME_TIMELINE_URL ". HTTP STATUS: %d", req->status_code);
     496               
    475497                return;
    476498        }
     
    507529{
    508530        struct im_connection *ic = req->data;
     531        struct twitter_data *td = ic->proto_data;
    509532        struct xt_parser *parser;
    510533        struct twitter_xml_list *txl;
     
    519542        if (req->status_code != 200) {
    520543                // It didn't go well, output the error and return.
    521                 imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL " HTTP STATUS: %d", req->status_code);
    522                 return;
     544                if (++td->http_fails >= 5)
     545                        imcb_error(ic, "Could not retrieve " TWITTER_SHOW_FRIENDS_URL " HTTP STATUS: %d", req->status_code);
     546               
     547                return;
     548        } else {
     549                td->http_fails = 0;
    523550        }
    524551
Note: See TracChangeset for help on using the changeset viewer.