Merge lp:~alecu/unity-lens-music/rework-credentials-check into lp:~unity-team/unity-lens-music/libunity7-compatible

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Michal Hruby
Approved revision: 149
Merged at revision: 149
Proposed branch: lp:~alecu/unity-lens-music/rework-credentials-check
Merge into: lp:~unity-team/unity-lens-music/libunity7-compatible
Diff against target: 222 lines (+84/-18)
6 files modified
configure.ac (+3/-0)
src/Makefile.am (+2/-0)
src/config.vala.in (+2/-0)
src/musicstore-scope.vala (+57/-15)
src/ubuntuone-webservices.vala (+11/-2)
tests/unit/test-ubuntuone-purchases.vala (+9/-1)
To merge this branch: bzr merge lp:~alecu/unity-lens-music/rework-credentials-check
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michal Hruby (community) Approve
Review via email: mp+160758@code.launchpad.net

Commit message

- Move account checking to payment preview (LP: #1170773).

Description of the change

* Credentials check was moved from search to the payment preview (LP: #1170773)
* Fixed the path and parameters for the new login ui

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

The autotools portions (which alecu asked me to review) look good to me.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
148. By Alejandro J. Cura

fix for the tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
149. By Alejandro J. Cura

fix formatting issue

Revision history for this message
Michal Hruby (mhr3) wrote :

Looks reasonable to me.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2013-04-23 08:09:36 +0000
+++ configure.ac 2013-04-25 16:47:27 +0000
@@ -116,6 +116,9 @@
116AS_AC_EXPAND(DATADIR, $datarootdir)116AS_AC_EXPAND(DATADIR, $datarootdir)
117AC_SUBST(DATADIR)117AC_SUBST(DATADIR)
118118
119AS_AC_EXPAND(LIBEXECDIR, $libexecdir)
120AC_SUBST(LIBEXECDIR)
121
119#####################################################122#####################################################
120# Look for dbus service dir123# Look for dbus service dir
121#####################################################124#####################################################
122125
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2013-04-17 15:02:43 +0000
+++ src/Makefile.am 2013-04-25 16:47:27 +0000
@@ -4,6 +4,7 @@
4EXTRA_DIST =4EXTRA_DIST =
55
6DATADIR = $(datadir)6DATADIR = $(datadir)
7LIBEXECDIR = $(libexecdir)
78
8# we're using Vala, C warnings are useless9# we're using Vala, C warnings are useless
9AM_CFLAGS = -w10AM_CFLAGS = -w
@@ -70,6 +71,7 @@
70 $(NULL)71 $(NULL)
7172
72unity_musicstore_daemon_CPPFLAGS = \73unity_musicstore_daemon_CPPFLAGS = \
74 -DLIBEXECDIR=\"$(LIBEXECDIR)\" \
73 $(unity_music_daemon_CPPFLAGS)75 $(unity_music_daemon_CPPFLAGS)
7476
75unity_musicstore_daemon_VALAFLAGS = \77unity_musicstore_daemon_VALAFLAGS = \
7678
=== modified file 'src/config.vala.in'
--- src/config.vala.in 2013-03-13 12:14:27 +0000
+++ src/config.vala.in 2013-04-25 16:47:27 +0000
@@ -8,6 +8,8 @@
8 8
9 const string BINDIR = "@prefix@/bin";9 const string BINDIR = "@prefix@/bin";
10 10
11 const string LIBEXECDIR = "@LIBEXECDIR@";
12
11 const string LOCALEDIR = "@DATADIR@/locale";13 const string LOCALEDIR = "@DATADIR@/locale";
12 14
13 const string PACKAGE = "@PACKAGE@";15 const string PACKAGE = "@PACKAGE@";
1416
=== modified file 'src/musicstore-scope.vala'
--- src/musicstore-scope.vala 2013-04-22 09:02:29 +0000
+++ src/musicstore-scope.vala 2013-04-25 16:47:27 +0000
@@ -29,7 +29,7 @@
29 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.");29 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.");
30 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.");30 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.");
31 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.");31 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.");
32 private const string U1_SSO_UI = "u1_login_register";32 private const string UBUNTUONE_MUSIC_LOGIN = Config.LIBEXECDIR + "/ubuntuone-credentials/ubuntuone-music-login";
3333
34 public class MusicStoreScopeProxy : SimpleScope34 public class MusicStoreScopeProxy : SimpleScope
35 {35 {
@@ -164,12 +164,6 @@
164 warning ("Failed to search for '%s': %s", search.search_string, e.message);164 warning ("Failed to search for '%s': %s", search.search_string, e.message);
165 }165 }
166166
167 try {
168 yield purchase_service.fetch_account_info ();
169 debug ("retrieved account info: %s %s", purchase_service.nickname, purchase_service.email);
170 } catch (PurchaseError e) {
171 debug ("can't get account info: %s", e.message);
172 }
173 }167 }
174168
175 delegate Unity.ActivationResponse LinkHandler (string uri);169 delegate Unity.ActivationResponse LinkHandler (string uri);
@@ -211,15 +205,16 @@
211 SList<Track> tracks = null;205 SList<Track> tracks = null;
212 collection.get_album_details (uri, out album, out tracks);206 collection.get_album_details (uri, out album, out tracks);
213207
214 var ui_path = Environment.find_program_in_path (U1_SSO_UI);208 debug ("Finding %s", UBUNTUONE_MUSIC_LOGIN);
209 var ui_path = Environment.find_program_in_path (UBUNTUONE_MUSIC_LOGIN);
215 GLib.Pid child_pid;210 GLib.Pid child_pid;
216 string argv[11] = {211 string argv[6] = {
217 ui_path,212 ui_path,
218 "--album", album.title,213 "--album=" + album.title,
219 "--artist", album.artist,214 "--artist=" + album.artist,
220 "--price", album.formatted_price,215 "--price=" + album.formatted_price,
221 "--picture", album.artwork_path,216 "--picture=" + album.artwork_path,
222 "--url", uri217 "--url=" + uri
223 };218 };
224 if (ui_path != null) {219 if (ui_path != null) {
225 try {220 try {
@@ -229,14 +224,61 @@
229 return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);224 return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);
230 }225 }
231 } catch (GLib.SpawnError e) {226 } catch (GLib.SpawnError e) {
232 debug ("Failed to start u1_sso_ui for uri %s", uri);227 debug ("Failed to start ubuntuone-music-login for uri %s", uri);
233 }228 }
234 }229 }
235 return open_uri (uri);230 return open_uri (uri);
236 }231 }
237232
233 bool run_with_timeout (MainLoop ml, uint timeout_ms)
234 {
235 bool timeout_reached = false;
236 var t_id = Timeout.add (timeout_ms, () => {
237 timeout_reached = true;
238 debug ("Timeout reached");
239 ml.quit ();
240 return false;
241 });
242
243 ml.run ();
244
245 if (!timeout_reached) {
246 Source.remove (t_id);
247 }
248
249 return !timeout_reached;
250 }
251
252 void fetch_account_info_sync () throws PurchaseError
253 {
254 PurchaseError failure = null;
255 MainLoop mainloop = new MainLoop ();
256 purchase_service.fetch_account_info.begin((obj, res) => {
257 mainloop.quit ();
258 try {
259 purchase_service.fetch_account_info.end (res);
260 } catch (PurchaseError e) {
261 failure = e;
262 }
263 });
264 if (!run_with_timeout (mainloop, 10000)) {
265 throw new PurchaseError.MISSING_CREDENTIALS_ERROR ("Timeout getting credentials.");
266 }
267 if (failure != null) {
268 throw failure;
269 }
270 }
271
238 public Unity.ActivationResponse show_purchase_preview (string uri)272 public Unity.ActivationResponse show_purchase_preview (string uri)
239 {273 {
274
275 try {
276 fetch_account_info_sync ();
277 debug ("retrieved account info: %s %s", purchase_service.nickname, purchase_service.email);
278 } catch (PurchaseError e) {
279 debug ("can't get account info: %s", e.message);
280 }
281
240 if (purchase_service.got_credentials () == false)282 if (purchase_service.got_credentials () == false)
241 {283 {
242 debug ("no credentials available, opening sso login. %s", uri);284 debug ("no credentials available, opening sso login. %s", uri);
243285
=== modified file 'src/ubuntuone-webservices.vala'
--- src/ubuntuone-webservices.vala 2013-04-17 19:25:40 +0000
+++ src/ubuntuone-webservices.vala 2013-04-25 16:47:27 +0000
@@ -22,7 +22,9 @@
22[DBus (name = "com.ubuntuone.CredentialsManagement")]22[DBus (name = "com.ubuntuone.CredentialsManagement")]
23interface CredentialsManagement : GLib.Object {23interface CredentialsManagement : GLib.Object {
24 public signal void credentials_found (HashTable <string, string> info);24 public signal void credentials_found (HashTable <string, string> info);
25 public signal void credentials_error ();25 public signal void credentials_not_found ();
26 public signal void credentials_error (HashTable <string, string> error_dict);
27
2628
27 [DBus (name = "find_credentials")]29 [DBus (name = "find_credentials")]
28 public abstract void find_credentials () throws Error;30 public abstract void find_credentials () throws Error;
@@ -176,8 +178,14 @@
176 debug ("got credentials");178 debug ("got credentials");
177 fetch_credentials.callback ();179 fetch_credentials.callback ();
178 });180 });
179 ulong error_handler = credentials_management.credentials_error.connect (() => {181 ulong not_found_handler = credentials_management.credentials_not_found.connect (() => {
182 error = new PurchaseError.MISSING_CREDENTIALS_ERROR ("No Ubuntu One tokens.");
183 debug ("not found handler");
184 fetch_credentials.callback ();
185 });
186 ulong error_handler = credentials_management.credentials_error.connect ((error_dict) => {
180 error = new PurchaseError.MISSING_CREDENTIALS_ERROR ("Can't get Ubuntu One tokens.");187 error = new PurchaseError.MISSING_CREDENTIALS_ERROR ("Can't get Ubuntu One tokens.");
188 debug ("error handler");
181 fetch_credentials.callback ();189 fetch_credentials.callback ();
182 });190 });
183191
@@ -189,6 +197,7 @@
189 }197 }
190198
191 credentials_management.disconnect (found_handler);199 credentials_management.disconnect (found_handler);
200 credentials_management.disconnect (not_found_handler);
192 credentials_management.disconnect (error_handler);201 credentials_management.disconnect (error_handler);
193202
194 if (error != null) {203 if (error != null) {
195204
=== modified file 'tests/unit/test-ubuntuone-purchases.vala'
--- tests/unit/test-ubuntuone-purchases.vala 2013-03-19 21:41:57 +0000
+++ tests/unit/test-ubuntuone-purchases.vala 2013-04-25 16:47:27 +0000
@@ -201,10 +201,18 @@
201201
202 class FailingCredentialsManagement : GLib.Object, CredentialsManagement202 class FailingCredentialsManagement : GLib.Object, CredentialsManagement
203 {203 {
204 private HashTable <string, string> fake_error_info;
205
206 construct
207 {
208 fake_error_info = new HashTable <string, string> (str_hash, str_equal);
209 fake_error_info["error"] = "fake_error";
210 }
211
204 public void find_credentials () throws IOError212 public void find_credentials () throws IOError
205 {213 {
206 Idle.add (() => {214 Idle.add (() => {
207 credentials_error ();215 credentials_error (fake_error_info);
208 return false;216 return false;
209 });217 });
210 }218 }

Subscribers

People subscribed via source and target branches

to all changes: