Changeset a214954 for protocols


Ignore:
Timestamp:
2006-09-24T20:00:09Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
eab2ac4
Parents:
4ecdc69
Message:

Added some experimental stuff with typing notifications that seems to show
that Gaim doesn't support the official JEP-0085 standard (yet?)...

And added simple garbage collection for the node_cache. Will improve it
later.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/jabber.c

    r4ecdc69 ra214954  
    118118static int jabber_send_im( struct gaim_connection *gc, char *who, char *message, int len, int away )
    119119{
    120         struct xt_node *node;
     120        struct xt_node *node, *event;
    121121        int st;
     122       
     123        /*
     124        event = xt_new_node( "active", NULL, NULL );
     125        xt_add_attr( event, "xlmns", "http://jabber.org/protocol/chatstates" );
     126       
     127        event = xt_new_node( "x", NULL, xt_new_node( "composing", NULL, NULL ) );
     128        xt_add_attr( event, "xmlns", "jabber:x:event" );
     129        */
    122130       
    123131        node = xt_new_node( "body", message, NULL );
    124132        node = jabber_make_packet( "message", "chat", who, node );
     133        xt_add_child( node, event );
    125134        st = jabber_write_packet( gc, node );
    126135        xt_free_node( node );
     
    169178static void jabber_keepalive( struct gaim_connection *gc )
    170179{
     180        struct jabber_data *jd = gc->proto_data;
     181        struct xt_node *c, *prev;
     182       
    171183        /* Just any whitespace character is enough as a keepalive for XMPP sessions. */
    172184        jabber_write( gc, "\n", 1 );
     185       
     186        /* Let's abuse this keepalive for garbage collection of the node cache too.
     187           It runs every minute, so let's mark every node with a special flag the
     188           first time we see it, and clean it up the second time (clean up all
     189           packets with the flag set).
     190           
     191           node->flags is normally only used by xmltree itself for parsing/handling,
     192           so it should be safe to use the variable for gc. */
     193       
     194        /* This horrible loop is explained in xmltree.c. Makes me wonder if maybe I
     195           didn't choose the perfect data structure... */
     196        for( prev = NULL, c = jd->node_cache->children; c; prev = c, c = c ? c->next : jd->node_cache->children )
     197        {
     198                if( c->flags == 0 )
     199                {
     200                        c->flags ++;
     201                }
     202                else
     203                {
     204                        if( prev )
     205                                prev->next = c->next;
     206                        else
     207                                jd->node_cache->children = c->next;
     208                       
     209                        xt_free_node( c );
     210                        c = prev;
     211                }
     212        }
    173213}
    174214
Note: See TracChangeset for help on using the changeset viewer.