Mercurial > pidgin
comparison src/prpl.c @ 12176:6f41d8d33989
[gaim-migrate @ 14478]
Iterating over all buddies for a presence when a presence is common to all
those buddies is dumb, not to mention buggy. I introduced this (these?)
bug back in January and told ChipX86 I'd revert it "soon" in March.
8 months is soon, right?
This fixes the online counts being wrong when you have a buddy in multiple
groups.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Mon, 21 Nov 2005 01:56:13 +0000 |
parents | 35c4797c5c57 |
children | ae190d00b06d |
comparison
equal
deleted
inserted
replaced
12175:a655bdeb561d | 12176:6f41d8d33989 |
---|---|
186 | 186 |
187 void | 187 void |
188 gaim_prpl_got_user_idle(GaimAccount *account, const char *name, | 188 gaim_prpl_got_user_idle(GaimAccount *account, const char *name, |
189 gboolean idle, time_t idle_time) | 189 gboolean idle, time_t idle_time) |
190 { | 190 { |
191 GSList *list, *iter; | 191 GaimBuddy *buddy; |
192 GaimPresence *presence; | |
192 | 193 |
193 g_return_if_fail(account != NULL); | 194 g_return_if_fail(account != NULL); |
194 g_return_if_fail(name != NULL); | 195 g_return_if_fail(name != NULL); |
195 g_return_if_fail(gaim_account_is_connected(account)); | 196 g_return_if_fail(gaim_account_is_connected(account)); |
196 | 197 |
197 list = gaim_find_buddies(account, name); | 198 if ((buddy = gaim_find_buddy(account, name)) == NULL) |
198 for (iter = list; iter != NULL; iter = iter->next) | 199 return; |
199 { | 200 |
200 GaimBuddy *buddy; | 201 presence = gaim_buddy_get_presence(buddy); |
201 GaimPresence *presence; | 202 |
202 | 203 gaim_presence_set_idle(presence, idle, idle_time); |
203 buddy = (GaimBuddy *)iter->data; | |
204 | |
205 presence = gaim_buddy_get_presence(buddy); | |
206 | |
207 gaim_presence_set_idle(presence, idle, idle_time); | |
208 } | |
209 g_slist_free(list); | |
210 } | 204 } |
211 | 205 |
212 void | 206 void |
213 gaim_prpl_got_user_login_time(GaimAccount *account, const char *name, | 207 gaim_prpl_got_user_login_time(GaimAccount *account, const char *name, |
214 time_t login_time) | 208 time_t login_time) |
215 { | 209 { |
216 GSList *list, *iter; | 210 GaimBuddy *buddy; |
211 GaimPresence *presence; | |
217 | 212 |
218 g_return_if_fail(account != NULL); | 213 g_return_if_fail(account != NULL); |
219 g_return_if_fail(name != NULL); | 214 g_return_if_fail(name != NULL); |
220 | 215 |
221 list = gaim_find_buddies(account, name); | 216 if ((buddy = gaim_find_buddy(account, name)) == NULL) |
222 for (iter = list; iter != NULL; iter = iter->next) | 217 return; |
223 { | 218 |
224 GaimBuddy *buddy; | 219 if (login_time == 0) |
225 GaimPresence *presence; | 220 login_time = time(NULL); |
226 | 221 |
227 buddy = (GaimBuddy *)iter->data; | 222 presence = gaim_buddy_get_presence(buddy); |
228 | 223 |
229 if (login_time == 0) | 224 gaim_presence_set_login_time(presence, login_time); |
230 login_time = time(NULL); | |
231 | |
232 presence = gaim_buddy_get_presence(buddy); | |
233 | |
234 gaim_presence_set_login_time(presence, login_time); | |
235 } | |
236 g_slist_free(list); | |
237 } | 225 } |
238 | 226 |
239 void | 227 void |
240 gaim_prpl_got_user_status(GaimAccount *account, const char *name, | 228 gaim_prpl_got_user_status(GaimAccount *account, const char *name, |
241 const char *status_id, const char *attr_id, ...) | 229 const char *status_id, const char *attr_id, ...) |
242 { | 230 { |
243 GSList *list, *iter; | 231 GSList *list, *iter; |
232 GaimBuddy *buddy; | |
233 GaimPresence *presence; | |
234 GaimStatus *status; | |
235 GaimStatus *old_status; | |
244 | 236 |
245 g_return_if_fail(account != NULL); | 237 g_return_if_fail(account != NULL); |
246 g_return_if_fail(name != NULL); | 238 g_return_if_fail(name != NULL); |
247 g_return_if_fail(status_id != NULL); | 239 g_return_if_fail(status_id != NULL); |
248 g_return_if_fail(gaim_account_is_connected(account)); | 240 g_return_if_fail(gaim_account_is_connected(account)); |
249 | 241 |
242 if ((buddy = gaim_find_buddy(account, name)) == NULL) | |
243 return; | |
244 | |
245 presence = gaim_buddy_get_presence(buddy); | |
246 status = gaim_presence_get_status(presence, status_id); | |
247 | |
248 g_return_if_fail(status != NULL); | |
249 | |
250 if (attr_id != NULL) | |
251 { | |
252 va_list args; | |
253 | |
254 va_start(args, attr_id); | |
255 | |
256 while (attr_id != NULL) | |
257 { | |
258 set_value_from_arg(status, attr_id, &args); | |
259 | |
260 attr_id = va_arg(args, char *); | |
261 } | |
262 | |
263 va_end(args); | |
264 } | |
265 | |
266 old_status = gaim_presence_get_active_status(presence); | |
267 gaim_presence_set_status_active(presence, status_id, TRUE); | |
268 | |
250 list = gaim_find_buddies(account, name); | 269 list = gaim_find_buddies(account, name); |
251 for (iter = list; iter != NULL; iter = iter->next) | 270 for (iter = list; iter != NULL; iter = iter->next) |
252 { | 271 { |
253 GaimBuddy *buddy; | |
254 GaimPresence *presence; | |
255 GaimStatus *status; | |
256 GaimStatus *old_status; | |
257 | |
258 buddy = (GaimBuddy *)iter->data; | 272 buddy = (GaimBuddy *)iter->data; |
259 presence = gaim_buddy_get_presence(buddy); | |
260 status = gaim_presence_get_status(presence, status_id); | |
261 | |
262 g_return_if_fail(status != NULL); | |
263 | |
264 if (attr_id != NULL) | |
265 { | |
266 va_list args; | |
267 | |
268 va_start(args, attr_id); | |
269 | |
270 while (attr_id != NULL) | |
271 { | |
272 set_value_from_arg(status, attr_id, &args); | |
273 | |
274 attr_id = va_arg(args, char *); | |
275 } | |
276 | |
277 va_end(args); | |
278 } | |
279 | |
280 old_status = gaim_presence_get_active_status(presence); | |
281 gaim_presence_set_status_active(presence, status_id, TRUE); | |
282 gaim_blist_update_buddy_status(buddy, old_status); | 273 gaim_blist_update_buddy_status(buddy, old_status); |
283 } | 274 } |
284 g_slist_free(list); | 275 g_slist_free(list); |
285 } | 276 } |
286 | 277 |