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

Proposed by Alberto Mardegan
Status: Needs review
Proposed branch: lp:~mardy/account-plugins/mcloud-plugin-lp1587282
Merge into: lp:~gary-wzl77/account-plugins/mcloud-plugin-lp1587282
Diff against target: 1210 lines (+351/-510)
27 files modified
.bzrignore (+5/-0)
Makefile.am (+26/-6)
configure.ac (+4/-1)
data/providers/facebook.provider.in.in (+1/-1)
data/providers/flickr.provider.in.in (+1/-1)
data/providers/mcloud.provider.in.in (+4/-5)
data/providers/twitter.provider.in.in (+1/-1)
data/webkit-options/api.twitter.com.conf (+0/-2)
data/webkit-options/login.yahoo.com.conf (+0/-2)
data/webkit-options/www.facebook.com.conf (+0/-7)
debian/account-plugin-facebook.install (+0/-1)
debian/account-plugin-flickr.install (+0/-1)
debian/account-plugin-twitter.install (+0/-1)
debian/changelog (+34/-0)
debian/control (+73/-52)
debian/libaccount-plugin-facebook.install (+1/-0)
debian/libaccount-plugin-flickr.install (+1/-0)
debian/libaccount-plugin-twitter.install (+1/-0)
qml/Makefile.am (+1/-0)
qml/mcloud/ErrorItem.qml (+0/-48)
qml/mcloud/Main.qml (+2/-3)
qml/mcloud/OAuth.qml (+0/-283)
qml/mcloud/WebView.qml (+0/-94)
src/facebook.vala (+69/-0)
src/flickr.vala (+41/-0)
src/google.vala (+40/-1)
src/twitter.vala (+46/-0)
To merge this branch: bzr merge lp:~mardy/account-plugins/mcloud-plugin-lp1587282
Reviewer Review Type Date Requested Status
Gary.Wang Approve
Review via email: mp+296288@code.launchpad.net

Description of the change

Use the web based flow for authentication

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

Enable state parameter

Revision history for this message
Gary.Wang (gary-wzl77) wrote :

Thanks for this MP, mandy.
It looks good to me.

I know the reason why you apply this change in the signon-plugin-oauth (https://gitlab.com/accounts-sso/signon-plugin-oauth2/commit/e812eb3e76a1221074e3cf27208aacced5091e42).
And modify the TokenPath here accordingly. :)
...
<setting name="TokenPath">https://ose.caiyun.feixin.10086.cn/oauthApp/OAuth2/getToken</setting>
...

I'd like to test it on my side with my phone, could you please give me the silo number for accounts-sso/signon-plugin-oauth2 with your patch applied after you finish verification.
Thanks.

Revision history for this message
Alberto Mardegan (mardy) wrote :

> I'd like to test it on my side with my phone, could you please give me the
> silo number for accounts-sso/signon-plugin-oauth2 with your patch applied
> after you finish verification.

That will probably take some days, as I still need people to review the upstream changes.

But I've uploaded the package to my personal PPA here:
https://launchpad.net/~mardy/+archive/ubuntu/phablet/+packages

While I'm writing this the signon-plugin-oauth is still building on armhf, but it should be ready soon.

Revision history for this message
Gary.Wang (gary-wzl77) wrote :

I install latest signon-plugin-oauth package (armhf) on my device from your PPA , and run several tests. Mcloud scopes and camera app with mcloud integration both works very well.
Thanks mandy.
So let's wait for signon-plugin-oauth upstream review.

review: Approve
Revision history for this message
Alberto Mardegan (mardy) wrote :

Upstream review was faster than expected. I've put the OAuth plugin in silo 59, the CI ticket is this one:
https://requests.ci-train.ubuntu.com/#/ticket/1497

If you don't have objections, I will also take this branch and put it in the same silo, so that it will be easier to test.

Revision history for this message
Gary.Wang (gary-wzl77) wrote :

That's so nice.
No problem.
Thanks.

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

167. By Alberto Mardegan

Update description

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.

165. By Alberto Mardegan

Enable state parameter

164. By Alberto Mardegan

Change token path

163. By Alberto Mardegan

Use web_server mechanism

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2016-05-31 08:53:33 +0000
3+++ .bzrignore 2016-06-16 11:50:25 +0000
4@@ -6,6 +6,7 @@
5 *.service
6 *.substvars
7 *.stamp
8+*.trs
9 INSTALL
10 Makefile
11 Makefile.in
12@@ -53,7 +54,11 @@
13 .deps
14 .dirstamp
15 .libs
16+/src/facebook.c
17+/src/flickr.c
18 /src/generic-oauth.c
19 /src/google.c
20+/src/twitter.c
21+/test-driver
22 /test-provider
23 /test-service
24
25=== modified file 'Makefile.am'
26--- Makefile.am 2016-05-31 08:53:33 +0000
27+++ Makefile.am 2016-06-16 11:50:25 +0000
28@@ -8,8 +8,11 @@
29 if ENABLE_LIBACCOUNT_PLUGIN
30 # Binary account plugins.
31 plugin_LTLIBRARIES = \
32+ libfacebook.la \
33+ libflickr.la \
34 libgeneric-oauth.la \
35- libgoogle.la
36+ libgoogle.la \
37+ libtwitter.la
38
39 VALAFLAGS = \
40 --vapidir $(top_srcdir)/src \
41@@ -36,12 +39,32 @@
42 -no-undefined \
43 -export-symbols-regex '^ap_module_get_object_type'
44
45-libgoogle_la_CPPFLAGS = $(plugin_cppflags)
46-libgoogle_la_LIBADD = $(plugin_libadd)
47+libfacebook_la_CPPFLAGS = $(plugin_cppflags) $(RESTAPIS_CFLAGS)
48+libfacebook_la_LIBADD = $(plugin_libadd) $(RESTAPIS_LIBS)
49+libfacebook_la_LDFLAGS = $(plugin_ldflags)
50+libfacebook_la_VALAFLAGS = --pkg libsoup-2.4 --pkg json-glib-1.0
51+libfacebook_la_SOURCES = \
52+ src/facebook.vala
53+
54+libflickr_la_CPPFLAGS = $(plugin_cppflags)
55+libflickr_la_LIBADD = $(plugin_libadd)
56+libflickr_la_LDFLAGS = $(plugin_ldflags)
57+libflickr_la_SOURCES = \
58+ src/flickr.vala
59+
60+libgoogle_la_CPPFLAGS = $(plugin_cppflags) $(RESTAPIS_CFLAGS)
61+libgoogle_la_LIBADD = $(plugin_libadd) $(RESTAPIS_LIBS)
62 libgoogle_la_LDFLAGS = $(plugin_ldflags)
63+libgoogle_la_VALAFLAGS = --pkg libsoup-2.4 --pkg json-glib-1.0
64 libgoogle_la_SOURCES = \
65 src/google.vala
66
67+libtwitter_la_CPPFLAGS = $(plugin_cppflags)
68+libtwitter_la_LIBADD = $(plugin_libadd)
69+libtwitter_la_LDFLAGS = $(plugin_ldflags)
70+libtwitter_la_SOURCES = \
71+ src/twitter.vala
72+
73 libgeneric_oauth_la_CPPFLAGS = $(plugin_cppflags)
74 libgeneric_oauth_la_LIBADD = $(plugin_libadd)
75 libgeneric_oauth_la_LDFLAGS = $(plugin_ldflags)
76@@ -107,12 +130,9 @@
77 data/webkit-options/api.instagram.com.conf \
78 data/webkit-options/api.weibo.com.conf \
79 data/webkit-options/api.t.sohu.com.conf \
80- data/webkit-options/api.twitter.com.conf \
81 data/webkit-options/foursquare.com.conf \
82 data/webkit-options/identi.ca.conf \
83 data/webkit-options/login.live.com.conf \
84- data/webkit-options/login.yahoo.com.conf \
85- data/webkit-options/www.facebook.com.conf \
86 data/webkit-options/www.linkedin.com.conf
87
88 # Temporary until these bugs are fixed:
89
90=== modified file 'configure.ac'
91--- configure.ac 2016-05-31 08:53:33 +0000
92+++ configure.ac 2016-06-16 11:50:25 +0000
93@@ -41,7 +41,10 @@
94 [have_libaccount_plugin=no])
95
96 AS_IF([test "x$have_libaccount_plugin" = "xyes"],
97- [PKG_CHECK_MODULES([ACCOUNT_PLUGINS], [account-plugin >= 0.1.3])],
98+ [
99+ PKG_CHECK_MODULES([ACCOUNT_PLUGINS], [account-plugin >= 0.1.3])
100+ PKG_CHECK_MODULES([RESTAPIS], [libsoup-2.4 json-glib-1.0])
101+ ],
102 [AS_IF([test "x$enable_libaccount_plugin" = "xyes"],
103 [AC_MSG_ERROR([libaccount-plugin support enabled but required dependencies were not found])])])
104
105
106=== modified file 'data/providers/facebook.provider.in.in'
107--- data/providers/facebook.provider.in.in 2015-09-09 08:48:32 +0000
108+++ data/providers/facebook.provider.in.in 2016-06-16 11:50:25 +0000
109@@ -4,7 +4,7 @@
110 <icon>facebook</icon>
111 <translations>account-plugins</translations>
112 <domains>.*facebook\.com</domains>
113- <plugin>generic-oauth</plugin>
114+ <plugin>facebook</plugin>
115 <single-account>true</single-account>
116
117 <template>
118
119=== modified file 'data/providers/flickr.provider.in.in'
120--- data/providers/flickr.provider.in.in 2013-02-25 06:25:34 +0000
121+++ data/providers/flickr.provider.in.in 2016-06-16 11:50:25 +0000
122@@ -4,7 +4,7 @@
123 <icon>flickr</icon>
124 <translations>account-plugins</translations>
125 <domains>.*flickr\.com</domains>
126- <plugin>generic-oauth</plugin>
127+ <plugin>flickr</plugin>
128
129 <template>
130 <group name="auth">
131
132=== modified file 'data/providers/mcloud.provider.in.in'
133--- data/providers/mcloud.provider.in.in 2016-05-31 08:53:33 +0000
134+++ data/providers/mcloud.provider.in.in 2016-06-16 11:50:25 +0000
135@@ -9,18 +9,17 @@
136 <template>
137 <group name="auth">
138 <setting name="method">oauth2</setting>
139- <setting name="mechanism">user_agent</setting>
140+ <setting name="mechanism">web_server</setting>
141 <group name="oauth2">
142- <group name="user_agent">
143+ <group name="web_server">
144 <setting name="Host">caiyun.feixin.10086.cn</setting>
145 <setting name="AuthPath">authorize.jsp</setting>
146- <setting name="TokenPath">access_token</setting>
147+ <setting name="TokenPath">https://ose.caiyun.feixin.10086.cn/oauthApp/OAuth2/getToken</setting>
148 <setting name="RedirectUri">http://developer.ubuntu.com/en/</setting>
149 <setting name="ResponseType">code</setting>
150 <setting name="ClientId">@MCLOUD_CLIENT_ID@</setting>
151+ <setting name="ClientSecret">@MCLOUD_CLIENT_SECRET@</setting>
152 <setting type="as" name="Scope">['nd_cloud']</setting>
153- <setting name="ForceClientAuthViaRequestBody" type="b">true</setting>
154- <setting name="DisableStateParameter" type="b">true</setting>
155 <setting type="as" name="AllowedSchemes">['https', 'http']</setting>
156 </group>
157 </group>
158
159=== modified file 'data/providers/twitter.provider.in.in'
160--- data/providers/twitter.provider.in.in 2013-02-22 15:17:49 +0000
161+++ data/providers/twitter.provider.in.in 2016-06-16 11:50:25 +0000
162@@ -3,7 +3,7 @@
163 <name>Twitter</name>
164 <icon>twitter</icon>
165 <translations>account-plugins</translations>
166- <plugin>generic-oauth</plugin>
167+ <plugin>twitter</plugin>
168 <domains>.*twitter\.com</domains>
169
170 <template>
171
172=== removed file 'data/webkit-options/api.twitter.com.conf'
173--- data/webkit-options/api.twitter.com.conf 2012-06-19 06:08:30 +0000
174+++ data/webkit-options/api.twitter.com.conf 1970-01-01 00:00:00 +0000
175@@ -1,2 +0,0 @@
176-UsernameField = input[id="username_or_email"]
177-PasswordField = input[id="password"]
178
179=== removed file 'data/webkit-options/login.yahoo.com.conf'
180--- data/webkit-options/login.yahoo.com.conf 2012-06-18 14:24:03 +0000
181+++ data/webkit-options/login.yahoo.com.conf 1970-01-01 00:00:00 +0000
182@@ -1,2 +0,0 @@
183-UsernameField = input[name="login"]
184-PasswordField = input[name="passwd"]
185
186=== removed file 'data/webkit-options/www.facebook.com.conf'
187--- data/webkit-options/www.facebook.com.conf 2012-05-02 22:58:29 +0000
188+++ data/webkit-options/www.facebook.com.conf 1970-01-01 00:00:00 +0000
189@@ -1,7 +0,0 @@
190-ViewportWidth = 420
191-ViewportHeight = 320
192-UsernameField = input[name="email"]
193-PasswordField = input[name="pass"]
194-#ZoomFactor = 2
195-#PreferredWidth = 420
196-
197
198=== modified file 'debian/account-plugin-facebook.install'
199--- debian/account-plugin-facebook.install 2015-04-17 08:53:11 +0000
200+++ debian/account-plugin-facebook.install 2016-06-16 11:50:25 +0000
201@@ -1,4 +1,3 @@
202-etc/signon-ui/webkit-options.d/www.facebook.com.conf
203 usr/share/accounts/services/facebook-sharing.service
204 usr/share/accounts/services/facebook-microblog.service
205 usr/share/accounts/providers/facebook.provider
206
207=== modified file 'debian/account-plugin-flickr.install'
208--- debian/account-plugin-flickr.install 2014-03-31 08:21:46 +0000
209+++ debian/account-plugin-flickr.install 2016-06-16 11:50:25 +0000
210@@ -1,4 +1,3 @@
211-etc/signon-ui/webkit-options.d/login.yahoo.com.conf
212 usr/share/accounts/services/flickr-*.service
213 usr/share/accounts/providers/flickr.provider
214 usr/share/accounts/qml-plugins/flickr/Main.qml
215
216=== modified file 'debian/account-plugin-twitter.install'
217--- debian/account-plugin-twitter.install 2013-06-07 11:56:25 +0000
218+++ debian/account-plugin-twitter.install 2016-06-16 11:50:25 +0000
219@@ -1,4 +1,3 @@
220-etc/signon-ui/webkit-options.d/api.twitter.com.conf
221 usr/share/accounts/services/twitter-microblog.service
222 usr/share/accounts/providers/twitter.provider
223 usr/share/accounts/qml-plugins/twitter/Main.qml
224
225=== modified file 'debian/changelog'
226--- debian/changelog 2016-01-26 10:52:41 +0000
227+++ debian/changelog 2016-06-16 11:50:25 +0000
228@@ -1,3 +1,37 @@
229+account-plugins (0.13+16.10.20160614-0ubuntu1) yakkety; urgency=medium
230+
231+ * debian/control:
232+ Update package descriptions for all account plugins (LP: #1590786)
233+
234+ -- Alberto Mardegan <mardy@users.sourceforge.net> Tue, 14 Jun 2016 09:07:28 +0000
235+
236+account-plugins (0.13+16.10.20160608-0ubuntu1) yakkety; urgency=medium
237+
238+ [ Alberto Mardegan ]
239+ * Add account plugin for vk.com (LP: #1564883)
240+ * Add ownCloud plugin (LP: #1570986)
241+
242+ -- David Barth <david.barth@canonical.com> Wed, 08 Jun 2016 12:09:10 +0000
243+
244+account-plugins (0.13+16.04.20160405-0ubuntu1) xenial; urgency=medium
245+
246+ [ Alberto Mardegan ]
247+ * After the authentication, retrieve the username in Google, Facebook,
248+ Flickr and Twitter plugins (LP: #1565772)
249+ * debian/control, debian/libaccount-plugin-facebook.install,
250+ debian/libaccount-plugin-flickr.install,
251+ debian/libaccount-plugin-twitter.install:
252+ add packages containing plugin modules.
253+ * debian/account-plugin-facebook.install,
254+ debian/account-plugin-flickr.install,
255+ debian/account-plugin-twitter.install:
256+ remove unneeded webkit-options files.
257+
258+ [ CI Train Bot ]
259+ * No-change rebuild.
260+
261+ -- David Barth <david.barth@canonical.com> Tue, 05 Apr 2016 12:57:47 +0000
262+
263 account-plugins (0.12+16.04.20160126-0ubuntu1) xenial; urgency=medium
264
265 [ Alberto Mardegan ]
266
267=== modified file 'debian/control'
268--- debian/control 2016-05-31 08:53:33 +0000
269+++ debian/control 2016-06-16 11:50:25 +0000
270@@ -7,9 +7,11 @@
271 gobject-introspection,
272 python3,
273 pkg-config,
274+ libaccount-plugin-1.0-dev (>= 0.1.9),
275 libaccounts-glib-dev (>= 1.10),
276+ libjson-glib-dev,
277 libsignon-glib-dev,
278- libaccount-plugin-1.0-dev (>= 0.1.3),
279+ libsoup2.4-dev,
280 valac (>= 0.16),
281 gnome-common,
282 dh-autoreconf,
283@@ -24,125 +26,151 @@
284 Architecture: any
285 Depends: ${shlibs:Depends}, ${misc:Depends},
286 signon-plugin-oauth2,
287-Replaces: account-plugin-generic-oauth (<< 0.10bzr13.04.30)
288-Breaks: account-plugin-generic-oauth (<< 0.10bzr13.04.30)
289-Conflicts: account-plugin-generic-oauth (<< 0.10bzr13.04.30),
290- account-plugin-windows-live,
291-Description: GNOME Control Center account plugin for single signon - generic OAuth
292- GNOME Control Center account plugins for single signon
293+Conflicts: account-plugin-windows-live,
294+Description: Online account plugin support lib for Unity 7 - generic OAuth
295+ Support library for the Unity 7 OAuth-based online account plugins
296
297 Package: libaccount-plugin-google
298 Architecture: any
299 Depends: ${shlibs:Depends}, ${misc:Depends},
300 signon-plugin-oauth2,
301-Replaces: account-plugin-google (<< 0.10bzr13.04.30)
302-Breaks: account-plugin-google (<< 0.10bzr13.04.30)
303-Conflicts: account-plugin-google (<< 0.10bzr13.04.30)
304-Description: GNOME Control Center account plugin for single signon - Google Auth
305- GNOME Control Center account plugins for single signon
306+Description: Online account plugin support lib for Unity 7 - Google
307+ Support library for the Unity 7 online account plugin
308
309 Package: account-plugin-google
310 Architecture: all
311 Depends: ${shlibs:Depends}, ${misc:Depends},
312 libaccount-plugin-google | ubuntu-system-settings-online-accounts,
313 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
314-Description: GNOME Control Center account plugin for single signon
315- GNOME Control Center account plugins for single signon
316+Description: Online account plugin for Unity - Google
317+ This plugin adds support for creating Google accounts in the Unity Control
318+ Center
319+
320+Package: libaccount-plugin-facebook
321+Architecture: any
322+Depends: ${shlibs:Depends}, ${misc:Depends},
323+ signon-plugin-oauth2,
324+Description: Online account plugin support lib for Unity 7 - Facebook
325+ Support library for the Unity 7 online account plugin
326
327 Package: account-plugin-facebook
328 Architecture: all
329 Depends: ${misc:Depends},
330- libaccount-plugin-generic-oauth | ubuntu-system-settings-online-accounts,
331+ libaccount-plugin-facebook | ubuntu-system-settings-online-accounts,
332 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
333-Description: GNOME Control Center account plugin for single signon - facebook
334- GNOME Control Center account plugins for single signon
335+Description: Online account plugin for Unity - Facebook
336+ This plugin adds support for creating Facebook accounts in the Unity Control
337+ Center
338+
339+Package: libaccount-plugin-twitter
340+Architecture: any
341+Depends: ${shlibs:Depends}, ${misc:Depends},
342+ signon-plugin-oauth2,
343+Description: Online account plugin support lib for Unity 7 - Twitter
344+ Support library for the Unity 7 online account plugin
345
346 Package: account-plugin-twitter
347 Architecture: all
348 Depends: ${misc:Depends},
349- libaccount-plugin-generic-oauth | ubuntu-system-settings-online-accounts,
350+ libaccount-plugin-twitter | ubuntu-system-settings-online-accounts,
351 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
352-Description: GNOME Control Center account plugin for single signon - twitter
353- GNOME Control Center account plugins for single signon
354+Description: Online account plugin for Unity - Twitter
355+ This plugin adds support for creating Twitter accounts in the Unity Control
356+ Center
357+
358+Package: libaccount-plugin-flickr
359+Architecture: any
360+Depends: ${shlibs:Depends}, ${misc:Depends},
361+ signon-plugin-oauth2,
362+Description: Online account plugin support lib for Unity 7 - Flickr
363+ Support library for the Unity 7 online account plugin
364
365 Package: account-plugin-flickr
366 Architecture: all
367 Depends: ${misc:Depends},
368- libaccount-plugin-generic-oauth | ubuntu-system-settings-online-accounts,
369+ libaccount-plugin-flickr | ubuntu-system-settings-online-accounts,
370 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
371-Description: GNOME Control Center account plugin for single signon - flickr
372- GNOME Control Center account plugins for single signon
373+Description: Online account plugin for Unity - Flickr
374+ This plugin adds support for creating Flickr accounts in the Unity Control
375+ Center
376
377 Package: account-plugin-identica
378 Architecture: all
379 Depends: ${misc:Depends},
380 libaccount-plugin-generic-oauth,
381 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
382-Description: GNOME Control Center account plugin for single signon - identica
383- GNOME Control Center account plugins for single signon
384+Description: Online account plugin for Unity - identi.ca
385+ This plugin adds support for creating identi.ca accounts in the Unity Control
386+ Center
387
388 Package: account-plugin-foursquare
389 Architecture: all
390 Depends: ${misc:Depends},
391 libaccount-plugin-generic-oauth,
392 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
393-Description: GNOME Control Center account plugin for single signon - foursquare
394- GNOME Control Center account plugins for single signon
395+Description: Online account plugin for Unity - FourSquare
396+ This plugin adds support for creating FourSquare accounts in the Unity
397+ Control Center
398
399 Package: account-plugin-sohu
400 Architecture: all
401 Depends: ${misc:Depends},
402 libaccount-plugin-generic-oauth,
403 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
404-Description: GNOME Control Center account plugin for single signon - sohu
405- GNOME Control Center account plugins for single signon
406+Description: Online account plugin for Unity - Sohu
407+ This plugin adds support for creating Sohu accounts in the Unity Control
408+ Center
409
410 Package: account-plugin-sina
411 Architecture: all
412 Depends: ${misc:Depends},
413 libaccount-plugin-generic-oauth,
414 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
415-Description: GNOME Control Center account plugin for single signon - sina
416- GNOME Control Center account plugins for single signon
417+Description: Online account plugin for Unity - Sina
418+ This plugin adds support for creating Sina accounts in the Unity Control
419+ Center
420
421 Package: account-plugin-linkedin
422 Architecture: all
423 Depends: ${misc:Depends},
424 libaccount-plugin-generic-oauth,
425 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
426-Description: GNOME Control Center account plugin for single signon - LinkedIn
427- GNOME Control Center account plugins for single signon
428+Description: Online account plugin for Unity - LinkedIn
429+ This plugin adds support for creating LinkedIn accounts in the Unity Control
430+ Center
431
432 Package: account-plugin-instagram
433 Architecture: all
434 Depends: ${misc:Depends},
435 libaccount-plugin-generic-oauth,
436 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
437-Description: GNOME Control Center account plugin for single signon - Instagram
438- GNOME Control Center account plugins for single signon
439+Description: Online account plugin for Unity - Instagram
440+ This plugin adds support for creating Instagram accounts in the Unity Control
441+ Center
442
443 Package: account-plugin-mcloud
444 Architecture: all
445 Depends: ${misc:Depends},
446 ubuntu-system-settings-online-accounts,
447-Description: Account plugin for online accounts - mCloud
448- Online Accounts plugin provide the user interface to create accounts for
449- third party services.
450+Description: Online account plugin for Unity - mCloud
451+ This plugin adds support for creating mCloud accounts in the Unity Control
452+ Center
453
454 Package: account-plugin-owncloud
455 Architecture: all
456 Depends: ${misc:Depends},
457 ubuntu-system-settings-online-accounts,
458-Description: Account plugin for online accounts - ownCloud
459- Online Accounts plugin provide the user interface to create accounts for
460- third party services.
461+Description: Online account plugin for Unity - ownCloud
462+ This plugin adds support for creating ownCloud accounts in the Unity Control
463+ Center
464
465 Package: account-plugin-vk
466 Architecture: all
467 Depends: ${misc:Depends},
468 libaccount-plugin-generic-oauth | ubuntu-system-settings-online-accounts,
469-Description: GNOME Control Center account plugin for single signon - VKontakte
470- GNOME Control Center account plugins for single signon
471+Description: Online account plugin for Unity - VKontakte
472+ This plugin adds support for creating VKontakte accounts in the Unity Control
473+ Center
474
475 Package: account-plugin-tools
476 Architecture: all
477@@ -154,12 +182,5 @@
478 gir1.2-accounts-1.0,
479 signon-plugin-oauth2,
480 unity-asset-pool (>> 0.8.24daily12.12.05-0ubuntu1),
481-Description: GNOME Control Center account plugins for single signon - tools
482- GNOME Control Center account plugins for single signon
483-
484-Package: account-plugin-icons
485-Depends: unity-asset-pool, ${misc:Depends}
486-Architecture: all
487-Section: oldlibs
488-Description: transitional dummy package
489- This is a transitional dummy package. It can safely be removed.
490+Description: Online account plugins for Unity - tools
491+ Command line tools for managing Online Accounts.
492
493=== added file 'debian/libaccount-plugin-facebook.install'
494--- debian/libaccount-plugin-facebook.install 1970-01-01 00:00:00 +0000
495+++ debian/libaccount-plugin-facebook.install 2016-06-16 11:50:25 +0000
496@@ -0,0 +1,1 @@
497+usr/lib/libaccount-plugin-1.0/providers/libfacebook.so
498
499=== added file 'debian/libaccount-plugin-flickr.install'
500--- debian/libaccount-plugin-flickr.install 1970-01-01 00:00:00 +0000
501+++ debian/libaccount-plugin-flickr.install 2016-06-16 11:50:25 +0000
502@@ -0,0 +1,1 @@
503+usr/lib/libaccount-plugin-1.0/providers/libflickr.so
504
505=== added file 'debian/libaccount-plugin-twitter.install'
506--- debian/libaccount-plugin-twitter.install 1970-01-01 00:00:00 +0000
507+++ debian/libaccount-plugin-twitter.install 2016-06-16 11:50:25 +0000
508@@ -0,0 +1,1 @@
509+usr/lib/libaccount-plugin-1.0/providers/libtwitter.so
510
511=== modified file 'qml/Makefile.am'
512--- qml/Makefile.am 2016-04-18 12:06:17 +0000
513+++ qml/Makefile.am 2016-06-16 11:50:25 +0000
514@@ -2,6 +2,7 @@
515 facebook/Main.qml \
516 flickr/Main.qml \
517 google/Main.qml \
518+ mcloud/Main.qml \
519 owncloud/Main.qml \
520 owncloud/NewAccount.qml \
521 twitter/Main.qml \
522
523=== removed file 'qml/mcloud/ErrorItem.qml'
524--- qml/mcloud/ErrorItem.qml 2016-05-31 08:53:33 +0000
525+++ qml/mcloud/ErrorItem.qml 1970-01-01 00:00:00 +0000
526@@ -1,48 +0,0 @@
527-/*
528- * Copyright (C) 2015 Canonical Ltd.
529- *
530- * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
531- *
532- * This program is free software: you can redistribute it and/or modify it
533- * under the terms of the GNU General Public License version 3, as published
534- * by the Free Software Foundation.
535- *
536- * This program is distributed in the hope that it will be useful, but
537- * WITHOUT ANY WARRANTY; without even the implied warranties of
538- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
539- * PURPOSE. See the GNU General Public License for more details.
540- *
541- * You should have received a copy of the GNU General Public License along
542- * with this program. If not, see <http://www.gnu.org/licenses/>.
543- */
544-
545-import QtQuick 2.0
546-import Ubuntu.Components 0.1
547-import Ubuntu.Components.ListItems 0.1 as ListItem
548-
549-Item {
550- id: root
551-
552- signal retryRequested()
553-
554- Column {
555- anchors {
556- verticalCenter: parent.verticalCenter
557- left: parent.left; right: parent.right
558- }
559- spacing: units.gu(2)
560-
561- Label {
562- anchors { left: parent.left; right: parent.right }
563- text: i18n.dtr("ubuntu-system-settings-online-accounts", "This service is not available right now. Try again later.")
564- wrapMode: Text.WordWrap
565- horizontalAlignment: Text.AlignHCenter
566- }
567-
568- Button {
569- anchors.horizontalCenter: parent.horizontalCenter
570- text: i18n.dtr("ubuntu-system-settings-online-accounts", "Try Again")
571- onClicked: root.retryRequested()
572- }
573- }
574-}
575
576=== modified file 'qml/mcloud/Main.qml'
577--- qml/mcloud/Main.qml 2016-05-31 08:53:33 +0000
578+++ qml/mcloud/Main.qml 2016-06-16 11:50:25 +0000
579@@ -1,7 +1,6 @@
580 import Ubuntu.OnlineAccounts.Plugin 1.0
581-import "." as Local
582
583 OAuthMain {
584- creationComponent: Local.OAuth {
585- }
586+ creationComponent: OAuth {
587+ }
588 }
589
590=== removed file 'qml/mcloud/OAuth.qml'
591--- qml/mcloud/OAuth.qml 2016-05-31 08:53:33 +0000
592+++ qml/mcloud/OAuth.qml 1970-01-01 00:00:00 +0000
593@@ -1,283 +0,0 @@
594-/*
595- * Copyright (C) 2013-2016 Canonical Ltd.
596- *
597- * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
598- *
599- * This program is free software: you can redistribute it and/or modify it
600- * under the terms of the GNU General Public License version 3, as published
601- * by the Free Software Foundation.
602- *
603- * This program is distributed in the hope that it will be useful, but
604- * WITHOUT ANY WARRANTY; without even the implied warranties of
605- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
606- * PURPOSE. See the GNU General Public License for more details.
607- *
608- * You should have received a copy of the GNU General Public License along
609- * with this program. If not, see <http://www.gnu.org/licenses/>.
610- */
611-
612-import QtQuick 2.0
613-import Ubuntu.Components 1.3
614-import Ubuntu.Components.ListItems 1.3 as ListItem
615-import Ubuntu.Components.Popups 1.3
616-import Ubuntu.OnlineAccounts 0.1
617-import Ubuntu.OnlineAccounts.Plugin 1.0
618-
619-Item {
620- id: root
621-
622- /* To override the parameters coming from the .provider file: */
623- property variant authenticationParameters: {}
624- /* To override the default access control list: */
625- property variant accessControlList: ["unconfined"]
626-
627- property variant authReply
628- property bool isNewAccount: false
629- property variant __account: account
630- property bool __isAuthenticating: false
631- property alias globalAccountService: globalAccountSettings
632- property bool loading: loader.status == Loader.Null || loader.status == Loader.Loading
633-
634- signal authenticated(variant reply)
635- signal authenticationError(variant error)
636- signal finished
637-
638- anchors.fill: parent
639-
640- Component.onCompleted: {
641- isNewAccount = (account.accountId === 0)
642- enableAccount()
643- authenticate()
644- }
645-
646- RequestHandler {
647- id: requestHandler
648- onRequestChanged: {
649- if (request) {
650- console.log("RequestHandler captured request!")
651- loader.setSource("WebView.qml", {
652- "signonRequest": request
653- })
654- } else {
655- console.log("Request destroyed!")
656- loader.source = ""
657- }
658- }
659- }
660-
661- Credentials {
662- id: creds
663- caption: account.provider.id
664- acl: accessControlList
665- onCredentialsIdChanged: root.credentialsStored()
666- }
667-
668- AccountService {
669- id: globalAccountSettings
670- objectHandle: account.accountServiceHandle
671- credentials: creds
672- autoSync: false
673-
674- onAuthenticated: {
675- __isAuthenticating = false
676- authReply = reply
677- root.authenticated(reply)
678- }
679- onAuthenticationError: {
680- __isAuthenticating = false
681- root.authenticationError(error)
682- }
683- }
684-
685- AccountServiceModel {
686- id: accountServices
687- includeDisabled: true
688- account: __account.objectHandle
689- }
690-
691- ListItem.Base {
692- visible: loading && !errorItem.visible
693- height: units.gu(7)
694- showDivider: false
695- anchors.top: parent.top
696-
697- Item {
698- height: units.gu(5)
699- width: units.gu(30)
700- anchors.horizontalCenter: parent.horizontalCenter
701- anchors.top: parent.top
702- anchors.margins: units.gu(1)
703-
704- ActivityIndicator {
705- id: loadingIndicator
706- anchors.verticalCenter: parent.verticalCenter
707- anchors.left: parent.left
708- anchors.leftMargin: units.gu(5)
709- running: loading
710- z: 1
711- }
712- Label {
713- text: i18n.dtr("ubuntu-system-settings-online-accounts", "Loading…")
714- anchors.verticalCenter: parent.verticalCenter
715- anchors.left: loadingIndicator.right
716- anchors.leftMargin: units.gu(3)
717- }
718- }
719- }
720-
721- Loader {
722- id: loader
723- anchors {
724- top: parent.top
725- left: parent.left
726- right: parent.right
727- bottom: Qt.inputMethod.visible ? osk.top : cancelButton.top
728- }
729- focus: true
730- visible: !loading
731- }
732-
733- ErrorItem {
734- id: errorItem
735- anchors { fill: parent; margins: units.gu(4) }
736- visible: false
737- onRetryRequested: {
738- root.credentialsStored()
739- visible = false
740- }
741- }
742-
743- KeyboardRectangle {
744- id: osk
745- }
746-
747- ListItem.SingleControl {
748- id: cancelButton
749- anchors.bottom: parent.bottom
750- showDivider: false
751- control: Button {
752- text: i18n.dtr("ubuntu-system-settings-online-accounts", "Cancel")
753- width: parent.width - units.gu(4)
754- onClicked: root.cancel()
755- }
756- }
757-
758- AccountServiceModel {
759- id: possiblyDuplicateAccounts
760- service: "global"
761- provider: __account.provider.id
762- }
763-
764- function authenticate() {
765- console.log("Authenticating...")
766- creds.sync()
767- }
768-
769- function credentialsStored() {
770- console.log("Credentials stored, id: " + creds.credentialsId)
771- if (creds.credentialsId == 0) return
772- var parameters = {}
773- parameters[requestHandler.matchKey] = requestHandler.matchId
774- parameters["providerId"] = account.provider.id
775- for (var p in authenticationParameters) {
776- parameters[p] = authenticationParameters[p]
777- }
778- __isAuthenticating = true
779- globalAccountSettings.authenticate(parameters)
780- }
781-
782- function cancel() {
783- if (__isAuthenticating) {
784- /* This will cause the authentication to fail, and this method will
785- * be invoked again to delete the credentials. */
786- globalAccountSettings.cancelAuthentication()
787- return
788- }
789- if (isNewAccount && creds.credentialsId != 0) {
790- console.log("Removing credentials...")
791- creds.remove()
792- creds.removed.connect(finished)
793- } else {
794- finished()
795- }
796- }
797-
798- function enableAccount() {
799- globalAccountSettings.updateServiceEnabled(true)
800- }
801-
802- function getUserName(reply, callback) {
803- /* This should work for OAuth 1.0a; for OAuth 2.0 this function needs
804- * to be reimplemented */
805- if ('ScreenName' in reply) return reply.ScreenName
806- else if ('UserId' in reply) return reply.UserId
807- return ''
808- }
809-
810- function accountIsDuplicate(userName) {
811- var model = possiblyDuplicateAccounts
812- for (var i = 0; i < model.count; i++) {
813- if (model.get(i, "displayName") == userName)
814- return true
815- }
816- return false
817- }
818-
819- function __gotUserName(userName, reply) {
820- console.log("UserName: " + userName)
821- if (userName != '') {
822- if (accountIsDuplicate(userName)) {
823- var dialog = PopupUtils.open(Qt.resolvedUrl("DuplicateAccount.qml"))
824- dialog.closed.connect(cancel)
825- return
826- }
827- account.updateDisplayName(userName)
828- }
829- beforeSaving(reply)
830- }
831-
832- function saveAccount() {
833- account.synced.connect(finished)
834- account.sync()
835- }
836-
837- /* reimplement this function in plugins in order to perform some actions
838- * before quitting the plugin */
839- function beforeSaving(reply) {
840- saveAccount()
841- }
842-
843- function __getUserNameAndSave(reply) {
844- /* If the completeCreation function is defined, run it */
845- if (typeof(completeCreation) == "function") {
846- console.warn("The completeCreation method is deprecated; use getUserName() or beforeSaving() instead")
847- completeCreation(reply)
848- return
849- }
850-
851- var userName = getUserName(reply, function(name) {
852- __gotUserName(name, reply)
853- })
854- if (typeof(userName) == "string") {
855- __gotUserName(userName, reply)
856- } else if (userName === false) {
857- cancel()
858- return
859- }
860- // otherwise (userName === true), wait for the callback to be invoked
861- }
862-
863- onAuthenticated: __getUserNameAndSave(reply)
864-
865- onAuthenticationError: {
866- console.log("Authentication error, code " + error.code)
867- if (error.code == AccountService.NetworkError) {
868- console.log("Network error")
869- errorItem.visible = true
870- return
871- }
872- root.cancel()
873- }
874-
875- onFinished: loading = false
876-}
877
878=== removed file 'qml/mcloud/WebView.qml'
879--- qml/mcloud/WebView.qml 2016-05-31 08:53:33 +0000
880+++ qml/mcloud/WebView.qml 1970-01-01 00:00:00 +0000
881@@ -1,94 +0,0 @@
882-import QtQuick 2.0
883-import Ubuntu.Components 1.1
884-import Ubuntu.Web 0.2
885-
886-WebView {
887- id: root
888-
889- property QtObject signonRequest
890- readonly property string token_url: "https://ose.caiyun.feixin.10086.cn/oauthApp/OAuth2/getToken"
891- readonly property string redirect_url: "http://developer.ubuntu.com/en/"
892- readonly property string client_id: "APP1ZtqoN3R0002"
893- readonly property string client_pass: "A70EFCDC91456349E7FDECF0A33574AC"
894-
895- Component.onCompleted: {
896- signonRequest.authenticated.connect(onAuthenticated)
897- url = signonRequest.startUrl
898- }
899-
900- //1.WORKAROUND: we need to retrieve refresh token instead of access token.
901- function fetchRefreshToken(code) {
902- var http = new XMLHttpRequest()
903- var body = "grant_type=authorization_code&code="+code+"&redirect_uri="+redirect_url
904-
905- http.open("POST", token_url, true);
906- http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
907- http.setRequestHeader("Authorization", "Basic " + Qt.btoa(client_id + ":" + client_pass));
908- http.onreadystatechange = function() {
909- if (http.readyState === 4 && http.status == 200) {
910- var response = JSON.parse(http.responseText)
911- //create a fake access_token with refresh token.
912- var urlStr = redirect_url+"#access_token="+response.refresh_token
913- var authUrl = Qt.resolvedUrl(urlStr);
914- signonRequest.currentUrl = authUrl
915- } else {
916- console.log("error: " + http.status)
917- }
918- };
919-
920- http.send(body);
921- }
922-
923- onLoadingStateChanged: {
924- if (loading) {
925- signonRequest.onLoadStarted()
926- } else if (lastLoadSucceeded) {
927- signonRequest.onLoadFinished(true)
928- } else {
929- signonRequest.onLoadFinished(false)
930- }
931- }
932-
933- onUrlChanged: {
934- //2.WORKAROUND: retrieve refresh token if code is fetched
935- var code_pattern= new RegExp("\\?code=.*&");
936- var urlStr = url.toString()
937- if (code_pattern.test(urlStr)){
938- var code = urlStr.match(/\?code=(.*)&/)[1];
939- console.log("code::", code)
940- fetchRefreshToken(code)
941- } else {
942- signonRequest.currentUrl = url
943- }
944- }
945-
946- //3.WORKAROUND: Apply desktop useragent to prevent server from detecting android client,
947- //which causes authentication failure.
948- context: WebContext {
949- dataPath: signonRequest ? signonRequest.rootDir : ""
950- userAgent: "Mozilla/5.0 (Linux; Ubuntu 14.04) AppleWebKit/537.36 Chromium/35.0.1870.2 Safari/537.36"
951- }
952-
953- function onAuthenticated() {
954- /* Get the cookies and set them on the request */
955- console.log("Authenticated; getting cookies")
956- context.cookieManager.getCookiesResponse.connect(onGotCookies)
957- context.cookieManager.getAllCookies()
958- visible = false
959- }
960-
961- function onGotCookies(requestId, cookies) {
962- signonRequest.setCookies(cookies)
963- }
964-
965- /* Taken from webbrowser-app */
966- ProgressBar {
967- anchors.top: parent.top
968- anchors.left: parent.left
969- anchors.right: parent.right
970- height: units.dp(3)
971- showProgressPercentage: false
972- visible: root.loading
973- value: root.loadProgress / 100
974- }
975-}
976
977=== added file 'src/facebook.vala'
978--- src/facebook.vala 1970-01-01 00:00:00 +0000
979+++ src/facebook.vala 2016-06-16 11:50:25 +0000
980@@ -0,0 +1,69 @@
981+/*
982+ * Copyright (C) 2016 Canonical, Inc
983+ *
984+ * This program is free software; you can redistribute it and/or modify
985+ * it under the terms of the GNU General Public License version 2 as
986+ * published by the Free Software Foundation.
987+ *
988+ * This program is distributed in the hope that it will be useful,
989+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
990+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
991+ * GNU General Public License for more details.
992+ *
993+ * You should have received a copy of the GNU General Public License
994+ * along with this program; if not, write to the Free Software
995+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
996+ * USA.
997+ *
998+ * Authors:
999+ * Alberto Mardegan <alberto.mardegan@canonical.com>
1000+ */
1001+
1002+public class FacebookPlugin : Ap.OAuthPlugin {
1003+ private Soup.Session session;
1004+
1005+ public FacebookPlugin (Ag.Account account) {
1006+ Object (account: account);
1007+ }
1008+
1009+ private void fetch_username (string access_token) {
1010+ debug ("fetching username, AT = " + access_token);
1011+ Soup.URI destination_uri =
1012+ new Soup.URI ("https://graph.facebook.com/me?access_token=" +
1013+ access_token);
1014+ var message = new Soup.Message.from_uri ("GET", destination_uri);
1015+ session = new Soup.Session ();
1016+ session.queue_message (message, (sess, msg) => {
1017+ debug ("Got message reply");
1018+ string body = (string) msg.response_body.data;
1019+ Json.Parser parser = new Json.Parser ();
1020+ try {
1021+ parser.load_from_data (body);
1022+
1023+ Json.Node root = parser.get_root ();
1024+ Json.Object response_object = root.get_object ();
1025+ var username = response_object.get_string_member ("name");
1026+ account.set_display_name (username);
1027+ } catch (Error error) {
1028+ warning ("Could not parse reply: " + body);
1029+ }
1030+
1031+ store_account ();
1032+ });
1033+ }
1034+
1035+ protected override void query_username () {
1036+ var reply = get_oauth_reply ();
1037+ Variant? v_token = reply.lookup_value ("AccessToken", null);
1038+ if (v_token != null) {
1039+ fetch_username (v_token.get_string ());
1040+ } else {
1041+ store_account ();
1042+ }
1043+ }
1044+}
1045+
1046+public GLib.Type ap_module_get_object_type ()
1047+{
1048+ return typeof (FacebookPlugin);
1049+}
1050
1051=== added file 'src/flickr.vala'
1052--- src/flickr.vala 1970-01-01 00:00:00 +0000
1053+++ src/flickr.vala 2016-06-16 11:50:25 +0000
1054@@ -0,0 +1,41 @@
1055+/*
1056+ * Copyright (C) 2016 Canonical, Inc
1057+ *
1058+ * This program is free software; you can redistribute it and/or modify
1059+ * it under the terms of the GNU General Public License version 2 as
1060+ * published by the Free Software Foundation.
1061+ *
1062+ * This program is distributed in the hope that it will be useful,
1063+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1064+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1065+ * GNU General Public License for more details.
1066+ *
1067+ * You should have received a copy of the GNU General Public License
1068+ * along with this program; if not, write to the Free Software
1069+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
1070+ * USA.
1071+ *
1072+ * Authors:
1073+ * Alberto Mardegan <alberto.mardegan@canonical.com>
1074+ */
1075+
1076+public class FlickrPlugin : Ap.OAuthPlugin {
1077+ public FlickrPlugin (Ag.Account account) {
1078+ Object (account: account);
1079+ }
1080+
1081+ protected override void query_username () {
1082+ var reply = get_oauth_reply ();
1083+ Variant? v_name = reply.lookup_value ("username", null);
1084+ if (v_name != null) {
1085+ account.set_display_name (v_name.get_string ());
1086+ }
1087+
1088+ store_account ();
1089+ }
1090+}
1091+
1092+public GLib.Type ap_module_get_object_type ()
1093+{
1094+ return typeof (FlickrPlugin);
1095+}
1096
1097=== modified file 'src/google.vala'
1098--- src/google.vala 2013-06-06 13:16:51 +0000
1099+++ src/google.vala 2016-06-16 11:50:25 +0000
1100@@ -1,5 +1,5 @@
1101 /*
1102- * Copyright (C) 2012 Canonical, Inc
1103+ * Copyright (C) 2012-2016 Canonical, Inc
1104 *
1105 * This program is free software; you can redistribute it and/or modify
1106 * it under the terms of the GNU General Public License version 2 as
1107@@ -20,6 +20,8 @@
1108 */
1109
1110 public class GooglePlugin : Ap.OAuthPlugin {
1111+ private Soup.Session session;
1112+
1113 public GooglePlugin (Ag.Account account) {
1114 Object (account: account);
1115 }
1116@@ -44,6 +46,43 @@
1117
1118 set_ignore_cookies (true);
1119 }
1120+
1121+ private void fetch_username (string access_token) {
1122+ debug ("fetching username, AT = " + access_token);
1123+ Soup.URI destination_uri =
1124+ new Soup.URI ("https://www.googleapis.com/oauth2/v3/userinfo");
1125+ var message = new Soup.Message.from_uri ("POST", destination_uri);
1126+ message.request_headers.append ("Authorization", "Bearer " + access_token);
1127+ message.request_headers.set_content_length (0);
1128+ session = new Soup.Session ();
1129+ session.queue_message (message, (sess, msg) => {
1130+ debug ("Got message reply");
1131+ string body = (string) msg.response_body.data;
1132+ Json.Parser parser = new Json.Parser ();
1133+ try {
1134+ parser.load_from_data (body);
1135+
1136+ Json.Node root = parser.get_root ();
1137+ Json.Object response_object = root.get_object ();
1138+ var username = response_object.get_string_member ("email");
1139+ account.set_display_name (username);
1140+ } catch (Error error) {
1141+ warning ("Could not parse reply: " + body);
1142+ }
1143+
1144+ store_account ();
1145+ });
1146+ }
1147+
1148+ protected override void query_username () {
1149+ var reply = get_oauth_reply ();
1150+ Variant? v_token = reply.lookup_value ("AccessToken", null);
1151+ if (v_token != null) {
1152+ fetch_username (v_token.get_string ());
1153+ } else {
1154+ store_account ();
1155+ }
1156+ }
1157 }
1158
1159 public GLib.Type ap_module_get_object_type ()
1160
1161=== added file 'src/twitter.vala'
1162--- src/twitter.vala 1970-01-01 00:00:00 +0000
1163+++ src/twitter.vala 2016-06-16 11:50:25 +0000
1164@@ -0,0 +1,46 @@
1165+/*
1166+ * Copyright (C) 2016 Canonical, Inc
1167+ *
1168+ * This program is free software; you can redistribute it and/or modify
1169+ * it under the terms of the GNU General Public License version 2 as
1170+ * published by the Free Software Foundation.
1171+ *
1172+ * This program is distributed in the hope that it will be useful,
1173+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1174+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1175+ * GNU General Public License for more details.
1176+ *
1177+ * You should have received a copy of the GNU General Public License
1178+ * along with this program; if not, write to the Free Software
1179+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
1180+ * USA.
1181+ *
1182+ * Authors:
1183+ * Alberto Mardegan <alberto.mardegan@canonical.com>
1184+ */
1185+
1186+public class TwitterPlugin : Ap.OAuthPlugin {
1187+ public TwitterPlugin (Ag.Account account) {
1188+ Object (account: account);
1189+ }
1190+
1191+ protected override void query_username () {
1192+ var reply = get_oauth_reply ();
1193+ Variant? v_name = reply.lookup_value ("ScreenName", null);
1194+ if (v_name != null) {
1195+ account.set_display_name (v_name.get_string ());
1196+ } else {
1197+ v_name = reply.lookup_value ("UserId", null);
1198+ if (v_name != null) {
1199+ account.set_display_name (v_name.get_string ());
1200+ }
1201+ }
1202+
1203+ store_account ();
1204+ }
1205+}
1206+
1207+public GLib.Type ap_module_get_object_type ()
1208+{
1209+ return typeof (TwitterPlugin);
1210+}

Subscribers

People subscribed via source and target branches

to all changes: