Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    reded1f7 r1bf1ae6  
    4545        gboolean ret;
    4646       
    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         }
    55        
    5647        if( jd->tx_len == 0 )
    5748        {
     
    120111                return TRUE;
    121112        }
    122         else if( st == 0 || ( st < 0 && !ssl_sockerr_again( jd->ssl ) ) )
     113        else if( st == 0 || ( st < 0 && !sockerr_again() ) )
    123114        {
    124115                /* Set fd to -1 to make sure we won't write to it anymore. */
     
    231222                }
    232223        }
    233         else if( st == 0 || ( st < 0 && !ssl_sockerr_again( jd->ssl ) ) )
     224        else if( st == 0 || ( st < 0 && !sockerr_again() ) )
    234225        {
    235226                closesocket( jd->fd );
     
    436427{
    437428        struct im_connection *ic = data;
     429        struct xt_node *c;
     430        char *s, *type = NULL, *text = NULL;
    438431        int allow_reconnect = TRUE;
    439         struct jabber_error *err;
    440        
    441         err = jabber_error_parse( node, XMLNS_STREAM_ERROR );
     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        }
    442451       
    443452        /* Tssk... */
    444         if( err->code == NULL )
     453        if( type == NULL )
    445454        {
    446455                imcb_error( ic, "Unknown stream error reported by server" );
    447456                imc_logout( ic, allow_reconnect );
    448                 jabber_error_free( err );
    449457                return XT_ABORT;
    450458        }
     
    453461           should turn off auto-reconnect to make sure we won't get some nasty
    454462           infinite loop! */
    455         if( strcmp( err->code, "conflict" ) == 0 )
     463        if( strcmp( type, "conflict" ) == 0 )
    456464        {
    457465                imcb_error( ic, "Account and resource used from a different location" );
     
    460468        else
    461469        {
    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 );
     470                imcb_error( ic, "Stream error: %s%s%s", type, text ? ": " : "", text ? text : "" );
     471        }
     472       
    467473        imc_logout( ic, allow_reconnect );
    468474       
     
    470476}
    471477
    472 static xt_status jabber_xmlconsole( struct xt_node *node, gpointer data )
    473 {
    474         struct im_connection *ic = data;
    475         struct jabber_data *jd = ic->proto_data;
    476        
    477         if( jd->flags & JFLAG_XMLCONSOLE )
    478         {
    479                 char *msg, *pkt;
    480                
    481                 pkt = xt_to_string( node );
    482                 msg = g_strdup_printf( "RX: %s", pkt );
    483                 imcb_buddy_msg( ic, JABBER_XMLCONSOLE_HANDLE, msg, 0, 0 );
    484                 g_free( msg );
    485                 g_free( pkt );
    486         }
    487        
    488         return XT_NEXT;
    489 }
    490 
    491478static const struct xt_handler_entry jabber_handlers[] = {
    492         { NULL,                 "stream:stream",        jabber_xmlconsole },
    493479        { "stream:stream",      "<root>",               jabber_end_of_stream },
    494480        { "message",            "stream:stream",        jabber_pkt_message },
Note: See TracChangeset for help on using the changeset viewer.