Changeset 4a0614e for protocols/jabber


Ignore:
Timestamp:
2006-09-21T09:37:03Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5bcf70a
Parents:
dd788bb
Message:

Added simple parsing of incoming <presence> tags, a nice </stream:stream>
at the end of sessions, support for sending messages, and restored the old
(and leaking) xt_print(), which I'll only use for debugging.

Location:
protocols/jabber
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/io.c

    rdd788bb r4a0614e  
    170170}
    171171
    172 static gboolean jabber_start_stream( struct gaim_connection *gc );
    173 
    174172gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond )
    175173{
     
    210208};
    211209
    212 static gboolean jabber_start_stream( struct gaim_connection *gc )
     210gboolean jabber_start_stream( struct gaim_connection *gc )
    213211{
    214212        struct jabber_data *jd = gc->proto_data;
     
    236234        return st;
    237235}
     236
     237gboolean jabber_end_stream( struct gaim_connection *gc )
     238{
     239        struct jabber_data *jd = gc->proto_data;
     240        char eos[] = "</stream:stream>";
     241       
     242        /* Let's only do this if the queue is currently empty, otherwise it'd
     243           take too long anyway. */
     244        if( jd->tx_len > 0 )
     245                return TRUE;
     246        else
     247                return jabber_write( gc, eos, strlen( eos ) );
     248}
  • protocols/jabber/jabber.c

    rdd788bb r4a0614e  
    9191        struct jabber_data *jd = gc->proto_data;
    9292       
     93        jabber_end_stream( gc );
     94       
    9395        if( jd->r_inpa >= 0 )
    9496                b_event_remove( jd->r_inpa );
     
    109111static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
    110112{
    111         return 0;
     113        struct xt_node *node;
     114        int st;
     115       
     116        node = xt_new_node( "body", message, NULL );
     117        node = jabber_make_packet( "message", "chat", who, node );
     118        st = jabber_write_packet( gc, node );
     119        xt_free_node( node );
     120       
     121        return st;
    112122}
    113123
  • protocols/jabber/jabber.h

    rdd788bb r4a0614e  
    5656int jabber_write( struct gaim_connection *gc, char *buf, int len );
    5757gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond );
     58gboolean jabber_start_stream( struct gaim_connection *gc );
     59gboolean jabber_end_stream( struct gaim_connection *gc );
    5860
    5961struct jabber_data
  • protocols/jabber/presence.c

    rdd788bb r4a0614e  
    2626xt_status jabber_pkt_presence( struct xt_node *node, gpointer data )
    2727{
     28        struct gaim_connection *gc = data;
    2829        char *from = xt_find_attr( node, "from" );
     30        char *type = xt_find_attr( node, "type" );      /* NULL should mean the person is online. */
     31        char *s;
    2932       
    30         printf( "Received PRES from %s:\n", from );
    31         xt_print( node );
     33        if( !from )
     34                return XT_HANDLED;
     35       
     36        s = strchr( from, '/' );
     37        if( s )
     38                *s = 0;
     39       
     40        if( type == NULL )
     41                serv_got_update( gc, from, 1, 0, 0, 0, 0, 0 );
     42        else if( strcmp( type, "unavailable" ) == 0 )
     43                serv_got_update( gc, from, 0, 0, 0, 0, 0, 0 );
     44        else
     45        {
     46                printf( "Received PRES from %s:\n", from );
     47                xt_print( node );
     48        }
     49       
     50        if( s )
     51                *s = '/';
    3252       
    3353        return XT_HANDLED;
  • protocols/jabber/xmltree.c

    rdd788bb r4a0614e  
    305305        struct xt_node *c;
    306306       
    307         printf( "%s\n", xt_to_string( node ) );
    308         return;
    309        
    310307        /* Indentation */
    311308        for( c = node; c->parent; c = c->parent )
Note: See TracChangeset for help on using the changeset viewer.