Ignore:
Timestamp:
2010-12-06T00:03:49Z (10 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d76e12f
Parents:
a429907
Message:

First bits of CTCP support to contacts. (Try /CTCP VERSION on a Jabber
contact.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    ra429907 rd88c92a  
    794794        return XT_HANDLED;
    795795}
     796
     797static xt_status jabber_iq_version_response( struct im_connection *ic,
     798        struct xt_node *node, struct xt_node *orig );
     799
     800void jabber_iq_version_send( struct im_connection *ic, struct jabber_buddy *bud, void *data )
     801{
     802        struct xt_node *node, *query;
     803       
     804        node = xt_new_node( "query", NULL, NULL );
     805        xt_add_attr( node, "xmlns", XMLNS_VERSION );
     806        query = jabber_make_packet( "iq", "get", bud->full_jid, node );
     807        jabber_cache_add( ic, query, jabber_iq_version_response );
     808
     809        jabber_write_packet( ic, query );
     810}
     811
     812static xt_status jabber_iq_version_response( struct im_connection *ic,
     813        struct xt_node *node, struct xt_node *orig )
     814{
     815        struct xt_node *query;
     816        GString *rets;
     817        char *s;
     818        char *ret[2] = {};
     819        bee_user_t *bu;
     820        struct jabber_buddy *bud = NULL;
     821       
     822        if( ( s = xt_find_attr( node, "from" ) ) &&
     823            ( bud = jabber_buddy_by_jid( ic, s, 0 ) ) &&
     824            ( query = xt_find_node( node->children, "query" ) ) &&
     825            ( bu = bee_user_by_handle( ic->bee, ic, bud->bare_jid ) ) )
     826        {
     827                rets = g_string_new( "Resource " );
     828                g_string_append( rets, bud->resource );
     829        }
     830        else
     831                return XT_HANDLED;
     832       
     833        for( query = query->children; query; query = query->next )
     834                if( query->text_len > 0 )
     835                        g_string_append_printf( rets, " %s: %s,", query->name, query->text );
     836       
     837        g_string_truncate( rets, rets->len - 1 );
     838        ret[0] = rets->str;
     839        imcb_buddy_action_response( bu, "VERSION", ret, NULL );
     840        g_string_free( rets, TRUE );
     841       
     842        return XT_HANDLED;
     843}
Note: See TracChangeset for help on using the changeset viewer.