Merge lp:~mardy/account-plugins/mcloud-plugin-lp1587282 into lp:account-plugins

Proposed by Alberto Mardegan
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
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

To post a comment you must log in.
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2016-04-05 10:03:39 +0000
+++ .bzrignore 2016-06-02 12:13:37 +0000
@@ -28,10 +28,13 @@
28/debian/account-plugin-google/28/debian/account-plugin-google/
29/debian/account-plugin-icons/29/debian/account-plugin-icons/
30/debian/account-plugin-identica/30/debian/account-plugin-identica/
31/debian/account-plugin-mcloud/
32/debian/account-plugin-owncloud/
31/debian/account-plugin-sina/33/debian/account-plugin-sina/
32/debian/account-plugin-sohu/34/debian/account-plugin-sohu/
33/debian/account-plugin-tools/35/debian/account-plugin-tools/
34/debian/account-plugin-twitter/36/debian/account-plugin-twitter/
37/debian/account-plugin-vk/
35/debian/account-plugin-windows-live/38/debian/account-plugin-windows-live/
36/debian/autoreconf.after39/debian/autoreconf.after
37/debian/autoreconf.before40/debian/autoreconf.before
3841
=== modified file 'Makefile.am'
--- Makefile.am 2016-04-05 10:46:13 +0000
+++ Makefile.am 2016-06-02 12:13:37 +0000
@@ -89,9 +89,12 @@
89 data/providers/identica.provider.in.in \89 data/providers/identica.provider.in.in \
90 data/providers/linkedin.provider.in.in \90 data/providers/linkedin.provider.in.in \
91 data/providers/instagram.provider.in.in \91 data/providers/instagram.provider.in.in \
92 data/providers/mcloud.provider.in.in \
93 data/providers/owncloud.provider.in.in \
92 data/providers/sina.provider.in.in \94 data/providers/sina.provider.in.in \
93 data/providers/sohu.provider.in.in \95 data/providers/sohu.provider.in.in \
94 data/providers/twitter.provider.in.in \96 data/providers/twitter.provider.in.in \
97 data/providers/vk.provider.in.in \
95 data/providers/windows-live.provider.in.in98 data/providers/windows-live.provider.in.in
9699
97providers_DATA = \100providers_DATA = \
@@ -132,6 +135,15 @@
132 data/webkit-options/login.live.com.conf \135 data/webkit-options/login.live.com.conf \
133 data/webkit-options/www.linkedin.com.conf136 data/webkit-options/www.linkedin.com.conf
134137
138# Temporary until these bugs are fixed:
139# https://bugs.launchpad.net/bugs/1567908
140# https://bugs.launchpad.net/bugs/1571587
141iconsdir = $(datadir)/icons/hicolor/32x32/apps
142dist_icons_DATA = \
143 data/icons/mcloud.png \
144 data/icons/owncloud.png \
145 data/icons/vk.png
146
135dist_bin_SCRIPTS = \147dist_bin_SCRIPTS = \
136 tools/account-console148 tools/account-console
137149
138150
=== modified file 'configure.ac'
--- configure.ac 2016-04-05 10:03:39 +0000
+++ configure.ac 2016-06-02 12:13:37 +0000
@@ -228,6 +228,28 @@
228AC_SUBST(SOHU_CLIENT_ID, ["$sohu_client_id"])228AC_SUBST(SOHU_CLIENT_ID, ["$sohu_client_id"])
229AC_SUBST(SOHU_CLIENT_SECRET, ["$sohu_client_secret"])229AC_SUBST(SOHU_CLIENT_SECRET, ["$sohu_client_secret"])
230230
231# Set Mcloud client id/secret
232AC_ARG_WITH(mcloud-client-id,
233 [AS_HELP_STRING([--with-mcloud-client-id],
234 [Mcloud client id])],
235 [mcloud_client_id=$withval],
236 [mcloud_client_id="APP1ZtqoN3R0002"])
237AC_ARG_WITH(mcloud-client-secret,
238 [AS_HELP_STRING([--with-mcloud-client-secret],
239 [Mcloud client secret])],
240 [mcloud_client_secret=$withval],
241 [mcloud_client_secret="A70EFCDC91456349E7FDECF0A33574AC"])
242AC_SUBST(MCLOUD_CLIENT_ID, ["$mcloud_client_id"])
243AC_SUBST(MCLOUD_CLIENT_SECRET, ["$mcloud_client_secret"])
244
245# Set VK client id
246AC_ARG_WITH(vk-client-id,
247 [AS_HELP_STRING([--with-vk-client-id],
248 [VK client ID])],
249 [vk_client_id=$withval],
250 [vk_client_id="5404010"])
251AC_SUBST(VK_CLIENT_ID, ["$vk_client_id"])
252
231# Set Windows Live client id253# Set Windows Live client id
232AC_ARG_WITH(windows-live-client-id,254AC_ARG_WITH(windows-live-client-id,
233 [AS_HELP_STRING([--with-windows-live-client-id],255 [AS_HELP_STRING([--with-windows-live-client-id],
@@ -244,9 +266,12 @@
244 data/providers/identica.provider.in266 data/providers/identica.provider.in
245 data/providers/linkedin.provider.in267 data/providers/linkedin.provider.in
246 data/providers/instagram.provider.in268 data/providers/instagram.provider.in
269 data/providers/mcloud.provider.in
270 data/providers/owncloud.provider.in
247 data/providers/sina.provider.in271 data/providers/sina.provider.in
248 data/providers/sohu.provider.in272 data/providers/sohu.provider.in
249 data/providers/twitter.provider.in273 data/providers/twitter.provider.in
274 data/providers/vk.provider.in
250 data/providers/windows-live.provider.in275 data/providers/windows-live.provider.in
251 Makefile276 Makefile
252 po/Makefile.in277 po/Makefile.in
253278
=== added directory 'data/icons'
=== added file 'data/icons/mcloud.png'
254Binary files data/icons/mcloud.png 1970-01-01 00:00:00 +0000 and data/icons/mcloud.png 2016-06-02 12:13:37 +0000 differ279Binary 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
=== added file 'data/icons/owncloud.png'
255Binary files data/icons/owncloud.png 1970-01-01 00:00:00 +0000 and data/icons/owncloud.png 2016-06-02 12:13:37 +0000 differ280Binary 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
=== added file 'data/icons/vk.png'
256Binary files data/icons/vk.png 1970-01-01 00:00:00 +0000 and data/icons/vk.png 2016-06-02 12:13:37 +0000 differ281Binary 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
=== added file 'data/providers/mcloud.provider.in.in'
--- data/providers/mcloud.provider.in.in 1970-01-01 00:00:00 +0000
+++ data/providers/mcloud.provider.in.in 2016-06-02 12:13:37 +0000
@@ -0,0 +1,28 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<provider id="mcloud">
3 <name>MCloud</name>
4 <icon>mcloud</icon>
5 <translations>MCloud</translations>
6 <domains>.*10086\.cn</domains>
7 <plugin>generic-oauth</plugin>
8 <single-account>true</single-account>
9 <template>
10 <group name="auth">
11 <setting name="method">oauth2</setting>
12 <setting name="mechanism">web_server</setting>
13 <group name="oauth2">
14 <group name="web_server">
15 <setting name="Host">caiyun.feixin.10086.cn</setting>
16 <setting name="AuthPath">authorize.jsp</setting>
17 <setting name="TokenPath">https://ose.caiyun.feixin.10086.cn/oauthApp/OAuth2/getToken</setting>
18 <setting name="RedirectUri">http://developer.ubuntu.com/en/</setting>
19 <setting name="ResponseType">code</setting>
20 <setting name="ClientId">@MCLOUD_CLIENT_ID@</setting>
21 <setting name="ClientSecret">@MCLOUD_CLIENT_SECRET@</setting>
22 <setting type="as" name="Scope">['nd_cloud']</setting>
23 <setting type="as" name="AllowedSchemes">['https', 'http']</setting>
24 </group>
25 </group>
26 </group>
27 </template>
28</provider>
029
=== added file 'data/providers/owncloud.provider.in.in'
--- data/providers/owncloud.provider.in.in 1970-01-01 00:00:00 +0000
+++ data/providers/owncloud.provider.in.in 2016-06-02 12:13:37 +0000
@@ -0,0 +1,13 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<provider id="owncloud">
3 <name>ownCloud</name>
4 <icon>owncloud.png</icon>
5 <translations>account-plugins</translations>
6
7 <template>
8 <group name="auth">
9 <setting name="method">password</setting>
10 <setting name="mechanism">password</setting>
11 </group>
12 </template>
13</provider>
014
=== added file 'data/providers/vk.provider.in.in'
--- data/providers/vk.provider.in.in 1970-01-01 00:00:00 +0000
+++ data/providers/vk.provider.in.in 2016-06-02 12:13:37 +0000
@@ -0,0 +1,26 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<provider id="vk">
3 <name>VKontakte</name>
4 <icon>vk</icon>
5 <translations>account-plugins</translations>
6 <domains>.*vk\.com</domains>
7
8 <template>
9 <group name="auth">
10 <setting name="method">oauth2</setting>
11 <setting name="mechanism">user_agent</setting>
12 <group name="oauth2">
13 <group name="user_agent">
14 <setting name="Host">oauth.vk.com</setting>
15 <setting name="AuthPath">authorize</setting>
16 <setting name="TokenPath">access_token</setting>
17 <setting name="RedirectUri">https://oauth.vk.com/blank.html</setting>
18 <setting name="ResponseType">token</setting>
19 <setting name="ClientId">@VK_CLIENT_ID@</setting>
20 <setting type="as" name="Scope">['offline']</setting>
21 <setting type="s" name="v">5.50</setting>
22 </group>
23 </group>
24 </group>
25 </template>
26</provider>
027
=== added file 'debian/account-plugin-mcloud.install'
--- debian/account-plugin-mcloud.install 1970-01-01 00:00:00 +0000
+++ debian/account-plugin-mcloud.install 2016-06-02 12:13:37 +0000
@@ -0,0 +1,4 @@
1usr/share/accounts/providers/mcloud.provider
2usr/share/accounts/qml-plugins/mcloud/*.qml
3usr/share/icons/hicolor/32x32/apps/mcloud.png
4
05
=== added file 'debian/account-plugin-owncloud.install'
--- debian/account-plugin-owncloud.install 1970-01-01 00:00:00 +0000
+++ debian/account-plugin-owncloud.install 2016-06-02 12:13:37 +0000
@@ -0,0 +1,3 @@
1usr/share/accounts/providers/owncloud.provider
2usr/share/accounts/qml-plugins/owncloud/*.qml
3usr/share/icons/hicolor/32x32/apps/owncloud.png
04
=== added file 'debian/account-plugin-vk.install'
--- debian/account-plugin-vk.install 1970-01-01 00:00:00 +0000
+++ debian/account-plugin-vk.install 2016-06-02 12:13:37 +0000
@@ -0,0 +1,3 @@
1usr/share/accounts/providers/vk.provider
2usr/share/accounts/qml-plugins/vk/Main.qml
3usr/share/icons/hicolor/32x32/apps/vk.png
04
=== modified file 'debian/control'
--- debian/control 2016-04-05 10:52:46 +0000
+++ debian/control 2016-06-02 12:13:37 +0000
@@ -144,6 +144,29 @@
144Description: GNOME Control Center account plugin for single signon - Instagram144Description: GNOME Control Center account plugin for single signon - Instagram
145 GNOME Control Center account plugins for single signon145 GNOME Control Center account plugins for single signon
146146
147Package: account-plugin-mcloud
148Architecture: all
149Depends: ${misc:Depends},
150 ubuntu-system-settings-online-accounts,
151Description: Account plugin for online accounts - mCloud
152 Online Accounts plugin provide the user interface to create accounts for
153 third party services.
154
155Package: account-plugin-owncloud
156Architecture: all
157Depends: ${misc:Depends},
158 ubuntu-system-settings-online-accounts,
159Description: Account plugin for online accounts - ownCloud
160 Online Accounts plugin provide the user interface to create accounts for
161 third party services.
162
163Package: account-plugin-vk
164Architecture: all
165Depends: ${misc:Depends},
166 libaccount-plugin-generic-oauth | ubuntu-system-settings-online-accounts,
167Description: GNOME Control Center account plugin for single signon - VKontakte
168 GNOME Control Center account plugins for single signon
169
147Package: account-plugin-tools170Package: account-plugin-tools
148Architecture: all171Architecture: all
149Depends: ${misc:Depends},172Depends: ${misc:Depends},
150173
=== modified file 'debian/rules'
--- debian/rules 2015-07-23 14:10:26 +0000
+++ debian/rules 2016-06-02 12:13:37 +0000
@@ -21,7 +21,10 @@
21 --with-linkedin-consumer-key="34gnzrg96iq5" \21 --with-linkedin-consumer-key="34gnzrg96iq5" \
22 --with-linkedin-consumer-secret="BazRki2LE8eZtcqh" \22 --with-linkedin-consumer-secret="BazRki2LE8eZtcqh" \
23 --with-instagram-client-id="01c3df41a2274a14882adea8e8ebbd46" \23 --with-instagram-client-id="01c3df41a2274a14882adea8e8ebbd46" \
24 --with-instagram-client-secret="4751ccdc39c648719ea83cfb1c866c26" 24 --with-instagram-client-secret="4751ccdc39c648719ea83cfb1c866c26" \
25 --with-mcloud-client-id="APP1ZtqoN3R0002" \
26 --with-mcloud-client-secret="A70EFCDC91456349E7FDECF0A33574AC" \
27 --with-vk-client-id="5402699"
2528
26override_dh_install:29override_dh_install:
27 rm -f debian/*/usr/lib/*/*/*.la30 rm -f debian/*/usr/lib/*/*/*.la
2831
=== modified file 'qml/Makefile.am'
--- qml/Makefile.am 2013-06-07 11:56:25 +0000
+++ qml/Makefile.am 2016-06-02 12:13:37 +0000
@@ -2,4 +2,8 @@
2 facebook/Main.qml \2 facebook/Main.qml \
3 flickr/Main.qml \3 flickr/Main.qml \
4 google/Main.qml \4 google/Main.qml \
5 twitter/Main.qml5 mcloud/Main.qml \
6 owncloud/Main.qml \
7 owncloud/NewAccount.qml \
8 twitter/Main.qml \
9 vk/Main.qml
610
=== added directory 'qml/mcloud'
=== added file 'qml/mcloud/Main.qml'
--- qml/mcloud/Main.qml 1970-01-01 00:00:00 +0000
+++ qml/mcloud/Main.qml 2016-06-02 12:13:37 +0000
@@ -0,0 +1,6 @@
1import Ubuntu.OnlineAccounts.Plugin 1.0
2
3OAuthMain {
4 creationComponent: OAuth {
5 }
6}
07
=== added directory 'qml/owncloud'
=== added file 'qml/owncloud/Main.qml'
--- qml/owncloud/Main.qml 1970-01-01 00:00:00 +0000
+++ qml/owncloud/Main.qml 2016-06-02 12:13:37 +0000
@@ -0,0 +1,27 @@
1import QtQuick 2.0
2import Ubuntu.OnlineAccounts.Plugin 1.0
3
4Flickable {
5 id: root
6
7 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
8 contentHeight: loader.item.height + keyboardSize
9
10 signal finished
11
12 Loader {
13 id: loader
14 anchors.fill: parent
15 sourceComponent: newAccountComponent
16
17 Connections {
18 target: loader.item
19 onFinished: root.finished()
20 }
21 }
22
23 Component {
24 id: newAccountComponent
25 NewAccount {}
26 }
27}
028
=== added file 'qml/owncloud/NewAccount.qml'
--- qml/owncloud/NewAccount.qml 1970-01-01 00:00:00 +0000
+++ qml/owncloud/NewAccount.qml 2016-06-02 12:13:37 +0000
@@ -0,0 +1,230 @@
1import QtQuick 2.0
2import Ubuntu.Components 1.3
3import Ubuntu.OnlineAccounts 0.1
4
5Item {
6 id: root
7
8 signal finished
9
10 anchors.margins: units.gu(1)
11 height: contents.height
12
13 property var __account: account
14 property string __host: ""
15 property bool __busy: false
16 property string __hostError: i18n.dtr("account-plugins", "Invalid host URL")
17
18 Column {
19 id: contents
20 anchors { left: parent.left; right: parent.right }
21 spacing: units.gu(1)
22
23 Label {
24 id: errorLabel
25 anchors { left: parent.left; right: parent.right }
26 font.bold: true
27 color: UbuntuColors.red
28 wrapMode: Text.Wrap
29 visible: !__busy && text != ""
30 }
31
32 Label {
33 anchors { left: parent.left; right: parent.right }
34 text: i18n.dtr("account-plugins", "URL:")
35 }
36
37 TextField {
38 id: urlField
39 anchors { left: parent.left; right: parent.right }
40 placeholderText: i18n.dtr("account-plugins", "http://example.org")
41 focus: true
42 enabled: !__busy
43
44 inputMethodHints: Qt.ImhUrlCharactersOnly
45 }
46
47 Label {
48 anchors { left: parent.left; right: parent.right }
49 text: i18n.dtr("account-plugins", "Username:")
50 }
51
52 TextField {
53 id: usernameField
54 anchors { left: parent.left; right: parent.right }
55 placeholderText: i18n.dtr("account-plugins", "Your username")
56 enabled: !__busy
57 inputMethodHints: Qt.ImhNoAutoUppercase + Qt.ImhNoPredictiveText + Qt.ImhPreferLowercase
58
59 KeyNavigation.tab: passwordField
60 }
61
62 Label {
63 anchors { left: parent.left; right: parent.right }
64 text: i18n.dtr("account-plugins", "Password:")
65 }
66
67 TextField {
68 id: passwordField
69 anchors { left: parent.left; right: parent.right }
70 placeholderText: i18n.dtr("account-plugins", "Your password")
71 echoMode: TextInput.Password
72 enabled: !__busy
73
74 inputMethodHints: Qt.ImhSensitiveData
75 Keys.onReturnPressed: login()
76 }
77
78 Row {
79 id: buttons
80 anchors { left: parent.left; right: parent.right }
81 height: units.gu(5)
82 spacing: units.gu(1)
83 Button {
84 id: btnCancel
85 text: i18n.dtr("account-plugins", "Cancel")
86 height: parent.height
87 width: (parent.width / 2) - 0.5 * parent.spacing
88 onClicked: finished()
89 }
90 Button {
91 id: btnContinue
92 text: i18n.dtr("account-plugins", "Continue")
93 color: UbuntuColors.green
94 height: parent.height
95 width: (parent.width / 2) - 0.5 * parent.spacing
96 onClicked: login()
97 enabled: !__busy
98 }
99 }
100 }
101
102 ActivityIndicator {
103 anchors.centerIn: parent
104 running: __busy
105 }
106
107 Credentials {
108 id: creds
109 caption: account.provider.id
110 acl: [ "unconfined" ]
111 storeSecret: true
112 onCredentialsIdChanged: root.credentialsStored()
113 }
114
115 AccountService {
116 id: globalAccountSettings
117 objectHandle: account.accountServiceHandle
118 autoSync: false
119 }
120
121 function login() {
122 __host = cleanUrl(urlField.text)
123 var username = usernameField.text
124 var password = passwordField.text
125
126 errorLabel.text = ""
127 __busy = true
128 var host = __host
129 var tryHttp = false
130 if (__host.indexOf("http") != 0) {
131 host = "https://" + __host
132 tryHttp = true
133 }
134
135 checkAccount(host, username, password, function cb(success) {
136 console.log("callback called: " + success)
137 if (success) {
138 saveData(host, username, password)
139 } else if (tryHttp) {
140 host = "http://" + __host
141 tryHttp = false
142 checkAccount(host, username, password, cb)
143 } else {
144 __busy = false
145 }
146 })
147 }
148
149 function saveData(host, username, password) {
150 __host = host
151 var strippedHost = __host.replace(/^https?:\/\//, '')
152 account.updateDisplayName(username + '@' + strippedHost)
153 creds.userName = username
154 creds.secret = password
155 creds.sync()
156 }
157
158 function findChild(node, tagName) {
159 if (!node) return node;
160 var children = node.childNodes
161 for (var i = 0; i < children.length; i++) {
162 if (children[i].nodeName == tagName) {
163 return children[i]
164 }
165 }
166 return null
167 }
168
169 function checkAccount(host, username, password, callback) {
170 console.log("Trying host " + host + " as " + username + ':' + password)
171 var request = new XMLHttpRequest();
172 request.onreadystatechange = function() {
173 if (request.readyState === XMLHttpRequest.DONE) {
174 console.log("response: " + request.responseText)
175 if (request.status == 200) {
176 var root = request.responseXML ? request.responseXML.documentElement : null
177 var metaElement = findChild(root, "meta")
178 var statusElement = findChild(metaElement, "status")
179 if (statusElement && statusElement.childNodes.length > 0 &&
180 statusElement.childNodes[0].nodeValue == "ok") {
181 callback(true)
182 } else {
183 var statusCodeElement = findChild(metaElement, "statuscode")
184 var statusCode = (statusCodeElement && statusCodeElement.childNodes.length > 0) ?
185 statusCodeElement.childNodes[0].nodeValue : "999"
186 if (statusCode == "999") {
187 showError(__hostError)
188 } else {
189 showError(i18n.dtr("account-plugins", "Invalid username or password"))
190 }
191 callback(false)
192 }
193 } else {
194 showError(__hostError)
195 callback(false)
196 }
197 }
198 }
199 request.open("POST", host + "/ocs/v1.php/person/check", true);
200 request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
201 var body = "login=" + username + "&password=" + password
202 request.send(body);
203 }
204
205 function showError(message) {
206 if (!errorLabel.text) errorLabel.text = message
207 }
208
209 function credentialsStored() {
210 console.log("Credentials stored, id: " + creds.credentialsId)
211 if (creds.credentialsId == 0) return
212
213 globalAccountSettings.updateServiceEnabled(true)
214 globalAccountSettings.credentials = creds
215 globalAccountSettings.updateSettings({
216 "host": __host
217 })
218 account.synced.connect(finished)
219 account.sync()
220 __busy = false
221 }
222
223 // check host url for http
224 function cleanUrl(url) {
225 var host = url.trim()
226 // if the user typed trailing '/' or "index.php", strip that
227 return host.replace(/\/(index.php)?\/*$/, '')
228 }
229
230}
0231
=== added directory 'qml/vk'
=== added file 'qml/vk/Main.qml'
--- qml/vk/Main.qml 1970-01-01 00:00:00 +0000
+++ qml/vk/Main.qml 2016-06-02 12:13:37 +0000
@@ -0,0 +1,36 @@
1import Ubuntu.OnlineAccounts.Plugin 1.0
2
3OAuthMain {
4 creationComponent: OAuth {
5 function completeCreation(reply) {
6 console.log("Access token: " + reply.AccessToken)
7 var http = new XMLHttpRequest()
8 var url = "https://api.vk.com/method/users.get?access_token=" + reply.AccessToken + "&fields=nickname,first_name,last_name";
9 http.open("GET", url, true);
10 http.onreadystatechange = function() {
11 if (http.readyState === 4){
12 if (http.status == 200) {
13 console.log("ok")
14 console.log("response text: " + http.responseText)
15 var response = JSON.parse(http.responseText)
16 if (response.response && response.response.length > 0) {
17 var data = response.response[0]
18 var name = data.first_name + " " + data.last_name
19 if (data.nickname) {
20 name += " (" + data.nickname + ")"
21 }
22 account.updateDisplayName(name)
23 }
24 account.synced.connect(finished)
25 account.sync()
26 } else {
27 console.log("error: " + http.status)
28 cancel()
29 }
30 }
31 };
32
33 http.send(null);
34 }
35 }
36}

Subscribers

People subscribed via source and target branches