Mercurial > pidgin.yaz
comparison libpurple/protocols/myspace/user.c @ 24509: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 |
comparison
equal
deleted
inserted
replaced
24508:5cd0188892f6 | 24509:125cac3e24ee |
---|---|
45 (song && *song) ? song : "Unknown Song"); | 45 (song && *song) ? song : "Unknown Song"); |
46 } else { | 46 } else { |
47 return NULL; | 47 return NULL; |
48 } | 48 } |
49 } | 49 } |
50 /** Get the MsimUser from a PurpleBuddy, creating it if needed. */ | 50 |
51 /** Get the MsimUser from a PurpleBuddy, optionally creating it if needed. */ | |
51 MsimUser * | 52 MsimUser * |
52 msim_get_user_from_buddy(PurpleBuddy *buddy) | 53 msim_get_user_from_buddy(PurpleBuddy *buddy, gboolean create) |
53 { | 54 { |
54 MsimUser *user; | 55 MsimUser *user; |
55 | 56 |
56 if (!buddy) { | 57 g_return_val_if_fail(buddy != NULL, NULL); |
57 return NULL; | 58 |
58 } | 59 if (create && !buddy->proto_data) { |
59 | |
60 if (!buddy->proto_data) { | |
61 /* No MsimUser for this buddy; make one. */ | 60 /* No MsimUser for this buddy; make one. */ |
62 | 61 |
63 /* TODO: where is this freed? */ | 62 /* TODO: where is this freed? */ |
64 user = g_new0(MsimUser, 1); | 63 user = g_new0(MsimUser, 1); |
65 user->buddy = buddy; | 64 user->buddy = buddy; |
66 buddy->proto_data = (gpointer)user; | 65 buddy->proto_data = (gpointer)user; |
67 } | 66 } else { |
68 | 67 user = (MsimUser *)(buddy->proto_data); |
69 user = (MsimUser *)(buddy->proto_data); | 68 } |
70 | 69 |
71 return user; | 70 return user; |
72 } | 71 } |
73 | 72 |
74 /** Find and return an MsimUser * representing a user on the buddy list, or NULL. */ | 73 /** Find and return an MsimUser * representing a user on the buddy list, or NULL. */ |
81 buddy = purple_find_buddy(session->account, username); | 80 buddy = purple_find_buddy(session->account, username); |
82 if (!buddy) { | 81 if (!buddy) { |
83 return NULL; | 82 return NULL; |
84 } | 83 } |
85 | 84 |
86 user = msim_get_user_from_buddy(buddy); | 85 user = msim_get_user_from_buddy(buddy, TRUE); |
87 | 86 |
88 return user; | 87 return user; |
89 } | 88 } |
90 | 89 |
91 /** Append user information to a PurpleNotifyUserInfo, given an MsimUser. | 90 /** Append user information to a PurpleNotifyUserInfo, given an MsimUser. |