Mercurial > pidgin
changeset 21654:32629dbb0bb9
Don't allow buddies to be manually added to Bonjour (remove the added buddy in the prpl add_buddy callback). Also, fix a crash when rendering the tooltip for one of these previously added buddies. Fixes #4045.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 26 Nov 2007 19:03:39 +0000 |
parents | 28c63fdcda73 |
children | 10a2ac84349d |
files | libpurple/protocols/bonjour/bonjour.c |
diffstat | 1 files changed, 26 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/bonjour.c Mon Nov 26 10:24:57 2007 +0000 +++ b/libpurple/protocols/bonjour/bonjour.c Mon Nov 26 19:03:39 2007 +0000 @@ -43,14 +43,6 @@ #include "buddy.h" #include "bonjour_ft.h" -/* - * TODO: Should implement an add_buddy callback that removes the buddy - * from the local list. Bonjour manages buddies for you, and - * adding someone locally by hand is stupid. Or, maybe even better, - * if a PRPL does not have an add_buddy callback then do not allow - * users to add buddies. - */ - static char *default_firstname; static char *default_lastname; static char *default_hostname; @@ -260,6 +252,25 @@ g_free(stripped); } +/* + * The add_buddy callback removes the buddy from the local list. + * Bonjour manages buddies for you, and adding someone locally by + * hand is stupid. Perhaps we should change libpurple not to allow adding + * if there is no add_buddy callback. + */ +static void +bonjour_fake_add_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group) { + purple_debug_error("bonjour", "Buddy '%s' manually added; removing. " + "Bonjour buddies must be discovered and not manually added.\n", + purple_buddy_get_name(buddy)); + + /* I suppose we could alert the user here, but it seems unnecessary. */ + + /* If this causes problems, it can be moved to an idle callback */ + purple_blist_remove_buddy(buddy); +} + + static void bonjour_remove_buddy(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group) { if (buddy->proto_data) { bonjour_buddy_delete(buddy->proto_data); @@ -303,7 +314,7 @@ PurpleBuddy *buddy = purple_find_buddy(connection->account, who); BonjourBuddy *bb; - if (buddy == NULL) + if (buddy == NULL || buddy->proto_data == NULL) { /* * This buddy is not in our buddy list, and therefore does not really @@ -370,6 +381,11 @@ if (message != NULL) purple_notify_user_info_add_pair(user_info, _("Message"), message); + if (bb == NULL) { + purple_debug_error("bonjour", "Got tooltip request for a buddy without protocol data.\n"); + return; + } + /* Only show first/last name if there is a nickname set (to avoid duplication) */ if (bb->nick != NULL) { if (bb->first != NULL) @@ -425,7 +441,7 @@ bonjour_set_status, /* set_status */ NULL, /* set_idle */ NULL, /* change_passwd */ - NULL, /* add_buddy */ + bonjour_fake_add_buddy, /* add_buddy */ NULL, /* add_buddies */ bonjour_remove_buddy, /* remove_buddy */ NULL, /* remove_buddies */