| |
1 /* |
| |
2 * Purple's oscar protocol plugin |
| |
3 * This file is the legal property of its developers. |
| |
4 * Please see the AUTHORS file distributed alongside this file. |
| |
5 * |
| |
6 * This library is free software; you can redistribute it and/or |
| |
7 * modify it under the terms of the GNU Lesser General Public |
| |
8 * License as published by the Free Software Foundation; either |
| |
9 * version 2 of the License, or (at your option) any later version. |
| |
10 * |
| |
11 * This library is distributed in the hope that it will be useful, |
| |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| |
14 * Lesser General Public License for more details. |
| |
15 * |
| |
16 * You should have received a copy of the GNU Lesser General Public |
| |
17 * License along with this library; if not, write to the Free Software |
| |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| |
19 */ |
| |
20 |
| |
21 #include "visibility.h" |
| |
22 |
| |
23 struct visibility_cb_data |
| |
24 { |
| |
25 guint16 list_type; |
| |
26 gboolean add_to_list; |
| |
27 }; |
| |
28 |
| |
29 static void |
| |
30 visibility_cb(PurpleBlistNode *node, struct visibility_cb_data *data) |
| |
31 { |
| |
32 PurpleBuddy *buddy = PURPLE_BUDDY(node); |
| |
33 const char* bname = purple_buddy_get_name(buddy); |
| |
34 OscarData *od = purple_account_get_connection(purple_buddy_get_account(buddy))->proto_data; |
| |
35 |
| |
36 if (data->add_to_list) { |
| |
37 aim_ssi_add_to_private_list(od, bname, data->list_type); |
| |
38 } else { |
| |
39 aim_ssi_del_from_private_list(od, bname, data->list_type); |
| |
40 } |
| |
41 |
| |
42 g_free(data); |
| |
43 } |
| |
44 |
| |
45 PurpleMenuAction * |
| |
46 create_visibility_menu_item(OscarData *od, const char *bname) |
| |
47 { |
| |
48 PurpleAccount *account = purple_connection_get_account(od->gc); |
| |
49 gboolean invisible = purple_account_is_status_active(account, OSCAR_STATUS_ID_INVISIBLE); |
| |
50 guint16 list_type = invisible ? AIM_SSI_TYPE_PERMIT : AIM_SSI_TYPE_DENY; |
| |
51 gboolean on_list = aim_ssi_itemlist_finditem(od->ssi.local, NULL, bname, list_type) != NULL; |
| |
52 gchar *label; |
| |
53 struct visibility_cb_data *data; |
| |
54 PurpleMenuAction *result; |
| |
55 |
| |
56 data = g_new0(struct visibility_cb_data, 1); |
| |
57 data->list_type = list_type; |
| |
58 data->add_to_list = !on_list; |
| |
59 |
| |
60 label = g_strdup_printf("%s %s", on_list ? "Don't appear" : "Appear", invisible ? "online" : "offline"); |
| |
61 result = purple_menu_action_new(label, PURPLE_CALLBACK(visibility_cb), data, NULL); |
| |
62 g_free(label); |
| |
63 return result; |
| |
64 } |