Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    r1bf1ae6 r1baaef8  
    4444        struct jabber_data *jd = ic->proto_data;
    4545        gboolean ret;
     46       
     47        if( jd->flags & JFLAG_XMLCONSOLE )
     48        {
     49                char *msg;
     50               
     51                msg = g_strdup_printf( "TX: %s", buf );
     52                imcb_buddy_msg( ic, JABBER_XMLCONSOLE_HANDLE, msg, 0, 0 );
     53                g_free( msg );
     54        }
    4655       
    4756        if( jd->tx_len == 0 )
     
    427436{
    428437        struct im_connection *ic = data;
    429         struct xt_node *c;
    430         char *s, *type = NULL, *text = NULL;
    431438        int allow_reconnect = TRUE;
    432        
    433         for( c = node->children; c; c = c->next )
    434         {
    435                 if( !( s = xt_find_attr( c, "xmlns" ) ) ||
    436                     strcmp( s, XMLNS_STREAM_ERROR ) != 0 )
    437                         continue;
    438                
    439                 if( strcmp( c->name, "text" ) != 0 )
    440                 {
    441                         type = c->name;
    442                 }
    443                 /* Only use the text if it doesn't have an xml:lang attribute,
    444                    if it's empty or if it's set to something English. */
    445                 else if( !( s = xt_find_attr( c, "xml:lang" ) ) ||
    446                          !*s || strncmp( s, "en", 2 ) == 0 )
    447                 {
    448                         text = c->text;
    449                 }
    450         }
     439        struct jabber_error *err;
     440       
     441        err = jabber_error_parse( node, XMLNS_STREAM_ERROR );
    451442       
    452443        /* Tssk... */
    453         if( type == NULL )
     444        if( err->code == NULL )
    454445        {
    455446                imcb_error( ic, "Unknown stream error reported by server" );
    456447                imc_logout( ic, allow_reconnect );
     448                jabber_error_free( err );
    457449                return XT_ABORT;
    458450        }
     
    461453           should turn off auto-reconnect to make sure we won't get some nasty
    462454           infinite loop! */
    463         if( strcmp( type, "conflict" ) == 0 )
     455        if( strcmp( err->code, "conflict" ) == 0 )
    464456        {
    465457                imcb_error( ic, "Account and resource used from a different location" );
     
    468460        else
    469461        {
    470                 imcb_error( ic, "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" );
    471         }
    472        
     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 );
    473467        imc_logout( ic, allow_reconnect );
    474468       
     
    476470}
    477471
     472static xt_status jabber_pkt_misc( struct xt_node *node, gpointer data )
     473{
     474        printf( "Received unknown packet:\n" );
     475        xt_print( node );
     476       
     477        return XT_HANDLED;
     478}
     479
     480static xt_status jabber_xmlconsole( struct xt_node *node, gpointer data )
     481{
     482        struct im_connection *ic = data;
     483        struct jabber_data *jd = ic->proto_data;
     484       
     485        if( jd->flags & JFLAG_XMLCONSOLE )
     486        {
     487                char *msg, *pkt;
     488               
     489                pkt = xt_to_string( node );
     490                msg = g_strdup_printf( "RX: %s", pkt );
     491                imcb_buddy_msg( ic, JABBER_XMLCONSOLE_HANDLE, msg, 0, 0 );
     492                g_free( msg );
     493                g_free( pkt );
     494        }
     495       
     496        return XT_NEXT;
     497}
     498
    478499static const struct xt_handler_entry jabber_handlers[] = {
     500        { NULL,                 "stream:stream",        jabber_xmlconsole },
    479501        { "stream:stream",      "<root>",               jabber_end_of_stream },
    480502        { "message",            "stream:stream",        jabber_pkt_message },
     
    487509        { "success",            "stream:stream",        sasl_pkt_result },
    488510        { "failure",            "stream:stream",        sasl_pkt_result },
     511        { NULL,                 "stream:stream",        jabber_pkt_misc },
    489512        { NULL,                 NULL,                   NULL }
    490513};
Note: See TracChangeset for help on using the changeset viewer.