From: <ev...@us...> - 2006-07-02 09:37:33
|
Revision: 16394 Author: evands Date: 2006-07-02 02:37:25 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16394&view=rev Log Message: ----------- msn_session_sync_users() iterates over the buddy list, following the ->next pointers of the groups, contacts, and buddies. msn_show_sync_issue(), if called, removed the buddy for which it was called, in preparation for the buddy either being added to the server list or confirmed-to-be-removed. This could lead to the buddy pointer being released and ->next therefore being junk. The buddy is now not removed until the user responds to the action dialog presented via msn_show_sync_issue(). I'm unclear why gtkgaim got away with this exercise in memory stomping but Adium/libgaim crashed every time, but it's safer in any case. I also changed some foo->bar to gaim_foo_get_bar(). Modified Paths: -------------- trunk/src/protocols/msn/dialog.c trunk/src/protocols/msn/session.c Modified: trunk/src/protocols/msn/dialog.c =================================================================== --- trunk/src/protocols/msn/dialog.c 2006-07-01 23:21:12 UTC (rev 16393) +++ trunk/src/protocols/msn/dialog.c 2006-07-02 09:37:25 UTC (rev 16394) @@ -34,9 +34,31 @@ } MsnAddRemData; +/* Remove the buddy referenced by the MsnAddRemData before the serverside list is changed. + * If the buddy will be added, he'll be added back; if he will be removed, he won't be. */ static void +msn_complete_sync_issue(MsnAddRemData *data) +{ + GaimBuddy *buddy; + GaimGroup *group = NULL; + + if (data->group != NULL) + group = gaim_find_group(data->group); + + if (group != NULL) + buddy = gaim_find_buddy_in_group(gaim_connection_get_account(data->gc), data->who, group); + else + buddy = gaim_find_buddy(gaim_connection_get_account(data->gc), data->who); + + if (buddy != NULL) + gaim_blist_remove_buddy(buddy); +} + +static void msn_add_cb(MsnAddRemData *data) { + msn_complete_sync_issue(data); + if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) { MsnSession *session = data->gc->proto_data; @@ -55,6 +77,8 @@ static void msn_rem_cb(MsnAddRemData *data) { + msn_complete_sync_issue(data); + if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) { MsnSession *session = data->gc->proto_data; @@ -78,8 +102,6 @@ GaimAccount *account; MsnAddRemData *data; char *msg, *reason; - GaimBuddy *buddy; - GaimGroup *group = NULL; account = session->account; gc = gaim_account_get_connection(account); @@ -114,17 +136,6 @@ _("Yes"), G_CALLBACK(msn_add_cb), _("No"), G_CALLBACK(msn_rem_cb)); - if (group_name != NULL) - group = gaim_find_group(group_name); - - if (group != NULL) - buddy = gaim_find_buddy_in_group(account, passport, group); - else - buddy = gaim_find_buddy(account, passport); - - if (buddy != NULL) - gaim_blist_remove_buddy(buddy); - g_free(reason); g_free(msg); } Modified: trunk/src/protocols/msn/session.c =================================================================== --- trunk/src/protocols/msn/session.c 2006-07-01 23:21:12 UTC (rev 16393) +++ trunk/src/protocols/msn/session.c 2006-07-02 09:37:25 UTC (rev 16394) @@ -231,7 +231,7 @@ * being logged in. This no longer happens, so we manually iterate * over the whole buddy list to identify sync issues. */ - for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { + for (gnode = gaim_blist_get_root(); gnode; gnode = gnode->next) { GaimGroup *group = (GaimGroup *)gnode; const char *group_name = group->name; if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) @@ -244,11 +244,11 @@ if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) continue; b = (GaimBuddy *)bnode; - if(b->account == gc->account) { + if(gaim_buddy_get_account(b) == gaim_connection_get_account(gc)) { MsnUser *remote_user; gboolean found = FALSE; - remote_user = msn_userlist_find_user(session->userlist, b->name); + remote_user = msn_userlist_find_user(session->userlist, gaim_buddy_get_name(b)); if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)) { @@ -273,7 +273,7 @@ { /* The user was not on the server list or not in that group * on the server list */ - msn_show_sync_issue(session, b->name, group_name); + msn_show_sync_issue(session, gaim_buddy_get_name(b), group_name); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |