[rygel] core,mpris: Make use of GDBus prop change API
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,mpris: Make use of GDBus prop change API
- Date: Wed, 17 Nov 2010 15:15:19 +0000 (UTC)
commit faefb6600d0b2d2ed5613627a36cc0cb73cbaea7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Nov 17 15:33:28 2010 +0200
core,mpris: Make use of GDBus prop change API
No need for using FreeDesktop.Properties.properties_changed when GDBus
provides us an API to hook to property changes.
src/plugins/mpris/rygel-mpris-player.vala | 43 +++++++++++++++-----------
src/plugins/mpris/rygel-mpris-plugin.vala | 8 -----
src/rygel/rygel-free-desktop-interfaces.vala | 5 ---
3 files changed, 25 insertions(+), 31 deletions(-)
---
diff --git a/src/plugins/mpris/rygel-mpris-player.vala b/src/plugins/mpris/rygel-mpris-player.vala
index c98fb1f..44bcef5 100644
--- a/src/plugins/mpris/rygel-mpris-player.vala
+++ b/src/plugins/mpris/rygel-mpris-player.vala
@@ -30,7 +30,6 @@ public class Rygel.MPRIS.Player : GLib.Object, Rygel.MediaPlayer {
private string[] mime_types;
private PlayerProxy actual_player;
- private Properties properties;
public string playback_state {
owned get {
@@ -114,15 +113,13 @@ public class Rygel.MPRIS.Player : GLib.Object, Rygel.MediaPlayer {
}
public Player (PlayerProxy actual_player,
- Properties properties,
string[] mime_types,
string[] protocols) {
this.actual_player = actual_player;
- this.properties = properties;
this.mime_types = mime_types;
this.protocols = protocols;
- this.properties.properties_changed.connect (this.on_properties_changed);
+ actual_player.g_properties_changed.connect (this.on_properties_changed);
}
public bool seek (Gst.ClockTime time) {
@@ -157,26 +154,36 @@ public class Rygel.MPRIS.Player : GLib.Object, Rygel.MediaPlayer {
}
}
- private void on_properties_changed (string iface,
- HashTable<string,Variant> changed,
- string[] invalidated) {
- if (changed.lookup ("PlaybackStatus") != null) {
- this.notify_property ("playback-state");
- }
+ private void on_properties_changed (DBusProxy actual_player,
+ Variant changed,
+ string[] invalidated) {
+ foreach (var changed_prop in changed) {
+ var key = (string) changed_prop.get_child_value (0);
+ var value = changed_prop.get_child_value (1).get_child_value (0);
- if (changed.lookup ("Volume") != null) {
- this.notify_property ("volume");
- }
+ switch (key) {
+ case "PlaybackStatus":
+ this.notify_property ("playback-state");
- if (changed.lookup ("Metadata") != null) {
- var metadata = this.actual_player.metadata;
+ break;
+ case "Volume":
+ this.notify_property ("volume");
+
+ break;
+ case "Metadata":
+ this.on_properties_changed (actual_player,
+ value,
+ new string[0]);
- if (metadata.lookup ("xesam:url") != null) {
+ break;
+ case "xesam:url":
this.notify_property ("uri");
- }
- if (metadata.lookup ("mpris:length") != null) {
+ break;
+ case "mpris:length":
this.notify_property ("duration");
+
+ break;
}
}
}
diff --git a/src/plugins/mpris/rygel-mpris-plugin.vala b/src/plugins/mpris/rygel-mpris-plugin.vala
index 9e79798..01351a8 100644
--- a/src/plugins/mpris/rygel-mpris-plugin.vala
+++ b/src/plugins/mpris/rygel-mpris-plugin.vala
@@ -30,7 +30,6 @@ public class Rygel.MPRIS.Plugin : Rygel.MediaRendererPlugin {
private const string MEDIA_PLAYER_PATH = "/org/mpris/MediaPlayer2";
private PlayerProxy actual_player;
- private FreeDesktop.Properties properties;
private string[] mime_types;
private string[] protocols;
@@ -50,12 +49,6 @@ public class Rygel.MPRIS.Plugin : Rygel.MediaRendererPlugin {
(BusType.SESSION,
service_name,
MEDIA_PLAYER_PATH);
- // Create proxy to FreeDesktop.Properties iface
- this.properties = Bus.get_proxy_sync
- (BusType.SESSION,
- service_name,
- MEDIA_PLAYER_PATH,
- DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
} catch (GLib.Error err) {
critical ("Failed to connect to session bus: %s", err.message);
}
@@ -63,7 +56,6 @@ public class Rygel.MPRIS.Plugin : Rygel.MediaRendererPlugin {
public override Rygel.MediaPlayer? get_player () {
return new MPRIS.Player (this.actual_player,
- this.properties,
this.mime_types,
this.protocols);
}
diff --git a/src/rygel/rygel-free-desktop-interfaces.vala b/src/rygel/rygel-free-desktop-interfaces.vala
index d09c78c..c17416d 100644
--- a/src/rygel/rygel-free-desktop-interfaces.vala
+++ b/src/rygel/rygel-free-desktop-interfaces.vala
@@ -52,10 +52,5 @@ public interface FreeDesktop.DBusObject: Object {
public interface FreeDesktop.Properties: Object {
public abstract async HashTable<string,Variant> get_all (string iface)
throws IOError;
- public abstract signal void properties_changed
- (string iface,
- HashTable<string,Variant> changed,
- string[]
- invalidated);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]