comparison libpurple/protocols/msn/dialog.c @ 20394:4a099e4d0d09

propagate from branch 'im.pidgin.pidgin' (head 98b6b547b29ea1192b73cc4e1de1e674edef4328) to branch 'im.pidgin.rlaager.merging.msnp13-and-pidgin' (head 4d82c29e56bd33cd6f94302e343dfeb5d68ab3eb)
author Richard Laager <rlaager@wiktel.com>
date Sun, 15 Apr 2007 03:43:17 +0000
parents 32c366eeeb99
children 6f986caeab59
comparison
equal deleted inserted replaced
20393:40a04930b233 20394:4a099e4d0d09
1 /**
2 * @file dialog.c Dialog functions
3 *
4 * purple
5 *
6 * Purple 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 PurpleConnection *gc;
31 char *who;
32 char *group;
33 gboolean add;
34
35 } MsnAddRemData;
36
37 static void
38 msn_add_cb(MsnAddRemData *data)
39 {
40 if (g_list_find(purple_connections_get_all(), data->gc) != NULL)
41 {
42 MsnSession *session = data->gc->proto_data;
43 MsnUserList *userlist = session->userlist;
44
45 msn_userlist_add_buddy(userlist, data->who, MSN_LIST_FL, data->group);
46 }
47
48 g_free(data->group);
49 g_free(data->who);
50 g_free(data);
51 }
52
53 static void
54 msn_rem_cb(MsnAddRemData *data)
55 {
56 if (g_list_find(purple_connections_get_all(), data->gc) != NULL)
57 {
58 MsnSession *session = data->gc->proto_data;
59 MsnUserList *userlist = session->userlist;
60
61 msn_userlist_rem_buddy(userlist, data->who, MSN_LIST_FL, data->group);
62 }
63
64 g_free(data->group);
65 g_free(data->who);
66 g_free(data);
67 }
68
69 void
70 msn_show_sync_issue(MsnSession *session, const char *passport,
71 const char *group_name)
72 {
73 PurpleConnection *gc;
74 PurpleAccount *account;
75 MsnAddRemData *data;
76 char *msg, *reason;
77 PurpleBuddy *buddy;
78 PurpleGroup *group = NULL;
79
80 account = session->account;
81 gc = purple_account_get_connection(account);
82
83 data = g_new0(MsnAddRemData, 1);
84 data->who = g_strdup(passport);
85 data->group = g_strdup(group_name);
86 data->gc = gc;
87
88 msg = g_strdup_printf(_("Buddy list synchronization issue in %s (%s)"),
89 purple_account_get_username(account),
90 purple_account_get_protocol_name(account));
91
92 if (group_name != NULL)
93 {
94 reason = g_strdup_printf(_("%s on the local list is "
95 "inside the group \"%s\" but not on "
96 "the server list. "
97 "Do you want this buddy to be added?"),
98 passport, group_name);
99 }
100 else
101 {
102 reason = g_strdup_printf(_("%s is on the local list but "
103 "not on the server list. "
104 "Do you want this buddy to be added?"),
105 passport);
106 }
107
108 purple_request_action(gc, NULL, msg, reason, PURPLE_DEFAULT_ACTION_NONE,
109 data, 2,
110 _("Yes"), G_CALLBACK(msn_add_cb),
111 _("No"), G_CALLBACK(msn_rem_cb));
112
113 if (group_name != NULL)
114 group = purple_find_group(group_name);
115
116 if (group != NULL)
117 buddy = purple_find_buddy_in_group(account, passport, group);
118 else
119 buddy = purple_find_buddy(account, passport);
120
121 if (buddy != NULL)
122 purple_blist_remove_buddy(buddy);
123
124 g_free(reason);
125 g_free(msg);
126 }