diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/Makefile.am unity-lens-music-6.8.1daily13.03.04/Makefile.am --- unity-lens-music-7.4-6.8.1daily13.03.04/Makefile.am 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/Makefile.am 2013-04-02 19:00:11.000000000 +0000 @@ -3,16 +3,16 @@ # # Install the music.lens and musicstore.scope files # -scope_in_files = \ - music-banshee.scope.in \ - music-rhythmbox.scope.in \ - musicstore.scope.in -scopedir = $(SCOPESDIR)/music -scope_DATA = $(scope_in_files:.scope.in=.scope) +lens_in_files = music.lens.in +lensdir = $(LENSESDIR)/music +lens_DATA = $(lens_in_files:.lens.in=.lens) + +scopedir = $(lensdir) +scope_DATA = musicstore.scope icondir = $(datadir)/unity/themes -@INTLTOOL_SCOPE_RULE@ +@INTLTOOL_LENS_RULE@ DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall @@ -33,13 +33,14 @@ EXTRA_DIST = \ autogen.sh \ - $(scope_in_files) \ + $(lens_in_music) \ + $(scope_DATA) \ AUTHORS \ COPYING \ MAINTAINERS \ README CLEANFILES = \ - $(scope_DATA) + $(lens_DATA) include $(top_srcdir)/Makefile.am.coverage diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/configure.ac unity-lens-music-6.8.1daily13.03.04/configure.ac --- unity-lens-music-7.4-6.8.1daily13.03.04/configure.ac 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/configure.ac 2013-04-02 19:00:11.000000000 +0000 @@ -48,8 +48,8 @@ ###################################################### # intltool rule for generating translated .lens file ###################################################### -INTLTOOL_SCOPE_RULE='%.scope: %.scope.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@' -AC_SUBST(INTLTOOL_SCOPE_RULE) +INTLTOOL_LENS_RULE='%.lens: %.lens.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@' +AC_SUBST(INTLTOOL_LENS_RULE) ########################### # gcov coverage reporting @@ -66,7 +66,7 @@ # Check for module and library dependancies ##################################################### GLIB_REQUIRED=2.32 -PKG_CHECK_MODULES(SCOPE_DAEMON, +PKG_CHECK_MODULES(LENS_DAEMON, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED @@ -90,8 +90,8 @@ gstreamer-pbutils-1.0 ) -AC_SUBST(SCOPE_DAEMON_CFLAGS) -AC_SUBST(SCOPE_DAEMON_LIBS) +AC_SUBST(LENS_DAEMON_CFLAGS) +AC_SUBST(LENS_DAEMON_LIBS) AC_SUBST(PREVIEW_PLAYER_CFLAGS) AC_SUBST(PREVIEW_PLAYER_LIBS) @@ -127,23 +127,21 @@ AC_SUBST(DBUSSERVICEDIR) ##################################################### -# Look for correct Scopes dir +# Look for correct Lenses dir ##################################################### if test "x$with_localinstall" = "xyes"; then - SCOPESDIR="${datadir}/unity/scopes" + LENSESDIR="${datadir}/unity/lenses" else - SCOPESDIR=`$PKG_CONFIG --variable=scopesdir unity` + LENSESDIR=`$PKG_CONFIG --variable=lensesdir unity` fi -AC_SUBST(SCOPESDIR) +AC_SUBST(LENSESDIR) ##################################################### # Create the Makefiles ##################################################### AC_CONFIG_FILES([ Makefile - music-banshee.scope.in - music-rhythmbox.scope.in - musicstore.scope.in + music.lens.in data/Makefile src/Makefile src/config.vala @@ -168,7 +166,7 @@ Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS Extra ValaFlags : ${CPPFLAGS} $MAINTAINER_VALAFLAGS - Scopes Directory: ${SCOPESDIR} + Lenses Directory: ${LENSESDIR} Testing Coverage reporting : ${use_gcov} diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/data/Makefile.am unity-lens-music-6.8.1daily13.03.04/data/Makefile.am --- unity-lens-music-7.4-6.8.1daily13.03.04/data/Makefile.am 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/data/Makefile.am 2013-04-02 19:00:11.000000000 +0000 @@ -1,6 +1,6 @@ dbus_servicesdir = $(DBUSSERVICEDIR) service_in_files = \ - unity-scope-music.service.in \ + unity-lens-music.service.in \ musicstore-scope.service.in \ music-preview-player.service.in @@ -13,6 +13,6 @@ $(service_in_files) CLEANFILES = \ - unity-scope-music.service \ + unity-lens-music.service \ musicstore-scope.service \ music-preview-player.service diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/data/unity-lens-music.service.in unity-lens-music-6.8.1daily13.03.04/data/unity-lens-music.service.in --- unity-lens-music-7.4-6.8.1daily13.03.04/data/unity-lens-music.service.in 1970-01-01 00:00:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/data/unity-lens-music.service.in 2013-04-02 19:00:11.000000000 +0000 @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=com.canonical.Unity.Lens.Music +Exec=@pkglibexecdir@/unity-music-daemon diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/data/unity-scope-music.service.in unity-lens-music-6.8.1daily13.03.04/data/unity-scope-music.service.in --- unity-lens-music-7.4-6.8.1daily13.03.04/data/unity-scope-music.service.in 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/data/unity-scope-music.service.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=com.canonical.Unity.Scope.Music -Exec=@pkglibexecdir@/unity-music-daemon diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/debian/bzr-builder.manifest unity-lens-music-6.8.1daily13.03.04/debian/bzr-builder.manifest --- unity-lens-music-7.4-6.8.1daily13.03.04/debian/bzr-builder.manifest 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/debian/bzr-builder.manifest 2013-04-02 19:00:12.000000000 +0000 @@ -1,3 +1,2 @@ -# bzr-builder format 0.3 deb-version 7.4-{debupstream}-r132 -lp:unity-lens-music revid:tarmac-20130304133221-rmela99pxfwa33l8 -merge purchase lp:~alecu/unity-lens-music/musicstore-purchase revid:alecu@canonical.com-20130321025900-siu5yylbvysadp10 +# bzr-builder format 0.3 deb-version {debupstream}-0ubuntu0~135 +lp:~mandel/unity-lens-music/musicstore-purchase revid:manuel@canonical.com-20130402105033-ecl82ipkhn2rxagy diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/debian/changelog unity-lens-music-6.8.1daily13.03.04/debian/changelog --- unity-lens-music-7.4-6.8.1daily13.03.04/debian/changelog 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/debian/changelog 2013-04-02 19:00:12.000000000 +0000 @@ -1,17 +1,11 @@ -unity-lens-music (7.4-6.8.1daily13.03.04-r132~quantal1) quantal; urgency=low +unity-lens-music (6.8.1daily13.03.04-0ubuntu0~135~quantal1) quantal; urgency=low * Auto build. - -- Diego Sarmentero Thu, 21 Mar 2013 13:54:00 +0000 + -- Michael Terry Tue, 02 Apr 2013 19:00:12 +0000 unity-lens-music (6.8.1daily13.03.04-0ubuntu3) UNRELEASED; urgency=low - [ Didier Roche ] - * debian/control: - - bump build-deps to new libunity - * debian/*install: - - installing/renaming files - [ Alejandro J. Cura ] * debian/control: - added libnotify-dev build dependency diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/debian/control unity-lens-music-6.8.1daily13.03.04/debian/control --- unity-lens-music-7.4-6.8.1daily13.03.04/debian/control 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/debian/control 2013-04-02 19:00:11.000000000 +0000 @@ -16,7 +16,7 @@ liboauth-dev, libdee-dev (>= 1.0.7), libsqlite3-dev (>= 3.7.7), - libunity-dev (>= 6.91), + libunity-dev (>= 6.9), libtdb-dev (>= 1.2.6), libgstreamer1.0-dev, libgstreamer-plugins-base1.0-dev diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/debian/unity-lens-music.install unity-lens-music-6.8.1daily13.03.04/debian/unity-lens-music.install --- unity-lens-music-7.4-6.8.1daily13.03.04/debian/unity-lens-music.install 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/debian/unity-lens-music.install 2013-04-02 19:00:11.000000000 +0000 @@ -1,6 +1,5 @@ usr/lib/*/unity-lens-music/unity-music-daemon usr/lib/*/unity-lens-music/music-preview-player -usr/share/dbus-1/services/unity-scope-music.service +usr/share/dbus-1/services/unity-lens-music.service usr/share/dbus-1/services/music-preview-player.service -usr/share/unity/scopes/music/music-banshee.scope -usr/share/unity/scopes/music/music-rhythmbox.scope +usr/share/unity/lenses/music/music.lens diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/debian/unity-scope-musicstores.install unity-lens-music-6.8.1daily13.03.04/debian/unity-scope-musicstores.install --- unity-lens-music-7.4-6.8.1daily13.03.04/debian/unity-scope-musicstores.install 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/debian/unity-scope-musicstores.install 2013-04-02 19:00:11.000000000 +0000 @@ -1,3 +1,3 @@ usr/lib/*/unity-lens-music/unity-musicstore-daemon usr/share/dbus-1/services/musicstore-scope.service -usr/share/unity/scopes/music/musicstore.scope +usr/share/unity/lenses/music/musicstore.scope diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/music-banshee.scope.in.in unity-lens-music-6.8.1daily13.03.04/music-banshee.scope.in.in --- unity-lens-music-7.4-6.8.1daily13.03.04/music-banshee.scope.in.in 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/music-banshee.scope.in.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -[Scope] -DBusName=com.canonical.Unity.Scope.Music -DBusPath=/com/canonical/unity/scope/banshee -Icon=@prefix@/share/unity/6/lens-nav-music.svg -_Name=Music (Banshee) -_Description=Find artists, albums, and your favorite tracks -_SearchHint=Search Music Collection -Shortcut=m -Type=music - -[Desktop Entry] -X-Ubuntu-Gettext-Domain=unity-lens-music - diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/music-rhythmbox.scope.in.in unity-lens-music-6.8.1daily13.03.04/music-rhythmbox.scope.in.in --- unity-lens-music-7.4-6.8.1daily13.03.04/music-rhythmbox.scope.in.in 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/music-rhythmbox.scope.in.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -[Scope] -DBusName=com.canonical.Unity.Scope.Music -DBusPath=/com/canonical/unity/scope/rhythmbox -Icon=@prefix@/share/unity/6/lens-nav-music.svg -_Name=Music (Rhythmbox) -_Description=Find artists, albums, and your favorite tracks -_SearchHint=Search Music Collection -Shortcut=m -Type=music - -[Desktop Entry] -X-Ubuntu-Gettext-Domain=unity-lens-music - diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/music.lens.in.in unity-lens-music-6.8.1daily13.03.04/music.lens.in.in --- unity-lens-music-7.4-6.8.1daily13.03.04/music.lens.in.in 1970-01-01 00:00:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/music.lens.in.in 2013-04-02 19:00:11.000000000 +0000 @@ -0,0 +1,12 @@ +[Lens] +DBusName=com.canonical.Unity.Lens.Music +DBusPath=/com/canonical/unity/lens/music +Icon=@prefix@/share/unity/6/lens-nav-music.svg +_Name=Music +_Description=Find artists, albums, and your favorite tracks +_SearchHint=Search Music Collection +Shortcut=m + +[Desktop Entry] +X-Ubuntu-Gettext-Domain=unity-lens-music + diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/musicstore.scope unity-lens-music-6.8.1daily13.03.04/musicstore.scope --- unity-lens-music-7.4-6.8.1daily13.03.04/musicstore.scope 1970-01-01 00:00:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/musicstore.scope 2013-04-02 19:00:11.000000000 +0000 @@ -0,0 +1,4 @@ +[Scope] +DBusName=com.canonical.Unity.Scope.MusicStore +DBusPath=/com/canonical/unity/scope/musicstore + diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/musicstore.scope.in.in unity-lens-music-6.8.1daily13.03.04/musicstore.scope.in.in --- unity-lens-music-7.4-6.8.1daily13.03.04/musicstore.scope.in.in 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/musicstore.scope.in.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -[Scope] -DBusName=com.canonical.Unity.Scope.MusicStore -DBusPath=/com/canonical/unity/scope/musicstore -Icon=@prefix@/share/unity/6/lens-nav-music.svg -_Name=Music Store -_Description=Find artists, albums, and your favorite tracks -_SearchHint=Search Music Store -Shortcut=m -Type=music - -[Desktop Entry] -X-Ubuntu-Gettext-Domain=unity-lens-music diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/po/POTFILES.in unity-lens-music-6.8.1daily13.03.04/po/POTFILES.in --- unity-lens-music-7.4-6.8.1daily13.03.04/po/POTFILES.in 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/po/POTFILES.in 2013-04-02 19:00:11.000000000 +0000 @@ -5,7 +5,5 @@ src/rhythmbox-scope.vala src/simple-scope.vala src/musicstore-scope.vala -[type: gettext/ini]music-banshee.scope.in.in -[type: gettext/ini]music-rhythmbox.scope.in.in -[type: gettext/ini]musicstore.scope.in.in +[type: gettext/ini]music.lens.in.in diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/Makefile.am unity-lens-music-6.8.1daily13.03.04/src/Makefile.am --- unity-lens-music-7.4-6.8.1daily13.03.04/src/Makefile.am 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/Makefile.am 2013-04-02 19:00:11.000000000 +0000 @@ -18,7 +18,7 @@ -DPKGDATADIR=\"$(PKGDATADIR)\" \ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ -DG_LOG_DOMAIN=\"unity-music-daemon\" \ - $(SCOPE_DAEMON_CFLAGS) \ + $(LENS_DAEMON_CFLAGS) \ $(MAINTAINER_CFLAGS) \ -I$(srcdir) \ -g @@ -39,7 +39,7 @@ $(MAINTAINER_VALAFLAGS) unity_music_daemon_LDADD = \ - $(SCOPE_DAEMON_LIBS) \ + $(LENS_DAEMON_LIBS) \ $(NULL) unity_music_daemon_VALASOURCES = \ diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/banshee-collection.vala unity-lens-music-6.8.1daily13.03.04/src/banshee-collection.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/banshee-collection.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/banshee-collection.vala 2013-04-02 19:00:11.000000000 +0000 @@ -49,7 +49,7 @@ /** * Performs a search on the banshee db */ - public void search (DeprecatedScopeSearch search, + public void search (LensSearch search, SearchType search_type, GLib.List? filters = null, int max_results = -1, @@ -67,7 +67,6 @@ var results_model = search.results_model; var helper_model = results_model; - var empty_asv = new Variant.array (VariantType.VARDICT.element (), {}); if (category_override >= 0) { helper_model = new Dee.SequenceModel (); @@ -131,9 +130,8 @@ category_id = category_override; helper_model.append (track.uri, artwork_path, category_id, - Unity.ResultType.PERSONAL, track.mime_type, track.title, track.artist, - track.uri, empty_asv); + track.uri); if (albums.add (album.artist + album.title)) { StringBuilder uri_list_builder = new StringBuilder (); @@ -148,9 +146,8 @@ category_id = category_override; results_model.append (album.uri, album.artwork_path, category_id, - Unity.ResultType.PERSONAL, "audio/mp3", album.title, album.artist, - uri_list_builder.str, empty_asv); + uri_list_builder.str); } break; diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/banshee-scope.vala unity-lens-music-6.8.1daily13.03.04/src/banshee-scope.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/banshee-scope.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/banshee-scope.vala 2013-04-02 19:00:11.000000000 +0000 @@ -24,17 +24,16 @@ public class BansheeScopeProxy : SimpleScope { private BansheeCollection collection; + private Unity.Extras.PreviewPlayerController preview_player; private Unity.MusicPreview? music_preview; public BansheeScopeProxy () { base (); - scope = new Unity.DeprecatedScope ("/com/canonical/unity/scope/banshee", "music-banshee.scope"); + scope = new Unity.Scope ("/com/canonical/unity/scope/banshee"); scope.search_in_global = true; - scope.search_hint = _("Search Music Collection"); - scope.visible = true; - + scope.provides_personal_content = true; scope.activate_uri.connect (activate); scope.preview_uri.connect (preview); scope.sources.add_option ("banshee", _("Banshee"), null); @@ -118,6 +117,10 @@ var show_folder_action = new Unity.PreviewAction ("show_in_folder", _("Show in Folder"), null); show_folder_action.activated.connect (show_in_folder); music_preview.add_action (show_folder_action); + + if (preview_player == null) + preview_player = new Unity.Extras.PreviewPlayerController (); + preview_player.active_preview = music_preview; } return music_preview; @@ -218,11 +221,11 @@ } } - public override async void perform_search (DeprecatedScopeSearch search, + public override async void perform_search (LensSearch search, SearchType search_type, owned List filters, int max_results = -1, - GLib.Cancellable? cancellable = null) + Cancellable? cancellable = null) { int category_override = -1; if (search_type == SearchType.GLOBAL) diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/categories.vala unity-lens-music-6.8.1daily13.03.04/src/categories.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/categories.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/categories.vala 2013-04-02 19:00:11.000000000 +0000 @@ -20,10 +20,10 @@ namespace Unity.MusicLens { public enum Category { - MUSIC, SONGS, ALBUMS, PURCHASE, + MUSIC, RADIOS } diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/config.vala.in unity-lens-music-6.8.1daily13.03.04/src/config.vala.in --- unity-lens-music-7.4-6.8.1daily13.03.04/src/config.vala.in 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/config.vala.in 2013-04-02 19:00:11.000000000 +0000 @@ -13,6 +13,4 @@ const string PACKAGE = "@PACKAGE@"; const string VERSION = "@VERSION@"; - - const string ICON_PATH = "@DATADIR@/icons/unity-icon-theme/places/svg"; } diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/daemon.vala unity-lens-music-6.8.1daily13.03.04/src/daemon.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/daemon.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/daemon.vala 2013-04-02 19:00:11.000000000 +0000 @@ -22,34 +22,126 @@ namespace Unity.MusicLens { + const string ICON_PATH = "/usr/share/icons/unity-icon-theme/places/svg/"; + public class Daemon : GLib.Object { + private Unity.Lens lens; private BansheeScopeProxy banshee; private RhythmboxScope rb; construct { + lens = new Unity.Lens("/com/canonical/unity/lens/music", "music"); + lens.search_in_global = true; + lens.search_hint = _("Search Music Collection"); + lens.sources_display_name = _("Sources"); + lens.visible = true; + + populate_categories (); + populate_filters(); + var app_check = new DesktopAppInfo ("banshee.desktop"); if (app_check != null) { banshee = new BansheeScopeProxy (); - try { - banshee.scope.export (); - } catch (GLib.IOError e) { - stdout.printf ("error %s\n", e.message); - } + lens.add_local_scope (banshee.scope); } app_check = new DesktopAppInfo ("rhythmbox.desktop"); if (app_check != null) { rb = new RhythmboxScope (); - try { - rb.scope.export (); - } catch (GLib.IOError e) { - stdout.printf ("error %s\n", e.message); - } + lens.add_local_scope (rb.scope); + } + + try { + lens.export (); + } catch (GLib.IOError e) { + stdout.printf ("error %s\n", e.message); } } + + private void populate_filters () + { + var filters = new GLib.List (); + + /* Decade filter */ + { + var filter = new MultiRangeFilter ("decade", _("Decade")); + + filter.add_option ("0", _("Old")); + filter.add_option ("1960", _("60s")); + filter.add_option ("1970", _("70s")); + filter.add_option ("1980", _("80s")); + filter.add_option ("1990", _("90s")); + filter.add_option ("2000", _("00s")); + filter.add_option ("2010", _("10s")); + + filters.append (filter); + } + + /* Genre filter */ + { + var filter = new CheckOptionFilterCompact ("genre", _("Genre")); + filter.sort_type = OptionsFilter.SortType.DISPLAY_NAME; + + filter.add_option (Genre.BLUES_ID, _("Blues")); + filter.add_option (Genre.CLASSICAL_ID, _("Classical")); + filter.add_option (Genre.COUNTRY_ID, _("Country")); + filter.add_option (Genre.DISCO_ID, _("Disco")); + filter.add_option (Genre.FUNK_ID, _("Funk")); + filter.add_option (Genre.ROCK_ID, _("Rock")); + filter.add_option (Genre.METAL_ID, _("Metal")); + filter.add_option (Genre.HIPHOP_ID, _("Hip-hop")); + filter.add_option (Genre.HOUSE_ID, _("House")); + filter.add_option (Genre.NEWWAVE_ID, _("New-wave")); + filter.add_option (Genre.RANDB_ID, _("R&B")); + filter.add_option (Genre.PUNK_ID, _("Punk")); + filter.add_option (Genre.JAZZ_ID, _("Jazz")); + filter.add_option (Genre.POP_ID, _("Pop")); + filter.add_option (Genre.REGGAE_ID, _("Reggae")); + filter.add_option (Genre.SOUL_ID, _("Soul")); + filter.add_option (Genre.TECHNO_ID, _("Techno")); + filter.add_option (Genre.OTHER_ID, _("Other")); + + filters.append (filter); + } + + lens.filters = filters; + } + + // FIXME icons + private void populate_categories () + { + /* Offsets of categories must match up with the Category enum */ + + var categories = new GLib.List (); + var icon_dir = File.new_for_path (ICON_PATH); + + var cat = new Unity.Category (_("Songs"), + new FileIcon (icon_dir.get_child ("group-songs.svg"))); + categories.append (cat); + + cat = new Unity.Category (_("Albums"), + new FileIcon (icon_dir.get_child ("group-albums.svg"))); + categories.append (cat); + + cat = new Unity.Category (_("More suggestions"), + new FileIcon (icon_dir.get_child ("group-treat-yourself.svg")), + Unity.CategoryRenderer.FLOW); + categories.append (cat); + + cat = new Unity.Category (_("Music"), + new FileIcon (icon_dir.get_child ("group-songs.svg"))); + categories.append (cat); + + cat = new Unity.Category (_("Radio"), + new FileIcon (icon_dir.get_child ("group-songs.svg"))); + categories.append (cat); + + lens.categories = categories; + } } } /* namespace */ + diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/main.vala unity-lens-music-6.8.1daily13.03.04/src/main.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/main.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/main.vala 2013-04-02 19:00:11.000000000 +0000 @@ -26,8 +26,6 @@ static Application? app = null; static Daemon? daemon = null; - static const string BUS_NAME = "com.canonical.Unity.Scope.Music"; - /* Check if a given well known DBus is owned. * WARNING: This does sync IO! */ public static bool dbus_name_has_owner (string name) @@ -68,7 +66,7 @@ * making it race against GDBus' worker thread to export our * objects on the bus before/after owning our name and receiving * method calls on our objects (which may not yet be up!)*/ - if (dbus_name_has_owner (BUS_NAME)) + if (dbus_name_has_owner ("com.canonical.Unity.Lens.Music")) { print ("Another instance of the Unity Music Daemon " + "already appears to be running.\nBailing out.\n"); @@ -80,7 +78,8 @@ daemon = new Daemon (); /* Use GApplication directly for single instance app functionality */ - app = new Application (BUS_NAME, ApplicationFlags.IS_SERVICE); + app = new Application ("com.canonical.Unity.Lens.Music", + ApplicationFlags.IS_SERVICE); try { app.register (); } catch (Error e) { diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/musicstore-collection.vala unity-lens-music-6.8.1daily13.03.04/src/musicstore-collection.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/musicstore-collection.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/musicstore-collection.vala 2013-04-02 19:00:11.000000000 +0000 @@ -33,8 +33,8 @@ preview_uri_map = new HashTable(str_hash, str_equal); } - public async void search (DeprecatedScopeSearch search, SearchType search_type, - owned List filters, int max_results = -1, GLib.Cancellable cancellable) throws IOError + public async void search (LensSearch search, SearchType search_type, + owned List filters, int max_results = -1, Cancellable cancellable) throws IOError { string? uri = build_search_uri (search.search_string, filters); @@ -133,7 +133,7 @@ } } - private async void read_musicstore_search_result_async (File file, Dee.Model model, GLib.Cancellable cancellable) + private async void read_musicstore_search_result_async (File file, Dee.Model model, Cancellable cancellable) { var timer = new Timer (); debug ("Searching %s", file.get_uri ()); @@ -181,9 +181,7 @@ dnd_uri = uri; model.append (uri, icon, PURCHASE_CATEGORY, - Unity.ResultType.DEFAULT, - mimetype, title, artist, dnd_uri, - empty_asv); + mimetype, title, artist, dnd_uri); preview_uri_map.insert (uri.substring (7), details_uri); // strip off "u1ms://" from the uri } @@ -212,9 +210,7 @@ // FIXME drag n drop uri needs to be the u1ms:// link model.append (uri, icon, PURCHASE_CATEGORY, - Unity.ResultType.DEFAULT, - mimetype, title, artist, dnd_uri, - empty_asv); + mimetype, title, artist, dnd_uri); preview_uri_map.insert (uri.substring (7), details_uri); // strip off "u1ms://" from the uri } diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/musicstore-daemon.vala unity-lens-music-6.8.1daily13.03.04/src/musicstore-daemon.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/musicstore-daemon.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/musicstore-daemon.vala 2013-04-02 19:00:11.000000000 +0000 @@ -106,4 +106,4 @@ return app.run (); } -} /* namespace */ +} /* namespace */ \ No newline at end of file diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/musicstore-scope.vala unity-lens-music-6.8.1daily13.03.04/src/musicstore-scope.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/musicstore-scope.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/musicstore-scope.vala 2013-04-02 19:00:11.000000000 +0000 @@ -25,7 +25,7 @@ namespace Unity.MusicLens { private const string FORGOTTEN_PASSWORD_URL = "https://login.ubuntu.com/+forgot_password"; - private const string CHANGE_PAYMENT_METHOD_URL = "https://one.ubuntu.com/account/"; + private const string CHANGE_PAYMENT_METHOD_URL = "https://pay.ubuntu.com/account/"; private const string ERROR_MESSAGE_NOT_LOGGED_IN = _("It seems you don't have an Ubuntu One account, or you are not logged in. To continue, please login and visit the Ubuntu One online store."); private const string ERROR_MESSAGE_NO_PAYMENT_METHOD = _("It seems you haven't set yet your preferred Ubuntu One payment method. To add a payment method, please visit the Ubuntu One online store."); private const string ERROR_MESSAGE_TECHNICAL_PROBLEM = _("Sorry, we have encountered a technical problem. No money has been taken from your account. To try your purchase again, please visit the Ubuntu One online store."); @@ -33,22 +33,23 @@ public class MusicStoreScopeProxy : SimpleScope { + const string NO_CREDENTIALS_LABEL_TEXT = _("Before you can purchase music you need to log in to the Ubuntu One app."); private MusicStoreCollection collection; + private Unity.Extras.PreviewPlayerController preview_player; private Unity.MusicPreview? music_preview; private PreferencesManager preferences = PreferencesManager.get_default (); private HashTable album_map; private PurchaseService purchase_service; private Notification notification; + private bool have_credentials = false; public MusicStoreScopeProxy () { base (); - scope = new Unity.DeprecatedScope ("/com/canonical/unity/scope/musicstore", "musicstore.scope"); + scope = new Unity.Scope ("/com/canonical/unity/scope/musicstore"); scope.search_in_global = false; - scope.search_hint = _("Search Music Collection"); - scope.visible = true; - + scope.provides_personal_content = false; scope.activate_uri.connect (activate); scope.preview_uri.connect (preview); @@ -113,6 +114,9 @@ int i = 1; music_preview = new Unity.MusicPreview (album.title, album.artist, cover); + if (preview_player == null) + preview_player = new Unity.Extras.PreviewPlayerController (); + preview_player.active_preview = music_preview; if (tracks != null) { @@ -127,21 +131,28 @@ } } - GLib.Icon? icon = new GLib.FileIcon (File.new_for_path (Config.DATADIR + "/icons/unity-icon-theme/places/svg/service-u1.svg")); - var download_action = new Unity.PreviewAction ("show_purchase_preview", _("Download"), icon); - if (album.formatted_price != null) - download_action.extra_text = album.formatted_price; - download_action.activated.connect (show_purchase_preview); - music_preview.add_action (download_action); + if (have_credentials) { + GLib.Icon? icon = new GLib.FileIcon (File.new_for_path (Config.DATADIR + "/icons/unity-icon-theme/places/svg/service-u1.svg")); + var download_action = new Unity.PreviewAction ("show_purchase_preview", _("Download"), icon); + if (album.formatted_price != null) + download_action.extra_text = album.formatted_price; + download_action.activated.connect (show_purchase_preview); + music_preview.add_action (download_action); + } else { + var data = new HashTable(str_hash, str_equal); + data["no_credentials_label"] = NO_CREDENTIALS_LABEL_TEXT; + InfoHint info_hint = new InfoHint.with_variant("music_preview", "", null, data); + music_preview.add_info(info_hint); + } } return music_preview; } - public override async void perform_search (DeprecatedScopeSearch search, + public override async void perform_search (LensSearch search, SearchType search_type, owned List filters, int max_results = -1, - GLib.Cancellable? cancellable = null) + Cancellable? cancellable = null) { if (is_search_empty (search)) return; @@ -158,11 +169,19 @@ } try { - debug ("model has %u rows before search", search.results_model.get_n_rows ()); - yield collection.search (search, search_type, (owned) filters, max_results, cancellable); - debug ("model has %u rows after search", search.results_model.get_n_rows ()); + yield purchase_service.fetch_credentials (); + have_credentials = true; + } catch (PurchaseError e) { + // this is not a serious error, just missing credentials + have_credentials = false; + } + + try { + debug ("model has %u rows before search", search.results_model.get_n_rows ()); + yield collection.search (search, search_type, (owned) filters, max_results, cancellable); + debug ("model has %u rows after search", search.results_model.get_n_rows ()); } catch (IOError e) { - warning ("Failed to search for '%s': %s", search.search_string, e.message); + warning ("Failed to search for '%s': %s", search.search_string, e.message); } try { @@ -185,7 +204,13 @@ var cover = new FileIcon (cover_file); var error_preview = new Unity.PaymentPreview.for_error(album.title, album.artist, cover); error_preview.header = error_header; - var error_action = new Unity.PreviewAction ("open_u1_link", link_text, null); + + var cancel_action = new Unity.PreviewAction ("cancel", _("Cancel"), null); + cancel_action.activated.connect (() => cancel_purchase (uri)); + error_preview.add_action (cancel_action); + + GLib.Icon? icon = new GLib.FileIcon (File.new_for_path (Config.DATADIR + "/icons/unity-icon-theme/places/svg/service-u1.svg")); + var error_action = new Unity.PreviewAction ("go_to_u1", link_text, icon); error_action.activated.connect (() => link_handler (uri)); error_preview.add_action (error_action); return new Unity.ActivationResponse.with_preview (error_preview); @@ -272,6 +297,15 @@ } var album = album_map.get (uri); + + File cover_file = File.new_for_uri (album.artwork_path); //artwork path is a remote uri + try { + var cover_pixbuf = new Pixbuf.from_stream (cover_file.read ()); + notification.set_icon_from_pixbuf (cover_pixbuf); + } catch (GLib.Error e) { + debug ("Cannot set notification icon from uri %s", uri); + } + notification.summary = album.title; notification.body = _("Authorizing purchase"); try { @@ -312,13 +346,6 @@ { File cover_file = File.new_for_uri (album.artwork_path); //artwork path is a remote uri - try { - var cover_pixbuf = new Pixbuf.from_stream (cover_file.read ()); - notification.set_icon_from_pixbuf (cover_pixbuf); - } catch (GLib.Error e) { - debug ("Cannot set notification icon from uri %s", uri); - } - var cover = new FileIcon (cover_file); album_purchase_preview = new Unity.PaymentPreview.for_music(album.title, album.artist, cover); diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/player.vala unity-lens-music-6.8.1daily13.03.04/src/player.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/player.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/player.vala 2013-04-02 19:00:11.000000000 +0000 @@ -262,7 +262,6 @@ gst_pipeline.set_state (Gst.State.PLAYING); timer_id = GLib.Timeout.add_seconds (1, progress_report_cb); - progress_report_cb(); } public void stop () diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/rhythmbox-collection.vala unity-lens-music-6.8.1daily13.03.04/src/rhythmbox-collection.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/rhythmbox-collection.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/rhythmbox-collection.vala 2013-04-02 19:00:11.000000000 +0000 @@ -658,19 +658,16 @@ var artwork = model.get_string (iter, Columns.ARTWORK); if (artwork == null || artwork == "") artwork = ALBUM_MISSING_ICON_PATH; - var empty_asv = new Variant.array (VariantType.VARDICT.element (), {}); results_model.append (uri, artwork, category_id, - Unity.ResultType.PERSONAL, model.get_string (iter, Columns.MIMETYPE), title, model.get_string (iter, Columns.ARTIST), - dnd_uri, - empty_asv); + dnd_uri); } - public void search (DeprecatedScopeSearch search, + public void search (LensSearch search, SearchType search_type, GLib.List? filters = null, int max_results = -1, diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/rhythmbox-scope.vala unity-lens-music-6.8.1daily13.03.04/src/rhythmbox-scope.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/rhythmbox-scope.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/rhythmbox-scope.vala 2013-04-02 19:00:11.000000000 +0000 @@ -26,17 +26,16 @@ private RhythmboxCollection collection; private bool db_ready; private FileMonitor rb_xml_monitor; + private Unity.Extras.PreviewPlayerController preview_player; private Unity.MusicPreview? music_preview; public RhythmboxScope () { base (); - scope = new Unity.DeprecatedScope ("/com/canonical/unity/scope/rhythmbox", "music-rhythmbox.scope"); + scope = new Unity.Scope ("/com/canonical/unity/scope/rhythmbox"); scope.search_in_global = true; - scope.search_hint = _("Search Music Collection"); - scope.visible = true; - + scope.provides_personal_content = true; scope.activate_uri.connect (activate); scope.preview_uri.connect (preview); scope.sources.add_option ("rhythmbox", _("Rhythmbox"), null); @@ -148,6 +147,15 @@ } } + if (music_preview != null) + { + if (preview_player == null) + { + preview_player = new Unity.Extras.PreviewPlayerController (); + } + preview_player.active_preview = music_preview; + } + return music_preview; } @@ -237,11 +245,11 @@ } } - public override async void perform_search (DeprecatedScopeSearch search, + public override async void perform_search (LensSearch search, SearchType search_type, owned List filters, int max_results = -1, - GLib.Cancellable? cancellable = null) + Cancellable? cancellable = null) { int category_override = -1; if (search_type == SearchType.GLOBAL) diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/simple-scope.vala unity-lens-music-6.8.1daily13.03.04/src/simple-scope.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/simple-scope.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/simple-scope.vala 2013-04-02 19:00:11.000000000 +0000 @@ -18,23 +18,22 @@ */ using GLib; -using Config; namespace Unity.MusicLens { public abstract class SimpleScope : Object { - public Unity.DeprecatedScope scope { get; protected set; } + public Unity.Scope scope { get; protected set; } protected abstract int num_results_without_search { get; } protected abstract int num_results_global_search { get; } protected abstract int num_results_lens_search { get; } - protected abstract async void perform_search (DeprecatedScopeSearch search, + protected abstract async void perform_search (LensSearch search, SearchType search_type, owned List filters, int max_results = -1, - GLib.Cancellable? cancellable = null); + Cancellable? cancellable = null); public SimpleScope () { @@ -42,16 +41,18 @@ protected void initialize () { - populate_filters (); - populate_categories (); + /* Listen for filter changes */ + scope.filters_changed.connect (() => { + scope.queue_search_changed (SearchType.DEFAULT); + }); scope.active_sources_changed.connect (() => { scope.queue_search_changed (SearchType.DEFAULT); }); /* No need to search if only the whitespace changes */ - scope.generate_search_key.connect ((search) => { - return search.search_string.strip (); + scope.generate_search_key.connect ((lens_search) => { + return lens_search.search_string.strip (); }); /* Listen for changes to the lens search entry */ @@ -59,91 +60,10 @@ update_search_async.begin (search, search_type, cancellable); }); } - - - private void populate_filters () - { - var filters = new Unity.FilterSet (); - - /* Decade filter */ - { - var filter = new MultiRangeFilter ("decade", _("Decade")); - - filter.add_option ("0", _("Old")); - filter.add_option ("1960", _("60s")); - filter.add_option ("1970", _("70s")); - filter.add_option ("1980", _("80s")); - filter.add_option ("1990", _("90s")); - filter.add_option ("2000", _("00s")); - filter.add_option ("2010", _("10s")); - - filters.add (filter); - } - - /* Genre filter */ - { - var filter = new CheckOptionFilterCompact ("genre", _("Genre")); - filter.sort_type = OptionsFilter.SortType.DISPLAY_NAME; - - filter.add_option (Genre.BLUES_ID, _("Blues")); - filter.add_option (Genre.CLASSICAL_ID, _("Classical")); - filter.add_option (Genre.COUNTRY_ID, _("Country")); - filter.add_option (Genre.DISCO_ID, _("Disco")); - filter.add_option (Genre.FUNK_ID, _("Funk")); - filter.add_option (Genre.ROCK_ID, _("Rock")); - filter.add_option (Genre.METAL_ID, _("Metal")); - filter.add_option (Genre.HIPHOP_ID, _("Hip-hop")); - filter.add_option (Genre.HOUSE_ID, _("House")); - filter.add_option (Genre.NEWWAVE_ID, _("New-wave")); - filter.add_option (Genre.RANDB_ID, _("R&B")); - filter.add_option (Genre.PUNK_ID, _("Punk")); - filter.add_option (Genre.JAZZ_ID, _("Jazz")); - filter.add_option (Genre.POP_ID, _("Pop")); - filter.add_option (Genre.REGGAE_ID, _("Reggae")); - filter.add_option (Genre.SOUL_ID, _("Soul")); - filter.add_option (Genre.TECHNO_ID, _("Techno")); - filter.add_option (Genre.OTHER_ID, _("Other")); - - filters.add (filter); - } - - scope.filters = filters; - } - - // FIXME icons - private void populate_categories () - { - /* Offsets of categories must match up with the Category enum */ - var categories = new Unity.CategorySet (); - var icon_dir = File.new_for_path (Config.ICON_PATH); - - var cat = new Unity.Category ("global", _("Music"), - new FileIcon (icon_dir.get_child ("group-songs.svg"))); - categories.add (cat); - - cat = new Unity.Category ("songs", _("Songs"), - new FileIcon (icon_dir.get_child ("group-songs.svg"))); - categories.add (cat); - - cat = new Unity.Category ("albums", _("Albums"), - new FileIcon (icon_dir.get_child ("group-albums.svg"))); - categories.add (cat); - - cat = new Unity.Category ("more", _("More suggestions"), - new FileIcon (icon_dir.get_child ("group-treat-yourself.svg")), - Unity.CategoryRenderer.FLOW); - categories.add (cat); - - cat = new Unity.Category ("radio", _("Radio"), - new FileIcon (icon_dir.get_child ("group-songs.svg"))); - categories.add (cat); - - scope.categories = categories; - } - - private async void update_search_async (DeprecatedScopeSearch search, + + private async void update_search_async (LensSearch search, SearchType search_type, - GLib.Cancellable cancellable) + Cancellable cancellable) { int max_results; /* @@ -160,10 +80,10 @@ yield prepare_search (search, search_type, max_results, cancellable); } - private async void prepare_search (DeprecatedScopeSearch search, + private async void prepare_search (LensSearch search, SearchType search_type, int max_results, - GLib.Cancellable cancellable) + Cancellable cancellable) { var results_model = search.results_model; @@ -171,11 +91,11 @@ // don't apply filters to global searches if (search_type != SearchType.GLOBAL) { - Filter filter = search.get_filter ("genre"); + Filter filter = scope.get_filter ("genre"); if (filter.filtering) filters.append (new GenreFilterParser (filter as CheckOptionFilterCompact)); - filter = search.get_filter ("decade"); + filter = scope.get_filter ("decade"); if (filter.filtering) filters.append (new DecadeFilterParser (filter as MultiRangeFilter)); } @@ -208,7 +128,7 @@ search.finished (); } - protected bool is_search_empty (DeprecatedScopeSearch search) + protected bool is_search_empty (LensSearch search) requires (search.search_string != null) { return search.search_string.strip () == ""; diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/src/ubuntuone-webservices.vala unity-lens-music-6.8.1daily13.03.04/src/ubuntuone-webservices.vala --- unity-lens-music-7.4-6.8.1daily13.03.04/src/ubuntuone-webservices.vala 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/src/ubuntuone-webservices.vala 2013-04-02 19:00:11.000000000 +0000 @@ -21,7 +21,9 @@ [DBus (name = "com.ubuntuone.CredentialsManagement")] interface CredentialsManagement : GLib.Object { + public signal void authorization_denied (); public signal void credentials_found (HashTable info); + public signal void credentials_not_found (); public signal void credentials_error (); [DBus (name = "find_credentials")] @@ -35,7 +37,8 @@ const string AUTHENTICATION_SERVER = "https://login.ubuntu.com/"; const string AUTHENTICATION_PATH = "api/1.1/authentications"; const string AUTHENTICATE_PARAMS = "ws.op=authenticate&token_name=Purchase_Token"; - +const int PASSWORD_CACHE_SECONDS = 300; +const int PAYMENT_METHOD_CACHE_SECONDS = 120; namespace Ubuntuone.Webservice { @@ -58,12 +61,17 @@ public string consumer_key { get; private set; default = null; } public string token { get; private set; default = null; } public string open_url { get; private set; default = null; } + internal DateTime _selected_payment_method_expiry; + DateTime _password_expiry; internal HashTable _ubuntuone_credentials = null; construct { http_session = build_http_session (); http_session_sso = build_http_session (); + reset_payment_method_cache (0); + reset_password_cache (0); + credentials_management = build_credentials_management (); } @@ -74,6 +82,11 @@ return session; } + internal DateTime now () + { + return new DateTime.now_utc (); + } + string webapi_server () { string staging_webapi = Environment.get_variable ("U1_STAGING_WEBAPI"); @@ -90,6 +103,21 @@ return webapi_server() + PAYMENT_METHOD_PATH; } + internal bool expired_payment_method_cache () + { + return _selected_payment_method_expiry.compare (now ()) <= 0; + } + + internal void reset_payment_method_cache (int seconds_from_now) + { + _selected_payment_method_expiry = now ().add_seconds (seconds_from_now); + } + + internal void reset_password_cache (int seconds_from_now) + { + _password_expiry = now ().add_seconds (seconds_from_now); + } + string purchase_with_default_payment_uri () { return webapi_server() + PURCHASE_WITH_DEFAULT_PAYMENT_PATH; @@ -167,7 +195,7 @@ } } - internal virtual async void fetch_credentials () throws PurchaseError + public virtual async void fetch_credentials () throws PurchaseError { PurchaseError error = null; @@ -176,6 +204,10 @@ debug ("got credentials"); fetch_credentials.callback (); }); + ulong not_found_handler = credentials_management.credentials_not_found.connect ((credentials) => { + error = new PurchaseError.MISSING_CREDENTIALS_ERROR ("Can't get Ubuntu One tokens."); + fetch_credentials.callback (); + }); ulong error_handler = credentials_management.credentials_error.connect (() => { error = new PurchaseError.MISSING_CREDENTIALS_ERROR ("Can't get Ubuntu One tokens."); fetch_credentials.callback (); @@ -189,6 +221,7 @@ } credentials_management.disconnect (found_handler); + credentials_management.disconnect (not_found_handler); credentials_management.disconnect (error_handler); if (error != null) { @@ -265,6 +298,7 @@ var result = (string) message.response_body.data; parse_payment_method_json (result); } catch (GLib.Error e) { + debug ("Error while getting payment method: %s.", e.message); throw new PurchaseError.PURCHASE_ERROR (e.message); } } @@ -273,9 +307,10 @@ { yield fetch_credentials (); yield fetch_account (); + reset_payment_method_cache (PAYMENT_METHOD_CACHE_SECONDS); } - public virtual void fetch_payment_info (string purchase_sku) throws PurchaseError + public void fetch_payment_info (string purchase_sku) throws PurchaseError { fetch_payment_method (purchase_sku); } diff -Nru unity-lens-music-7.4-6.8.1daily13.03.04/tests/unit/Makefile.am unity-lens-music-6.8.1daily13.03.04/tests/unit/Makefile.am --- unity-lens-music-7.4-6.8.1daily13.03.04/tests/unit/Makefile.am 2013-03-21 13:54:00.000000000 +0000 +++ unity-lens-music-6.8.1daily13.03.04/tests/unit/Makefile.am 2013-04-02 19:00:11.000000000 +0000 @@ -4,7 +4,7 @@ AM_CPPFLAGS = \ -w \ - $(SCOPE_DAEMON_CFLAGS) \ + $(LENS_DAEMON_CFLAGS) \ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ -I$(top_srcdir)/src \ $(COVERAGE_CFLAGS) \ @@ -26,11 +26,10 @@ --pkg tdb \ --pkg unity \ $(srcdir)/assertions.vapi \ - $(MAINTAINER_VALAFLAGS) $(NULL) test_libs = \ - $(SCOPE_DAEMON_LIBS) \ + $(LENS_DAEMON_LIBS) \ $(NULL) test_rhythmbox_parser_LDADD = $(test_libs)