comparison 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
comparison
equal deleted inserted replaced
31185:1e5654e2928d 31186:ecfa71bc216d
567 } 567 }
568 568
569 static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 569 static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
570 { 570 {
571 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; 571 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
572 struct irc_buddy *ib = g_new0(struct irc_buddy, 1); 572 struct irc_buddy *ib;
573 ib->name = g_strdup(purple_buddy_get_name(buddy)); 573 const char *bname = purple_buddy_get_name(buddy);
574 g_hash_table_replace(irc->buddies, ib->name, ib); 574
575 ib = g_hash_table_lookup(irc->buddies, bname);
576 if (ib != NULL) {
577 ib->ref++;
578 purple_prpl_got_user_status(irc->account, bname,
579 ib->online ? "available" : "offline", NULL);
580 } else {
581 ib = g_new0(struct irc_buddy, 1);
582 ib->name = g_strdup(bname);
583 ib->ref = 1;
584 g_hash_table_replace(irc->buddies, ib->name, ib);
585 }
575 586
576 /* if the timer isn't set, this is during signon, so we don't want to flood 587 /* if the timer isn't set, this is during signon, so we don't want to flood
577 * ourself off with ISON's, so we don't, but after that we want to know when 588 * ourself off with ISON's, so we don't, but after that we want to know when
578 * someone's online asap */ 589 * someone's online asap */
579 if (irc->timer) 590 if (irc->timer)
581 } 592 }
582 593
583 static void irc_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 594 static void irc_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
584 { 595 {
585 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; 596 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
586 g_hash_table_remove(irc->buddies, purple_buddy_get_name(buddy)); 597 struct irc_buddy *ib;
598
599 ib = g_hash_table_lookup(irc->buddies, purple_buddy_get_name(buddy));
600 if (ib && --ib->ref == 0) {
601 g_hash_table_remove(irc->buddies, purple_buddy_get_name(buddy));
602 }
587 } 603 }
588 604
589 static void read_input(struct irc_conn *irc, int len) 605 static void read_input(struct irc_conn *irc, int len)
590 { 606 {
591 char *cur, *end; 607 char *cur, *end;