diff libpurple/protocols/oscar/visibility.c @ 30373:4e804413b12b

Added a way to view the Visible/Invisible lists. The UI is kind of crippled, but that seems to be the best we can do with the notify API.
author ivan.komarov@soc.pidgin.im
date Tue, 29 Jun 2010 21:17:02 +0000
parents 5bfef3338383
children 48fe4720d795
line wrap: on
line diff
--- a/libpurple/protocols/oscar/visibility.c	Mon Jun 28 20:02:12 2010 +0000
+++ b/libpurple/protocols/oscar/visibility.c	Tue Jun 29 21:17:02 2010 +0000
@@ -57,8 +57,58 @@
 	data->list_type = list_type;
 	data->add_to_list = !on_list;
 
-	label = g_strdup_printf("%s %s", on_list ? "Don't appear" : "Appear", invisible ? "online" : "offline");
+	label = g_strdup_printf("%s %s", on_list ? "Don't appear" : "Appear", invisible ? "Online" : "Offline");
 	result = purple_menu_action_new(label, PURPLE_CALLBACK(visibility_cb), data, NULL);
 	g_free(label);
 	return result;
 }
+
+static void
+show_private_list(PurplePluginAction *action, guint16 list_type, const gchar *list_description, const gchar *menu_action_name)
+{
+	PurpleConnection *gc = (PurpleConnection *) action->context;
+	OscarData *od = purple_connection_get_protocol_data(gc);
+	PurpleAccount *account = purple_connection_get_account(gc);
+	GSList *buddies, *filtered_buddies, *cur;
+	gchar *text, *secondary;
+
+	buddies = purple_find_buddies(account, NULL);
+	filtered_buddies = NULL;
+	for (cur = buddies; cur != NULL; cur = cur->next) {
+		PurpleBuddy *buddy;
+		const gchar *bname;
+
+		buddy = cur->data;
+		bname = purple_buddy_get_name(buddy);
+		if (aim_ssi_itemlist_finditem(od->ssi.local, NULL, bname, list_type)) {
+			filtered_buddies = g_slist_prepend(filtered_buddies, buddy);
+		}
+	}
+
+	g_slist_free(buddies);
+
+	filtered_buddies = g_slist_reverse(filtered_buddies);
+	text = oscar_format_buddies(filtered_buddies, "you have no buddies on this list");
+	g_slist_free(filtered_buddies);
+
+	secondary = g_strdup_printf("You can add a buddy to this list "
+					"by right-clicking on them and "
+					"selecting \"%s\"", menu_action_name);
+	purple_notify_formatted(gc, NULL, list_description, secondary, text, NULL, NULL);
+	g_free(secondary);
+	g_free(text);
+}
+
+void
+oscar_show_visible_list(PurplePluginAction *action)
+{
+	show_private_list(action, AIM_SSI_TYPE_PERMIT, "These buddies will always see "
+							"your status, even when you switch "
+							"to \"Invisible\"", "Appear Online");
+}
+
+void
+oscar_show_invisible_list(PurplePluginAction *action)
+{
+	show_private_list(action, AIM_SSI_TYPE_DENY, "These buddies will always see you as offline", "Appear Offline");
+}
\ No newline at end of file