Changeset cfbb3a6


Ignore:
Timestamp:
2006-09-24T18:08:07Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
8e5e2e9
Parents:
e101506
Message:

Added add_buddy/remove_buddy functions. Removing a contact doesn't seem
to work perfectly though.

Location:
protocols/jabber
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    re101506 rcfbb3a6  
    184184        return st;
    185185}
     186
     187int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name )
     188{
     189        struct xt_node *node;
     190        int st;
     191       
     192        /* Build the item entry */
     193        node = xt_new_node( "item", NULL, NULL );
     194        xt_add_attr( node, "jid", handle );
     195        if( name )
     196                xt_add_attr( node, "name", name );
     197       
     198        /* And pack it into a roster-add packet */
     199        node = xt_new_node( "query", NULL, node );
     200        xt_add_attr( node, "xmlns", "jabber:iq:roster" );
     201        node = jabber_make_packet( "iq", "set", NULL, node );
     202       
     203        st = jabber_write_packet( gc, node );
     204       
     205        xt_free_node( node );
     206        return st;
     207}
     208
     209int jabber_remove_from_roster( struct gaim_connection *gc, char *handle )
     210{
     211        struct xt_node *node;
     212        int st;
     213       
     214        /* Build the item entry */
     215        node = xt_new_node( "item", NULL, NULL );
     216        xt_add_attr( node, "jid", handle );
     217        xt_add_attr( node, "subscription", "remove" );
     218       
     219        /* And pack it into a roster-add packet */
     220        node = xt_new_node( "query", NULL, node );
     221        xt_add_attr( node, "xmlns", "jabber:iq:roster" );
     222        node = jabber_make_packet( "iq", "set", NULL, node );
     223       
     224        st = jabber_write_packet( gc, node );
     225       
     226        xt_free_node( node );
     227        return st;
     228}
  • protocols/jabber/jabber.c

    re101506 rcfbb3a6  
    153153       
    154154        presence_send_update( gc );
     155}
     156
     157static void jabber_add_buddy( struct gaim_connection *gc, char *who )
     158{
     159        if( jabber_add_to_roster( gc, who, NULL ) )
     160                presence_send_request( gc, who, "subscribe" );
     161}
     162
     163static void jabber_remove_buddy( struct gaim_connection *gc, char *who, char *group )
     164{
     165        if( jabber_remove_from_roster( gc, who ) )
     166                presence_send_request( gc, who, "unsubscribe" );
    155167}
    156168
     
    175187//      ret->set_info = jabber_set_info;
    176188//      ret->get_info = jabber_get_info;
    177 //      ret->add_buddy = jabber_add_buddy;
    178 //      ret->remove_buddy = jabber_remove_buddy;
     189        ret->add_buddy = jabber_add_buddy;
     190        ret->remove_buddy = jabber_remove_buddy;
    179191//      ret->chat_send = jabber_chat_send;
    180192//      ret->chat_invite = jabber_chat_invite;
  • protocols/jabber/jabber.h

    re101506 rcfbb3a6  
    7373int jabber_start_iq_auth( struct gaim_connection *gc );
    7474int jabber_get_roster( struct gaim_connection *gc );
     75int jabber_add_to_roster( struct gaim_connection *gc, char *handle, char *name );
     76int jabber_remove_from_roster( struct gaim_connection *gc, char *handle );
    7577
     78/* message.c */
    7679xt_status jabber_pkt_message( struct xt_node *node, gpointer data );
    7780
     
    7982xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );
    8083int presence_send_update( struct gaim_connection *gc );
     84int presence_send_request( struct gaim_connection *gc, char *handle, char *request );
    8185
    8286/* jabber_util.c */
  • protocols/jabber/presence.c

    re101506 rcfbb3a6  
    7878        return st;
    7979}
     80
     81/* Send a subscribe/unsubscribe request to a buddy. */
     82int presence_send_request( struct gaim_connection *gc, char *handle, char *request )
     83{
     84        struct xt_node *node;
     85        int st;
     86       
     87        node = jabber_make_packet( "presence", NULL, NULL, NULL );
     88        xt_add_attr( node, "to", handle );
     89        xt_add_attr( node, "type", request );
     90       
     91        st = jabber_write_packet( gc, node );
     92       
     93        xt_free_node( node );
     94        return st;
     95}
Note: See TracChangeset for help on using the changeset viewer.