diff options
-rw-r--r-- | protocols/jabber/iq.c | 19 | ||||
-rw-r--r-- | protocols/jabber/jabber.c | 2 | ||||
-rw-r--r-- | protocols/jabber/jabber.h | 1 | ||||
-rw-r--r-- | protocols/jabber/jabber_util.c | 30 |
4 files changed, 32 insertions, 20 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 595718fb..3dae39f6 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -30,7 +30,6 @@ static xt_status jabber_iq_display_vcard( struct im_connection *ic, struct xt_no xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) { struct im_connection *ic = data; - struct jabber_data *jd = ic->proto_data; struct xt_node *c, *reply = NULL; char *type, *s; int st, pack = 1; @@ -46,23 +45,7 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ) if( strcmp( type, "result" ) == 0 || strcmp( type, "error" ) == 0 ) { - struct jabber_cache_entry *entry; - - 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 IQ-%s packet with unknown/expired ID %s!", type, s ); - else if( entry->func ) - return entry->func( ic, node, entry->node ); + return jabber_cache_handle_packet( ic, node ); } else if( strcmp( type, "get" ) == 0 ) { diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index b0651a59..6ee10a38 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -225,8 +225,6 @@ static void jabber_generate_id_hash( struct jabber_data *jd ) s = base64_encode( binbuf, 9 ); jd->cached_id_prefix = g_strdup_printf( "%s%s", JABBER_CACHED_ID, s ); g_free( s ); - - printf( "%s\n", jd->cached_id_prefix ); } static void jabber_logout( struct im_connection *ic ) diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index fc9d2fc4..bee5cb73 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -184,6 +184,7 @@ void jabber_cache_add( struct im_connection *ic, struct xt_node *node, jabber_ca struct xt_node *jabber_cache_get( struct im_connection *ic, char *id ); void jabber_cache_entry_free( gpointer entry ); void jabber_cache_clean( struct im_connection *ic ); +xt_status jabber_cache_handle_packet( struct im_connection *ic, struct xt_node *node ); const struct jabber_away_state *jabber_away_state_by_code( char *code ); const struct jabber_away_state *jabber_away_state_by_name( char *name ); void jabber_buddy_ask( struct im_connection *ic, char *handle ); 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" }, |