From e4bb3237e72b10941b22beac5c2c0a630f6666c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 15:27:17 -0500 Subject: Make sure to update the player if needed --- src/service.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/service.vala b/src/service.vala index d94aa18..8863a16 100644 --- a/src/service.vala +++ b/src/service.vala @@ -80,6 +80,8 @@ public class IndicatorSound.Service: Object { } this.accounts_service = new AccountsServiceUser(); + + this.eventually_update_player_actions(); } public int run () { -- cgit v1.2.3 From 6be3d4e79f6121a56ae458c18af010768d73a2dc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 15:28:59 -0500 Subject: Clear everything --- src/accounts-service-user.vala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index f021764..8797fb9 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -45,6 +45,13 @@ public class AccountsServiceUser : Object { /* Clear it */ this.proxy.player_name = ""; this.proxy.timestamp = 0; + this.proxy.title = ""; + this.proxy.artist = ""; + this.proxy.album = ""; + this.proxy.art_url = ""; + + var icon = new ThemedIcon.with_default_fallbacks ("application-default-icon"); + this.proxy.player_icon = icon.serialize(); } else { this.proxy.timestamp = GLib.get_monotonic_time(); this.proxy.player_name = this._player.name; -- cgit v1.2.3 From cdfa2afeb95b1067bde7412b6cee744a1ab0e0b9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 15:40:39 -0500 Subject: Debug messages --- src/accounts-service-user.vala | 2 ++ src/service.vala | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 8797fb9..77dc9d4 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -42,6 +42,8 @@ public class AccountsServiceUser : Object { } if (this._player == null) { + debug("Clearing player data in accounts service"); + /* Clear it */ this.proxy.player_name = ""; this.proxy.timestamp = 0; diff --git a/src/service.vala b/src/service.vala index 8863a16..de03296 100644 --- a/src/service.vala +++ b/src/service.vala @@ -71,11 +71,13 @@ public class IndicatorSound.Service: Object { /* If we're not exporting, don't build anything */ if (!this.settings.get_boolean("greeter-export")) { + debug("Accounts service export disabled due to user setting"); return; } /* If we're on the greeter, don't export */ if (GLib.Environment.get_user_name() == "lightdm") { + debug("Accounts service export disabled due to being used on the greeter"); return; } -- cgit v1.2.3 From 61d3328c1a41b3704db9e96c8f9a27b42e649aca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 15:48:03 -0500 Subject: If the user is already loaded don't wait on it. --- src/accounts-service-user.vala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 77dc9d4..e18e20f 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -93,11 +93,16 @@ public class AccountsServiceUser : Object { public AccountsServiceUser () { user = accounts_manager.get_user(GLib.Environment.get_user_name()); - user.notify["is-loaded"].connect(() => { - debug("User loaded"); + user.notify["is-loaded"].connect(() => user_loaded_changed()); + user_loaded_changed(); + } - this.proxy = null; + void user_loaded_changed () { + debug("User loaded changed"); + this.proxy = null; + + if (this.user.is_loaded) { Bus.get_proxy.begin ( BusType.SYSTEM, "org.freedesktop.Accounts", @@ -105,7 +110,7 @@ public class AccountsServiceUser : Object { DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, new_proxy); - }); + } } ~AccountsServiceUser () { -- cgit v1.2.3 From 6ebc8b959ae45538e04d6831c94779b5c0c3d58e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 15:58:44 -0500 Subject: Backport the timer patch --- src/accounts-service-user.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index e18e20f..92c972d 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -115,6 +115,11 @@ public class AccountsServiceUser : Object { ~AccountsServiceUser () { this.player = null; + + if (this.timer != 0) { + GLib.Source.remove(this.timer); + this.timer = 0; + } } void new_proxy (GLib.Object? obj, AsyncResult res) { -- cgit v1.2.3 From f444eecaec57ab4966f2ebcfce0aefc0f8fbb6ba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 16:13:14 -0500 Subject: Debug message --- src/accounts-service-user.vala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 92c972d..c29842a 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -114,6 +114,7 @@ public class AccountsServiceUser : Object { } ~AccountsServiceUser () { + debug("Account Service Object Finalizing"); this.player = null; if (this.timer != 0) { -- cgit v1.2.3 From 9d458fd02cc5180b9728186690026fd296edd9d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 17:06:07 -0500 Subject: Clear the player to ensure we don't get into a ref loop --- src/service.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/service.vala b/src/service.vala index de03296..df33a62 100644 --- a/src/service.vala +++ b/src/service.vala @@ -67,6 +67,11 @@ public class IndicatorSound.Service: Object { } void build_accountsservice () { + /* NOTE: This is a bit of a hack to ensure that accounts service doesn't + continue to export the player by keeping a ref in the timer */ + if (this.accounts_service != null) + this.accounts_service.player = null; + this.accounts_service = null; /* If we're not exporting, don't build anything */ -- cgit v1.2.3 From c04df47dc6e092e843532c602d367ef315a5d79d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 17:07:27 -0500 Subject: Handle sigterm --- src/service.vala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/service.vala b/src/service.vala index df33a62..c8a57ac 100644 --- a/src/service.vala +++ b/src/service.vala @@ -101,6 +101,13 @@ public class IndicatorSound.Service: Object { this.bus_acquired, null, this.name_lost); this.loop = new MainLoop (null, false); + + GLib.Unix.signal_add(GLib.ProcessSignal.TERM, () => { + debug("SIGTERM recieved, stopping our mainloop"); + this.loop.quit(); + return false; + }); + this.loop.run (); return 0; -- cgit v1.2.3 From 0ef1cba5e195c4d92b7dd5753cb88f072aa9f297 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 20 Mar 2014 17:13:05 -0500 Subject: Make sure to clear the player on exit --- src/service.vala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/service.vala b/src/service.vala index c8a57ac..8b83082 100644 --- a/src/service.vala +++ b/src/service.vala @@ -110,6 +110,10 @@ public class IndicatorSound.Service: Object { this.loop.run (); + /* Ensure we clear the player right after the mainloop quits */ + if (this.accounts_service != null) + this.accounts_service.player = null; + return 0; } -- cgit v1.2.3 From 0f18af8fd8c22b756436a5d7ff8c93e6d9a489a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Mar 2014 14:26:43 -0500 Subject: Move all the clearing of the player into one place --- src/service.vala | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/service.vala b/src/service.vala index 8b83082..bfd4115 100644 --- a/src/service.vala +++ b/src/service.vala @@ -67,11 +67,7 @@ public class IndicatorSound.Service: Object { } void build_accountsservice () { - /* NOTE: This is a bit of a hack to ensure that accounts service doesn't - continue to export the player by keeping a ref in the timer */ - if (this.accounts_service != null) - this.accounts_service.player = null; - + clear_acts_player(); this.accounts_service = null; /* If we're not exporting, don't build anything */ @@ -91,6 +87,13 @@ public class IndicatorSound.Service: Object { this.eventually_update_player_actions(); } + void clear_acts_player () { + /* NOTE: This is a bit of a hack to ensure that accounts service doesn't + continue to export the player by keeping a ref in the timer */ + if (this.accounts_service != null) + this.accounts_service.player = null; + } + public int run () { if (this.loop != null) { warning ("service is already running"); @@ -110,9 +113,7 @@ public class IndicatorSound.Service: Object { this.loop.run (); - /* Ensure we clear the player right after the mainloop quits */ - if (this.accounts_service != null) - this.accounts_service.player = null; + clear_acts_player(); return 0; } @@ -400,9 +401,8 @@ public class IndicatorSound.Service: Object { } } - if (clear_accounts_player && accounts_service != null) { - accounts_service.player = null; - } + if (clear_accounts_player) + clear_acts_player(); this.player_action_update_id = 0; return false; -- cgit v1.2.3 From 929d65e2b0df330cc3995b9ea1c6ba36732407b2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Mar 2014 14:30:09 -0500 Subject: Remove sound blocked timer when the service is shutdown --- src/service.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/service.vala b/src/service.vala index bfd4115..3bda52f 100644 --- a/src/service.vala +++ b/src/service.vala @@ -66,6 +66,11 @@ public class IndicatorSound.Service: Object { sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET); } + ~Service() { + if (this.sound_was_blocked_timeout_id > 0) + Source.remove (this.sound_was_blocked_timeout_id); + } + void build_accountsservice () { clear_acts_player(); this.accounts_service = null; -- cgit v1.2.3 From aee881c058971adcbe676d0d24d4924a0f38ef67 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 Mar 2014 14:31:40 -0500 Subject: Make sure to clear values after removing the source --- src/service.vala | 4 +++- src/volume-control.vala | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/service.vala b/src/service.vala index 3bda52f..f6c5f01 100644 --- a/src/service.vala +++ b/src/service.vala @@ -67,8 +67,10 @@ public class IndicatorSound.Service: Object { } ~Service() { - if (this.sound_was_blocked_timeout_id > 0) + if (this.sound_was_blocked_timeout_id > 0) { Source.remove (this.sound_was_blocked_timeout_id); + this.sound_was_blocked_timeout_id = 0; + } } void build_accountsservice () { diff --git a/src/volume-control.vala b/src/volume-control.vala index 8f21b60..03cac0b 100644 --- a/src/volume-control.vala +++ b/src/volume-control.vala @@ -56,6 +56,7 @@ public class VolumeControl : Object { if (_reconnect_timer != 0) { Source.remove (_reconnect_timer); + _reconnect_timer = 0; } } -- cgit v1.2.3