aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-01-09 14:20:41 +0000
committerConor Curran <conor.curran@canonical.com>2011-01-09 14:20:41 +0000
commit6599f962aacdb311322305234d3746ac27533f5e (patch)
tree12013d678a9e3c99578a9105b971b921277d6a1b /src
parent9dc6c636a4ae4c117afa2973c7dc32c72d22abd0 (diff)
downloadayatana-indicator-sound-6599f962aacdb311322305234d3746ac27533f5e.tar.gz
ayatana-indicator-sound-6599f962aacdb311322305234d3746ac27533f5e.tar.bz2
ayatana-indicator-sound-6599f962aacdb311322305234d3746ac27533f5e.zip
found the way around banshee dbus peculiar
Diffstat (limited to 'src')
-rw-r--r--src/mpris2-controller.vala34
-rw-r--r--src/mpris2-watcher.vala76
-rw-r--r--src/music-player-bridge.vala11
-rw-r--r--src/player-controller.vala19
-rw-r--r--src/sound-service.c4
5 files changed, 76 insertions, 68 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 7b512a3..c43f5fe 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -50,9 +50,11 @@ public class Mpris2Controller : GLib.Object
this.player = Bus.get_proxy_sync ( BusType.SESSION,
this.owner.dbus_name,
"/org/mpris/MediaPlayer2" );
- this.playlists = Bus.get_proxy_sync ( BusType.SESSION,
- this.owner.dbus_name,
- "/org/mpris/MediaPlayer2" );
+ if ( this.owner.use_playlists == true ){
+ this.playlists = Bus.get_proxy_sync ( BusType.SESSION,
+ this.owner.dbus_name,
+ "/org/mpris/MediaPlayer2" );
+ }
this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION,
"org.freedesktop.Properties.PropertiesChanged",
"/org/mpris/MediaPlayer2" );
@@ -94,18 +96,10 @@ public class Mpris2Controller : GLib.Object
metadata.populated(MetadataMenuitem.attributes_format()));
}
Variant? playlist_v = changed_properties.lookup("ActivePlaylist");
- if ( playlist_v != null && this.playlists_support_exist() ){
+ if ( playlist_v != null && this.owner.use_playlists == true ){
this.fetch_active_playlist();
}
}
-
- public bool playlists_support_exist()
- {
- if (this.playlists == null) return false;
- uint32? count = this.playlists.PlaylistCount;
- if ( count == null || count <= 0 ) return false;
- return true;
- }
private bool ensure_correct_playback_status(){
debug("TEST playback status = %s", this.player.PlaybackStatus);
@@ -153,11 +147,11 @@ public class Mpris2Controller : GLib.Object
this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata,
MetadataMenuitem.attributes_format());
- /*if ( playlists_support_exist() == true ){
+ if ( this.owner.use_playlists == true ){
debug ("it thinks that there is a valid playlist interface");
this.fetch_playlists();
this.fetch_active_playlist();
- }*/
+ }
}
public void transport_update(TransportMenuitem.action command)
@@ -185,6 +179,10 @@ public class Mpris2Controller : GLib.Object
PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
playlists_item.update(current_playlists);
}
+ else{
+ warning(" Playlists are on but its returning no current_playlists" );
+ this.owner.use_playlists = false;
+ }
return;
}
@@ -202,7 +200,7 @@ public class Mpris2Controller : GLib.Object
{
return (this.player != null && this.mpris2_root != null);
}
-
+
public void expose()
{
if(this.connected() == true){
@@ -212,15 +210,11 @@ public class Mpris2Controller : GLib.Object
public void activate_playlist (ObjectPath path)
{
- if ( playlists_support_exist() == false ){
- return;
- }
-
try{
this.playlists.ActivatePlaylist.begin(path);
}
catch(IOError e){
debug("Could not activate playlist %s because %s", (string)path, e.message);
}
- }
+ }
} \ No newline at end of file
diff --git a/src/mpris2-watcher.vala b/src/mpris2-watcher.vala
index fa4207a..b30aa88 100644
--- a/src/mpris2-watcher.vala
+++ b/src/mpris2-watcher.vala
@@ -29,7 +29,7 @@ public interface FreeDesktopObject: Object {
[DBus (name = "org.freedesktop.DBus.Introspectable")]
public interface FreeDesktopIntrospectable: Object {
- public abstract string introspect() throws IOError;
+ public abstract string Introspect() throws IOError;
}
public errordomain XmlError {
@@ -45,8 +45,11 @@ public class Mpris2Watcher : GLib.Object
private const string MPRIS_MEDIA_PLAYER_PATH = "/org/mpris/MediaPlayer2";
FreeDesktopObject fdesktop_obj;
-
- public signal void client_appeared ( string desktop_file_name, string dbus_name );
+ FreeDesktopIntrospectable introspectable;
+
+ public signal void client_appeared ( string desktop_file_name,
+ string dbus_name,
+ bool use_playlists );
public signal void client_disappeared ( string dbus_name );
public Mpris2Watcher ()
@@ -69,6 +72,29 @@ public class Mpris2Watcher : GLib.Object
}
}
+ // At startup check to see if there are clients up that we are interested in
+ // More relevant for development and daemon's like mpd.
+ private async void check_for_active_clients()
+ {
+ string[] interfaces;
+ try{
+ interfaces = yield this.fdesktop_obj.list_names();
+ }
+ catch ( IOError e) {
+ warning( "Mpris2watcher could fetch active interfaces at startup: %s",
+ e.message );
+ return;
+ }
+ foreach (var address in interfaces) {
+ if (address.has_prefix (MPRIS_PREFIX)){
+ MprisRoot? mpris2_root = this.create_mpris_root(address);
+ if (mpris2_root == null) return;
+ bool use_playlists = this.supports_playlists ( address );
+ client_appeared (mpris2_root.DesktopEntry, address, use_playlists);
+ }
+ }
+ }
+
private void name_changes_detected ( FreeDesktopObject dbus_obj,
string name,
string previous_owner,
@@ -84,8 +110,8 @@ public class Mpris2Watcher : GLib.Object
}
else if (previous_owner == "" && current_owner != "") {
debug ("Client '%s' has appeared", name);
- bool use_playlists = this.supports_playlists ( name );
- client_appeared (mpris2_root.DesktopEntry, name);
+ bool use_playlists = this.supports_playlists ( name );
+ client_appeared (mpris2_root.DesktopEntry, name, false/*use_playlists*/);
}
}
@@ -107,13 +133,15 @@ public class Mpris2Watcher : GLib.Object
private bool supports_playlists ( string name )
{
- FreeDesktopIntrospectable introspectable;
try {
- introspectable = Bus.get_proxy_sync ( BusType.SESSION,
- name,
- MPRIS_MEDIA_PLAYER_PATH );
- var results = introspectable.introspect();
- return this.parse_interfaces (results);
+ debug( "name = %s", name);
+ this.introspectable = Bus.get_proxy_sync ( BusType.SESSION,
+ name,
+ MPRIS_MEDIA_PLAYER_PATH,
+ GLib.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
+
+ var results = introspectable.Introspect();
+ return this.parse_interfaces (results);
}
catch (IOError e){
warning( "Could not create an introspectable object: %s",
@@ -126,7 +154,6 @@ public class Mpris2Watcher : GLib.Object
{
//parse the document from path
bool result = false;
- debug ("attempting to parse %s", interface_info);
Xml.Doc* xml_doc = Parser.parse_doc (interface_info);
if (xml_doc == null) {
warning ("Mpris2Watcher - parse-interfaces - failed to instantiate xml doc");
@@ -153,31 +180,8 @@ public class Mpris2Watcher : GLib.Object
if ( interface_name == MPRIS_PREFIX.concat("Playlists")){
result = true;
}
- delete attributes;
}
delete xml_doc;
return result;
- }
-
- // At startup check to see if there are clients up that we are interested in
- // More relevant for development and daemon's like mpd.
- private async void check_for_active_clients()
- {
- string[] interfaces;
- try{
- interfaces = yield this.fdesktop_obj.list_names();
- }
- catch ( IOError e) {
- warning( "Mpris2watcher could fetch active interfaces at startup: %s",
- e.message );
- return;
- }
- foreach (var address in interfaces) {
- if (address.has_prefix (MPRIS_PREFIX)){
- MprisRoot? mpris2_root = this.create_mpris_root(address);
- if (mpris2_root == null) return;
- client_appeared (mpris2_root.DesktopEntry, address);
- }
- }
- }
+ }
} \ No newline at end of file
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
index 10c333a..7587684 100644
--- a/src/music-player-bridge.vala
+++ b/src/music-player-bridge.vala
@@ -59,8 +59,9 @@ public class MusicPlayerBridge : GLib.Object
null,
this.fetch_icon_name(desktop),
calculate_menu_position(),
+ null,
PlayerController.state.OFFLINE );
- this.registered_clients.set(mpris_key, ctrl);
+ this.registered_clients.set(mpris_key, ctrl);
}
}
@@ -74,7 +75,9 @@ public class MusicPlayerBridge : GLib.Object
}
}
- public void client_has_become_available ( string desktop, string dbus_name )
+ public void client_has_become_available ( string desktop,
+ string dbus_name,
+ bool use_playlists )
{
if (desktop == null || desktop == ""){
warning("Client %s attempting to register without desktop entry being set on the mpris root",
@@ -104,6 +107,7 @@ public class MusicPlayerBridge : GLib.Object
dbus_name,
this.fetch_icon_name(desktop),
this.calculate_menu_position(),
+ use_playlists,
PlayerController.state.READY );
this.registered_clients.set ( mpris_key, ctrl );
debug ( "Have not seen this %s before, new controller created.", desktop );
@@ -111,6 +115,7 @@ public class MusicPlayerBridge : GLib.Object
debug ( "application added to the interested list" );
}
else{
+ this.registered_clients[mpris_key].use_playlists = use_playlists;
this.registered_clients[mpris_key].update_state ( PlayerController.state.READY );
this.registered_clients[mpris_key].activate ( dbus_name );
debug("Application has already registered - awaken the hibernation: %s \n", dbus_name );
@@ -130,7 +135,7 @@ public class MusicPlayerBridge : GLib.Object
}
}
}
-
+
public void set_root_menu_item ( Dbusmenu.Menuitem menu )
{
this.root_menu = menu;
diff --git a/src/player-controller.vala b/src/player-controller.vala
index 3922ecf..adefb65 100644
--- a/src/player-controller.vala
+++ b/src/player-controller.vala
@@ -45,19 +45,22 @@ public class PlayerController : GLib.Object
private Dbusmenu.Menuitem root_menu;
public string dbus_name { get; set;}
- public ArrayList<PlayerItem> custom_items;
+ public ArrayList<PlayerItem> custom_items;
public Mpris2Controller mpris_bridge;
public AppInfo? app_info { get; set;}
public int menu_offset { get; set;}
public string icon_name { get; set; }
-
+ public bool? use_playlists;
+
public PlayerController(Dbusmenu.Menuitem root,
GLib.AppInfo app,
string? dbus_name,
string icon_name,
int offset,
+ bool? use_playlists,
state initial_state)
{
+ this.use_playlists = use_playlists;
this.root_menu = root;
this.app_info = app;
this.dbus_name = dbus_name;
@@ -67,7 +70,7 @@ public class PlayerController : GLib.Object
this.menu_offset = offset;
this.construct_widgets();
this.establish_mpris_connection();
- this.update_layout();
+ this.update_layout();
}
public void update_state(state new_state)
@@ -81,7 +84,7 @@ public class PlayerController : GLib.Object
public void activate( string dbus_name )
{
this.dbus_name = dbus_name;
- this.establish_mpris_connection();
+ this.establish_mpris_connection();
}
/*
@@ -109,6 +112,9 @@ public class PlayerController : GLib.Object
debug("establish_mpris_connection - Not ready to connect");
return;
}
+ debug ( " establish mpris connection - use playlists value = %s ",
+ this.use_playlists.to_string() );
+
this.mpris_bridge = new Mpris2Controller(this);
this.determine_state();
}
@@ -148,7 +154,7 @@ public class PlayerController : GLib.Object
this.custom_items[widget_order.TRANSPORT].property_set_bool(MENUITEM_PROP_VISIBLE,
true);
playlists_menuitem.root_item.property_set_bool ( MENUITEM_PROP_VISIBLE,
- this.mpris_bridge.playlists_support_exist() );
+ this.use_playlists );
}
private void construct_widgets()
@@ -181,9 +187,8 @@ public class PlayerController : GLib.Object
root_menu.child_add_position(playlists_menuitem.root_item, this.menu_offset + this.custom_items.index_of(item));
}
}
- }
+ }
-
private static string format_player_name(owned string app_info_name)
{
string result = app_info_name.down().strip();
diff --git a/src/sound-service.c b/src/sound-service.c
index defcb94..98f1881 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- //close_pulse_activites();
- //g_main_loop_quit(mainloop);
+ close_pulse_activites();
+ g_main_loop_quit(mainloop);
}
return;
}