14192
|
1 /**
|
|
2 * @file dialog.c Dialog functions
|
|
3 *
|
|
4 * gaim
|
|
5 *
|
|
6 * Gaim is the legal property of its developers, whose names are too numerous
|
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this
|
|
8 * source distribution.
|
|
9 *
|
|
10 * This program is free software; you can redistribute it and/or modify
|
|
11 * it under the terms of the GNU General Public License as published by
|
|
12 * the Free Software Foundation; either version 2 of the License, or
|
|
13 * (at your option) any later version.
|
|
14 *
|
|
15 * This program is distributed in the hope that it will be useful,
|
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 * GNU General Public License for more details.
|
|
19 *
|
|
20 * You should have received a copy of the GNU General Public License
|
|
21 * along with this program; if not, write to the Free Software
|
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
23 */
|
|
24
|
|
25 #include "msn.h"
|
|
26 #include "dialog.h"
|
|
27
|
|
28 typedef struct
|
|
29 {
|
|
30 GaimConnection *gc;
|
|
31 char *who;
|
|
32 char *group;
|
|
33 gboolean add;
|
|
34
|
|
35 } MsnAddRemData;
|
|
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
|
|
57 static void
|
|
58 msn_add_cb(MsnAddRemData *data)
|
|
59 {
|
|
60 MsnSession *session;
|
|
61 MsnUserList *userlist;
|
|
62
|
|
63 msn_complete_sync_issue(data);
|
|
64
|
|
65 session = data->gc->proto_data;
|
|
66 userlist = session->userlist;
|
|
67
|
|
68 msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group);
|
|
69
|
|
70 g_free(data->group);
|
|
71 g_free(data->who);
|
|
72 g_free(data);
|
|
73 }
|
|
74
|
|
75 static void
|
|
76 msn_rem_cb(MsnAddRemData *data)
|
|
77 {
|
|
78 MsnSession *session;
|
|
79 MsnUserList *userlist;
|
|
80
|
|
81 msn_complete_sync_issue(data);
|
|
82
|
|
83 session = data->gc->proto_data;
|
|
84 userlist = session->userlist;
|
|
85
|
|
86 msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group);
|
|
87
|
|
88 g_free(data->group);
|
|
89 g_free(data->who);
|
|
90 g_free(data);
|
|
91 }
|
|
92
|
|
93 void
|
|
94 msn_show_sync_issue(MsnSession *session, const char *passport,
|
|
95 const char *group_name)
|
|
96 {
|
|
97 GaimConnection *gc;
|
|
98 GaimAccount *account;
|
|
99 MsnAddRemData *data;
|
|
100 char *msg, *reason;
|
|
101
|
|
102 account = session->account;
|
|
103 gc = gaim_account_get_connection(account);
|
|
104
|
|
105 data = g_new0(MsnAddRemData, 1);
|
|
106 data->who = g_strdup(passport);
|
|
107 data->group = g_strdup(group_name);
|
|
108 data->gc = gc;
|
|
109
|
|
110 msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"),
|
|
111 gaim_account_get_username(account),
|
|
112 gaim_account_get_protocol_name(account));
|
|
113
|
|
114 if (group_name != NULL)
|
|
115 {
|
|
116 reason = g_strdup_printf(_("%s on the local list is "
|
|
117 "inside the group \"%s\" but not on "
|
|
118 "the server list. "
|
|
119 "Do you want this buddy to be added?"),
|
|
120 passport, group_name);
|
|
121 }
|
|
122 else
|
|
123 {
|
|
124 reason = g_strdup_printf(_("%s is on the local list but "
|
|
125 "not on the server list. "
|
|
126 "Do you want this buddy to be added?"),
|
|
127 passport);
|
|
128 }
|
|
129
|
|
130 gaim_request_action(gc, NULL, msg, reason, GAIM_DEFAULT_ACTION_NONE,
|
|
131 data, 2,
|
|
132 _("Yes"), G_CALLBACK(msn_add_cb),
|
|
133 _("No"), G_CALLBACK(msn_rem_cb));
|
|
134
|
|
135 g_free(reason);
|
|
136 g_free(msg);
|
|
137 }
|