Merge lp:~mardy/account-plugins/nextcloud-1639175 into lp:account-plugins

Proposed by Alberto Mardegan
Status: Merged
Approved by: Alberto Mardegan
Approved revision: 182
Merged at revision: 180
Proposed branch: lp:~mardy/account-plugins/nextcloud-1639175
Merge into: lp:account-plugins
Prerequisite: lp:~gary-wzl77/account-plugins/onedrive_provider
Diff against target: 433 lines (+312/-3)
11 files modified
.bzrignore (+10/-0)
Makefile.am (+3/-2)
configure.ac (+1/-0)
data/providers/nextcloud.provider.in.in (+13/-0)
debian/account-plugin-nextcloud.install (+3/-0)
debian/account-plugin-owncloud.install (+0/-1)
debian/changelog (+10/-0)
debian/control (+9/-0)
qml/Makefile.am (+2/-0)
qml/nextcloud/Main.qml (+27/-0)
qml/nextcloud/NewAccount.qml (+234/-0)
To merge this branch: bzr merge lp:~mardy/account-plugins/nextcloud-1639175
Reviewer Review Type Date Requested Status
Online Accounts Pending
Review via email: mp+310522@code.launchpad.net

Description of the change

Add account plugin for Nextcloud

To post a comment you must log in.
183. By Alberto Mardegan

Improve nextcloud icon

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2016-06-16 11:48:50 +0000
+++ .bzrignore 2016-11-10 13:53:58 +0000
@@ -21,6 +21,7 @@
21configure21configure
22compile22compile
23/data/providers/*.provider.in23/data/providers/*.provider.in
24/debian/*-stamp
24/debian/account-plugin-facebook/25/debian/account-plugin-facebook/
25/debian/account-plugin-flickr/26/debian/account-plugin-flickr/
26/debian/account-plugin-foursquare/27/debian/account-plugin-foursquare/
@@ -28,7 +29,11 @@
28/debian/account-plugin-google/29/debian/account-plugin-google/
29/debian/account-plugin-icons/30/debian/account-plugin-icons/
30/debian/account-plugin-identica/31/debian/account-plugin-identica/
32/debian/account-plugin-instagram/
33/debian/account-plugin-linkedin/
31/debian/account-plugin-mcloud/34/debian/account-plugin-mcloud/
35/debian/account-plugin-microsoft/
36/debian/account-plugin-nextcloud/
32/debian/account-plugin-owncloud/37/debian/account-plugin-owncloud/
33/debian/account-plugin-sina/38/debian/account-plugin-sina/
34/debian/account-plugin-sohu/39/debian/account-plugin-sohu/
@@ -39,6 +44,11 @@
39/debian/autoreconf.after44/debian/autoreconf.after
40/debian/autoreconf.before45/debian/autoreconf.before
41/debian/files46/debian/files
47/debian/libaccount-plugin-facebook/
48/debian/libaccount-plugin-flickr/
49/debian/libaccount-plugin-generic-oauth/
50/debian/libaccount-plugin-google/
51/debian/libaccount-plugin-twitter/
42/debian/tmp/52/debian/tmp/
43depcomp53depcomp
44install-sh54install-sh
4555
=== modified file 'Makefile.am'
--- Makefile.am 2016-11-10 13:53:58 +0000
+++ Makefile.am 2016-11-10 13:53:58 +0000
@@ -91,6 +91,7 @@
91 data/providers/instagram.provider.in.in \91 data/providers/instagram.provider.in.in \
92 data/providers/mcloud.provider.in.in \92 data/providers/mcloud.provider.in.in \
93 data/providers/microsoft.provider.in.in \93 data/providers/microsoft.provider.in.in \
94 data/providers/nextcloud.provider.in.in \
94 data/providers/owncloud.provider.in.in \95 data/providers/owncloud.provider.in.in \
95 data/providers/sina.provider.in.in \96 data/providers/sina.provider.in.in \
96 data/providers/sohu.provider.in.in \97 data/providers/sohu.provider.in.in \
@@ -137,12 +138,12 @@
137138
138# Temporary until these bugs are fixed:139# Temporary until these bugs are fixed:
139# https://bugs.launchpad.net/bugs/1567908140# https://bugs.launchpad.net/bugs/1567908
140# https://bugs.launchpad.net/bugs/1571587141# https://bugs.launchpad.net/bugs/1640704
141iconsdir = $(datadir)/icons/hicolor/32x32/apps142iconsdir = $(datadir)/icons/hicolor/32x32/apps
142dist_icons_DATA = \143dist_icons_DATA = \
143 data/icons/mcloud.png \144 data/icons/mcloud.png \
144 data/icons/microsoft.png \145 data/icons/microsoft.png \
145 data/icons/owncloud.png \146 data/icons/nextcloud.png \
146 data/icons/vk.png147 data/icons/vk.png
147148
148dist_bin_SCRIPTS = \149dist_bin_SCRIPTS = \
149150
=== modified file 'configure.ac'
--- configure.ac 2016-11-10 13:53:58 +0000
+++ configure.ac 2016-11-10 13:53:58 +0000
@@ -268,6 +268,7 @@
268 data/providers/instagram.provider.in268 data/providers/instagram.provider.in
269 data/providers/mcloud.provider.in269 data/providers/mcloud.provider.in
270 data/providers/microsoft.provider.in270 data/providers/microsoft.provider.in
271 data/providers/nextcloud.provider.in
271 data/providers/owncloud.provider.in272 data/providers/owncloud.provider.in
272 data/providers/sina.provider.in273 data/providers/sina.provider.in
273 data/providers/sohu.provider.in274 data/providers/sohu.provider.in
274275
=== added file 'data/icons/nextcloud.png'
275Binary files data/icons/nextcloud.png 1970-01-01 00:00:00 +0000 and data/icons/nextcloud.png 2016-11-10 13:53:58 +0000 differ276Binary files data/icons/nextcloud.png 1970-01-01 00:00:00 +0000 and data/icons/nextcloud.png 2016-11-10 13:53:58 +0000 differ
=== added file 'data/providers/nextcloud.provider.in.in'
--- data/providers/nextcloud.provider.in.in 1970-01-01 00:00:00 +0000
+++ data/providers/nextcloud.provider.in.in 2016-11-10 13:53:58 +0000
@@ -0,0 +1,13 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<provider id="nextcloud">
3 <name>Nextcloud</name>
4 <icon>nextcloud</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 'debian/account-plugin-nextcloud.install'
--- debian/account-plugin-nextcloud.install 1970-01-01 00:00:00 +0000
+++ debian/account-plugin-nextcloud.install 2016-11-10 13:53:58 +0000
@@ -0,0 +1,3 @@
1usr/share/accounts/providers/nextcloud.provider
2usr/share/accounts/qml-plugins/nextcloud/*.qml
3usr/share/icons/hicolor/32x32/apps/nextcloud.png
04
=== modified file 'debian/account-plugin-owncloud.install'
--- debian/account-plugin-owncloud.install 2016-08-01 15:50:48 +0000
+++ debian/account-plugin-owncloud.install 2016-11-10 13:53:58 +0000
@@ -1,3 +1,2 @@
1usr/share/accounts/providers/owncloud.provider1usr/share/accounts/providers/owncloud.provider
2usr/share/accounts/qml-plugins/owncloud/*.qml2usr/share/accounts/qml-plugins/owncloud/*.qml
3usr/share/icons/hicolor/32x32/apps/owncloud.png
43
=== modified file 'debian/changelog'
--- debian/changelog 2016-09-29 09:23:40 +0000
+++ debian/changelog 2016-11-10 13:53:58 +0000
@@ -1,3 +1,13 @@
1account-plugins (0.13+16.10.20160929.1-0ubuntu2) UNRELEASED; urgency=medium
2
3 * debian/account-plugin-owncloud.install:
4 - remove owncloud icon, it's now provided by the theme
5 * debian/control,debian/account-plugin-nextcloud.install:
6 - add Nextcloud account plugin
7 * Add account plugin for Nextcloud (LP: #1639175)
8
9 -- Alberto Mardegan <alberto.mardegan@canonical.com> Thu, 10 Nov 2016 11:43:37 +0300
10
1account-plugins (0.13+16.10.20160929.1-0ubuntu1) yakkety; urgency=medium11account-plugins (0.13+16.10.20160929.1-0ubuntu1) yakkety; urgency=medium
212
3 * Owncloud: properly encode username and password in POST request (LP:13 * Owncloud: properly encode username and password in POST request (LP:
414
=== modified file 'debian/control'
--- debian/control 2016-11-10 13:53:58 +0000
+++ debian/control 2016-11-10 13:53:58 +0000
@@ -163,6 +163,15 @@
163 This plugin adds support for creating microsoft accounts in the Unity Control163 This plugin adds support for creating microsoft accounts in the Unity Control
164 Center164 Center
165165
166Package: account-plugin-nextcloud
167Architecture: all
168Depends: ${misc:Depends},
169 signon-plugin-password,
170 ubuntu-system-settings-online-accounts,
171Description: Online account plugin for Unity - Nextcloud
172 This plugin adds support for creating Nextcloud accounts in the Unity Control
173 Center
174
166Package: account-plugin-owncloud175Package: account-plugin-owncloud
167Architecture: all176Architecture: all
168Depends: ${misc:Depends},177Depends: ${misc:Depends},
169178
=== modified file 'qml/Makefile.am'
--- qml/Makefile.am 2016-11-10 13:53:58 +0000
+++ qml/Makefile.am 2016-11-10 13:53:58 +0000
@@ -4,6 +4,8 @@
4 google/Main.qml \4 google/Main.qml \
5 mcloud/Main.qml \5 mcloud/Main.qml \
6 microsoft/Main.qml \6 microsoft/Main.qml \
7 nextcloud/Main.qml \
8 nextcloud/NewAccount.qml \
7 owncloud/Main.qml \9 owncloud/Main.qml \
8 owncloud/NewAccount.qml \10 owncloud/NewAccount.qml \
9 twitter/Main.qml \11 twitter/Main.qml \
1012
=== added directory 'qml/nextcloud'
=== added file 'qml/nextcloud/Main.qml'
--- qml/nextcloud/Main.qml 1970-01-01 00:00:00 +0000
+++ qml/nextcloud/Main.qml 2016-11-10 13:53:58 +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/nextcloud/NewAccount.qml'
--- qml/nextcloud/NewAccount.qml 1970-01-01 00:00:00 +0000
+++ qml/nextcloud/NewAccount.qml 2016-11-10 13:53:58 +0000
@@ -0,0 +1,234 @@
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 height: contents.height
11
12 property var __account: account
13 property string __host: ""
14 property bool __busy: false
15 property string __hostError: i18n.dtr("account-plugins", "Invalid host URL")
16
17 Column {
18 id: contents
19 anchors {
20 top: parent.top
21 left: parent.left
22 right: parent.right
23 margins: units.gu(2)
24 }
25 spacing: units.gu(2)
26
27 Label {
28 id: errorLabel
29 anchors { left: parent.left; right: parent.right }
30 font.bold: true
31 color: UbuntuColors.red
32 wrapMode: Text.Wrap
33 visible: !__busy && text != ""
34 }
35
36 Label {
37 anchors { left: parent.left; right: parent.right }
38 text: i18n.dtr("account-plugins", "URL:")
39 }
40
41 TextField {
42 id: urlField
43 anchors { left: parent.left; right: parent.right }
44 placeholderText: i18n.dtr("account-plugins", "http://myserver.com/nextcloud")
45 focus: true
46 enabled: !__busy
47
48 inputMethodHints: Qt.ImhUrlCharactersOnly
49 }
50
51 Label {
52 anchors { left: parent.left; right: parent.right }
53 text: i18n.dtr("account-plugins", "Username:")
54 }
55
56 TextField {
57 id: usernameField
58 anchors { left: parent.left; right: parent.right }
59 placeholderText: i18n.dtr("account-plugins", "Your username")
60 enabled: !__busy
61 inputMethodHints: Qt.ImhNoAutoUppercase + Qt.ImhNoPredictiveText + Qt.ImhPreferLowercase
62
63 KeyNavigation.tab: passwordField
64 }
65
66 Label {
67 anchors { left: parent.left; right: parent.right }
68 text: i18n.dtr("account-plugins", "Password:")
69 }
70
71 TextField {
72 id: passwordField
73 anchors { left: parent.left; right: parent.right }
74 placeholderText: i18n.dtr("account-plugins", "Your password")
75 echoMode: TextInput.Password
76 enabled: !__busy
77
78 inputMethodHints: Qt.ImhSensitiveData
79 Keys.onReturnPressed: login()
80 }
81
82 Row {
83 id: buttons
84 anchors { left: parent.left; right: parent.right }
85 height: units.gu(5)
86 spacing: units.gu(1)
87 Button {
88 id: btnCancel
89 text: i18n.dtr("account-plugins", "Cancel")
90 height: parent.height
91 width: (parent.width / 2) - 0.5 * parent.spacing
92 onClicked: finished()
93 }
94 Button {
95 id: btnContinue
96 text: i18n.dtr("account-plugins", "Continue")
97 color: UbuntuColors.green
98 height: parent.height
99 width: (parent.width / 2) - 0.5 * parent.spacing
100 onClicked: login()
101 enabled: !__busy
102 }
103 }
104 }
105
106 ActivityIndicator {
107 anchors.centerIn: parent
108 running: __busy
109 }
110
111 Credentials {
112 id: creds
113 caption: account.provider.id
114 acl: [ "unconfined" ]
115 storeSecret: true
116 onCredentialsIdChanged: root.credentialsStored()
117 }
118
119 AccountService {
120 id: globalAccountSettings
121 objectHandle: account.accountServiceHandle
122 autoSync: false
123 }
124
125 function login() {
126 __host = cleanUrl(urlField.text)
127 var username = usernameField.text
128 var password = passwordField.text
129
130 errorLabel.text = ""
131 __busy = true
132 var host = __host
133 var tryHttp = false
134 if (__host.indexOf("http") != 0) {
135 host = "https://" + __host
136 tryHttp = true
137 }
138
139 checkAccount(host, username, password, function cb(success) {
140 console.log("callback called: " + success)
141 if (success) {
142 saveData(host, username, password)
143 } else if (tryHttp) {
144 host = "http://" + __host
145 tryHttp = false
146 checkAccount(host, username, password, cb)
147 } else {
148 __busy = false
149 }
150 })
151 }
152
153 function saveData(host, username, password) {
154 __host = host
155 var strippedHost = __host.replace(/^https?:\/\//, '')
156 account.updateDisplayName(username + '@' + strippedHost)
157 creds.userName = username
158 creds.secret = password
159 creds.sync()
160 }
161
162 function findChild(node, tagName) {
163 if (!node) return node;
164 var children = node.childNodes
165 for (var i = 0; i < children.length; i++) {
166 if (children[i].nodeName == tagName) {
167 return children[i]
168 }
169 }
170 return null
171 }
172
173 function checkAccount(host, username, password, callback) {
174 console.log("Trying host " + host + " as " + username + ':' + password)
175 var request = new XMLHttpRequest();
176 request.onreadystatechange = function() {
177 if (request.readyState === XMLHttpRequest.DONE) {
178 console.log("response: " + request.responseText)
179 if (request.status == 200) {
180 var root = request.responseXML ? request.responseXML.documentElement : null
181 var metaElement = findChild(root, "meta")
182 var statusElement = findChild(metaElement, "status")
183 if (statusElement && statusElement.childNodes.length > 0 &&
184 statusElement.childNodes[0].nodeValue == "ok") {
185 callback(true)
186 } else {
187 var statusCodeElement = findChild(metaElement, "statuscode")
188 var statusCode = (statusCodeElement && statusCodeElement.childNodes.length > 0) ?
189 statusCodeElement.childNodes[0].nodeValue : "999"
190 if (statusCode == "999") {
191 showError(__hostError)
192 } else {
193 showError(i18n.dtr("account-plugins", "Invalid username or password"))
194 }
195 callback(false)
196 }
197 } else {
198 showError(__hostError)
199 callback(false)
200 }
201 }
202 }
203 request.open("POST", host + "/ocs/v1.php/person/check", true);
204 request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
205 var body = "login=" + encodeURIComponent(username) + "&password=" + encodeURIComponent(password)
206 request.send(body);
207 }
208
209 function showError(message) {
210 if (!errorLabel.text) errorLabel.text = message
211 }
212
213 function credentialsStored() {
214 console.log("Credentials stored, id: " + creds.credentialsId)
215 if (creds.credentialsId == 0) return
216
217 globalAccountSettings.updateServiceEnabled(true)
218 globalAccountSettings.credentials = creds
219 globalAccountSettings.updateSettings({
220 "host": __host
221 })
222 account.synced.connect(finished)
223 account.sync()
224 __busy = false
225 }
226
227 // check host url for http
228 function cleanUrl(url) {
229 var host = url.trim()
230 // if the user typed trailing '/' or "index.php", strip that
231 return host.replace(/\/(index.php)?\/*$/, '')
232 }
233
234}

Subscribers

People subscribed via source and target branches