Merge lp:~mardy/ubuntu-system-settings-online-accounts/qml-dialog into lp:~online-accounts/ubuntu-system-settings-online-accounts/master
- qml-dialog
- Merge into master
Proposed by
Alberto Mardegan
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 203 | ||||||||
Proposed branch: | lp:~mardy/ubuntu-system-settings-online-accounts/qml-dialog | ||||||||
Merge into: | lp:~online-accounts/ubuntu-system-settings-online-accounts/master | ||||||||
Diff against target: |
588 lines (+492/-2) 7 files modified
debian/control (+1/-0) online-accounts-ui/dialog-request.cpp (+286/-0) online-accounts-ui/dialog-request.h (+54/-0) online-accounts-ui/online-accounts-ui.pro (+3/-0) online-accounts-ui/qml/SignOnUiDialog.qml (+115/-0) online-accounts-ui/signonui-request.cpp (+32/-2) online-accounts-ui/ui.qrc (+1/-0) |
||||||||
To merge this branch: | bzr merge lp:~mardy/ubuntu-system-settings-online-accounts/qml-dialog | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Barth (community) | Approve | ||
Review via email: mp+237970@code.launchpad.net |
Commit message
Implement QML dialog for password queries
Authentication plugins can request SignOnUi to show a login form to the user. Support for this action is implemented by unity7's signon-ui, but was never implemented in this project.
Description of the change
Implement QML dialog for password queries
Authentication plugins can request SignOnUi to show a login form to the user. Support for this action is implemented by unity7's signon-ui, but was never implemented in this project.
Test case:
ubuntu-
To post a comment you must log in.
Revision history for this message
David Barth (dbarth) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2014-10-08 07:12:09 +0000 | |||
3 | +++ debian/control 2014-10-10 13:24:04 +0000 | |||
4 | @@ -6,6 +6,7 @@ | |||
5 | 6 | pkg-config, | 6 | pkg-config, |
6 | 7 | python3:any, | 7 | python3:any, |
7 | 8 | libaccounts-qt5-dev (>= 1.13), | 8 | libaccounts-qt5-dev (>= 1.13), |
8 | 9 | libapparmor-dev, | ||
9 | 9 | libclick-0.4-dev, | 10 | libclick-0.4-dev, |
10 | 10 | libmirclient-dev [!powerpc !ppc64 !ppc64el], | 11 | libmirclient-dev [!powerpc !ppc64 !ppc64el], |
11 | 11 | libnotify-dev, | 12 | libnotify-dev, |
12 | 12 | 13 | ||
13 | === added file 'online-accounts-ui/dialog-request.cpp' | |||
14 | --- online-accounts-ui/dialog-request.cpp 1970-01-01 00:00:00 +0000 | |||
15 | +++ online-accounts-ui/dialog-request.cpp 2014-10-10 13:24:04 +0000 | |||
16 | @@ -0,0 +1,286 @@ | |||
17 | 1 | /* | ||
18 | 2 | * This file is part of online-accounts-ui | ||
19 | 3 | * | ||
20 | 4 | * Copyright (C) 2014 Canonical Ltd. | ||
21 | 5 | * | ||
22 | 6 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
23 | 7 | * | ||
24 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
25 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
26 | 10 | * by the Free Software Foundation. | ||
27 | 11 | * | ||
28 | 12 | * This program is distributed in the hope that it will be useful, but | ||
29 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
30 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
31 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
32 | 16 | * | ||
33 | 17 | * You should have received a copy of the GNU General Public License along | ||
34 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
35 | 19 | */ | ||
36 | 20 | |||
37 | 21 | #include "dialog-request.h" | ||
38 | 22 | |||
39 | 23 | #include "debug.h" | ||
40 | 24 | #include "dialog.h" | ||
41 | 25 | #include "globals.h" | ||
42 | 26 | #include "i18n.h" | ||
43 | 27 | |||
44 | 28 | #include <OnlineAccountsPlugin/request-handler.h> | ||
45 | 29 | #include <QDir> | ||
46 | 30 | #include <QQmlContext> | ||
47 | 31 | #include <QQmlEngine> | ||
48 | 32 | #include <SignOn/uisessiondata_priv.h> | ||
49 | 33 | |||
50 | 34 | using namespace SignOnUi; | ||
51 | 35 | |||
52 | 36 | /* These fields are temporarily defined here; they'll be eventually moved to | ||
53 | 37 | * signond's include files. */ | ||
54 | 38 | #define SSOUI_KEY_USERNAME_TEXT QLatin1String("UserNameText") | ||
55 | 39 | #define SSOUI_KEY_PASSWORD_TEXT QLatin1String("PasswordText") | ||
56 | 40 | #define SSOUI_KEY_REGISTER_URL QLatin1String("RegisterUrl") | ||
57 | 41 | #define SSOUI_KEY_REGISTER_TEXT QLatin1String("RegisterText") | ||
58 | 42 | #define SSOUI_KEY_LOGIN_TEXT QLatin1String("LoginText") | ||
59 | 43 | |||
60 | 44 | namespace SignOnUi { | ||
61 | 45 | |||
62 | 46 | class DialogRequestPrivate: public QObject | ||
63 | 47 | { | ||
64 | 48 | Q_OBJECT | ||
65 | 49 | Q_DECLARE_PUBLIC(DialogRequest) | ||
66 | 50 | Q_PROPERTY(QString title READ title CONSTANT) | ||
67 | 51 | Q_PROPERTY(QString userName READ userName WRITE setUserName \ | ||
68 | 52 | NOTIFY userNameChanged) | ||
69 | 53 | Q_PROPERTY(QString password READ password WRITE setPassword \ | ||
70 | 54 | NOTIFY passwordChanged) | ||
71 | 55 | Q_PROPERTY(QString userNameText READ userNameText CONSTANT) | ||
72 | 56 | Q_PROPERTY(QString passwordText READ passwordText CONSTANT) | ||
73 | 57 | Q_PROPERTY(QString message READ message CONSTANT) | ||
74 | 58 | Q_PROPERTY(bool queryUserName READ queryUserName CONSTANT) | ||
75 | 59 | Q_PROPERTY(bool queryPassword READ queryPassword CONSTANT) | ||
76 | 60 | Q_PROPERTY(QUrl forgotPasswordUrl READ forgotPasswordUrl CONSTANT) | ||
77 | 61 | Q_PROPERTY(QString forgotPasswordText READ forgotPasswordText CONSTANT) | ||
78 | 62 | Q_PROPERTY(QUrl registerUrl READ registerUrl CONSTANT) | ||
79 | 63 | Q_PROPERTY(QString registerText READ registerText CONSTANT) | ||
80 | 64 | Q_PROPERTY(QString loginText READ loginText CONSTANT) | ||
81 | 65 | |||
82 | 66 | public: | ||
83 | 67 | DialogRequestPrivate(DialogRequest *request); | ||
84 | 68 | ~DialogRequestPrivate(); | ||
85 | 69 | |||
86 | 70 | void start(); | ||
87 | 71 | |||
88 | 72 | QString title() const { return m_title; } | ||
89 | 73 | void setUserName(const QString &userName); | ||
90 | 74 | QString userName() const { return m_userName; } | ||
91 | 75 | void setPassword(const QString &password); | ||
92 | 76 | QString password() const { return m_password; } | ||
93 | 77 | QString userNameText() const { return m_userNameText; } | ||
94 | 78 | QString passwordText() const { return m_passwordText; } | ||
95 | 79 | QString message() const { return m_message; } | ||
96 | 80 | bool queryUserName() const { return m_queryUsername; } | ||
97 | 81 | bool queryPassword() const { return m_queryPassword; } | ||
98 | 82 | QUrl forgotPasswordUrl() const { return m_forgotPasswordUrl; } | ||
99 | 83 | QString forgotPasswordText() const { return m_forgotPasswordText; } | ||
100 | 84 | QUrl registerUrl() const { return m_registerUrl; } | ||
101 | 85 | QString registerText() const { return m_registerText; } | ||
102 | 86 | QString loginText() const { return m_loginText; } | ||
103 | 87 | |||
104 | 88 | public Q_SLOTS: | ||
105 | 89 | void cancel(); | ||
106 | 90 | void accept(); | ||
107 | 91 | |||
108 | 92 | Q_SIGNALS: | ||
109 | 93 | void userNameChanged(); | ||
110 | 94 | void passwordChanged(); | ||
111 | 95 | |||
112 | 96 | private Q_SLOTS: | ||
113 | 97 | void onFinished(); | ||
114 | 98 | |||
115 | 99 | private: | ||
116 | 100 | void closeView(); | ||
117 | 101 | |||
118 | 102 | private: | ||
119 | 103 | Dialog *m_dialog; | ||
120 | 104 | QString m_title; | ||
121 | 105 | QString m_userName; | ||
122 | 106 | QString m_password; | ||
123 | 107 | QString m_userNameText; | ||
124 | 108 | QString m_passwordText; | ||
125 | 109 | QString m_message; | ||
126 | 110 | bool m_queryUsername; | ||
127 | 111 | bool m_queryPassword; | ||
128 | 112 | QUrl m_forgotPasswordUrl; | ||
129 | 113 | QString m_forgotPasswordText; | ||
130 | 114 | QUrl m_registerUrl; | ||
131 | 115 | QString m_registerText; | ||
132 | 116 | QString m_loginText; | ||
133 | 117 | mutable DialogRequest *q_ptr; | ||
134 | 118 | }; | ||
135 | 119 | |||
136 | 120 | } // namespace | ||
137 | 121 | |||
138 | 122 | DialogRequestPrivate::DialogRequestPrivate(DialogRequest *request): | ||
139 | 123 | QObject(request), | ||
140 | 124 | m_dialog(0), | ||
141 | 125 | m_queryUsername(false), | ||
142 | 126 | m_queryPassword(false), | ||
143 | 127 | q_ptr(request) | ||
144 | 128 | { | ||
145 | 129 | const QVariantMap ¶ms = q_ptr->parameters(); | ||
146 | 130 | |||
147 | 131 | if (params.contains(SSOUI_KEY_TITLE)) { | ||
148 | 132 | m_title = params[SSOUI_KEY_TITLE].toString(); | ||
149 | 133 | } else if (params.contains(SSOUI_KEY_CAPTION)) { | ||
150 | 134 | m_title = OnlineAccountsUi::_("Web authentication for %1", | ||
151 | 135 | SIGNONUI_I18N_DOMAIN). | ||
152 | 136 | arg(params[SSOUI_KEY_CAPTION].toString()); | ||
153 | 137 | } else { | ||
154 | 138 | m_title = OnlineAccountsUi::_("Web authentication", | ||
155 | 139 | SIGNONUI_I18N_DOMAIN); | ||
156 | 140 | } | ||
157 | 141 | |||
158 | 142 | m_queryUsername = params.value(SSOUI_KEY_QUERYUSERNAME, false).toBool(); | ||
159 | 143 | m_userName = params.value(SSOUI_KEY_USERNAME).toString(); | ||
160 | 144 | m_userNameText = params.value(SSOUI_KEY_USERNAME_TEXT).toString(); | ||
161 | 145 | if (m_userNameText.isEmpty()) { | ||
162 | 146 | m_userNameText = OnlineAccountsUi::_("Username:", | ||
163 | 147 | SIGNONUI_I18N_DOMAIN); | ||
164 | 148 | } | ||
165 | 149 | |||
166 | 150 | m_queryPassword = params.value(SSOUI_KEY_QUERYPASSWORD, false).toBool(); | ||
167 | 151 | m_password = params.value(SSOUI_KEY_PASSWORD).toString(); | ||
168 | 152 | m_passwordText = params.value(SSOUI_KEY_PASSWORD_TEXT).toString(); | ||
169 | 153 | if (m_passwordText.isEmpty()) { | ||
170 | 154 | m_passwordText = OnlineAccountsUi::_("Password:", | ||
171 | 155 | SIGNONUI_I18N_DOMAIN); | ||
172 | 156 | } | ||
173 | 157 | |||
174 | 158 | |||
175 | 159 | m_message = params.value(SSOUI_KEY_MESSAGE).toString(); | ||
176 | 160 | |||
177 | 161 | m_forgotPasswordUrl = | ||
178 | 162 | QUrl(params.value(SSOUI_KEY_FORGOTPASSWORDURL).toString()); | ||
179 | 163 | m_forgotPasswordText = params.value(SSOUI_KEY_FORGOTPASSWORD).toString(); | ||
180 | 164 | |||
181 | 165 | m_registerUrl = | ||
182 | 166 | QUrl(params.value(SSOUI_KEY_REGISTER_URL).toString()); | ||
183 | 167 | m_registerText = params.value(SSOUI_KEY_REGISTER_TEXT).toString(); | ||
184 | 168 | |||
185 | 169 | m_loginText = params.value(SSOUI_KEY_LOGIN_TEXT).toString(); | ||
186 | 170 | if (m_loginText.isEmpty()) { | ||
187 | 171 | m_loginText = OnlineAccountsUi::_("Sign in"); | ||
188 | 172 | } | ||
189 | 173 | } | ||
190 | 174 | |||
191 | 175 | DialogRequestPrivate::~DialogRequestPrivate() | ||
192 | 176 | { | ||
193 | 177 | closeView(); | ||
194 | 178 | delete m_dialog; | ||
195 | 179 | } | ||
196 | 180 | |||
197 | 181 | void DialogRequestPrivate::start() | ||
198 | 182 | { | ||
199 | 183 | Q_Q(DialogRequest); | ||
200 | 184 | |||
201 | 185 | const QVariantMap ¶ms = q->parameters(); | ||
202 | 186 | DEBUG() << params; | ||
203 | 187 | |||
204 | 188 | if (!q->hasHandler()) { | ||
205 | 189 | m_dialog = new Dialog; | ||
206 | 190 | m_dialog->setTitle(m_title); | ||
207 | 191 | |||
208 | 192 | QObject::connect(m_dialog, SIGNAL(finished(int)), | ||
209 | 193 | this, SLOT(onFinished())); | ||
210 | 194 | |||
211 | 195 | m_dialog->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR); | ||
212 | 196 | m_dialog->rootContext()->setContextProperty("request", this); | ||
213 | 197 | m_dialog->setSource(QUrl("qrc:/qml/SignOnUiDialog.qml")); | ||
214 | 198 | q->setWindow(m_dialog); | ||
215 | 199 | } else { | ||
216 | 200 | DEBUG() << "Setting request on handler"; | ||
217 | 201 | q->handler()->setRequest(this); | ||
218 | 202 | } | ||
219 | 203 | } | ||
220 | 204 | |||
221 | 205 | void DialogRequestPrivate::accept() | ||
222 | 206 | { | ||
223 | 207 | DEBUG() << "User accepted"; | ||
224 | 208 | onFinished(); | ||
225 | 209 | } | ||
226 | 210 | |||
227 | 211 | void DialogRequestPrivate::cancel() | ||
228 | 212 | { | ||
229 | 213 | Q_Q(DialogRequest); | ||
230 | 214 | |||
231 | 215 | DEBUG() << "User requested to cancel"; | ||
232 | 216 | q->setCanceled(); | ||
233 | 217 | closeView(); | ||
234 | 218 | } | ||
235 | 219 | |||
236 | 220 | void DialogRequestPrivate::setUserName(const QString &userName) | ||
237 | 221 | { | ||
238 | 222 | if (userName == m_userName) return; | ||
239 | 223 | m_userName = userName; | ||
240 | 224 | Q_EMIT userNameChanged(); | ||
241 | 225 | } | ||
242 | 226 | |||
243 | 227 | void DialogRequestPrivate::setPassword(const QString &password) | ||
244 | 228 | { | ||
245 | 229 | if (password == m_password) return; | ||
246 | 230 | m_password = password; | ||
247 | 231 | Q_EMIT passwordChanged(); | ||
248 | 232 | } | ||
249 | 233 | |||
250 | 234 | void DialogRequestPrivate::onFinished() | ||
251 | 235 | { | ||
252 | 236 | Q_Q(DialogRequest); | ||
253 | 237 | |||
254 | 238 | DEBUG() << "Dialog closed"; | ||
255 | 239 | |||
256 | 240 | QVariantMap reply; | ||
257 | 241 | |||
258 | 242 | if (m_queryUsername) { | ||
259 | 243 | reply[SSOUI_KEY_USERNAME] = m_userName; | ||
260 | 244 | } | ||
261 | 245 | if (m_queryPassword) { | ||
262 | 246 | reply[SSOUI_KEY_PASSWORD] = m_password; | ||
263 | 247 | } | ||
264 | 248 | |||
265 | 249 | closeView(); | ||
266 | 250 | |||
267 | 251 | q->setResult(reply); | ||
268 | 252 | } | ||
269 | 253 | |||
270 | 254 | void DialogRequestPrivate::closeView() | ||
271 | 255 | { | ||
272 | 256 | Q_Q(DialogRequest); | ||
273 | 257 | |||
274 | 258 | if (q->hasHandler()) { | ||
275 | 259 | q->handler()->setRequest(0); | ||
276 | 260 | } else if (m_dialog) { | ||
277 | 261 | m_dialog->close(); | ||
278 | 262 | } | ||
279 | 263 | } | ||
280 | 264 | |||
281 | 265 | DialogRequest::DialogRequest(int id, | ||
282 | 266 | const QString &clientProfile, | ||
283 | 267 | const QVariantMap ¶meters, | ||
284 | 268 | QObject *parent): | ||
285 | 269 | Request(id, clientProfile, parameters, parent), | ||
286 | 270 | d_ptr(new DialogRequestPrivate(this)) | ||
287 | 271 | { | ||
288 | 272 | } | ||
289 | 273 | |||
290 | 274 | DialogRequest::~DialogRequest() | ||
291 | 275 | { | ||
292 | 276 | } | ||
293 | 277 | |||
294 | 278 | void DialogRequest::start() | ||
295 | 279 | { | ||
296 | 280 | Q_D(DialogRequest); | ||
297 | 281 | |||
298 | 282 | Request::start(); | ||
299 | 283 | d->start(); | ||
300 | 284 | } | ||
301 | 285 | |||
302 | 286 | #include "dialog-request.moc" | ||
303 | 0 | 287 | ||
304 | === added file 'online-accounts-ui/dialog-request.h' | |||
305 | --- online-accounts-ui/dialog-request.h 1970-01-01 00:00:00 +0000 | |||
306 | +++ online-accounts-ui/dialog-request.h 2014-10-10 13:24:04 +0000 | |||
307 | @@ -0,0 +1,54 @@ | |||
308 | 1 | /* | ||
309 | 2 | * This file is part of online-accounts-ui | ||
310 | 3 | * | ||
311 | 4 | * Copyright (C) 2014 Canonical Ltd. | ||
312 | 5 | * | ||
313 | 6 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
314 | 7 | * | ||
315 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
316 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
317 | 10 | * by the Free Software Foundation. | ||
318 | 11 | * | ||
319 | 12 | * This program is distributed in the hope that it will be useful, but | ||
320 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
321 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
322 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
323 | 16 | * | ||
324 | 17 | * You should have received a copy of the GNU General Public License along | ||
325 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
326 | 19 | */ | ||
327 | 20 | |||
328 | 21 | #ifndef SIGNON_UI_DIALOG_REQUEST_H | ||
329 | 22 | #define SIGNON_UI_DIALOG_REQUEST_H | ||
330 | 23 | |||
331 | 24 | #include "signonui-request.h" | ||
332 | 25 | |||
333 | 26 | #include <QObject> | ||
334 | 27 | |||
335 | 28 | namespace SignOnUi { | ||
336 | 29 | |||
337 | 30 | class DialogRequestPrivate; | ||
338 | 31 | |||
339 | 32 | class DialogRequest: public Request | ||
340 | 33 | { | ||
341 | 34 | Q_OBJECT | ||
342 | 35 | |||
343 | 36 | public: | ||
344 | 37 | explicit DialogRequest(int id, | ||
345 | 38 | const QString &clientProfile, | ||
346 | 39 | const QVariantMap ¶meters, | ||
347 | 40 | QObject *parent = 0); | ||
348 | 41 | ~DialogRequest(); | ||
349 | 42 | |||
350 | 43 | // reimplemented virtual methods | ||
351 | 44 | void start(); | ||
352 | 45 | |||
353 | 46 | private: | ||
354 | 47 | DialogRequestPrivate *d_ptr; | ||
355 | 48 | Q_DECLARE_PRIVATE(DialogRequest) | ||
356 | 49 | }; | ||
357 | 50 | |||
358 | 51 | } // namespace | ||
359 | 52 | |||
360 | 53 | #endif // SIGNON_UI_DIALOG_REQUEST_H | ||
361 | 54 | |||
362 | 0 | 55 | ||
363 | === modified file 'online-accounts-ui/online-accounts-ui.pro' | |||
364 | --- online-accounts-ui/online-accounts-ui.pro 2014-10-09 12:24:45 +0000 | |||
365 | +++ online-accounts-ui/online-accounts-ui.pro 2014-10-10 13:24:04 +0000 | |||
366 | @@ -17,6 +17,7 @@ | |||
367 | 17 | 17 | ||
368 | 18 | PKGCONFIG += \ | 18 | PKGCONFIG += \ |
369 | 19 | accounts-qt5 \ | 19 | accounts-qt5 \ |
370 | 20 | libapparmor \ | ||
371 | 20 | libnotify \ | 21 | libnotify \ |
372 | 21 | libsignon-qt5 \ | 22 | libsignon-qt5 \ |
373 | 22 | signon-plugins-common | 23 | signon-plugins-common |
374 | @@ -44,6 +45,7 @@ | |||
375 | 44 | browser-request.cpp \ | 45 | browser-request.cpp \ |
376 | 45 | debug.cpp \ | 46 | debug.cpp \ |
377 | 46 | dialog.cpp \ | 47 | dialog.cpp \ |
378 | 48 | dialog-request.cpp \ | ||
379 | 47 | i18n.cpp \ | 49 | i18n.cpp \ |
380 | 48 | ipc.cpp \ | 50 | ipc.cpp \ |
381 | 49 | main.cpp \ | 51 | main.cpp \ |
382 | @@ -59,6 +61,7 @@ | |||
383 | 59 | browser-request.h \ | 61 | browser-request.h \ |
384 | 60 | debug.h \ | 62 | debug.h \ |
385 | 61 | dialog.h \ | 63 | dialog.h \ |
386 | 64 | dialog-request.h \ | ||
387 | 62 | i18n.h \ | 65 | i18n.h \ |
388 | 63 | ipc.h \ | 66 | ipc.h \ |
389 | 64 | notification.h \ | 67 | notification.h \ |
390 | 65 | 68 | ||
391 | === added file 'online-accounts-ui/qml/SignOnUiDialog.qml' | |||
392 | --- online-accounts-ui/qml/SignOnUiDialog.qml 1970-01-01 00:00:00 +0000 | |||
393 | +++ online-accounts-ui/qml/SignOnUiDialog.qml 2014-10-10 13:24:04 +0000 | |||
394 | @@ -0,0 +1,115 @@ | |||
395 | 1 | import QtQuick 2.0 | ||
396 | 2 | import Ubuntu.Components 0.1 | ||
397 | 3 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
398 | 4 | import Ubuntu.OnlineAccounts.Plugin 1.0 | ||
399 | 5 | |||
400 | 6 | MainView { | ||
401 | 7 | id: root | ||
402 | 8 | |||
403 | 9 | property var signonRequest: request | ||
404 | 10 | |||
405 | 11 | width: units.gu(60) | ||
406 | 12 | height: units.gu(90) | ||
407 | 13 | |||
408 | 14 | Page { | ||
409 | 15 | title: signonRequest.title | ||
410 | 16 | |||
411 | 17 | Column { | ||
412 | 18 | id: loginForm | ||
413 | 19 | anchors.left: parent.left | ||
414 | 20 | anchors.right: parent.right | ||
415 | 21 | |||
416 | 22 | ListItem.Caption { | ||
417 | 23 | visible: signonRequest.message !== "" | ||
418 | 24 | text: signonRequest.message | ||
419 | 25 | } | ||
420 | 26 | |||
421 | 27 | Label { | ||
422 | 28 | id: userNameLabel | ||
423 | 29 | visible: signonRequest.queryUserName | ||
424 | 30 | text: signonRequest.userNameText | ||
425 | 31 | } | ||
426 | 32 | |||
427 | 33 | TextField { | ||
428 | 34 | id: userNameField | ||
429 | 35 | visible: signonRequest.queryUserName | ||
430 | 36 | text: signonRequest.userName | ||
431 | 37 | onTextChanged: signonRequest.userName = text | ||
432 | 38 | } | ||
433 | 39 | |||
434 | 40 | Column { | ||
435 | 41 | anchors.left: parent.left | ||
436 | 42 | anchors.right: parent.right | ||
437 | 43 | visible: signonRequest.queryPassword | ||
438 | 44 | |||
439 | 45 | Label { | ||
440 | 46 | id: passwordLabel | ||
441 | 47 | text: signonRequest.passwordText | ||
442 | 48 | } | ||
443 | 49 | |||
444 | 50 | TextField { | ||
445 | 51 | id: passwordField | ||
446 | 52 | text: signonRequest.password | ||
447 | 53 | echoMode: TextInput.Password | ||
448 | 54 | onTextChanged: signonRequest.password = text | ||
449 | 55 | Keys.onReturnPressed: signonRequest.accept() | ||
450 | 56 | } | ||
451 | 57 | Label { | ||
452 | 58 | visible: signonRequest.forgotPasswordUrl.toString() !== "" | ||
453 | 59 | text: "<a href=\"" + signonRequest.forgotPasswordUrl + "\">" + | ||
454 | 60 | signonRequest.forgotPasswordText + "</a>" | ||
455 | 61 | } | ||
456 | 62 | } | ||
457 | 63 | } | ||
458 | 64 | |||
459 | 65 | Item { | ||
460 | 66 | anchors.left: parent.left | ||
461 | 67 | anchors.right: parent.right | ||
462 | 68 | anchors.top: loginForm.bottom | ||
463 | 69 | anchors.bottom: pageFooter.top | ||
464 | 70 | |||
465 | 71 | Row { | ||
466 | 72 | height: childrenRect.height | ||
467 | 73 | anchors.left: parent.left | ||
468 | 74 | anchors.right: parent.right | ||
469 | 75 | anchors.bottom: parent.bottom | ||
470 | 76 | spacing: units.gu(1) | ||
471 | 77 | |||
472 | 78 | Button { | ||
473 | 79 | text: i18n.dtr("ubuntu-system-settings-online-accounts", "Cancel") | ||
474 | 80 | width: (parent.width / 2) - 0.5 * parent.spacing | ||
475 | 81 | onClicked: signonRequest.cancel() | ||
476 | 82 | } | ||
477 | 83 | |||
478 | 84 | Button { | ||
479 | 85 | text: signonRequest.loginText | ||
480 | 86 | width: (parent.width / 2) - 0.5 * parent.spacing | ||
481 | 87 | onClicked: signonRequest.accept() | ||
482 | 88 | } | ||
483 | 89 | } | ||
484 | 90 | } | ||
485 | 91 | |||
486 | 92 | Item { | ||
487 | 93 | id: pageFooter | ||
488 | 94 | anchors.left: parent.left | ||
489 | 95 | anchors.right: parent.right | ||
490 | 96 | anchors.bottom: osk.top | ||
491 | 97 | visible: signonRequest.registerUrl.toString() !== "" | ||
492 | 98 | |||
493 | 99 | ListItem.ThinDivider { | ||
494 | 100 | anchors.bottom: registerUrlLabel.top | ||
495 | 101 | } | ||
496 | 102 | |||
497 | 103 | Label { | ||
498 | 104 | anchors.bottom: parent.bottom | ||
499 | 105 | id: registerUrlLabel | ||
500 | 106 | text: "<a href=\"" + signonRequest.registerUrl + "\">" + | ||
501 | 107 | signonRequest.registerText + "</a>" | ||
502 | 108 | } | ||
503 | 109 | } | ||
504 | 110 | |||
505 | 111 | KeyboardRectangle { | ||
506 | 112 | id: osk | ||
507 | 113 | } | ||
508 | 114 | } | ||
509 | 115 | } | ||
510 | 0 | 116 | ||
511 | === modified file 'online-accounts-ui/signonui-request.cpp' | |||
512 | --- online-accounts-ui/signonui-request.cpp 2014-10-09 12:24:45 +0000 | |||
513 | +++ online-accounts-ui/signonui-request.cpp 2014-10-10 13:24:04 +0000 | |||
514 | @@ -22,6 +22,7 @@ | |||
515 | 22 | 22 | ||
516 | 23 | #include "browser-request.h" | 23 | #include "browser-request.h" |
517 | 24 | #include "debug.h" | 24 | #include "debug.h" |
518 | 25 | #include "dialog-request.h" | ||
519 | 25 | #include "globals.h" | 26 | #include "globals.h" |
520 | 26 | #include "notification.h" | 27 | #include "notification.h" |
521 | 27 | 28 | ||
522 | @@ -35,6 +36,7 @@ | |||
523 | 35 | #include <QPointer> | 36 | #include <QPointer> |
524 | 36 | #include <SignOn/uisessiondata.h> | 37 | #include <SignOn/uisessiondata.h> |
525 | 37 | #include <SignOn/uisessiondata_priv.h> | 38 | #include <SignOn/uisessiondata_priv.h> |
526 | 39 | #include <sys/apparmor.h> | ||
527 | 38 | 40 | ||
528 | 39 | using namespace SignOnUi; | 41 | using namespace SignOnUi; |
529 | 40 | 42 | ||
530 | @@ -203,16 +205,44 @@ | |||
531 | 203 | return new SignOnUi::BrowserRequest(id, clientProfile, | 205 | return new SignOnUi::BrowserRequest(id, clientProfile, |
532 | 204 | parameters, parent); | 206 | parameters, parent); |
533 | 205 | } else { | 207 | } else { |
535 | 206 | return 0; // TODO new DialogRequest(connection, message, parameters, parent); | 208 | return new SignOnUi::DialogRequest(id, clientProfile, |
536 | 209 | parameters, parent); | ||
537 | 207 | } | 210 | } |
538 | 208 | } | 211 | } |
539 | 209 | #endif | 212 | #endif |
540 | 210 | 213 | ||
541 | 214 | static QString findClientProfile(const QString &clientProfile, | ||
542 | 215 | const QVariantMap ¶meters) | ||
543 | 216 | { | ||
544 | 217 | QString profile = clientProfile; | ||
545 | 218 | /* If the request is coming on the SignOnUi interface from an | ||
546 | 219 | * unconfined process and it carries the SSOUI_KEY_PID key, it means that | ||
547 | 220 | * it's coming from signond. In that case, we want to know what was the | ||
548 | 221 | * client which originated the call. | ||
549 | 222 | */ | ||
550 | 223 | if (profile == "unconfined" && | ||
551 | 224 | parameters.contains(SSOUI_KEY_PID)) { | ||
552 | 225 | pid_t pid = parameters.value(SSOUI_KEY_PID).toUInt(); | ||
553 | 226 | char *con = NULL, *mode = NULL; | ||
554 | 227 | int ret = aa_gettaskcon(pid, &con, &mode); | ||
555 | 228 | if (Q_LIKELY(ret >= 0)) { | ||
556 | 229 | profile = QString::fromUtf8(con); | ||
557 | 230 | /* libapparmor allocates "con" and "mode" in a single allocation, | ||
558 | 231 | * so freeing "con" is actually freeing both. */ | ||
559 | 232 | free(con); | ||
560 | 233 | } else { | ||
561 | 234 | qWarning() << "Couldn't get apparmor profile of PID" << pid; | ||
562 | 235 | } | ||
563 | 236 | } | ||
564 | 237 | return profile; | ||
565 | 238 | } | ||
566 | 239 | |||
567 | 211 | Request::Request(int id, | 240 | Request::Request(int id, |
568 | 212 | const QString &clientProfile, | 241 | const QString &clientProfile, |
569 | 213 | const QVariantMap ¶meters, | 242 | const QVariantMap ¶meters, |
570 | 214 | QObject *parent): | 243 | QObject *parent): |
572 | 215 | OnlineAccountsUi::Request(SIGNONUI_INTERFACE, id, clientProfile, | 244 | OnlineAccountsUi::Request(SIGNONUI_INTERFACE, id, |
573 | 245 | findClientProfile(clientProfile, parameters), | ||
574 | 216 | parameters, parent), | 246 | parameters, parent), |
575 | 217 | d_ptr(new RequestPrivate(this)) | 247 | d_ptr(new RequestPrivate(this)) |
576 | 218 | { | 248 | { |
577 | 219 | 249 | ||
578 | === modified file 'online-accounts-ui/ui.qrc' | |||
579 | --- online-accounts-ui/ui.qrc 2014-08-13 14:39:53 +0000 | |||
580 | +++ online-accounts-ui/ui.qrc 2014-10-10 13:24:04 +0000 | |||
581 | @@ -3,6 +3,7 @@ | |||
582 | 3 | <file>qml/AccountCreationPage.qml</file> | 3 | <file>qml/AccountCreationPage.qml</file> |
583 | 4 | <file>qml/AuthorizationPage.qml</file> | 4 | <file>qml/AuthorizationPage.qml</file> |
584 | 5 | <file>qml/ProviderRequest.qml</file> | 5 | <file>qml/ProviderRequest.qml</file> |
585 | 6 | <file>qml/SignOnUiDialog.qml</file> | ||
586 | 6 | <file>qml/SignOnUiPage.qml</file> | 7 | <file>qml/SignOnUiPage.qml</file> |
587 | 7 | </qresource> | 8 | </qresource> |
588 | 8 | </RCC> | 9 | </RCC> |