aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/control2
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/accounts-service-user.vala42
-rw-r--r--src/greeter-broadcast.vala34
-rw-r--r--src/media-player-user.vala62
5 files changed, 142 insertions, 3 deletions
diff --git a/debian/control b/debian/control
index f10d9b0..7c9fe2a 100644
--- a/debian/control
+++ b/debian/control
@@ -39,6 +39,8 @@ 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,
+ accountsservice,
Description: System sound indicator.
System sound indicator which provides easy control of the PulseAudio sound
daemon.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f2c6cec..98bc7c4 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
@@ -102,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/accounts-service-user.vala b/src/accounts-service-user.vala
index c29842a..4dd7e6f 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 {
@@ -95,6 +96,14 @@ public class AccountsServiceUser : Object {
user = accounts_manager.get_user(GLib.Environment.get_user_name());
user.notify["is-loaded"].connect(() => user_loaded_changed());
user_loaded_changed();
+
+ Bus.get_proxy.begin<GreeterBroadcast> (
+ BusType.SYSTEM,
+ "com.canonical.Unity.Greeter.Broadcast",
+ "/com/canonical/Unity/Greeter/Broadcast",
+ DBusProxyFlags.NONE,
+ null,
+ greeter_proxy_new);
}
void user_loaded_changed () {
@@ -132,4 +141,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);
+ }
+ }
}
diff --git a/src/greeter-broadcast.vala b/src/greeter-broadcast.vala
new file mode 100644
index 0000000..f3d380e
--- /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 <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Ted Gould <ted@canonical.com>
+ */
+
+[DBus (name = "com.canonical.Unity.Greeter.Broadcast")]
+public interface GreeterBroadcast : Object {
+ // methods
+ // 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
+ // 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);
+}
diff --git a/src/media-player-user.vala b/src/media-player-user.vala
index dfe6229..11678d5 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<string, bool> properties_queued = new HashTable<string, bool>(str_hash, str_equal);
uint properties_timeout = 0;
@@ -45,6 +46,14 @@ public class MediaPlayerUser : MediaPlayer {
null,
new_proxy);
});
+
+ Bus.get_proxy.begin<GreeterBroadcast> (
+ BusType.SYSTEM,
+ "com.canonical.Unity.Greeter.Broadcast",
+ "/com/canonical/Unity/Greeter/Broadcast",
+ DBusProxyFlags.NONE,
+ null,
+ greeter_proxy_new);
}
~MediaPlayerUser () {
@@ -152,6 +161,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 "";
@@ -163,6 +173,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 "";
@@ -209,18 +220,63 @@ 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: */
+ debug("Play Pause for user: %s", this.username);
+
+ if (this.greeter != null) {
+ 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");
+ }
}
public override void next () {
- /* TODO: */
+ debug("Next for user: %s", this.username);
+
+ if (this.greeter != null) {
+ 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");
+ }
}
public override void previous () {
- /* TODO: */
+ debug("Previous for user: %s", this.username);
+
+ if (this.greeter != null) {
+ 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");
+ }
}
/* Play list functions are all null as we don't support the