Mercurial > pidgin
diff libpurple/protocols/irc/irc.c @ 31186:ecfa71bc216d
propagate from branch 'im.pidgin.pidgin' (head edd569c9522df52af33d6132a9d4955bd842f9bb)
to branch 'im.pidgin.pidgin.openq' (head 5afb2c825d40388ede03697166175f4331e9eaf4)
| author | SHiNE CsyFeK <csyfek@gmail.com> |
|---|---|
| date | Sat, 08 Aug 2009 15:00:34 +0000 |
| parents | f9cf1e14838b |
| children | 2cb6ea4420a0 |
line wrap: on
line diff
--- a/libpurple/protocols/irc/irc.c Sat Jul 18 15:15:45 2009 +0000 +++ b/libpurple/protocols/irc/irc.c Sat Aug 08 15:00:34 2009 +0000 @@ -569,9 +569,20 @@ static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { struct irc_conn *irc = (struct irc_conn *)gc->proto_data; - struct irc_buddy *ib = g_new0(struct irc_buddy, 1); - ib->name = g_strdup(purple_buddy_get_name(buddy)); - g_hash_table_replace(irc->buddies, ib->name, ib); + struct irc_buddy *ib; + const char *bname = purple_buddy_get_name(buddy); + + ib = g_hash_table_lookup(irc->buddies, bname); + if (ib != NULL) { + ib->ref++; + purple_prpl_got_user_status(irc->account, bname, + ib->online ? "available" : "offline", NULL); + } else { + ib = g_new0(struct irc_buddy, 1); + ib->name = g_strdup(bname); + ib->ref = 1; + g_hash_table_replace(irc->buddies, ib->name, ib); + } /* if the timer isn't set, this is during signon, so we don't want to flood * ourself off with ISON's, so we don't, but after that we want to know when @@ -583,7 +594,12 @@ static void irc_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) { struct irc_conn *irc = (struct irc_conn *)gc->proto_data; - g_hash_table_remove(irc->buddies, purple_buddy_get_name(buddy)); + struct irc_buddy *ib; + + ib = g_hash_table_lookup(irc->buddies, purple_buddy_get_name(buddy)); + if (ib && --ib->ref == 0) { + g_hash_table_remove(irc->buddies, purple_buddy_get_name(buddy)); + } } static void read_input(struct irc_conn *irc, int len)
