Mercurial > pidgin
diff libpurple/protocols/myspace/user.c @ 25172:125cac3e24ee
The Add Buddy dialog should not blindly create a duplicate buddy in a group
Fix up a subset of the prpls add_buddy functions to properly handle
this situation.
* Everything that comes before oscar alphabetically should work properly
(except Gadu-Gadu and MSN, which need testing/another set of eyes)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 29 Nov 2008 18:46:49 +0000 |
parents | 85fc34efe733 |
children | 401f548e3544 |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/user.c Sat Nov 29 18:20:58 2008 +0000 +++ b/libpurple/protocols/myspace/user.c Sat Nov 29 18:46:49 2008 +0000 @@ -47,26 +47,25 @@ return NULL; } } -/** Get the MsimUser from a PurpleBuddy, creating it if needed. */ + +/** Get the MsimUser from a PurpleBuddy, optionally creating it if needed. */ MsimUser * -msim_get_user_from_buddy(PurpleBuddy *buddy) +msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create) { MsimUser *user; - if (!buddy) { - return NULL; - } + g_return_val_if_fail(buddy != NULL, NULL); - if (!buddy->proto_data) { + if (create && !buddy->proto_data) { /* No MsimUser for this buddy; make one. */ /* TODO: where is this freed? */ user = g_new0(MsimUser, 1); user->buddy = buddy; buddy->proto_data = (gpointer)user; - } - - user = (MsimUser *)(buddy->proto_data); + } else { + user = (MsimUser *)(buddy->proto_data); + } return user; } @@ -83,7 +82,7 @@ return NULL; } - user = msim_get_user_from_buddy(buddy); + user = msim_get_user_from_buddy(buddy, TRUE); return user; }