diff options
Diffstat (limited to 'src/sound-service-dbus.c')
-rw-r--r-- | src/sound-service-dbus.c | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c index b493ce8..8d0cc0b 100644 --- a/src/sound-service-dbus.c +++ b/src/sound-service-dbus.c @@ -74,6 +74,8 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, gchar* player_name, gboolean blacklist); +static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus* self, + gchar* player_name); G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT); @@ -147,7 +149,10 @@ sound_service_dbus_create_root_item (SoundServiceDbus* self) SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self); priv->root_menuitem = dbusmenu_menuitem_new(); g_debug("Root ID: %d", dbusmenu_menuitem_get_id(priv->root_menuitem)); - DbusmenuServer *server = dbusmenu_server_new(INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH); + DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH); + const gchar* paths[] = {"/usr/share/banshee-1/icons", NULL}; + dbusmenu_server_set_icon_paths (server, + paths); dbusmenu_server_set_root (server, priv->root_menuitem); g_object_unref (priv->root_menuitem); priv->active_sink = active_sink_new (self); @@ -281,7 +286,16 @@ bus_method_call (GDBusConnection * connection, player_name, blacklist); retval = g_variant_new ("(b)", result); - } + } + else if (g_strcmp0(method, "IsBlacklisted") == 0) { + gchar* player_name; + g_variant_get (params, "(s)", &player_name); + + g_debug ("IsBlacklisted - name %s", player_name); + gboolean result = sound_service_dbus_is_blacklisted (service, + player_name); + retval = g_variant_new ("(b)", result); + } else { g_warning("Calling method '%s' on the sound service but it's unknown", method); } @@ -296,17 +310,18 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, gboolean blacklist) { g_return_val_if_fail (player_name != NULL, FALSE); + g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE); + GVariant* the_black_list; gboolean result = FALSE; - GSettings* our_settings = NULL; - our_settings = g_settings_new ("com.canonical.indicators.sound"); - GVariant* the_black_list = g_settings_get_value (our_settings, - "blacklisted-media-players"); + GSettings* our_settings; GVariantIter iter; gchar *str; - // Firstly prep new array which will be set on the key. GVariantBuilder builder; - + + our_settings = g_settings_new ("com.canonical.indicators.sound"); + the_black_list = g_settings_get_value (our_settings, + "blacklisted-media-players"); g_variant_iter_init (&iter, the_black_list); g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY); @@ -373,4 +388,34 @@ static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self, return result; } +static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus *self, + gchar *player_name) +{ + GSettings *our_settings; + GVariant *the_black_list; + GVariantIter iter; + gchar *str; + gboolean result = FALSE; + + g_return_val_if_fail (player_name != NULL, FALSE); + g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE); + + our_settings = g_settings_new ("com.canonical.indicators.sound"); + the_black_list = g_settings_get_value (our_settings, + "blacklisted-media-players"); + g_variant_iter_init (&iter, the_black_list); + while (g_variant_iter_next (&iter, "s", &str)){ + if (g_strcmp0 (player_name, str) == 0) { + result = TRUE; + g_free (str); + break; + } + g_free (str); + } + + g_object_unref (our_settings); + g_variant_unref (the_black_list); + + return result; +} |