From 07197b0c4a8153ad65daecf920d0e0d51b1bebbc Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sun, 9 Jan 2011 15:05:33 +0000 Subject: nice refactor or mpris code --- src/Makefile.am | 1 + src/freedesktop-interfaces.vala | 41 +++++++++++++++++++++++++++++++++++++++++ src/mpris2-controller.vala | 2 +- src/mpris2-interfaces.vala | 4 +++- src/mpris2-watcher.vala | 35 ++++++----------------------------- src/sound-service.c | 4 ++-- 6 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 src/freedesktop-interfaces.vala diff --git a/src/Makefile.am b/src/Makefile.am index 57f52d4..7fe7e0f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -66,6 +66,7 @@ music_bridge_VALASOURCES = \ player-item.vala \ settings-manager.vala \ playlists-menu-item.vala \ + freedesktop-interfaces.vala \ fetch-file.vala diff --git a/src/freedesktop-interfaces.vala b/src/freedesktop-interfaces.vala new file mode 100644 index 0000000..3e5d832 --- /dev/null +++ b/src/freedesktop-interfaces.vala @@ -0,0 +1,41 @@ +/* +Copyright 2010 Canonical Ltd. + +Authors: + Conor Curran + +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 . +*/ + +[DBus (name = "org.freedesktop.DBus")] +public interface FreeDesktopObject: Object { + public abstract async string[] list_names() throws IOError; + public abstract signal void name_owner_changed ( string name, + string old_owner, + string new_owner ); +} + +[DBus (name = "org.freedesktop.DBus.Introspectable")] +public interface FreeDesktopIntrospectable: Object { + public abstract string Introspect() throws IOError; +} + +public errordomain XmlError { + FILE_NOT_FOUND, + XML_DOCUMENT_EMPTY +} + +const string FREEDESKTOP_SERVICE = "org.freedesktop.DBus"; +const string FREEDESKTOP_OBJECT = "/org/freedesktop/DBus"; + + diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index c43f5fe..66da069 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -71,7 +71,7 @@ public class Mpris2Controller : GLib.Object { debug("properties-changed for interface %s and owner %s", interface_source, this.owner.dbus_name); if ( changed_properties == null || - interface_source.has_prefix ( Mpris2Watcher.MPRIS_PREFIX ) == false ){ + interface_source.has_prefix ( MPRIS_PREFIX ) == false ){ warning("Property-changed hash is null or this is an interface that doesn't concerns us"); return; } diff --git a/src/mpris2-interfaces.vala b/src/mpris2-interfaces.vala index 88610e6..9d0b8c9 100644 --- a/src/mpris2-interfaces.vala +++ b/src/mpris2-interfaces.vala @@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +const string MPRIS_PREFIX = "org.mpris.MediaPlayer2."; +const string MPRIS_MEDIA_PLAYER_PATH = "/org/mpris/MediaPlayer2"; [DBus (name = "org.mpris.MediaPlayer2")] public interface MprisRoot : Object { @@ -24,7 +26,7 @@ public interface MprisRoot : Object { 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;} + public abstract string DesktopEntry{owned get; set;} // methods public abstract async void Quit() throws IOError; public abstract async void Raise() throws IOError; diff --git a/src/mpris2-watcher.vala b/src/mpris2-watcher.vala index 9ef9b2f..c20b04b 100644 --- a/src/mpris2-watcher.vala +++ b/src/mpris2-watcher.vala @@ -19,33 +19,9 @@ with this program. If not, see . using Xml; -[DBus (name = "org.freedesktop.DBus")] -public interface FreeDesktopObject: Object { - public abstract async string[] list_names() throws IOError; - public abstract signal void name_owner_changed ( string name, - string old_owner, - string new_owner ); -} - -[DBus (name = "org.freedesktop.DBus.Introspectable")] -public interface FreeDesktopIntrospectable: Object { - public abstract string Introspect() throws IOError; -} - -public errordomain XmlError { - FILE_NOT_FOUND, - XML_DOCUMENT_EMPTY -} - public class Mpris2Watcher : GLib.Object { - private const string FREEDESKTOP_SERVICE = "org.freedesktop.DBus"; - private const string FREEDESKTOP_OBJECT = "/org/freedesktop/DBus"; - public const string MPRIS_PREFIX = "org.mpris.MediaPlayer2."; - private const string MPRIS_MEDIA_PLAYER_PATH = "/org/mpris/MediaPlayer2"; - FreeDesktopObject fdesktop_obj; - FreeDesktopIntrospectable introspectable; public signal void client_appeared ( string desktop_file_name, string dbus_name, @@ -133,6 +109,8 @@ public class Mpris2Watcher : GLib.Object private bool supports_playlists ( string name ) { + FreeDesktopIntrospectable introspectable; + try { /* The dbusproxy flag parameter is needed to ensure Banshee does not blow up. I suspect the issue is that if you @@ -142,11 +120,10 @@ public class Mpris2Watcher : GLib.Object causes a crash because it doesn't check for the presence of properties before attempting to access them. */ - this.introspectable = Bus.get_proxy_sync ( BusType.SESSION, - name, - MPRIS_MEDIA_PLAYER_PATH, - GLib.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES); - + 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); } diff --git a/src/sound-service.c b/src/sound-service.c index 98f1881..defcb94 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; } -- cgit v1.2.3 From 33e8e6c2ac125ba3806032ea3ef730bd5c782ac8 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sun, 9 Jan 2011 15:30:29 +0000 Subject: more refactoring --- src/freedesktop-interfaces.vala | 6 ++++++ src/mpris2-controller.vala | 9 +-------- src/sound-service.c | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/freedesktop-interfaces.vala b/src/freedesktop-interfaces.vala index 3e5d832..4d75044 100644 --- a/src/freedesktop-interfaces.vala +++ b/src/freedesktop-interfaces.vala @@ -30,6 +30,12 @@ public interface FreeDesktopIntrospectable: Object { public abstract string Introspect() throws IOError; } +[DBus (name = "org.freedesktop.DBus.Properties")] +public interface FreeDesktopProperties : Object{ + public signal void PropertiesChanged (string source, HashTable changed_properties, + string[] invalid ); +} + public errordomain XmlError { FILE_NOT_FOUND, XML_DOCUMENT_EMPTY diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 66da069..fc61c12 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -18,12 +18,6 @@ with this program. If not, see . */ using Dbusmenu; -[DBus (name = "org.freedesktop.DBus.Properties")] -public interface FreeDesktopProperties : Object{ - public signal void PropertiesChanged (string source, HashTable changed_properties, - string[] invalid ); -} - /* This class will entirely replace mpris-controller.vala hence why there is no point in trying to get encorporate both into the same object model. @@ -148,9 +142,8 @@ public class Mpris2Controller : GLib.Object MetadataMenuitem.attributes_format()); if ( this.owner.use_playlists == true ){ - debug ("it thinks that there is a valid playlist interface"); this.fetch_playlists(); - this.fetch_active_playlist(); + this.fetch_active_playlist(); } } 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; } -- cgit v1.2.3 From 714c7c49776e8a341254a3e4297b465d181206cd Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Sun, 9 Jan 2011 16:33:07 +0000 Subject: prep for new release --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 928ffff..1297120 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ -AC_INIT(indicator-sound, 0.5.4, conor.curran@canonical.com) +AC_INIT(indicator-sound, 0.5.5, conor.curran@canonical.com) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-sound, 0.5.4) +AM_INIT_AUTOMAKE(indicator-sound, 0.5.5) AM_MAINTAINER_MODE -- cgit v1.2.3