Merge lp:~mardy/account-plugins/mcloud-plugin-lp1587282 into lp:account-plugins
- mcloud-plugin-lp1587282
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~mardy/account-plugins/mcloud-plugin-lp1587282 | ||||
Merge into: | lp:account-plugins | ||||
Diff against target: |
596 lines (+448/-2) 16 files modified
.bzrignore (+3/-0) Makefile.am (+12/-0) configure.ac (+25/-0) data/providers/mcloud.provider.in.in (+28/-0) data/providers/owncloud.provider.in.in (+13/-0) data/providers/vk.provider.in.in (+26/-0) debian/account-plugin-mcloud.install (+4/-0) debian/account-plugin-owncloud.install (+3/-0) debian/account-plugin-vk.install (+3/-0) debian/control (+23/-0) debian/rules (+4/-1) qml/Makefile.am (+5/-1) qml/mcloud/Main.qml (+6/-0) qml/owncloud/Main.qml (+27/-0) qml/owncloud/NewAccount.qml (+230/-0) qml/vk/Main.qml (+36/-0) |
||||
To merge this branch: | bzr merge lp:~mardy/account-plugins/mcloud-plugin-lp1587282 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Online Accounts | Pending | ||
Review via email: mp+296318@code.launchpad.net |
Commit message
Add account plugin for MCloud
Description of the change
Add account plugin for MCloud
- 166. By Alberto Mardegan
-
Merge from trunk
* debian/control:
Update package descriptions for all account plugins (LP: #1590786)
[ Alberto Mardegan ]
* Add account plugin for vk.com (LP: #1564883)
* Add ownCloud plugin (LP: #1570986)
[ Alberto Mardegan ]
* After the authentication, retrieve the username in Google, Facebook,
Flickr and Twitter plugins (LP: #1565772)
* debian/control, debian/libaccount- plugin- facebook. install,
debian/libaccount- plugin- flickr. install,
debian/libaccount- plugin- twitter. install:
add packages containing plugin modules.
* debian/account- plugin- facebook. install,
debian/account- plugin- flickr. install,
debian/account- plugin- twitter. install:
remove unneeded webkit-options files.
[ CI Train Bot ]
* No-change rebuild. - 167. By Alberto Mardegan
-
Update description
Unmerged revisions
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2016-04-05 10:03:39 +0000 |
3 | +++ .bzrignore 2016-06-02 12:13:37 +0000 |
4 | @@ -28,10 +28,13 @@ |
5 | /debian/account-plugin-google/ |
6 | /debian/account-plugin-icons/ |
7 | /debian/account-plugin-identica/ |
8 | +/debian/account-plugin-mcloud/ |
9 | +/debian/account-plugin-owncloud/ |
10 | /debian/account-plugin-sina/ |
11 | /debian/account-plugin-sohu/ |
12 | /debian/account-plugin-tools/ |
13 | /debian/account-plugin-twitter/ |
14 | +/debian/account-plugin-vk/ |
15 | /debian/account-plugin-windows-live/ |
16 | /debian/autoreconf.after |
17 | /debian/autoreconf.before |
18 | |
19 | === modified file 'Makefile.am' |
20 | --- Makefile.am 2016-04-05 10:46:13 +0000 |
21 | +++ Makefile.am 2016-06-02 12:13:37 +0000 |
22 | @@ -89,9 +89,12 @@ |
23 | data/providers/identica.provider.in.in \ |
24 | data/providers/linkedin.provider.in.in \ |
25 | data/providers/instagram.provider.in.in \ |
26 | + data/providers/mcloud.provider.in.in \ |
27 | + data/providers/owncloud.provider.in.in \ |
28 | data/providers/sina.provider.in.in \ |
29 | data/providers/sohu.provider.in.in \ |
30 | data/providers/twitter.provider.in.in \ |
31 | + data/providers/vk.provider.in.in \ |
32 | data/providers/windows-live.provider.in.in |
33 | |
34 | providers_DATA = \ |
35 | @@ -132,6 +135,15 @@ |
36 | data/webkit-options/login.live.com.conf \ |
37 | data/webkit-options/www.linkedin.com.conf |
38 | |
39 | +# Temporary until these bugs are fixed: |
40 | +# https://bugs.launchpad.net/bugs/1567908 |
41 | +# https://bugs.launchpad.net/bugs/1571587 |
42 | +iconsdir = $(datadir)/icons/hicolor/32x32/apps |
43 | +dist_icons_DATA = \ |
44 | + data/icons/mcloud.png \ |
45 | + data/icons/owncloud.png \ |
46 | + data/icons/vk.png |
47 | + |
48 | dist_bin_SCRIPTS = \ |
49 | tools/account-console |
50 | |
51 | |
52 | === modified file 'configure.ac' |
53 | --- configure.ac 2016-04-05 10:03:39 +0000 |
54 | +++ configure.ac 2016-06-02 12:13:37 +0000 |
55 | @@ -228,6 +228,28 @@ |
56 | AC_SUBST(SOHU_CLIENT_ID, ["$sohu_client_id"]) |
57 | AC_SUBST(SOHU_CLIENT_SECRET, ["$sohu_client_secret"]) |
58 | |
59 | +# Set Mcloud client id/secret |
60 | +AC_ARG_WITH(mcloud-client-id, |
61 | + [AS_HELP_STRING([--with-mcloud-client-id], |
62 | + [Mcloud client id])], |
63 | + [mcloud_client_id=$withval], |
64 | + [mcloud_client_id="APP1ZtqoN3R0002"]) |
65 | +AC_ARG_WITH(mcloud-client-secret, |
66 | + [AS_HELP_STRING([--with-mcloud-client-secret], |
67 | + [Mcloud client secret])], |
68 | + [mcloud_client_secret=$withval], |
69 | + [mcloud_client_secret="A70EFCDC91456349E7FDECF0A33574AC"]) |
70 | +AC_SUBST(MCLOUD_CLIENT_ID, ["$mcloud_client_id"]) |
71 | +AC_SUBST(MCLOUD_CLIENT_SECRET, ["$mcloud_client_secret"]) |
72 | + |
73 | +# Set VK client id |
74 | +AC_ARG_WITH(vk-client-id, |
75 | + [AS_HELP_STRING([--with-vk-client-id], |
76 | + [VK client ID])], |
77 | + [vk_client_id=$withval], |
78 | + [vk_client_id="5404010"]) |
79 | +AC_SUBST(VK_CLIENT_ID, ["$vk_client_id"]) |
80 | + |
81 | # Set Windows Live client id |
82 | AC_ARG_WITH(windows-live-client-id, |
83 | [AS_HELP_STRING([--with-windows-live-client-id], |
84 | @@ -244,9 +266,12 @@ |
85 | data/providers/identica.provider.in |
86 | data/providers/linkedin.provider.in |
87 | data/providers/instagram.provider.in |
88 | + data/providers/mcloud.provider.in |
89 | + data/providers/owncloud.provider.in |
90 | data/providers/sina.provider.in |
91 | data/providers/sohu.provider.in |
92 | data/providers/twitter.provider.in |
93 | + data/providers/vk.provider.in |
94 | data/providers/windows-live.provider.in |
95 | Makefile |
96 | po/Makefile.in |
97 | |
98 | === added directory 'data/icons' |
99 | === added file 'data/icons/mcloud.png' |
100 | Binary files data/icons/mcloud.png 1970-01-01 00:00:00 +0000 and data/icons/mcloud.png 2016-06-02 12:13:37 +0000 differ |
101 | === added file 'data/icons/owncloud.png' |
102 | Binary files data/icons/owncloud.png 1970-01-01 00:00:00 +0000 and data/icons/owncloud.png 2016-06-02 12:13:37 +0000 differ |
103 | === added file 'data/icons/vk.png' |
104 | Binary files data/icons/vk.png 1970-01-01 00:00:00 +0000 and data/icons/vk.png 2016-06-02 12:13:37 +0000 differ |
105 | === added file 'data/providers/mcloud.provider.in.in' |
106 | --- data/providers/mcloud.provider.in.in 1970-01-01 00:00:00 +0000 |
107 | +++ data/providers/mcloud.provider.in.in 2016-06-02 12:13:37 +0000 |
108 | @@ -0,0 +1,28 @@ |
109 | +<?xml version="1.0" encoding="UTF-8"?> |
110 | +<provider id="mcloud"> |
111 | + <name>MCloud</name> |
112 | + <icon>mcloud</icon> |
113 | + <translations>MCloud</translations> |
114 | + <domains>.*10086\.cn</domains> |
115 | + <plugin>generic-oauth</plugin> |
116 | + <single-account>true</single-account> |
117 | + <template> |
118 | + <group name="auth"> |
119 | + <setting name="method">oauth2</setting> |
120 | + <setting name="mechanism">web_server</setting> |
121 | + <group name="oauth2"> |
122 | + <group name="web_server"> |
123 | + <setting name="Host">caiyun.feixin.10086.cn</setting> |
124 | + <setting name="AuthPath">authorize.jsp</setting> |
125 | + <setting name="TokenPath">https://ose.caiyun.feixin.10086.cn/oauthApp/OAuth2/getToken</setting> |
126 | + <setting name="RedirectUri">http://developer.ubuntu.com/en/</setting> |
127 | + <setting name="ResponseType">code</setting> |
128 | + <setting name="ClientId">@MCLOUD_CLIENT_ID@</setting> |
129 | + <setting name="ClientSecret">@MCLOUD_CLIENT_SECRET@</setting> |
130 | + <setting type="as" name="Scope">['nd_cloud']</setting> |
131 | + <setting type="as" name="AllowedSchemes">['https', 'http']</setting> |
132 | + </group> |
133 | + </group> |
134 | + </group> |
135 | + </template> |
136 | +</provider> |
137 | |
138 | === added file 'data/providers/owncloud.provider.in.in' |
139 | --- data/providers/owncloud.provider.in.in 1970-01-01 00:00:00 +0000 |
140 | +++ data/providers/owncloud.provider.in.in 2016-06-02 12:13:37 +0000 |
141 | @@ -0,0 +1,13 @@ |
142 | +<?xml version="1.0" encoding="UTF-8"?> |
143 | +<provider id="owncloud"> |
144 | + <name>ownCloud</name> |
145 | + <icon>owncloud.png</icon> |
146 | + <translations>account-plugins</translations> |
147 | + |
148 | + <template> |
149 | + <group name="auth"> |
150 | + <setting name="method">password</setting> |
151 | + <setting name="mechanism">password</setting> |
152 | + </group> |
153 | + </template> |
154 | +</provider> |
155 | |
156 | === added file 'data/providers/vk.provider.in.in' |
157 | --- data/providers/vk.provider.in.in 1970-01-01 00:00:00 +0000 |
158 | +++ data/providers/vk.provider.in.in 2016-06-02 12:13:37 +0000 |
159 | @@ -0,0 +1,26 @@ |
160 | +<?xml version="1.0" encoding="UTF-8"?> |
161 | +<provider id="vk"> |
162 | + <name>VKontakte</name> |
163 | + <icon>vk</icon> |
164 | + <translations>account-plugins</translations> |
165 | + <domains>.*vk\.com</domains> |
166 | + |
167 | + <template> |
168 | + <group name="auth"> |
169 | + <setting name="method">oauth2</setting> |
170 | + <setting name="mechanism">user_agent</setting> |
171 | + <group name="oauth2"> |
172 | + <group name="user_agent"> |
173 | + <setting name="Host">oauth.vk.com</setting> |
174 | + <setting name="AuthPath">authorize</setting> |
175 | + <setting name="TokenPath">access_token</setting> |
176 | + <setting name="RedirectUri">https://oauth.vk.com/blank.html</setting> |
177 | + <setting name="ResponseType">token</setting> |
178 | + <setting name="ClientId">@VK_CLIENT_ID@</setting> |
179 | + <setting type="as" name="Scope">['offline']</setting> |
180 | + <setting type="s" name="v">5.50</setting> |
181 | + </group> |
182 | + </group> |
183 | + </group> |
184 | + </template> |
185 | +</provider> |
186 | |
187 | === added file 'debian/account-plugin-mcloud.install' |
188 | --- debian/account-plugin-mcloud.install 1970-01-01 00:00:00 +0000 |
189 | +++ debian/account-plugin-mcloud.install 2016-06-02 12:13:37 +0000 |
190 | @@ -0,0 +1,4 @@ |
191 | +usr/share/accounts/providers/mcloud.provider |
192 | +usr/share/accounts/qml-plugins/mcloud/*.qml |
193 | +usr/share/icons/hicolor/32x32/apps/mcloud.png |
194 | + |
195 | |
196 | === added file 'debian/account-plugin-owncloud.install' |
197 | --- debian/account-plugin-owncloud.install 1970-01-01 00:00:00 +0000 |
198 | +++ debian/account-plugin-owncloud.install 2016-06-02 12:13:37 +0000 |
199 | @@ -0,0 +1,3 @@ |
200 | +usr/share/accounts/providers/owncloud.provider |
201 | +usr/share/accounts/qml-plugins/owncloud/*.qml |
202 | +usr/share/icons/hicolor/32x32/apps/owncloud.png |
203 | |
204 | === added file 'debian/account-plugin-vk.install' |
205 | --- debian/account-plugin-vk.install 1970-01-01 00:00:00 +0000 |
206 | +++ debian/account-plugin-vk.install 2016-06-02 12:13:37 +0000 |
207 | @@ -0,0 +1,3 @@ |
208 | +usr/share/accounts/providers/vk.provider |
209 | +usr/share/accounts/qml-plugins/vk/Main.qml |
210 | +usr/share/icons/hicolor/32x32/apps/vk.png |
211 | |
212 | === modified file 'debian/control' |
213 | --- debian/control 2016-04-05 10:52:46 +0000 |
214 | +++ debian/control 2016-06-02 12:13:37 +0000 |
215 | @@ -144,6 +144,29 @@ |
216 | Description: GNOME Control Center account plugin for single signon - Instagram |
217 | GNOME Control Center account plugins for single signon |
218 | |
219 | +Package: account-plugin-mcloud |
220 | +Architecture: all |
221 | +Depends: ${misc:Depends}, |
222 | + ubuntu-system-settings-online-accounts, |
223 | +Description: Account plugin for online accounts - mCloud |
224 | + Online Accounts plugin provide the user interface to create accounts for |
225 | + third party services. |
226 | + |
227 | +Package: account-plugin-owncloud |
228 | +Architecture: all |
229 | +Depends: ${misc:Depends}, |
230 | + ubuntu-system-settings-online-accounts, |
231 | +Description: Account plugin for online accounts - ownCloud |
232 | + Online Accounts plugin provide the user interface to create accounts for |
233 | + third party services. |
234 | + |
235 | +Package: account-plugin-vk |
236 | +Architecture: all |
237 | +Depends: ${misc:Depends}, |
238 | + libaccount-plugin-generic-oauth | ubuntu-system-settings-online-accounts, |
239 | +Description: GNOME Control Center account plugin for single signon - VKontakte |
240 | + GNOME Control Center account plugins for single signon |
241 | + |
242 | Package: account-plugin-tools |
243 | Architecture: all |
244 | Depends: ${misc:Depends}, |
245 | |
246 | === modified file 'debian/rules' |
247 | --- debian/rules 2015-07-23 14:10:26 +0000 |
248 | +++ debian/rules 2016-06-02 12:13:37 +0000 |
249 | @@ -21,7 +21,10 @@ |
250 | --with-linkedin-consumer-key="34gnzrg96iq5" \ |
251 | --with-linkedin-consumer-secret="BazRki2LE8eZtcqh" \ |
252 | --with-instagram-client-id="01c3df41a2274a14882adea8e8ebbd46" \ |
253 | - --with-instagram-client-secret="4751ccdc39c648719ea83cfb1c866c26" |
254 | + --with-instagram-client-secret="4751ccdc39c648719ea83cfb1c866c26" \ |
255 | + --with-mcloud-client-id="APP1ZtqoN3R0002" \ |
256 | + --with-mcloud-client-secret="A70EFCDC91456349E7FDECF0A33574AC" \ |
257 | + --with-vk-client-id="5402699" |
258 | |
259 | override_dh_install: |
260 | rm -f debian/*/usr/lib/*/*/*.la |
261 | |
262 | === modified file 'qml/Makefile.am' |
263 | --- qml/Makefile.am 2013-06-07 11:56:25 +0000 |
264 | +++ qml/Makefile.am 2016-06-02 12:13:37 +0000 |
265 | @@ -2,4 +2,8 @@ |
266 | facebook/Main.qml \ |
267 | flickr/Main.qml \ |
268 | google/Main.qml \ |
269 | - twitter/Main.qml |
270 | + mcloud/Main.qml \ |
271 | + owncloud/Main.qml \ |
272 | + owncloud/NewAccount.qml \ |
273 | + twitter/Main.qml \ |
274 | + vk/Main.qml |
275 | |
276 | === added directory 'qml/mcloud' |
277 | === added file 'qml/mcloud/Main.qml' |
278 | --- qml/mcloud/Main.qml 1970-01-01 00:00:00 +0000 |
279 | +++ qml/mcloud/Main.qml 2016-06-02 12:13:37 +0000 |
280 | @@ -0,0 +1,6 @@ |
281 | +import Ubuntu.OnlineAccounts.Plugin 1.0 |
282 | + |
283 | +OAuthMain { |
284 | + creationComponent: OAuth { |
285 | + } |
286 | +} |
287 | |
288 | === added directory 'qml/owncloud' |
289 | === added file 'qml/owncloud/Main.qml' |
290 | --- qml/owncloud/Main.qml 1970-01-01 00:00:00 +0000 |
291 | +++ qml/owncloud/Main.qml 2016-06-02 12:13:37 +0000 |
292 | @@ -0,0 +1,27 @@ |
293 | +import QtQuick 2.0 |
294 | +import Ubuntu.OnlineAccounts.Plugin 1.0 |
295 | + |
296 | +Flickable { |
297 | + id: root |
298 | + |
299 | + property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 |
300 | + contentHeight: loader.item.height + keyboardSize |
301 | + |
302 | + signal finished |
303 | + |
304 | + Loader { |
305 | + id: loader |
306 | + anchors.fill: parent |
307 | + sourceComponent: newAccountComponent |
308 | + |
309 | + Connections { |
310 | + target: loader.item |
311 | + onFinished: root.finished() |
312 | + } |
313 | + } |
314 | + |
315 | + Component { |
316 | + id: newAccountComponent |
317 | + NewAccount {} |
318 | + } |
319 | +} |
320 | |
321 | === added file 'qml/owncloud/NewAccount.qml' |
322 | --- qml/owncloud/NewAccount.qml 1970-01-01 00:00:00 +0000 |
323 | +++ qml/owncloud/NewAccount.qml 2016-06-02 12:13:37 +0000 |
324 | @@ -0,0 +1,230 @@ |
325 | +import QtQuick 2.0 |
326 | +import Ubuntu.Components 1.3 |
327 | +import Ubuntu.OnlineAccounts 0.1 |
328 | + |
329 | +Item { |
330 | + id: root |
331 | + |
332 | + signal finished |
333 | + |
334 | + anchors.margins: units.gu(1) |
335 | + height: contents.height |
336 | + |
337 | + property var __account: account |
338 | + property string __host: "" |
339 | + property bool __busy: false |
340 | + property string __hostError: i18n.dtr("account-plugins", "Invalid host URL") |
341 | + |
342 | + Column { |
343 | + id: contents |
344 | + anchors { left: parent.left; right: parent.right } |
345 | + spacing: units.gu(1) |
346 | + |
347 | + Label { |
348 | + id: errorLabel |
349 | + anchors { left: parent.left; right: parent.right } |
350 | + font.bold: true |
351 | + color: UbuntuColors.red |
352 | + wrapMode: Text.Wrap |
353 | + visible: !__busy && text != "" |
354 | + } |
355 | + |
356 | + Label { |
357 | + anchors { left: parent.left; right: parent.right } |
358 | + text: i18n.dtr("account-plugins", "URL:") |
359 | + } |
360 | + |
361 | + TextField { |
362 | + id: urlField |
363 | + anchors { left: parent.left; right: parent.right } |
364 | + placeholderText: i18n.dtr("account-plugins", "http://example.org") |
365 | + focus: true |
366 | + enabled: !__busy |
367 | + |
368 | + inputMethodHints: Qt.ImhUrlCharactersOnly |
369 | + } |
370 | + |
371 | + Label { |
372 | + anchors { left: parent.left; right: parent.right } |
373 | + text: i18n.dtr("account-plugins", "Username:") |
374 | + } |
375 | + |
376 | + TextField { |
377 | + id: usernameField |
378 | + anchors { left: parent.left; right: parent.right } |
379 | + placeholderText: i18n.dtr("account-plugins", "Your username") |
380 | + enabled: !__busy |
381 | + inputMethodHints: Qt.ImhNoAutoUppercase + Qt.ImhNoPredictiveText + Qt.ImhPreferLowercase |
382 | + |
383 | + KeyNavigation.tab: passwordField |
384 | + } |
385 | + |
386 | + Label { |
387 | + anchors { left: parent.left; right: parent.right } |
388 | + text: i18n.dtr("account-plugins", "Password:") |
389 | + } |
390 | + |
391 | + TextField { |
392 | + id: passwordField |
393 | + anchors { left: parent.left; right: parent.right } |
394 | + placeholderText: i18n.dtr("account-plugins", "Your password") |
395 | + echoMode: TextInput.Password |
396 | + enabled: !__busy |
397 | + |
398 | + inputMethodHints: Qt.ImhSensitiveData |
399 | + Keys.onReturnPressed: login() |
400 | + } |
401 | + |
402 | + Row { |
403 | + id: buttons |
404 | + anchors { left: parent.left; right: parent.right } |
405 | + height: units.gu(5) |
406 | + spacing: units.gu(1) |
407 | + Button { |
408 | + id: btnCancel |
409 | + text: i18n.dtr("account-plugins", "Cancel") |
410 | + height: parent.height |
411 | + width: (parent.width / 2) - 0.5 * parent.spacing |
412 | + onClicked: finished() |
413 | + } |
414 | + Button { |
415 | + id: btnContinue |
416 | + text: i18n.dtr("account-plugins", "Continue") |
417 | + color: UbuntuColors.green |
418 | + height: parent.height |
419 | + width: (parent.width / 2) - 0.5 * parent.spacing |
420 | + onClicked: login() |
421 | + enabled: !__busy |
422 | + } |
423 | + } |
424 | + } |
425 | + |
426 | + ActivityIndicator { |
427 | + anchors.centerIn: parent |
428 | + running: __busy |
429 | + } |
430 | + |
431 | + Credentials { |
432 | + id: creds |
433 | + caption: account.provider.id |
434 | + acl: [ "unconfined" ] |
435 | + storeSecret: true |
436 | + onCredentialsIdChanged: root.credentialsStored() |
437 | + } |
438 | + |
439 | + AccountService { |
440 | + id: globalAccountSettings |
441 | + objectHandle: account.accountServiceHandle |
442 | + autoSync: false |
443 | + } |
444 | + |
445 | + function login() { |
446 | + __host = cleanUrl(urlField.text) |
447 | + var username = usernameField.text |
448 | + var password = passwordField.text |
449 | + |
450 | + errorLabel.text = "" |
451 | + __busy = true |
452 | + var host = __host |
453 | + var tryHttp = false |
454 | + if (__host.indexOf("http") != 0) { |
455 | + host = "https://" + __host |
456 | + tryHttp = true |
457 | + } |
458 | + |
459 | + checkAccount(host, username, password, function cb(success) { |
460 | + console.log("callback called: " + success) |
461 | + if (success) { |
462 | + saveData(host, username, password) |
463 | + } else if (tryHttp) { |
464 | + host = "http://" + __host |
465 | + tryHttp = false |
466 | + checkAccount(host, username, password, cb) |
467 | + } else { |
468 | + __busy = false |
469 | + } |
470 | + }) |
471 | + } |
472 | + |
473 | + function saveData(host, username, password) { |
474 | + __host = host |
475 | + var strippedHost = __host.replace(/^https?:\/\//, '') |
476 | + account.updateDisplayName(username + '@' + strippedHost) |
477 | + creds.userName = username |
478 | + creds.secret = password |
479 | + creds.sync() |
480 | + } |
481 | + |
482 | + function findChild(node, tagName) { |
483 | + if (!node) return node; |
484 | + var children = node.childNodes |
485 | + for (var i = 0; i < children.length; i++) { |
486 | + if (children[i].nodeName == tagName) { |
487 | + return children[i] |
488 | + } |
489 | + } |
490 | + return null |
491 | + } |
492 | + |
493 | + function checkAccount(host, username, password, callback) { |
494 | + console.log("Trying host " + host + " as " + username + ':' + password) |
495 | + var request = new XMLHttpRequest(); |
496 | + request.onreadystatechange = function() { |
497 | + if (request.readyState === XMLHttpRequest.DONE) { |
498 | + console.log("response: " + request.responseText) |
499 | + if (request.status == 200) { |
500 | + var root = request.responseXML ? request.responseXML.documentElement : null |
501 | + var metaElement = findChild(root, "meta") |
502 | + var statusElement = findChild(metaElement, "status") |
503 | + if (statusElement && statusElement.childNodes.length > 0 && |
504 | + statusElement.childNodes[0].nodeValue == "ok") { |
505 | + callback(true) |
506 | + } else { |
507 | + var statusCodeElement = findChild(metaElement, "statuscode") |
508 | + var statusCode = (statusCodeElement && statusCodeElement.childNodes.length > 0) ? |
509 | + statusCodeElement.childNodes[0].nodeValue : "999" |
510 | + if (statusCode == "999") { |
511 | + showError(__hostError) |
512 | + } else { |
513 | + showError(i18n.dtr("account-plugins", "Invalid username or password")) |
514 | + } |
515 | + callback(false) |
516 | + } |
517 | + } else { |
518 | + showError(__hostError) |
519 | + callback(false) |
520 | + } |
521 | + } |
522 | + } |
523 | + request.open("POST", host + "/ocs/v1.php/person/check", true); |
524 | + request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
525 | + var body = "login=" + username + "&password=" + password |
526 | + request.send(body); |
527 | + } |
528 | + |
529 | + function showError(message) { |
530 | + if (!errorLabel.text) errorLabel.text = message |
531 | + } |
532 | + |
533 | + function credentialsStored() { |
534 | + console.log("Credentials stored, id: " + creds.credentialsId) |
535 | + if (creds.credentialsId == 0) return |
536 | + |
537 | + globalAccountSettings.updateServiceEnabled(true) |
538 | + globalAccountSettings.credentials = creds |
539 | + globalAccountSettings.updateSettings({ |
540 | + "host": __host |
541 | + }) |
542 | + account.synced.connect(finished) |
543 | + account.sync() |
544 | + __busy = false |
545 | + } |
546 | + |
547 | + // check host url for http |
548 | + function cleanUrl(url) { |
549 | + var host = url.trim() |
550 | + // if the user typed trailing '/' or "index.php", strip that |
551 | + return host.replace(/\/(index.php)?\/*$/, '') |
552 | + } |
553 | + |
554 | +} |
555 | |
556 | === added directory 'qml/vk' |
557 | === added file 'qml/vk/Main.qml' |
558 | --- qml/vk/Main.qml 1970-01-01 00:00:00 +0000 |
559 | +++ qml/vk/Main.qml 2016-06-02 12:13:37 +0000 |
560 | @@ -0,0 +1,36 @@ |
561 | +import Ubuntu.OnlineAccounts.Plugin 1.0 |
562 | + |
563 | +OAuthMain { |
564 | + creationComponent: OAuth { |
565 | + function completeCreation(reply) { |
566 | + console.log("Access token: " + reply.AccessToken) |
567 | + var http = new XMLHttpRequest() |
568 | + var url = "https://api.vk.com/method/users.get?access_token=" + reply.AccessToken + "&fields=nickname,first_name,last_name"; |
569 | + http.open("GET", url, true); |
570 | + http.onreadystatechange = function() { |
571 | + if (http.readyState === 4){ |
572 | + if (http.status == 200) { |
573 | + console.log("ok") |
574 | + console.log("response text: " + http.responseText) |
575 | + var response = JSON.parse(http.responseText) |
576 | + if (response.response && response.response.length > 0) { |
577 | + var data = response.response[0] |
578 | + var name = data.first_name + " " + data.last_name |
579 | + if (data.nickname) { |
580 | + name += " (" + data.nickname + ")" |
581 | + } |
582 | + account.updateDisplayName(name) |
583 | + } |
584 | + account.synced.connect(finished) |
585 | + account.sync() |
586 | + } else { |
587 | + console.log("error: " + http.status) |
588 | + cancel() |
589 | + } |
590 | + } |
591 | + }; |
592 | + |
593 | + http.send(null); |
594 | + } |
595 | + } |
596 | +} |