Merge lp:~cjcurran/indicator-sound/is_blacklisted_dbus_method into lp:~indicator-applet-developers/indicator-sound/trunk_3

Proposed by Conor Curran
Status: Merged
Merged at revision: 214
Proposed branch: lp:~cjcurran/indicator-sound/is_blacklisted_dbus_method
Merge into: lp:~indicator-applet-developers/indicator-sound/trunk_3
Diff against target: 107 lines (+55/-7)
2 files modified
src/sound-service-dbus.c (+49/-7)
src/sound-service.xml (+6/-0)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/is_blacklisted_dbus_method
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+52425@code.launchpad.net

Description of the change

Fixed

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sound-service-dbus.c'
2--- src/sound-service-dbus.c 2011-03-01 11:23:15 +0000
3+++ src/sound-service-dbus.c 2011-03-07 15:28:35 +0000
4@@ -74,6 +74,8 @@
5 gchar* player_name,
6 gboolean blacklist);
7
8+static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus* self,
9+ gchar* player_name);
10
11 G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
12
13@@ -281,7 +283,16 @@
14 player_name,
15 blacklist);
16 retval = g_variant_new ("(b)", result);
17- }
18+ }
19+ else if (g_strcmp0(method, "IsBlacklisted") == 0) {
20+ gchar* player_name;
21+ g_variant_get (params, "(s)", &player_name);
22+
23+ g_debug ("IsBlacklisted - name %s", player_name);
24+ gboolean result = sound_service_dbus_is_blacklisted (service,
25+ player_name);
26+ retval = g_variant_new ("(b)", result);
27+ }
28 else {
29 g_warning("Calling method '%s' on the sound service but it's unknown", method);
30 }
31@@ -296,17 +307,18 @@
32 gboolean blacklist)
33 {
34 g_return_val_if_fail (player_name != NULL, FALSE);
35+ g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE);
36
37+ GVariant* the_black_list;
38 gboolean result = FALSE;
39- GSettings* our_settings = NULL;
40- our_settings = g_settings_new ("com.canonical.indicators.sound");
41- GVariant* the_black_list = g_settings_get_value (our_settings,
42- "blacklisted-media-players");
43+ GSettings* our_settings;
44 GVariantIter iter;
45 gchar *str;
46- // Firstly prep new array which will be set on the key.
47 GVariantBuilder builder;
48-
49+
50+ our_settings = g_settings_new ("com.canonical.indicators.sound");
51+ the_black_list = g_settings_get_value (our_settings,
52+ "blacklisted-media-players");
53 g_variant_iter_init (&iter, the_black_list);
54 g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY);
55
56@@ -373,4 +385,34 @@
57 return result;
58 }
59
60+static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus *self,
61+ gchar *player_name)
62+{
63+ GSettings *our_settings;
64+ GVariant *the_black_list;
65+ GVariantIter iter;
66+ gchar *str;
67+ gboolean result = FALSE;
68+
69+ g_return_val_if_fail (player_name != NULL, FALSE);
70+ g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE);
71+
72+ our_settings = g_settings_new ("com.canonical.indicators.sound");
73+ the_black_list = g_settings_get_value (our_settings,
74+ "blacklisted-media-players");
75+ g_variant_iter_init (&iter, the_black_list);
76+ while (g_variant_iter_next (&iter, "s", &str)){
77+ if (g_strcmp0 (player_name, str) == 0) {
78+ result = TRUE;
79+ g_free (str);
80+ break;
81+ }
82+ g_free (str);
83+ }
84+
85+ g_object_unref (our_settings);
86+ g_variant_unref (the_black_list);
87+
88+ return result;
89+}
90
91
92=== modified file 'src/sound-service.xml'
93--- src/sound-service.xml 2011-01-31 19:14:47 +0000
94+++ src/sound-service.xml 2011-03-07 15:28:35 +0000
95@@ -7,6 +7,12 @@
96 <arg type='b' name='blacklist' direction="in"/>
97 <arg type='b' name='result' direction="out"/>
98 </method>
99+ <method name = "IsBlacklisted">
100+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
101+ <arg type='s' name='player_desktop_name' direction="in"/>
102+ <arg type='b' name='result' direction="out"/>
103+ </method>
104+
105 <method name = "GetSoundState">
106 <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
107 <arg type='i' name='current_state' direction="out"/>

Subscribers

People subscribed via source and target branches