~mterry/indicator-sound/grab-greeter-name

« back to all changes in this revision

Viewing changes to src/media-player-user.vala

  • Committer: CI bot
  • Author(s): Ted Gould
  • Date: 2014-03-24 15:03:03 UTC
  • mfrom: (409.5.14 greeter-control)
  • Revision ID: ps-jenkins@lists.canonical.com-20140324150303-o9cfddrh7p3ke699
Allow the phone greeter player to control the running player in the session. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        string username;
23
23
        Act.User? actuser = null;
24
24
        AccountsServiceSoundSettings? proxy = null;
 
25
        GreeterBroadcast? greeter = null;
25
26
 
26
27
        HashTable<string, bool> properties_queued = new HashTable<string, bool>(str_hash, str_equal);
27
28
        uint properties_timeout = 0;
45
46
                                null,
46
47
                                new_proxy);
47
48
                });
 
49
 
 
50
                Bus.get_proxy.begin<GreeterBroadcast> (
 
51
                        BusType.SYSTEM,
 
52
                        "com.canonical.Unity.Greeter.Broadcast",
 
53
                        "/com/canonical/Unity/Greeter/Broadcast",
 
54
                        DBusProxyFlags.NONE,
 
55
                        null,
 
56
                        greeter_proxy_new);
48
57
        }
49
58
 
50
59
        ~MediaPlayerUser () {
152
161
                get {
153
162
                        if (proxy_is_valid()) {
154
163
                                name_cache = this.proxy.player_name;
 
164
                                debug("Player Name: %s", name_cache);
155
165
                                return name_cache;
156
166
                        } else {
157
167
                                return "";
163
173
                get {
164
174
                        if (proxy_is_valid()) {
165
175
                                state_cache = this.proxy.state;
 
176
                                debug("State: %s", state_cache);
166
177
                                return state_cache;
167
178
                        } else {
168
179
                                return "";
209
220
                set { }
210
221
        }
211
222
 
 
223
        void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
 
224
                try {
 
225
                        this.greeter = Bus.get_proxy.end (res);
 
226
                } catch (Error e) {
 
227
                        this.greeter = null;
 
228
                        warning("Unable to get greeter proxy: %s", e.message);
 
229
                }
 
230
        }
 
231
 
212
232
        /* Control functions through unity-greeter-session-broadcast */
213
233
        public override void activate () {
214
234
                /* TODO: */
215
235
        }
216
236
        public override void play_pause () {
217
 
                /* TODO: */
 
237
                debug("Play Pause for user: %s", this.username);
 
238
 
 
239
                if (this.greeter != null) {
 
240
                        this.greeter.RequestSoundPlayPause.begin(this.username, (obj, res) => {
 
241
                                try {
 
242
                                        (obj as GreeterBroadcast).RequestSoundPlayPause.end(res);
 
243
                                } catch (Error e) {
 
244
                                        warning("Unable to send play pause: %s", e.message);
 
245
                                }
 
246
                        });
 
247
                } else {
 
248
                        warning("No unity-greeter-session-broadcast to send play-pause");
 
249
                }
218
250
        }
219
251
        public override void next () {
220
 
                /* TODO: */
 
252
                debug("Next for user: %s", this.username);
 
253
 
 
254
                if (this.greeter != null) {
 
255
                        this.greeter.RequestSoundNext.begin(this.username, (obj, res) => {
 
256
                                try {
 
257
                                        (obj as GreeterBroadcast).RequestSoundNext.end(res);
 
258
                                } catch (Error e) {
 
259
                                        warning("Unable to send next: %s", e.message);
 
260
                                }
 
261
                        });
 
262
                } else {
 
263
                        warning("No unity-greeter-session-broadcast to send next");
 
264
                }
221
265
        }
222
266
        public override void previous () {
223
 
                /* TODO: */
 
267
                debug("Previous for user: %s", this.username);
 
268
 
 
269
                if (this.greeter != null) {
 
270
                        this.greeter.RequestSoundPrev.begin(this.username, (obj, res) => {
 
271
                                try {
 
272
                                        (obj as GreeterBroadcast).RequestSoundPrev.end(res);
 
273
                                } catch (Error e) {
 
274
                                        warning("Unable to send previous: %s", e.message);
 
275
                                }
 
276
                        });
 
277
                } else {
 
278
                        warning("No unity-greeter-session-broadcast to send previous");
 
279
                }
224
280
        }
225
281
 
226
282
        /* Play list functions are all null as we don't support the