Ignore:
Timestamp:
2007-07-30T19:12:06Z (13 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/jabber_util.c

    r85023c6 r1baaef8  
    648648        return res;
    649649}
     650
     651struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns )
     652{
     653        struct jabber_error *err = g_new0( struct jabber_error, 1 );
     654        struct xt_node *c;
     655        char *s;
     656       
     657        err->type = xt_find_attr( node, "type" );
     658       
     659        for( c = node->children; c; c = c->next )
     660        {
     661                if( !( s = xt_find_attr( c, "xmlns" ) ) ||
     662                    strcmp( s, xmlns ) != 0 )
     663                        continue;
     664               
     665                if( strcmp( c->name, "text" ) != 0 )
     666                {
     667                        err->code = c->name;
     668                }
     669                /* Only use the text if it doesn't have an xml:lang attribute,
     670                   if it's empty or if it's set to something English. */
     671                else if( !( s = xt_find_attr( c, "xml:lang" ) ) ||
     672                         !*s || strncmp( s, "en", 2 ) == 0 )
     673                {
     674                        err->text = c->text;
     675                }
     676        }
     677       
     678        return err;
     679}
     680
     681void jabber_error_free( struct jabber_error *err )
     682{
     683        g_free( err );
     684}
Note: See TracChangeset for help on using the changeset viewer.