Merge lp:~stolowski/unity-lens-shopping/use-libunity-extras into lp:unity-lens-shopping

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 33
Merged at revision: 32
Proposed branch: lp:~stolowski/unity-lens-shopping/use-libunity-extras
Merge into: lp:unity-lens-shopping
Diff against target: 330 lines (+11/-225)
5 files modified
configure.ac (+4/-2)
src/Makefile.am (+1/-2)
src/preview-player-client.vala (+0/-112)
src/scope.vala (+4/-4)
src/u1ms-preview.vala (+2/-105)
To merge this branch: bzr merge lp:~stolowski/unity-lens-shopping/use-libunity-extras
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michal Hruby (community) Approve
Review via email: mp+129164@code.launchpad.net

Commit message

Removed PreviewPlayer client code. Use PreviewPlayerHandler from Unity.Extras (requires new libunity).

Description of the change

Removed PreviewPlayer client code. Use PreviewPlayerHandler from Unity.Extras (requires new libunity).

DON'T approve until https://code.launchpad.net/~stolowski/libunity/libunity-extras/+merge/129120 is merged!

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

+1

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-10-04 14:00:06 +0000
3+++ configure.ac 2012-10-17 14:53:21 +0000
4@@ -64,7 +64,9 @@
5 gee-1.0
6 libsoup-gnome-2.4
7 json-glib-1.0
8- unity >= 6.7)
9+ unity >= 6.90.0
10+ unity-extras >= 6.90.0
11+ )
12
13 AC_SUBST(LENS_DAEMON_CFLAGS)
14 AC_SUBST(LENS_DAEMON_LIBS)
15@@ -134,7 +136,7 @@
16 ----------------------------------
17
18 Prefix : ${prefix}
19-
20+
21 Local install : ${with_localinstall}
22
23 Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS
24
25=== modified file 'src/Makefile.am'
26--- src/Makefile.am 2012-09-26 11:10:59 +0000
27+++ src/Makefile.am 2012-10-17 14:53:21 +0000
28@@ -23,6 +23,7 @@
29 -C \
30 --pkg dee-1.0 \
31 --pkg unity \
32+ --pkg unity-extras \
33 --pkg gee-1.0 \
34 --pkg gio-2.0 \
35 --pkg gio-unix-2.0 \
36@@ -47,7 +48,6 @@
37 main.vala \
38 scope.vala \
39 markup-cleaner.vala \
40- preview-player-client.vala \
41 u1ms-preview.vala \
42 $(NULL)
43
44@@ -72,4 +72,3 @@
45 *.stamp \
46 $(unity_shopping_daemon_VALASOURCES:.vala=.c) \
47 $(NULL)
48-
49
50=== removed file 'src/preview-player-client.vala'
51--- src/preview-player-client.vala 2012-09-25 15:57:47 +0000
52+++ src/preview-player-client.vala 1970-01-01 00:00:00 +0000
53@@ -1,112 +0,0 @@
54-/*
55- * Copyright (C) 2012 Canonical Ltd
56- *
57- * This program is free software: you can redistribute it and/or modify
58- * it under the terms of the GNU General Public License version 3 as
59- * published by the Free Software Foundation.
60- *
61- * This program is distributed in the hope that it will be useful,
62- * but WITHOUT ANY WARRANTY; without even the implied warranty of
63- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64- * GNU General Public License for more details.
65- *
66- * You should have received a copy of the GNU General Public License
67- * along with this program. If not, see <http://www.gnu.org/licenses/>.
68- *
69- * Authored by Pawel Stolowski <pawel.stolowski@canonical.com>
70- */
71-
72-
73-/*
74- * FIXME: this code was copied from music-lens; it needs to be kept in sync and eventually moved to a library !!!
75- */
76-namespace Unity.ShoppingLens {
77-
78- static const string PREVIEW_PLAYER_DBUS_NAME = "com.canonical.Unity.Lens.Music.PreviewPlayer";
79- static const string PREVIEW_PLAYER_DBUS_PATH = "/com/canonical/Unity/Lens/Music/PreviewPlayer";
80-
81- [DBus (name = "com.canonical.Unity.Lens.Music.PreviewPlayer")]
82- public interface PreviewPlayerService: GLib.Object
83- {
84- public signal void progress(string uri, uint32 state, double progress);
85-
86- public abstract async void play (string uri) throws Error;
87- public abstract async void pause () throws Error;
88- public abstract async void pause_resume () throws Error;
89- public abstract async void resume () throws Error;
90- public abstract async void stop () throws Error;
91- public abstract async void close () throws Error;
92- }
93-
94- public class PreviewPlayer: GLib.Object
95- {
96- public signal void progress(string uri, Unity.MusicPreview.TrackState state, double progress);
97-
98- public async void connect_to () throws Error
99- {
100- _preview_player_service = Bus.get_proxy_sync (BusType.SESSION, PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH);
101- _preview_player_service.progress.connect (on_progress_signal);
102- }
103-
104- public async void play (string uri) throws Error
105- {
106- if (_preview_player_service == null)
107- {
108- yield connect_to ();
109- }
110- yield _preview_player_service.play (uri);
111- }
112-
113- public async void pause () throws Error
114- {
115- if (_preview_player_service == null)
116- {
117- yield connect_to ();
118- }
119- yield _preview_player_service.pause ();
120- }
121-
122- public async void pause_resume () throws Error
123- {
124- if (_preview_player_service == null)
125- {
126- yield connect_to ();
127- }
128- yield _preview_player_service.pause_resume ();
129- }
130-
131- public async void resume () throws Error
132- {
133- if (_preview_player_service == null)
134- {
135- yield connect_to ();
136- }
137- yield _preview_player_service.resume ();
138- }
139-
140- public async void stop () throws Error
141- {
142- if (_preview_player_service == null)
143- {
144- yield connect_to ();
145- }
146- yield _preview_player_service.stop ();
147- }
148-
149- public async void close () throws Error
150- {
151- if (_preview_player_service == null)
152- {
153- yield connect_to ();
154- }
155- yield _preview_player_service.close ();
156- }
157-
158- internal void on_progress_signal (string uri, uint32 state, double progress_value)
159- {
160- progress(uri, (Unity.MusicPreview.TrackState)state, progress_value);
161- }
162-
163- private PreviewPlayerService _preview_player_service;
164- }
165-}
166\ No newline at end of file
167
168=== modified file 'src/scope.vala'
169--- src/scope.vala 2012-10-11 09:17:45 +0000
170+++ src/scope.vala 2012-10-17 14:53:21 +0000
171@@ -28,7 +28,7 @@
172 private HashTable<string, string> results_details_map;
173 private HashTable<string, string> global_results_details_map;
174 private Soup.Session session;
175- private PreviewPlayerHandler player;
176+ private Unity.Extras.PreviewPlayerController player;
177
178 private PreferencesManager preferences = PreferencesManager.get_default ();
179
180@@ -78,7 +78,7 @@
181
182 preferences.notify["remote-content-search"].connect ((obj, pspec) => { queue_search_changed (SearchType.GLOBAL); });
183 }
184-
185+
186 private async void update_search_async (LensSearch search,
187 SearchType search_type,
188 Cancellable cancellable)
189@@ -166,8 +166,8 @@
190 var preview = u1mspf.create_preview (parser);
191 u1mspf.add_download_action (preview); // download will be handled by normal activation
192 if (player == null)
193- player = new PreviewPlayerHandler ();
194- player.music_preview = preview;
195+ player = new Unity.Extras.PreviewPlayerController ();
196+ player.active_preview = preview;
197 return preview;
198 }
199 else
200
201=== modified file 'src/u1ms-preview.vala'
202--- src/u1ms-preview.vala 2012-09-25 15:57:47 +0000
203+++ src/u1ms-preview.vala 2012-10-17 14:53:21 +0000
204@@ -23,109 +23,6 @@
205 */
206 namespace Unity.ShoppingLens
207 {
208-
209- public class PreviewPlayerHandler
210- {
211- private PreviewPlayer preview_player;
212- private Unity.MusicPreview music_preview_;
213-
214- public Unity.MusicPreview music_preview
215- {
216- get
217- {
218- return music_preview_;
219- }
220- set
221- {
222- music_preview_ = value;
223- if (value != null)
224- {
225- music_preview.play.connect (play);
226- music_preview.pause.connect (pause);
227- music_preview.closed.connect (closed);
228- }
229- }
230- }
231-
232- public PreviewPlayerHandler (Unity.MusicPreview? preview = null)
233- {
234- music_preview = preview;
235- }
236-
237- private void on_progress_changed (string uri, Unity.MusicPreview.TrackState state, double progress)
238- {
239- if (music_preview != null)
240- {
241- music_preview.current_track_uri = uri;
242- music_preview.current_track_state = state;
243- music_preview.current_progress = (float)progress;
244- }
245- }
246-
247- private void closed (Unity.Preview preview)
248- {
249- if (preview_player != null)
250- {
251- try
252- {
253- preview_player.close ();
254- }
255- catch (Error e)
256- {
257- warning ("Failed to close preview player: %s", e.message);
258- }
259- }
260- }
261-
262- private void play (Unity.Preview preview, string uri)
263- {
264- debug ("play request: '%s'", uri);
265-
266- try
267- {
268- if (preview_player == null)
269- {
270- preview_player = new PreviewPlayer ();
271- preview_player.progress.connect (on_progress_changed);
272- preview_player.connect_to ();
273- }
274-
275- // we will receive state back in on_progress_changed, but set it now so that it's immediately reflected in the dash
276- music_preview.current_track_uri = uri;
277- music_preview.current_progress = 0.0f;
278- music_preview.current_track_state = Unity.MusicPreview.TrackState.PLAYING;
279-
280- preview_player.play (uri);
281- }
282- catch (Error e)
283- {
284- warning ("Failed to play '%s': %s", uri, e.message);
285- }
286- }
287-
288- public void pause (Unity.Preview preview, string uri)
289- {
290- debug ("pause request: '%s'", uri);
291-
292- try
293- {
294- if (preview_player != null)
295- {
296- // we will receive state back in on_progress_changed, but set it now so that it's immediately reflected in the dash
297- music_preview.current_track_uri = uri;
298- music_preview.current_track_state = Unity.MusicPreview.TrackState.PAUSED;
299-
300- preview_player.pause ();
301- }
302- }
303- catch (Error e)
304- {
305- warning ("Failed to pause '%s': %s", uri, e.message);
306- }
307- }
308- }
309-
310-
311 public class U1MSPreviewFactory
312 {
313 public string formatted_price { get; internal set; }
314@@ -146,14 +43,14 @@
315 var cover = new FileIcon (cover_file);
316
317 var artist = root_obj.get_string_member ("artist");
318-
319+
320 var preview = new Unity.MusicPreview (title, artist, cover);
321
322 if (root_obj.has_member ("formatted_price"))
323 formatted_price = root_obj.get_string_member ("formatted_price");
324 else
325 formatted_price = "";
326-
327+
328 if (root_obj.has_member ("tracks"))
329 {
330 var tracks_node = root_obj.get_array_member ("tracks");

Subscribers

People subscribed via source and target branches