Merge lp:~mikemc/ubuntuone-credentials/add-qmlplugin into lp:ubuntuone-credentials
- add-qmlplugin
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | dobey | ||||
Approved revision: | 42 | ||||
Merged at revision: | 32 | ||||
Proposed branch: | lp:~mikemc/ubuntuone-credentials/add-qmlplugin | ||||
Merge into: | lp:ubuntuone-credentials | ||||
Prerequisite: | lp:~mikemc/ubuntuone-credentials/token-tweaks | ||||
Diff against target: |
787 lines (+655/-6) 15 files modified
CMakeLists.txt (+8/-0) libubuntuoneauth/ssoservice.cpp (+1/-1) libubuntuoneauth/ssoservice.h (+1/-1) music-login/ssowizard.cpp (+3/-3) music-login/ssowizard.h (+1/-1) qml-credentials-service/CMakeLists.txt (+26/-0) qml-credentials-service/CredentialsUI.qml (+192/-0) qml-credentials-service/LoginForm.qml (+90/-0) qml-credentials-service/RegisterForm.qml (+102/-0) qml-credentials-service/SuccessScreen.qml (+20/-0) qml-credentials-service/qmldir.template (+3/-0) qml-credentials-service/ubuntuone_credentials_plugin.cpp (+11/-0) qml-credentials-service/ubuntuone_credentials_plugin.h (+16/-0) qml-credentials-service/ubuntuone_credentials_service.cpp (+125/-0) qml-credentials-service/ubuntuone_credentials_service.h (+56/-0) |
||||
To merge this branch: | bzr merge lp:~mikemc/ubuntuone-credentials/add-qmlplugin | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
dobey (community) | Approve | ||
Diego Sarmentero (community) | Approve | ||
Review via email:
|
Commit message
Add QML plugin that wraps login/register and signUrl functionality of libubuntuoneauth, and accompanying QML UI prototype
Description of the change
Add QML plugin that wraps login/register and signUrl functionality of libubuntuoneauth, and accompanying QML UI prototype
The plugin functionality is the main purpose of this branch. The UI is not final, hasn't had design review, and will probably require some refactoring to be useful for its final purpose of being embedded into client apps.
The functionality can be tested by doing the following from a fresh branch:
mkdir build
cd build
cmake -DCMAKE_
make all install
cd ..
LD_LIBRARY_
-------
One question to consider while reviewing:
- Should the name of the QML module be "UbuntuOne" or "something.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
dobey (dobey) wrote : | # |
+set (QML_MODULE_
What exactly is TODO here?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
dobey (dobey) wrote : | # |
99 +find_package(
100 +find_package(
Only one of these needs to be here. After one find_package() call for a Qt5 lib, you can then use the qt5_use_modules() method.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
dobey (dobey) wrote : | # |
10 +set (PLUGIN_VERSION 0.1.0)
11 +set (PLUGIN_SOVERSION 0)
Also, I think these are not needed, as the plug-in is a MODULE and not a normal library?
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mike McCracken (mikemc) wrote : | # |
The last rev removes the unnecessary commands mentioned in the last two comments.
We need to fix the install path / packaging story within the next couple days, so I'd like to suggest that the TODO can stand until the branch that fixes that..
For reference, the TODO reflects the fact that I don't yet know where we should install this thing.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mike McCracken (mikemc) wrote : | # |
rev 42 fixes the install step so that the component is installed into CMAKE_INSTALL_
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mike McCracken (mikemc) wrote : | # |
Updated the MP change description with notes on how to run with new install setup.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
dobey (dobey) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~mikemc/ubuntuone-credentials/add-qmlplugin into lp:ubuntuone-credentials failed. Below is the output from the failed tests.
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'libsecret-1'
-- found libsecret-1, version 0.15
-- checking for module 'oauth'
-- found oauth, version 1.0.1
-- Configuring incomplete, errors occurred!
CMake Warning at /usr/lib/
Could not find a package configuration file provided by "Qt5Quick" with any
of the following names:
Qt5QuickCon
qt5quick-
Add the installation prefix of "Qt5Quick" to CMAKE_PREFIX_PATH or set
"Qt5Quick_DIR" to a directory containing one of the above files. If
"Qt5Quick" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
qml-credentia
CMake Error at /usr/lib/
Can not use "Quick" module which has not yet been found.
Call Stack (most recent call first):
qml-credentia
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~mikemc/ubuntuone-credentials/add-qmlplugin into lp:ubuntuone-credentials failed. Below is the output from the failed tests.
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'libsecret-1'
-- found libsecret-1, version 0.15
-- checking for module 'oauth'
-- found oauth, version 1.0.1
-- Configuring incomplete, errors occurred!
CMake Warning at /usr/lib/
Could not find a package configuration file provided by "Qt5Quick" with any
of the following names:
Qt5QuickCon
qt5quick-
Add the installation prefix of "Qt5Quick" to CMAKE_PREFIX_PATH or set
"Qt5Quick_DIR" to a directory containing one of the above files. If
"Qt5Quick" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
qml-credentia
CMake Error at /usr/lib/
Can not use "Quick" module which has not yet been found.
Call Stack (most recent call first):
qml-credentia
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2013-05-28 21:31:26 +0000 |
3 | +++ CMakeLists.txt 2013-07-11 22:40:31 +0000 |
4 | @@ -15,6 +15,11 @@ |
5 | SET (AUTHUI_LIB_API_VERSION 2.0) |
6 | SET (AUTHUI_LIB_NAME ubuntuoneauthui-${AUTHUI_LIB_API_VERSION}) |
7 | |
8 | +# these names are also used in qml-credentials-service/qmldir, be sure to change them in both places |
9 | +set (QML_MODULE_NAME UbuntuOne) |
10 | +set (PLUGIN_API_VERSION 1.0) |
11 | +set (PLUGIN_NAME UbuntuOneCredentialsPlugin-${PLUGIN_API_VERSION}) |
12 | + |
13 | # Some default CFLAGS |
14 | SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -Wall -Werror -fPIC") |
15 | SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -O2 -g -Wall -Werror -fPIC") |
16 | @@ -23,6 +28,8 @@ |
17 | SET (LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name.") |
18 | SET (LIB_INSTALL_DIR "lib${LIB_SUFFIX}") |
19 | |
20 | +set (QML_MODULE_INSTALL_DIR ${LIB_INSTALL_DIR}/qt5/qml/${QML_MODULE_NAME} ) |
21 | + |
22 | include_directories(${CMAKE_SOURCE_DIR}/libubuntuoneauth |
23 | ${CMAKE_SOURCE_DIR}/libubuntuoneauthui) |
24 | |
25 | @@ -38,6 +45,7 @@ |
26 | add_subdirectory(libubuntuoneauth) |
27 | add_subdirectory(libubuntuoneauthui) |
28 | add_subdirectory(music-login) |
29 | +add_subdirectory(qml-credentials-service) |
30 | |
31 | # We need to add these here which simply depend on other test rules, as |
32 | # CMake doesn't allow defining a "check" rule in multiple places. |
33 | |
34 | === modified file 'libubuntuoneauth/ssoservice.cpp' |
35 | --- libubuntuoneauth/ssoservice.cpp 2013-06-28 23:44:14 +0000 |
36 | +++ libubuntuoneauth/ssoservice.cpp 2013-07-11 22:40:31 +0000 |
37 | @@ -88,7 +88,7 @@ |
38 | |
39 | void SSOService::handleTokenStored() |
40 | { |
41 | - emit credentialsStored(_pendingPing); |
42 | + emit credentialsStored(); |
43 | _pendingPing = Token(); |
44 | } |
45 | |
46 | |
47 | === modified file 'libubuntuoneauth/ssoservice.h' |
48 | --- libubuntuoneauth/ssoservice.h 2013-06-20 19:21:02 +0000 |
49 | +++ libubuntuoneauth/ssoservice.h 2013-07-11 22:40:31 +0000 |
50 | @@ -49,7 +49,7 @@ |
51 | |
52 | signals: |
53 | void credentialsDeleted(); |
54 | - void credentialsStored(const Token& token); |
55 | + void credentialsStored(); |
56 | void credentialsFound(const Token& token); |
57 | void credentialsNotFound(); |
58 | void requestFailed(const ErrorResponse& error); |
59 | |
60 | === modified file 'music-login/ssowizard.cpp' |
61 | --- music-login/ssowizard.cpp 2013-07-02 18:59:41 +0000 |
62 | +++ music-login/ssowizard.cpp 2013-07-11 22:40:31 +0000 |
63 | @@ -81,8 +81,8 @@ |
64 | QObject::connect(&(this->downloader), SIGNAL(fileDownloaded(QString&)), |
65 | this, SLOT(imageDownloaded(QString&))); |
66 | |
67 | - QObject::connect(&(this->_service), SIGNAL(credentialsStored(const Token&)), |
68 | - this, SLOT(accountAuthenticated(Token))); |
69 | + QObject::connect(&(this->_service), SIGNAL(credentialsStored()), |
70 | + this, SLOT(accountAuthenticated())); |
71 | QObject::connect(&(this->_service), SIGNAL(credentialsFound(const Token&)), |
72 | this, SLOT(openUrlAndFinish(Token))); |
73 | |
74 | @@ -142,7 +142,7 @@ |
75 | this->_service.login(email, password); |
76 | } |
77 | |
78 | -void SSOWizard::accountAuthenticated(Token token) |
79 | +void SSOWizard::accountAuthenticated() |
80 | { |
81 | this->_service.getCredentials(); |
82 | } |
83 | |
84 | === modified file 'music-login/ssowizard.h' |
85 | --- music-login/ssowizard.h 2013-07-02 18:59:41 +0000 |
86 | +++ music-login/ssowizard.h 2013-07-11 22:40:31 +0000 |
87 | @@ -67,7 +67,7 @@ |
88 | void registerAndBuy(QString email, QString password, QString name); |
89 | void showPageLogin(); |
90 | |
91 | - void accountAuthenticated(Token); |
92 | + void accountAuthenticated(); |
93 | void openUrlAndFinish(Token); |
94 | void serviceFailed(const ErrorResponse&); |
95 | |
96 | |
97 | === added directory 'qml-credentials-service' |
98 | === added file 'qml-credentials-service/CMakeLists.txt' |
99 | --- qml-credentials-service/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
100 | +++ qml-credentials-service/CMakeLists.txt 2013-07-11 22:40:31 +0000 |
101 | @@ -0,0 +1,26 @@ |
102 | +# Qt5 bits |
103 | +set (CMAKE_INCLUDE_CURRENT_DIR ON) |
104 | +set (CMAKE_AUTOMOC ON) |
105 | +find_package(Qt5Core REQUIRED) |
106 | + |
107 | +file (GLOB CPP_SOURCES *.cpp) |
108 | +file (GLOB QML_SOURCES *.qml) |
109 | + |
110 | +configure_file (qmldir.template qmldir) |
111 | + |
112 | +add_library (${PLUGIN_NAME} MODULE ${CPP_SOURCES}) |
113 | + |
114 | +target_link_libraries (${PLUGIN_NAME} |
115 | + ${AUTH_LIB_NAME} |
116 | +) |
117 | + |
118 | +qt5_use_modules (${PLUGIN_NAME} Core Widgets Quick Qml ) |
119 | + |
120 | +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir DESTINATION ${QML_MODULE_INSTALL_DIR}) |
121 | + |
122 | +install (TARGETS ${PLUGIN_NAME} |
123 | + LIBRARY DESTINATION ${QML_MODULE_INSTALL_DIR} |
124 | + NAMELINK_SKIP |
125 | +) |
126 | + |
127 | +install (FILES ${QML_SOURCES} DESTINATION ${QML_MODULE_INSTALL_DIR}) |
128 | |
129 | === added file 'qml-credentials-service/CredentialsUI.qml' |
130 | --- qml-credentials-service/CredentialsUI.qml 1970-01-01 00:00:00 +0000 |
131 | +++ qml-credentials-service/CredentialsUI.qml 2013-07-11 22:40:31 +0000 |
132 | @@ -0,0 +1,192 @@ |
133 | +import QtQuick 2.0 |
134 | +import Ubuntu.Components 0.1 |
135 | +import UbuntuOne 1.0 |
136 | + |
137 | +Rectangle { |
138 | + id: main |
139 | + width: 400 |
140 | + height: 600 |
141 | + gradient: Gradient { |
142 | + GradientStop { position: 0.0; color: "#863636" } |
143 | + GradientStop { position: 0.5; color: "#5b2235" } |
144 | + GradientStop { position: 1.0; color: "#2b0f21" } |
145 | + } |
146 | + |
147 | + property bool loginActive: true |
148 | + |
149 | + UbuntuOneCredentialsService { |
150 | + id: u1credservice |
151 | + |
152 | + onCredentialsFound: { |
153 | + console.log("Credentials Found"); |
154 | + signUrl("http://server", "GET"); |
155 | + } |
156 | + |
157 | + onLoginOrRegisterSuccess: { |
158 | + console.log(" login success."); |
159 | + signUrl("http://server", "GET"); |
160 | + login_successful(); |
161 | + } |
162 | + |
163 | + |
164 | + onUrlSigned: { |
165 | + console.log("signed url is "+ signedUrl); |
166 | + } |
167 | + |
168 | + onUrlSigningError: { |
169 | + console.log("signing error."); |
170 | + console.log(errorMessage); |
171 | + } |
172 | + |
173 | + onCredentialsNotFound: { |
174 | + console.log("\nCredentials NOT FOUND"); |
175 | + signUrl("http://server", "GET"); // xfail |
176 | + } |
177 | + |
178 | + onLoginOrRegisterError: { |
179 | + console.log("getting credentials failed"); |
180 | + console.log(errorMessage); |
181 | + error(); |
182 | + } |
183 | + } |
184 | + |
185 | + Label { |
186 | + id: title |
187 | + anchors.left: parent.left |
188 | + anchors.top: parent.top |
189 | + anchors.margins: units.gu(1) |
190 | + fontSize: "x-large" |
191 | + color: "#e5d8ce" |
192 | + text: "Ubuntu Sign In" |
193 | + } |
194 | + |
195 | + UbuntuShape { |
196 | + anchors.left: parent.left |
197 | + anchors.top: title.bottom |
198 | + anchors.topMargin: units.gu(3) |
199 | + width: parent.width |
200 | + height: parent.height - y - buttons.height - units.gu(2) |
201 | + |
202 | + LoginForm { |
203 | + id: loginForm |
204 | + x: 0 |
205 | + anchors.top: parent.top |
206 | + width: parent.width |
207 | + |
208 | + Behavior on x { PropertyAnimation { duration: 300 } } |
209 | + } |
210 | + |
211 | + RegisterForm { |
212 | + id: registerForm |
213 | + x: parent.width |
214 | + anchors.top: parent.top |
215 | + width: parent.width |
216 | + |
217 | + Behavior on x { PropertyAnimation { duration: 300 } } |
218 | + } |
219 | + |
220 | + SuccessScreen { |
221 | + id: successScreen |
222 | + x: parent.width |
223 | + anchors.top: parent.top |
224 | + width: parent.width |
225 | + |
226 | + Behavior on x { PropertyAnimation { duration: 300 } } |
227 | + } |
228 | + } |
229 | + |
230 | + Row { |
231 | + id: buttons |
232 | + anchors.left: parent.left |
233 | + anchors.bottom: parent.bottom |
234 | + anchors.margins: units.gu(1) |
235 | + width: parent.width |
236 | + height: units.gu(5) |
237 | + spacing: units.gu(1) |
238 | + |
239 | + Button { |
240 | + id: btnCancel |
241 | + text: "Check existing creds" |
242 | + color: "#1c091a" |
243 | + height: parent.height |
244 | + width: (parent.width / 2) - parent.anchors.margins - parent.spacing |
245 | + onClicked: { |
246 | + console.debug("checking for creds in keyring:"); |
247 | + u1credservice.checkCredentials(); |
248 | + } |
249 | + } |
250 | + Button { |
251 | + id: btnContinue |
252 | + text: "Continue" |
253 | + color: "#cc3300" |
254 | + height: parent.height |
255 | + width: (parent.width / 2) - parent.anchors.margins - parent.spacing |
256 | + |
257 | + onClicked: { |
258 | + console.log("Continue clicked") |
259 | + process_form(); |
260 | + } |
261 | + |
262 | + } |
263 | + } |
264 | + |
265 | + Rectangle { |
266 | + id: loading |
267 | + anchors.fill: parent |
268 | + opacity: 0.6 |
269 | + visible: false |
270 | + |
271 | + ActivityIndicator { |
272 | + id: activity |
273 | + anchors.centerIn: parent |
274 | + running: true |
275 | + } |
276 | + } |
277 | + |
278 | + function switch_form(){ |
279 | + if(loginActive){ |
280 | + registerForm.new_switch.checked = loginForm.new_switch.checked; |
281 | + loginForm.x = -main.width; |
282 | + registerForm.x = 0; |
283 | + loginActive = false; |
284 | + }else{ |
285 | + loginForm.new_switch.checked = registerForm.new_switch.checked; |
286 | + loginForm.x = 0; |
287 | + registerForm.x = main.width; |
288 | + loginActive = true; |
289 | + } |
290 | + } |
291 | + |
292 | + function process_form(){ |
293 | + if(loginActive){ |
294 | + loading.visible = true; |
295 | + var email = loginForm.email; |
296 | + var password = loginForm.password; |
297 | + u1credservice.login(email, password); |
298 | + }else{ |
299 | + loading.visible = true; |
300 | + var email = registerForm.email; |
301 | + var password = registerForm.password; |
302 | + var display_name = registerForm.display_name; |
303 | + u1credservice.registerUser(email, password, display_name); |
304 | + } |
305 | + } |
306 | + |
307 | + function login_successful(){ |
308 | + if(loginActive){ |
309 | + loginForm.x = -main.width; |
310 | + successScreen.x = 0; |
311 | + btnContinue.visible = false; |
312 | + loading.visible = false; |
313 | + }else{ |
314 | + registerForm.x = -main.width; |
315 | + successScreen.x = 0; |
316 | + btnContinue.visible = false; |
317 | + loading.visible = false; |
318 | + } |
319 | + } |
320 | + |
321 | + function error(){ |
322 | + loading.visible = false; |
323 | + } |
324 | +} |
325 | |
326 | === added file 'qml-credentials-service/LoginForm.qml' |
327 | --- qml-credentials-service/LoginForm.qml 1970-01-01 00:00:00 +0000 |
328 | +++ qml-credentials-service/LoginForm.qml 2013-07-11 22:40:31 +0000 |
329 | @@ -0,0 +1,90 @@ |
330 | +import QtQuick 2.0 |
331 | +import Ubuntu.Components 0.1 |
332 | + |
333 | +Rectangle { |
334 | + color: "transparent" |
335 | + |
336 | + property alias new_switch: newSwitch |
337 | + property alias email: txtEmail.text |
338 | + property alias password: txtPassword.text |
339 | + |
340 | + Label { |
341 | + id: subtitle |
342 | + anchors.left: parent.left |
343 | + anchors.top: parent.top |
344 | + anchors.topMargin: units.gu(1) |
345 | + anchors.leftMargin: units.gu(2) |
346 | + fontSize: "large" |
347 | + color: "white" |
348 | + text: "Please type your email:" |
349 | + } |
350 | + |
351 | + Grid { |
352 | + anchors.fill: parent |
353 | + anchors.topMargin: units.gu(8) |
354 | + anchors.margins: units.gu(2) |
355 | + columns: 2 |
356 | + spacing: units.gu(2) |
357 | + |
358 | + Label{ |
359 | + text: "Your email" |
360 | + color: "white" |
361 | + fontSize: "large" |
362 | + } |
363 | + TextField { |
364 | + id: txtEmail |
365 | + placeholderText: "Your email" |
366 | + } |
367 | + |
368 | + Label{ |
369 | + text: " " |
370 | + } |
371 | + Label{ |
372 | + text: "Enter the email address you use to log into your Ubuntu One account. If you don't have an account yet, don't worry we'll create one for you." |
373 | + color: "white" |
374 | + fontSize: "small" |
375 | + width: txtEmail.width |
376 | + wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
377 | + } |
378 | + |
379 | + Label{ |
380 | + text: "New Customer" |
381 | + color: "white" |
382 | + fontSize: "large" |
383 | + } |
384 | + Switch { |
385 | + id: newSwitch |
386 | + checked: false |
387 | + |
388 | + onCheckedChanged: { |
389 | + main.switch_form(); |
390 | + } |
391 | + } |
392 | + |
393 | + Label{ |
394 | + text: "Your Password" |
395 | + color: "white" |
396 | + fontSize: "large" |
397 | + } |
398 | + TextField { |
399 | + id: txtPassword |
400 | + placeholderText: "Your password" |
401 | + echoMode: TextInput.Password |
402 | + } |
403 | + |
404 | + Label{ |
405 | + text: " " |
406 | + } |
407 | + Label{ |
408 | + text: '<a href="https://login.ubuntu.com/+forgot_password"><span style="color: #dd4814;">Forgotten your password?</span></a>' |
409 | + textFormat: Text.RichText |
410 | + color: "white" |
411 | + fontSize: "small" |
412 | + width: txtEmail.width |
413 | + wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
414 | + onLinkActivated: { Qt.openUrlExternally(link); } |
415 | + } |
416 | + |
417 | + } |
418 | + |
419 | +} |
420 | |
421 | === added file 'qml-credentials-service/RegisterForm.qml' |
422 | --- qml-credentials-service/RegisterForm.qml 1970-01-01 00:00:00 +0000 |
423 | +++ qml-credentials-service/RegisterForm.qml 2013-07-11 22:40:31 +0000 |
424 | @@ -0,0 +1,102 @@ |
425 | +import QtQuick 2.0 |
426 | +import Ubuntu.Components 0.1 |
427 | + |
428 | +Rectangle { |
429 | + color: "transparent" |
430 | + |
431 | + property alias new_switch: newSwitch |
432 | + property alias email: txtEmail.text |
433 | + property alias password: txtPassword.text |
434 | + property alias display_name: txtName.text |
435 | + |
436 | + Label { |
437 | + id: subtitle |
438 | + anchors.left: parent.left |
439 | + anchors.top: parent.top |
440 | + anchors.topMargin: units.gu(1) |
441 | + anchors.leftMargin: units.gu(2) |
442 | + fontSize: "large" |
443 | + color: "white" |
444 | + text: "Please tell us your name and choose a password" |
445 | + width: parent.width |
446 | + wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
447 | + } |
448 | + |
449 | + Grid { |
450 | + anchors.fill: parent |
451 | + anchors.topMargin: units.gu(10) |
452 | + anchors.margins: units.gu(1) |
453 | + columns: 2 |
454 | + spacing: units.gu(1) |
455 | + |
456 | + Label{ |
457 | + text: "Your email" |
458 | + color: "white" |
459 | + fontSize: "large" |
460 | + } |
461 | + TextField { |
462 | + id: txtEmail |
463 | + placeholderText: "Your email" |
464 | + } |
465 | + |
466 | + Label{ |
467 | + text: "Your name" |
468 | + color: "white" |
469 | + fontSize: "large" |
470 | + } |
471 | + TextField { |
472 | + id: txtName |
473 | + placeholderText: "Your name" |
474 | + } |
475 | + |
476 | + Label{ |
477 | + id: lblChoose |
478 | + text: "Choose a password" |
479 | + color: "white" |
480 | + fontSize: "large" |
481 | + } |
482 | + TextField { |
483 | + id: txtPassword |
484 | + placeholderText: "At list 8 characters" |
485 | + echoMode: TextInput.Password |
486 | + } |
487 | + |
488 | + Label{ |
489 | + text: "Confirm password" |
490 | + color: "white" |
491 | + fontSize: "large" |
492 | + } |
493 | + TextField { |
494 | + id: txtConfirmPassword |
495 | + placeholderText: "Re-type your password" |
496 | + echoMode: TextInput.Password |
497 | + } |
498 | + |
499 | + Label{ |
500 | + text: "New Customer" |
501 | + color: "white" |
502 | + fontSize: "large" |
503 | + } |
504 | + Switch { |
505 | + id: newSwitch |
506 | + checked: false |
507 | + |
508 | + onCheckedChanged: { |
509 | + main.switch_form(); |
510 | + } |
511 | + } |
512 | + |
513 | + Label{ |
514 | + text: "I agree to the Ubuntu One Terms and Conditions" |
515 | + color: "white" |
516 | + fontSize: "medium" |
517 | + width: lblChoose.width |
518 | + wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
519 | + } |
520 | + CheckBox { |
521 | + checked: true |
522 | + } |
523 | + |
524 | + } |
525 | + |
526 | +} |
527 | |
528 | === added file 'qml-credentials-service/SuccessScreen.qml' |
529 | --- qml-credentials-service/SuccessScreen.qml 1970-01-01 00:00:00 +0000 |
530 | +++ qml-credentials-service/SuccessScreen.qml 2013-07-11 22:40:31 +0000 |
531 | @@ -0,0 +1,20 @@ |
532 | +import QtQuick 2.0 |
533 | +import Ubuntu.Components 0.1 |
534 | + |
535 | +Rectangle { |
536 | + color: "transparent" |
537 | + |
538 | + Rectangle{ |
539 | + anchors.fill: parent |
540 | + anchors.leftMargin: units.gu(4) |
541 | + anchors.topMargin: units.gu(20) |
542 | + Label { |
543 | + font.bold: true |
544 | + fontSize: "x-large" |
545 | + width: parent.width |
546 | + wrapMode: Text.WrapAtWordBoundaryOrAnywhere |
547 | + color: "#dd4814" |
548 | + text: "LOGIN SUCCESSFUL!" |
549 | + } |
550 | + } |
551 | +} |
552 | |
553 | === added file 'qml-credentials-service/qmldir.template' |
554 | --- qml-credentials-service/qmldir.template 1970-01-01 00:00:00 +0000 |
555 | +++ qml-credentials-service/qmldir.template 2013-07-11 22:40:31 +0000 |
556 | @@ -0,0 +1,3 @@ |
557 | +module @QML_MODULE_NAME@ |
558 | +plugin @PLUGIN_NAME@ |
559 | +typeinfo UbuntuOneCredentials.qmltypes |
560 | |
561 | === added file 'qml-credentials-service/ubuntuone_credentials_plugin.cpp' |
562 | --- qml-credentials-service/ubuntuone_credentials_plugin.cpp 1970-01-01 00:00:00 +0000 |
563 | +++ qml-credentials-service/ubuntuone_credentials_plugin.cpp 2013-07-11 22:40:31 +0000 |
564 | @@ -0,0 +1,11 @@ |
565 | +#include "ubuntuone_credentials_plugin.h" |
566 | +#include "ubuntuone_credentials_service.h" |
567 | + |
568 | +#include <qqml.h> |
569 | + |
570 | +void UbuntuOneCredentialsPlugin::registerTypes(const char *uri) |
571 | +{ |
572 | + qmlRegisterType<UbuntuOneCredentialsService>(uri, 1, 0, "UbuntuOneCredentialsService"); |
573 | +} |
574 | + |
575 | + |
576 | |
577 | === added file 'qml-credentials-service/ubuntuone_credentials_plugin.h' |
578 | --- qml-credentials-service/ubuntuone_credentials_plugin.h 1970-01-01 00:00:00 +0000 |
579 | +++ qml-credentials-service/ubuntuone_credentials_plugin.h 2013-07-11 22:40:31 +0000 |
580 | @@ -0,0 +1,16 @@ |
581 | +#ifndef UBUNTUONECREDENTIALS_PLUGIN_H |
582 | +#define UBUNTUONECREDENTIALS_PLUGIN_H |
583 | + |
584 | +#include <QQmlExtensionPlugin> |
585 | + |
586 | +class UbuntuOneCredentialsPlugin : public QQmlExtensionPlugin |
587 | +{ |
588 | + Q_OBJECT |
589 | + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
590 | + |
591 | +public: |
592 | + void registerTypes(const char *uri); |
593 | +}; |
594 | + |
595 | +#endif // UBUNTUONECREDENTIALS_PLUGIN_H |
596 | + |
597 | |
598 | === added file 'qml-credentials-service/ubuntuone_credentials_service.cpp' |
599 | --- qml-credentials-service/ubuntuone_credentials_service.cpp 1970-01-01 00:00:00 +0000 |
600 | +++ qml-credentials-service/ubuntuone_credentials_service.cpp 2013-07-11 22:40:31 +0000 |
601 | @@ -0,0 +1,125 @@ |
602 | +#include "ubuntuone_credentials_service.h" |
603 | +#include <QDebug> |
604 | + |
605 | +UbuntuOneCredentialsService::UbuntuOneCredentialsService(QQuickItem *parent): |
606 | + QQuickItem(parent) |
607 | +{ |
608 | + QObject::connect(&(this->_service), SIGNAL(credentialsFound(Token)), |
609 | + this, SLOT(handleCredentialsFound(Token))); |
610 | + QObject::connect(&(this->_service), SIGNAL(credentialsNotFound()), |
611 | + this, SLOT(handleCredentialsNotFound())); |
612 | + QObject::connect(&(this->_service), SIGNAL(credentialsStored()), |
613 | + this, SLOT(handleCredentialsStored())); |
614 | + |
615 | + QObject::connect(&(this->_service), SIGNAL(requestFailed(ErrorResponse)), |
616 | + this, SLOT(handleError(ErrorResponse))); |
617 | +} |
618 | + |
619 | +UbuntuOneCredentialsService::~UbuntuOneCredentialsService() |
620 | +{ |
621 | +} |
622 | + |
623 | + |
624 | +// public API (Q_INVOKABLE) |
625 | + |
626 | +void UbuntuOneCredentialsService::checkCredentials() |
627 | +{ |
628 | + Q_ASSERT(_state == IDLE); |
629 | + _state = CHECK; |
630 | + _service.getCredentials(); |
631 | +} |
632 | + |
633 | +void UbuntuOneCredentialsService::login(QString email, QString password) |
634 | +{ |
635 | + Q_ASSERT(_state == IDLE); |
636 | + _state = LOGIN; |
637 | + _service.login(email, password); |
638 | +} |
639 | + |
640 | +void UbuntuOneCredentialsService::registerUser(QString email, QString password, QString name) |
641 | +{ |
642 | + Q_ASSERT(_state == IDLE); |
643 | + _state = REGISTER; |
644 | + _service.registerUser(email, password, name); |
645 | +} |
646 | + |
647 | +// calling signUrl with no credentials stored will emit an error |
648 | +void UbuntuOneCredentialsService::signUrl(const QString url, const QString method, bool asQuery) |
649 | +{ |
650 | + Q_ASSERT(_state == IDLE); |
651 | + _state = SIGN; |
652 | + _sign_url = url; |
653 | + _sign_method = method; |
654 | + _sign_asQuery = asQuery; |
655 | + _service.getCredentials(); |
656 | +} |
657 | + |
658 | +// signal handlers |
659 | + |
660 | +// credentials found is only sent by _service.getCredentials(), not login or register |
661 | +void UbuntuOneCredentialsService::handleCredentialsFound(const Token& token) |
662 | +{ |
663 | + QString signedUrl; |
664 | + |
665 | + qDebug() << "in UbuntuOneCredentialsService::handleCredentialsFound"; |
666 | + |
667 | + // set state before emitting any signals, as signals happen 'after' transition |
668 | + CredentialsServiceState calledState = _state; |
669 | + _state = IDLE; |
670 | + |
671 | + switch(calledState){ |
672 | + case CHECK: |
673 | + emit credentialsFound(); |
674 | + break; |
675 | + case SIGN: |
676 | + signedUrl = token.signUrl(_sign_url, _sign_method, _sign_asQuery); |
677 | + emit urlSigned(signedUrl); |
678 | + break; |
679 | + default: |
680 | + qDebug() << "UbuntuOneCredentialsService did not expect credentialsFound in state " << calledState; |
681 | + } |
682 | + |
683 | +} |
684 | + |
685 | +void UbuntuOneCredentialsService::handleCredentialsNotFound() |
686 | +{ |
687 | + qDebug() << "in UbuntuOneCredentialsService::handleCredentialsNotFound"; |
688 | + |
689 | + // set state before emitting any signals, as signals happen 'after' transition |
690 | + CredentialsServiceState calledState = _state; |
691 | + _state = IDLE; |
692 | + |
693 | + switch(calledState){ |
694 | + case CHECK: |
695 | + emit credentialsNotFound(); |
696 | + break; |
697 | + case SIGN: |
698 | + emit urlSigningError(QString("Attempt to sign without credentials in keyring")); |
699 | + break; |
700 | + default: |
701 | + qDebug() << "UbuntuOneCredentialsService did not expect credentialsNotFound in state " << calledState; |
702 | + } |
703 | +} |
704 | + |
705 | +// Credentials stored is signaled when the u1 ping is done after login/register |
706 | +void UbuntuOneCredentialsService::handleCredentialsStored() |
707 | +{ |
708 | + qDebug() << "in UbuntuOneCredentialsService::handleCredentialsStored"; |
709 | + |
710 | + // set state before emitting any signals, as signals happen 'after' transition |
711 | + CredentialsServiceState calledState = _state; |
712 | + _state = IDLE; |
713 | + |
714 | + if (calledState == LOGIN || calledState == REGISTER){ |
715 | + emit loginOrRegisterSuccess(); |
716 | + }else{ |
717 | + qDebug() << "UbuntuOneCredentialsService did not expect credentialsStored in state " << calledState; |
718 | + } |
719 | +} |
720 | + |
721 | +void UbuntuOneCredentialsService::handleError(const ErrorResponse& error) |
722 | +{ |
723 | + qDebug() << "in handleError\n"; |
724 | + _state = IDLE; |
725 | + emit loginOrRegisterError(error.message()); |
726 | +} |
727 | |
728 | === added file 'qml-credentials-service/ubuntuone_credentials_service.h' |
729 | --- qml-credentials-service/ubuntuone_credentials_service.h 1970-01-01 00:00:00 +0000 |
730 | +++ qml-credentials-service/ubuntuone_credentials_service.h 2013-07-11 22:40:31 +0000 |
731 | @@ -0,0 +1,56 @@ |
732 | +#ifndef UBUNTUONE_CREDENTIALS_SERVICE_H |
733 | +#define UBUNTUONE_CREDENTIALS_SERVICE_H |
734 | + |
735 | +#include <QQuickItem> |
736 | +#include "ssoservice.h" |
737 | + |
738 | +using namespace UbuntuOne; |
739 | + |
740 | +enum CredentialsServiceState{ |
741 | + IDLE = 0, |
742 | + CHECK, |
743 | + LOGIN, |
744 | + REGISTER, |
745 | + SIGN |
746 | +}; |
747 | + |
748 | +class UbuntuOneCredentialsService : public QQuickItem |
749 | +{ |
750 | + Q_OBJECT |
751 | + Q_DISABLE_COPY(UbuntuOneCredentialsService) |
752 | + |
753 | +public: |
754 | + UbuntuOneCredentialsService(QQuickItem *parent = 0); |
755 | + ~UbuntuOneCredentialsService(); |
756 | + |
757 | + Q_INVOKABLE void checkCredentials(); |
758 | + Q_INVOKABLE void login(QString email, QString password); |
759 | + Q_INVOKABLE void registerUser(QString email, QString password, QString name); |
760 | + Q_INVOKABLE void signUrl(QString url, QString method, bool asQuery = false); |
761 | + |
762 | +signals: |
763 | + void credentialsFound(); |
764 | + void credentialsNotFound(); |
765 | + void loginOrRegisterSuccess(); |
766 | + void loginOrRegisterError(QString errorMessage); |
767 | + void urlSigned(QString signedUrl); |
768 | + void urlSigningError(QString errorMessage); |
769 | + |
770 | +private slots: |
771 | + void handleCredentialsFound(const Token&); |
772 | + void handleCredentialsNotFound(); |
773 | + void handleCredentialsStored(); |
774 | + void handleError(const ErrorResponse&); |
775 | + |
776 | +private: |
777 | + SSOService _service; |
778 | + CredentialsServiceState _state; |
779 | + QString _sign_url; |
780 | + QString _sign_method; |
781 | + bool _sign_asQuery; |
782 | +}; |
783 | + |
784 | +QML_DECLARE_TYPE(UbuntuOneCredentialsService) |
785 | + |
786 | +#endif // UBUNTUONE_CREDENTIALS_SERVICE_H |
787 | + |
+1
I understand the UI of this is in early stages and waiting for some definitions from Design, but just a reminder when that come, the Login and Register screen should be tested in different form factors and maybe improve a little bit the proportions between the elements. Also if would probably be useful to have the grids inside a Flickable element for situations where the screen is small or the phone/tablet is rotated.