comparison src/protocols/msn/dialog.c @ 13905:4e44ecb866bd

[gaim-migrate @ 16394] 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(). committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Sun, 02 Jul 2006 09:37:25 +0000
parents 90f488e08216
children 6fc412e59214
comparison
equal deleted inserted replaced
13904:863feae7fefa 13905:4e44ecb866bd
32 char *group; 32 char *group;
33 gboolean add; 33 gboolean add;
34 34
35 } MsnAddRemData; 35 } MsnAddRemData;
36 36
37 /* Remove the buddy referenced by the MsnAddRemData before the serverside list is changed.
38 * If the buddy will be added, he'll be added back; if he will be removed, he won't be. */
39 static void
40 msn_complete_sync_issue(MsnAddRemData *data)
41 {
42 GaimBuddy *buddy;
43 GaimGroup *group = NULL;
44
45 if (data->group != NULL)
46 group = gaim_find_group(data->group);
47
48 if (group != NULL)
49 buddy = gaim_find_buddy_in_group(gaim_connection_get_account(data->gc), data->who, group);
50 else
51 buddy = gaim_find_buddy(gaim_connection_get_account(data->gc), data->who);
52
53 if (buddy != NULL)
54 gaim_blist_remove_buddy(buddy);
55 }
56
37 static void 57 static void
38 msn_add_cb(MsnAddRemData *data) 58 msn_add_cb(MsnAddRemData *data)
39 { 59 {
60 msn_complete_sync_issue(data);
61
40 if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) 62 if (g_list_find(gaim_connections_get_all(), data->gc) != NULL)
41 { 63 {
42 MsnSession *session = data->gc->proto_data; 64 MsnSession *session = data->gc->proto_data;
43 MsnUserList *userlist = session->userlist; 65 MsnUserList *userlist = session->userlist;
44 66
53 } 75 }
54 76
55 static void 77 static void
56 msn_rem_cb(MsnAddRemData *data) 78 msn_rem_cb(MsnAddRemData *data)
57 { 79 {
80 msn_complete_sync_issue(data);
81
58 if (g_list_find(gaim_connections_get_all(), data->gc) != NULL) 82 if (g_list_find(gaim_connections_get_all(), data->gc) != NULL)
59 { 83 {
60 MsnSession *session = data->gc->proto_data; 84 MsnSession *session = data->gc->proto_data;
61 MsnUserList *userlist = session->userlist; 85 MsnUserList *userlist = session->userlist;
62 86
76 { 100 {
77 GaimConnection *gc; 101 GaimConnection *gc;
78 GaimAccount *account; 102 GaimAccount *account;
79 MsnAddRemData *data; 103 MsnAddRemData *data;
80 char *msg, *reason; 104 char *msg, *reason;
81 GaimBuddy *buddy;
82 GaimGroup *group = NULL;
83 105
84 account = session->account; 106 account = session->account;
85 gc = gaim_account_get_connection(account); 107 gc = gaim_account_get_connection(account);
86 108
87 data = g_new0(MsnAddRemData, 1); 109 data = g_new0(MsnAddRemData, 1);
112 gaim_request_action(gc, NULL, msg, reason, GAIM_DEFAULT_ACTION_NONE, 134 gaim_request_action(gc, NULL, msg, reason, GAIM_DEFAULT_ACTION_NONE,
113 data, 2, 135 data, 2,
114 _("Yes"), G_CALLBACK(msn_add_cb), 136 _("Yes"), G_CALLBACK(msn_add_cb),
115 _("No"), G_CALLBACK(msn_rem_cb)); 137 _("No"), G_CALLBACK(msn_rem_cb));
116 138
117 if (group_name != NULL)
118 group = gaim_find_group(group_name);
119
120 if (group != NULL)
121 buddy = gaim_find_buddy_in_group(account, passport, group);
122 else
123 buddy = gaim_find_buddy(account, passport);
124
125 if (buddy != NULL)
126 gaim_blist_remove_buddy(buddy);
127
128 g_free(reason); 139 g_free(reason);
129 g_free(msg); 140 g_free(msg);
130 } 141 }