aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sound-service-dbus.c56
-rw-r--r--src/sound-service.xml6
2 files changed, 55 insertions, 7 deletions
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index b493ce8..43d7360 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);
@@ -281,7 +283,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 +307,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 +385,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;
+}
diff --git a/src/sound-service.xml b/src/sound-service.xml
index 81ebc2d..517088e 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -7,6 +7,12 @@
<arg type='b' name='blacklist' direction="in"/>
<arg type='b' name='result' direction="out"/>
</method>
+ <method name = "IsBlacklisted">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type='s' name='player_desktop_name' direction="in"/>
+ <arg type='b' name='result' direction="out"/>
+ </method>
+
<method name = "GetSoundState">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type='i' name='current_state' direction="out"/>