From 948e2a727ebd214752a7b9ecc863ed613cc110d2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Feb 2014 09:26:42 -0600 Subject: Adding the greeter broadcast DBus API --- src/CMakeLists.txt | 4 ++++ src/greeter-broadcast.vala | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/greeter-broadcast.vala diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 436a154..c3ff2ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,10 +103,14 @@ vala_add(indicator-sound-service media-player mpris2-interfaces accounts-service-sound-settings + greeter-broadcast ) vala_add(indicator-sound-service accounts-service-sound-settings.vala ) +vala_add(indicator-sound-service + greeter-broadcast.vala +) vala_finish(indicator-sound-service SOURCES diff --git a/src/greeter-broadcast.vala b/src/greeter-broadcast.vala new file mode 100644 index 0000000..e1a2793 --- /dev/null +++ b/src/greeter-broadcast.vala @@ -0,0 +1,34 @@ +/* + * Copyright 2014 © Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY 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 . + * + * Authors: + * Ted Gould + */ + +[DBus (name = "com.canonical.Unity.Greeter.Broadcast")] +public interface GreeterBroadcast : Object { + // methods + public abstract async void RequestApplicationStart(string name, string appid) throws IOError; + public abstract async void RequestHomeShown(string name) throws IOError; + public abstract async void RequestSoundPlayPause(string name) throws IOError; + public abstract async void RequestSoundNext(string name) throws IOError; + public abstract async void RequestSoundPrev(string name) throws IOError; + // signals + public signal void StartApplication(string username, string appid); + public signal void ShowHome(string username); + public signal void SoundPlayPause(string username); + public signal void SoundNext(string username); + public signal void SoundPrev(string username); +} -- cgit v1.2.3 From 70d2d969bc4ba562792580f10e8c382691fa5881 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Feb 2014 11:17:10 -0600 Subject: Get teh greeter proxy and control it --- src/CMakeLists.txt | 1 + src/media-player-user.vala | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c3ff2ae..55c5fba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,6 +64,7 @@ vala_add(indicator-sound-service DEPENDS media-player accounts-service-sound-settings + greeter-broadcast ) vala_add(indicator-sound-service media-player-list.vala diff --git a/src/media-player-user.vala b/src/media-player-user.vala index 798c8c8..6545cef 100644 --- a/src/media-player-user.vala +++ b/src/media-player-user.vala @@ -22,6 +22,7 @@ public class MediaPlayerUser : MediaPlayer { string username; Act.User? actuser = null; AccountsServiceSoundSettings? proxy = null; + GreeterBroadcast? greeter = null; HashTable properties_queued = new HashTable(str_hash, str_equal); uint properties_timeout = 0; @@ -45,6 +46,14 @@ public class MediaPlayerUser : MediaPlayer { null, new_proxy); }); + + Bus.get_proxy.begin ( + BusType.SYSTEM, + "com.canonical.Unity.Greeter.Broadcast", + "/com/canonical/Unity/Greeter/Broadcast", + DBusProxyFlags.NONE, + null, + greeter_proxy_new); } ~MediaPlayerUser () { @@ -205,18 +214,33 @@ public class MediaPlayerUser : MediaPlayer { set { } } + void greeter_proxy_new (GLib.Object? obj, AsyncResult res) { + try { + this.greeter = Bus.get_proxy.end (res); + } catch (Error e) { + this.greeter = null; + warning("Unable to get greeter proxy: %s", e.message); + } + } + /* Control functions through unity-greeter-session-broadcast */ public override void activate () { /* TODO: */ } public override void play_pause () { - /* TODO: */ + if (this.greeter != null) { + this.greeter.SoundPlayPause(this.username); + } } public override void next () { - /* TODO: */ + if (this.greeter != null) { + this.greeter.SoundNext(this.username); + } } public override void previous () { - /* TODO: */ + if (this.greeter != null) { + this.greeter.SoundPrev(this.username); + } } /* Play list functions are all null as we don't support the -- cgit v1.2.3 From 636de261d04d47de8305597c27c9eed921c20b71 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 27 Feb 2014 15:11:29 -0600 Subject: Adding support to the greeter signals on the other side --- src/accounts-service-user.vala | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index f021764..debf8bb 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -23,6 +23,7 @@ public class AccountsServiceUser : Object { AccountsServiceSoundSettings? proxy = null; uint timer = 0; MediaPlayer? _player = null; + GreeterBroadcast? greeter = null; public MediaPlayer? player { set { @@ -97,6 +98,14 @@ public class AccountsServiceUser : Object { null, new_proxy); }); + + Bus.get_proxy.begin ( + BusType.SYSTEM, + "com.canonical.Unity.Greeter.Broadcast", + "/com/canonical/Unity/Greeter/Broadcast", + DBusProxyFlags.NONE, + null, + greeter_proxy_new); } ~AccountsServiceUser () { @@ -112,4 +121,37 @@ public class AccountsServiceUser : Object { warning("Unable to get proxy to user sound settings: %s", e.message); } } + + void greeter_proxy_new (GLib.Object? obj, AsyncResult res) { + try { + this.greeter = Bus.get_proxy.end (res); + + this.greeter.SoundPlayPause.connect((username) => { + if (username != GLib.Environment.get_user_name()) + return; + if (this._player == null) + return; + this._player.play_pause(); + }); + + this.greeter.SoundNext.connect((username) => { + if (username != GLib.Environment.get_user_name()) + return; + if (this._player == null) + return; + this._player.next(); + }); + + this.greeter.SoundPrev.connect((username) => { + if (username != GLib.Environment.get_user_name()) + return; + if (this._player == null) + return; + this._player.previous(); + }); + } catch (Error e) { + this.greeter = null; + warning("Unable to get greeter proxy: %s", e.message); + } + } } -- cgit v1.2.3 From cb111a1f8489c1d2cec3069988c5e499030f8b50 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 28 Feb 2014 13:55:27 -0600 Subject: Putting in some debug output --- src/media-player-user.vala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/media-player-user.vala b/src/media-player-user.vala index 6545cef..7e5bc53 100644 --- a/src/media-player-user.vala +++ b/src/media-player-user.vala @@ -157,6 +157,7 @@ public class MediaPlayerUser : MediaPlayer { get { if (proxy_is_valid()) { name_cache = this.proxy.player_name; + debug("Player Name: %s", name_cache); return name_cache; } else { return ""; @@ -168,6 +169,7 @@ public class MediaPlayerUser : MediaPlayer { get { if (proxy_is_valid()) { state_cache = this.proxy.state; + debug("State: %s", state_cache); return state_cache; } else { return ""; @@ -228,18 +230,30 @@ public class MediaPlayerUser : MediaPlayer { /* TODO: */ } public override void play_pause () { + debug("Play Pause for user: %s", this.username); + if (this.greeter != null) { this.greeter.SoundPlayPause(this.username); + } else { + warning("No unity-greeter-session-broadcast to send play-pause"); } } public override void next () { + debug("Next for user: %s", this.username); + if (this.greeter != null) { this.greeter.SoundNext(this.username); + } else { + warning("No unity-greeter-session-broadcast to send next"); } } public override void previous () { + debug("Previous for user: %s", this.username); + if (this.greeter != null) { this.greeter.SoundPrev(this.username); + } else { + warning("No unity-greeter-session-broadcast to send previous"); } } -- cgit v1.2.3 From f06b9ff784c15e9e1c0ad0840299ed70b5616a74 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 28 Feb 2014 14:35:28 -0600 Subject: Use the right function and report error --- src/media-player-user.vala | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/media-player-user.vala b/src/media-player-user.vala index 7e5bc53..c48c39b 100644 --- a/src/media-player-user.vala +++ b/src/media-player-user.vala @@ -233,7 +233,13 @@ public class MediaPlayerUser : MediaPlayer { debug("Play Pause for user: %s", this.username); if (this.greeter != null) { - this.greeter.SoundPlayPause(this.username); + this.greeter.RequestSoundPlayPause.begin(this.username, (obj, res) => { + try { + (obj as GreeterBroadcast).RequestSoundPlayPause.end(res); + } catch (Error e) { + warning("Unable to send play pause: %s", e.message); + } + }); } else { warning("No unity-greeter-session-broadcast to send play-pause"); } @@ -242,7 +248,13 @@ public class MediaPlayerUser : MediaPlayer { debug("Next for user: %s", this.username); if (this.greeter != null) { - this.greeter.SoundNext(this.username); + this.greeter.RequestSoundNext.begin(this.username, (obj, res) => { + try { + (obj as GreeterBroadcast).RequestSoundNext.end(res); + } catch (Error e) { + warning("Unable to send next: %s", e.message); + } + }); } else { warning("No unity-greeter-session-broadcast to send next"); } @@ -251,7 +263,13 @@ public class MediaPlayerUser : MediaPlayer { debug("Previous for user: %s", this.username); if (this.greeter != null) { - this.greeter.SoundPrev(this.username); + this.greeter.RequestSoundPrev.begin(this.username, (obj, res) => { + try { + (obj as GreeterBroadcast).RequestSoundPrev.end(res); + } catch (Error e) { + warning("Unable to send previous: %s", e.message); + } + }); } else { warning("No unity-greeter-session-broadcast to send previous"); } -- cgit v1.2.3 From 7dbb4d8816152c584ef65e7b2004df3a17d13b1a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 4 Mar 2014 23:20:30 -0600 Subject: Try to get session broadcast if we can --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index f026240..2cbdc47 100644 --- a/debian/control +++ b/debian/control @@ -39,6 +39,7 @@ Depends: ${shlibs:Depends}, pulseaudio, gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140224), Recommends: unity-control-center | gnome-control-center | ubuntu-system-settings | pavucontrol, + unity-greeter-session-broadcast, Description: System sound indicator. System sound indicator which provides easy control of the PulseAudio sound daemon. -- cgit v1.2.3 From e12654c5ddd82849442bf88d61f9634fc2afc37b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 4 Mar 2014 23:21:56 -0600 Subject: Grab accounts service too --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 2cbdc47..ad6b4fb 100644 --- a/debian/control +++ b/debian/control @@ -40,6 +40,7 @@ Depends: ${shlibs:Depends}, gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140224), Recommends: unity-control-center | gnome-control-center | ubuntu-system-settings | pavucontrol, unity-greeter-session-broadcast, + accountsservice, Description: System sound indicator. System sound indicator which provides easy control of the PulseAudio sound daemon. -- cgit v1.2.3 From 661dc6ed9f771c8f84677aefd951c5e9a5505038 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 13 Mar 2014 13:38:55 -0500 Subject: Don't build proxy for unused functions --- src/greeter-broadcast.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/greeter-broadcast.vala b/src/greeter-broadcast.vala index e1a2793..f3d380e 100644 --- a/src/greeter-broadcast.vala +++ b/src/greeter-broadcast.vala @@ -20,14 +20,14 @@ [DBus (name = "com.canonical.Unity.Greeter.Broadcast")] public interface GreeterBroadcast : Object { // methods - public abstract async void RequestApplicationStart(string name, string appid) throws IOError; - public abstract async void RequestHomeShown(string name) throws IOError; + // unused public abstract async void RequestApplicationStart(string name, string appid) throws IOError; + // unused public abstract async void RequestHomeShown(string name) throws IOError; public abstract async void RequestSoundPlayPause(string name) throws IOError; public abstract async void RequestSoundNext(string name) throws IOError; public abstract async void RequestSoundPrev(string name) throws IOError; // signals - public signal void StartApplication(string username, string appid); - public signal void ShowHome(string username); + // unused public signal void StartApplication(string username, string appid); + // unused public signal void ShowHome(string username); public signal void SoundPlayPause(string username); public signal void SoundNext(string username); public signal void SoundPrev(string username); -- cgit v1.2.3