Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/session.c @ 27076:1fcd09c34fee
Use purple_find_buddies() instead of iterating the buddy list.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 01 Jun 2009 04:02:10 +0000 |
parents | 0c796a1950b7 |
children | f541583e31bd |
comparison
equal
deleted
inserted
replaced
27075:5ff1d66e6aef | 27076:1fcd09c34fee |
---|---|
259 } | 259 } |
260 | 260 |
261 static void | 261 static void |
262 msn_session_sync_users(MsnSession *session) | 262 msn_session_sync_users(MsnSession *session) |
263 { | 263 { |
264 PurpleBlistNode *gnode, *cnode, *bnode; | |
265 PurpleConnection *gc = purple_account_get_connection(session->account); | 264 PurpleConnection *gc = purple_account_get_connection(session->account); |
266 GList *to_remove = NULL; | 265 GList *to_remove = NULL; |
266 GSList *buddies; | |
267 | 267 |
268 g_return_if_fail(gc != NULL); | 268 g_return_if_fail(gc != NULL); |
269 | 269 |
270 /* The core used to use msn_add_buddy to add all buddies before | 270 /* The core used to use msn_add_buddy to add all buddies before |
271 * being logged in. This no longer happens, so we manually iterate | 271 * being logged in. This no longer happens, so we manually iterate |
272 * over the whole buddy list to identify sync issues. | 272 * over the whole buddy list to identify sync issues. |
273 */ | 273 */ |
274 for (gnode = purple_blist_get_root(); gnode; | 274 for (buddies = purple_find_buddies(session->account, NULL); buddies; |
275 gnode = purple_blist_node_get_sibling_next(gnode)) { | 275 buddies = g_slist_delete_link(buddies, buddies)) { |
276 PurpleGroup *group = (PurpleGroup *)gnode; | 276 PurpleBuddy *buddy = buddies->data; |
277 const char *group_name; | 277 const gchar *buddy_name = purple_buddy_get_name(buddy); |
278 if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) | 278 const gchar *group_name = purple_group_get_name(purple_buddy_get_group(buddy)); |
279 continue; | 279 MsnUser *remote_user; |
280 group_name = purple_group_get_name(group); | 280 gboolean found = FALSE; |
281 for(cnode = purple_blist_node_get_first_child(gnode); | 281 |
282 cnode; | 282 remote_user = msn_userlist_find_user(session->userlist, buddy_name); |
283 cnode = purple_blist_node_get_sibling_next(cnode)) { | 283 if (remote_user && remote_user->list_op & MSN_LIST_FL_OP) { |
284 if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) | 284 GList *l; |
285 continue; | 285 for (l = remote_user->group_ids; l; l = l->next) { |
286 for(bnode = purple_blist_node_get_first_child(cnode); | 286 const char *name = msn_userlist_find_group_name(remote_user->userlist, l->data); |
287 bnode; | 287 if (name && !g_ascii_strcasecmp(group_name, name)) { |
288 bnode = purple_blist_node_get_sibling_next(bnode)) { | 288 found = TRUE; |
289 PurpleBuddy *b; | 289 break; |
290 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | 290 } |
291 continue; | 291 } |
292 b = (PurpleBuddy *)bnode; | 292 |
293 if(purple_buddy_get_account(b) == purple_connection_get_account(gc)) { | 293 /* We don't care if they're in a different group, as long as they're on the |
294 MsnUser *remote_user; | 294 * list somewhere. If we check for the group, we cause pain, agony and |
295 gboolean found = FALSE; | 295 * suffering for people who decide to re-arrange their buddy list elsewhere. |
296 | 296 */ |
297 remote_user = msn_userlist_find_user(session->userlist, purple_buddy_get_name(b)); | 297 if (!found) { |
298 | 298 if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) { |
299 if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)) | 299 /* The user is not on the server list */ |
300 { | 300 msn_show_sync_issue(session, buddy_name, group_name); |
301 GList *l; | 301 } else { |
302 | 302 /* The user is not in that group on the server list */ |
303 for (l = remote_user->group_ids; l != NULL; l = l->next) | 303 to_remove = g_list_prepend(to_remove, buddy); |
304 { | |
305 const char *name = msn_userlist_find_group_name(remote_user->userlist, l->data); | |
306 if (name && !g_ascii_strcasecmp(group_name, name)) | |
307 { | |
308 found = TRUE; | |
309 break; | |
310 } | |
311 } | |
312 } | |
313 | |
314 /* We don't care if they're in a different group, as long as they're on the | |
315 * list somewhere. If we check for the group, we cause pain, agony and | |
316 * suffering for people who decide to re-arrange their buddy list elsewhere. | |
317 */ | |
318 if (!found) | |
319 { | |
320 if ((remote_user == NULL) || !(remote_user->list_op & MSN_LIST_FL_OP)) { | |
321 /* The user is not on the server list */ | |
322 msn_show_sync_issue(session, purple_buddy_get_name(b), group_name); | |
323 } else { | |
324 /* The user is not in that group on the server list */ | |
325 to_remove = g_list_prepend(to_remove, b); | |
326 } | |
327 } | |
328 } | 304 } |
329 } | 305 } |
330 } | 306 } |
331 } | 307 } |
332 | 308 |