Merge lp:~mikemc/ubuntuone-credentials/add-qmlplugin into lp:ubuntuone-credentials

Proposed by Mike McCracken
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
Reviewer Review Type Date Requested Status
dobey (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+172183@code.launchpad.net

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_INSTALL_PREFIX:PATH=/tmp/installtemp ..
make all install
cd ..
LD_LIBRARY_PATH=/tmp/installtemp/lib/ qmlscene -I /tmp/installtemp/lib/qt5/qml/ qml-credentials-service/CredentialsUI.qml

-------

One question to consider while reviewing:

- Should the name of the QML module be "UbuntuOne" or "something.ubuntu.com" as per http://qt-project.org/doc/qt-5.0/qtqml/qtqml-modules-identifiedmodules.html ? (if we use reverse DNS, what should 'something' be? one? login?

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

+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.

review: Approve
Revision history for this message
dobey (dobey) wrote :

+set (QML_MODULE_INSTALL_DIR ${QML_MODULE_NAME} ) # TODO

What exactly is TODO here?

review: Needs Fixing
Revision history for this message
dobey (dobey) wrote :

99 +find_package(Qt5Core REQUIRED)
100 +find_package(Qt5Widgets REQUIRED)

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.

Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
Mike McCracken (mikemc) wrote :

rev 42 fixes the install step so that the component is installed into CMAKE_INSTALL_PREFIX/LIB_INSTALL_DIR/qt5/qml , and the built plugin module has correct rpath entries to link to libubuntuoneauth when installed.

Revision history for this message
Mike McCracken (mikemc) wrote :

Updated the MP change description with notes on how to run with new install setup.

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
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/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:237 (find_package):
  Could not find a package configuration file provided by "Qt5Quick" with any
  of the following names:

    Qt5QuickConfig.cmake
    qt5quick-config.cmake

  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-credentials-service/CMakeLists.txt:17 (qt5_use_modules)

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:239 (message):
  Can not use "Quick" module which has not yet been found.
Call Stack (most recent call first):
  qml-credentials-service/CMakeLists.txt:17 (qt5_use_modules)

Revision history for this message
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/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:237 (find_package):
  Could not find a package configuration file provided by "Qt5Quick" with any
  of the following names:

    Qt5QuickConfig.cmake
    qt5quick-config.cmake

  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-credentials-service/CMakeLists.txt:17 (qt5_use_modules)

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:239 (message):
  Can not use "Quick" module which has not yet been found.
Call Stack (most recent call first):
  qml-credentials-service/CMakeLists.txt:17 (qt5_use_modules)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-05-28 21:31:26 +0000
+++ CMakeLists.txt 2013-07-11 22:40:31 +0000
@@ -15,6 +15,11 @@
15SET (AUTHUI_LIB_API_VERSION 2.0)15SET (AUTHUI_LIB_API_VERSION 2.0)
16SET (AUTHUI_LIB_NAME ubuntuoneauthui-${AUTHUI_LIB_API_VERSION})16SET (AUTHUI_LIB_NAME ubuntuoneauthui-${AUTHUI_LIB_API_VERSION})
1717
18# these names are also used in qml-credentials-service/qmldir, be sure to change them in both places
19set (QML_MODULE_NAME UbuntuOne)
20set (PLUGIN_API_VERSION 1.0)
21set (PLUGIN_NAME UbuntuOneCredentialsPlugin-${PLUGIN_API_VERSION})
22
18# Some default CFLAGS23# Some default CFLAGS
19SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -Wall -Werror -fPIC")24SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -Wall -Werror -fPIC")
20SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -O2 -g -Wall -Werror -fPIC")25SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -O2 -g -Wall -Werror -fPIC")
@@ -23,6 +28,8 @@
23SET (LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name.")28SET (LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name.")
24SET (LIB_INSTALL_DIR "lib${LIB_SUFFIX}")29SET (LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
2530
31set (QML_MODULE_INSTALL_DIR ${LIB_INSTALL_DIR}/qt5/qml/${QML_MODULE_NAME} )
32
26include_directories(${CMAKE_SOURCE_DIR}/libubuntuoneauth33include_directories(${CMAKE_SOURCE_DIR}/libubuntuoneauth
27 ${CMAKE_SOURCE_DIR}/libubuntuoneauthui)34 ${CMAKE_SOURCE_DIR}/libubuntuoneauthui)
2835
@@ -38,6 +45,7 @@
38add_subdirectory(libubuntuoneauth)45add_subdirectory(libubuntuoneauth)
39add_subdirectory(libubuntuoneauthui)46add_subdirectory(libubuntuoneauthui)
40add_subdirectory(music-login)47add_subdirectory(music-login)
48add_subdirectory(qml-credentials-service)
4149
42# We need to add these here which simply depend on other test rules, as50# We need to add these here which simply depend on other test rules, as
43# CMake doesn't allow defining a "check" rule in multiple places.51# CMake doesn't allow defining a "check" rule in multiple places.
4452
=== modified file 'libubuntuoneauth/ssoservice.cpp'
--- libubuntuoneauth/ssoservice.cpp 2013-06-28 23:44:14 +0000
+++ libubuntuoneauth/ssoservice.cpp 2013-07-11 22:40:31 +0000
@@ -88,7 +88,7 @@
8888
89 void SSOService::handleTokenStored()89 void SSOService::handleTokenStored()
90 {90 {
91 emit credentialsStored(_pendingPing); 91 emit credentialsStored();
92 _pendingPing = Token();92 _pendingPing = Token();
93 }93 }
9494
9595
=== modified file 'libubuntuoneauth/ssoservice.h'
--- libubuntuoneauth/ssoservice.h 2013-06-20 19:21:02 +0000
+++ libubuntuoneauth/ssoservice.h 2013-07-11 22:40:31 +0000
@@ -49,7 +49,7 @@
4949
50 signals:50 signals:
51 void credentialsDeleted();51 void credentialsDeleted();
52 void credentialsStored(const Token& token);52 void credentialsStored();
53 void credentialsFound(const Token& token);53 void credentialsFound(const Token& token);
54 void credentialsNotFound();54 void credentialsNotFound();
55 void requestFailed(const ErrorResponse& error);55 void requestFailed(const ErrorResponse& error);
5656
=== modified file 'music-login/ssowizard.cpp'
--- music-login/ssowizard.cpp 2013-07-02 18:59:41 +0000
+++ music-login/ssowizard.cpp 2013-07-11 22:40:31 +0000
@@ -81,8 +81,8 @@
81 QObject::connect(&(this->downloader), SIGNAL(fileDownloaded(QString&)),81 QObject::connect(&(this->downloader), SIGNAL(fileDownloaded(QString&)),
82 this, SLOT(imageDownloaded(QString&)));82 this, SLOT(imageDownloaded(QString&)));
8383
84 QObject::connect(&(this->_service), SIGNAL(credentialsStored(const Token&)),84 QObject::connect(&(this->_service), SIGNAL(credentialsStored()),
85 this, SLOT(accountAuthenticated(Token)));85 this, SLOT(accountAuthenticated()));
86 QObject::connect(&(this->_service), SIGNAL(credentialsFound(const Token&)),86 QObject::connect(&(this->_service), SIGNAL(credentialsFound(const Token&)),
87 this, SLOT(openUrlAndFinish(Token)));87 this, SLOT(openUrlAndFinish(Token)));
8888
@@ -142,7 +142,7 @@
142 this->_service.login(email, password);142 this->_service.login(email, password);
143}143}
144144
145void SSOWizard::accountAuthenticated(Token token)145void SSOWizard::accountAuthenticated()
146{146{
147 this->_service.getCredentials();147 this->_service.getCredentials();
148}148}
149149
=== modified file 'music-login/ssowizard.h'
--- music-login/ssowizard.h 2013-07-02 18:59:41 +0000
+++ music-login/ssowizard.h 2013-07-11 22:40:31 +0000
@@ -67,7 +67,7 @@
67 void registerAndBuy(QString email, QString password, QString name);67 void registerAndBuy(QString email, QString password, QString name);
68 void showPageLogin();68 void showPageLogin();
6969
70 void accountAuthenticated(Token);70 void accountAuthenticated();
71 void openUrlAndFinish(Token);71 void openUrlAndFinish(Token);
72 void serviceFailed(const ErrorResponse&);72 void serviceFailed(const ErrorResponse&);
7373
7474
=== added directory 'qml-credentials-service'
=== added file 'qml-credentials-service/CMakeLists.txt'
--- qml-credentials-service/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/CMakeLists.txt 2013-07-11 22:40:31 +0000
@@ -0,0 +1,26 @@
1# Qt5 bits
2set (CMAKE_INCLUDE_CURRENT_DIR ON)
3set (CMAKE_AUTOMOC ON)
4find_package(Qt5Core REQUIRED)
5
6file (GLOB CPP_SOURCES *.cpp)
7file (GLOB QML_SOURCES *.qml)
8
9configure_file (qmldir.template qmldir)
10
11add_library (${PLUGIN_NAME} MODULE ${CPP_SOURCES})
12
13target_link_libraries (${PLUGIN_NAME}
14 ${AUTH_LIB_NAME}
15)
16
17qt5_use_modules (${PLUGIN_NAME} Core Widgets Quick Qml )
18
19install (FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir DESTINATION ${QML_MODULE_INSTALL_DIR})
20
21install (TARGETS ${PLUGIN_NAME}
22 LIBRARY DESTINATION ${QML_MODULE_INSTALL_DIR}
23 NAMELINK_SKIP
24)
25
26install (FILES ${QML_SOURCES} DESTINATION ${QML_MODULE_INSTALL_DIR})
027
=== added file 'qml-credentials-service/CredentialsUI.qml'
--- qml-credentials-service/CredentialsUI.qml 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/CredentialsUI.qml 2013-07-11 22:40:31 +0000
@@ -0,0 +1,192 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3import UbuntuOne 1.0
4
5Rectangle {
6 id: main
7 width: 400
8 height: 600
9 gradient: Gradient {
10 GradientStop { position: 0.0; color: "#863636" }
11 GradientStop { position: 0.5; color: "#5b2235" }
12 GradientStop { position: 1.0; color: "#2b0f21" }
13 }
14
15 property bool loginActive: true
16
17 UbuntuOneCredentialsService {
18 id: u1credservice
19
20 onCredentialsFound: {
21 console.log("Credentials Found");
22 signUrl("http://server", "GET");
23 }
24
25 onLoginOrRegisterSuccess: {
26 console.log(" login success.");
27 signUrl("http://server", "GET");
28 login_successful();
29 }
30
31
32 onUrlSigned: {
33 console.log("signed url is "+ signedUrl);
34 }
35
36 onUrlSigningError: {
37 console.log("signing error.");
38 console.log(errorMessage);
39 }
40
41 onCredentialsNotFound: {
42 console.log("\nCredentials NOT FOUND");
43 signUrl("http://server", "GET"); // xfail
44 }
45
46 onLoginOrRegisterError: {
47 console.log("getting credentials failed");
48 console.log(errorMessage);
49 error();
50 }
51 }
52
53 Label {
54 id: title
55 anchors.left: parent.left
56 anchors.top: parent.top
57 anchors.margins: units.gu(1)
58 fontSize: "x-large"
59 color: "#e5d8ce"
60 text: "Ubuntu Sign In"
61 }
62
63 UbuntuShape {
64 anchors.left: parent.left
65 anchors.top: title.bottom
66 anchors.topMargin: units.gu(3)
67 width: parent.width
68 height: parent.height - y - buttons.height - units.gu(2)
69
70 LoginForm {
71 id: loginForm
72 x: 0
73 anchors.top: parent.top
74 width: parent.width
75
76 Behavior on x { PropertyAnimation { duration: 300 } }
77 }
78
79 RegisterForm {
80 id: registerForm
81 x: parent.width
82 anchors.top: parent.top
83 width: parent.width
84
85 Behavior on x { PropertyAnimation { duration: 300 } }
86 }
87
88 SuccessScreen {
89 id: successScreen
90 x: parent.width
91 anchors.top: parent.top
92 width: parent.width
93
94 Behavior on x { PropertyAnimation { duration: 300 } }
95 }
96 }
97
98 Row {
99 id: buttons
100 anchors.left: parent.left
101 anchors.bottom: parent.bottom
102 anchors.margins: units.gu(1)
103 width: parent.width
104 height: units.gu(5)
105 spacing: units.gu(1)
106
107 Button {
108 id: btnCancel
109 text: "Check existing creds"
110 color: "#1c091a"
111 height: parent.height
112 width: (parent.width / 2) - parent.anchors.margins - parent.spacing
113 onClicked: {
114 console.debug("checking for creds in keyring:");
115 u1credservice.checkCredentials();
116 }
117 }
118 Button {
119 id: btnContinue
120 text: "Continue"
121 color: "#cc3300"
122 height: parent.height
123 width: (parent.width / 2) - parent.anchors.margins - parent.spacing
124
125 onClicked: {
126 console.log("Continue clicked")
127 process_form();
128 }
129
130 }
131 }
132
133 Rectangle {
134 id: loading
135 anchors.fill: parent
136 opacity: 0.6
137 visible: false
138
139 ActivityIndicator {
140 id: activity
141 anchors.centerIn: parent
142 running: true
143 }
144 }
145
146 function switch_form(){
147 if(loginActive){
148 registerForm.new_switch.checked = loginForm.new_switch.checked;
149 loginForm.x = -main.width;
150 registerForm.x = 0;
151 loginActive = false;
152 }else{
153 loginForm.new_switch.checked = registerForm.new_switch.checked;
154 loginForm.x = 0;
155 registerForm.x = main.width;
156 loginActive = true;
157 }
158 }
159
160 function process_form(){
161 if(loginActive){
162 loading.visible = true;
163 var email = loginForm.email;
164 var password = loginForm.password;
165 u1credservice.login(email, password);
166 }else{
167 loading.visible = true;
168 var email = registerForm.email;
169 var password = registerForm.password;
170 var display_name = registerForm.display_name;
171 u1credservice.registerUser(email, password, display_name);
172 }
173 }
174
175 function login_successful(){
176 if(loginActive){
177 loginForm.x = -main.width;
178 successScreen.x = 0;
179 btnContinue.visible = false;
180 loading.visible = false;
181 }else{
182 registerForm.x = -main.width;
183 successScreen.x = 0;
184 btnContinue.visible = false;
185 loading.visible = false;
186 }
187 }
188
189 function error(){
190 loading.visible = false;
191 }
192}
0193
=== added file 'qml-credentials-service/LoginForm.qml'
--- qml-credentials-service/LoginForm.qml 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/LoginForm.qml 2013-07-11 22:40:31 +0000
@@ -0,0 +1,90 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3
4Rectangle {
5 color: "transparent"
6
7 property alias new_switch: newSwitch
8 property alias email: txtEmail.text
9 property alias password: txtPassword.text
10
11 Label {
12 id: subtitle
13 anchors.left: parent.left
14 anchors.top: parent.top
15 anchors.topMargin: units.gu(1)
16 anchors.leftMargin: units.gu(2)
17 fontSize: "large"
18 color: "white"
19 text: "Please type your email:"
20 }
21
22 Grid {
23 anchors.fill: parent
24 anchors.topMargin: units.gu(8)
25 anchors.margins: units.gu(2)
26 columns: 2
27 spacing: units.gu(2)
28
29 Label{
30 text: "Your email"
31 color: "white"
32 fontSize: "large"
33 }
34 TextField {
35 id: txtEmail
36 placeholderText: "Your email"
37 }
38
39 Label{
40 text: " "
41 }
42 Label{
43 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."
44 color: "white"
45 fontSize: "small"
46 width: txtEmail.width
47 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
48 }
49
50 Label{
51 text: "New Customer"
52 color: "white"
53 fontSize: "large"
54 }
55 Switch {
56 id: newSwitch
57 checked: false
58
59 onCheckedChanged: {
60 main.switch_form();
61 }
62 }
63
64 Label{
65 text: "Your Password"
66 color: "white"
67 fontSize: "large"
68 }
69 TextField {
70 id: txtPassword
71 placeholderText: "Your password"
72 echoMode: TextInput.Password
73 }
74
75 Label{
76 text: " "
77 }
78 Label{
79 text: '<a href="https://login.ubuntu.com/+forgot_password"><span style="color: #dd4814;">Forgotten your password?</span></a>'
80 textFormat: Text.RichText
81 color: "white"
82 fontSize: "small"
83 width: txtEmail.width
84 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
85 onLinkActivated: { Qt.openUrlExternally(link); }
86 }
87
88 }
89
90}
091
=== added file 'qml-credentials-service/RegisterForm.qml'
--- qml-credentials-service/RegisterForm.qml 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/RegisterForm.qml 2013-07-11 22:40:31 +0000
@@ -0,0 +1,102 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3
4Rectangle {
5 color: "transparent"
6
7 property alias new_switch: newSwitch
8 property alias email: txtEmail.text
9 property alias password: txtPassword.text
10 property alias display_name: txtName.text
11
12 Label {
13 id: subtitle
14 anchors.left: parent.left
15 anchors.top: parent.top
16 anchors.topMargin: units.gu(1)
17 anchors.leftMargin: units.gu(2)
18 fontSize: "large"
19 color: "white"
20 text: "Please tell us your name and choose a password"
21 width: parent.width
22 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
23 }
24
25 Grid {
26 anchors.fill: parent
27 anchors.topMargin: units.gu(10)
28 anchors.margins: units.gu(1)
29 columns: 2
30 spacing: units.gu(1)
31
32 Label{
33 text: "Your email"
34 color: "white"
35 fontSize: "large"
36 }
37 TextField {
38 id: txtEmail
39 placeholderText: "Your email"
40 }
41
42 Label{
43 text: "Your name"
44 color: "white"
45 fontSize: "large"
46 }
47 TextField {
48 id: txtName
49 placeholderText: "Your name"
50 }
51
52 Label{
53 id: lblChoose
54 text: "Choose a password"
55 color: "white"
56 fontSize: "large"
57 }
58 TextField {
59 id: txtPassword
60 placeholderText: "At list 8 characters"
61 echoMode: TextInput.Password
62 }
63
64 Label{
65 text: "Confirm password"
66 color: "white"
67 fontSize: "large"
68 }
69 TextField {
70 id: txtConfirmPassword
71 placeholderText: "Re-type your password"
72 echoMode: TextInput.Password
73 }
74
75 Label{
76 text: "New Customer"
77 color: "white"
78 fontSize: "large"
79 }
80 Switch {
81 id: newSwitch
82 checked: false
83
84 onCheckedChanged: {
85 main.switch_form();
86 }
87 }
88
89 Label{
90 text: "I agree to the Ubuntu One Terms and Conditions"
91 color: "white"
92 fontSize: "medium"
93 width: lblChoose.width
94 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
95 }
96 CheckBox {
97 checked: true
98 }
99
100 }
101
102}
0103
=== added file 'qml-credentials-service/SuccessScreen.qml'
--- qml-credentials-service/SuccessScreen.qml 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/SuccessScreen.qml 2013-07-11 22:40:31 +0000
@@ -0,0 +1,20 @@
1import QtQuick 2.0
2import Ubuntu.Components 0.1
3
4Rectangle {
5 color: "transparent"
6
7 Rectangle{
8 anchors.fill: parent
9 anchors.leftMargin: units.gu(4)
10 anchors.topMargin: units.gu(20)
11 Label {
12 font.bold: true
13 fontSize: "x-large"
14 width: parent.width
15 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
16 color: "#dd4814"
17 text: "LOGIN SUCCESSFUL!"
18 }
19 }
20}
021
=== added file 'qml-credentials-service/qmldir.template'
--- qml-credentials-service/qmldir.template 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/qmldir.template 2013-07-11 22:40:31 +0000
@@ -0,0 +1,3 @@
1module @QML_MODULE_NAME@
2plugin @PLUGIN_NAME@
3typeinfo UbuntuOneCredentials.qmltypes
04
=== added file 'qml-credentials-service/ubuntuone_credentials_plugin.cpp'
--- qml-credentials-service/ubuntuone_credentials_plugin.cpp 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/ubuntuone_credentials_plugin.cpp 2013-07-11 22:40:31 +0000
@@ -0,0 +1,11 @@
1#include "ubuntuone_credentials_plugin.h"
2#include "ubuntuone_credentials_service.h"
3
4#include <qqml.h>
5
6void UbuntuOneCredentialsPlugin::registerTypes(const char *uri)
7{
8 qmlRegisterType<UbuntuOneCredentialsService>(uri, 1, 0, "UbuntuOneCredentialsService");
9}
10
11
012
=== added file 'qml-credentials-service/ubuntuone_credentials_plugin.h'
--- qml-credentials-service/ubuntuone_credentials_plugin.h 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/ubuntuone_credentials_plugin.h 2013-07-11 22:40:31 +0000
@@ -0,0 +1,16 @@
1#ifndef UBUNTUONECREDENTIALS_PLUGIN_H
2#define UBUNTUONECREDENTIALS_PLUGIN_H
3
4#include <QQmlExtensionPlugin>
5
6class UbuntuOneCredentialsPlugin : public QQmlExtensionPlugin
7{
8 Q_OBJECT
9 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
10
11public:
12 void registerTypes(const char *uri);
13};
14
15#endif // UBUNTUONECREDENTIALS_PLUGIN_H
16
017
=== added file 'qml-credentials-service/ubuntuone_credentials_service.cpp'
--- qml-credentials-service/ubuntuone_credentials_service.cpp 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/ubuntuone_credentials_service.cpp 2013-07-11 22:40:31 +0000
@@ -0,0 +1,125 @@
1#include "ubuntuone_credentials_service.h"
2#include <QDebug>
3
4UbuntuOneCredentialsService::UbuntuOneCredentialsService(QQuickItem *parent):
5 QQuickItem(parent)
6{
7 QObject::connect(&(this->_service), SIGNAL(credentialsFound(Token)),
8 this, SLOT(handleCredentialsFound(Token)));
9 QObject::connect(&(this->_service), SIGNAL(credentialsNotFound()),
10 this, SLOT(handleCredentialsNotFound()));
11 QObject::connect(&(this->_service), SIGNAL(credentialsStored()),
12 this, SLOT(handleCredentialsStored()));
13
14 QObject::connect(&(this->_service), SIGNAL(requestFailed(ErrorResponse)),
15 this, SLOT(handleError(ErrorResponse)));
16}
17
18UbuntuOneCredentialsService::~UbuntuOneCredentialsService()
19{
20}
21
22
23// public API (Q_INVOKABLE)
24
25void UbuntuOneCredentialsService::checkCredentials()
26{
27 Q_ASSERT(_state == IDLE);
28 _state = CHECK;
29 _service.getCredentials();
30}
31
32void UbuntuOneCredentialsService::login(QString email, QString password)
33{
34 Q_ASSERT(_state == IDLE);
35 _state = LOGIN;
36 _service.login(email, password);
37}
38
39void UbuntuOneCredentialsService::registerUser(QString email, QString password, QString name)
40{
41 Q_ASSERT(_state == IDLE);
42 _state = REGISTER;
43 _service.registerUser(email, password, name);
44}
45
46// calling signUrl with no credentials stored will emit an error
47void UbuntuOneCredentialsService::signUrl(const QString url, const QString method, bool asQuery)
48{
49 Q_ASSERT(_state == IDLE);
50 _state = SIGN;
51 _sign_url = url;
52 _sign_method = method;
53 _sign_asQuery = asQuery;
54 _service.getCredentials();
55}
56
57// signal handlers
58
59// credentials found is only sent by _service.getCredentials(), not login or register
60void UbuntuOneCredentialsService::handleCredentialsFound(const Token& token)
61{
62 QString signedUrl;
63
64 qDebug() << "in UbuntuOneCredentialsService::handleCredentialsFound";
65
66 // set state before emitting any signals, as signals happen 'after' transition
67 CredentialsServiceState calledState = _state;
68 _state = IDLE;
69
70 switch(calledState){
71 case CHECK:
72 emit credentialsFound();
73 break;
74 case SIGN:
75 signedUrl = token.signUrl(_sign_url, _sign_method, _sign_asQuery);
76 emit urlSigned(signedUrl);
77 break;
78 default:
79 qDebug() << "UbuntuOneCredentialsService did not expect credentialsFound in state " << calledState;
80 }
81
82}
83
84void UbuntuOneCredentialsService::handleCredentialsNotFound()
85{
86 qDebug() << "in UbuntuOneCredentialsService::handleCredentialsNotFound";
87
88 // set state before emitting any signals, as signals happen 'after' transition
89 CredentialsServiceState calledState = _state;
90 _state = IDLE;
91
92 switch(calledState){
93 case CHECK:
94 emit credentialsNotFound();
95 break;
96 case SIGN:
97 emit urlSigningError(QString("Attempt to sign without credentials in keyring"));
98 break;
99 default:
100 qDebug() << "UbuntuOneCredentialsService did not expect credentialsNotFound in state " << calledState;
101 }
102}
103
104// Credentials stored is signaled when the u1 ping is done after login/register
105void UbuntuOneCredentialsService::handleCredentialsStored()
106{
107 qDebug() << "in UbuntuOneCredentialsService::handleCredentialsStored";
108
109 // set state before emitting any signals, as signals happen 'after' transition
110 CredentialsServiceState calledState = _state;
111 _state = IDLE;
112
113 if (calledState == LOGIN || calledState == REGISTER){
114 emit loginOrRegisterSuccess();
115 }else{
116 qDebug() << "UbuntuOneCredentialsService did not expect credentialsStored in state " << calledState;
117 }
118}
119
120void UbuntuOneCredentialsService::handleError(const ErrorResponse& error)
121{
122 qDebug() << "in handleError\n";
123 _state = IDLE;
124 emit loginOrRegisterError(error.message());
125}
0126
=== added file 'qml-credentials-service/ubuntuone_credentials_service.h'
--- qml-credentials-service/ubuntuone_credentials_service.h 1970-01-01 00:00:00 +0000
+++ qml-credentials-service/ubuntuone_credentials_service.h 2013-07-11 22:40:31 +0000
@@ -0,0 +1,56 @@
1#ifndef UBUNTUONE_CREDENTIALS_SERVICE_H
2#define UBUNTUONE_CREDENTIALS_SERVICE_H
3
4#include <QQuickItem>
5#include "ssoservice.h"
6
7using namespace UbuntuOne;
8
9enum CredentialsServiceState{
10 IDLE = 0,
11 CHECK,
12 LOGIN,
13 REGISTER,
14 SIGN
15};
16
17class UbuntuOneCredentialsService : public QQuickItem
18{
19 Q_OBJECT
20 Q_DISABLE_COPY(UbuntuOneCredentialsService)
21
22public:
23 UbuntuOneCredentialsService(QQuickItem *parent = 0);
24 ~UbuntuOneCredentialsService();
25
26 Q_INVOKABLE void checkCredentials();
27 Q_INVOKABLE void login(QString email, QString password);
28 Q_INVOKABLE void registerUser(QString email, QString password, QString name);
29 Q_INVOKABLE void signUrl(QString url, QString method, bool asQuery = false);
30
31signals:
32 void credentialsFound();
33 void credentialsNotFound();
34 void loginOrRegisterSuccess();
35 void loginOrRegisterError(QString errorMessage);
36 void urlSigned(QString signedUrl);
37 void urlSigningError(QString errorMessage);
38
39private slots:
40 void handleCredentialsFound(const Token&);
41 void handleCredentialsNotFound();
42 void handleCredentialsStored();
43 void handleError(const ErrorResponse&);
44
45private:
46 SSOService _service;
47 CredentialsServiceState _state;
48 QString _sign_url;
49 QString _sign_method;
50 bool _sign_asQuery;
51};
52
53QML_DECLARE_TYPE(UbuntuOneCredentialsService)
54
55#endif // UBUNTUONE_CREDENTIALS_SERVICE_H
56

Subscribers

People subscribed via source and target branches

to all changes: