Merge lp:~alexlauni/unity-lens-music/musicstore into lp:unity-lens-music

Proposed by Alex Launi
Status: Merged
Merged at revision: 43
Proposed branch: lp:~alexlauni/unity-lens-music/musicstore
Merge into: lp:unity-lens-music
Diff against target: 1316 lines (+811/-155)
24 files modified
Makefile.am (+10/-6)
configure.ac (+2/-2)
data/Makefile.am (+6/-2)
data/musicstore-scope.service.in (+3/-0)
musicstore.scope (+4/-0)
src/Makefile.am (+48/-4)
src/album.vala (+4/-2)
src/banshee-collection.vala (+30/-14)
src/banshee-filter-parser-decade.vala (+54/-0)
src/banshee-filter-parser-genre.vala (+58/-0)
src/banshee-filter-parser.vala (+3/-84)
src/banshee-scope.vala (+8/-13)
src/daemon.vala (+1/-1)
src/filter-parser-decade.vala (+38/-0)
src/filter-parser-genre.vala (+54/-0)
src/filter-parser.vala (+36/-0)
src/musicstore-collection.vala (+118/-0)
src/musicstore-daemon.vala (+101/-0)
src/musicstore-filter-parser-decade.vala (+53/-0)
src/musicstore-filter-parser-genre.vala (+38/-0)
src/musicstore-filter-parser.vala (+28/-0)
src/musicstore-scope.vala (+86/-0)
src/simple-scope.vala (+23/-23)
src/track.vala (+5/-4)
To merge this branch: bzr merge lp:~alexlauni/unity-lens-music/musicstore
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Mikkel Kamstrup Erlandsen (community) Needs Fixing
Review via email: mp+75398@code.launchpad.net

Description of the change

Implements a scope to search the music store for tracks and albums available for purchase. Reworks quite a bit of the original lens to avoid duplicated code between the two scopes. Leaves lots of room for more scopes to be added very easily using the framework provided.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

CODE:
Compiles almost without warnings froms gcc, which is a welcome feature compared to our other Vala projects! :-D

data/musicstore-scope.service.in, src/Makefile.am:
Can we prefix the musicstore-scope-daemon with unity-* like all the lens daemons? That makes process management so much easier.

Would it make sense to do a rename 's/musicstore/u1musicstore/' and 's/MusicStore/U1MusicStore/' in filenames and classes? Is it inconceivable to we'll ever add another music store?

774 +// if (cancellable != null) {
775 +// cancellable.cancel ();
776 +// cancellable = null;
777 +// }
778 +
779 + cancellable = new Cancellable ();

Delete these lines?^^

IN PRACTICE:
It appears that the entire music lens daemon becomes unresponsive until the musicstore scope daemon has replied - which blocks until it gets an answer from the u1 search service (which seems to be somewhat unreliable). I am trying to figure out if this is a bug in libunity or because it's an issue with the musicstore/music-lens.

review: Needs Fixing
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Just for note: Testing this unveils bugs in libunity as I go along. I am pushing these fixes to lp:~kamstrup/libunity/fixes-2011-09-15

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

It also seems that both the main banshee scope as well as the u1 scope is searched when performing a global search - although the results does not show in the global result set.

I just took this by John on IRC. The intended behavior is that the results from your local collection are added to the global results, while the u1 store is not searched in the global dash search.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

I just rolled libunity-4.0.4 that contains some fixes very relevant for the u1 scope. Namely that each scope (remote or not) is run async when we search it. This means that the IN PRACTICE note in comment #1 no longer appears to be a problem.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

@Alex: I put up lp:~kamstrup/unity-lens-music/u1-tweaks for merging into this branch.

Revision history for this message
Neil J. Patel (njpatel) wrote :

Updated the daemon name to unity-musicstore-daemon, removed the commented out code. I left the naming of the classes as this is the only one we'll ship with the Lens, so no need to worry about classified naming. Merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2011-08-09 17:28:19 +0000
3+++ Makefile.am 2011-09-14 18:37:04 +0000
4@@ -1,12 +1,15 @@
5 SUBDIRS = src data po
6
7 #
8-# Install the music.lens file
9+# Install the music.lens and musicstore.scope files
10 #
11 lens_in_files = music.lens.in
12 lensdir = $(LENSESDIR)/music
13 lens_DATA = $(lens_in_files:.lens.in=.lens)
14
15+scopedir = $(lensdir)
16+scope_DATA = musicstore.scope
17+
18 icondir = $(datadir)/unity/themes
19
20 @INTLTOOL_LENS_RULE@
21@@ -16,26 +19,27 @@
22 # ChangeLog file created at distcheck time
23 dist-hook:
24 @if test -d "$(srcdir)/.bzr"; \
25- then \
26- echo Creating ChangeLog && \
27+ then \
28+ echo Creating ChangeLog && \
29 ( cd "$(top_srcdir)" && \
30- echo '# Generated by Makefile. Do not edit.'; echo; \
31+ echo '# Generated by Makefile. Do not edit.'; echo; \
32 $(top_srcdir)/missing --run bzr log --gnu-changelog ) > ChangeLog.tmp \
33 && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \
34 || (rm -f ChangeLog.tmp; \
35 echo Failed to generate ChangeLog >&2 ); \
36 else \
37- echo Failed to generate ChangeLog: not a branch >&2; \
38+ echo Failed to generate ChangeLog: not a branch >&2; \
39 fi
40
41 EXTRA_DIST = \
42 autogen.sh \
43 $(lens_in_music) \
44+ $(scope_DATA) \
45 AUTHORS \
46 COPYING \
47 MAINTAINERS \
48 README
49
50 CLEANFILES = \
51- $(lens_DATA)
52+ $(lens_DATA)
53
54
55=== modified file 'configure.ac'
56--- configure.ac 2011-09-08 16:01:37 +0000
57+++ configure.ac 2011-09-14 18:37:04 +0000
58@@ -60,12 +60,12 @@
59 gobject-2.0 >= $GLIB_REQUIRED
60 gio-2.0 >= $GLIB_REQUIRED
61 gio-unix-2.0 >= $GLIB_REQUIRED
62- gee-1.0
63 dee-1.0 >= 0.5.16
64 sqlite3 >= 3.7.7
65+ gee-1.0
66+ json-glib-1.0
67 unity >= 4.0.2)
68
69-
70 AC_SUBST(LENS_DAEMON_CFLAGS)
71 AC_SUBST(LENS_DAEMON_LIBS)
72
73
74=== modified file 'data/Makefile.am'
75--- data/Makefile.am 2011-08-09 17:28:19 +0000
76+++ data/Makefile.am 2011-09-14 18:37:04 +0000
77@@ -1,5 +1,8 @@
78 dbus_servicesdir = $(DBUSSERVICEDIR)
79-service_in_files = unity-lens-music.service.in
80+service_in_files = \
81+ unity-lens-music.service.in \
82+ musicstore-scope.service.in
83+
84 dbus_services_DATA = $(service_in_files:.service.in=.service)
85
86 %.service: %.service.in
87@@ -9,4 +12,5 @@
88 $(service_in_files)
89
90 CLEANFILES = \
91- unity-lens-music.service
92+ unity-lens-music.service \
93+ musicstore-scope.service
94
95=== added file 'data/musicstore-scope.service.in'
96--- data/musicstore-scope.service.in 1970-01-01 00:00:00 +0000
97+++ data/musicstore-scope.service.in 2011-09-14 18:37:04 +0000
98@@ -0,0 +1,3 @@
99+[D-BUS Service]
100+Name=com.canonical.Unity.Scope.MusicStore
101+Exec=@libexecdir@/musicstore-scope-daemon
102
103=== added file 'musicstore.scope'
104--- musicstore.scope 1970-01-01 00:00:00 +0000
105+++ musicstore.scope 2011-09-14 18:37:04 +0000
106@@ -0,0 +1,4 @@
107+[Scope]
108+DBusName=com.canonical.Unity.Scope.MusicStore
109+DBusPath=/com/canonical/unity/scope/musicstore
110+
111
112=== modified file 'src/Makefile.am'
113--- src/Makefile.am 2011-09-08 17:22:43 +0000
114+++ src/Makefile.am 2011-09-14 18:37:04 +0000
115@@ -6,7 +6,8 @@
116 DATADIR = $(datadir)
117
118 libexec_PROGRAMS = \
119- unity-music-daemon
120+ unity-music-daemon \
121+ musicstore-scope-daemon
122
123 unity_music_daemon_CPPFLAGS = \
124 -DDATADIR=\"$(DATADIR)\" \
125@@ -36,10 +37,15 @@
126 unity_music_daemon_VALASOURCES = \
127 album.vala \
128 banshee-collection.vala \
129+ banshee-filter-parser.vala \
130+ banshee-filter-parser-decade.vala \
131+ banshee-filter-parser-genre.vala \
132 banshee-scope.vala \
133 config.vala \
134 daemon.vala \
135 filter-parser.vala \
136+ filter-parser-decade.vala \
137+ filter-parser-genre.vala \
138 genre.vala \
139 main.vala \
140 simple-scope.vala \
141@@ -50,21 +56,59 @@
142 $(unity_music_daemon_VALASOURCES:.vala=.c) \
143 $(NULL)
144
145-BUILT_SOURCES += unity_music_daemon.vala.stamp
146+musicstore_scope_daemon_CPPFLAGS = \
147+ $(unity_music_daemon_CPPFLAGS)
148+
149+musicstore_scope_daemon_VALAFLAGS = \
150+ --pkg json-glib-1.0 \
151+ $(unity_music_daemon_VALAFLAGS)
152+
153+musicstore_scope_daemon_LDADD = \
154+ $(unity_music_daemon_LDADD)
155+
156+musicstore_scope_daemon_VALASOURCES = \
157+ album.vala \
158+ config.vala \
159+ filter-parser.vala \
160+ filter-parser-decade.vala \
161+ filter-parser-genre.vala \
162+ genre.vala \
163+ musicstore-collection.vala \
164+ musicstore-daemon.vala \
165+ musicstore-filter-parser.vala \
166+ musicstore-filter-parser-decade.vala \
167+ musicstore-filter-parser-genre.vala \
168+ musicstore-scope.vala \
169+ simple-scope.vala \
170+ track.vala
171+
172+musicstore_scope_daemon_SOURCES = \
173+ $(musicstore_scope_daemon_VALASOURCES:.vala=.c) \
174+ $(NULL)
175+
176+BUILT_SOURCES += \
177+ unity_music_daemon.vala.stamp \
178+ musicstore_scope_daemon.vala.stamp
179+
180 EXTRA_DIST += \
181 unity_music_daemon.vala.stamp \
182+ musicstore_scope_daemon.vala.stamp \
183 $(unity_music_daemon_VALASOURCES) \
184+ $(musicstore_scope_daemon_VALASOURCES) \
185 $(NULL)
186
187-# Major hack alert: https://bugzilla.gnome.org/show_bug.cgi?id=621292
188-# Introduced because of our requirements for the GLIB_2_22 define. See above.
189 unity_music_daemon.vala.stamp: $(unity_music_daemon_VALASOURCES)
190 $(AM_V_GEN) $(VALAC) $(unity_music_daemon_VALAFLAGS) $^
191 touch unity_music_daemon.vala.stamp
192
193+musicstore_scope_daemon.vala.stamp: $(musicstore_scope_daemon_VALASOURCES)
194+ $(AM_V_GEN) $(VALAC) $(musicstore_scope_daemon_VALAFLAGS) $^
195+ touch musicstore_scope_daemon.vala.stamp
196+
197 CLEANFILES += \
198 *.stamp \
199 *.vapi \
200 $(unity_music_daemon_VALASOURCES:.vala=.c) \
201+ $(musicstore_scope_daemon_VALASOURCES:.vala=.c) \
202 $(NULL)
203
204
205=== modified file 'src/album.vala'
206--- src/album.vala 2011-09-02 16:46:11 +0000
207+++ src/album.vala 2011-09-14 18:37:04 +0000
208@@ -23,7 +23,9 @@
209
210 public class Album : GLib.Object
211 {
212- public string Title { get; set; }
213- public string Artist { get; set; }
214+ public string title { get; set; }
215+ public string artist { get; set; }
216+ public string uri { get; set; }
217+ public string artwork_path { get; set; }
218 }
219 }
220\ No newline at end of file
221
222=== modified file 'src/banshee-collection.vala'
223--- src/banshee-collection.vala 2011-09-12 16:30:54 +0000
224+++ src/banshee-collection.vala 2011-09-14 18:37:04 +0000
225@@ -107,20 +107,23 @@
226 artwork_path = "audio-x-generic";
227
228 Track track = new Track ();
229- track.Title = stmt.column_text (TRACK_TITLE);
230- track.Artist = stmt.column_text (ARTIST_NAME);
231- track.Uri = stmt.column_text (TRACK_URI);
232- track.MimeType = stmt.column_text (TRACK_MIMETYPE);
233+ track.title = stmt.column_text (TRACK_TITLE);
234+ track.artist = stmt.column_text (ARTIST_NAME);
235+ track.uri = stmt.column_text (TRACK_URI);
236+ track.mime_type = stmt.column_text (TRACK_MIMETYPE);
237+ track.artwork_path = artwork_path;
238
239 Album album = new Album ();
240- album.Title = stmt.column_text (ALBUM_TITLE);
241- album.Artist = stmt.column_text (ARTIST_NAME);
242-
243- results_model.append (track.Uri, artwork_path, 0, track.MimeType, track.Title, track.Artist);
244-
245- if (albums.add (album.Artist + album.Title)) {
246- results_model.append ("album://%s/%s".printf (album.Artist, album.Title), artwork_path, 1,
247- "audio-x-generic", album.Title, album.Artist);
248+ album.title = stmt.column_text (ALBUM_TITLE);
249+ album.artist = stmt.column_text (ARTIST_NAME);
250+ album.uri = "album://%s/%s".printf (album.artist, album.title);
251+ album.artwork_path = artwork_path;
252+
253+ results_model.append (track.uri, track.artwork_path, 0, track.mime_type, track.title, track.artist, track.uri);
254+
255+ if (albums.add (album.artist + album.title)) {
256+ // FIXME drag n drop uri should be the path to the album dir?
257+ results_model.append (album.uri, album.artwork_path, 1, "audio-x-generic", album.title, album.artist, null);
258 }
259
260 break;
261@@ -148,7 +151,7 @@
262 AND CoreAlbums.Title IS '%s'
263 AND CoreArtists.Name IS '%s'
264 AND CoreTracks.URI IS NOT NULL
265- ORDER BY CoreTracks.TrackNumber ASC".printf (album.Title, album.Artist);
266+ ORDER BY CoreTracks.TrackNumber ASC".printf (album.title, album.artist);
267
268 rc = execute_sql (sql, out stmt);
269
270@@ -184,7 +187,20 @@
271
272 foreach (FilterParser parser in filters)
273 {
274- string parsed = parser.parse ();
275+ BansheeFilterParser bparser;
276+ debug ("parsing for %s", parser.id);
277+ if (parser is GenreFilterParser)
278+ bparser = new BansheeGenreFilterParser (parser as GenreFilterParser);
279+ else if (parser is DecadeFilterParser)
280+ bparser = new BansheeDecadeFilterParser (parser as DecadeFilterParser);
281+ else
282+ {
283+ warning ("Recieved an unimplemented filter type");
284+ continue;
285+ }
286+
287+ string parsed = bparser.parse ();
288+ debug (parsed);
289
290 if (parsed == null || parsed == "")
291 continue;
292
293=== added file 'src/banshee-filter-parser-decade.vala'
294--- src/banshee-filter-parser-decade.vala 1970-01-01 00:00:00 +0000
295+++ src/banshee-filter-parser-decade.vala 2011-09-14 18:37:04 +0000
296@@ -0,0 +1,54 @@
297+/*
298+ * Copyright (C) 2011 Canonical Ltd
299+ *
300+ * This program is free software: you can redistribute it and/or modify
301+ * it under the terms of the GNU General Public License version 3 as
302+ * published by the Free Software Foundation.
303+ *
304+ * This program is distributed in the hope that it will be useful,
305+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
306+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
307+ * GNU General Public License for more details.
308+ *
309+ * You should have received a copy of the GNU General Public License
310+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
311+ *
312+ * Authored by Alex Launi <alex.launi@canonical.com>
313+ *
314+ */
315+
316+using GLib;
317+
318+namespace Unity.MusicLens {
319+
320+ public class BansheeDecadeFilterParser : BansheeFilterParser, DecadeFilterParser
321+ {
322+
323+ public BansheeDecadeFilterParser (DecadeFilterParser parser)
324+ {
325+ base (parser.filter as MultiRangeFilter);
326+ }
327+
328+ public override string parse ()
329+ {
330+ int start_year, end_year;
331+
332+ MultiRangeFilter range_filter = filter as MultiRangeFilter;
333+ FilterOption start = range_filter.get_first_active ();
334+ FilterOption end = range_filter.get_last_active ();
335+
336+ start_year = int.parse (start.id);
337+ end_year = int.parse (end.id);
338+
339+ // bump the end_year up to the beginning of the next range
340+ int end_index = range_filter.options.index (end);
341+ // if we have already selected the last option
342+ if (end_index == range_filter.options.length () - 1)
343+ end_year += 10;
344+ else
345+ end_year = int.parse (range_filter.options.nth_data (end_index + 1).id);
346+
347+ return "(CoreTracks.Year >= %d AND CoreTracks.Year < %d) ".printf (start_year, end_year);
348+ }
349+ }
350+}
351\ No newline at end of file
352
353=== added file 'src/banshee-filter-parser-genre.vala'
354--- src/banshee-filter-parser-genre.vala 1970-01-01 00:00:00 +0000
355+++ src/banshee-filter-parser-genre.vala 2011-09-14 18:37:04 +0000
356@@ -0,0 +1,58 @@
357+/*
358+ * Copyright (C) 2011 Canonical Ltd
359+ *
360+ * This program is free software: you can redistribute it and/or modify
361+ * it under the terms of the GNU General Public License version 3 as
362+ * published by the Free Software Foundation.
363+ *
364+ * This program is distributed in the hope that it will be useful,
365+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
366+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
367+ * GNU General Public License for more details.
368+ *
369+ * You should have received a copy of the GNU General Public License
370+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
371+ *
372+ * Authored by Alex Launi <alex.launi@canonical.com>
373+ *
374+ */
375+
376+using GLib;
377+
378+namespace Unity.MusicLens {
379+
380+ public class BansheeGenreFilterParser : BansheeFilterParser, GenreFilterParser
381+ {
382+
383+ public BansheeGenreFilterParser (GenreFilterParser parser)
384+ {
385+ base (parser.filter as CheckOptionFilter);
386+ }
387+
388+ public override string parse ()
389+ {
390+ StringBuilder builder = new StringBuilder ();
391+ List<FilterOption> genres = get_all_selected_genres ();
392+
393+ /* CoreTracks.Genre IS ___ OR CoreTracks.Genre IS ____ ... */
394+ foreach (FilterOption genre in genres)
395+ {
396+ string id = genre.id;
397+ if (genre.id == null)
398+ continue;
399+
400+ foreach (string alt in map.get_genre_synonyms (id))
401+ {
402+ builder.append ("(CoreTracks.Genre LIKE '%");
403+ builder.append (alt);
404+ builder.append ("""%' ESCAPE '\' AND CoreTracks.Genre IS NOT NULL) OR """);
405+ }
406+ }
407+ builder.truncate (builder.len - (" OR ".length));
408+ builder.prepend ("(");
409+ builder.append (")");
410+
411+ return builder.str;
412+ }
413+ }
414+}
415\ No newline at end of file
416
417=== renamed file 'src/filter-parser.vala' => 'src/banshee-filter-parser.vala'
418--- src/filter-parser.vala 2011-09-02 16:46:11 +0000
419+++ src/banshee-filter-parser.vala 2011-09-14 18:37:04 +0000
420@@ -1,4 +1,4 @@
421-/*
422+ /*
423 * Copyright (C) 2011 Canonical Ltd
424 *
425 * This program is free software: you can redistribute it and/or modify
426@@ -21,89 +21,8 @@
427
428 namespace Unity.MusicLens {
429
430- public class FilterParser : Object
431+ public interface BansheeFilterParser : FilterParser
432 {
433- private Genre map;
434- private Filter _filter;
435-
436- public string Id { get { return _filter.id; } }
437-
438- public FilterParser (Filter filter)
439- {
440- _filter = filter;
441- map = new Genre ();
442- }
443-
444- public string? parse ()
445- {
446- if (Id == "genre")
447- return parse_genre_filter ();
448- else if (Id == "decade")
449- return parse_decade_filter ();
450-
451- return null;
452- }
453-
454- /* returns a string like CoreTracks.Genre IS 'Rock' OR CoreTracks.Genre IS 'Metal'... */
455- public string? parse_genre_filter ()
456- {
457- StringBuilder builder = new StringBuilder ();
458- List<FilterOption> genres = get_all_selected_genre_options ((_filter as CheckOptionFilter).options);
459-
460- /* CoreTracks.Genre IS ___ OR CoreTracks.Genre IS ____ ... */
461- foreach (FilterOption genre in genres)
462- {
463- string id = genre.id;
464- if (genre.id == null)
465- continue;
466-
467- foreach (string alt in map.get_genre_synonyms (id))
468- {
469- builder.append ("(CoreTracks.Genre LIKE '%");
470- builder.append (alt);
471- builder.append ("""%' ESCAPE '\' AND CoreTracks.Genre IS NOT NULL) OR """);
472- }
473- }
474- builder.truncate (builder.len - (" OR ".length));
475- builder.prepend ("(");
476- builder.append (")");
477-
478- return builder.str;
479- }
480-
481- /* returns a string like CoreTracks.Year >= LOWER_BOUND AND CoreTracks.Year < UPPER_BOUND */
482- public string? parse_decade_filter ()
483- {
484- int start_year, end_year;
485-
486- MultiRangeFilter range_filter = _filter as MultiRangeFilter;
487- FilterOption start = range_filter.get_first_active ();
488- FilterOption end = range_filter.get_last_active ();
489-
490- start_year = int.parse (start.id);
491- end_year = int.parse (end.id);
492-
493- // bump the end_year up to the beginning of the next range
494- int end_index = range_filter.options.index (end);
495- // if we have already selected the last option
496- if (end_index == range_filter.options.length () - 1)
497- end_year += 10;
498- else
499- end_year = int.parse (range_filter.options.nth_data (end_index + 1).id);
500-
501- return "(CoreTracks.Year >= %d AND CoreTracks.Year < %d) ".printf (start_year, end_year);
502- }
503-
504- private List<FilterOption> get_all_selected_genre_options (List<FilterOption> options)
505- {
506- var active = new List<FilterOption> ();
507- foreach (FilterOption option in options)
508- {
509- if (option.active)
510- active.append (option);
511- }
512-
513- return active;
514- }
515+
516 }
517 }
518
519=== modified file 'src/banshee-scope.vala'
520--- src/banshee-scope.vala 2011-09-08 17:22:43 +0000
521+++ src/banshee-scope.vala 2011-09-14 18:37:04 +0000
522@@ -29,11 +29,11 @@
523 {
524 base ();
525
526- Scope = new Unity.Scope ("/com/canonical/unity/scope/banshee");
527- Scope.search_in_global = true;
528- Scope.activate_uri.connect (activate);
529+ scope = new Unity.Scope ("/com/canonical/unity/scope/banshee");
530+ scope.search_in_global = true;
531+ scope.activate_uri.connect (activate);
532
533- base.Initialize ();
534+ base.initialize ();
535
536 try {
537 collection = new BansheeCollection ();
538@@ -63,8 +63,8 @@
539 string title = split[3];
540
541 Album album = new Album ();
542- album.Artist = artist;
543- album.Title = title;
544+ album.artist = artist;
545+ album.title = title;
546 // FIXME there must be a better way..
547 foreach (string track in collection.get_track_uris (album))
548 exec += track;
549@@ -91,14 +91,9 @@
550 }
551
552 public override void perform_search (LensSearch? search, Dee.Model results_model,
553- List<Filter> filters, int max_results = -1)
554+ List<FilterParser> filters, int max_results = -1)
555 {
556- List<FilterParser> parsers = new List<FilterParser> ();
557- foreach (Filter f in filters) {
558- parsers.append (new FilterParser (f));
559- }
560-
561- collection.search (search, results_model, parsers, max_results);
562+ collection.search (search, results_model, filters, max_results);
563 }
564 }
565 }
566
567=== modified file 'src/daemon.vala'
568--- src/daemon.vala 2011-09-12 15:58:34 +0000
569+++ src/daemon.vala 2011-09-14 18:37:04 +0000
570@@ -41,7 +41,7 @@
571 populate_categories ();
572 populate_filters();
573
574- lens.add_local_scope (banshee.Scope);
575+ lens.add_local_scope (banshee.scope);
576
577 try {
578 lens.export ();
579
580=== added file 'src/filter-parser-decade.vala'
581--- src/filter-parser-decade.vala 1970-01-01 00:00:00 +0000
582+++ src/filter-parser-decade.vala 2011-09-14 18:37:04 +0000
583@@ -0,0 +1,38 @@
584+/*
585+ * Copyright (C) 2011 Canonical Ltd
586+ *
587+ * This program is free software: you can redistribute it and/or modify
588+ * it under the terms of the GNU General Public License version 3 as
589+ * published by the Free Software Foundation.
590+ *
591+ * This program is distributed in the hope that it will be useful,
592+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
593+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
594+ * GNU General Public License for more details.
595+ *
596+ * You should have received a copy of the GNU General Public License
597+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
598+ *
599+ * Authored by Alex Launi <alex.launi@canonical.com>
600+ *
601+ */
602+
603+using GLib;
604+
605+namespace Unity.MusicLens {
606+
607+ public class DecadeFilterParser : FilterParser
608+ {
609+ public DecadeFilterParser (MultiRangeFilter filter)
610+ {
611+ base (filter);
612+ }
613+
614+ public override string parse ()
615+ {
616+ return "";
617+ }
618+
619+ protected override string id { get { return "decade"; } }
620+ }
621+}
622\ No newline at end of file
623
624=== added file 'src/filter-parser-genre.vala'
625--- src/filter-parser-genre.vala 1970-01-01 00:00:00 +0000
626+++ src/filter-parser-genre.vala 2011-09-14 18:37:04 +0000
627@@ -0,0 +1,54 @@
628+/*
629+ * Copyright (C) 2011 Canonical Ltd
630+ *
631+ * This program is free software: you can redistribute it and/or modify
632+ * it under the terms of the GNU General Public License version 3 as
633+ * published by the Free Software Foundation.
634+ *
635+ * This program is distributed in the hope that it will be useful,
636+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
637+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
638+ * GNU General Public License for more details.
639+ *
640+ * You should have received a copy of the GNU General Public License
641+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
642+ *
643+ * Authored by Alex Launi <alex.launi@canonical.com>
644+ *
645+ */
646+
647+using GLib;
648+
649+namespace Unity.MusicLens {
650+
651+ public class GenreFilterParser : FilterParser
652+ {
653+ public GenreFilterParser (CheckOptionFilter filter)
654+ {
655+ base (filter);
656+ map = new Genre ();
657+ }
658+
659+ public override string parse ()
660+ {
661+ return "";
662+ }
663+
664+ protected override string id { get { return "genre"; } }
665+ protected Genre map { get; private set; }
666+
667+ protected List<FilterOption> get_all_selected_genres ()
668+ {
669+ unowned List<FilterOption> options = (filter as CheckOptionFilter).options;
670+ var active = new List<FilterOption> ();
671+
672+ foreach (FilterOption option in options)
673+ {
674+ if (option.active)
675+ active.append (option);
676+ }
677+
678+ return active;
679+ }
680+ }
681+}
682\ No newline at end of file
683
684=== added file 'src/filter-parser.vala'
685--- src/filter-parser.vala 1970-01-01 00:00:00 +0000
686+++ src/filter-parser.vala 2011-09-14 18:37:04 +0000
687@@ -0,0 +1,36 @@
688+/*
689+ * Copyright (C) 2011 Canonical Ltd
690+ *
691+ * This program is free software: you can redistribute it and/or modify
692+ * it under the terms of the GNU General Public License version 3 as
693+ * published by the Free Software Foundation.
694+ *
695+ * This program is distributed in the hope that it will be useful,
696+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
697+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
698+ * GNU General Public License for more details.
699+ *
700+ * You should have received a copy of the GNU General Public License
701+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
702+ *
703+ * Authored by Alex Launi <alex.launi@canonical.com>
704+ *
705+ */
706+
707+using GLib;
708+
709+namespace Unity.MusicLens {
710+
711+ public abstract class FilterParser : Object
712+ {
713+ public FilterParser (Filter filter)
714+ {
715+ this.filter = filter;
716+ }
717+
718+ public Filter filter { get; protected set; }
719+
720+ public abstract string id { get;}
721+ public abstract string parse ();
722+ }
723+}
724\ No newline at end of file
725
726=== added file 'src/musicstore-collection.vala'
727--- src/musicstore-collection.vala 1970-01-01 00:00:00 +0000
728+++ src/musicstore-collection.vala 2011-09-14 18:37:04 +0000
729@@ -0,0 +1,118 @@
730+/*
731+ * Copyright (C) 2011 Canonical Ltd
732+ *
733+ * This program is free software: you can redistribute it and/or modify
734+ * it under the terms of the GNU General Public License version 3 as
735+ * published by the Free Software Foundation.
736+ *
737+ * This program is distributed in the hope that it will be useful,
738+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
739+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
740+ * GNU General Public License for more details.
741+ *
742+ * You should have received a copy of the GNU General Public License
743+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
744+ *
745+ * Authored by Alex Launi <alex.launi@canonical.com>
746+ *
747+ */
748+
749+using GLib;
750+
751+namespace Unity.MusicLens {
752+
753+ public class MusicStoreCollection : Object
754+ {
755+
756+ private const string MUSICSTORE_BASE_URI = "https://staging.one.ubuntu.com/api/music_search/v1/";
757+
758+ private Cancellable? cancellable;
759+
760+ public MusicStoreCollection ()
761+ {
762+ }
763+
764+ public void search (LensSearch? search, Dee.Model results_model,
765+ List<FilterParser> filters, int max_results = -1) throws IOError
766+ {
767+ string? uri = build_search_uri (search.search_string, filters);
768+ if (uri == null)
769+ return;
770+
771+ debug ("searching %s", uri);
772+ File file = File.new_for_uri (uri);
773+
774+// if (cancellable != null) {
775+// cancellable.cancel ();
776+// cancellable = null;
777+// }
778+
779+ cancellable = new Cancellable ();
780+ read_musicstore_search_result_async.begin (file, results_model);
781+ }
782+
783+ private async void read_musicstore_search_result_async (File file, Dee.Model model)
784+ {
785+ try {
786+ var dis = new DataInputStream (file.read (cancellable));
787+ var parser = new Json.Parser ();
788+ parser.load_from_stream (dis, cancellable);
789+ var root_object = parser.get_root ().get_object ();
790+
791+ foreach (var r in root_object.get_array_member ("results").get_elements ()) {
792+ var result_obj = r.get_object ();
793+
794+ string type = result_obj.get_string_member ("type");
795+ if (type == "track") {
796+ Track track = new Track ();
797+ track.title = result_obj.get_string_member ("title");
798+ track.artist = result_obj.get_string_member ("artist");
799+ track.uri = result_obj.get_string_member ("details");
800+ track.artwork_path = result_obj.get_string_member ("image");
801+ track.mime_type = "audio-x-generic";
802+
803+ // FIXME drag n drop uri needs to be the u1ms:// link
804+ model.append (track.uri, track.artwork_path, 2, track.mime_type, track.title, track.artist, null);
805+
806+ } else if (type == "album") {
807+ Album album = new Album ();
808+ album.title = result_obj.get_string_member ("title");
809+ album.artist = result_obj.get_string_member ("artist");
810+ album.uri = result_obj.get_string_member ("details");
811+ album.artwork_path = result_obj.get_string_member ("image");
812+
813+ model.append (album.uri, album.artwork_path, 2, "audio-x-generic", album.title, album.artist, null);
814+ }
815+ }
816+ cancellable = null;
817+
818+ } catch (Error e) {
819+ stdout.printf (e.message);
820+ }
821+ }
822+
823+ private string build_search_uri (string query, List<FilterParser> filters)
824+ {
825+ MusicStoreFilterParser store_parser;
826+
827+ StringBuilder uri = new StringBuilder (MUSICSTORE_BASE_URI);
828+ uri.append ("search?q=");
829+ uri.append (Uri.escape_string (query, "", false));
830+
831+ foreach (FilterParser parser in filters) {
832+ if (parser is GenreFilterParser)
833+ store_parser = new MusicStoreGenreFilterParser (parser as GenreFilterParser);
834+ else if (parser is DecadeFilterParser)
835+ store_parser = new MusicStoreDecadeFilterParser (parser as DecadeFilterParser);
836+ else
837+ continue;
838+
839+ uri.append (store_parser.parse ());
840+ }
841+
842+ uri.append ("&geo_store=US");
843+
844+ return uri.str;
845+ }
846+ }
847+}
848\ No newline at end of file
849
850=== added file 'src/musicstore-daemon.vala'
851--- src/musicstore-daemon.vala 1970-01-01 00:00:00 +0000
852+++ src/musicstore-daemon.vala 2011-09-14 18:37:04 +0000
853@@ -0,0 +1,101 @@
854+/*
855+ * Copyright (C) 2011 Canonical Ltd
856+ *
857+ * This program is free software: you can redistribute it and/or modify
858+ * it under the terms of the GNU General Public License version 3 as
859+ * published by the Free Software Foundation.
860+ *
861+ * This program is distributed in the hope that it will be useful,
862+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
863+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
864+ * GNU General Public License for more details.
865+ *
866+ * You should have received a copy of the GNU General Public License
867+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
868+ *
869+ * Authored by Alex Launi <alex.launi@canonical.com>
870+ *
871+ */
872+
873+using GLib;
874+using Config;
875+
876+namespace Unity.MusicLens {
877+
878+ static Application? app = null;
879+ static MusicStoreScopeProxy? daemon = null;
880+
881+ /* Check if a given well known DBus is owned.
882+ * WARNING: This does sync IO! */
883+ public static bool dbus_name_has_owner (string name)
884+ {
885+ try {
886+ bool has_owner;
887+ DBusConnection bus = Bus.get_sync (BusType.SESSION);
888+ Variant result = bus.call_sync ("org.freedesktop.DBus",
889+ "/org/freedesktop/dbus",
890+ "org.freedesktop.DBus",
891+ "NameHasOwner",
892+ new Variant ("(s)", name),
893+ new VariantType ("(b)"),
894+ DBusCallFlags.NO_AUTO_START,
895+ -1);
896+ result.get ("(b)", out has_owner);
897+ return has_owner;
898+ } catch (Error e) {
899+ warning ("Unable to decide whether '%s' is running: %s", name, e.message);
900+ }
901+
902+ return false;
903+ }
904+
905+ public static int main (string[] args)
906+ {
907+ /* Sort up locale to get translations but also sorting and
908+ * punctuation right */
909+ GLib.Intl.textdomain (Config.PACKAGE);
910+ GLib.Intl.bindtextdomain (Config.PACKAGE, Config.LOCALEDIR);
911+ GLib.Intl.bind_textdomain_codeset (Config.PACKAGE, "UTF-8");
912+ GLib.Intl.setlocale(GLib.LocaleCategory.ALL, "");
913+
914+ /* Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=640714
915+ * GApplication.register() call owns our DBus name in a sync manner
916+ * making it race against GDBus' worker thread to export our
917+ * objects on the bus before/after owning our name and receiving
918+ * method calls on our objects (which may not yet be up!)*/
919+ if (dbus_name_has_owner ("com.canonical.Unity.Scope.MusicStore"))
920+ {
921+ print ("Another instance of the UbuntuOne Music Daemon " +
922+ "already appears to be running.\nBailing out.\n");
923+ return 2;
924+ }
925+
926+ /* Now register our DBus objects *before* acquiring the name!
927+ * See above for reasons */
928+ daemon = new MusicStoreScopeProxy ();
929+
930+ /* Use GApplication directly for single instance app functionality */
931+ app = new Application ("com.canonical.Unity.Scope.MusicStore",
932+ ApplicationFlags.IS_SERVICE);
933+ try {
934+ app.register ();
935+ } catch (Error e) {
936+ /* FIXME: We get this error if another daemon is already running,
937+ * but it uses a generic error so we can't detect this reliably... */
938+ print ("Failed to start music daemon: %s\n", e.message);
939+ return 1;
940+ }
941+
942+ if (app.get_is_remote ())
943+ {
944+ print ("Another instance of the Unity Music Daemon " +
945+ "already appears to be running.\nBailing out.\n");
946+ return 2;
947+ }
948+
949+ /* Hold()ing the app makes sure the GApplication doesn't exit */
950+ app.hold();
951+ return app.run ();
952+ }
953+
954+} /* namespace */
955\ No newline at end of file
956
957=== added file 'src/musicstore-filter-parser-decade.vala'
958--- src/musicstore-filter-parser-decade.vala 1970-01-01 00:00:00 +0000
959+++ src/musicstore-filter-parser-decade.vala 2011-09-14 18:37:04 +0000
960@@ -0,0 +1,53 @@
961+/*
962+ * Copyright (C) 2011 Canonical Ltd
963+ *
964+ * This program is free software: you can redistribute it and/or modify
965+ * it under the terms of the GNU General Public License version 3 as
966+ * published by the Free Software Foundation.
967+ *
968+ * This program is distributed in the hope that it will be useful,
969+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
970+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
971+ * GNU General Public License for more details.
972+ *
973+ * You should have received a copy of the GNU General Public License
974+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
975+ *
976+ * Authored by Alex Launi <alex.launi@canonical.com>
977+ *
978+ */
979+
980+using GLib;
981+
982+namespace Unity.MusicLens {
983+
984+ public class MusicStoreDecadeFilterParser : DecadeFilterParser, MusicStoreFilterParser
985+ {
986+
987+ public MusicStoreDecadeFilterParser (DecadeFilterParser parser)
988+ {
989+ base (parser.filter as MultiRangeFilter);
990+ }
991+
992+ public override string parse ()
993+ {
994+ StringBuilder builder = new StringBuilder ("&decade=");
995+ MultiRangeFilter range_filter = filter as MultiRangeFilter;
996+ string start = range_filter.get_first_active ().id;
997+ string end = range_filter.get_first_active ().id;
998+
999+ int start_year = int.parse (start);
1000+ int end_year = int.parse (end);
1001+
1002+ for (; start_year <= end_year; start_year += 10)
1003+ {
1004+ builder.append_printf ("%d", start_year);
1005+ }
1006+
1007+ // chop off the last ,
1008+ builder.truncate (builder.len - 1);
1009+
1010+ return builder.str;
1011+ }
1012+ }
1013+}
1014\ No newline at end of file
1015
1016=== added file 'src/musicstore-filter-parser-genre.vala'
1017--- src/musicstore-filter-parser-genre.vala 1970-01-01 00:00:00 +0000
1018+++ src/musicstore-filter-parser-genre.vala 2011-09-14 18:37:04 +0000
1019@@ -0,0 +1,38 @@
1020+/*
1021+ * Copyright (C) 2011 Canonical Ltd
1022+ *
1023+ * This program is free software: you can redistribute it and/or modify
1024+ * it under the terms of the GNU General Public License version 3 as
1025+ * published by the Free Software Foundation.
1026+ *
1027+ * This program is distributed in the hope that it will be useful,
1028+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1029+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1030+ * GNU General Public License for more details.
1031+ *
1032+ * You should have received a copy of the GNU General Public License
1033+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1034+ *
1035+ * Authored by Alex Launi <alex.launi@canonical.com>
1036+ *
1037+ */
1038+
1039+using GLib;
1040+
1041+namespace Unity.MusicLens {
1042+
1043+ public class MusicStoreGenreFilterParser : GenreFilterParser, MusicStoreFilterParser
1044+ {
1045+
1046+ public MusicStoreGenreFilterParser (GenreFilterParser parser)
1047+ {
1048+ base (parser.filter as CheckOptionFilter);
1049+ }
1050+
1051+ /*
1052+ public override string parse ()
1053+ {
1054+ }
1055+ */
1056+ }
1057+}
1058\ No newline at end of file
1059
1060=== added file 'src/musicstore-filter-parser.vala'
1061--- src/musicstore-filter-parser.vala 1970-01-01 00:00:00 +0000
1062+++ src/musicstore-filter-parser.vala 2011-09-14 18:37:04 +0000
1063@@ -0,0 +1,28 @@
1064+ /*
1065+ * Copyright (C) 2011 Canonical Ltd
1066+ *
1067+ * This program is free software: you can redistribute it and/or modify
1068+ * it under the terms of the GNU General Public License version 3 as
1069+ * published by the Free Software Foundation.
1070+ *
1071+ * This program is distributed in the hope that it will be useful,
1072+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1073+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1074+ * GNU General Public License for more details.
1075+ *
1076+ * You should have received a copy of the GNU General Public License
1077+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1078+ *
1079+ * Authored by Alex Launi <alex.launi@canonical.com>
1080+ *
1081+ */
1082+
1083+using GLib;
1084+
1085+namespace Unity.MusicLens {
1086+
1087+ public interface MusicStoreFilterParser : FilterParser
1088+ {
1089+
1090+ }
1091+}
1092
1093=== added file 'src/musicstore-scope.vala'
1094--- src/musicstore-scope.vala 1970-01-01 00:00:00 +0000
1095+++ src/musicstore-scope.vala 2011-09-14 18:37:04 +0000
1096@@ -0,0 +1,86 @@
1097+/*
1098+ * Copyright (C) 2011 Canonical Ltd
1099+ *
1100+ * This program is free software: you can redistribute it and/or modify
1101+ * it under the terms of the GNU General Public License version 3 as
1102+ * published by the Free Software Foundation.
1103+ *
1104+ * This program is distributed in the hope that it will be useful,
1105+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1106+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1107+ * GNU General Public License for more details.
1108+ *
1109+ * You should have received a copy of the GNU General Public License
1110+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1111+ *
1112+ * Authored by Alex Launi <alex.launi@canonical.com>
1113+ *
1114+ */
1115+
1116+using GLib;
1117+
1118+namespace Unity.MusicLens {
1119+
1120+ public class MusicStoreScopeProxy : SimpleScope
1121+ {
1122+ private MusicStoreCollection collection;
1123+
1124+ public MusicStoreScopeProxy ()
1125+ {
1126+ base ();
1127+
1128+ scope = new Unity.Scope ("/com/canonical/unity/scope/musicstore");
1129+ scope.search_in_global = true;
1130+ scope.activate_uri.connect (activate);
1131+
1132+ base.initialize ();
1133+
1134+ collection = new MusicStoreCollection ();
1135+
1136+ try {
1137+ scope.export ();
1138+ } catch (GLib.IOError e) {
1139+ stdout.printf (e.message);
1140+ }
1141+ }
1142+
1143+ protected override int num_results_without_search { get { return 100; } }
1144+ protected override int num_results_global_search { get { return 20; } }
1145+ protected override int num_results_lens_search { get { return 50; } }
1146+
1147+ public Unity.ActivationResponse activate (string uri)
1148+ {
1149+ /* launch the music store streaming client or the webstore or whatevz */
1150+ File file = File.new_for_uri (uri);
1151+ get_and_open_purchase_url.begin (file);
1152+ return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);
1153+ }
1154+
1155+ public override void perform_search (LensSearch? search, Dee.Model results_model,
1156+ List<FilterParser> filters, int max_results = -1)
1157+ {
1158+ try {
1159+ collection.search (search, results_model, filters, max_results);
1160+ } catch (IOError e) {
1161+ stdout.printf (e.message);
1162+ }
1163+ }
1164+
1165+ private async void get_and_open_purchase_url (File file)
1166+ {
1167+ string url = "UNASSIGNED";
1168+
1169+ try {
1170+ var dis = new DataInputStream (file.read ());
1171+ var parser = new Json.Parser ();
1172+ parser.load_from_stream (dis, new Cancellable ());
1173+ var root_object = parser.get_root ().get_object ();
1174+
1175+ url = root_object.get_string_member ("web_purchase_url");
1176+ AppInfo.launch_default_for_uri (url, null);
1177+ } catch (GLib.Error e) {
1178+ warning ("Failed to open url %s. %s", url, e.message);
1179+ }
1180+ }
1181+ }
1182+}
1183\ No newline at end of file
1184
1185=== modified file 'src/simple-scope.vala'
1186--- src/simple-scope.vala 2011-09-08 17:22:43 +0000
1187+++ src/simple-scope.vala 2011-09-14 18:37:04 +0000
1188@@ -23,13 +23,13 @@
1189 {
1190 public abstract class SimpleScope : Object
1191 {
1192- public Unity.Scope Scope { get; protected set; }
1193+ public Unity.Scope scope { get; protected set; }
1194
1195 protected abstract int num_results_without_search { get; }
1196 protected abstract int num_results_global_search { get; }
1197 protected abstract int num_results_lens_search { get; }
1198
1199- protected abstract void perform_search (LensSearch? search, Dee.Model results_model, List<Filter> filters, int max_results = -1);
1200+ protected abstract void perform_search (LensSearch? search, Dee.Model results_model, List<FilterParser> filters, int max_results = -1);
1201
1202 protected bool is_dirty;
1203 protected LensSearch? previous_search;
1204@@ -40,23 +40,23 @@
1205 previous_search = null;
1206 }
1207
1208- protected void Initialize ()
1209+ protected void initialize ()
1210 {
1211 /* Listen for filter changes */
1212- Scope.filters_changed.connect(
1213+ scope.filters_changed.connect(
1214 () => {
1215- if (Scope.active_search != null)
1216+ if (scope.active_search != null)
1217 {
1218 is_dirty = true;
1219- Scope.notify_property ("active-search");
1220+ scope.notify_property ("active-search");
1221 }
1222 }
1223 );
1224
1225 /* Listen for changes to the lens search entry */
1226- Scope.notify["active-search"].connect (
1227+ scope.notify["active-search"].connect (
1228 (obj, pspec) => {
1229- var search = Scope.active_search;
1230+ var search = scope.active_search;
1231 if (!(is_dirty || search_has_really_changed (previous_search, search)))
1232 return;
1233 is_dirty = false;
1234@@ -66,9 +66,9 @@
1235 );
1236
1237 /* Listen for changes to the global search */
1238- Scope.notify["active-global-search"].connect (
1239+ scope.notify["active-global-search"].connect (
1240 (obj, pspec) => {
1241- var search = Scope.active_global_search;
1242+ var search = scope.active_global_search;
1243
1244 if (search_is_invalid (search))
1245 return;
1246@@ -96,7 +96,7 @@
1247 */
1248 private async void update_global_search_async (LensSearch search)
1249 {
1250- var results_model = Scope.global_results_model;
1251+ var results_model = scope.global_results_model;
1252
1253 if (search_is_invalid (search))
1254 {
1255@@ -121,21 +121,21 @@
1256
1257 private async void perform_search_async (LensSearch search, int max_results)
1258 {
1259- var results_model = Scope.results_model;
1260+ var results_model = scope.results_model;
1261
1262 /* Prevent concurrent searches and concurrent updates of our models,
1263 * by preventing any notify signals from propagating to us.
1264 * Important: Remeber to thaw the notifys again! */
1265- List<Filter> filters = new List<Filter> ();
1266- Filter filter = Scope.get_filter ("genre");
1267- if (filter.filtering)
1268- filters.append (filter);
1269-
1270- filter = Scope.get_filter ("decade");
1271- if (filter.filtering)
1272- filters.append (filter);
1273-
1274- Scope.freeze_notify ();
1275+ List<FilterParser> filters = new List<FilterParser> ();
1276+ Filter filter = scope.get_filter ("genre");
1277+ if (filter.filtering)
1278+ filters.append (new GenreFilterParser (filter as CheckOptionFilter));
1279+
1280+ filter = scope.get_filter ("decade");
1281+ if (filter.filtering)
1282+ filters.append (new DecadeFilterParser (filter as MultiRangeFilter));
1283+
1284+ scope.freeze_notify ();
1285
1286 results_model.clear ();
1287 perform_search (search, results_model, filters, max_results);
1288@@ -145,7 +145,7 @@
1289 * changing the model even before we had flushed out current changes
1290 */
1291 Idle.add (() => {
1292- Scope.thaw_notify ();
1293+ scope.thaw_notify ();
1294 return false;
1295 });
1296
1297
1298=== modified file 'src/track.vala'
1299--- src/track.vala 2011-09-02 16:46:11 +0000
1300+++ src/track.vala 2011-09-14 18:37:04 +0000
1301@@ -21,9 +21,10 @@
1302
1303 public class Track : GLib.Object
1304 {
1305- public string Title { get; set; }
1306- public string Uri { get; set; }
1307- public string Artist { get; set; }
1308- public string MimeType { get; set; }
1309+ public string title { get; set; }
1310+ public string uri { get; set; }
1311+ public string artist { get; set; }
1312+ public string mime_type { get; set; }
1313+ public string artwork_path { get; set; }
1314 }
1315 }
1316\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: