Ignore:
Timestamp:
2007-07-30T19:12:06Z (17 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
82135c7
Parents:
85023c6
Message:

Added jabber_error_parse() and using it for both stream- and stanza
(only presence so far) errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r85023c6 r1baaef8  
    436436{
    437437        struct im_connection *ic = data;
    438         struct xt_node *c;
    439         char *s, *type = NULL, *text = NULL;
    440438        int allow_reconnect = TRUE;
    441        
    442         for( c = node->children; c; c = c->next )
    443         {
    444                 if( !( s = xt_find_attr( c, "xmlns" ) ) ||
    445                     strcmp( s, XMLNS_STREAM_ERROR ) != 0 )
    446                         continue;
    447                
    448                 if( strcmp( c->name, "text" ) != 0 )
    449                 {
    450                         type = c->name;
    451                 }
    452                 /* Only use the text if it doesn't have an xml:lang attribute,
    453                    if it's empty or if it's set to something English. */
    454                 else if( !( s = xt_find_attr( c, "xml:lang" ) ) ||
    455                          !*s || strncmp( s, "en", 2 ) == 0 )
    456                 {
    457                         text = c->text;
    458                 }
    459         }
     439        struct jabber_error *err;
     440       
     441        err = jabber_error_parse( node, XMLNS_STREAM_ERROR );
    460442       
    461443        /* Tssk... */
    462         if( type == NULL )
     444        if( err->code == NULL )
    463445        {
    464446                imcb_error( ic, "Unknown stream error reported by server" );
    465447                imc_logout( ic, allow_reconnect );
     448                jabber_error_free( err );
    466449                return XT_ABORT;
    467450        }
     
    470453           should turn off auto-reconnect to make sure we won't get some nasty
    471454           infinite loop! */
    472         if( strcmp( type, "conflict" ) == 0 )
     455        if( strcmp( err->code, "conflict" ) == 0 )
    473456        {
    474457                imcb_error( ic, "Account and resource used from a different location" );
     
    477460        else
    478461        {
    479                 imcb_error( ic, "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" );
    480         }
    481        
     462                imcb_error( ic, "Stream error: %s%s%s", err->code, err->text ? ": " : "",
     463                            err->text ? err->text : "" );
     464        }
     465       
     466        jabber_error_free( err );
    482467        imc_logout( ic, allow_reconnect );
    483468       
Note: See TracChangeset for help on using the changeset viewer.