Merge lp:~abreu-alexandre/unity-webapps-qml/14.10-backport-oa-api-requestaccount into lp:unity-webapps-qml/14.10

Proposed by Alexandre Abreu
Status: Needs review
Proposed branch: lp:~abreu-alexandre/unity-webapps-qml/14.10-backport-oa-api-requestaccount
Merge into: lp:unity-webapps-qml/14.10
Diff against target: 318 lines (+164/-10)
10 files modified
debian/control (+2/-1)
examples/api-bindings/online-accounts/www/js/app.js (+11/-1)
src/Ubuntu/UnityWebApps/UnityWebApps.js (+1/-2)
src/Ubuntu/UnityWebApps/UnityWebApps.pro (+3/-1)
src/Ubuntu/UnityWebApps/UnityWebApps.qml (+9/-1)
src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js (+2/-2)
src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts-client.js (+87/-0)
src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js (+2/-0)
src/Ubuntu/UnityWebApps/bindings/online-accounts/client/online-accounts.js (+46/-1)
src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js (+1/-1)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-webapps-qml/14.10-backport-oa-api-requestaccount
Reviewer Review Type Date Requested Status
Alberto Mardegan (community) Approve
Review via email: mp+253057@code.launchpad.net

Commit message

Backport requestAccount() new OA API to 14.10

Description of the change

Backport requestAccount() new OA API to 14.10

To post a comment you must log in.
135. By Alexandre Abreu

fixes

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

Yes, looks familiar :-)

review: Approve

Unmerged revisions

135. By Alexandre Abreu

fixes

134. By Alexandre Abreu

backport requestAccount() for OA API

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-10-14 10:02:49 +0000
+++ debian/control 2015-03-16 20:19:48 +0000
@@ -36,7 +36,8 @@
36 qtdeclarative5-accounts-plugin,36 qtdeclarative5-accounts-plugin,
37 ${misc:Depends},37 ${misc:Depends},
38 ${shlibs:Depends},38 ${shlibs:Depends},
39Suggests: qtdeclarative5-ubuntu-content1,39Suggests: qtdeclarative5-online-accounts-client0.1 (>= 0.3+14.10.20140530),
40 qtdeclarative5-ubuntu-content1,
40 qtdeclarative5-ubuntu-download-manager0.141 qtdeclarative5-ubuntu-download-manager0.1
41Description: Unity Webapps QML component42Description: Unity Webapps QML component
42 Unity Webapps QML is a QML component that binds to a QML WebView and allows43 Unity Webapps QML is a QML component that binds to a QML WebView and allows
4344
=== modified file 'examples/api-bindings/online-accounts/www/js/app.js'
--- examples/api-bindings/online-accounts/www/js/app.js 2014-05-09 13:17:09 +0000
+++ examples/api-bindings/online-accounts/www/js/app.js 2015-03-16 20:19:48 +0000
@@ -4,13 +4,23 @@
4 var api = external.getUnityObject('1.0');4 var api = external.getUnityObject('1.0');
5 var oa = api.OnlineAccounts;5 var oa = api.OnlineAccounts;
66
7 oa.api.getProviders({"applicationId": "webbrowser-app"}, function(providers) {7 var appId = "shotwell";
8
9 oa.api.getProviders({"applicationId": appId}, function(providers) {
8 var ul = document.querySelector('#providers ul');10 var ul = document.querySelector('#providers ul');
911
10 for (var i = 0; i < providers.length; ++i) {12 for (var i = 0; i < providers.length; ++i) {
11 var li = document.createElement('li');13 var li = document.createElement('li');
14 var button = document.createElement('input');
15 button.type = 'button';
16 button.providerId = providers[i].providerId;
17 button.value = 'Request account';
18 button.addEventListener('click', function() {
19 oa.api.requestAccount(appId, this.providerId, function() {});
20 });
12 li.innerHTML = 'displayName: ' + providers[i].displayName21 li.innerHTML = 'displayName: ' + providers[i].displayName
13 + ', providerId: ' + providers[i].providerId;22 + ', providerId: ' + providers[i].providerId;
23 li.appendChild(button);
14 ul.appendChild(li);24 ul.appendChild(li);
15 }25 }
16 });26 });
1727
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.js'
--- src/Ubuntu/UnityWebApps/UnityWebApps.js 2014-07-18 13:43:55 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.js 2015-03-16 20:19:48 +0000
@@ -75,8 +75,7 @@
75 var cb = this._onMessageReceivedCallback.bind(self);75 var cb = this._onMessageReceivedCallback.bind(self);
76 self._bindeeProxies.messageReceivedConnect(cb);76 self._bindeeProxies.messageReceivedConnect(cb);
7777
78 cb = this._onLoadingStartedCallback.bind(self);78 this._onLoadingStartedCallback();
79 self._bindeeProxies.loadingStartedConnect(cb);
80 },79 },
8180
82 /**81 /**
8382
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.pro'
--- src/Ubuntu/UnityWebApps/UnityWebApps.pro 2014-07-11 17:13:18 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.pro 2015-03-16 20:19:48 +0000
@@ -60,7 +60,9 @@
60alarm_binding_backend_js_files.files = ./bindings/alarm-api/backend/alarm-api.js60alarm_binding_backend_js_files.files = ./bindings/alarm-api/backend/alarm-api.js
6161
62online_accounts_binding_backend_js_files.path = $$installPath/bindings/online-accounts/backend/62online_accounts_binding_backend_js_files.path = $$installPath/bindings/online-accounts/backend/
63online_accounts_binding_backend_js_files.files = ./bindings/online-accounts/backend/online-accounts.js63online_accounts_binding_backend_js_files.files = \
64 ./bindings/online-accounts/backend/online-accounts.js \
65 ./bindings/online-accounts/backend/online-accounts-client.js
6466
65runtime_api_binding_backend_js_files.path = $$installPath/bindings/runtime-api/backend/67runtime_api_binding_backend_js_files.path = $$installPath/bindings/runtime-api/backend/
66runtime_api_binding_backend_js_files.files = ./bindings/runtime-api/backend/runtime-api.js68runtime_api_binding_backend_js_files.files = ./bindings/runtime-api/backend/runtime-api.js
6769
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-07-18 21:46:57 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2015-03-16 20:19:48 +0000
@@ -26,6 +26,7 @@
26import "./bindings/alarm-api/backend/alarm-api.js" as AlarmApiBackend26import "./bindings/alarm-api/backend/alarm-api.js" as AlarmApiBackend
27import "./bindings/content-hub/backend/content-hub.js" as ContentHubApiBackend27import "./bindings/content-hub/backend/content-hub.js" as ContentHubApiBackend
28import "./bindings/online-accounts/backend/online-accounts.js" as OnlineAccountsApiBackend28import "./bindings/online-accounts/backend/online-accounts.js" as OnlineAccountsApiBackend
29import "./bindings/online-accounts/backend/online-accounts-client.js" as OnlineAccountsClientApiBackend
29import "./bindings/download-manager/backend/download-api.js" as DownloadApiBackend30import "./bindings/download-manager/backend/download-api.js" as DownloadApiBackend
3031
31/*!32/*!
@@ -167,6 +168,7 @@
167 */168 */
168 property string _opt_homepage: ""169 property string _opt_homepage: ""
169170
171 signal userScriptsInjected()
170172
171 Settings {173 Settings {
172 id: settings174 id: settings
@@ -237,6 +239,8 @@
237239
238 if (internal.backends)240 if (internal.backends)
239 internal.instance.setBackends(internal.backends)241 internal.instance.setBackends(internal.backends)
242
243 userScriptsInjected();
240 }244 }
241245
242 /*!246 /*!
@@ -392,7 +396,11 @@
392 \internal396 \internal
393397
394 */398 */
395 onModelChanged: model.modelContentChanged.connect(__setupNamedWebappEnvironment)399 onModelChanged: {
400 if (model) {
401 model.modelContentChanged.connect(__setupNamedWebappEnvironment)
402 }
403 }
396404
397 /*!405 /*!
398 \internal406 \internal
399407
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js'
--- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2014-07-18 13:43:55 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2015-03-16 20:19:48 +0000
@@ -64,7 +64,7 @@
64 this.disposer = disposer;64 this.disposer = disposer;
65 this.makeSignalDisconnecter = makeSignalDisconnecter;65 this.makeSignalDisconnecter = makeSignalDisconnecter;
66 this._userScriptInjected = false;66 this._userScriptInjected = false;
67 this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://UnityWebappsApi";67 this._WEBAPPS_USER_SCRIPT_CONTEXT = "oxide://main-world";
68}68}
69OxideWebviewAdapter.prototype = {69OxideWebviewAdapter.prototype = {
70 injectUserScripts: function(userScriptUrls) {70 injectUserScripts: function(userScriptUrls) {
@@ -82,7 +82,7 @@
82 var scriptEnd = "}";82 var scriptEnd = "}";
83 var statement = scriptStart +83 var statement = scriptStart +
84 '"' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '"' +84 '"' + this._WEBAPPS_USER_SCRIPT_CONTEXT + '"' +
85 '; matchAllFrames: false; url: "' + userScriptUrls[i] + '";' + scriptEnd;85 '; matchAllFrames: false; emulateGreasemonkey: true; url: "' + userScriptUrls[i] + '";' + scriptEnd;
86 context.addUserScript(Qt.createQmlObject(statement, this.webview));86 context.addUserScript(Qt.createQmlObject(statement, this.webview));
87 }87 }
88 this._userScriptInjected = true;88 this._userScriptInjected = true;
8989
=== added file 'src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts-client.js'
--- src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts-client.js 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts-client.js 2015-03-16 20:19:48 +0000
@@ -0,0 +1,87 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This file is part of unity-webapps-qml.
5 *
6 * unity-webapps-qml is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * unity-webapps-qml is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 *
21 * Online Accounts client API backend binding
22 *
23 */
24function createOnlineAccountsClientApi(backendDelegate) {
25 var PLUGIN_URI = 'Ubuntu.OnlineAccounts.Client';
26 var VERSION = 0.1;
27
28 function Setup(params) {
29 var result = backendDelegate.createQmlObject(
30 PLUGIN_URI, VERSION, 'Setup', params);
31 this._id = result.id;
32 this._object = result.object;
33 };
34 Setup.prototype = {
35 _validate: function() {
36 if (! this._object)
37 throw new TypeError("Invalid object null");
38 },
39
40 destroy: function() {
41 if (! this._object)
42 return;
43 this._object.destroy();
44 backendDelegate.deleteId(this._id);
45 },
46
47 // object methods
48 serialize: function() {
49 this._validate();
50 return {
51 type: 'object-proxy',
52 apiid: 'OnlineAccounts.Client',
53 objecttype: 'Setup',
54 objectid: this._id,
55 }
56 },
57
58 // methods
59 exec: function(callback) {
60 this._validate();
61
62 var self = this;
63
64 var onFinished = function() {
65 self._object.onFinished.disconnect(onFinished);
66 callback();
67 }
68
69 this._object.onFinished.connect(onFinished);
70 this._object.exec();
71 }
72 };
73
74 return {
75 requestAccount: function(applicationId, providerId, callback) {
76 var setup = new Setup({
77 'applicationId': applicationId,
78 'providerId': providerId,
79 });
80 var onFinished = function() {
81 setup.destroy();
82 callback();
83 };
84 setup.exec(onFinished);
85 },
86 };
87}
088
=== modified file 'src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js'
--- src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js 2014-05-22 08:54:56 +0000
+++ src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js 2015-03-16 20:19:48 +0000
@@ -673,6 +673,8 @@
673 }673 }
674 },674 },
675675
676 Client: OnlineAccountsClientApiBackend.createOnlineAccountsClientApi(backendDelegate),
677
676 // Internal678 // Internal
677679
678 dispatchToObject: function(infos) {680 dispatchToObject: function(infos) {
679681
=== modified file 'src/Ubuntu/UnityWebApps/bindings/online-accounts/client/online-accounts.js'
--- src/Ubuntu/UnityWebApps/bindings/online-accounts/client/online-accounts.js 2014-05-09 13:17:09 +0000
+++ src/Ubuntu/UnityWebApps/bindings/online-accounts/client/online-accounts.js 2015-03-16 20:19:48 +0000
@@ -161,7 +161,7 @@
161 *161 *
162 * @method api.getAccounts162 * @method api.getAccounts
163 * @param filters {Object} A dictionary of parameters to filter the result. The filtering keys are:163 * @param filters {Object} A dictionary of parameters to filter the result. The filtering keys are:
164 * - application: the ID of a application (see /usr/share/accounts/applications/ or ~/.local/share/accounts/applications/ for a list of the available applications)164 * - applicationId: the ID of a application (see /usr/share/accounts/applications/ or ~/.local/share/accounts/applications/ for a list of the available applications)
165 * - provider: the ID of a provider (see /usr/share/accounts/providers/ or ~/.local/share/accounts/providers/ for a list of the available providers)165 * - provider: the ID of a provider (see /usr/share/accounts/providers/ or ~/.local/share/accounts/providers/ for a list of the available providers)
166 * - service: the ID of a service (see /usr/share/accounts/services/ or ~/.local/share/accounts/services/ for a list of the available services)166 * - service: the ID of a service (see /usr/share/accounts/services/ or ~/.local/share/accounts/services/ for a list of the available services)
167 *167 *
@@ -215,6 +215,51 @@
215 , [filters]215 , [filters]
216 , callback);216 , callback);
217 },217 },
218 /**
219 * Requests access to an account.
220 *
221 * Applications must invoke this method in order to obtain access
222 * to an account. The user will be prompted to grant access to
223 * either an existing account, to create a new one or to decline
224 * the request.
225 *
226 * @method api.requestAccount
227 * @param applicationId {String} The ID of the application
228 * requesting the account (see /usr/share/accounts/applications/ or
229 * ~/.local/share/accounts/applications/ for a list of the
230 * available applications)
231 * @param providerId {String} The ID of the provider of the desired
232 * account (see /usr/share/accounts/providers/ or
233 * ~/.local/share/accounts/providers/ for a list of the available
234 * providers)
235 * @param callback {Function()} Callback which will be invoked
236 * after the access request has been decided (either with the
237 * access to an account being granted, or with a refusal).
238 *
239 * @example
240 var api = external.getUnityObject(1.0);
241 var oa = api.OnlineAccounts;
242
243 var appId = 'com.ubuntu.developer.me.MyPackage_MyApp';
244 oa.api.requestAccount(appId,
245 'facebook',
246 function() {
247 oa.api.getAccounts({ 'application': appId }, function(result) {
248 for (var i = 0; i < result.length; ++i) {
249 console.log("name: " + result[i].displayName()
250 + ', id: ' + result[i].accountId()
251 + ', providerName: ' + result[i].provider().displayName
252 + ', enabled: ' + (result[i].enabled() ? "true" : "false")
253 );
254 }
255 });
256 });
257 */
258 requestAccount: function(applicationId, providerId, callback) {
259 backendBridge.call('OnlineAccounts.Client.requestAccount',
260 [ applicationId, providerId],
261 callback);
262 },
218 },263 },
219264
220265
221266
=== modified file 'src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js'
--- src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js 2014-03-28 13:21:47 +0000
+++ src/Ubuntu/UnityWebApps/common/js/unity-backend-messaging-proxy.js 2015-03-16 20:19:48 +0000
@@ -4,7 +4,7 @@
4 navigator.qt.postMessage) {4 navigator.qt.postMessage) {
5 return new UnityQtWebkitBackendMessagingProxy();5 return new UnityQtWebkitBackendMessagingProxy();
6 }6 }
7 else if (window.oxide) {7 else if (oxide) {
8 return new UnityOxideBackendMessagingProxy();8 return new UnityOxideBackendMessagingProxy();
9 }9 }
10 return null;10 return null;

Subscribers

People subscribed via source and target branches

to all changes: