aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/jabber/jabber_util.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-09-22 20:39:31 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-09-22 20:39:31 +0200
commitfe7a55434385fd858453dffdbb425a21f41e3859 (patch)
tree31f7d29dd436d59d80d06674c12b98b934ddb467 /protocols/jabber/jabber_util.c
parent8d7429102adf8dce6844f2f3da2723d1f87c6442 (diff)
Better detection of successful IQ authentication (using packet caching),
properly working SASL authentication (although only PLAIN so far).
Diffstat (limited to 'protocols/jabber/jabber_util.c')
-rw-r--r--protocols/jabber/jabber_util.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index 46811d05..88b9e55d 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -51,18 +51,43 @@ char *set_eval_tls( set_t *set, char *value )
struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children )
{
- char *id = g_strdup_printf( "BeeX%04x", next_id++ );
struct xt_node *node;
node = xt_new_node( name, NULL, children );
- xt_add_attr( node, "id", id );
if( type )
xt_add_attr( node, "type", type );
if( to )
xt_add_attr( node, "to", to );
+ return node;
+}
+
+/* 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_packet( struct gaim_connection *gc, struct xt_node *node )
+{
+ struct jabber_data *jd = gc->proto_data;
+ char *id = g_strdup_printf( "BeeX%04x", next_id++ );
+
+ /* FIXME: Maybe start using g_error() here if nodes still have a parent, for example? */
+
+ xt_add_attr( node, "id", id );
+ xt_add_child( jd->node_cache, node );
g_free( id );
+}
+
+/* Emptying this cache is a BIG TODO! */
+struct xt_node *jabber_packet_from_cache( struct gaim_connection *gc, char *id )
+{
+ struct jabber_data *jd = gc->proto_data;
+ struct xt_node *node;
+ char *s;
+
+ for( node = jd->node_cache->children; node; node = node->next )
+ if( ( s = xt_find_attr( node, "id" ) ) && strcmp( id, s ) == 0 )
+ break;
return node;
}