aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/mpris2-controller.vala253
-rw-r--r--src/mpris2-interfaces.vala46
-rw-r--r--src/mpris2-watcher.vala84
-rw-r--r--src/music-player-bridge.vala196
-rw-r--r--src/player-controller.vala5
-rw-r--r--src/player-item.vala20
-rw-r--r--src/sound-service.c1
8 files changed, 347 insertions, 263 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index b23e9c1..1c381f5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,6 +60,8 @@ music_bridge_VALASOURCES = \
metadata-menu-item.vala \
title-menu-item.vala \
player-controller.vala \
+ mpris2-interfaces.vala \
+ mpris2-watcher.vala \
mpris2-controller.vala \
player-item.vala \
familiar-players-db.vala \
@@ -74,10 +76,9 @@ music_bridge_VALAFLAGS = \
--vapidir=./ \
--thread \
--pkg gee-1.0 \
- --pkg Indicate-0.2 \
--pkg Dbusmenu-Glib-0.2 \
--pkg common-defs \
- --pkg dbus-glib-1 \
+ --pkg gio-2.0 \
--pkg gio-unix-2.0 \
--pkg gdk-pixbuf-2.0
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index f440c13..87f0307 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -16,42 +16,12 @@ PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-using DBus;
using Dbusmenu;
-[DBus (name = "org.mpris.MediaPlayer2")]
-public interface MprisRoot : DBus.Object {
- // properties
- public abstract bool HasTracklist{owned get; set;}
- public abstract bool CanQuit{owned get; set;}
- public abstract bool CanRaise{owned get; set;}
- public abstract string Identity{owned get; set;}
- public abstract string DesktopEntry{owned get; set;}
- // methods
- public abstract async void Quit() throws DBus.Error;
- public abstract async void Raise() throws DBus.Error;
-}
-
-[DBus (name = "org.mpris.MediaPlayer2.Player")]
-public interface MprisPlayer : DBus.Object {
-
- // properties
- public abstract HashTable<string, Value?> Metadata{owned get; set;}
- public abstract int32 Position{owned get; set;}
- public abstract string PlaybackStatus{owned get; set;}
- // methods
- public abstract async void PlayPause() throws DBus.Error;
- public abstract async void Next() throws DBus.Error;
- public abstract async void Previous() throws DBus.Error;
- // signals
- public signal void Seeked(int64 new_position);
-}
[DBus (name = "org.freedesktop.DBus.Properties")]
-public interface FreeDesktopProperties : DBus.Object{
- // signals
- public signal void PropertiesChanged(string source, HashTable<string,
- Value?> changed_properties,
+ public interface FreeDesktopProperties : Object{
+ public signal void PropertiesChanged(string source, HashTable<string, Variant?> changed_properties,
string[] invalid);
}
@@ -60,74 +30,76 @@ public interface FreeDesktopProperties : DBus.Object{
point in trying to get encorporate both into the same object model.
*/
public class Mpris2Controller : GLib.Object
-{
- public static const string root_interface = "org.mpris.MediaPlayer2" ;
- public MprisRoot mpris2_root {get; construct;}
- public MprisPlayer player {get; construct;}
- public PlayerController owner {get; construct;}
- public FreeDesktopProperties properties_interface {get; construct;}
-
- public Mpris2Controller(PlayerController ctrl)
- {
- GLib.Object(owner: ctrl);
- }
-
- construct{
+{
+ public static const string root_interface = "org.mpris.MediaPlayer2" ;
+ public MprisRoot mpris2_root {get; construct;}
+ public MprisPlayer player {get; construct;}
+ public FreeDesktopProperties properties_interface {get; construct;}
+
+ public PlayerController owner {get; construct;}
+
+ public Mpris2Controller(PlayerController ctrl)
+ {
+ GLib.Object(owner: ctrl);
+ }
+
+ construct{
try {
- var connection = DBus.Bus.get (DBus.BusType.SESSION);
- this.mpris2_root = (MprisRoot) connection.get_object (root_interface.concat(".").concat(this.owner.mpris_name),
- "/org/mpris/MediaPlayer2",
- root_interface);
- this.player = (MprisPlayer) connection.get_object (root_interface.concat(".").concat(this.owner.mpris_name),
- "/org/mpris/MediaPlayer2",
- root_interface.concat(".Player"));
- this.properties_interface = (FreeDesktopProperties) connection.get_object("org.freedesktop.Properties.PropertiesChanged",
- "/org/mpris/MediaPlayer2");
- this.properties_interface.PropertiesChanged += property_changed_cb;
+ this.mpris2_root = Bus.get_proxy_sync ( BusType.SESSION,
+ root_interface.concat(".").concat(this.owner.mpris_name),
+ "/org/mpris/MediaPlayer2");
+ this.player = Bus.get_proxy_sync ( BusType.SESSION,
+ root_interface.concat(".").concat(this.owner.mpris_name),
+ "/org/mpris/MediaPlayer2" );
- } catch (DBus.Error e) {
- error("Problems connecting to the session bus - %s", e.message);
- }
- }
-
- public void property_changed_cb(string interface_source, HashTable<string, Value?> changed_properties, string[] invalid )
- {
- debug("properties-changed for interface %s and owner %s", interface_source, this.owner.mpris_name);
-
- if(changed_properties == null || interface_source.has_prefix(this.root_interface) == false ){
- warning("Property-changed hash is null or this is an interface that doesn't concerns us");
- return;
- }
- Value? play_v = changed_properties.lookup("PlaybackStatus");
- if(play_v != null){
- string state = this.player.PlaybackStatus;
- TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(state);
- (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
- }
-
- Value? meta_v = changed_properties.lookup("Metadata");
- if(meta_v != null){
- GLib.HashTable<string, Value?> changed_updates = clean_metadata();
+ this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION,
+ "org.freedesktop.Properties.PropertiesChanged",
+ "/org/mpris/MediaPlayer2" );
+ this.properties_interface.PropertiesChanged += property_changed_cb;
+ }
+ catch (IOError e) {
+ error("Problems connecting to the session bus - %s", e.message);
+ }
+ }
+
+ public void property_changed_cb ( string interface_source,
+ HashTable<string, Variant?> changed_properties,
+ string[] invalid )
+ {
+ debug("properties-changed for interface %s and owner %s", interface_source, this.owner.mpris_name);
+ if(changed_properties == null || interface_source.has_prefix(this.root_interface) == false ){
+ warning("Property-changed hash is null or this is an interface that doesn't concerns us");
+ return;
+ }
+ Variant? play_v = changed_properties.lookup("PlaybackStatus");
+ if(play_v != null){
+ string state = this.player.PlaybackStatus;
+ TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(state);
+ (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(p);
+ }
+ Variant? meta_v = changed_properties.lookup("Metadata");
+ if(meta_v != null){
+ GLib.HashTable<string, Variant?> changed_updates = clean_metadata();
PlayerItem metadata = this.owner.custom_items[PlayerController.widget_order.METADATA];
- metadata.reset(MetadataMenuitem.attributes_format());
- metadata.update(changed_updates,
- MetadataMenuitem.attributes_format());
- metadata.property_set_bool(MENUITEM_PROP_VISIBLE,
- metadata.populated(MetadataMenuitem.attributes_format()));
+ metadata.reset( MetadataMenuitem.attributes_format());
+ metadata.update ( changed_updates,
+ MetadataMenuitem.attributes_format());
+ metadata.property_set_bool ( MENUITEM_PROP_VISIBLE,
+ metadata.populated(MetadataMenuitem.attributes_format()));
}
- }
+ }
- private GLib.HashTable<string, Value?> clean_metadata()
+ private GLib.HashTable<string, Variant?>? clean_metadata()
{
- GLib.HashTable<string, Value?> changed_updates = this.player.Metadata;
- Value? artist_v = this.player.Metadata.lookup("xesam:artist");
+ GLib.HashTable<string, Variant?> changed_updates = this.player.Metadata;
+ Variant? artist_v = this.player.Metadata.lookup("xesam:artist");
if(artist_v != null){
- string[] artists = (string[])this.player.Metadata.lookup("xesam:artist");
+ string[] artists = (string[])this.player.Metadata.lookup("xesam:artist");
string display_artists = string.joinv(", ", artists);
changed_updates.replace("xesam:artist", display_artists);
- debug("artist : %s", display_artists);
+ debug("artist : %s", (string)changed_updates.lookup("xesam:artist"));
}
- Value? length_v = this.player.Metadata.lookup("mpris:length");
+ Variant? length_v = this.player.Metadata.lookup("mpris:length");
if(length_v != null){
int64 duration = this.player.Metadata.lookup("mpris:length").get_int64();
changed_updates.replace("mpris:length", duration/1000000);
@@ -135,62 +107,51 @@ public class Mpris2Controller : GLib.Object
return changed_updates;
}
- private TransportMenuitem.state determine_play_state(string status){
- if(status != null && status == "Playing"){
- return TransportMenuitem.state.PLAYING;
- }
- return TransportMenuitem.state.PAUSED;
- }
-
- public void initial_update()
- {
- TransportMenuitem.state update;
- if(this.player.PlaybackStatus == null){
- update = TransportMenuitem.state.PAUSED;
- }
- else{
- update = determine_play_state(this.player.PlaybackStatus);
- }
- (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(update);
- GLib.HashTable<string, Value?> cleaned_metadata = this.clean_metadata();
- this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
- MetadataMenuitem.attributes_format());
- }
+ private TransportMenuitem.state determine_play_state(string? status){
+ if(status != null && status == "Playing"){
+ return TransportMenuitem.state.PLAYING;
+ }
+ return TransportMenuitem.state.PAUSED;
+ }
+
+ public void initial_update()
+ {
+ TransportMenuitem.state update;
+ if(this.player.PlaybackStatus == null){
+ update = TransportMenuitem.state.PAUSED;
+ }
- public void transport_update(TransportMenuitem.action command)
- {
- debug("transport_event input = %i", (int)command);
- if(command == TransportMenuitem.action.PLAY_PAUSE){
- this.player.PlayPause.begin();
- }
- else if(command == TransportMenuitem.action.PREVIOUS){
- this.player.Previous.begin();
- }
- else if(command == TransportMenuitem.action.NEXT){
- this.player.Next.begin();
- }
- }
-
- public bool connected()
- {
- return (this.player != null && this.mpris2_root != null);
- }
+ update = determine_play_state(null);
+
+ (this.owner.custom_items[PlayerController.widget_order.TRANSPORT] as TransportMenuitem).change_play_state(TransportMenuitem.state.PAUSED);
+ GLib.HashTable<string, Value?>? cleaned_metadata = this.clean_metadata();
+ this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
+ MetadataMenuitem.attributes_format());
+ }
+
+ public void transport_update(TransportMenuitem.action command)
+ {
+ debug("transport_event input = %i", (int)command);
+ if(command == TransportMenuitem.action.PLAY_PAUSE){
+ this.player.PlayPause.begin();
+ }
+ else if(command == TransportMenuitem.action.PREVIOUS){
+ this.player.Previous.begin();
+ }
+ else if(command == TransportMenuitem.action.NEXT){
+ this.player.Next.begin();
+ }
+ }
-
- public bool was_successfull(){
- if(this.mpris2_root == null || this.player == null){
- return false;
- }
- return true;
- }
+ public bool connected()
+ {
+ return (this.player != null && this.mpris2_root != null);
+ }
- public void expose()
- {
- if(this.connected() == true){
- this.mpris2_root.Raise.begin();
- }
- }
-}
-
-
-
+ public void expose()
+ {
+ if(this.connected() == true){
+ this.mpris2_root.Raise.begin();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala
new file mode 100644
index 0000000..ef62aba
--- /dev/null
+++ b/src/mpris2-interfaces.vala
@@ -0,0 +1,46 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+[DBus (name = "org.mpris.MediaPlayer2")]
+public interface MprisRoot : Object {
+ // properties
+ public abstract bool HasTracklist{owned get; set;}
+ public abstract bool CanQuit{owned get; set;}
+ public abstract bool CanRaise{owned get; set;}
+ public abstract string Identity{owned get; set;}
+ public abstract string DesktopEntry{owned get; set;}
+ // methods
+ public abstract async void Quit() throws IOError;
+ public abstract async void Raise() throws IOError;
+}
+
+[DBus (name = "org.mpris.MediaPlayer2.Player")]
+public interface MprisPlayer : Object {
+ // properties
+ public abstract HashTable<string, Variant?> Metadata{owned get; set;}
+ public abstract int32 Position{owned get; set;}
+ public abstract string PlaybackStatus{owned get; set;}
+ // methods
+ public abstract async void PlayPause() throws IOError;
+ public abstract async void Next() throws IOError;
+ public abstract async void Previous() throws IOError;
+ // signals
+ public signal void Seeked(int64 new_position);
+}
diff --git a/src/mpris2-watcher.vala b/src/mpris2-watcher.vala
new file mode 100644
index 0000000..1cf8baa
--- /dev/null
+++ b/src/mpris2-watcher.vala
@@ -0,0 +1,84 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+[DBus (name = "org.freedesktop.DBus")]
+public interface FreeDesktopObject: Object {
+ public abstract signal void name_owner_changed (string name,
+ string old_owner,
+ string new_owner);
+}
+
+public class Mpris2Watcher : GLib.Object
+{
+ private const string FREEDESKTOP_SERVICE = "org.freedesktop.DBus";
+ private const string FREEDESKTOP_OBJECT = "/org/freedesktop/DBus";
+ private const string MPRIS_PREFIX = "org.mpris.MediaPlayer2.";
+ private const string MPRIS_MEDIA_PLAYER_PATH = "/org/mpris/MediaPlayer2";
+
+ FreeDesktopObject fdesktop_obj;
+
+ public signal void client_appeared ( string desktop_name );
+ public signal void client_disappeared ( string mpris_root_interface );
+
+ public Mpris2Watcher ()
+ {
+ }
+
+ construct
+ {
+ try {
+ this.fdesktop_obj = Bus.get_proxy_sync ( BusType.SESSION,
+ FREEDESKTOP_SERVICE,
+ FREEDESKTOP_OBJECT,
+ DBusProxyFlags.DO_NOT_LOAD_PROPERTIES );
+ this.fdesktop_obj.name_owner_changed.connect (this.name_changes_detected);
+ }
+ catch ( IOError e ){
+ warning( "Mpris2watcher could not set up a watch for mpris clients appearing on the bus: %s",
+ e.message );
+ }
+ }
+
+ private void name_changes_detected ( FreeDesktopObject dbus_obj,
+ string name,
+ string previous_owner,
+ string current_owner ) {
+ MprisRoot mpris2_root;
+ if ( name.has_prefix (MPRIS_PREFIX) ){
+ try {
+ mpris2_root = Bus.get_proxy_sync ( BusType.SESSION,
+ name,
+ MPRIS_MEDIA_PLAYER_PATH );
+ }
+ catch (IOError e){
+ warning( "Mpris2watcher could not create a root interface: %s",
+ e.message );
+ return;
+ }
+ if (previous_owner != "" && current_owner == "") {
+ debug ("Client '%s' gone down", name);
+ client_disappeared (name);
+ }
+ else if (previous_owner == "" && current_owner != "") {
+ debug ("Client '%s' has appeared", name);
+ client_appeared (mpris2_root.DesktopEntry);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index f13c2f4..d1c2334 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -17,66 +17,63 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-using Indicate;
using Dbusmenu;
using Gee;
using GLib;
public class MusicPlayerBridge : GLib.Object
{
- private Listener listener;
private Dbusmenu.Menuitem root_menu;
- private HashMap<string, PlayerController> registered_clients;
- private FamiliarPlayersDB playersDB;
-
+ private HashMap<string, PlayerController> registered_clients;
+ private FamiliarPlayersDB playersDB;
+ private Mpris2Watcher watcher;
+ private const string DESKTOP_PREFIX = "/usr/share/applications/";
+
public MusicPlayerBridge()
{
- playersDB = new FamiliarPlayersDB();
- registered_clients = new HashMap<string, PlayerController> ();
- listener = Listener.ref_default();
- listener.server_added.connect(on_server_added);
- listener.server_removed.connect(on_server_removed);
+ playersDB = new FamiliarPlayersDB();
+ registered_clients = new HashMap<string, PlayerController> ();
}
+
+ private void try_to_add_inactive_familiar_clients(){
+ foreach(string app in this.playersDB.records()){
+ if(app == null){
+ warning("App string in keyfile is null therefore moving on to next player");
+ continue;
+ }
- private void try_to_add_inactive_familiar_clients(){
- foreach(string app in this.playersDB.records()){
- if(app == null){
- warning("App string in keyfile is null therefore moving on to next player");
- continue;
- }
+ debug("attempting to make an app info from %s", app);
- debug("attempting to make an app info from %s", app);
-
- DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
+ DesktopAppInfo info = new DesktopAppInfo.from_filename(app);
if(info == null){
- warning("Could not create a desktopappinfo instance from app,: %s , moving on to the next client", app);
- continue;
- }
+ warning("Could not create a desktopappinfo instance from app,: %s , moving on to the next client", app);
+ continue;
+ }
- GLib.AppInfo app_info = info as GLib.AppInfo;
- var mpris_key = determine_key(app);
- PlayerController ctrl = new PlayerController(this.root_menu,
- app_info,
+ GLib.AppInfo app_info = info as GLib.AppInfo;
+ var mpris_key = determine_key ( app );
+ PlayerController ctrl = new PlayerController(this.root_menu,
+ app_info,
mpris_key,
playersDB.fetch_icon_name(app),
- calculate_menu_position(),
- PlayerController.state.OFFLINE);
- this.registered_clients.set(mpris_key, ctrl);
- }
- }
+ calculate_menu_position(),
+ PlayerController.state.OFFLINE);
+ this.registered_clients.set(mpris_key, ctrl);
+ }
+ }
- private int calculate_menu_position()
- {
- if(this.registered_clients.size == 0){
- return 2;
- }
- else{
- return (2 + (this.registered_clients.size * PlayerController.WIDGET_QUANTITY));
- }
- }
-
- public void on_server_added(Indicate.ListenerServer object, string type)
+ private int calculate_menu_position()
+ {
+ if(this.registered_clients.size == 0){
+ return 2;
+ }
+ else{
+ return (2 + (this.registered_clients.size * PlayerController.WIDGET_QUANTITY));
+ }
+ }
+
+ /*public void on_server_added(Indicate.ListenerServer object, string type)
{
debug("MusicPlayerBridge -> on_server_added with value %s", type);
if(server_is_not_of_interest(type)) return;
@@ -84,84 +81,83 @@ public class MusicPlayerBridge : GLib.Object
listener_get_server_property_cb cb = (listener_get_server_property_cb)desktop_info_callback;
this.listener.server_get_desktop(object, cb, this);
}
- }
+ }*/
- private void desktop_info_callback ( Indicate.ListenerServer server,
- owned string path,
- void* data )
- {
- MusicPlayerBridge bridge = data as MusicPlayerBridge;
- AppInfo? app_info = create_app_info(path);
+ public void client_has_become_available ( string desktop_file_name )
+ {
+ debug ( "client_has_become_available %s", desktop_file_name );
+ string path = DESKTOP_PREFIX.concat ( desktop_file_name.concat( ".desktop" ) );
+ AppInfo? app_info = create_app_info ( path );
if ( app_info == null ){
warning ( "Could not create app_info for path %s \n Getting out of here ", path);
return;
}
- var mpris_key = determine_key(path);
+ var mpris_key = determine_key ( path );
- if(bridge.playersDB.already_familiar(path) == false){
- debug("New client has registered that we have seen before: %s", path);
- bridge.playersDB.insert(path);
- PlayerController ctrl = new PlayerController ( bridge.root_menu,
- app_info,
+ if ( this.playersDB.already_familiar ( path ) == false ){
+ debug("New client has registered that we have not seen before: %s", desktop_file_name );
+ this.playersDB.insert ( path );
+ PlayerController ctrl = new PlayerController ( this.root_menu,
+ app_info,
mpris_key,
playersDB.fetch_icon_name(path),
- bridge.calculate_menu_position(),
- PlayerController.state.READY );
- bridge.registered_clients.set(mpris_key, ctrl);
- debug("successfully created appinfo and instance from path and set it on the respective instance");
- }
- else{
- bridge.registered_clients[mpris_key].update_state(PlayerController.state.READY);
- bridge.registered_clients[mpris_key].activate();
- debug("Ignoring desktop file path callback because the db cache file has it already: %s \n", path);
- }
- }
+ this.calculate_menu_position(),
+ PlayerController.state.READY );
+ this.registered_clients.set ( mpris_key, ctrl );
+ debug ( "successfully created appinfo and instance from path and set it on the respective instance" );
+ }
+ else{
+ this.registered_clients[mpris_key].update_state ( PlayerController.state.READY );
+ this.registered_clients[mpris_key].activate ( );
+ debug("Ignoring desktop file path callback because the db cache file has it already: %s \n", path);
+ }
+ }
- public void on_server_removed(Indicate.ListenerServer object, string type)
+ public void client_has_vanished ( string mpris_root_interface )
{
- debug("MusicPlayerBridge -> on_server_removed with value %s", type);
- if(server_is_not_of_interest(type)) return;
- if (root_menu != null){
- var tmp = type.split(".");
- debug("attempt to remove %s", tmp[tmp.length-1]);
- if(tmp.length > 0){
- registered_clients[tmp[tmp.length - 1]].hibernate();
- debug("Successively offlined client %s", tmp[tmp.length - 1]);
+ debug("MusicPlayerBridge -> on_server_removed with value %s", mpris_root_interface);
+ if (root_menu != null){
+ debug("attempt to remove %s", mpris_root_interface);
+ var mpris_key = determine_key ( mpris_root_interface );
+ if ( mpris_key != null ){
+ registered_clients[mpris_key].hibernate();
+ debug("Successively offlined client %s", mpris_key);
}
- }
- }
-
- private bool server_is_not_of_interest(string type){
- if (type == null) return true;
- if (type.contains("music") == false) {
- debug("server is of no interest, it is not an music server");
- return true;
}
- return false;
- }
-
+ }
+
public void set_root_menu_item(Dbusmenu.Menuitem menu)
{
- this.root_menu = menu;
- try_to_add_inactive_familiar_clients();
+ this.root_menu = menu;
+ this.try_to_add_inactive_familiar_clients();
+ this.watcher = new Mpris2Watcher ();
+ this.watcher.client_appeared += this.client_has_become_available;
+ this.watcher.client_disappeared += this.client_has_vanished;
}
- public static AppInfo? create_app_info(string path)
- {
- DesktopAppInfo info = new DesktopAppInfo.from_filename(path);
- if(path == null){
- warning("Could not create a desktopappinfo instance from app: %s", path);
- return null;
- }
- GLib.AppInfo app_info = info as GLib.AppInfo;
- return app_info;
- }
+ public static AppInfo? create_app_info ( string path )
+ {
+ DesktopAppInfo info = new DesktopAppInfo.from_filename ( path ) ;
+ if ( path == null || info == null ){
+ warning ( "Could not create a desktopappinfo instance from app: %s", path );
+ return null;
+ }
+ GLib.AppInfo app_info = info as GLib.AppInfo;
+ return app_info;
+ }
private static string? determine_key(owned string path)
{
- var tokens = path.split("/");
- if ( tokens.length < 2) return null;
+ var tokens = path.split( "/" );
+ if ( tokens.length < 2 ){
+ // try to split on "."
+ tokens = path.split(".");
+ if ( tokens.length < 2 ){
+ // don't know what this is
+ return null;
+ }
+ }
var filename = tokens[tokens.length - 1];
var result = filename.split(".")[0];
var temp = result.split("-");
diff --git a/src/player-controller.vala b/src/player-controller.vala
index e2ae4d7..3c9b0ff 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -114,7 +114,7 @@ public class PlayerController : GLib.Object
public void vanish()
{
foreach(Dbusmenu.Menuitem item in this.custom_items){
- root_menu.child_delete(item);
+ root_menu.child_delete(item);
}
}
@@ -178,9 +178,6 @@ public class PlayerController : GLib.Object
return result;
}
- // Temporarily we will need to handle to different mpris implemenations
- // Do it for now - a couple of weeks should see this messy carry on out of
- // the codebase.
public void determine_state()
{
if(this.mpris_bridge.connected() == true){
diff --git a/src/player-item.vala b/src/player-item.vala
index 51471d1..54d0d89 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -48,7 +48,7 @@ public class PlayerItem : Dbusmenu.Menuitem
* and attmepts to update the appropriate props on the object.
* Album art is handled separately to deal with remote and local file paths.
*/
- public void update(HashTable<string, Value?> data, HashSet<string> attributes)
+ public void update(HashTable<string, Variant?> data, HashSet<string> attributes)
{
debug("PlayerItem::update()");
if(data == null){
@@ -60,29 +60,29 @@ public class PlayerItem : Dbusmenu.Menuitem
string[] input_keys = property.split("-");
string search_key = input_keys[input_keys.length-1 : input_keys.length][0];
debug("search key = %s", search_key);
- Value? v = data.lookup(search_key);
+ Variant? v = data.lookup(search_key);
- if (v.holds (typeof (string))){
+ if (v.is_of_type ( VariantType.STRING )){
string update = v.get_string().strip();
debug("with value : %s", update);
if(property.contains("mpris:artUrl")){
// We know its a metadata instance because thats the only
// object with the arturl prop
MetadataMenuitem metadata = this as MetadataMenuitem;
- metadata.fetch_art(update.strip(), property);
- continue;
+ metadata.fetch_art ( update, property );
+ continue;
}
this.property_set(property, update);
}
- else if (v.holds (typeof (int))){
- debug("with value : %i", v.get_int());
- this.property_set_int(property, v.get_int());
+ else if (v.is_of_type (VariantType.INT32 )){
+ debug("with value : %i", v.get_int32());
+ this.property_set_int(property, v.get_int32());
}
- else if (v.holds (typeof (int64))){
+ else if (v.is_of_type (VariantType.INT64 )){
debug("with value : %i", (int)v.get_int64());
this.property_set_int(property, (int)v.get_int64());
}
- else if(v.holds (typeof (bool))){
+ else if(v.is_of_type ( VariantType.BOOLEAN )){
debug("with value : %s", v.get_boolean().to_string());
this.property_set_bool(property, v.get_boolean());
}
diff --git a/src/sound-service.c b/src/sound-service.c
index f19379d..98f1881 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,7 +40,6 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- //TODO: uncomment for release !!
close_pulse_activites();
g_main_loop_quit(mainloop);
}