[rygel] mpris: Simplify DBus related code
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] mpris: Simplify DBus related code
- Date: Wed, 17 Nov 2010 15:15:29 +0000 (UTC)
commit 57945e70293674cad67c37560a2620caac3b1fca
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Nov 17 16:19:39 2010 +0200
mpris: Simplify DBus related code
- Require interface MediaPlayer2 from MediaPlayer2.Player as they are
always implemented by the same object.
- Create proxy for only MediaPlayer2.Player interface and use that
everywhere. No need to use Properties.get_all.
src/plugins/mpris/rygel-mpris-interfaces.vala | 3 +-
src/plugins/mpris/rygel-mpris-plugin-factory.vala | 29 +++-----------------
src/plugins/mpris/rygel-mpris-plugin.vala | 27 ++++++++-----------
3 files changed, 18 insertions(+), 41 deletions(-)
---
diff --git a/src/plugins/mpris/rygel-mpris-interfaces.vala b/src/plugins/mpris/rygel-mpris-interfaces.vala
index 03ec27b..049fe63 100644
--- a/src/plugins/mpris/rygel-mpris-interfaces.vala
+++ b/src/plugins/mpris/rygel-mpris-interfaces.vala
@@ -31,7 +31,8 @@ public interface Rygel.MPRIS.MediaPlayerProxy : DBusProxy {
}
[DBus (name = "org.mpris.MediaPlayer2.Player")]
-public interface Rygel.MPRIS.MediaPlayer.PlayerProxy : DBusProxy {
+public interface Rygel.MPRIS.MediaPlayer.PlayerProxy : DBusProxy,
+ MediaPlayerProxy {
public const string IFACE = "org.mpris.MediaPlayer2.Player";
public abstract string playback_status { owned get; }
diff --git a/src/plugins/mpris/rygel-mpris-plugin-factory.vala b/src/plugins/mpris/rygel-mpris-plugin-factory.vala
index 5c396a9..eaed555 100644
--- a/src/plugins/mpris/rygel-mpris-plugin-factory.vala
+++ b/src/plugins/mpris/rygel-mpris-plugin-factory.vala
@@ -116,31 +116,12 @@ public class Rygel.MPRIS.PluginFactory {
}
private async void load_plugin (string service_name) throws IOError {
- Properties props = yield Bus.get_proxy
- (BusType.SESSION,
- service_name,
- MEDIA_PLAYER_PATH,
- DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
-
- var props_hash = yield props.get_all (MediaPlayerProxy.IFACE);
-
- this.load_plugin_from_props (service_name, props_hash);
- }
-
- private void load_plugin_from_props (string service_name,
- HashTable<string,Variant> props_hash) {
- var title = (string) props_hash.lookup ("Identity");
- if (title == null) {
- title = service_name;
- }
-
- var mime_types = (string[]) props_hash.lookup ("SupportedMimeTypes");
- var schemes = (string[]) props_hash.lookup ("SupportedUriSchemes");
+ MediaPlayer.PlayerProxy player =
+ yield Bus.get_proxy (BusType.SESSION,
+ service_name,
+ MEDIA_PLAYER_PATH);
- var plugin = new MPRIS.Plugin (service_name,
- title,
- mime_types,
- schemes);
+ var plugin = new MPRIS.Plugin (service_name, player);
this.loader.add_plugin (plugin);
}
diff --git a/src/plugins/mpris/rygel-mpris-plugin.vala b/src/plugins/mpris/rygel-mpris-plugin.vala
index 01351a8..142c518 100644
--- a/src/plugins/mpris/rygel-mpris-plugin.vala
+++ b/src/plugins/mpris/rygel-mpris-plugin.vala
@@ -34,24 +34,19 @@ public class Rygel.MPRIS.Plugin : Rygel.MediaRendererPlugin {
private string[] mime_types;
private string[] protocols;
- public Plugin (string service_name,
- string title,
- string[] mime_types,
- string[] schemes) {
- base (service_name, title);
+ public Plugin (string service_name,
+ PlayerProxy actual_player) {
+ var title = actual_player.identity;
+ if (title == null) {
+ title = service_name;
+ }
- this.mime_types = mime_types;
- this.protocols = this.schemes_to_protocols (schemes);
+ base (service_name, title);
- try {
- // Create proxy to MediaPlayer.Player iface
- this.actual_player = Bus.get_proxy_sync
- (BusType.SESSION,
- service_name,
- MEDIA_PLAYER_PATH);
- } catch (GLib.Error err) {
- critical ("Failed to connect to session bus: %s", err.message);
- }
+ this.actual_player = actual_player;
+ this.mime_types = actual_player.supported_mime_types;
+ this.protocols = this.schemes_to_protocols
+ (actual_player.supported_uri_schemes);
}
public override Rygel.MediaPlayer? get_player () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]