From 76c85b4c79d533ca7a780df381ccda5b9ab2934c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 19 Nov 2009 13:11:38 +0000 Subject: resource_select now defaults to activity instead of priority. Also, adding a activity_timeout setting. Now, messages to someone who hasn't spoken for a while will be sent to his/her bare JID, usually resulting in a broadcast. This should fix issues with messages sometimes arriving on someone's Crackberry/Android/etc instead of some place s/he's paying attention to. Last, the activity timer is only reset on incoming messages. --- protocols/jabber/jabber.c | 16 +++------- protocols/jabber/jabber.h | 11 ++++++- protocols/jabber/jabber_util.c | 70 +++++++++++++++++++++++------------------- protocols/jabber/message.c | 2 +- protocols/jabber/presence.c | 3 -- 5 files changed, 54 insertions(+), 48 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index b8e88c26..6d63f354 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -57,6 +57,8 @@ static void jabber_init( account_t *acc ) set_t *s; char str[16]; + s = set_add( &acc->set, "activity_timeout", "600", set_eval_int, acc ); + g_snprintf( str, sizeof( str ), "%d", jabber_port_list[0] ); s = set_add( &acc->set, "port", str, set_eval_int, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; @@ -66,7 +68,7 @@ static void jabber_init( account_t *acc ) s = set_add( &acc->set, "resource", "BitlBee", NULL, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "resource_select", "priority", NULL, acc ); + s = set_add( &acc->set, "resource_select", "activity", NULL, acc ); s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY | SET_NULL_OK; @@ -304,7 +306,7 @@ static int jabber_buddy_msg( struct im_connection *ic, char *who, char *message, if( ( s = strchr( who, '=' ) ) && jabber_chat_by_jid( ic, s + 1 ) ) bud = jabber_buddy_by_ext_jid( ic, who, 0 ); else - bud = jabber_buddy_by_jid( ic, who, 0 ); + bud = jabber_buddy_by_jid( ic, who, GET_BUDDY_BARE_OK ); node = xt_new_node( "body", message, NULL ); node = jabber_make_packet( "message", "chat", bud ? bud->full_jid : who, node ); @@ -349,17 +351,9 @@ static GList *jabber_away_states( struct im_connection *ic ) static void jabber_get_info( struct im_connection *ic, char *who ) { - struct jabber_data *jd = ic->proto_data; struct jabber_buddy *bud; - if( strchr( who, '/' ) ) - bud = jabber_buddy_by_jid( ic, who, 0 ); - else - { - char *s = jabber_normalize( who ); - bud = g_hash_table_lookup( jd->buddies, s ); - g_free( s ); - } + bud = jabber_buddy_by_jid( ic, who, GET_BUDDY_FIRST ); while( bud ) { diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h index 1180d2b9..5eac70d0 100644 --- a/protocols/jabber/jabber.h +++ b/protocols/jabber/jabber.h @@ -106,6 +106,13 @@ struct jabber_cache_entry jabber_cache_event func; }; +/* Somewhat messy data structure: We have a hash table with the bare JID as + the key and the head of a struct jabber_buddy list as the value. The head + is always a bare JID. If the JID has other resources (often the case, + except for some transports that don't support multiple resources), those + follow. In that case, the bare JID at the beginning doesn't actually + refer to a real session and should only be used for operations that + support incomplete JIDs. */ struct jabber_buddy { char *bare_jid; @@ -119,7 +126,7 @@ struct jabber_buddy struct jabber_away_state *away_state; char *away_message; - time_t last_act; + time_t last_msg; jabber_buddy_flags_t flags; struct jabber_buddy *next; @@ -207,6 +214,8 @@ typedef enum GET_BUDDY_CREAT = 1, /* Try to create it, if necessary. */ GET_BUDDY_EXACT = 2, /* Get an exact match (only makes sense with bare JIDs). */ GET_BUDDY_FIRST = 4, /* No selection, simply get the first resource for this JID. */ + GET_BUDDY_BARE = 8, /* Get the bare version of the JID (possibly inexistent). */ + GET_BUDDY_BARE_OK = 16, /* Allow returning a bare JID if that seems better. */ } get_buddy_flags_t; struct jabber_error diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 19a73b6a..6c37c2ef 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -339,6 +339,11 @@ struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid_ if( ( bud = g_hash_table_lookup( jd->buddies, full_jid ) ) ) { + /* The first entry is always a bare JID. If there are more, we + should ignore the first one here. */ + if( bud->next ) + bud = bud->next; + /* If this is a transport buddy or whatever, it can't have more than one instance, so this is always wrong: */ if( s == NULL || bud->resource == NULL ) @@ -373,10 +378,15 @@ struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid_ } else { - /* Keep in mind that full_jid currently isn't really - a full JID... */ - new->bare_jid = g_strdup( full_jid ); + new->full_jid = new->bare_jid = g_strdup( full_jid ); g_hash_table_insert( jd->buddies, new->bare_jid, new ); + + if( s ) + { + new->next = g_new0( struct jabber_buddy, 1 ); + new->next->bare_jid = new->bare_jid; + new = new->next; + } } if( s ) @@ -402,18 +412,19 @@ struct jabber_buddy *jabber_buddy_add( struct im_connection *ic, char *full_jid_ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, get_buddy_flags_t flags ) { struct jabber_data *jd = ic->proto_data; - struct jabber_buddy *bud; + struct jabber_buddy *bud, *head; char *s, *jid; jid = jabber_normalize( jid_ ); if( ( s = strchr( jid, '/' ) ) ) { - int bare_exists = 0; - *s = 0; if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) ) { + if( bud->next ) + bud = bud->next; + /* Just return the first one for this bare JID. */ if( flags & GET_BUDDY_FIRST ) { @@ -435,16 +446,8 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, if( strcmp( bud->resource, s + 1 ) == 0 ) break; } - else - { - /* This variable tells the if down here that the bare - JID already exists and we should feel free to add - more resources, if the caller asked for that. */ - bare_exists = 1; - } - if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && - ( !bare_exists || imcb_find_buddy( ic, jid ) ) ) + if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && imcb_find_buddy( ic, jid ) ) { *s = '/'; bud = jabber_buddy_add( ic, jid ); @@ -458,7 +461,8 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, struct jabber_buddy *best_prio, *best_time; char *set; - bud = g_hash_table_lookup( jd->buddies, jid ); + head = g_hash_table_lookup( jd->buddies, jid ); + bud = head->next ? head->next : head; g_free( jid ); @@ -475,22 +479,31 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, else if( flags & GET_BUDDY_FIRST ) /* Looks like the caller doesn't care about details. */ return bud; + else if( flags & GET_BUDDY_BARE ) + return head; best_prio = best_time = bud; for( ; bud; bud = bud->next ) { if( bud->priority > best_prio->priority ) best_prio = bud; - if( bud->last_act > best_time->last_act ) + if( bud->last_msg > best_time->last_msg ) best_time = bud; } if( ( set = set_getstr( &ic->acc->set, "resource_select" ) ) == NULL ) return NULL; - else if( strcmp( set, "activity" ) == 0 ) - return best_time; - else /* if( strcmp( set, "priority" ) == 0 ) */ + else if( strcmp( set, "priority" ) == 0 ) return best_prio; + else if( flags & GET_BUDDY_BARE_OK ) /* && strcmp( set, "activity" ) == 0 */ + { + if( best_time->last_msg + set_getint( &ic->acc->set, "activity_timeout" ) >= time( NULL ) ) + return best_time; + else + return head; + } + else + return best_time; } } @@ -532,7 +545,7 @@ struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *ji int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) { struct jabber_data *jd = ic->proto_data; - struct jabber_buddy *bud, *prev, *bi; + struct jabber_buddy *head, *bud, *prev, *bi; char *s, *full_jid; full_jid = jabber_normalize( full_jid_ ); @@ -540,8 +553,10 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) if( ( s = strchr( full_jid, '/' ) ) ) *s = 0; - if( ( bud = g_hash_table_lookup( jd->buddies, full_jid ) ) ) + if( ( head = g_hash_table_lookup( jd->buddies, full_jid ) ) ) { + bud = head->next ? head->next : head; + /* If there's only one item in the list (and if the resource matches), removing it is simple. (And the hash reference should be removed too!) */ @@ -549,16 +564,7 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) ( ( s == NULL && bud->resource == NULL ) || ( bud->resource && s && strcmp( bud->resource, s + 1 ) == 0 ) ) ) { - g_hash_table_remove( jd->buddies, bud->bare_jid ); - g_free( bud->bare_jid ); - g_free( bud->ext_jid ); - g_free( bud->full_jid ); - g_free( bud->away_message ); - g_free( bud ); - - g_free( full_jid ); - - return 1; + return jabber_buddy_remove_bare( ic, full_jid ); } else if( s == NULL || bud->resource == NULL ) { diff --git a/protocols/jabber/message.c b/protocols/jabber/message.c index 6cb67d42..a226a225 100644 --- a/protocols/jabber/message.c +++ b/protocols/jabber/message.c @@ -70,7 +70,7 @@ xt_status jabber_pkt_message( struct xt_node *node, gpointer data ) { if( bud ) { - bud->last_act = time( NULL ); + bud->last_msg = time( NULL ); from = bud->ext_jid ? : bud->bare_jid; } else diff --git a/protocols/jabber/presence.c b/protocols/jabber/presence.c index 939bc888..68d4e52c 100644 --- a/protocols/jabber/presence.c +++ b/protocols/jabber/presence.c @@ -67,9 +67,6 @@ xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ) else { bud->away_state = NULL; - /* Let's only set last_act if there's *no* away state, - since it could be some auto-away thingy. */ - bud->last_act = time( NULL ); } if( ( c = xt_find_node( node->children, "priority" ) ) && c->text_len > 0 ) -- cgit v1.2.3 From 20e830b641638bc580e1a58b68fc3c5837e76807 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 19 Nov 2009 14:58:30 +0000 Subject: Fixed a facepalm kind of NULL pointer dereference bug. --- protocols/jabber/jabber_util.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 6c37c2ef..ec23919e 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -462,7 +462,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, char *set; head = g_hash_table_lookup( jd->buddies, jid ); - bud = head->next ? head->next : head; + bud = ( head && head->next ) ? head->next : head; g_free( jid ); @@ -545,7 +545,7 @@ struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *ji int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) { struct jabber_data *jd = ic->proto_data; - struct jabber_buddy *head, *bud, *prev, *bi; + struct jabber_buddy *bud, *prev, *bi; char *s, *full_jid; full_jid = jabber_normalize( full_jid_ ); @@ -553,9 +553,10 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) if( ( s = strchr( full_jid, '/' ) ) ) *s = 0; - if( ( head = g_hash_table_lookup( jd->buddies, full_jid ) ) ) + if( ( bud = g_hash_table_lookup( jd->buddies, full_jid ) ) ) { - bud = head->next ? head->next : head; + if( bud->next ) + bud = bud->next; /* If there's only one item in the list (and if the resource matches), removing it is simple. (And the hash reference -- cgit v1.2.3 From 08e5bb2bb2fcc7125f837be4f225d3a9ebf320ed Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 19 Nov 2009 18:50:53 +0000 Subject: Restoring some logic that seemed broken but was important with handling of chatrooms (and likely more things). The restored version is somewhat less confusing. --- protocols/jabber/jabber_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index ec23919e..120a56b6 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -419,9 +419,13 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, if( ( s = strchr( jid, '/' ) ) ) { + int bare_exists = 0; + *s = 0; if( ( bud = g_hash_table_lookup( jd->buddies, jid ) ) ) { + bare_exists = 1; + if( bud->next ) bud = bud->next; @@ -447,7 +451,8 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, break; } - if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && imcb_find_buddy( ic, jid ) ) + if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && + ( imcb_find_buddy( ic, jid ) || bare_exists ) ) { *s = '/'; bud = jabber_buddy_add( ic, jid ); -- cgit v1.2.3 From dde9d5710cd6392592c1417032933f0ba4299d9c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 12 Mar 2010 19:35:51 +0000 Subject: Fixed jabber_util unittest. It passes, yet something still seems to be broken. :-( --- protocols/jabber/jabber_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 6e103609..a0266d3e 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -457,7 +457,7 @@ struct jabber_buddy *jabber_buddy_by_jid( struct im_connection *ic, char *jid_, } if( bud == NULL && ( flags & GET_BUDDY_CREAT ) && - ( imcb_find_buddy( ic, jid ) || bare_exists ) ) + ( bare_exists || imcb_find_buddy( ic, jid ) ) ) { *s = '/'; bud = jabber_buddy_add( ic, jid ); -- cgit v1.2.3 From 315dd4c1566dcd4caa9c4ca0eceeceb995a01443 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 15 Mar 2010 01:25:47 +0000 Subject: Oops.. Today's Jabber fix could get stuck in a somewhat infinite loop if a Jabber server returns an empty response to the session establishment request (which is valid and actually done by the example, but my test Jabberd shows different behaviour). Fixed. --- protocols/jabber/io.c | 12 +----------- protocols/jabber/iq.c | 8 ++------ 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c index 4a790f27..a14ad21c 100644 --- a/protocols/jabber/io.c +++ b/protocols/jabber/io.c @@ -379,18 +379,8 @@ static xt_status jabber_pkt_features( struct xt_node *node, gpointer data ) if( ( c = xt_find_node( node->children, "session" ) ) ) jd->flags |= JFLAG_WANT_SESSION; - /* This flag is already set if we authenticated via SASL, so now - we can resume the session in the new stream, if we don't have - to bind/initialize the session. */ - if( jd->flags & JFLAG_AUTHENTICATED && ( jd->flags & ( JFLAG_WANT_BIND | JFLAG_WANT_SESSION ) ) == 0 ) - { - if( !jabber_get_roster( ic ) ) - return XT_ABORT; - } - else if( jd->flags & JFLAG_AUTHENTICATED ) - { + if( jd->flags & JFLAG_AUTHENTICATED ) return jabber_pkt_bind_sess( ic, NULL, NULL ); - } return XT_HANDLED; } diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c index 21e52da6..1b76a761 100644 --- a/protocols/jabber/iq.c +++ b/protocols/jabber/iq.c @@ -306,23 +306,19 @@ xt_status jabber_pkt_bind_sess( struct im_connection *ic, struct xt_node *node, if( c && c->text_len && ( s = strchr( c->text, '/' ) ) && strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 ) imcb_log( ic, "Server changed session resource string to `%s'", s + 1 ); - - jd->flags &= ~JFLAG_WANT_BIND; - } - else if( node && ( c = xt_find_node( node->children, "session" ) ) ) - { - jd->flags &= ~JFLAG_WANT_SESSION; } if( jd->flags & JFLAG_WANT_BIND ) { reply = xt_new_node( "bind", NULL, xt_new_node( "resource", set_getstr( &ic->acc->set, "resource" ), NULL ) ); xt_add_attr( reply, "xmlns", XMLNS_BIND ); + jd->flags &= ~JFLAG_WANT_BIND; } else if( jd->flags & JFLAG_WANT_SESSION ) { reply = xt_new_node( "session", NULL, NULL ); xt_add_attr( reply, "xmlns", XMLNS_SESSION ); + jd->flags &= ~JFLAG_WANT_SESSION; } if( reply != NULL ) -- cgit v1.2.3 From 9fca06579d61d6360520db98092bce13d30d39ce Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 15 Mar 2010 10:26:25 +0000 Subject: Deal with stupid (on first sight, at least) Yahoo! server behaviour causing double free()s on testing ATM. Apparently it's perfectly legal to give buddy information with an "end buddy" marker but no "begin buddy". --- protocols/yahoo/libyahoo2.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/yahoo/libyahoo2.c b/protocols/yahoo/libyahoo2.c index 5b2ff44e..1bfc2e59 100644 --- a/protocols/yahoo/libyahoo2.c +++ b/protocols/yahoo/libyahoo2.c @@ -1343,7 +1343,11 @@ static void yahoo_process_status(struct yahoo_input_data *yid, break; case 301: /* End buddy */ if (!strcmp(pair->value, "315") && u) { - users = y_list_prepend(users, u); + /* Sometimes user info comes in an odd format with no + "begin buddy" but *with* an "end buddy". Don't add + it twice. */ + if (!y_list_find(users, u)) + users = y_list_prepend(users, u); u = yd->half_user = NULL; } break; -- cgit v1.2.3 From 449a51de265cb3b4f0f5003e09fbbb030247c972 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 16 Mar 2010 10:18:02 +0000 Subject: Include non-away status messages in blist and whois responses. The whois change is a complete violation of the IRC protocol but that doesn't seem to be an uncommon thing. --- protocols/nogaim.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'protocols') diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 9c6daeaf..c326e378 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -646,11 +646,9 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, oa = u->away != NULL; oo = u->online; - if( u->away ) - { - g_free( u->away ); - u->away = NULL; - } + g_free( u->away ); + g_free( u->status_msg ); + u->away = u->status_msg = NULL; if( ( flags & OPT_LOGGED_IN ) && !u->online ) { @@ -688,7 +686,10 @@ void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, u->away = g_strdup( "Away" ); } } - /* else waste_any_state_information_for_now(); */ + else + { + u->status_msg = g_strdup( message ); + } /* LISPy... */ if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) && /* Don't do a thing when user doesn't want it */ -- cgit v1.2.3 From ec55a7d76711d6b071e0d1ba043cb120d3e11c24 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 16 Mar 2010 10:24:00 +0000 Subject: Really set Yahoo! status messages properly. YMSG, how I hate you. --- protocols/yahoo/yahoo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index a47de966..b61f6ff9 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -226,7 +226,7 @@ static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) else yd->current_status = YAHOO_STATUS_CUSTOM; } - else if( state ) + else if( msg ) yd->current_status = YAHOO_STATUS_CUSTOM; else yd->current_status = YAHOO_STATUS_AVAILABLE; -- cgit v1.2.3 From f9928cb319c2879a56b7280f09723b26035982d0 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 17 Mar 2010 01:13:23 +0000 Subject: Set resource_select to activity by default since priority has always been a stupid default. More fixes coming up soon. --- protocols/jabber/jabber.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c index eca7d2d3..a1fb8817 100644 --- a/protocols/jabber/jabber.c +++ b/protocols/jabber/jabber.c @@ -66,7 +66,7 @@ static void jabber_init( account_t *acc ) s = set_add( &acc->set, "resource", "BitlBee", NULL, acc ); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add( &acc->set, "resource_select", "priority", NULL, acc ); + s = set_add( &acc->set, "resource_select", "activity", NULL, acc ); s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY | SET_NULL_OK; -- cgit v1.2.3 From 842cd8dbfb98b61af33b5fe481364c3cfbeaca04 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 18 Mar 2010 11:22:17 +0000 Subject: Fixed a bug that caused full JIDs to get lost sometimes with the new way of storing full JIDs belongong to a contact. --- protocols/jabber/jabber_util.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'protocols') diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index a0266d3e..db5944bc 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -3,7 +3,7 @@ * BitlBee - An IRC to IM gateway * * Jabber module - Misc. stuff * * * -* Copyright 2006 Wilmer van der Gaast * +* Copyright 2006-2010 Wilmer van der Gaast * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -555,7 +555,7 @@ struct jabber_buddy *jabber_buddy_by_ext_jid( struct im_connection *ic, char *ji int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) { struct jabber_data *jd = ic->proto_data; - struct jabber_buddy *bud, *prev, *bi; + struct jabber_buddy *bud, *prev = NULL, *bi; char *s, *full_jid; full_jid = jabber_normalize( full_jid_ ); @@ -566,7 +566,7 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) if( ( bud = g_hash_table_lookup( jd->buddies, full_jid ) ) ) { if( bud->next ) - bud = bud->next; + bud = (prev=bud)->next; /* If there's only one item in the list (and if the resource matches), removing it is simple. (And the hash reference @@ -586,7 +586,7 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) } else { - for( bi = bud, prev = NULL; bi; bi = (prev=bi)->next ) + for( bi = bud; bi; bi = (prev=bi)->next ) if( strcmp( bi->resource, s + 1 ) == 0 ) break; @@ -597,8 +597,7 @@ int jabber_buddy_remove( struct im_connection *ic, char *full_jid_ ) if( prev ) prev->next = bi->next; else - /* The hash table should point at the second - item, because we're removing the first. */ + /* Don't think this should ever happen anymore. */ g_hash_table_replace( jd->buddies, bi->bare_jid, bi->next ); g_free( bi->ext_jid ); -- cgit v1.2.3