aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/jabber_util.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-10-08 20:41:11 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-10-08 20:41:11 +0200
commit861c199fb60fecf5dab96e0ed9d4b0cf0c57822f (patch)
tree45a66a0ebd0f1d1d25016490f00471c7a3456927 /protocols/jabber/jabber_util.c
parent038d17f834219505cbbdae469b2b150117467dd0 (diff)
Moved handling of all IQ packets to event handlers. Cleaned up a LOT of
mess in iq.c!
Diffstat (limited to 'protocols/jabber/jabber_util.c')
-rw-r--r--protocols/jabber/jabber_util.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index 11156258..f26b9617 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -81,7 +81,7 @@ struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_
/* Cache a node/packet for later use. Mainly useful for IQ packets if you need
them when you receive the response. Use this BEFORE sending the packet so
it'll get an id= tag, and do NOT free() the packet after writing it! */
-void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node )
+void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node, jabber_cache_event func )
{
struct jabber_data *jd = gc->proto_data;
char *id = g_strdup_printf( "BeeX%04x", next_id++ );
@@ -91,17 +91,10 @@ void jabber_cache_add( struct gaim_connection *gc, struct xt_node *node )
g_free( id );
entry->node = node;
+ entry->func = func;
g_hash_table_insert( jd->node_cache, xt_find_attr( node, "id" ), entry );
}
-struct xt_node *jabber_cache_get( struct gaim_connection *gc, char *id )
-{
- struct jabber_data *jd = gc->proto_data;
- struct jabber_cache_entry *entry = g_hash_table_lookup( jd->node_cache, id );
-
- return entry ? entry->node : NULL;
-}
-
void jabber_cache_entry_free( gpointer data )
{
struct jabber_cache_entry *entry = data;
@@ -112,6 +105,11 @@ void jabber_cache_entry_free( gpointer data )
gboolean jabber_cache_clean_entry( gpointer key, gpointer entry, gpointer nullpointer );
+/* This one should be called from time to time (from keepalive, in this case)
+ to make sure things don't stay in the node cache forever. By marking nodes
+ during the first run and deleting marked nodes during a next run, every
+ node should be available in the cache for at least a minute (assuming the
+ function is indeed called every minute). */
void jabber_cache_clean( struct gaim_connection *gc )
{
struct jabber_data *jd = gc->proto_data;