Changeset deff040


Ignore:
Timestamp:
2006-09-21T19:48:17Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5997488
Parents:
5bcf70a
Message:

Implemented set_away() (VERY simple version, have to add an away state
table like in the MSN module), added sending of keepalive "packets" and
removed old main() code (for testing only) from jabber.c.

Location:
protocols/jabber
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r5bcf70a rdeff040  
    122122}
    123123
     124/* TODO: For away state handling, implement some list like the one for MSN. */
    124125static GList *jabber_away_states( struct gaim_connection *gc )
    125126{
     
    136137static void jabber_set_away( struct gaim_connection *gc, char *state, char *message )
    137138{
     139        /* For now let's just always set state to "away" and send the message, if available. */
     140        presence_send( gc, NULL, g_strcasecmp( state, "Online" ) == 0 ? NULL : "away", message );
     141}
     142
     143static void jabber_keepalive( struct gaim_connection *gc )
     144{
     145        /* Just any whitespace character is enough as a keepalive for XMPP sessions. */
     146        jabber_write( gc, "\n", 1 );
    138147}
    139148
    140149void jabber_init()
    141150{
    142         struct prpl *ret = g_new0(struct prpl, 1);
     151        struct prpl *ret = g_new0( struct prpl, 1 );
    143152       
    144153        ret->name = "jabber";
     
    158167//      ret->chat_leave = jabber_chat_leave;
    159168//      ret->chat_open = jabber_chat_open;
    160 //      ret->keepalive = jabber_keepalive;
     169        ret->keepalive = jabber_keepalive;
    161170//      ret->add_permit = jabber_add_permit;
    162171//      ret->rem_permit = jabber_rem_permit;
     
    166175        ret->handle_cmp = g_strcasecmp;
    167176
    168         register_protocol(ret);
     177        register_protocol( ret );
    169178}
    170 
    171 #if 0
    172 int main( int argc, char *argv[] )
    173 {
    174         struct xt_parser *xt = xt_new( NULL );
    175         struct xt_node *msg;
    176         int i;
    177         char buf[512];
    178        
    179         msg = xt_new_node( "message", NULL, xt_new_node( "body", "blaataap-test", NULL ) );
    180         xt_add_child( msg, xt_new_node( "html", NULL, xt_new_node( "body", "<b>blaataap in html</b>", NULL ) ) );
    181         xt_add_attr( msg, "xmlns", "jabber:client" );
    182         xt_add_attr( xt_find_node( msg->children, "html" ), "xmlns", "html rotte zooi" );
    183         printf( "%s\n", xt_to_string( msg ) );
    184        
    185         while( ( i = read( 0, buf, 512 ) ) > 0 )
    186         {
    187                 if( xt_feed( xt, buf, i ) < 1 )
    188                         break;
    189         }
    190         xt->handlers = jabber_handlers;
    191         xt_handle( xt, NULL );
    192        
    193         xt_cleanup( xt, NULL );
    194         printf( "%d\n", xt->root );
    195        
    196         xt_free( xt );
    197 }
    198 #endif
  • protocols/jabber/jabber.h

    r5bcf70a rdeff040  
    4646xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );
    4747int presence_announce( struct gaim_connection *gc );
     48int presence_send( struct gaim_connection *gc, char *to, char *show, char *status );
    4849
    4950/* jabber_util.c */
  • protocols/jabber/presence.c

    r5bcf70a rdeff040  
    5454}
    5555
     56/* Send the <presence/> tag that finalizes the whole login process, from here
     57   we'll actually show up as online to our buddies. */
    5658int presence_announce( struct gaim_connection *gc )
    5759{
     
    6971        return st;
    7072}
     73
     74int presence_send( struct gaim_connection *gc, char *to, char *show, char *status )
     75{
     76        struct xt_node *node;
     77        int st;
     78       
     79        node = jabber_make_packet( "presence", NULL, to, NULL );
     80        if( show )
     81                xt_add_child( node, xt_new_node( "show", show, NULL ) );
     82        if( status )
     83                xt_add_child( node, xt_new_node( "status", status, NULL ) );
     84       
     85        st = jabber_write_packet( gc, node );
     86       
     87        xt_free_node( node );
     88        return st;
     89}
Note: See TracChangeset for help on using the changeset viewer.