From 4306d8b066d335cb6667414bdd6c5b2e78ccbfd5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 2 Dec 2007 16:43:57 +0000 Subject: Removed retarded printf() (ARGH) and moved the event handling handling of IQ packets to jabber_util so I can reuse it for certain presence packets. --- protocols/jabber/jabber_util.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'protocols/jabber/jabber_util.c') diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 43b91fe3..453e5930 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -180,6 +180,36 @@ gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer nullp } } +xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node ) +{ + struct jabber_data *jd = ic->proto_data; + struct jabber_cache_entry *entry; + char *s; + + if( ( s = xt_find_attr( node, "id" ) ) == NULL || + strncmp( s, jd->cached_id_prefix, strlen( jd->cached_id_prefix ) ) != 0 ) + { + /* Silently ignore it, without an ID (or a non-cache + ID) we don't know how to handle the packet and we + probably don't have to. */ + return XT_HANDLED; + } + + entry = g_hash_table_lookup( jd->node_cache, s ); + + if( entry == NULL ) + { + imcb_log( ic, "WARNING: Received %s-%s packet with unknown/expired ID %s!", + node->name, xt_find_attr( node, "type" ) ? : "(no type)", s ); + } + else if( entry->func ) + { + return entry->func( ic, node, entry->node ); + } + + return XT_HANDLED; +} + const struct jabber_away_state jabber_away_state_list[] = { { "away", "Away" }, -- cgit v1.2.3 From 5bd21df87b195af211c2280ca00391493a669895 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 2 Dec 2007 17:25:57 +0000 Subject: Handling of presence-error packets (only useful for groupchats now), moved jabber_chat_by_jid() (with the right name) to conference.c, I don't know what it was doing in jabber_util.c. --- protocols/jabber/jabber_util.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'protocols/jabber/jabber_util.c') diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 453e5930..9d84e099 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -613,23 +613,6 @@ int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid ) } } -struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name ) -{ - char *normalized = jabber_normalize( name ); - struct groupchat *ret; - struct jabber_chat *jc; - - for( ret = ic->groupchats; ret; ret = ret->next ) - { - jc = ret->data; - if( strcmp( normalized, jc->name ) == 0 ) - break; - } - g_free( normalized ); - - return ret; -} - time_t jabber_get_timestamp( struct xt_node *xt ) { struct tm tp, utc; @@ -681,10 +664,14 @@ time_t jabber_get_timestamp( struct xt_node *xt ) struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns ) { - struct jabber_error *err = g_new0( struct jabber_error, 1 ); + struct jabber_error *err; struct xt_node *c; char *s; + if( node == NULL ) + return NULL; + + err = g_new0( struct jabber_error, 1 ); err->type = xt_find_attr( node, "type" ); for( c = node->children; c; c = c->next ) -- cgit v1.2.3