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.
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.
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.
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
21 #include "visibility.h"
23 /* Translators: This string is a menu option that, if selected, will cause
24 you to appear online to the chosen user even when your status is set to
26 #define APPEAR_ONLINE N_("Appear Online")
28 /* Translators: This string is a menu option that, if selected, will cause
29 you to appear offline to the chosen user when your status is set to
30 Invisible (this is the default). */
31 #define DONT_APPEAR_ONLINE N_("Don't Appear Online")
33 /* Translators: This string is a menu option that, if selected, will cause
34 you to always appear offline to the chosen user (even when your status
36 #define APPEAR_OFFLINE N_("Appear Offline")
38 /* Translators: This string is a menu option that, if selected, will cause
39 you to appear offline to the chosen user if you are invisible, and
40 appear online to the chosen user if you are not invisible (this is the
42 #define DONT_APPEAR_OFFLINE N_("Don't Appear Offline")
45 get_buddy_list_type(OscarData
*od
)
47 PurpleAccount
*account
= purple_connection_get_account(od
->gc
);
48 return purple_account_is_status_active(account
, OSCAR_STATUS_ID_INVISIBLE
) ? AIM_SSI_TYPE_PERMIT
: AIM_SSI_TYPE_DENY
;
52 is_buddy_on_list(OscarData
*od
, const char *bname
)
54 return aim_ssi_itemlist_finditem(&od
->ssi
.local
, NULL
, bname
, get_buddy_list_type(od
)) != NULL
;
58 visibility_cb(PurpleBlistNode
*node
, gpointer whatever
)
60 PurpleBuddy
*buddy
= PURPLE_BUDDY(node
);
61 const char* bname
= purple_buddy_get_name(buddy
);
62 OscarData
*od
= purple_connection_get_protocol_data(purple_account_get_connection(purple_buddy_get_account(buddy
)));
63 guint16 list_type
= get_buddy_list_type(od
);
65 if (!is_buddy_on_list(od
, bname
)) {
66 aim_ssi_add_to_private_list(od
, bname
, list_type
);
68 aim_ssi_del_from_private_list(od
, bname
, list_type
);
73 create_visibility_menu_item(OscarData
*od
, const char *bname
)
75 PurpleAccount
*account
= purple_connection_get_account(od
->gc
);
76 gboolean invisible
= purple_account_is_status_active(account
, OSCAR_STATUS_ID_INVISIBLE
);
77 gboolean on_list
= is_buddy_on_list(od
, bname
);
81 label
= on_list
? _(DONT_APPEAR_ONLINE
) : _(APPEAR_ONLINE
);
83 label
= on_list
? _(DONT_APPEAR_OFFLINE
) : _(APPEAR_OFFLINE
);
85 return purple_menu_action_new(label
, PURPLE_CALLBACK(visibility_cb
), NULL
, NULL
);
89 show_private_list(PurpleProtocolAction
*action
, guint16 list_type
, const gchar
*title
, const gchar
*list_description
, const gchar
*menu_action_name
)
91 PurpleConnection
*gc
= action
->connection
;
92 OscarData
*od
= purple_connection_get_protocol_data(gc
);
93 PurpleAccount
*account
= purple_connection_get_account(gc
);
94 GSList
*buddies
, *filtered_buddies
, *cur
;
95 gchar
*text
, *secondary
;
97 buddies
= purple_blist_find_buddies(account
, NULL
);
98 filtered_buddies
= NULL
;
99 for (cur
= buddies
; cur
!= NULL
; cur
= cur
->next
) {
104 bname
= purple_buddy_get_name(buddy
);
105 if (aim_ssi_itemlist_finditem(&od
->ssi
.local
, NULL
, bname
, list_type
)) {
106 filtered_buddies
= g_slist_prepend(filtered_buddies
, buddy
);
110 g_slist_free(buddies
);
112 filtered_buddies
= g_slist_reverse(filtered_buddies
);
113 text
= oscar_format_buddies(filtered_buddies
, _("you have no buddies on this list"));
114 g_slist_free(filtered_buddies
);
116 secondary
= g_strdup_printf(_("You can add a buddy to this list "
117 "by right-clicking on them and "
118 "selecting \"%s\""), menu_action_name
);
119 purple_notify_formatted(gc
, title
, list_description
, secondary
, text
, NULL
, NULL
);
125 oscar_show_visible_list(PurpleProtocolAction
*action
)
127 show_private_list(action
, AIM_SSI_TYPE_PERMIT
, _("Visible List"),
128 _("These buddies can see your status even when you're "
134 oscar_show_invisible_list(PurpleProtocolAction
*action
)
136 show_private_list(action
, AIM_SSI_TYPE_DENY
, _("Invisible List"),
137 _("These buddies will always see you as offline."),