Merge lp:~dbarth/ubuntu-system-settings-online-accounts/inline-plugin into lp:ubuntu-system-settings-online-accounts
- inline-plugin
- Merge into trunk
Proposed by
David Barth
Status: | Superseded |
---|---|
Proposed branch: | lp:~dbarth/ubuntu-system-settings-online-accounts/inline-plugin |
Merge into: | lp:ubuntu-system-settings-online-accounts |
Diff against target: |
2212 lines (+1631/-147) 37 files modified
.bzrignore (+1/-0) debian/control (+0/-1) src/browser-request.cpp (+5/-15) src/module/OAuth.qml (+0/-1) src/module/WebView.qml (+1/-2) src/module/qmldir.in (+2/-0) src/notification.cpp (+8/-0) src/notification.h (+1/-0) src/online-accounts-ui.pro (+2/-1) src/qml/SignOnUiPage.qml (+40/-0) src/signonui-request.cpp (+101/-46) src/ui.qrc (+1/-0) system-settings-plugin/AccountEditPage.qml (+66/-0) system-settings-plugin/AccountItem.qml (+59/-0) system-settings-plugin/AccountsPage.qml (+65/-0) system-settings-plugin/AddAccountLabel.qml (+28/-0) system-settings-plugin/AuthorizationPage.qml (+75/-0) system-settings-plugin/EntryComponent.qml (+33/-0) system-settings-plugin/MainPage.qml (+66/-0) system-settings-plugin/NewAccountPage.qml (+38/-0) system-settings-plugin/NoAccountsPage.qml (+54/-0) system-settings-plugin/NormalStartupPage.qml (+46/-0) system-settings-plugin/ProviderPluginList.qml (+42/-0) system-settings-plugin/ProvidersList.qml (+62/-0) system-settings-plugin/online-accounts.settings (+2/-1) system-settings-plugin/plugin.cpp (+17/-70) system-settings-plugin/plugin.h (+6/-9) system-settings-plugin/system-settings-plugin.pro (+18/-0) tests/online-accounts-ui/data/com.ubuntu.tests_application.application (+19/-0) tests/online-accounts-ui/mock/notification-mock.cpp (+81/-0) tests/online-accounts-ui/mock/notification-mock.h (+66/-0) tests/online-accounts-ui/mock/request-mock.cpp (+136/-0) tests/online-accounts-ui/mock/request-mock.h (+64/-0) tests/online-accounts-ui/online-accounts-ui.pro (+2/-1) tests/online-accounts-ui/tst_notification.cpp (+33/-0) tests/online-accounts-ui/tst_signonui_request.cpp (+338/-0) tests/online-accounts-ui/tst_signonui_request.pro (+53/-0) |
To merge this branch: | bzr merge lp:~dbarth/ubuntu-system-settings-online-accounts/inline-plugin |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Online Accounts | Pending | ||
Review via email: mp+230301@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-08-11.
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
- 131. By David Barth
-
inline plugin take 2; made of bzr move'd qml files
- 132. By David Barth
-
only support OAuth providers for now
- 133. By David Barth
-
navigate back up once an account is removed
- 134. By David Barth
-
Simplify code by using Setup{} and Options{}
- 135. By David Barth
-
cleanups
- 136. By David Barth
-
no more plugin code
- 137. By David Barth
-
fix build in the rest of the project
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2014-06-05 13:28:30 +0000 | |||
3 | +++ .bzrignore 2014-08-11 13:15:20 +0000 | |||
4 | @@ -46,3 +46,4 @@ | |||
5 | 46 | /tests/online-accounts-ui/tst_inactivity_timer | 46 | /tests/online-accounts-ui/tst_inactivity_timer |
6 | 47 | /tests/online-accounts-ui/tst_notification | 47 | /tests/online-accounts-ui/tst_notification |
7 | 48 | /tests/online-accounts-ui/tst_service | 48 | /tests/online-accounts-ui/tst_service |
8 | 49 | /tests/online-accounts-ui/tst_signonui_request | ||
9 | 49 | 50 | ||
10 | === modified file 'debian/control' | |||
11 | --- debian/control 2014-06-04 12:00:43 +0000 | |||
12 | +++ debian/control 2014-08-11 13:15:20 +0000 | |||
13 | @@ -36,7 +36,6 @@ | |||
14 | 36 | qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles, | 36 | qtdeclarative5-ubuntu-ui-toolkit-plugin | qtdeclarative5-ubuntu-ui-toolkit-plugin-gles, |
15 | 37 | signon-ui-service, | 37 | signon-ui-service, |
16 | 38 | ubuntu-system-settings | 38 | ubuntu-system-settings |
17 | 39 | Provides: signon-ui | ||
18 | 40 | Description: Online Accounts setup for Ubuntu Touch | 39 | Description: Online Accounts setup for Ubuntu Touch |
19 | 41 | Online Accounts setup utility for the Ubuntu Touch System Settings. | 40 | Online Accounts setup utility for the Ubuntu Touch System Settings. |
20 | 42 | 41 | ||
21 | 43 | 42 | ||
22 | === modified file 'src/browser-request.cpp' | |||
23 | --- src/browser-request.cpp 2014-04-29 14:34:44 +0000 | |||
24 | +++ src/browser-request.cpp 2014-08-11 13:15:20 +0000 | |||
25 | @@ -28,6 +28,7 @@ | |||
26 | 28 | 28 | ||
27 | 29 | #include <QDir> | 29 | #include <QDir> |
28 | 30 | #include <QQmlContext> | 30 | #include <QQmlContext> |
29 | 31 | #include <QQmlEngine> | ||
30 | 31 | #include <QStandardPaths> | 32 | #include <QStandardPaths> |
31 | 32 | #include <QTimer> | 33 | #include <QTimer> |
32 | 33 | #include <SignOn/uisessiondata_priv.h> | 34 | #include <SignOn/uisessiondata_priv.h> |
33 | @@ -133,18 +134,9 @@ | |||
34 | 133 | QObject::connect(m_dialog, SIGNAL(finished(int)), | 134 | QObject::connect(m_dialog, SIGNAL(finished(int)), |
35 | 134 | this, SLOT(onFinished())); | 135 | this, SLOT(onFinished())); |
36 | 135 | 136 | ||
46 | 136 | QUrl webview("qrc:/MainWindow.qml"); | 137 | m_dialog->engine()->addImportPath(PLUGIN_PRIVATE_MODULE_DIR); |
38 | 137 | QDir qmlDir("/usr/share/signon-ui/qml"); | ||
39 | 138 | if (qmlDir.exists()) | ||
40 | 139 | { | ||
41 | 140 | QFileInfo qmlFile(qmlDir.absolutePath() + "/MainWindow.qml"); | ||
42 | 141 | if (qmlFile.exists()) | ||
43 | 142 | webview.setUrl(qmlFile.absoluteFilePath()); | ||
44 | 143 | } | ||
45 | 144 | |||
47 | 145 | m_dialog->rootContext()->setContextProperty("request", this); | 138 | m_dialog->rootContext()->setContextProperty("request", this); |
50 | 146 | m_dialog->rootContext()->setContextProperty("rootDir", m_rootDir); | 139 | m_dialog->setSource(QUrl("qrc:/qml/SignOnUiPage.qml")); |
49 | 147 | m_dialog->setSource(webview); | ||
51 | 148 | } else { | 140 | } else { |
52 | 149 | DEBUG() << "Setting request on handler"; | 141 | DEBUG() << "Setting request on handler"; |
53 | 150 | q->handler()->setRequest(this); | 142 | q->handler()->setRequest(this); |
54 | @@ -208,7 +200,7 @@ | |||
55 | 208 | 200 | ||
56 | 209 | void BrowserRequestPrivate::onLoadFinished(bool ok) | 201 | void BrowserRequestPrivate::onLoadFinished(bool ok) |
57 | 210 | { | 202 | { |
59 | 211 | Q_Q(const BrowserRequest); | 203 | Q_Q(BrowserRequest); |
60 | 212 | 204 | ||
61 | 213 | DEBUG() << "Load finished" << ok; | 205 | DEBUG() << "Load finished" << ok; |
62 | 214 | 206 | ||
63 | @@ -219,9 +211,7 @@ | |||
64 | 219 | 211 | ||
65 | 220 | if (m_dialog && !m_dialog->isVisible()) { | 212 | if (m_dialog && !m_dialog->isVisible()) { |
66 | 221 | if (m_responseUrl.isEmpty()) { | 213 | if (m_responseUrl.isEmpty()) { |
70 | 222 | Dialog::ShowMode mode = | 214 | q->setWindow(m_dialog); |
68 | 223 | (q->windowId() == 0) ? Dialog::TopLevel : Dialog::Transient; | ||
69 | 224 | m_dialog->show(q->windowId(), mode); | ||
71 | 225 | } else { | 215 | } else { |
72 | 226 | onFinished(); | 216 | onFinished(); |
73 | 227 | } | 217 | } |
74 | 228 | 218 | ||
75 | === modified file 'src/module/OAuth.qml' | |||
76 | --- src/module/OAuth.qml 2014-04-29 12:11:55 +0000 | |||
77 | +++ src/module/OAuth.qml 2014-08-11 13:15:20 +0000 | |||
78 | @@ -55,7 +55,6 @@ | |||
79 | 55 | if (request) { | 55 | if (request) { |
80 | 56 | console.log("RequestHandler captured request!") | 56 | console.log("RequestHandler captured request!") |
81 | 57 | loader.setSource("WebView.qml", { | 57 | loader.setSource("WebView.qml", { |
82 | 58 | "rootDir": request.rootDir, | ||
83 | 59 | "signonRequest": request | 58 | "signonRequest": request |
84 | 60 | }) | 59 | }) |
85 | 61 | } else { | 60 | } else { |
86 | 62 | 61 | ||
87 | === modified file 'src/module/WebView.qml' | |||
88 | --- src/module/WebView.qml 2014-04-29 12:11:55 +0000 | |||
89 | +++ src/module/WebView.qml 2014-08-11 13:15:20 +0000 | |||
90 | @@ -5,7 +5,6 @@ | |||
91 | 5 | 5 | ||
92 | 6 | UbuntuWebView { | 6 | UbuntuWebView { |
93 | 7 | property QtObject signonRequest | 7 | property QtObject signonRequest |
94 | 8 | property url rootDir | ||
95 | 9 | 8 | ||
96 | 10 | Component.onCompleted: url = signonRequest.startUrl | 9 | Component.onCompleted: url = signonRequest.startUrl |
97 | 11 | 10 | ||
98 | @@ -22,6 +21,6 @@ | |||
99 | 22 | onUrlChanged: signonRequest.currentUrl = url | 21 | onUrlChanged: signonRequest.currentUrl = url |
100 | 23 | 22 | ||
101 | 24 | context: UbuntuWebContext { | 23 | context: UbuntuWebContext { |
103 | 25 | dataPath: rootDir | 24 | dataPath: signonRequest.rootDir |
104 | 26 | } | 25 | } |
105 | 27 | } | 26 | } |
106 | 28 | 27 | ||
107 | === modified file 'src/module/qmldir.in' | |||
108 | --- src/module/qmldir.in 2013-06-05 11:33:39 +0000 | |||
109 | +++ src/module/qmldir.in 2014-08-11 13:15:20 +0000 | |||
110 | @@ -1,7 +1,9 @@ | |||
111 | 1 | module $${API_URI} | 1 | module $${API_URI} |
112 | 2 | KeyboardRectangle 1.0 KeyboardRectangle.qml | ||
113 | 2 | OAuthMain 1.0 OAuthMain.qml | 3 | OAuthMain 1.0 OAuthMain.qml |
114 | 3 | OAuth 1.0 OAuth.qml | 4 | OAuth 1.0 OAuth.qml |
115 | 4 | Options 1.0 Options.qml | 5 | Options 1.0 Options.qml |
116 | 5 | RemovalConfirmation 1.0 RemovalConfirmation.qml | 6 | RemovalConfirmation 1.0 RemovalConfirmation.qml |
117 | 6 | ServiceItem 1.0 ServiceItem.qml | 7 | ServiceItem 1.0 ServiceItem.qml |
118 | 7 | ServiceSwitches 1.0 ServiceSwitches.qml | 8 | ServiceSwitches 1.0 ServiceSwitches.qml |
119 | 9 | WebView 1.0 WebView.qml | ||
120 | 8 | 10 | ||
121 | === modified file 'src/notification.cpp' | |||
122 | --- src/notification.cpp 2014-06-05 13:28:30 +0000 | |||
123 | +++ src/notification.cpp 2014-08-11 13:15:20 +0000 | |||
124 | @@ -108,6 +108,14 @@ | |||
125 | 108 | this, NULL); | 108 | this, NULL); |
126 | 109 | } | 109 | } |
127 | 110 | 110 | ||
128 | 111 | void Notification::setSnapDecision(bool snapDecision) | ||
129 | 112 | { | ||
130 | 113 | Q_D(Notification); | ||
131 | 114 | notify_notification_set_hint(d->m_notification, | ||
132 | 115 | "x-canonical-snap-decisions", | ||
133 | 116 | g_variant_new_boolean(snapDecision)); | ||
134 | 117 | } | ||
135 | 118 | |||
136 | 111 | void Notification::show() | 119 | void Notification::show() |
137 | 112 | { | 120 | { |
138 | 113 | Q_D(Notification); | 121 | Q_D(Notification); |
139 | 114 | 122 | ||
140 | === modified file 'src/notification.h' | |||
141 | --- src/notification.h 2014-06-05 13:28:30 +0000 | |||
142 | +++ src/notification.h 2014-08-11 13:15:20 +0000 | |||
143 | @@ -37,6 +37,7 @@ | |||
144 | 37 | ~Notification(); | 37 | ~Notification(); |
145 | 38 | 38 | ||
146 | 39 | void addAction(const QString &action, const QString &label); | 39 | void addAction(const QString &action, const QString &label); |
147 | 40 | void setSnapDecision(bool snapDecision); | ||
148 | 40 | 41 | ||
149 | 41 | public Q_SLOTS: | 42 | public Q_SLOTS: |
150 | 42 | void show(); | 43 | void show(); |
151 | 43 | 44 | ||
152 | === modified file 'src/online-accounts-ui.pro' | |||
153 | --- src/online-accounts-ui.pro 2014-06-05 13:28:30 +0000 | |||
154 | +++ src/online-accounts-ui.pro 2014-08-11 13:15:20 +0000 | |||
155 | @@ -92,7 +92,8 @@ | |||
156 | 92 | qml/NormalStartupPage.qml \ | 92 | qml/NormalStartupPage.qml \ |
157 | 93 | qml/ProviderPluginList.qml \ | 93 | qml/ProviderPluginList.qml \ |
158 | 94 | qml/ProviderRequest.qml \ | 94 | qml/ProviderRequest.qml \ |
160 | 95 | qml/ProvidersList.qml | 95 | qml/ProvidersList.qml \ |
161 | 96 | qml/SignOnUiPage.qml | ||
162 | 96 | 97 | ||
163 | 97 | RESOURCES += \ | 98 | RESOURCES += \ |
164 | 98 | ui.qrc | 99 | ui.qrc |
165 | 99 | 100 | ||
166 | === added file 'src/qml/SignOnUiPage.qml' | |||
167 | --- src/qml/SignOnUiPage.qml 1970-01-01 00:00:00 +0000 | |||
168 | +++ src/qml/SignOnUiPage.qml 2014-08-11 13:15:20 +0000 | |||
169 | @@ -0,0 +1,40 @@ | |||
170 | 1 | import QtQuick 2.0 | ||
171 | 2 | import Ubuntu.Components 0.1 | ||
172 | 3 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
173 | 4 | import Ubuntu.OnlineAccounts.Plugin 1.0 | ||
174 | 5 | |||
175 | 6 | MainView { | ||
176 | 7 | id: root | ||
177 | 8 | |||
178 | 9 | property var signonRequest: request | ||
179 | 10 | |||
180 | 11 | width: units.gu(60) | ||
181 | 12 | height: units.gu(90) | ||
182 | 13 | |||
183 | 14 | Page { | ||
184 | 15 | WebView { | ||
185 | 16 | id: loader | ||
186 | 17 | signonRequest: root.signonRequest | ||
187 | 18 | |||
188 | 19 | anchors { | ||
189 | 20 | fill: parent | ||
190 | 21 | bottomMargin: Math.max(osk.height, cancelButton.height) | ||
191 | 22 | } | ||
192 | 23 | } | ||
193 | 24 | |||
194 | 25 | ListItem.SingleControl { | ||
195 | 26 | id: cancelButton | ||
196 | 27 | anchors.bottom: parent.bottom | ||
197 | 28 | showDivider: false | ||
198 | 29 | control: Button { | ||
199 | 30 | text: i18n.dtr("ubuntu-system-settings-online-accounts", "Cancel") | ||
200 | 31 | width: parent.width - units.gu(4) | ||
201 | 32 | onClicked: signonRequest.cancel() | ||
202 | 33 | } | ||
203 | 34 | } | ||
204 | 35 | |||
205 | 36 | KeyboardRectangle { | ||
206 | 37 | id: osk | ||
207 | 38 | } | ||
208 | 39 | } | ||
209 | 40 | } | ||
210 | 0 | 41 | ||
211 | === modified file 'src/signonui-request.cpp' | |||
212 | --- src/signonui-request.cpp 2014-06-05 13:28:30 +0000 | |||
213 | +++ src/signonui-request.cpp 2014-08-11 13:15:20 +0000 | |||
214 | @@ -1,7 +1,7 @@ | |||
215 | 1 | /* | 1 | /* |
216 | 2 | * This file is part of online-accounts-ui | 2 | * This file is part of online-accounts-ui |
217 | 3 | * | 3 | * |
219 | 4 | * Copyright (C) 2011 Canonical Ltd. | 4 | * Copyright (C) 2011-2014 Canonical Ltd. |
220 | 5 | * | 5 | * |
221 | 6 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | 6 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
222 | 7 | * | 7 | * |
223 | @@ -20,13 +20,16 @@ | |||
224 | 20 | 20 | ||
225 | 21 | #include "signonui-request.h" | 21 | #include "signonui-request.h" |
226 | 22 | 22 | ||
227 | 23 | #include "account-manager.h" | ||
228 | 24 | #include "application-manager.h" | ||
229 | 23 | #include "browser-request.h" | 25 | #include "browser-request.h" |
230 | 24 | #include "debug.h" | 26 | #include "debug.h" |
231 | 25 | #include "globals.h" | 27 | #include "globals.h" |
233 | 26 | #include "indicator-service.h" | 28 | #include "notification.h" |
234 | 27 | 29 | ||
235 | 28 | #include <Accounts/Account> | 30 | #include <Accounts/Account> |
237 | 29 | #include <Accounts/Manager> | 31 | #include <Accounts/Application> |
238 | 32 | #include <Accounts/Provider> | ||
239 | 30 | #include <QDBusArgument> | 33 | #include <QDBusArgument> |
240 | 31 | #include <SignOn/uisessiondata.h> | 34 | #include <SignOn/uisessiondata.h> |
241 | 32 | #include <SignOn/uisessiondata_priv.h> | 35 | #include <SignOn/uisessiondata_priv.h> |
242 | @@ -45,16 +48,19 @@ | |||
243 | 45 | ~RequestPrivate(); | 48 | ~RequestPrivate(); |
244 | 46 | 49 | ||
245 | 47 | private: | 50 | private: |
247 | 48 | bool setWindow(QWindow *window); | 51 | void setWindow(QWindow *window); |
248 | 49 | Accounts::Account *findAccount(); | 52 | Accounts::Account *findAccount(); |
250 | 50 | bool dispatchToIndicator(); | 53 | |
251 | 54 | private Q_SLOTS: | ||
252 | 55 | void onActionInvoked(const QString &action); | ||
253 | 56 | void onNotificationClosed(); | ||
254 | 51 | 57 | ||
255 | 52 | private: | 58 | private: |
256 | 53 | mutable Request *q_ptr; | 59 | mutable Request *q_ptr; |
257 | 54 | QVariantMap m_clientData; | 60 | QVariantMap m_clientData; |
258 | 55 | bool m_inProgress; | ||
259 | 56 | RequestHandler *m_handler; | 61 | RequestHandler *m_handler; |
261 | 57 | Accounts::Manager *m_accountManager; | 62 | OnlineAccountsUi::Notification *m_notification; |
262 | 63 | QWindow *m_window; | ||
263 | 58 | }; | 64 | }; |
264 | 59 | 65 | ||
265 | 60 | } // namespace | 66 | } // namespace |
266 | @@ -62,9 +68,9 @@ | |||
267 | 62 | RequestPrivate::RequestPrivate(Request *request): | 68 | RequestPrivate::RequestPrivate(Request *request): |
268 | 63 | QObject(request), | 69 | QObject(request), |
269 | 64 | q_ptr(request), | 70 | q_ptr(request), |
270 | 65 | m_inProgress(false), | ||
271 | 66 | m_handler(0), | 71 | m_handler(0), |
273 | 67 | m_accountManager(0) | 72 | m_notification(0), |
274 | 73 | m_window(0) | ||
275 | 68 | { | 74 | { |
276 | 69 | const QVariantMap ¶meters = request->parameters(); | 75 | const QVariantMap ¶meters = request->parameters(); |
277 | 70 | if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) { | 76 | if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) { |
278 | @@ -77,20 +83,51 @@ | |||
279 | 77 | 83 | ||
280 | 78 | RequestPrivate::~RequestPrivate() | 84 | RequestPrivate::~RequestPrivate() |
281 | 79 | { | 85 | { |
282 | 86 | delete m_notification; | ||
283 | 87 | m_notification = 0; | ||
284 | 80 | } | 88 | } |
285 | 81 | 89 | ||
287 | 82 | bool RequestPrivate::setWindow(QWindow *window) | 90 | void RequestPrivate::setWindow(QWindow *window) |
288 | 83 | { | 91 | { |
289 | 84 | Q_Q(Request); | 92 | Q_Q(Request); |
290 | 85 | Q_UNUSED(window); | ||
291 | 86 | 93 | ||
296 | 87 | /* If the window has no parent and the webcredentials indicator service is | 94 | /* Don't show the window yet: the user must be presented with a |
297 | 88 | * up, dispatch the request to it. */ | 95 | * snap-decision, and we'll show the window only if he decides to |
298 | 89 | if (q->windowId() == 0 && dispatchToIndicator()) { | 96 | * authenticate. */ |
299 | 90 | return true; | 97 | Accounts::Account *account = findAccount(); |
300 | 98 | if (Q_UNLIKELY(!account)) { | ||
301 | 99 | QVariantMap result; | ||
302 | 100 | result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_FORBIDDEN; | ||
303 | 101 | q->setResult(result); | ||
304 | 102 | return; | ||
305 | 91 | } | 103 | } |
306 | 92 | 104 | ||
308 | 93 | return false; | 105 | OnlineAccountsUi::ApplicationManager *appManager = |
309 | 106 | OnlineAccountsUi::ApplicationManager::instance(); | ||
310 | 107 | Accounts::Application application = | ||
311 | 108 | appManager->applicationFromProfile(q->clientApparmorProfile()); | ||
312 | 109 | |||
313 | 110 | OnlineAccountsUi::AccountManager *accountManager = | ||
314 | 111 | OnlineAccountsUi::AccountManager::instance(); | ||
315 | 112 | Accounts::Provider provider = | ||
316 | 113 | accountManager->provider(account->providerName()); | ||
317 | 114 | |||
318 | 115 | QString summary = | ||
319 | 116 | QString("Please authorize %1 to access your %2 account %3"). | ||
320 | 117 | arg(application.isValid() ? application.displayName() : "Ubuntu"). | ||
321 | 118 | arg(provider.displayName()). | ||
322 | 119 | arg(account->displayName()); | ||
323 | 120 | m_notification = | ||
324 | 121 | new OnlineAccountsUi::Notification("Authentication request", summary); | ||
325 | 122 | m_notification->addAction("cancel", "Cancel"); | ||
326 | 123 | m_notification->addAction("continue", "Authorize..."); | ||
327 | 124 | m_notification->setSnapDecision(true); | ||
328 | 125 | QObject::connect(m_notification, SIGNAL(actionInvoked(const QString &)), | ||
329 | 126 | this, SLOT(onActionInvoked(const QString &))); | ||
330 | 127 | QObject::connect(m_notification, SIGNAL(closed()), | ||
331 | 128 | this, SLOT(onNotificationClosed())); | ||
332 | 129 | m_notification->show(); | ||
333 | 130 | m_window = window; | ||
334 | 94 | } | 131 | } |
335 | 95 | 132 | ||
336 | 96 | Accounts::Account *RequestPrivate::findAccount() | 133 | Accounts::Account *RequestPrivate::findAccount() |
337 | @@ -104,11 +141,10 @@ | |||
338 | 104 | /* Find the account using this identity. | 141 | /* Find the account using this identity. |
339 | 105 | * FIXME: there might be more than one! | 142 | * FIXME: there might be more than one! |
340 | 106 | */ | 143 | */ |
346 | 107 | if (m_accountManager == 0) { | 144 | OnlineAccountsUi::AccountManager *manager = |
347 | 108 | m_accountManager = new Accounts::Manager(this); | 145 | OnlineAccountsUi::AccountManager::instance(); |
348 | 109 | } | 146 | Q_FOREACH(Accounts::AccountId accountId, manager->accountList()) { |
349 | 110 | Q_FOREACH(Accounts::AccountId accountId, m_accountManager->accountList()) { | 147 | Accounts::Account *account = manager->account(accountId); |
345 | 111 | Accounts::Account *account = m_accountManager->account(accountId); | ||
350 | 112 | if (account == 0) continue; | 148 | if (account == 0) continue; |
351 | 113 | 149 | ||
352 | 114 | QVariant value(QVariant::UInt); | 150 | QVariant value(QVariant::UInt); |
353 | @@ -122,34 +158,40 @@ | |||
354 | 122 | return 0; | 158 | return 0; |
355 | 123 | } | 159 | } |
356 | 124 | 160 | ||
358 | 125 | bool RequestPrivate::dispatchToIndicator() | 161 | void RequestPrivate::onActionInvoked(const QString &action) |
359 | 126 | { | 162 | { |
360 | 127 | Q_Q(Request); | 163 | Q_Q(Request); |
361 | 128 | 164 | ||
365 | 129 | Accounts::Account *account = findAccount(); | 165 | DEBUG() << action; |
366 | 130 | if (account == 0) { | 166 | |
367 | 131 | return false; | 167 | QObject::disconnect(m_notification, 0, this, 0); |
368 | 168 | m_notification->deleteLater(); | ||
369 | 169 | m_notification = 0; | ||
370 | 170 | |||
371 | 171 | if (action == QStringLiteral("continue")) { | ||
372 | 172 | q->setWindow(m_window); | ||
373 | 173 | } else { | ||
374 | 174 | q->cancel(); | ||
375 | 132 | } | 175 | } |
390 | 133 | 176 | } | |
391 | 134 | QVariantMap notification; | 177 | |
392 | 135 | notification["DisplayName"] = account->displayName(); | 178 | void RequestPrivate::onNotificationClosed() |
393 | 136 | notification["ClientData"] = m_clientData; | 179 | { |
394 | 137 | notification["Identity"] = q->identity(); | 180 | Q_Q(Request); |
395 | 138 | notification["Method"] = q->method(); | 181 | |
396 | 139 | notification["Mechanism"] = q->mechanism(); | 182 | DEBUG(); |
397 | 140 | 183 | ||
398 | 141 | IndicatorService *indicator = IndicatorService::instance(); | 184 | /* setResult() should have been called by onActionInvoked(), but calling it |
399 | 142 | indicator->reportFailure(account->id(), notification); | 185 | * twice won't harm because only the first invocation counts. */ |
386 | 143 | |||
387 | 144 | /* the account has been reported as failing. We can now close this | ||
388 | 145 | * request, and tell the application that UI interaction is forbidden. | ||
389 | 146 | */ | ||
400 | 147 | QVariantMap result; | 186 | QVariantMap result; |
401 | 148 | result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_FORBIDDEN; | 187 | result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_FORBIDDEN; |
402 | 149 | q->setResult(result); | 188 | q->setResult(result); |
404 | 150 | return true; | 189 | |
405 | 190 | m_notification->deleteLater(); | ||
406 | 191 | m_notification = 0; | ||
407 | 151 | } | 192 | } |
408 | 152 | 193 | ||
409 | 194 | #ifndef NO_REQUEST_FACTORY | ||
410 | 153 | Request *Request::newRequest(const QDBusConnection &connection, | 195 | Request *Request::newRequest(const QDBusConnection &connection, |
411 | 154 | const QDBusMessage &message, | 196 | const QDBusMessage &message, |
412 | 155 | const QVariantMap ¶meters, | 197 | const QVariantMap ¶meters, |
413 | @@ -162,6 +204,7 @@ | |||
414 | 162 | return 0; // TODO new DialogRequest(connection, message, parameters, parent); | 204 | return 0; // TODO new DialogRequest(connection, message, parameters, parent); |
415 | 163 | } | 205 | } |
416 | 164 | } | 206 | } |
417 | 207 | #endif | ||
418 | 165 | 208 | ||
419 | 166 | Request::Request(const QDBusConnection &connection, | 209 | Request::Request(const QDBusConnection &connection, |
420 | 167 | const QDBusMessage &message, | 210 | const QDBusMessage &message, |
421 | @@ -189,8 +232,22 @@ | |||
422 | 189 | void Request::setWindow(QWindow *window) | 232 | void Request::setWindow(QWindow *window) |
423 | 190 | { | 233 | { |
424 | 191 | Q_D(Request); | 234 | Q_D(Request); |
426 | 192 | if (!d->setWindow(window)) | 235 | |
427 | 236 | /* While a notification is shown, ignore any further calls to | ||
428 | 237 | * setWindow(). */ | ||
429 | 238 | if (d->m_notification) return; | ||
430 | 239 | |||
431 | 240 | /* The first time that this method is called, we handle it by presenting a | ||
432 | 241 | * snap decision to the user. | ||
433 | 242 | * Then, if this is called again with the same QWindow, it means that the | ||
434 | 243 | * snap decision was accepted, and we show the window. | ||
435 | 244 | */ | ||
436 | 245 | if (window == d->m_window) { | ||
437 | 193 | OnlineAccountsUi::Request::setWindow(window); | 246 | OnlineAccountsUi::Request::setWindow(window); |
438 | 247 | d->m_window = 0; | ||
439 | 248 | } else { | ||
440 | 249 | d->setWindow(window); | ||
441 | 250 | } | ||
442 | 194 | } | 251 | } |
443 | 195 | 252 | ||
444 | 196 | uint Request::identity() const | 253 | uint Request::identity() const |
445 | @@ -232,12 +289,10 @@ | |||
446 | 232 | 289 | ||
447 | 233 | void Request::setCanceled() | 290 | void Request::setCanceled() |
448 | 234 | { | 291 | { |
452 | 235 | if (isInProgress()) { | 292 | QVariantMap result; |
453 | 236 | QVariantMap result; | 293 | result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_CANCELED; |
451 | 237 | result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_CANCELED; | ||
454 | 238 | 294 | ||
457 | 239 | setResult(result); | 295 | setResult(result); |
456 | 240 | } | ||
458 | 241 | } | 296 | } |
459 | 242 | 297 | ||
460 | 243 | #include "signonui-request.moc" | 298 | #include "signonui-request.moc" |
461 | 244 | 299 | ||
462 | === modified file 'src/ui.qrc' | |||
463 | --- src/ui.qrc 2014-03-19 12:14:14 +0000 | |||
464 | +++ src/ui.qrc 2014-08-11 13:15:20 +0000 | |||
465 | @@ -13,5 +13,6 @@ | |||
466 | 13 | <file>qml/ProviderPluginList.qml</file> | 13 | <file>qml/ProviderPluginList.qml</file> |
467 | 14 | <file>qml/ProviderRequest.qml</file> | 14 | <file>qml/ProviderRequest.qml</file> |
468 | 15 | <file>qml/ProvidersList.qml</file> | 15 | <file>qml/ProvidersList.qml</file> |
469 | 16 | <file>qml/SignOnUiPage.qml</file> | ||
470 | 16 | </qresource> | 17 | </qresource> |
471 | 17 | </RCC> | 18 | </RCC> |
472 | 18 | 19 | ||
473 | === added file 'system-settings-plugin/AccountEditPage.qml' | |||
474 | --- system-settings-plugin/AccountEditPage.qml 1970-01-01 00:00:00 +0000 | |||
475 | +++ system-settings-plugin/AccountEditPage.qml 2014-08-11 13:15:20 +0000 | |||
476 | @@ -0,0 +1,66 @@ | |||
477 | 1 | /* | ||
478 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
479 | 3 | * | ||
480 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
481 | 5 | * | ||
482 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
483 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
484 | 8 | * by the Free Software Foundation. | ||
485 | 9 | * | ||
486 | 10 | * This program is distributed in the hope that it will be useful, but | ||
487 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
488 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
489 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
490 | 14 | * | ||
491 | 15 | * You should have received a copy of the GNU General Public License along | ||
492 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
493 | 17 | */ | ||
494 | 18 | |||
495 | 19 | import QtQuick 2.0 | ||
496 | 20 | import Ubuntu.Components 0.1 | ||
497 | 21 | import Ubuntu.OnlineAccounts 0.1 | ||
498 | 22 | |||
499 | 23 | // HACK | ||
500 | 24 | import Ubuntu.OnlineAccounts.Plugin 1.0 | ||
501 | 25 | |||
502 | 26 | Page { | ||
503 | 27 | id: root | ||
504 | 28 | |||
505 | 29 | property variant accountHandle | ||
506 | 30 | |||
507 | 31 | signal finished | ||
508 | 32 | |||
509 | 33 | title: account.provider.displayName | ||
510 | 34 | |||
511 | 35 | Account { | ||
512 | 36 | id: account | ||
513 | 37 | objectHandle: accountHandle | ||
514 | 38 | } | ||
515 | 39 | |||
516 | 40 | /* Loader { | ||
517 | 41 | id: loader | ||
518 | 42 | property var account: account | ||
519 | 43 | |||
520 | 44 | anchors.fill: parent | ||
521 | 45 | source: localQmlPluginPath + account.provider.id + "/Main.qml" | ||
522 | 46 | |||
523 | 47 | onStatusChanged: { | ||
524 | 48 | if (loader.status == Loader.Error) { | ||
525 | 49 | loader.source = systemQmlPluginPath + account.provider.id + "/Main.qml" | ||
526 | 50 | } | ||
527 | 51 | } | ||
528 | 52 | |||
529 | 53 | |||
530 | 54 | Connections { | ||
531 | 55 | target: loader.item | ||
532 | 56 | onFinished: { | ||
533 | 57 | console.log("====== PLUGIN FINISHED ======") | ||
534 | 58 | root.finished() | ||
535 | 59 | } | ||
536 | 60 | } | ||
537 | 61 | } | ||
538 | 62 | */ | ||
539 | 63 | // HACK: this only suppots OAuth-based providers... | ||
540 | 64 | OAuthMain {} | ||
541 | 65 | |||
542 | 66 | } | ||
543 | 0 | 67 | ||
544 | === added file 'system-settings-plugin/AccountItem.qml' | |||
545 | --- system-settings-plugin/AccountItem.qml 1970-01-01 00:00:00 +0000 | |||
546 | +++ system-settings-plugin/AccountItem.qml 2014-08-11 13:15:20 +0000 | |||
547 | @@ -0,0 +1,59 @@ | |||
548 | 1 | /* | ||
549 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
550 | 3 | * | ||
551 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
552 | 5 | * | ||
553 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
554 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
555 | 8 | * by the Free Software Foundation. | ||
556 | 9 | * | ||
557 | 10 | * This program is distributed in the hope that it will be useful, but | ||
558 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
559 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
560 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
561 | 14 | * | ||
562 | 15 | * You should have received a copy of the GNU General Public License along | ||
563 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
564 | 17 | */ | ||
565 | 18 | |||
566 | 19 | import QtQuick 2.0 | ||
567 | 20 | import Ubuntu.Components 0.1 | ||
568 | 21 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
569 | 22 | import Ubuntu.OnlineAccounts 0.1 | ||
570 | 23 | |||
571 | 24 | ListItem.Subtitled { | ||
572 | 25 | property variant accountHandle | ||
573 | 26 | property variant globalServiceHandle | ||
574 | 27 | property variant __editPage: null | ||
575 | 28 | property bool running: false | ||
576 | 29 | |||
577 | 30 | iconName: globalService.provider.iconName | ||
578 | 31 | progression: true | ||
579 | 32 | opacity: globalService.enabled ? 1 : 0.5 | ||
580 | 33 | |||
581 | 34 | resources: [ | ||
582 | 35 | AccountService { | ||
583 | 36 | id: globalService | ||
584 | 37 | objectHandle: globalServiceHandle | ||
585 | 38 | }, | ||
586 | 39 | Component { | ||
587 | 40 | id: accountEditPage | ||
588 | 41 | AccountEditPage {} | ||
589 | 42 | } | ||
590 | 43 | ] | ||
591 | 44 | |||
592 | 45 | onClicked: { | ||
593 | 46 | __editPage = accountEditPage.createObject(null, { | ||
594 | 47 | "accountHandle": accountHandle }) | ||
595 | 48 | __editPage.finished.connect(__onEditFinished) | ||
596 | 49 | pageStack.push(__editPage) | ||
597 | 50 | running = true; | ||
598 | 51 | } | ||
599 | 52 | |||
600 | 53 | function __onEditFinished() { | ||
601 | 54 | __editPage.destroy(1000) | ||
602 | 55 | __editPage = null | ||
603 | 56 | pageStack.pop() | ||
604 | 57 | running = false | ||
605 | 58 | } | ||
606 | 59 | } | ||
607 | 0 | 60 | ||
608 | === added file 'system-settings-plugin/AccountsPage.qml' | |||
609 | --- system-settings-plugin/AccountsPage.qml 1970-01-01 00:00:00 +0000 | |||
610 | +++ system-settings-plugin/AccountsPage.qml 2014-08-11 13:15:20 +0000 | |||
611 | @@ -0,0 +1,65 @@ | |||
612 | 1 | /* | ||
613 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
614 | 3 | * | ||
615 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
616 | 5 | * | ||
617 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
618 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
619 | 8 | * by the Free Software Foundation. | ||
620 | 9 | * | ||
621 | 10 | * This program is distributed in the hope that it will be useful, but | ||
622 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
623 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
624 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
625 | 14 | * | ||
626 | 15 | * You should have received a copy of the GNU General Public License along | ||
627 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
628 | 17 | */ | ||
629 | 18 | |||
630 | 19 | import QtQuick 2.0 | ||
631 | 20 | import Ubuntu.Components 0.1 | ||
632 | 21 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
633 | 22 | |||
634 | 23 | Flickable { | ||
635 | 24 | id: root | ||
636 | 25 | property variant accountsModel | ||
637 | 26 | contentHeight: contentItem.childrenRect.height | ||
638 | 27 | boundsBehavior: Flickable.StopAtBounds | ||
639 | 28 | |||
640 | 29 | Column { | ||
641 | 30 | anchors.left: parent.left | ||
642 | 31 | anchors.right: parent.right | ||
643 | 32 | |||
644 | 33 | ListView { | ||
645 | 34 | anchors.left: parent.left | ||
646 | 35 | anchors.right: parent.right | ||
647 | 36 | interactive: false | ||
648 | 37 | height: contentHeight | ||
649 | 38 | model: accountsModel | ||
650 | 39 | |||
651 | 40 | delegate: AccountItem { | ||
652 | 41 | ListView.delayRemove: running | ||
653 | 42 | text: providerName | ||
654 | 43 | subText: displayName | ||
655 | 44 | accountHandle: model.accountHandle | ||
656 | 45 | globalServiceHandle: accountServiceHandle | ||
657 | 46 | } | ||
658 | 47 | } | ||
659 | 48 | |||
660 | 49 | ListItem.SingleControl { | ||
661 | 50 | control: Button { | ||
662 | 51 | text: i18n.tr("Add account…") | ||
663 | 52 | width: parent.width - units.gu(4) | ||
664 | 53 | onClicked: pageStack.push(newAccountPage) | ||
665 | 54 | } | ||
666 | 55 | showDivider: false | ||
667 | 56 | } | ||
668 | 57 | |||
669 | 58 | AddAccountLabel {} | ||
670 | 59 | } | ||
671 | 60 | |||
672 | 61 | Component { | ||
673 | 62 | id: newAccountPage | ||
674 | 63 | NewAccountPage {} | ||
675 | 64 | } | ||
676 | 65 | } | ||
677 | 0 | 66 | ||
678 | === added file 'system-settings-plugin/AddAccountLabel.qml' | |||
679 | --- system-settings-plugin/AddAccountLabel.qml 1970-01-01 00:00:00 +0000 | |||
680 | +++ system-settings-plugin/AddAccountLabel.qml 2014-08-11 13:15:20 +0000 | |||
681 | @@ -0,0 +1,28 @@ | |||
682 | 1 | /* | ||
683 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
684 | 3 | * | ||
685 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
686 | 5 | * | ||
687 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
688 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
689 | 8 | * by the Free Software Foundation. | ||
690 | 9 | * | ||
691 | 10 | * This program is distributed in the hope that it will be useful, but | ||
692 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
693 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
694 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
695 | 14 | * | ||
696 | 15 | * You should have received a copy of the GNU General Public License along | ||
697 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
698 | 17 | */ | ||
699 | 18 | |||
700 | 19 | import QtQuick 2.0 | ||
701 | 20 | import Ubuntu.Components 0.1 | ||
702 | 21 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
703 | 22 | |||
704 | 23 | ListItem.Caption { | ||
705 | 24 | anchors.left: parent.left | ||
706 | 25 | anchors.right: parent.right | ||
707 | 26 | anchors.margins: units.gu(2) | ||
708 | 27 | text: i18n.tr("Storing account details here lets apps use the accounts without you having to sign in for each app.") | ||
709 | 28 | } | ||
710 | 0 | 29 | ||
711 | === added file 'system-settings-plugin/AuthorizationPage.qml' | |||
712 | --- system-settings-plugin/AuthorizationPage.qml 1970-01-01 00:00:00 +0000 | |||
713 | +++ system-settings-plugin/AuthorizationPage.qml 2014-08-11 13:15:20 +0000 | |||
714 | @@ -0,0 +1,75 @@ | |||
715 | 1 | /* | ||
716 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
717 | 3 | * | ||
718 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
719 | 5 | * | ||
720 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
721 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
722 | 8 | * by the Free Software Foundation. | ||
723 | 9 | * | ||
724 | 10 | * This program is distributed in the hope that it will be useful, but | ||
725 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
726 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
727 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
728 | 14 | * | ||
729 | 15 | * You should have received a copy of the GNU General Public License along | ||
730 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
731 | 17 | */ | ||
732 | 18 | |||
733 | 19 | import QtQuick 2.0 | ||
734 | 20 | import Ubuntu.Components 0.1 | ||
735 | 21 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
736 | 22 | |||
737 | 23 | Flickable { | ||
738 | 24 | id: root | ||
739 | 25 | |||
740 | 26 | property variant model | ||
741 | 27 | property variant application | ||
742 | 28 | property variant provider | ||
743 | 29 | |||
744 | 30 | signal allowed(int accountId) | ||
745 | 31 | signal denied | ||
746 | 32 | signal createAccount | ||
747 | 33 | |||
748 | 34 | Column { | ||
749 | 35 | anchors.left: parent.left | ||
750 | 36 | anchors.right: parent.right | ||
751 | 37 | |||
752 | 38 | Label { | ||
753 | 39 | anchors.left: parent.left | ||
754 | 40 | anchors.right: parent.right | ||
755 | 41 | text: i18n.tr("%1 wants to access your %2 account"). | ||
756 | 42 | arg(application.displayName).arg(provider.displayName); | ||
757 | 43 | wrapMode: Text.WordWrap | ||
758 | 44 | } | ||
759 | 45 | |||
760 | 46 | ListItem.ItemSelector { | ||
761 | 47 | id: accountSelector | ||
762 | 48 | anchors.left: parent.left | ||
763 | 49 | anchors.right: parent.right | ||
764 | 50 | text: "Account" | ||
765 | 51 | model: root.model | ||
766 | 52 | delegate: OptionSelectorDelegate { | ||
767 | 53 | property string modelData: model.displayName | ||
768 | 54 | } | ||
769 | 55 | onDelegateClicked: { | ||
770 | 56 | /* The last item in the model is the "Add another..." label */ | ||
771 | 57 | if (index == model.count - 1) root.createAccount(); | ||
772 | 58 | } | ||
773 | 59 | } | ||
774 | 60 | |||
775 | 61 | Button { | ||
776 | 62 | anchors.horizontalCenter: parent.horizontalCenter | ||
777 | 63 | width: parent.width - units.gu(4) | ||
778 | 64 | text: i18n.tr("Allow") | ||
779 | 65 | onClicked: root.allowed(root.model.get(accountSelector.selectedIndex, "accountId")) | ||
780 | 66 | } | ||
781 | 67 | |||
782 | 68 | Button { | ||
783 | 69 | anchors.horizontalCenter: parent.horizontalCenter | ||
784 | 70 | width: parent.width - units.gu(4) | ||
785 | 71 | text: i18n.tr("Don't allow") | ||
786 | 72 | onClicked: root.denied() | ||
787 | 73 | } | ||
788 | 74 | } | ||
789 | 75 | } | ||
790 | 0 | 76 | ||
791 | === added file 'system-settings-plugin/EntryComponent.qml' | |||
792 | --- system-settings-plugin/EntryComponent.qml 1970-01-01 00:00:00 +0000 | |||
793 | +++ system-settings-plugin/EntryComponent.qml 2014-08-11 13:15:20 +0000 | |||
794 | @@ -0,0 +1,33 @@ | |||
795 | 1 | /* | ||
796 | 2 | * This file is part of system-settings | ||
797 | 3 | * | ||
798 | 4 | * Copyright (C) 2013 Canonical Ltd. | ||
799 | 5 | * | ||
800 | 6 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
801 | 7 | * | ||
802 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
803 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
804 | 10 | * by the Free Software Foundation. | ||
805 | 11 | * | ||
806 | 12 | * This program is distributed in the hope that it will be useful, but | ||
807 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
808 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
809 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
810 | 16 | * | ||
811 | 17 | * You should have received a copy of the GNU General Public License along | ||
812 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
813 | 19 | */ | ||
814 | 20 | |||
815 | 21 | import QtQuick 2.0 | ||
816 | 22 | import Ubuntu.Components 0.1 | ||
817 | 23 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
818 | 24 | |||
819 | 25 | ListItem.Standard { | ||
820 | 26 | id: root | ||
821 | 27 | |||
822 | 28 | objectName: "entryComponent-about" | ||
823 | 29 | iconSource: Qt.resolvedUrl(model.icon) | ||
824 | 30 | iconFrame: false | ||
825 | 31 | text: i18n.tr(model.displayName) | ||
826 | 32 | progression: true | ||
827 | 33 | } | ||
828 | 0 | 34 | ||
829 | === added file 'system-settings-plugin/MainPage.qml' | |||
830 | --- system-settings-plugin/MainPage.qml 1970-01-01 00:00:00 +0000 | |||
831 | +++ system-settings-plugin/MainPage.qml 2014-08-11 13:15:20 +0000 | |||
832 | @@ -0,0 +1,66 @@ | |||
833 | 1 | /* | ||
834 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
835 | 3 | * | ||
836 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
837 | 5 | * | ||
838 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
839 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
840 | 8 | * by the Free Software Foundation. | ||
841 | 9 | * | ||
842 | 10 | * This program is distributed in the hope that it will be useful, but | ||
843 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
844 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
845 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
846 | 14 | * | ||
847 | 15 | * You should have received a copy of the GNU General Public License along | ||
848 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
849 | 17 | */ | ||
850 | 18 | |||
851 | 19 | import QtQuick 2.0 | ||
852 | 20 | import SystemSettings 1.0 | ||
853 | 21 | import Ubuntu.Components 0.1 | ||
854 | 22 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
855 | 23 | import Ubuntu.OnlineAccounts 0.1 | ||
856 | 24 | |||
857 | 25 | ItemPage { | ||
858 | 26 | id: root | ||
859 | 27 | objectName: "accountsPage" | ||
860 | 28 | |||
861 | 29 | title: i18n.tr("Accounts") | ||
862 | 30 | |||
863 | 31 | // OnlineAccountsPanel { | ||
864 | 32 | // id: onlineAccountsPanel | ||
865 | 33 | // } | ||
866 | 34 | |||
867 | 35 | property Item flickable: accountsPage.visible ? accountsPage : noAccountsPage | ||
868 | 36 | |||
869 | 37 | AccountServiceModel { | ||
870 | 38 | id: accountsModel | ||
871 | 39 | service: "global" | ||
872 | 40 | includeDisabled: true | ||
873 | 41 | } | ||
874 | 42 | |||
875 | 43 | AccountsPage { | ||
876 | 44 | id: accountsPage | ||
877 | 45 | anchors.fill: parent | ||
878 | 46 | accountsModel: accountsModel | ||
879 | 47 | visible: accountsModel.count > 0 | ||
880 | 48 | } | ||
881 | 49 | |||
882 | 50 | NoAccountsPage { | ||
883 | 51 | id: noAccountsPage | ||
884 | 52 | anchors.fill: parent | ||
885 | 53 | accountsModel: accountsModel | ||
886 | 54 | visible:!accountsPage.visible | ||
887 | 55 | } | ||
888 | 56 | |||
889 | 57 | |||
890 | 58 | Component { | ||
891 | 59 | id: accountCreationPage | ||
892 | 60 | AccountCreationPage { | ||
893 | 61 | providerId: pluginOptions.provider | ||
894 | 62 | } | ||
895 | 63 | } | ||
896 | 64 | |||
897 | 65 | } | ||
898 | 66 | |||
899 | 0 | 67 | ||
900 | === added file 'system-settings-plugin/NewAccountPage.qml' | |||
901 | --- system-settings-plugin/NewAccountPage.qml 1970-01-01 00:00:00 +0000 | |||
902 | +++ system-settings-plugin/NewAccountPage.qml 2014-08-11 13:15:20 +0000 | |||
903 | @@ -0,0 +1,38 @@ | |||
904 | 1 | /* | ||
905 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
906 | 3 | * | ||
907 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
908 | 5 | * | ||
909 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
910 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
911 | 8 | * by the Free Software Foundation. | ||
912 | 9 | * | ||
913 | 10 | * This program is distributed in the hope that it will be useful, but | ||
914 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
915 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
916 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
917 | 14 | * | ||
918 | 15 | * You should have received a copy of the GNU General Public License along | ||
919 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
920 | 17 | */ | ||
921 | 18 | |||
922 | 19 | import QtQuick 2.0 | ||
923 | 20 | import Ubuntu.Components 0.1 | ||
924 | 21 | |||
925 | 22 | Page { | ||
926 | 23 | title: i18n.tr("Add account") | ||
927 | 24 | |||
928 | 25 | Flickable { | ||
929 | 26 | anchors.fill: parent | ||
930 | 27 | contentHeight: contentItem.childrenRect.height | ||
931 | 28 | boundsBehavior: Flickable.StopAtBounds | ||
932 | 29 | |||
933 | 30 | ProviderPluginList { | ||
934 | 31 | onCreationFinished: { | ||
935 | 32 | // pop the creation page and this page (go back to parent page) | ||
936 | 33 | pageStack.pop() | ||
937 | 34 | pageStack.pop() | ||
938 | 35 | } | ||
939 | 36 | } | ||
940 | 37 | } | ||
941 | 38 | } | ||
942 | 0 | 39 | ||
943 | === added file 'system-settings-plugin/NoAccountsPage.qml' | |||
944 | --- system-settings-plugin/NoAccountsPage.qml 1970-01-01 00:00:00 +0000 | |||
945 | +++ system-settings-plugin/NoAccountsPage.qml 2014-08-11 13:15:20 +0000 | |||
946 | @@ -0,0 +1,54 @@ | |||
947 | 1 | /* | ||
948 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
949 | 3 | * | ||
950 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
951 | 5 | * | ||
952 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
953 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
954 | 8 | * by the Free Software Foundation. | ||
955 | 9 | * | ||
956 | 10 | * This program is distributed in the hope that it will be useful, but | ||
957 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
958 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
959 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
960 | 14 | * | ||
961 | 15 | * You should have received a copy of the GNU General Public License along | ||
962 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
963 | 17 | */ | ||
964 | 18 | |||
965 | 19 | import QtQuick 2.0 | ||
966 | 20 | import Ubuntu.Components 0.1 | ||
967 | 21 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
968 | 22 | |||
969 | 23 | Flickable { | ||
970 | 24 | id: root | ||
971 | 25 | |||
972 | 26 | property variant accountsModel | ||
973 | 27 | contentHeight: contentItem.childrenRect.height | ||
974 | 28 | boundsBehavior: Flickable.StopAtBounds | ||
975 | 29 | |||
976 | 30 | Column { | ||
977 | 31 | anchors.left: parent.left | ||
978 | 32 | anchors.right: parent.right | ||
979 | 33 | |||
980 | 34 | ListItem.Base { | ||
981 | 35 | Label { | ||
982 | 36 | text: i18n.tr("No accounts") | ||
983 | 37 | anchors.centerIn: parent | ||
984 | 38 | } | ||
985 | 39 | } | ||
986 | 40 | |||
987 | 41 | AddAccountLabel {} | ||
988 | 42 | |||
989 | 43 | ListItem.Standard { | ||
990 | 44 | text: i18n.tr("Add account:") | ||
991 | 45 | } | ||
992 | 46 | |||
993 | 47 | ProviderPluginList { | ||
994 | 48 | onCreationFinished: { | ||
995 | 49 | // pop the creation page; remain in this page | ||
996 | 50 | pageStack.pop() | ||
997 | 51 | } | ||
998 | 52 | } | ||
999 | 53 | } | ||
1000 | 54 | } | ||
1001 | 0 | 55 | ||
1002 | === added file 'system-settings-plugin/NormalStartupPage.qml' | |||
1003 | --- system-settings-plugin/NormalStartupPage.qml 1970-01-01 00:00:00 +0000 | |||
1004 | +++ system-settings-plugin/NormalStartupPage.qml 2014-08-11 13:15:20 +0000 | |||
1005 | @@ -0,0 +1,46 @@ | |||
1006 | 1 | /* | ||
1007 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
1008 | 3 | * | ||
1009 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1010 | 5 | * | ||
1011 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
1012 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
1013 | 8 | * by the Free Software Foundation. | ||
1014 | 9 | * | ||
1015 | 10 | * This program is distributed in the hope that it will be useful, but | ||
1016 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1017 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1018 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
1019 | 14 | * | ||
1020 | 15 | * You should have received a copy of the GNU General Public License along | ||
1021 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1022 | 17 | */ | ||
1023 | 18 | |||
1024 | 19 | import QtQuick 2.0 | ||
1025 | 20 | import Ubuntu.OnlineAccounts 0.1 | ||
1026 | 21 | |||
1027 | 22 | Item { | ||
1028 | 23 | id: root | ||
1029 | 24 | |||
1030 | 25 | property Item flickable: accountsPage.visible ? accountsPage : noAccountsPage | ||
1031 | 26 | |||
1032 | 27 | AccountServiceModel { | ||
1033 | 28 | id: accountsModel | ||
1034 | 29 | service: "global" | ||
1035 | 30 | includeDisabled: true | ||
1036 | 31 | } | ||
1037 | 32 | |||
1038 | 33 | AccountsPage { | ||
1039 | 34 | id: accountsPage | ||
1040 | 35 | anchors.fill: parent | ||
1041 | 36 | accountsModel: accountsModel | ||
1042 | 37 | visible: accountsModel.count > 0 | ||
1043 | 38 | } | ||
1044 | 39 | |||
1045 | 40 | NoAccountsPage { | ||
1046 | 41 | id: noAccountsPage | ||
1047 | 42 | anchors.fill: parent | ||
1048 | 43 | accountsModel: accountsModel | ||
1049 | 44 | visible: !accountsPage.visible | ||
1050 | 45 | } | ||
1051 | 46 | } | ||
1052 | 0 | 47 | ||
1053 | === added file 'system-settings-plugin/ProviderPluginList.qml' | |||
1054 | --- system-settings-plugin/ProviderPluginList.qml 1970-01-01 00:00:00 +0000 | |||
1055 | +++ system-settings-plugin/ProviderPluginList.qml 2014-08-11 13:15:20 +0000 | |||
1056 | @@ -0,0 +1,42 @@ | |||
1057 | 1 | /* | ||
1058 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
1059 | 3 | * | ||
1060 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1061 | 5 | * | ||
1062 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
1063 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
1064 | 8 | * by the Free Software Foundation. | ||
1065 | 9 | * | ||
1066 | 10 | * This program is distributed in the hope that it will be useful, but | ||
1067 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1068 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1069 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
1070 | 14 | * | ||
1071 | 15 | * You should have received a copy of the GNU General Public License along | ||
1072 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1073 | 17 | */ | ||
1074 | 18 | |||
1075 | 19 | import QtQuick 2.0 | ||
1076 | 20 | import Ubuntu.Components 0.1 | ||
1077 | 21 | |||
1078 | 22 | ProvidersList { | ||
1079 | 23 | id: root | ||
1080 | 24 | |||
1081 | 25 | property variant __creationPage: null | ||
1082 | 26 | |||
1083 | 27 | signal creationFinished | ||
1084 | 28 | |||
1085 | 29 | onProviderClicked: { | ||
1086 | 30 | __creationPage = accountCreationPage.createObject(null, { | ||
1087 | 31 | "providerId": providerId }) | ||
1088 | 32 | __creationPage.finished.connect(__onCreationFinished) | ||
1089 | 33 | pageStack.push(__creationPage) | ||
1090 | 34 | } | ||
1091 | 35 | |||
1092 | 36 | function __onCreationFinished() { | ||
1093 | 37 | __creationPage.destroy(1000) | ||
1094 | 38 | __creationPage.finished.disconnect(__onCreationFinished) | ||
1095 | 39 | __creationPage = null | ||
1096 | 40 | creationFinished() | ||
1097 | 41 | } | ||
1098 | 42 | } | ||
1099 | 0 | 43 | ||
1100 | === added file 'system-settings-plugin/ProvidersList.qml' | |||
1101 | --- system-settings-plugin/ProvidersList.qml 1970-01-01 00:00:00 +0000 | |||
1102 | +++ system-settings-plugin/ProvidersList.qml 2014-08-11 13:15:20 +0000 | |||
1103 | @@ -0,0 +1,62 @@ | |||
1104 | 1 | /* | ||
1105 | 2 | * Copyright (C) 2013 Canonical Ltd. | ||
1106 | 3 | * | ||
1107 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1108 | 5 | * | ||
1109 | 6 | * This program is free software: you can redistribute it and/or modify it | ||
1110 | 7 | * under the terms of the GNU General Public License version 3, as published | ||
1111 | 8 | * by the Free Software Foundation. | ||
1112 | 9 | * | ||
1113 | 10 | * This program is distributed in the hope that it will be useful, but | ||
1114 | 11 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1115 | 12 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1116 | 13 | * PURPOSE. See the GNU General Public License for more details. | ||
1117 | 14 | * | ||
1118 | 15 | * You should have received a copy of the GNU General Public License along | ||
1119 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1120 | 17 | */ | ||
1121 | 18 | |||
1122 | 19 | import QtQuick 2.0 | ||
1123 | 20 | import Ubuntu.Components 0.1 | ||
1124 | 21 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
1125 | 22 | import Ubuntu.OnlineAccounts 0.1 | ||
1126 | 23 | |||
1127 | 24 | Column { | ||
1128 | 25 | id: root | ||
1129 | 26 | |||
1130 | 27 | signal providerClicked(string providerId) | ||
1131 | 28 | |||
1132 | 29 | anchors.left: parent.left | ||
1133 | 30 | anchors.right: parent.right | ||
1134 | 31 | |||
1135 | 32 | ProviderModel { | ||
1136 | 33 | id: providerModel | ||
1137 | 34 | } | ||
1138 | 35 | |||
1139 | 36 | Repeater { | ||
1140 | 37 | model: providerModel | ||
1141 | 38 | |||
1142 | 39 | delegate: ListItem.Standard { | ||
1143 | 40 | text: displayName | ||
1144 | 41 | enabled: !isSingleAccount || hasNoAccounts(providerId) | ||
1145 | 42 | iconName: model.iconName | ||
1146 | 43 | progression: true | ||
1147 | 44 | onClicked: root.providerClicked(providerId) | ||
1148 | 45 | } | ||
1149 | 46 | } | ||
1150 | 47 | |||
1151 | 48 | Component { | ||
1152 | 49 | id: accountModel | ||
1153 | 50 | AccountServiceModel { | ||
1154 | 51 | includeDisabled: true | ||
1155 | 52 | } | ||
1156 | 53 | } | ||
1157 | 54 | |||
1158 | 55 | function hasNoAccounts(providerId) { | ||
1159 | 56 | var model = accountModel.createObject(null, { | ||
1160 | 57 | "provider": providerId }) | ||
1161 | 58 | var hasAccounts = (model.count > 0) | ||
1162 | 59 | model.destroy() | ||
1163 | 60 | return !hasAccounts | ||
1164 | 61 | } | ||
1165 | 62 | } | ||
1166 | 0 | 63 | ||
1167 | === modified file 'system-settings-plugin/online-accounts.settings' | |||
1168 | --- system-settings-plugin/online-accounts.settings 2013-09-09 10:56:53 +0000 | |||
1169 | +++ system-settings-plugin/online-accounts.settings 2014-08-11 13:15:20 +0000 | |||
1170 | @@ -11,5 +11,6 @@ | |||
1171 | 11 | ], | 11 | ], |
1172 | 12 | "has-dynamic-keywords": true, | 12 | "has-dynamic-keywords": true, |
1173 | 13 | "has-dynamic-visibility": false, | 13 | "has-dynamic-visibility": false, |
1175 | 14 | "plugin": "online-accounts" | 14 | "entry-component": "EntryComponent.qml", |
1176 | 15 | "page-component": "MainPage.qml" | ||
1177 | 15 | } | 16 | } |
1178 | 16 | 17 | ||
1179 | === modified file 'system-settings-plugin/plugin.cpp' | |||
1180 | --- system-settings-plugin/plugin.cpp 2014-05-30 08:55:40 +0000 | |||
1181 | +++ system-settings-plugin/plugin.cpp 2014-08-11 13:15:20 +0000 | |||
1182 | @@ -16,74 +16,21 @@ | |||
1183 | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
1184 | 17 | */ | 17 | */ |
1185 | 18 | 18 | ||
1186 | 19 | #include <QtQml> | ||
1187 | 20 | #include <QtQml/QQmlContext> | ||
1188 | 19 | #include "plugin.h" | 21 | #include "plugin.h" |
1259 | 20 | 22 | // #include "accounts.h" | |
1260 | 21 | #include <OnlineAccountsClient/Setup> | 23 | |
1261 | 22 | #include <QDebug> | 24 | |
1262 | 23 | #include <QStringList> | 25 | void BackendPlugin::registerTypes(const char *uri) |
1263 | 24 | #include <SystemSettings/ItemBase> | 26 | { |
1264 | 25 | 27 | Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.OnlineAccounts")); | |
1265 | 26 | using namespace SystemSettings; | 28 | |
1266 | 27 | 29 | qDebug() << uri; | |
1267 | 28 | class Item: public ItemBase | 30 | // qmlRegisterType<OnlineAccounts>(uri, 1, 0, "OnlineAccountsPanel"); |
1268 | 29 | { | 31 | } |
1269 | 30 | Q_OBJECT | 32 | |
1270 | 31 | 33 | void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | |
1271 | 32 | public: | 34 | { |
1272 | 33 | Item(const QVariantMap &staticData, QObject *parent = 0); | 35 | QQmlExtensionPlugin::initializeEngine(engine, uri); |
1273 | 34 | ~Item(); | 36 | } |
1204 | 35 | |||
1205 | 36 | QQmlComponent *pageComponent(QQmlEngine *engine, | ||
1206 | 37 | QObject *parent = 0) Q_DECL_OVERRIDE; | ||
1207 | 38 | |||
1208 | 39 | private Q_SLOTS: | ||
1209 | 40 | void onFinished(); | ||
1210 | 41 | |||
1211 | 42 | private: | ||
1212 | 43 | OnlineAccountsClient::Setup m_setup; | ||
1213 | 44 | bool m_isOpen; | ||
1214 | 45 | }; | ||
1215 | 46 | |||
1216 | 47 | Item::Item(const QVariantMap &staticData, QObject *parent): | ||
1217 | 48 | ItemBase(staticData, parent), | ||
1218 | 49 | m_isOpen(false) | ||
1219 | 50 | { | ||
1220 | 51 | QObject::connect(&m_setup, SIGNAL(finished()), | ||
1221 | 52 | this, SLOT(onFinished())); | ||
1222 | 53 | } | ||
1223 | 54 | |||
1224 | 55 | Item::~Item() | ||
1225 | 56 | { | ||
1226 | 57 | } | ||
1227 | 58 | |||
1228 | 59 | QQmlComponent *Item::pageComponent(QQmlEngine *engine, | ||
1229 | 60 | QObject *parent) | ||
1230 | 61 | { | ||
1231 | 62 | Q_UNUSED(engine); | ||
1232 | 63 | Q_UNUSED(parent); | ||
1233 | 64 | |||
1234 | 65 | if (!m_isOpen) { | ||
1235 | 66 | qDebug() << "Opening Online Accounts"; | ||
1236 | 67 | m_isOpen = true; | ||
1237 | 68 | m_setup.exec(); | ||
1238 | 69 | } | ||
1239 | 70 | return 0; | ||
1240 | 71 | } | ||
1241 | 72 | |||
1242 | 73 | void Item::onFinished() | ||
1243 | 74 | { | ||
1244 | 75 | m_isOpen = false; | ||
1245 | 76 | } | ||
1246 | 77 | |||
1247 | 78 | Plugin::Plugin(): | ||
1248 | 79 | QObject() | ||
1249 | 80 | { | ||
1250 | 81 | } | ||
1251 | 82 | |||
1252 | 83 | ItemBase *Plugin::createItem(const QVariantMap &staticData, | ||
1253 | 84 | QObject *parent) | ||
1254 | 85 | { | ||
1255 | 86 | return new Item(staticData, parent); | ||
1256 | 87 | } | ||
1257 | 88 | |||
1258 | 89 | #include "plugin.moc" | ||
1274 | 90 | 37 | ||
1275 | === modified file 'system-settings-plugin/plugin.h' | |||
1276 | --- system-settings-plugin/plugin.h 2013-09-09 10:56:53 +0000 | |||
1277 | +++ system-settings-plugin/plugin.h 2014-08-11 13:15:20 +0000 | |||
1278 | @@ -19,20 +19,17 @@ | |||
1279 | 19 | #ifndef ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H | 19 | #ifndef ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H |
1280 | 20 | #define ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H | 20 | #define ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H |
1281 | 21 | 21 | ||
1284 | 22 | #include <QObject> | 22 | #include <QtQml/QQmlEngine> |
1285 | 23 | #include <SystemSettings/PluginInterface> | 23 | #include <QtQml/QQmlExtensionPlugin> |
1286 | 24 | 24 | ||
1288 | 25 | class Plugin: public QObject, public SystemSettings::PluginInterface | 25 | class BackendPlugin : public QQmlExtensionPlugin |
1289 | 26 | { | 26 | { |
1290 | 27 | Q_OBJECT | 27 | Q_OBJECT |
1293 | 28 | Q_PLUGIN_METADATA(IID "com.ubuntu.SystemSettings.PluginInterface") | 28 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
1292 | 29 | Q_INTERFACES(SystemSettings::PluginInterface) | ||
1294 | 30 | 29 | ||
1295 | 31 | public: | 30 | public: |
1300 | 32 | Plugin(); | 31 | void registerTypes(const char *uri); |
1301 | 33 | 32 | void initializeEngine(QQmlEngine *engine, const char *uri); | |
1298 | 34 | SystemSettings::ItemBase *createItem(const QVariantMap &staticData, | ||
1299 | 35 | QObject *parent = 0); | ||
1302 | 36 | }; | 33 | }; |
1303 | 37 | 34 | ||
1304 | 38 | #endif // ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H | 35 | #endif // ONLINE_ACCOUNTS_SYSTEM_SETTINGS_PLUGIN_H |
1305 | 39 | 36 | ||
1306 | === modified file 'system-settings-plugin/system-settings-plugin.pro' | |||
1307 | --- system-settings-plugin/system-settings-plugin.pro 2013-09-09 10:56:53 +0000 | |||
1308 | +++ system-settings-plugin/system-settings-plugin.pro 2014-08-11 13:15:20 +0000 | |||
1309 | @@ -4,6 +4,21 @@ | |||
1310 | 4 | TEMPLATE = lib | 4 | TEMPLATE = lib |
1311 | 5 | TARGET = online-accounts | 5 | TARGET = online-accounts |
1312 | 6 | 6 | ||
1313 | 7 | QML_SOURCES = \ | ||
1314 | 8 | AccountEditPage.qml \ | ||
1315 | 9 | AccountCreationPage.qml \ | ||
1316 | 10 | AuthorizationPage.qml \ | ||
1317 | 11 | NoAccountsPage.qml \ | ||
1318 | 12 | AccountItem.qml \ | ||
1319 | 13 | EntryComponent.qml \ | ||
1320 | 14 | NormalStartupPage.qml \ | ||
1321 | 15 | AccountsPage.qml \ | ||
1322 | 16 | MainPage.qml \ | ||
1323 | 17 | ProviderPluginList.qml \ | ||
1324 | 18 | AddAccountLabel.qml \ | ||
1325 | 19 | NewAccountPage.qml \ | ||
1326 | 20 | ProvidersList.qml | ||
1327 | 21 | |||
1328 | 7 | CONFIG += \ | 22 | CONFIG += \ |
1329 | 8 | link_pkgconfig \ | 23 | link_pkgconfig \ |
1330 | 9 | plugin \ | 24 | plugin \ |
1331 | @@ -39,3 +54,6 @@ | |||
1332 | 39 | image.path = $${PLUGIN_MANIFEST_DIR}/icons | 54 | image.path = $${PLUGIN_MANIFEST_DIR}/icons |
1333 | 40 | INSTALLS += image | 55 | INSTALLS += image |
1334 | 41 | 56 | ||
1335 | 57 | qml.files = $${QML_SOURCES} | ||
1336 | 58 | qml.path = $${PLUGIN_QML_DIR}/online-accounts | ||
1337 | 59 | INSTALLS += qml | ||
1338 | 42 | 60 | ||
1339 | === added file 'tests/online-accounts-ui/data/com.ubuntu.tests_application.application' | |||
1340 | --- tests/online-accounts-ui/data/com.ubuntu.tests_application.application 1970-01-01 00:00:00 +0000 | |||
1341 | +++ tests/online-accounts-ui/data/com.ubuntu.tests_application.application 2014-08-11 13:15:20 +0000 | |||
1342 | @@ -0,0 +1,19 @@ | |||
1343 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
1344 | 2 | <application id="com.ubuntu.tests_application"> | ||
1345 | 3 | <description>Mailer</description> | ||
1346 | 4 | <translations>mailer-catalog</translations> | ||
1347 | 5 | <desktop-entry>mailer.desktop</desktop-entry> | ||
1348 | 6 | |||
1349 | 7 | <service-types> | ||
1350 | 8 | <service-type id="e-mail"> | ||
1351 | 9 | <description>Mailer can retrieve your e-mails</description> | ||
1352 | 10 | </service-type> | ||
1353 | 11 | </service-types> | ||
1354 | 12 | |||
1355 | 13 | <services> | ||
1356 | 14 | <service id="coolshare"> | ||
1357 | 15 | <description>Mailer can even share stuff on CoolShare</description> | ||
1358 | 16 | </service> | ||
1359 | 17 | </services> | ||
1360 | 18 | <profile>com.ubuntu.tests_application_0.3</profile> | ||
1361 | 19 | </application> | ||
1362 | 0 | 20 | ||
1363 | === added file 'tests/online-accounts-ui/mock/notification-mock.cpp' | |||
1364 | --- tests/online-accounts-ui/mock/notification-mock.cpp 1970-01-01 00:00:00 +0000 | |||
1365 | +++ tests/online-accounts-ui/mock/notification-mock.cpp 2014-08-11 13:15:20 +0000 | |||
1366 | @@ -0,0 +1,81 @@ | |||
1367 | 1 | /* | ||
1368 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
1369 | 3 | * | ||
1370 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1371 | 5 | * | ||
1372 | 6 | * This file is part of online-accounts-ui | ||
1373 | 7 | * | ||
1374 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
1375 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
1376 | 10 | * by the Free Software Foundation. | ||
1377 | 11 | * | ||
1378 | 12 | * This program is distributed in the hope that it will be useful, but | ||
1379 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1380 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1381 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
1382 | 16 | * | ||
1383 | 17 | * You should have received a copy of the GNU General Public License along | ||
1384 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1385 | 19 | */ | ||
1386 | 20 | |||
1387 | 21 | #include "notification-mock.h" | ||
1388 | 22 | |||
1389 | 23 | #include <QByteArray> | ||
1390 | 24 | #include <QDebug> | ||
1391 | 25 | #include <QString> | ||
1392 | 26 | |||
1393 | 27 | using namespace OnlineAccountsUi; | ||
1394 | 28 | |||
1395 | 29 | QList<Notification*> NotificationPrivate::allNotifications; | ||
1396 | 30 | |||
1397 | 31 | NotificationPrivate::NotificationPrivate(const QString &summary, | ||
1398 | 32 | const QString &body, | ||
1399 | 33 | Notification *notification): | ||
1400 | 34 | QObject(notification), | ||
1401 | 35 | m_summary(summary), | ||
1402 | 36 | m_body(body), | ||
1403 | 37 | q_ptr(notification) | ||
1404 | 38 | { | ||
1405 | 39 | allNotifications.append(notification); | ||
1406 | 40 | } | ||
1407 | 41 | |||
1408 | 42 | NotificationPrivate::~NotificationPrivate() | ||
1409 | 43 | { | ||
1410 | 44 | allNotifications.removeAll(q_ptr); | ||
1411 | 45 | } | ||
1412 | 46 | |||
1413 | 47 | void NotificationPrivate::invokeAction(const QString &action) | ||
1414 | 48 | { | ||
1415 | 49 | Q_Q(Notification); | ||
1416 | 50 | Q_EMIT q->actionInvoked(action); | ||
1417 | 51 | } | ||
1418 | 52 | |||
1419 | 53 | Notification::Notification(const QString &summary, | ||
1420 | 54 | const QString &body, | ||
1421 | 55 | QObject *parent): | ||
1422 | 56 | QObject(parent), | ||
1423 | 57 | d_ptr(new NotificationPrivate(summary, body, this)) | ||
1424 | 58 | { | ||
1425 | 59 | } | ||
1426 | 60 | |||
1427 | 61 | Notification::~Notification() | ||
1428 | 62 | { | ||
1429 | 63 | } | ||
1430 | 64 | |||
1431 | 65 | void Notification::addAction(const QString &action, const QString &label) | ||
1432 | 66 | { | ||
1433 | 67 | Q_D(Notification); | ||
1434 | 68 | d->m_actions.append(ActionPair(action, label)); | ||
1435 | 69 | } | ||
1436 | 70 | |||
1437 | 71 | void Notification::setSnapDecision(bool snapDecision) | ||
1438 | 72 | { | ||
1439 | 73 | Q_D(Notification); | ||
1440 | 74 | d->m_isSnapDecision = snapDecision; | ||
1441 | 75 | } | ||
1442 | 76 | |||
1443 | 77 | void Notification::show() | ||
1444 | 78 | { | ||
1445 | 79 | Q_D(Notification); | ||
1446 | 80 | Q_EMIT d->showCalled(); | ||
1447 | 81 | } | ||
1448 | 0 | 82 | ||
1449 | === added file 'tests/online-accounts-ui/mock/notification-mock.h' | |||
1450 | --- tests/online-accounts-ui/mock/notification-mock.h 1970-01-01 00:00:00 +0000 | |||
1451 | +++ tests/online-accounts-ui/mock/notification-mock.h 2014-08-11 13:15:20 +0000 | |||
1452 | @@ -0,0 +1,66 @@ | |||
1453 | 1 | /* | ||
1454 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
1455 | 3 | * | ||
1456 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1457 | 5 | * | ||
1458 | 6 | * This file is part of online-accounts-ui | ||
1459 | 7 | * | ||
1460 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
1461 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
1462 | 10 | * by the Free Software Foundation. | ||
1463 | 11 | * | ||
1464 | 12 | * This program is distributed in the hope that it will be useful, but | ||
1465 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1466 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1467 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
1468 | 16 | * | ||
1469 | 17 | * You should have received a copy of the GNU General Public License along | ||
1470 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1471 | 19 | */ | ||
1472 | 20 | |||
1473 | 21 | #ifndef MOCK_NOTIFICATiON_H | ||
1474 | 22 | #define MOCK_NOTIFICATiON_H | ||
1475 | 23 | |||
1476 | 24 | #include "notification.h" | ||
1477 | 25 | |||
1478 | 26 | #include <QByteArray> | ||
1479 | 27 | #include <QList> | ||
1480 | 28 | #include <QPair> | ||
1481 | 29 | #include <QString> | ||
1482 | 30 | |||
1483 | 31 | using namespace OnlineAccountsUi; | ||
1484 | 32 | |||
1485 | 33 | namespace OnlineAccountsUi { | ||
1486 | 34 | |||
1487 | 35 | typedef QPair<QString,QString> ActionPair; | ||
1488 | 36 | |||
1489 | 37 | class NotificationPrivate: public QObject | ||
1490 | 38 | { | ||
1491 | 39 | Q_OBJECT | ||
1492 | 40 | Q_DECLARE_PUBLIC(Notification) | ||
1493 | 41 | |||
1494 | 42 | public: | ||
1495 | 43 | NotificationPrivate(const QString &summary, | ||
1496 | 44 | const QString &body, | ||
1497 | 45 | Notification *notification); | ||
1498 | 46 | ~NotificationPrivate(); | ||
1499 | 47 | static NotificationPrivate *mocked(Notification *n) { return n->d_ptr; } | ||
1500 | 48 | |||
1501 | 49 | static QList<Notification *> allNotifications; | ||
1502 | 50 | |||
1503 | 51 | void invokeAction(const QString &action); | ||
1504 | 52 | |||
1505 | 53 | Q_SIGNALS: | ||
1506 | 54 | void showCalled(); | ||
1507 | 55 | |||
1508 | 56 | public: | ||
1509 | 57 | QString m_summary; | ||
1510 | 58 | QString m_body; | ||
1511 | 59 | QList<ActionPair> m_actions; | ||
1512 | 60 | bool m_isSnapDecision; | ||
1513 | 61 | mutable Notification *q_ptr; | ||
1514 | 62 | }; | ||
1515 | 63 | |||
1516 | 64 | } // namespace | ||
1517 | 65 | |||
1518 | 66 | #endif // MOCK_NOTIFICATiON_H | ||
1519 | 0 | 67 | ||
1520 | === added file 'tests/online-accounts-ui/mock/request-mock.cpp' | |||
1521 | --- tests/online-accounts-ui/mock/request-mock.cpp 1970-01-01 00:00:00 +0000 | |||
1522 | +++ tests/online-accounts-ui/mock/request-mock.cpp 2014-08-11 13:15:20 +0000 | |||
1523 | @@ -0,0 +1,136 @@ | |||
1524 | 1 | /* | ||
1525 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
1526 | 3 | * | ||
1527 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1528 | 5 | * | ||
1529 | 6 | * This file is part of online-accounts-ui | ||
1530 | 7 | * | ||
1531 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
1532 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
1533 | 10 | * by the Free Software Foundation. | ||
1534 | 11 | * | ||
1535 | 12 | * This program is distributed in the hope that it will be useful, but | ||
1536 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1537 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1538 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
1539 | 16 | * | ||
1540 | 17 | * You should have received a copy of the GNU General Public License along | ||
1541 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1542 | 19 | */ | ||
1543 | 20 | |||
1544 | 21 | #include "globals.h" | ||
1545 | 22 | #include "request-mock.h" | ||
1546 | 23 | |||
1547 | 24 | #include <QDebug> | ||
1548 | 25 | |||
1549 | 26 | using namespace OnlineAccountsUi; | ||
1550 | 27 | |||
1551 | 28 | RequestPrivate::RequestPrivate(const QDBusConnection &connection, | ||
1552 | 29 | const QDBusMessage &message, | ||
1553 | 30 | const QVariantMap ¶meters, | ||
1554 | 31 | Request *request): | ||
1555 | 32 | QObject(request), | ||
1556 | 33 | q_ptr(request), | ||
1557 | 34 | m_parameters(parameters), | ||
1558 | 35 | m_window(0), | ||
1559 | 36 | m_inProgress(false) | ||
1560 | 37 | { | ||
1561 | 38 | Q_UNUSED(connection); | ||
1562 | 39 | Q_UNUSED(message); | ||
1563 | 40 | } | ||
1564 | 41 | |||
1565 | 42 | RequestPrivate::~RequestPrivate() | ||
1566 | 43 | { | ||
1567 | 44 | } | ||
1568 | 45 | |||
1569 | 46 | Request::Request(const QDBusConnection &connection, | ||
1570 | 47 | const QDBusMessage &message, | ||
1571 | 48 | const QVariantMap ¶meters, | ||
1572 | 49 | QObject *parent): | ||
1573 | 50 | QObject(parent), | ||
1574 | 51 | d_ptr(new RequestPrivate(connection, message, parameters, this)) | ||
1575 | 52 | { | ||
1576 | 53 | } | ||
1577 | 54 | |||
1578 | 55 | Request::~Request() | ||
1579 | 56 | { | ||
1580 | 57 | } | ||
1581 | 58 | |||
1582 | 59 | void Request::setWindow(QWindow *window) | ||
1583 | 60 | { | ||
1584 | 61 | Q_D(Request); | ||
1585 | 62 | Q_EMIT d->setWindowCalled(window); | ||
1586 | 63 | } | ||
1587 | 64 | |||
1588 | 65 | WId Request::windowId() const | ||
1589 | 66 | { | ||
1590 | 67 | Q_D(const Request); | ||
1591 | 68 | return d->m_parameters[OAU_KEY_WINDOW_ID].toUInt(); | ||
1592 | 69 | } | ||
1593 | 70 | |||
1594 | 71 | bool Request::isInProgress() const | ||
1595 | 72 | { | ||
1596 | 73 | Q_D(const Request); | ||
1597 | 74 | return d->m_inProgress; | ||
1598 | 75 | } | ||
1599 | 76 | |||
1600 | 77 | const QVariantMap &Request::parameters() const | ||
1601 | 78 | { | ||
1602 | 79 | Q_D(const Request); | ||
1603 | 80 | return d->m_parameters; | ||
1604 | 81 | } | ||
1605 | 82 | |||
1606 | 83 | QString Request::clientApparmorProfile() const | ||
1607 | 84 | { | ||
1608 | 85 | Q_D(const Request); | ||
1609 | 86 | return d->m_clientApparmorProfile; | ||
1610 | 87 | } | ||
1611 | 88 | |||
1612 | 89 | QWindow *Request::window() const | ||
1613 | 90 | { | ||
1614 | 91 | Q_D(const Request); | ||
1615 | 92 | return d->m_window; | ||
1616 | 93 | } | ||
1617 | 94 | |||
1618 | 95 | void Request::start() | ||
1619 | 96 | { | ||
1620 | 97 | Q_D(Request); | ||
1621 | 98 | if (d->m_inProgress) { | ||
1622 | 99 | qWarning() << "Request already started!"; | ||
1623 | 100 | return; | ||
1624 | 101 | } | ||
1625 | 102 | d->m_inProgress = true; | ||
1626 | 103 | } | ||
1627 | 104 | |||
1628 | 105 | void Request::cancel() | ||
1629 | 106 | { | ||
1630 | 107 | setCanceled(); | ||
1631 | 108 | } | ||
1632 | 109 | |||
1633 | 110 | void Request::fail(const QString &name, const QString &message) | ||
1634 | 111 | { | ||
1635 | 112 | Q_D(Request); | ||
1636 | 113 | Q_EMIT d->failCalled(name, message); | ||
1637 | 114 | |||
1638 | 115 | Q_EMIT completed(); | ||
1639 | 116 | } | ||
1640 | 117 | |||
1641 | 118 | void Request::setCanceled() | ||
1642 | 119 | { | ||
1643 | 120 | Q_D(Request); | ||
1644 | 121 | if (d->m_inProgress) { | ||
1645 | 122 | fail(OAU_ERROR_USER_CANCELED, QStringLiteral("Canceled")); | ||
1646 | 123 | d->m_inProgress = false; | ||
1647 | 124 | } | ||
1648 | 125 | } | ||
1649 | 126 | |||
1650 | 127 | void Request::setResult(const QVariantMap &result) | ||
1651 | 128 | { | ||
1652 | 129 | Q_D(Request); | ||
1653 | 130 | if (d->m_inProgress) { | ||
1654 | 131 | Q_EMIT d->setResultCalled(result); | ||
1655 | 132 | |||
1656 | 133 | Q_EMIT completed(); | ||
1657 | 134 | d->m_inProgress = false; | ||
1658 | 135 | } | ||
1659 | 136 | } | ||
1660 | 0 | 137 | ||
1661 | === added file 'tests/online-accounts-ui/mock/request-mock.h' | |||
1662 | --- tests/online-accounts-ui/mock/request-mock.h 1970-01-01 00:00:00 +0000 | |||
1663 | +++ tests/online-accounts-ui/mock/request-mock.h 2014-08-11 13:15:20 +0000 | |||
1664 | @@ -0,0 +1,64 @@ | |||
1665 | 1 | /* | ||
1666 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
1667 | 3 | * | ||
1668 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1669 | 5 | * | ||
1670 | 6 | * This file is part of online-accounts-ui | ||
1671 | 7 | * | ||
1672 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
1673 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
1674 | 10 | * by the Free Software Foundation. | ||
1675 | 11 | * | ||
1676 | 12 | * This program is distributed in the hope that it will be useful, but | ||
1677 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1678 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1679 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
1680 | 16 | * | ||
1681 | 17 | * You should have received a copy of the GNU General Public License along | ||
1682 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1683 | 19 | */ | ||
1684 | 20 | |||
1685 | 21 | #ifndef MOCK_REQUEST_H | ||
1686 | 22 | #define MOCK_REQUEST_H | ||
1687 | 23 | |||
1688 | 24 | #include "request.h" | ||
1689 | 25 | |||
1690 | 26 | #include <QObject> | ||
1691 | 27 | #include <QString> | ||
1692 | 28 | #include <QVariantMap> | ||
1693 | 29 | |||
1694 | 30 | namespace OnlineAccountsUi { | ||
1695 | 31 | |||
1696 | 32 | class RequestPrivate: public QObject | ||
1697 | 33 | { | ||
1698 | 34 | Q_OBJECT | ||
1699 | 35 | Q_DECLARE_PUBLIC(Request) | ||
1700 | 36 | |||
1701 | 37 | public: | ||
1702 | 38 | RequestPrivate(const QDBusConnection &connection, | ||
1703 | 39 | const QDBusMessage &message, | ||
1704 | 40 | const QVariantMap ¶meters, | ||
1705 | 41 | Request *request); | ||
1706 | 42 | ~RequestPrivate(); | ||
1707 | 43 | static RequestPrivate *mocked(Request *r) { return r->d_ptr; } | ||
1708 | 44 | |||
1709 | 45 | void setClientApparmorProfile(const QString &profile) { | ||
1710 | 46 | m_clientApparmorProfile = profile; | ||
1711 | 47 | } | ||
1712 | 48 | |||
1713 | 49 | Q_SIGNALS: | ||
1714 | 50 | void setWindowCalled(QWindow *); | ||
1715 | 51 | void failCalled(const QString &name, const QString &message); | ||
1716 | 52 | void setResultCalled(const QVariantMap &result); | ||
1717 | 53 | |||
1718 | 54 | private: | ||
1719 | 55 | mutable Request *q_ptr; | ||
1720 | 56 | QVariantMap m_parameters; | ||
1721 | 57 | QString m_clientApparmorProfile; | ||
1722 | 58 | QWindow *m_window; | ||
1723 | 59 | bool m_inProgress; | ||
1724 | 60 | }; | ||
1725 | 61 | |||
1726 | 62 | } // namespace | ||
1727 | 63 | |||
1728 | 64 | #endif // MOCK_REQUEST_H | ||
1729 | 0 | 65 | ||
1730 | === modified file 'tests/online-accounts-ui/online-accounts-ui.pro' | |||
1731 | --- tests/online-accounts-ui/online-accounts-ui.pro 2014-06-05 13:28:30 +0000 | |||
1732 | +++ tests/online-accounts-ui/online-accounts-ui.pro 2014-08-11 13:15:20 +0000 | |||
1733 | @@ -5,4 +5,5 @@ | |||
1734 | 5 | tst_application_manager.pro \ | 5 | tst_application_manager.pro \ |
1735 | 6 | tst_inactivity_timer.pro \ | 6 | tst_inactivity_timer.pro \ |
1736 | 7 | tst_notification.pro \ | 7 | tst_notification.pro \ |
1738 | 8 | tst_service.pro | 8 | tst_service.pro \ |
1739 | 9 | tst_signonui_request.pro | ||
1740 | 9 | 10 | ||
1741 | === modified file 'tests/online-accounts-ui/tst_notification.cpp' | |||
1742 | --- tests/online-accounts-ui/tst_notification.cpp 2014-06-05 13:28:30 +0000 | |||
1743 | +++ tests/online-accounts-ui/tst_notification.cpp 2014-08-11 13:15:20 +0000 | |||
1744 | @@ -26,6 +26,7 @@ | |||
1745 | 26 | #include <QPair> | 26 | #include <QPair> |
1746 | 27 | #include <QSignalSpy> | 27 | #include <QSignalSpy> |
1747 | 28 | #include <QTest> | 28 | #include <QTest> |
1748 | 29 | #include <QVariantMap> | ||
1749 | 29 | #include <libnotify/notification.h> | 30 | #include <libnotify/notification.h> |
1750 | 30 | #include <libnotify/notify.h> | 31 | #include <libnotify/notify.h> |
1751 | 31 | 32 | ||
1752 | @@ -52,6 +53,7 @@ | |||
1753 | 52 | QString summary; | 53 | QString summary; |
1754 | 53 | QString body; | 54 | QString body; |
1755 | 54 | QList<ActionPair> actions; | 55 | QList<ActionPair> actions; |
1756 | 56 | QVariantMap hints; | ||
1757 | 55 | bool visible; | 57 | bool visible; |
1758 | 56 | 58 | ||
1759 | 57 | MockNotification(); | 59 | MockNotification(); |
1760 | @@ -167,6 +169,22 @@ | |||
1761 | 167 | callbackData.userData = user_data; | 169 | callbackData.userData = user_data; |
1762 | 168 | } | 170 | } |
1763 | 169 | 171 | ||
1764 | 172 | void notify_notification_set_hint(NotifyNotification *notification, | ||
1765 | 173 | const char *key, | ||
1766 | 174 | GVariant *value) | ||
1767 | 175 | { | ||
1768 | 176 | MockNotification *mock = | ||
1769 | 177 | reinterpret_cast<MockNotification*>(notification); | ||
1770 | 178 | QVariant variant; | ||
1771 | 179 | if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) { | ||
1772 | 180 | variant = bool(g_variant_get_boolean(value)); | ||
1773 | 181 | } else { | ||
1774 | 182 | /* Add support for any needed types */ | ||
1775 | 183 | qWarning() << "Unsupported variant type"; | ||
1776 | 184 | } | ||
1777 | 185 | mock->hints.insert(QString::fromUtf8(key), variant); | ||
1778 | 186 | } | ||
1779 | 187 | |||
1780 | 170 | /* End of mock code */ | 188 | /* End of mock code */ |
1781 | 171 | 189 | ||
1782 | 172 | class NotificationTest: public QObject | 190 | class NotificationTest: public QObject |
1783 | @@ -180,6 +198,7 @@ | |||
1784 | 180 | void testInitialization(); | 198 | void testInitialization(); |
1785 | 181 | void testDestruction(); | 199 | void testDestruction(); |
1786 | 182 | void testContents(); | 200 | void testContents(); |
1787 | 201 | void testSnapDecision(); | ||
1788 | 183 | void testVisibility(); | 202 | void testVisibility(); |
1789 | 184 | void testClosing(); | 203 | void testClosing(); |
1790 | 185 | void testActions(); | 204 | void testActions(); |
1791 | @@ -220,6 +239,20 @@ | |||
1792 | 220 | MockNotification *mock = *(notifications.begin()); | 239 | MockNotification *mock = *(notifications.begin()); |
1793 | 221 | QCOMPARE(mock->summary, QString("Summary")); | 240 | QCOMPARE(mock->summary, QString("Summary")); |
1794 | 222 | QCOMPARE(mock->body, QString("Body")); | 241 | QCOMPARE(mock->body, QString("Body")); |
1795 | 242 | QVERIFY(mock->hints.isEmpty()); | ||
1796 | 243 | } | ||
1797 | 244 | |||
1798 | 245 | void NotificationTest::testSnapDecision() | ||
1799 | 246 | { | ||
1800 | 247 | Notification first("Summary", "Body"); | ||
1801 | 248 | MockNotification *mock = *(notifications.begin()); | ||
1802 | 249 | QVERIFY(mock->hints.isEmpty()); | ||
1803 | 250 | |||
1804 | 251 | first.setSnapDecision(true); | ||
1805 | 252 | QCOMPARE(mock->hints["x-canonical-snap-decisions"].toBool(), true); | ||
1806 | 253 | |||
1807 | 254 | first.setSnapDecision(false); | ||
1808 | 255 | QCOMPARE(mock->hints["x-canonical-snap-decisions"].toBool(), false); | ||
1809 | 223 | } | 256 | } |
1810 | 224 | 257 | ||
1811 | 225 | void NotificationTest::testVisibility() | 258 | void NotificationTest::testVisibility() |
1812 | 226 | 259 | ||
1813 | === added file 'tests/online-accounts-ui/tst_signonui_request.cpp' | |||
1814 | --- tests/online-accounts-ui/tst_signonui_request.cpp 1970-01-01 00:00:00 +0000 | |||
1815 | +++ tests/online-accounts-ui/tst_signonui_request.cpp 2014-08-11 13:15:20 +0000 | |||
1816 | @@ -0,0 +1,338 @@ | |||
1817 | 1 | /* | ||
1818 | 2 | * Copyright (C) 2014 Canonical Ltd. | ||
1819 | 3 | * | ||
1820 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
1821 | 5 | * | ||
1822 | 6 | * This file is part of online-accounts-ui | ||
1823 | 7 | * | ||
1824 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
1825 | 9 | * under the terms of the GNU General Public License version 3, as published | ||
1826 | 10 | * by the Free Software Foundation. | ||
1827 | 11 | * | ||
1828 | 12 | * This program is distributed in the hope that it will be useful, but | ||
1829 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1830 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1831 | 15 | * PURPOSE. See the GNU General Public License for more details. | ||
1832 | 16 | * | ||
1833 | 17 | * You should have received a copy of the GNU General Public License along | ||
1834 | 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1835 | 19 | */ | ||
1836 | 20 | |||
1837 | 21 | #include "globals.h" | ||
1838 | 22 | #include "request-handler.h" | ||
1839 | 23 | #include "signonui-request.h" | ||
1840 | 24 | #include "mock/notification-mock.h" | ||
1841 | 25 | #include "mock/request-mock.h" | ||
1842 | 26 | |||
1843 | 27 | #include <Accounts/Account> | ||
1844 | 28 | #include <Accounts/Manager> | ||
1845 | 29 | |||
1846 | 30 | #include <QDebug> | ||
1847 | 31 | #include <QSignalSpy> | ||
1848 | 32 | #include <QTemporaryDir> | ||
1849 | 33 | #include <QTest> | ||
1850 | 34 | |||
1851 | 35 | #include <SignOn/uisessiondata.h> | ||
1852 | 36 | #include <SignOn/uisessiondata_priv.h> | ||
1853 | 37 | |||
1854 | 38 | using namespace OnlineAccountsUi; | ||
1855 | 39 | |||
1856 | 40 | class TestRequest: public SignOnUi::Request | ||
1857 | 41 | { | ||
1858 | 42 | Q_OBJECT | ||
1859 | 43 | |||
1860 | 44 | public: | ||
1861 | 45 | TestRequest(const QDBusConnection &connection, | ||
1862 | 46 | const QDBusMessage &message, | ||
1863 | 47 | const QVariantMap ¶meters, | ||
1864 | 48 | QObject *parent = 0): | ||
1865 | 49 | Request(connection, message, parameters, parent) | ||
1866 | 50 | { | ||
1867 | 51 | } | ||
1868 | 52 | |||
1869 | 53 | void setWindow(QWindow *window) { Request::setWindow(window); } | ||
1870 | 54 | |||
1871 | 55 | void sendResult(const QVariantMap &result) { setResult(result); } | ||
1872 | 56 | }; | ||
1873 | 57 | |||
1874 | 58 | class SignonuiRequestTest: public QObject | ||
1875 | 59 | { | ||
1876 | 60 | Q_OBJECT | ||
1877 | 61 | |||
1878 | 62 | public: | ||
1879 | 63 | SignonuiRequestTest(); | ||
1880 | 64 | |||
1881 | 65 | private Q_SLOTS: | ||
1882 | 66 | void initTestCase(); | ||
1883 | 67 | void testParameters_data(); | ||
1884 | 68 | void testParameters(); | ||
1885 | 69 | void testHandler(); | ||
1886 | 70 | void testSnapDecision_data(); | ||
1887 | 71 | void testSnapDecision(); | ||
1888 | 72 | |||
1889 | 73 | private: | ||
1890 | 74 | bool mustCreateAccount(uint credentialsId) { return credentialsId > 10; } | ||
1891 | 75 | |||
1892 | 76 | private: | ||
1893 | 77 | QDBusConnection m_connection; | ||
1894 | 78 | QDBusMessage m_message; | ||
1895 | 79 | QTemporaryDir m_accountsDir; | ||
1896 | 80 | }; | ||
1897 | 81 | |||
1898 | 82 | SignonuiRequestTest::SignonuiRequestTest(): | ||
1899 | 83 | QObject(), | ||
1900 | 84 | m_connection(QStringLiteral("uninitialized")) | ||
1901 | 85 | { | ||
1902 | 86 | } | ||
1903 | 87 | |||
1904 | 88 | void SignonuiRequestTest::initTestCase() | ||
1905 | 89 | { | ||
1906 | 90 | QVERIFY(m_accountsDir.isValid()); | ||
1907 | 91 | |||
1908 | 92 | qputenv("ACCOUNTS", m_accountsDir.path().toUtf8()); | ||
1909 | 93 | qputenv("AG_APPLICATIONS", TEST_DATA_DIR); | ||
1910 | 94 | qputenv("AG_PROVIDERS", TEST_DATA_DIR); | ||
1911 | 95 | qputenv("AG_SERVICES", TEST_DATA_DIR); | ||
1912 | 96 | qputenv("XDG_DATA_HOME", TEST_DATA_DIR); | ||
1913 | 97 | } | ||
1914 | 98 | |||
1915 | 99 | void SignonuiRequestTest::testParameters_data() | ||
1916 | 100 | { | ||
1917 | 101 | QTest::addColumn<QVariantMap>("parameters"); | ||
1918 | 102 | QTest::addColumn<uint>("identity"); | ||
1919 | 103 | QTest::addColumn<QString>("method"); | ||
1920 | 104 | QTest::addColumn<QString>("mechanism"); | ||
1921 | 105 | QTest::addColumn<QString>("id"); | ||
1922 | 106 | QTest::addColumn<QVariantMap>("clientData"); | ||
1923 | 107 | |||
1924 | 108 | QTest::newRow("empty") << | ||
1925 | 109 | QVariantMap() << | ||
1926 | 110 | uint(0) << | ||
1927 | 111 | QString() << | ||
1928 | 112 | QString() << | ||
1929 | 113 | QString() << | ||
1930 | 114 | QVariantMap(); | ||
1931 | 115 | |||
1932 | 116 | QVariantMap clientData; | ||
1933 | 117 | clientData.insert("some number", 4); | ||
1934 | 118 | |||
1935 | 119 | QVariantMap parameters; | ||
1936 | 120 | parameters.insert(SSOUI_KEY_CLIENT_DATA, clientData); | ||
1937 | 121 | parameters.insert(SSOUI_KEY_IDENTITY, uint(45)); | ||
1938 | 122 | parameters.insert(SSOUI_KEY_METHOD, QString("a method")); | ||
1939 | 123 | parameters.insert(SSOUI_KEY_MECHANISM, QString("a mechanism")); | ||
1940 | 124 | parameters.insert(SSOUI_KEY_REQUESTID, QString("/id-4")); | ||
1941 | 125 | |||
1942 | 126 | |||
1943 | 127 | QTest::newRow("basic") << | ||
1944 | 128 | parameters << | ||
1945 | 129 | uint(45) << | ||
1946 | 130 | "a method" << | ||
1947 | 131 | "a mechanism" << | ||
1948 | 132 | "/id-4" << | ||
1949 | 133 | clientData; | ||
1950 | 134 | } | ||
1951 | 135 | |||
1952 | 136 | void SignonuiRequestTest::testParameters() | ||
1953 | 137 | { | ||
1954 | 138 | QFETCH(QVariantMap, parameters); | ||
1955 | 139 | QFETCH(QString, method); | ||
1956 | 140 | QFETCH(QString, mechanism); | ||
1957 | 141 | QFETCH(QString, id); | ||
1958 | 142 | QFETCH(QVariantMap, clientData); | ||
1959 | 143 | |||
1960 | 144 | TestRequest request(m_connection, m_message, parameters); | ||
1961 | 145 | QCOMPARE(request.method(), method); | ||
1962 | 146 | QCOMPARE(request.mechanism(), mechanism); | ||
1963 | 147 | QCOMPARE(request.id(), id); | ||
1964 | 148 | QCOMPARE(request.clientData(), clientData); | ||
1965 | 149 | } | ||
1966 | 150 | |||
1967 | 151 | void SignonuiRequestTest::testHandler() | ||
1968 | 152 | { | ||
1969 | 153 | QVariantMap parameters; | ||
1970 | 154 | TestRequest request(m_connection, m_message, parameters); | ||
1971 | 155 | QVERIFY(request.handler() == 0); | ||
1972 | 156 | |||
1973 | 157 | SignOnUi::RequestHandler *handler = new SignOnUi::RequestHandler; | ||
1974 | 158 | request.setHandler(handler); | ||
1975 | 159 | QCOMPARE(request.handler(), handler); | ||
1976 | 160 | |||
1977 | 161 | /* Try to set another handler; this won't be allowed */ | ||
1978 | 162 | SignOnUi::RequestHandler *handler2 = new SignOnUi::RequestHandler; | ||
1979 | 163 | request.setHandler(handler2); | ||
1980 | 164 | QCOMPARE(request.handler(), handler); | ||
1981 | 165 | |||
1982 | 166 | delete handler2; | ||
1983 | 167 | delete handler; | ||
1984 | 168 | } | ||
1985 | 169 | |||
1986 | 170 | void SignonuiRequestTest::testSnapDecision_data() | ||
1987 | 171 | { | ||
1988 | 172 | QTest::addColumn<uint>("credentialsId"); | ||
1989 | 173 | QTest::addColumn<QString>("accountName"); | ||
1990 | 174 | QTest::addColumn<QString>("clientProfile"); | ||
1991 | 175 | QTest::addColumn<QString>("applicationName"); | ||
1992 | 176 | QTest::addColumn<bool>("mustAccept"); | ||
1993 | 177 | QTest::addColumn<QVariantMap>("result"); | ||
1994 | 178 | |||
1995 | 179 | QVariantMap acceptedResult; | ||
1996 | 180 | acceptedResult.insert("some key", QString("some value")); | ||
1997 | 181 | |||
1998 | 182 | QVariantMap declinedResult; | ||
1999 | 183 | declinedResult.insert(SSOUI_KEY_ERROR, SignOn::QUERY_ERROR_CANCELED); | ||
2000 | 184 | |||
2001 | 185 | QVariantMap errorResult; | ||
2002 | 186 | errorResult.insert(SSOUI_KEY_ERROR, SignOn::QUERY_ERROR_FORBIDDEN); | ||
2003 | 187 | |||
2004 | 188 | QTest::newRow("no account") << | ||
2005 | 189 | uint(0) << | ||
2006 | 190 | "tom@example.com" << | ||
2007 | 191 | "com.ubuntu.tests_application_0.3" << | ||
2008 | 192 | QString() << | ||
2009 | 193 | false << | ||
2010 | 194 | errorResult; | ||
2011 | 195 | |||
2012 | 196 | QTest::newRow("invalid account") << | ||
2013 | 197 | uint(1) << | ||
2014 | 198 | "tom@example.com" << | ||
2015 | 199 | "com.ubuntu.tests_application_0.3" << | ||
2016 | 200 | QString() << | ||
2017 | 201 | false << | ||
2018 | 202 | errorResult; | ||
2019 | 203 | |||
2020 | 204 | QTest::newRow("valid application, accepted") << | ||
2021 | 205 | uint(14231) << | ||
2022 | 206 | "tom@example.com" << | ||
2023 | 207 | "com.ubuntu.tests_application_0.3" << | ||
2024 | 208 | "Easy Mailer" << | ||
2025 | 209 | true << | ||
2026 | 210 | acceptedResult; | ||
2027 | 211 | |||
2028 | 212 | QTest::newRow("valid application, declined") << | ||
2029 | 213 | uint(14231) << | ||
2030 | 214 | "tom@example.com" << | ||
2031 | 215 | "com.ubuntu.tests_application_0.3" << | ||
2032 | 216 | "Easy Mailer" << | ||
2033 | 217 | false << | ||
2034 | 218 | declinedResult; | ||
2035 | 219 | |||
2036 | 220 | QTest::newRow("unconfined application, accepted") << | ||
2037 | 221 | uint(14235) << | ||
2038 | 222 | "tom@example.com" << | ||
2039 | 223 | "unconfined" << | ||
2040 | 224 | "Ubuntu" << | ||
2041 | 225 | true << | ||
2042 | 226 | acceptedResult; | ||
2043 | 227 | |||
2044 | 228 | QTest::newRow("unconfined application, declined") << | ||
2045 | 229 | uint(14235) << | ||
2046 | 230 | "tom@example.com" << | ||
2047 | 231 | "unconfined" << | ||
2048 | 232 | "Ubuntu" << | ||
2049 | 233 | false << | ||
2050 | 234 | declinedResult; | ||
2051 | 235 | } | ||
2052 | 236 | |||
2053 | 237 | void SignonuiRequestTest::testSnapDecision() | ||
2054 | 238 | { | ||
2055 | 239 | QString providerId("cool"); | ||
2056 | 240 | QFETCH(uint, credentialsId); | ||
2057 | 241 | QFETCH(QString, accountName); | ||
2058 | 242 | QFETCH(QString, clientProfile); | ||
2059 | 243 | QFETCH(QString, applicationName); | ||
2060 | 244 | QFETCH(bool, mustAccept); | ||
2061 | 245 | QFETCH(QVariantMap, result); | ||
2062 | 246 | |||
2063 | 247 | // First, create an account | ||
2064 | 248 | Accounts::Manager *manager = new Accounts::Manager(this); | ||
2065 | 249 | Accounts::Provider provider = manager->provider(providerId); | ||
2066 | 250 | QVERIFY(provider.isValid()); | ||
2067 | 251 | if (mustCreateAccount(credentialsId)) { | ||
2068 | 252 | Accounts::Account *account = manager->createAccount(providerId); | ||
2069 | 253 | QVERIFY(account != 0); | ||
2070 | 254 | account->setEnabled(true); | ||
2071 | 255 | account->setDisplayName(accountName); | ||
2072 | 256 | account->setCredentialsId(credentialsId); | ||
2073 | 257 | account->syncAndBlock(); | ||
2074 | 258 | } | ||
2075 | 259 | |||
2076 | 260 | /* Then, create a request referring to the same credentials ID of the | ||
2077 | 261 | * created account. */ | ||
2078 | 262 | QVariantMap parameters; | ||
2079 | 263 | parameters.insert(SSOUI_KEY_IDENTITY, credentialsId); | ||
2080 | 264 | parameters.insert(SSOUI_KEY_METHOD, "funnyMethod"); | ||
2081 | 265 | parameters.insert(SSOUI_KEY_MECHANISM, "funnyMechanism"); | ||
2082 | 266 | TestRequest request(m_connection, m_message, parameters); | ||
2083 | 267 | OnlineAccountsUi::RequestPrivate *mockRequest = | ||
2084 | 268 | OnlineAccountsUi::RequestPrivate::mocked(&request); | ||
2085 | 269 | QSignalSpy failCalled(mockRequest, | ||
2086 | 270 | SIGNAL(failCalled(const QString&, const QString&))); | ||
2087 | 271 | QSignalSpy setResultCalled(mockRequest, | ||
2088 | 272 | SIGNAL(setResultCalled(const QVariantMap &))); | ||
2089 | 273 | mockRequest->setClientApparmorProfile(clientProfile); | ||
2090 | 274 | request.start(); | ||
2091 | 275 | |||
2092 | 276 | /* Request to show a window; a snap decision should appear instead */ | ||
2093 | 277 | QWindow *window = new QWindow; | ||
2094 | 278 | QSignalSpy setWindowCalled(mockRequest, | ||
2095 | 279 | SIGNAL(setWindowCalled(QWindow*))); | ||
2096 | 280 | request.setWindow(window); | ||
2097 | 281 | QCOMPARE(setWindowCalled.count(), 0); | ||
2098 | 282 | if (mustCreateAccount(credentialsId)) { | ||
2099 | 283 | QCOMPARE(NotificationPrivate::allNotifications.count(), 1); | ||
2100 | 284 | } else { | ||
2101 | 285 | /* If the account is not found, no notification should appear, and an | ||
2102 | 286 | * error returned to the app */ | ||
2103 | 287 | QCOMPARE(NotificationPrivate::allNotifications.count(), 0); | ||
2104 | 288 | QCOMPARE(setResultCalled.count(), 1); | ||
2105 | 289 | QCOMPARE(setResultCalled.at(0).at(0).toMap(), result); | ||
2106 | 290 | return; | ||
2107 | 291 | } | ||
2108 | 292 | |||
2109 | 293 | /* Inspect the snap decision contents */ | ||
2110 | 294 | Notification *notification = | ||
2111 | 295 | NotificationPrivate::allNotifications.first(); | ||
2112 | 296 | NotificationPrivate *mockNotification = | ||
2113 | 297 | NotificationPrivate::mocked(notification); | ||
2114 | 298 | QCOMPARE(mockNotification->m_summary, QString("Authentication request")); | ||
2115 | 299 | QCOMPARE(mockNotification->m_body, | ||
2116 | 300 | QString("Please authorize %1 to access your %2 account %3"). | ||
2117 | 301 | arg(applicationName).arg(provider.displayName()).arg(accountName)); | ||
2118 | 302 | QVERIFY(mockNotification->m_isSnapDecision); | ||
2119 | 303 | |||
2120 | 304 | /* Invoke the action on the snap decision */ | ||
2121 | 305 | QString action = mustAccept ? "continue" : "cancel"; | ||
2122 | 306 | QSignalSpy actionInvoked(notification, | ||
2123 | 307 | SIGNAL(actionInvoked(const QString &))); | ||
2124 | 308 | mockNotification->invokeAction(action); | ||
2125 | 309 | QCOMPARE(actionInvoked.count(), 1); | ||
2126 | 310 | QCOMPARE(actionInvoked.at(0).at(0).toString(), action); | ||
2127 | 311 | |||
2128 | 312 | /* Here we iterate the main loop because the notification object is | ||
2129 | 313 | * destroyed with deleteLater() */ | ||
2130 | 314 | QTest::qWait(5); | ||
2131 | 315 | |||
2132 | 316 | if (mustAccept) { | ||
2133 | 317 | QCOMPARE(setWindowCalled.count(), 1); | ||
2134 | 318 | QCOMPARE(setWindowCalled.at(0).at(0), QVariant::fromValue(window)); | ||
2135 | 319 | QCOMPARE(failCalled.count(), 0); | ||
2136 | 320 | QCOMPARE(setResultCalled.count(), 0); | ||
2137 | 321 | |||
2138 | 322 | /* deliver the result */ | ||
2139 | 323 | request.sendResult(result); | ||
2140 | 324 | QCOMPARE(setResultCalled.count(), 1); | ||
2141 | 325 | QCOMPARE(setResultCalled.at(0).at(0).toMap(), result); | ||
2142 | 326 | } else { | ||
2143 | 327 | QCOMPARE(setWindowCalled.count(), 0); | ||
2144 | 328 | QCOMPARE(failCalled.count(), 0); | ||
2145 | 329 | QCOMPARE(setResultCalled.count(), 1); | ||
2146 | 330 | QCOMPARE(setResultCalled.at(0).at(0).toMap(), result); | ||
2147 | 331 | } | ||
2148 | 332 | delete window; | ||
2149 | 333 | delete manager; | ||
2150 | 334 | } | ||
2151 | 335 | |||
2152 | 336 | QTEST_MAIN(SignonuiRequestTest); | ||
2153 | 337 | |||
2154 | 338 | #include "tst_signonui_request.moc" | ||
2155 | 0 | 339 | ||
2156 | === added file 'tests/online-accounts-ui/tst_signonui_request.pro' | |||
2157 | --- tests/online-accounts-ui/tst_signonui_request.pro 1970-01-01 00:00:00 +0000 | |||
2158 | +++ tests/online-accounts-ui/tst_signonui_request.pro 2014-08-11 13:15:20 +0000 | |||
2159 | @@ -0,0 +1,53 @@ | |||
2160 | 1 | include(../../common-project-config.pri) | ||
2161 | 2 | |||
2162 | 3 | TARGET = tst_signonui_request | ||
2163 | 4 | |||
2164 | 5 | CONFIG += \ | ||
2165 | 6 | debug \ | ||
2166 | 7 | link_pkgconfig | ||
2167 | 8 | |||
2168 | 9 | QT += \ | ||
2169 | 10 | core \ | ||
2170 | 11 | dbus \ | ||
2171 | 12 | testlib | ||
2172 | 13 | |||
2173 | 14 | PKGCONFIG += \ | ||
2174 | 15 | accounts-qt5 \ | ||
2175 | 16 | libsignon-qt5 \ | ||
2176 | 17 | signon-plugins-common | ||
2177 | 18 | |||
2178 | 19 | DEFINES += \ | ||
2179 | 20 | DEBUG_ENABLED \ | ||
2180 | 21 | NO_REQUEST_FACTORY \ | ||
2181 | 22 | TEST_DATA_DIR=\\\"$${PWD}/data\\\" | ||
2182 | 23 | |||
2183 | 24 | SRCDIR = $${TOP_SRC_DIR}/src | ||
2184 | 25 | |||
2185 | 26 | SOURCES += \ | ||
2186 | 27 | $${SRCDIR}/account-manager.cpp \ | ||
2187 | 28 | $${SRCDIR}/application-manager.cpp \ | ||
2188 | 29 | $${SRCDIR}/debug.cpp \ | ||
2189 | 30 | $${SRCDIR}/request-handler.cpp \ | ||
2190 | 31 | $${SRCDIR}/signonui-request.cpp \ | ||
2191 | 32 | mock/notification-mock.cpp \ | ||
2192 | 33 | mock/request-mock.cpp \ | ||
2193 | 34 | mock/qwindow.cpp \ | ||
2194 | 35 | tst_signonui_request.cpp | ||
2195 | 36 | |||
2196 | 37 | HEADERS += \ | ||
2197 | 38 | $${SRCDIR}/account-manager.h \ | ||
2198 | 39 | $${SRCDIR}/application-manager.h \ | ||
2199 | 40 | $${SRCDIR}/notification.h \ | ||
2200 | 41 | $${SRCDIR}/request.h \ | ||
2201 | 42 | $${SRCDIR}/request-handler.h \ | ||
2202 | 43 | $${SRCDIR}/signonui-request.h \ | ||
2203 | 44 | mock/notification-mock.h \ | ||
2204 | 45 | mock/request-mock.h \ | ||
2205 | 46 | window-watcher.h | ||
2206 | 47 | |||
2207 | 48 | INCLUDEPATH += \ | ||
2208 | 49 | $${SRCDIR} | ||
2209 | 50 | |||
2210 | 51 | check.commands = "xvfb-run -s '-screen 0 640x480x24' -a dbus-test-runner -t ./$${TARGET}" | ||
2211 | 52 | check.depends = $${TARGET} | ||
2212 | 53 | QMAKE_EXTRA_TARGETS += check |
FAILED: Continuous integration, rev:150 /code.launchpad .net/~dbarth/ ubuntu- system- settings- online- accounts/ inline- plugin/ +merge/ 230301/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http:// jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- online- accounts- ci/143/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/3309/ console jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- online- accounts- utopic- amd64-ci/ 36/console jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- online- accounts- utopic- armhf-ci/ 36/console jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- online- accounts- utopic- i386-ci/ 36/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/4554/ console
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- online- accounts- ci/143/ rebuild
http://