aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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.vala44
4 files changed, 122 insertions, 3 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 436a154..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
@@ -103,10 +104,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 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<GreeterBroadcast> (
+ 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);
+ }
+ }
}
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 <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Ted Gould <ted@canonical.com>
+ */
+
+[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);
+}
diff --git a/src/media-player-user.vala b/src/media-player-user.vala
index 798c8c8..7e5bc53 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 () {
@@ -148,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 "";
@@ -159,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 "";
@@ -205,18 +216,45 @@ 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.SoundPlayPause(this.username);
+ } 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.SoundNext(this.username);
+ } 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.SoundPrev(this.username);
+ } else {
+ warning("No unity-greeter-session-broadcast to send previous");
+ }
}
/* Play list functions are all null as we don't support the