Merge lp:~jonobacon/ubuntu-accomplishments-daemon/u1-signup into lp:ubuntu-accomplishments-daemon

Proposed by Jono Bacon
Status: Merged
Merged at revision: 71
Proposed branch: lp:~jonobacon/ubuntu-accomplishments-daemon/u1-signup
Merge into: lp:ubuntu-accomplishments-daemon
Diff against target: 95 lines (+27/-22)
2 files modified
accomplishments/daemon/api.py (+22/-21)
accomplishments/daemon/dbusapi.py (+5/-1)
To merge this branch: bzr merge lp:~jonobacon/ubuntu-accomplishments-daemon/u1-signup
Reviewer Review Type Date Requested Status
Rafał Cieślak Pending
Review via email: mp+109257@code.launchpad.net

Description of the change

This branch adds support for signing up from the application if no Ubuntu One account is found. Please note: you should ensure that you also apply the equivilent branch to the viewer: lp:~jonobacon/ubuntu-accomplishments-viewer/u1-signup

This is the user experience: the user does not have an Ubuntu One account. They fire up the accomplishments system and a message explains why Ubuntu One is required and says it will detect an account. If no account is found a native GTK window pops up where the user can sign up, and when they register they are emailed a code that they enter into the app. When the signup process is complete, the app moves on to register the share as normal. While the process is not perfect for 0.2, it works, and in 0.3 we can refine it further: but at least we will know that people without accounts are taken care of.

Some notes:

 * This works by running a new method in the daemon that detects credententials and if credentials are found it triggers a dbus signal (ubuntu_one_account_ready) which then moves the client onto the share setup step.
 * When we detect the credentials, if none are found the signup process continues before the execution continues.
 * The reason we need to detect for an account first is that we don't know up front from the daemon if the user has credentials, as such if they don't have credentials the signup processes is triggered and the signal is generated as normal.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'accomplishments/daemon/api.py'
2--- accomplishments/daemon/api.py 2012-06-07 14:02:41 +0000
3+++ accomplishments/daemon/api.py 2012-06-07 23:52:19 +0000
4@@ -44,6 +44,7 @@
5 pynotify = None
6
7 from ubuntuone.platform.tools import SyncDaemonTool
8+from ubuntuone.platform.credentials import CredentialsManagementTool
9 from ubuntuone.couch import auth
10
11 import accomplishments
12@@ -113,6 +114,23 @@
13 self.parent.run_scripts(0)
14 self.wait_until_a_sig_file_arrives()
15
16+ @defer.inlineCallbacks
17+ def verify_ubuntu_one_account(self):
18+ # check if this machine has an Ubuntu One account
19+ log.msg("Check if this machine has an Ubuntu One account...")
20+
21+ tool = CredentialsManagementTool()
22+ creds = yield tool.register()
23+
24+ if len(creds) > 1:
25+ log.msg("...Yes.")
26+ self.parent.has_u1 = True
27+ self.parent.service.ubuntu_one_account_ready()
28+ else:
29+ log.msg("...No.")
30+ log.msg(u1auth_response)
31+ self.parent.has_u1 = False
32+
33 # XXX let's rewrite this to use deferreds explicitly
34 @defer.inlineCallbacks
35 def register_trophy_dir(self, trophydir):
36@@ -467,27 +485,6 @@
37 im.putalpha(alpha)
38 return im
39
40- def verify_ubuntu_one_account(self):
41- # check if this machine has an Ubuntu One account
42- log.msg("Check if this machine has an Ubuntu One account...")
43- u1auth_response = auth.request(
44- url='https://one.ubuntu.com/api/account/')
45- u1email = None
46- if not isinstance(u1auth_response, basestring):
47- u1email = json.loads(u1auth_response[1])['email']
48- else:
49- log.msg("No Ubuntu One account is configured.")
50-
51- if u1email is None:
52- log.msg("...No.")
53- log.msg(u1auth_response)
54- self.has_u1 = False
55- return False
56- else:
57- log.msg("...Yes.")
58- self.has_u1 = True
59- return True
60-
61 def get_config_value(self, section, item):
62 """Return a configuration value from the .accomplishments file"""
63 log.msg(
64@@ -513,6 +510,10 @@
65 else:
66 return "NoOption"
67
68+ def verify_ubuntu_one_account(self):
69+ log.msg("------------------- run first func")
70+ self.asyncapi.verify_ubuntu_one_account()
71+
72 def write_config_file_item(self, section, item, value):
73 """Set a configuration value in the .accomplishments file"""
74 log.msg(
75
76=== modified file 'accomplishments/daemon/dbusapi.py'
77--- accomplishments/daemon/dbusapi.py 2012-06-07 14:02:41 +0000
78+++ accomplishments/daemon/dbusapi.py 2012-06-07 23:52:19 +0000
79@@ -216,7 +216,7 @@
80 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
81 in_signature="s", out_signature="s")
82 def get_acc_icon(self,accomID):
83- return self.api.get_acc_icon(accomID)
84+ return self.api.get_acc_icon(accomID)
85
86 @dbus.service.method(dbus_interface='org.ubuntu.accomplishments',
87 in_signature="s", out_signature="s")
88@@ -320,3 +320,7 @@
89 @dbus.service.signal(dbus_interface='org.ubuntu.accomplishments')
90 def scriptrunner_finish(self):
91 pass
92+
93+ @dbus.service.signal(dbus_interface='org.ubuntu.accomplishments')
94+ def ubuntu_one_account_ready(self):
95+ pass

Subscribers

People subscribed via source and target branches