Merge lp:~ted/indicator-sound/greeter-control into lp:indicator-sound/14.04

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 463
Merged at revision: 434
Proposed branch: lp:~ted/indicator-sound/greeter-control
Merge into: lp:indicator-sound/14.04
Prerequisite: lp:~ted/indicator-sound/account-service-player
Diff against target: 253 lines (+142/-3)
5 files modified
debian/control (+2/-0)
src/CMakeLists.txt (+5/-0)
src/accounts-service-user.vala (+42/-0)
src/greeter-broadcast.vala (+34/-0)
src/media-player-user.vala (+59/-3)
To merge this branch: bzr merge lp:~ted/indicator-sound/greeter-control
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+209338@code.launchpad.net

Commit message

Allow the phone greeter player to control the running player in the session.

Description of the change

Puts both the sender and the listener of the greeter broadcast into both sides of the indicator-sound world. One emits the event through the reflector and the other receives it. Needs this branch to work:

https://code.launchpad.net/~ted/unity-greeter-session-broadcast/sound-control/+merge/208894

To post a comment you must log in.
459. By Ted Gould

Try to get session broadcast if we can

460. By Ted Gould

Grab accounts service too

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

 * Is Recommends sufficient for accountsservice? Surely it's a Depends now...?

 * In GreeterBroadcast, RequestApplicationStart(), RequestHomeShown(), StartApplication(),
   ShowHome() appear to be unused. Is there another branch waiting to be stacked on top
   of this one? Otherwise, these unused methods/signals should be removed

 * In accounts-service-user, probably ought to Warn() if username != g_get_user_name()
   instead of returning silently... if that argument's wrong, something's gone wrong
   in MediaPlayerListGreeter

461. By Ted Gould

Don't build proxy for unused functions

Revision history for this message
Ted Gould (ted) wrote :

 * Is Recommends sufficient for accountsservice? Surely it's a Depends now...?

I left it as a recommends just because we wouldn't *die* without it. I'd go either way, I figured the only thing we *needed* was the lib which gets pulled in by linking.

* In GreeterBroadcast, RequestApplicationStart(), RequestHomeShown(), StartApplication(),
   ShowHome() appear to be unused. Is there another branch waiting to be stacked on top
   of this one? Otherwise, these unused methods/signals should be removed

Fixed. r461. I commented them in case someone wanted to steal this Vala code in the future.

 * In accounts-service-user, probably ought to Warn() if username != g_get_user_name()
   instead of returning silently... if that argument's wrong, something's gone wrong
   in MediaPlayerListGreeter

Those are the signals that come off the system bus, so those events can be targeted at another user session that is also running at the same time. So it can be normal that we'd get ones that aren't for us.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
462. By Ted Gould

Sync to latest account-service-player

Revision history for this message
Ted Gould (ted) wrote :

Failing because it needs a newer dbus-test-runner, updated the dep.

463. By Ted Gould

Merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Jenkins failing because it needs to get the dbus-test-runner branch to land at the same time.

Revision history for this message
Charles Kerr (charlesk) :
review: Approve
464. By Ted Gould

Update to trunk and export updates

465. By Ted Gould

Updating to latest export

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-03-21 21:36:35 +0000
3+++ debian/control 2014-03-21 21:36:35 +0000
4@@ -39,6 +39,8 @@
5 pulseaudio,
6 gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140224),
7 Recommends: unity-control-center | gnome-control-center | ubuntu-system-settings | pavucontrol,
8+ unity-greeter-session-broadcast,
9+ accountsservice,
10 Description: System sound indicator.
11 System sound indicator which provides easy control of the PulseAudio sound
12 daemon.
13
14=== modified file 'src/CMakeLists.txt'
15--- src/CMakeLists.txt 2014-03-21 21:36:35 +0000
16+++ src/CMakeLists.txt 2014-03-21 21:36:35 +0000
17@@ -64,6 +64,7 @@
18 DEPENDS
19 media-player
20 accounts-service-sound-settings
21+ greeter-broadcast
22 )
23 vala_add(indicator-sound-service
24 media-player-list.vala
25@@ -102,10 +103,14 @@
26 media-player
27 mpris2-interfaces
28 accounts-service-sound-settings
29+ greeter-broadcast
30 )
31 vala_add(indicator-sound-service
32 accounts-service-sound-settings.vala
33 )
34+vala_add(indicator-sound-service
35+ greeter-broadcast.vala
36+)
37
38 vala_finish(indicator-sound-service
39 SOURCES
40
41=== modified file 'src/accounts-service-user.vala'
42--- src/accounts-service-user.vala 2014-03-21 21:36:35 +0000
43+++ src/accounts-service-user.vala 2014-03-21 21:36:35 +0000
44@@ -23,6 +23,7 @@
45 AccountsServiceSoundSettings? proxy = null;
46 uint timer = 0;
47 MediaPlayer? _player = null;
48+ GreeterBroadcast? greeter = null;
49
50 public MediaPlayer? player {
51 set {
52@@ -95,6 +96,14 @@
53 user = accounts_manager.get_user(GLib.Environment.get_user_name());
54 user.notify["is-loaded"].connect(() => user_loaded_changed());
55 user_loaded_changed();
56+
57+ Bus.get_proxy.begin<GreeterBroadcast> (
58+ BusType.SYSTEM,
59+ "com.canonical.Unity.Greeter.Broadcast",
60+ "/com/canonical/Unity/Greeter/Broadcast",
61+ DBusProxyFlags.NONE,
62+ null,
63+ greeter_proxy_new);
64 }
65
66 void user_loaded_changed () {
67@@ -132,4 +141,37 @@
68 warning("Unable to get proxy to user sound settings: %s", e.message);
69 }
70 }
71+
72+ void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
73+ try {
74+ this.greeter = Bus.get_proxy.end (res);
75+
76+ this.greeter.SoundPlayPause.connect((username) => {
77+ if (username != GLib.Environment.get_user_name())
78+ return;
79+ if (this._player == null)
80+ return;
81+ this._player.play_pause();
82+ });
83+
84+ this.greeter.SoundNext.connect((username) => {
85+ if (username != GLib.Environment.get_user_name())
86+ return;
87+ if (this._player == null)
88+ return;
89+ this._player.next();
90+ });
91+
92+ this.greeter.SoundPrev.connect((username) => {
93+ if (username != GLib.Environment.get_user_name())
94+ return;
95+ if (this._player == null)
96+ return;
97+ this._player.previous();
98+ });
99+ } catch (Error e) {
100+ this.greeter = null;
101+ warning("Unable to get greeter proxy: %s", e.message);
102+ }
103+ }
104 }
105
106=== added file 'src/greeter-broadcast.vala'
107--- src/greeter-broadcast.vala 1970-01-01 00:00:00 +0000
108+++ src/greeter-broadcast.vala 2014-03-21 21:36:35 +0000
109@@ -0,0 +1,34 @@
110+/*
111+ * Copyright 2014 © Canonical Ltd.
112+ *
113+ * This program is free software; you can redistribute it and/or modify
114+ * it under the terms of the GNU General Public License as published by
115+ * the Free Software Foundation; version 3.
116+ *
117+ * This program is distributed in the hope that it will be useful,
118+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
119+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
120+ * GNU General Public License for more details.
121+ *
122+ * You should have received a copy of the GNU General Public License
123+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
124+ *
125+ * Authors:
126+ * Ted Gould <ted@canonical.com>
127+ */
128+
129+[DBus (name = "com.canonical.Unity.Greeter.Broadcast")]
130+public interface GreeterBroadcast : Object {
131+ // methods
132+ // unused public abstract async void RequestApplicationStart(string name, string appid) throws IOError;
133+ // unused public abstract async void RequestHomeShown(string name) throws IOError;
134+ public abstract async void RequestSoundPlayPause(string name) throws IOError;
135+ public abstract async void RequestSoundNext(string name) throws IOError;
136+ public abstract async void RequestSoundPrev(string name) throws IOError;
137+ // signals
138+ // unused public signal void StartApplication(string username, string appid);
139+ // unused public signal void ShowHome(string username);
140+ public signal void SoundPlayPause(string username);
141+ public signal void SoundNext(string username);
142+ public signal void SoundPrev(string username);
143+}
144
145=== modified file 'src/media-player-user.vala'
146--- src/media-player-user.vala 2014-03-21 21:36:35 +0000
147+++ src/media-player-user.vala 2014-03-21 21:36:35 +0000
148@@ -22,6 +22,7 @@
149 string username;
150 Act.User? actuser = null;
151 AccountsServiceSoundSettings? proxy = null;
152+ GreeterBroadcast? greeter = null;
153
154 HashTable<string, bool> properties_queued = new HashTable<string, bool>(str_hash, str_equal);
155 uint properties_timeout = 0;
156@@ -45,6 +46,14 @@
157 null,
158 new_proxy);
159 });
160+
161+ Bus.get_proxy.begin<GreeterBroadcast> (
162+ BusType.SYSTEM,
163+ "com.canonical.Unity.Greeter.Broadcast",
164+ "/com/canonical/Unity/Greeter/Broadcast",
165+ DBusProxyFlags.NONE,
166+ null,
167+ greeter_proxy_new);
168 }
169
170 ~MediaPlayerUser () {
171@@ -152,6 +161,7 @@
172 get {
173 if (proxy_is_valid()) {
174 name_cache = this.proxy.player_name;
175+ debug("Player Name: %s", name_cache);
176 return name_cache;
177 } else {
178 return "";
179@@ -163,6 +173,7 @@
180 get {
181 if (proxy_is_valid()) {
182 state_cache = this.proxy.state;
183+ debug("State: %s", state_cache);
184 return state_cache;
185 } else {
186 return "";
187@@ -209,18 +220,63 @@
188 set { }
189 }
190
191+ void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
192+ try {
193+ this.greeter = Bus.get_proxy.end (res);
194+ } catch (Error e) {
195+ this.greeter = null;
196+ warning("Unable to get greeter proxy: %s", e.message);
197+ }
198+ }
199+
200 /* Control functions through unity-greeter-session-broadcast */
201 public override void activate () {
202 /* TODO: */
203 }
204 public override void play_pause () {
205- /* TODO: */
206+ debug("Play Pause for user: %s", this.username);
207+
208+ if (this.greeter != null) {
209+ this.greeter.RequestSoundPlayPause.begin(this.username, (obj, res) => {
210+ try {
211+ (obj as GreeterBroadcast).RequestSoundPlayPause.end(res);
212+ } catch (Error e) {
213+ warning("Unable to send play pause: %s", e.message);
214+ }
215+ });
216+ } else {
217+ warning("No unity-greeter-session-broadcast to send play-pause");
218+ }
219 }
220 public override void next () {
221- /* TODO: */
222+ debug("Next for user: %s", this.username);
223+
224+ if (this.greeter != null) {
225+ this.greeter.RequestSoundNext.begin(this.username, (obj, res) => {
226+ try {
227+ (obj as GreeterBroadcast).RequestSoundNext.end(res);
228+ } catch (Error e) {
229+ warning("Unable to send next: %s", e.message);
230+ }
231+ });
232+ } else {
233+ warning("No unity-greeter-session-broadcast to send next");
234+ }
235 }
236 public override void previous () {
237- /* TODO: */
238+ debug("Previous for user: %s", this.username);
239+
240+ if (this.greeter != null) {
241+ this.greeter.RequestSoundPrev.begin(this.username, (obj, res) => {
242+ try {
243+ (obj as GreeterBroadcast).RequestSoundPrev.end(res);
244+ } catch (Error e) {
245+ warning("Unable to send previous: %s", e.message);
246+ }
247+ });
248+ } else {
249+ warning("No unity-greeter-session-broadcast to send previous");
250+ }
251 }
252
253 /* Play list functions are all null as we don't support the

Subscribers

People subscribed via source and target branches