Changeset b56b220


Ignore:
Timestamp:
2006-10-11T18:29:56Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
259edd4
Parents:
58b5f62
Message:

Fixed issues in end-of-connection detection and added basic "handling" of
stream errors. (They can't really be handled, but at least the user can
be informed.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r58b5f62 rb56b220  
    162162        {
    163163                /* Parse. */
    164                 if( !xt_feed( jd->xt, buf, st ) )
     164                if( xt_feed( jd->xt, buf, st ) < 0 )
    165165                {
    166166                        hide_login_progress_error( gc, "XML stream error" );
     
    279279static xt_status jabber_end_of_stream( struct xt_node *node, gpointer data )
    280280{
     281        signoff( data );
    281282        return XT_ABORT;
    282283}
     
    427428}
    428429
     430static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data )
     431{
     432        struct gaim_connection *gc = data;
     433        struct xt_node *c;
     434        char *s, *type = NULL, *text = NULL;
     435       
     436        for( c = node->children; c; c = c->next )
     437        {
     438                if( !( s = xt_find_attr( c, "xmlns" ) ) ||
     439                    strcmp( s, "urn:ietf:params:xml:ns:xmpp-streams" ) != 0 )
     440                        continue;
     441               
     442                if( strcmp( c->name, "text" ) != 0 )
     443                {
     444                        type = c->name;
     445                }
     446                /* Only use the text if it doesn't have an xml:lang attribute,
     447                   if it's empty or if it's set to something English. */
     448                else if( !( s = xt_find_attr( c, "xml:lang" ) ) ||
     449                         !*s || strncmp( s, "en", 2 ) == 0 )
     450                {
     451                        text = c->text;
     452                }
     453        }
     454       
     455        /* Tssk... */
     456        if( type == NULL )
     457        {
     458                hide_login_progress_error( gc, "Unknown stream error reported by server" );
     459                signoff( gc );
     460                return XT_ABORT;
     461        }
     462       
     463        /* We know that this is a fatal error. If it's a "conflict" error, we
     464           should turn off auto-reconnect to make sure we won't get some nasty
     465           infinite loop! */
     466        if( strcmp( type, "conflict" ) == 0 )
     467                gc->wants_to_die = TRUE;
     468       
     469        s = g_strdup_printf( "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" );
     470        hide_login_progress_error( gc, s );
     471        g_free( s );
     472        signoff( gc );
     473       
     474        return XT_ABORT;
     475}
     476
    429477static xt_status jabber_pkt_misc( struct xt_node *node, gpointer data )
    430478{
     
    441489        { "iq",                 "stream:stream",        jabber_pkt_iq },
    442490        { "stream:features",    "stream:stream",        jabber_pkt_features },
     491        { "stream:error",       "stream:stream",        jabber_pkt_stream_error },
    443492        { "proceed",            "stream:stream",        jabber_pkt_proceed_tls },
    444493        { "challenge",          "stream:stream",        sasl_pkt_challenge },
Note: See TracChangeset for help on using the changeset viewer.