Merge lp:~abreu-alexandre/unity-webapps-qml/content-hub-share into lp:unity-webapps-qml
- content-hub-share
- Merge into trunk
Proposed by
Alexandre Abreu
Status: | Work in progress |
---|---|
Proposed branch: | lp:~abreu-alexandre/unity-webapps-qml/content-hub-share |
Merge into: | lp:unity-webapps-qml |
Diff against target: |
965 lines (+763/-9) 20 files modified
examples/facebook-share/bla.qml (+13/-0) examples/facebook-share/content-hub/content-hub-exporter.json (+5/-0) examples/facebook-share/facebook-webapp.service (+6/-0) examples/facebook-share/manifest.json (+19/-0) examples/facebook-share/unity-webapps-facebook/HubSharer.qml (+80/-0) examples/facebook-share/unity-webapps-facebook/Share.qml (+303/-0) examples/facebook-share/unity-webapps-facebook/facebook.user.js (+72/-0) examples/facebook-share/unity-webapps-facebook/manifest.json (+7/-0) examples/facebook-share/unity-webapps-facebook/uploader.html (+15/-0) examples/facebook-share/unity-webapps-facebook/uploader.js (+34/-0) examples/facebook-share/webapp-facebook.application (+11/-0) examples/facebook-share/webapp-facebook.desktop (+9/-0) examples/facebook-share/webapp-facebook.json (+13/-0) src/Ubuntu/UnityWebApps/UnityWebApps.qml (+76/-6) src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js (+15/-1) src/Ubuntu/UnityWebApps/bindings/content-hub/client/content-hub.js (+52/-0) src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js (+1/-1) src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp (+19/-0) src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h (+7/-1) src/Ubuntu/UnityWebApps/unity-webapps-api.js.in (+6/-0) |
To merge this branch: | bzr merge lp:~abreu-alexandre/unity-webapps-qml/content-hub-share |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
WebApps | Pending | ||
Review via email: mp+222640@code.launchpad.net |
Commit message
Add share cpability
Description of the change
Add share cpability
To post a comment you must log in.
Unmerged revisions
- 122. By Alexandre Abreu
-
expand
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'examples/facebook-share' | |||
2 | === added file 'examples/facebook-share/bla.qml' | |||
3 | --- examples/facebook-share/bla.qml 1970-01-01 00:00:00 +0000 | |||
4 | +++ examples/facebook-share/bla.qml 2014-06-10 12:45:47 +0000 | |||
5 | @@ -0,0 +1,13 @@ | |||
6 | 1 | import QtQuick 2.0; | ||
7 | 2 | |||
8 | 3 | //import "/home/ken/work/phablet/content-hub/14.10/content-hub-share/examples/facebook-share/unity-webapps-facebook" as Sharer | ||
9 | 4 | import "unity-webapps-facebook" as Sharer | ||
10 | 5 | |||
11 | 6 | Sharer.HubSharer { | ||
12 | 7 | width: 800 | ||
13 | 8 | height: 500 | ||
14 | 9 | |||
15 | 10 | fileToShare: 'file:///home/ken/.cache/com.ubuntu.developer.webapps.webapp-facebook/HubIncoming/14/ubuntu-varsity-red-1920x1200.png'; | ||
16 | 11 | visible: true; | ||
17 | 12 | } | ||
18 | 13 | |||
19 | 0 | 14 | ||
20 | === added directory 'examples/facebook-share/content-hub' | |||
21 | === added file 'examples/facebook-share/content-hub/content-hub-exporter.json' | |||
22 | --- examples/facebook-share/content-hub/content-hub-exporter.json 1970-01-01 00:00:00 +0000 | |||
23 | +++ examples/facebook-share/content-hub/content-hub-exporter.json 2014-06-10 12:45:47 +0000 | |||
24 | @@ -0,0 +1,5 @@ | |||
25 | 1 | { | ||
26 | 2 | "source": [ | ||
27 | 3 | "pictures" | ||
28 | 4 | ] | ||
29 | 5 | } | ||
30 | 0 | 6 | ||
31 | === added file 'examples/facebook-share/facebook-webapp.service' | |||
32 | --- examples/facebook-share/facebook-webapp.service 1970-01-01 00:00:00 +0000 | |||
33 | +++ examples/facebook-share/facebook-webapp.service 2014-06-10 12:45:47 +0000 | |||
34 | @@ -0,0 +1,6 @@ | |||
35 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
36 | 2 | <service id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook"> | ||
37 | 3 | <type>webapps</type> | ||
38 | 4 | <name>Facebook Webapp</name> | ||
39 | 5 | <provider>facebook</provider> | ||
40 | 6 | </service> | ||
41 | 0 | 7 | ||
42 | === added file 'examples/facebook-share/facebook.png' | |||
43 | 1 | Binary files examples/facebook-share/facebook.png 1970-01-01 00:00:00 +0000 and examples/facebook-share/facebook.png 2014-06-10 12:45:47 +0000 differ | 8 | Binary files examples/facebook-share/facebook.png 1970-01-01 00:00:00 +0000 and examples/facebook-share/facebook.png 2014-06-10 12:45:47 +0000 differ |
44 | === added file 'examples/facebook-share/manifest.json' | |||
45 | --- examples/facebook-share/manifest.json 1970-01-01 00:00:00 +0000 | |||
46 | +++ examples/facebook-share/manifest.json 2014-06-10 12:45:47 +0000 | |||
47 | @@ -0,0 +1,19 @@ | |||
48 | 1 | { | ||
49 | 2 | "description": "Facebook (webapp version)", | ||
50 | 3 | "framework": "ubuntu-sdk-14.04-dev1", | ||
51 | 4 | "architecture": "all", | ||
52 | 5 | "hooks": { | ||
53 | 6 | "webapp-facebook": { | ||
54 | 7 | "account-application": "webapp-facebook.application", | ||
55 | 8 | "content-hub": "content-hub/content-hub-exporter.json", | ||
56 | 9 | "account-service": "facebook-webapp.service", | ||
57 | 10 | "apparmor": "webapp-facebook.json", | ||
58 | 11 | "desktop": "webapp-facebook.desktop" | ||
59 | 12 | } | ||
60 | 13 | }, | ||
61 | 14 | "maintainer": "Webapps Team <webapps@lists.launchpad.net>", | ||
62 | 15 | "name": "com.ubuntu.developer.webapps.webapp-facebook", | ||
63 | 16 | "title": "webapp-facebook", | ||
64 | 17 | "version": "1.0.13" | ||
65 | 18 | } | ||
66 | 19 | |||
67 | 0 | 20 | ||
68 | === added directory 'examples/facebook-share/unity-webapps-facebook' | |||
69 | === added file 'examples/facebook-share/unity-webapps-facebook/HubSharer.qml' | |||
70 | --- examples/facebook-share/unity-webapps-facebook/HubSharer.qml 1970-01-01 00:00:00 +0000 | |||
71 | +++ examples/facebook-share/unity-webapps-facebook/HubSharer.qml 2014-06-10 12:45:47 +0000 | |||
72 | @@ -0,0 +1,80 @@ | |||
73 | 1 | import QtQuick 2.0 | ||
74 | 2 | import Ubuntu.Components 0.1 | ||
75 | 3 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
76 | 4 | import Ubuntu.Components.Popups 0.1 | ||
77 | 5 | import Ubuntu.Components.Extras.Browser 0.1 | ||
78 | 6 | |||
79 | 7 | |||
80 | 8 | /*! | ||
81 | 9 | \brief MainView with a Label and Button elements. | ||
82 | 10 | */ | ||
83 | 11 | |||
84 | 12 | Item { | ||
85 | 13 | id: main | ||
86 | 14 | // objectName for functional testing purposes (autopilot-qt5) | ||
87 | 15 | //objectName: "mainView" | ||
88 | 16 | |||
89 | 17 | // Note! applicationName needs to match the "name" field of the click manifest | ||
90 | 18 | //applicationName: "com.ubuntu.developer.ken-vandine.hub-sharer" | ||
91 | 19 | |||
92 | 20 | /* | ||
93 | 21 | This property enables the application to change orientation | ||
94 | 22 | when the device is rotated. The default is false. | ||
95 | 23 | */ | ||
96 | 24 | //automaticOrientation: true | ||
97 | 25 | |||
98 | 26 | width: parent.width | ||
99 | 27 | height: parent.height | ||
100 | 28 | anchors.fill: parent | ||
101 | 29 | |||
102 | 30 | signal completed(string result) | ||
103 | 31 | |||
104 | 32 | property string fileToShare: "/home/ken/Pictures/Ubuntu_TV.png" | ||
105 | 33 | |||
106 | 34 | function _callback(accessToken, fileToShare, message, cb) { | ||
107 | 35 | print ("_callback: " + accessToken); | ||
108 | 36 | print ("_callback: " + fileToShare); | ||
109 | 37 | print ("_callback: " + message); | ||
110 | 38 | webview.experimental.postMessage(JSON.stringify({file: fileToShare, token: accessToken})); | ||
111 | 39 | } | ||
112 | 40 | |||
113 | 41 | UbuntuWebView { | ||
114 | 42 | id: webview | ||
115 | 43 | |||
116 | 44 | url: Qt.resolvedUrl("uploader.html") | ||
117 | 45 | |||
118 | 46 | experimental.onMessageReceived: { | ||
119 | 47 | completed("[]"); | ||
120 | 48 | } | ||
121 | 49 | |||
122 | 50 | experimental.preferences.offlineWebApplicationCacheEnabled: true | ||
123 | 51 | experimental.preferences.universalAccessFromFileURLsAllowed: true | ||
124 | 52 | experimental.preferences.navigatorQtObjectEnabled: true | ||
125 | 53 | |||
126 | 54 | // port in QTWEBKIT_INSPECTOR_SERVER enviroment variable | ||
127 | 55 | experimental.preferences.developerExtrasEnabled: true | ||
128 | 56 | } | ||
129 | 57 | |||
130 | 58 | //PageStack { | ||
131 | 59 | // id: pageStack | ||
132 | 60 | // Component.onCompleted: push(sharePage) | ||
133 | 61 | |||
134 | 62 | //Page { | ||
135 | 63 | // id: sharePage | ||
136 | 64 | // anchors.fill: parent | ||
137 | 65 | // visible: true | ||
138 | 66 | // title: i18n.tr("Hub Share") | ||
139 | 67 | |||
140 | 68 | Share { | ||
141 | 69 | anchors.fill: parent | ||
142 | 70 | visible: true | ||
143 | 71 | fileToShare: main.fileToShare | ||
144 | 72 | callback: _callback | ||
145 | 73 | provider: "facebook" | ||
146 | 74 | onCanceled: print ("canceled") | ||
147 | 75 | onUploadCompleted: print (success) | ||
148 | 76 | Component.onCompleted: print ("Page completed " + height + " : " + width) | ||
149 | 77 | } | ||
150 | 78 | //} | ||
151 | 79 | //} | ||
152 | 80 | } | ||
153 | 0 | 81 | ||
154 | === added file 'examples/facebook-share/unity-webapps-facebook/Share.qml' | |||
155 | --- examples/facebook-share/unity-webapps-facebook/Share.qml 1970-01-01 00:00:00 +0000 | |||
156 | +++ examples/facebook-share/unity-webapps-facebook/Share.qml 2014-06-10 12:45:47 +0000 | |||
157 | @@ -0,0 +1,303 @@ | |||
158 | 1 | /* | ||
159 | 2 | * Copyright (C) 2012-2013 Canonical, Ltd. | ||
160 | 3 | * | ||
161 | 4 | * This program is free software; you can redistribute it and/or modify | ||
162 | 5 | * it under the terms of the GNU General Public License as published by | ||
163 | 6 | * the Free Software Foundation; version 3. | ||
164 | 7 | * | ||
165 | 8 | * This program is distributed in the hope that it will be useful, | ||
166 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
167 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
168 | 11 | * GNU General Public License for more details. | ||
169 | 12 | * | ||
170 | 13 | * You should have received a copy of the GNU General Public License | ||
171 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
172 | 15 | */ | ||
173 | 16 | |||
174 | 17 | import QtQuick 2.0 | ||
175 | 18 | import QtQuick.Window 2.0 | ||
176 | 19 | import Ubuntu.Components 0.1 | ||
177 | 20 | import Ubuntu.Components.ListItems 0.1 as ListItem | ||
178 | 21 | import Ubuntu.OnlineAccounts 0.1 | ||
179 | 22 | |||
180 | 23 | Rectangle { | ||
181 | 24 | id: root | ||
182 | 25 | anchors.fill: parent | ||
183 | 26 | color: Theme.palette.normal.background | ||
184 | 27 | property string fileToShare | ||
185 | 28 | property var callback | ||
186 | 29 | property string serviceType: "sharing" | ||
187 | 30 | property string provider: "facebook" | ||
188 | 31 | property string userAccountId | ||
189 | 32 | property string accessToken | ||
190 | 33 | property var account | ||
191 | 34 | signal accountSelected | ||
192 | 35 | signal canceled() | ||
193 | 36 | signal uploadCompleted(bool success) | ||
194 | 37 | |||
195 | 38 | onUploadCompleted: { | ||
196 | 39 | activitySpinner.visible = false; | ||
197 | 40 | if (success) | ||
198 | 41 | print ("Successfully posted"); | ||
199 | 42 | else | ||
200 | 43 | print ("Failed to post"); | ||
201 | 44 | } | ||
202 | 45 | |||
203 | 46 | Component.onCompleted: print ("Root completed " + height + " : " + width) | ||
204 | 47 | |||
205 | 48 | AccountServiceModel { | ||
206 | 49 | id: accounts | ||
207 | 50 | serviceType: root.serviceType | ||
208 | 51 | provider: root.provider | ||
209 | 52 | } | ||
210 | 53 | |||
211 | 54 | Rectangle { | ||
212 | 55 | id: shareComponent | ||
213 | 56 | objectName: "shareComponent" | ||
214 | 57 | anchors.fill: parent | ||
215 | 58 | color: Theme.palette.normal.background | ||
216 | 59 | visible: false | ||
217 | 60 | |||
218 | 61 | Component.onCompleted: print ("shareComponent completed " + height + " : " + width) | ||
219 | 62 | |||
220 | 63 | Column { | ||
221 | 64 | anchors.fill: parent | ||
222 | 65 | spacing: units.gu(1) | ||
223 | 66 | |||
224 | 67 | Item { | ||
225 | 68 | id: serviceHeader | ||
226 | 69 | y: 0 | ||
227 | 70 | anchors.left: parent.left | ||
228 | 71 | anchors.right: parent.right | ||
229 | 72 | anchors.topMargin: units.gu(1) | ||
230 | 73 | anchors.leftMargin: units.gu(1) | ||
231 | 74 | anchors.rightMargin: units.gu(1) | ||
232 | 75 | height: childrenRect.height | ||
233 | 76 | |||
234 | 77 | ListItem.Subtitled { | ||
235 | 78 | anchors { | ||
236 | 79 | left: parent.left | ||
237 | 80 | right: parent.right | ||
238 | 81 | } | ||
239 | 82 | iconName: root.account.provider.iconName | ||
240 | 83 | text: root.account.provider.displayName | ||
241 | 84 | subText: root.account.displayName | ||
242 | 85 | showDivider: false | ||
243 | 86 | } | ||
244 | 87 | } | ||
245 | 88 | |||
246 | 89 | ListItem.ThinDivider {} | ||
247 | 90 | |||
248 | 91 | UbuntuShape { | ||
249 | 92 | id: messageArea | ||
250 | 93 | objectName: "messageArea" | ||
251 | 94 | anchors.left: parent.left | ||
252 | 95 | anchors.right: parent.right | ||
253 | 96 | anchors.topMargin: units.gu(1) | ||
254 | 97 | anchors.leftMargin: units.gu(1) | ||
255 | 98 | anchors.rightMargin: units.gu(1) | ||
256 | 99 | |||
257 | 100 | height: units.gu(20) | ||
258 | 101 | color: "#f2f2f2" | ||
259 | 102 | |||
260 | 103 | TextEdit { | ||
261 | 104 | id: message | ||
262 | 105 | color: "#333333" | ||
263 | 106 | anchors.top: parent.top | ||
264 | 107 | anchors.left: snapshot.right | ||
265 | 108 | anchors.bottom: parent.bottom | ||
266 | 109 | anchors.margins: units.gu(1) | ||
267 | 110 | wrapMode: Text.Wrap | ||
268 | 111 | width: parent.width - snapshot.width - | ||
269 | 112 | snapshot.anchors.margins * 2 - | ||
270 | 113 | message.anchors.leftMargin - message.anchors.rightMargin | ||
271 | 114 | clip: true | ||
272 | 115 | font.pixelSize: FontUtils.sizeToPixels("medium") | ||
273 | 116 | font.weight: Font.Light | ||
274 | 117 | focus: true | ||
275 | 118 | } | ||
276 | 119 | |||
277 | 120 | ActivityIndicator { | ||
278 | 121 | id: activitySpinner | ||
279 | 122 | anchors.centerIn: message | ||
280 | 123 | visible: false | ||
281 | 124 | running: visible | ||
282 | 125 | } | ||
283 | 126 | |||
284 | 127 | UbuntuShape { | ||
285 | 128 | id: snapshot | ||
286 | 129 | anchors.top: parent.top | ||
287 | 130 | anchors.left: parent.left | ||
288 | 131 | anchors.margins: units.gu(1) | ||
289 | 132 | width: units.gu(10) | ||
290 | 133 | height: units.gu(10) | ||
291 | 134 | |||
292 | 135 | image: Image { | ||
293 | 136 | source: fileToShare | ||
294 | 137 | sourceSize.height: snapshot.height | ||
295 | 138 | sourceSize.width: snapshot.width | ||
296 | 139 | fillMode: Image.PreserveAspectCrop | ||
297 | 140 | } | ||
298 | 141 | } | ||
299 | 142 | } | ||
300 | 143 | |||
301 | 144 | Item { | ||
302 | 145 | id: actionsBar | ||
303 | 146 | anchors.left: parent.left | ||
304 | 147 | anchors.right: parent.right | ||
305 | 148 | anchors.topMargin: units.gu(2) | ||
306 | 149 | anchors.leftMargin: units.gu(1) | ||
307 | 150 | anchors.rightMargin: units.gu(1) | ||
308 | 151 | height: childrenRect.height | ||
309 | 152 | |||
310 | 153 | Button { | ||
311 | 154 | objectName: "cancelButton" | ||
312 | 155 | anchors.left: parent.left | ||
313 | 156 | text: i18n.dtr("ubuntu-ui-extras", "Cancel") | ||
314 | 157 | color: "#cccccc" | ||
315 | 158 | width: units.gu(10) | ||
316 | 159 | height: units.gu(4) | ||
317 | 160 | onClicked: canceled() | ||
318 | 161 | } | ||
319 | 162 | |||
320 | 163 | Button { | ||
321 | 164 | objectName: "postButton" | ||
322 | 165 | anchors.right: parent.right | ||
323 | 166 | anchors.top: parent.top | ||
324 | 167 | text: i18n.dtr("ubuntu-ui-extras", "Post") | ||
325 | 168 | color: "#dd4814" | ||
326 | 169 | width: units.gu(10) | ||
327 | 170 | height: units.gu(4) | ||
328 | 171 | enabled: !activitySpinner.visible | ||
329 | 172 | onClicked: { | ||
330 | 173 | activitySpinner.visible = true; | ||
331 | 174 | callback(accessToken, fileToShare, message.text, uploadCompleted); | ||
332 | 175 | } | ||
333 | 176 | } | ||
334 | 177 | } | ||
335 | 178 | |||
336 | 179 | UbuntuShape { | ||
337 | 180 | id: useLocation | ||
338 | 181 | anchors { | ||
339 | 182 | left: parent.left | ||
340 | 183 | leftMargin: units.gu(1) | ||
341 | 184 | topMargin: units.gu(1) | ||
342 | 185 | } | ||
343 | 186 | color: selected ? "#cccccc" : "transparent" | ||
344 | 187 | property bool selected: false | ||
345 | 188 | width: units.gu(4.5) | ||
346 | 189 | height: units.gu(4) | ||
347 | 190 | |||
348 | 191 | AbstractButton { | ||
349 | 192 | anchors.fill: parent | ||
350 | 193 | onClicked: parent.selected = !parent.selected | ||
351 | 194 | Image { | ||
352 | 195 | source: "assets/icon_location.png" | ||
353 | 196 | anchors.centerIn: parent | ||
354 | 197 | height: parent.height * 0.75 | ||
355 | 198 | fillMode: Image.PreserveAspectFit | ||
356 | 199 | smooth: true | ||
357 | 200 | } | ||
358 | 201 | } | ||
359 | 202 | } | ||
360 | 203 | |||
361 | 204 | Label { | ||
362 | 205 | anchors.left: useLocation.right | ||
363 | 206 | anchors.baseline: useLocation.top | ||
364 | 207 | anchors.baselineOffset: units.gu(3) | ||
365 | 208 | anchors.leftMargin: units.gu(1) | ||
366 | 209 | text: i18n.dtr("ubuntu-ui-extras", "Include location") | ||
367 | 210 | fontSize: "small" | ||
368 | 211 | } | ||
369 | 212 | |||
370 | 213 | } | ||
371 | 214 | |||
372 | 215 | states: [ | ||
373 | 216 | State { | ||
374 | 217 | name: "landscape-with-keyborad" | ||
375 | 218 | PropertyChanges { | ||
376 | 219 | target: serviceHeader | ||
377 | 220 | y: - serviceHeader.height | ||
378 | 221 | } | ||
379 | 222 | PropertyChanges { | ||
380 | 223 | target: messageArea | ||
381 | 224 | height: units.gu(12) | ||
382 | 225 | } | ||
383 | 226 | } | ||
384 | 227 | ] | ||
385 | 228 | |||
386 | 229 | state: ((Screen.orientation === Qt.LandscapeOrientation) || | ||
387 | 230 | (Screen.orientation === Qt.InvertedLandscapeOrientation)) && | ||
388 | 231 | Qt.inputMethod.visible ? "landscape-with-keyborad" : "" | ||
389 | 232 | } | ||
390 | 233 | |||
391 | 234 | /* Menu listing online accounts */ | ||
392 | 235 | Item { | ||
393 | 236 | id: sharemenu | ||
394 | 237 | anchors.fill: parent | ||
395 | 238 | visible: true | ||
396 | 239 | |||
397 | 240 | signal selected(string accountId, string token) | ||
398 | 241 | |||
399 | 242 | Component.onCompleted: { | ||
400 | 243 | visible = true; | ||
401 | 244 | print ("sharemenu completed " + height + " : " + width); | ||
402 | 245 | } | ||
403 | 246 | onSelected: { | ||
404 | 247 | root.userAccountId = accountId; | ||
405 | 248 | root.accessToken = token; | ||
406 | 249 | shareComponent.visible = true; | ||
407 | 250 | sharemenu.visible = false; | ||
408 | 251 | } | ||
409 | 252 | |||
410 | 253 | Component { | ||
411 | 254 | id: acctDelegate | ||
412 | 255 | Item { | ||
413 | 256 | anchors { | ||
414 | 257 | left: parent.left | ||
415 | 258 | right: parent.right | ||
416 | 259 | } | ||
417 | 260 | AccountService { | ||
418 | 261 | id: service | ||
419 | 262 | objectHandle: accountServiceHandle | ||
420 | 263 | onAuthenticated: { | ||
421 | 264 | sharemenu.selected(accountId, reply.AccessToken); | ||
422 | 265 | } | ||
423 | 266 | } | ||
424 | 267 | |||
425 | 268 | height: childrenRect.height | ||
426 | 269 | |||
427 | 270 | ListItem.Subtitled { | ||
428 | 271 | anchors { | ||
429 | 272 | left: parent.left | ||
430 | 273 | right: parent.right | ||
431 | 274 | } | ||
432 | 275 | text: service.provider.displayName | ||
433 | 276 | subText: displayName | ||
434 | 277 | iconName: service.provider.iconName | ||
435 | 278 | __iconHeight: units.gu(5) | ||
436 | 279 | __iconWidth: units.gu(5) | ||
437 | 280 | |||
438 | 281 | onClicked: { | ||
439 | 282 | root.account = service; | ||
440 | 283 | root.account.authenticate(null); | ||
441 | 284 | } | ||
442 | 285 | Component.onCompleted: print ("KEN: " + service.provider.displayName + " height: " + height + " y: " + y + " visible: " + visible) | ||
443 | 286 | } | ||
444 | 287 | } | ||
445 | 288 | } | ||
446 | 289 | |||
447 | 290 | ListView { | ||
448 | 291 | anchors { | ||
449 | 292 | top: parent.top | ||
450 | 293 | left: parent.left | ||
451 | 294 | right: parent.right | ||
452 | 295 | } | ||
453 | 296 | height: childrenRect.height | ||
454 | 297 | interactive: false | ||
455 | 298 | model: accounts | ||
456 | 299 | delegate: acctDelegate | ||
457 | 300 | Component.onCompleted: print ("listview completed " + height + " : " + width) | ||
458 | 301 | } | ||
459 | 302 | } | ||
460 | 303 | } | ||
461 | 0 | 304 | ||
462 | === added file 'examples/facebook-share/unity-webapps-facebook/facebook.user.js' | |||
463 | --- examples/facebook-share/unity-webapps-facebook/facebook.user.js 1970-01-01 00:00:00 +0000 | |||
464 | +++ examples/facebook-share/unity-webapps-facebook/facebook.user.js 2014-06-10 12:45:47 +0000 | |||
465 | @@ -0,0 +1,72 @@ | |||
466 | 1 | var api = external.getUnityObject('1.0'); | ||
467 | 2 | |||
468 | 3 | var oa = api.OnlineAccounts; | ||
469 | 4 | var hub = api.ContentHub; | ||
470 | 5 | |||
471 | 6 | function _shareRequested(transfer) { | ||
472 | 7 | transfer.items(function(items) { | ||
473 | 8 | api.launchEmbeddedUI("HubSharer", upload, {"fileToShare": items[0]}); | ||
474 | 9 | }); | ||
475 | 10 | }; | ||
476 | 11 | hub.onShareRequested(_shareRequested); | ||
477 | 12 | |||
478 | 13 | function upload(res) { | ||
479 | 14 | var results = JSON.parse(res); | ||
480 | 15 | //console.log (results); | ||
481 | 16 | console.log (results.accessToken); | ||
482 | 17 | var xhr = new XMLHttpRequest(); | ||
483 | 18 | xhr.open( 'POST', 'https://graph.facebook.com/me/photos?access_token=' + results.accessToken, true ); | ||
484 | 19 | xhr.onload = xhr.onerror = function() { | ||
485 | 20 | console.log( xhr.responseText ); | ||
486 | 21 | }; | ||
487 | 22 | |||
488 | 23 | //var xhrr = new XMLHttpRequest(); | ||
489 | 24 | //var re = /file:\/\//gi; | ||
490 | 25 | //var file = results.fileToShare.replace(re, ''); | ||
491 | 26 | //console.log ("FILE: " + results.fileToShare); | ||
492 | 27 | console.log('file to share lenght: ' + [].slice.call(results.fileToShare).length) | ||
493 | 28 | |||
494 | 29 | console.log(results.fileToShare) | ||
495 | 30 | |||
496 | 31 | console.log("After atob: " + atob(results.fileToShare)) | ||
497 | 32 | |||
498 | 33 | var bin = atob(results.fileToShare); | ||
499 | 34 | var a = new Uint8Array(results.contentlength); | ||
500 | 35 | |||
501 | 36 | console.log('results.length: ' + results.size) | ||
502 | 37 | |||
503 | 38 | for (var i = 0; i < results.size; ++i) { | ||
504 | 39 | a[i] = bin.charCodeAt(i); | ||
505 | 40 | } | ||
506 | 41 | |||
507 | 42 | console.log("array buffer content: " + btoa(a.buffer)) | ||
508 | 43 | |||
509 | 44 | var div = document.createElement('div'); | ||
510 | 45 | div.innerHTML = '<form enctype="multipart/form-data" method="post" id="uploadForm"><textarea id="message" name="message"></textarea></form>'; | ||
511 | 46 | document.getElementsByTagName('body')[0].appendChild(div); | ||
512 | 47 | |||
513 | 48 | var blob = new Blob([a], {type: "image/png"}); | ||
514 | 49 | |||
515 | 50 | console.log('blob size: ' + blob.size) | ||
516 | 51 | console.log(blob.type) | ||
517 | 52 | |||
518 | 53 | var uploadForm = document.forms.namedItem("uploadForm"); | ||
519 | 54 | var formData = new FormData(uploadForm); | ||
520 | 55 | formData.append('source', blob); | ||
521 | 56 | xhr.send(formData); | ||
522 | 57 | |||
523 | 58 | /* | ||
524 | 59 | xhrr.open("GET", results.fileToShare, true); | ||
525 | 60 | xhrr.responseType = "blob"; | ||
526 | 61 | xhrr.onload = function (e) { | ||
527 | 62 | var blob = new Blob([xhrr.response], {type: "image/png"}); | ||
528 | 63 | var formData = new FormData(); | ||
529 | 64 | formData.append('source', blob); | ||
530 | 65 | formData.append('message', results.message); | ||
531 | 66 | xhr.send(formData); | ||
532 | 67 | } | ||
533 | 68 | xhrr.send(); | ||
534 | 69 | */ | ||
535 | 70 | } | ||
536 | 71 | |||
537 | 72 | |||
538 | 0 | 73 | ||
539 | === added file 'examples/facebook-share/unity-webapps-facebook/manifest.json' | |||
540 | --- examples/facebook-share/unity-webapps-facebook/manifest.json 1970-01-01 00:00:00 +0000 | |||
541 | +++ examples/facebook-share/unity-webapps-facebook/manifest.json 2014-06-10 12:45:47 +0000 | |||
542 | @@ -0,0 +1,7 @@ | |||
543 | 1 | { | ||
544 | 2 | "name": "facebook", | ||
545 | 3 | "includes": ["https://*.facebook.com/*"], | ||
546 | 4 | "homepage": "https://m.facebook.com/", | ||
547 | 5 | "domain": "facebook.com", | ||
548 | 6 | "scripts": ["facebook.user.js"] | ||
549 | 7 | } | ||
550 | 0 | 8 | ||
551 | === added file 'examples/facebook-share/unity-webapps-facebook/uploader.html' | |||
552 | --- examples/facebook-share/unity-webapps-facebook/uploader.html 1970-01-01 00:00:00 +0000 | |||
553 | +++ examples/facebook-share/unity-webapps-facebook/uploader.html 2014-06-10 12:45:47 +0000 | |||
554 | @@ -0,0 +1,15 @@ | |||
555 | 1 | <html> | ||
556 | 2 | <head> | ||
557 | 3 | <script src="./uploader.js"></script> | ||
558 | 4 | </head> | ||
559 | 5 | <body> | ||
560 | 6 | |||
561 | 7 | <div> | ||
562 | 8 | <form enctype="multipart/form-data" method="post" id="uploadForm"> | ||
563 | 9 | <textarea id="message" name="message" rows="5" style="height: auto; width: 600px;" placeholder="What's on your mind?"> | ||
564 | 10 | </textarea> | ||
565 | 11 | </form> | ||
566 | 12 | </div> | ||
567 | 13 | |||
568 | 14 | <body> | ||
569 | 15 | </html> | ||
570 | 0 | 16 | ||
571 | === added file 'examples/facebook-share/unity-webapps-facebook/uploader.js' | |||
572 | --- examples/facebook-share/unity-webapps-facebook/uploader.js 1970-01-01 00:00:00 +0000 | |||
573 | +++ examples/facebook-share/unity-webapps-facebook/uploader.js 2014-06-10 12:45:47 +0000 | |||
574 | @@ -0,0 +1,34 @@ | |||
575 | 1 | /** | ||
576 | 2 | * Wait before the DOM has been loaded before initializing the Ubuntu UI layer | ||
577 | 3 | */ | ||
578 | 4 | navigator.qt.onmessage = function(message) { | ||
579 | 5 | var data = null; | ||
580 | 6 | try { | ||
581 | 7 | data = JSON.parse(message.data); | ||
582 | 8 | } catch (error) { | ||
583 | 9 | return; | ||
584 | 10 | } | ||
585 | 11 | upload(data.file, data.token); | ||
586 | 12 | } | ||
587 | 13 | |||
588 | 14 | function upload(file, token) { | ||
589 | 15 | // FIXME: we should submit multiples if we can | ||
590 | 16 | var xhr = new XMLHttpRequest(); | ||
591 | 17 | xhr.open( 'POST', 'https://graph.facebook.com/me/photos?access_token=' + token, true ); | ||
592 | 18 | xhr.onload = xhr.onerror = function() { | ||
593 | 19 | navigator.qt.postMessage(JSON.stringify({})); | ||
594 | 20 | }; | ||
595 | 21 | |||
596 | 22 | var xhrr = new XMLHttpRequest(); | ||
597 | 23 | xhrr.open("GET", file, true); | ||
598 | 24 | xhrr.responseType = "blob"; | ||
599 | 25 | xhrr.onload = function (e) { | ||
600 | 26 | var blob = new Blob([xhrr.response], {type: "image/png"}); | ||
601 | 27 | var uploadForm = document.forms.namedItem("uploadForm"); | ||
602 | 28 | var formData = new FormData(uploadForm); | ||
603 | 29 | formData.append('source', blob); | ||
604 | 30 | xhr.send(formData); | ||
605 | 31 | } | ||
606 | 32 | xhrr.send(); | ||
607 | 33 | } | ||
608 | 34 | |||
609 | 0 | 35 | ||
610 | === added file 'examples/facebook-share/webapp-facebook.application' | |||
611 | --- examples/facebook-share/webapp-facebook.application 1970-01-01 00:00:00 +0000 | |||
612 | +++ examples/facebook-share/webapp-facebook.application 2014-06-10 12:45:47 +0000 | |||
613 | @@ -0,0 +1,11 @@ | |||
614 | 1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
615 | 2 | <application id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook"> | ||
616 | 3 | <description>Facebook webapp</description> | ||
617 | 4 | |||
618 | 5 | <services> | ||
619 | 6 | <service id="com.ubuntu.developer.webapps.webapp-facebook_webapp-facebook"> | ||
620 | 7 | <description>Use the service in a webapp</description> | ||
621 | 8 | </service> | ||
622 | 9 | </services> | ||
623 | 10 | |||
624 | 11 | </application> | ||
625 | 0 | 12 | ||
626 | === added file 'examples/facebook-share/webapp-facebook.desktop' | |||
627 | --- examples/facebook-share/webapp-facebook.desktop 1970-01-01 00:00:00 +0000 | |||
628 | +++ examples/facebook-share/webapp-facebook.desktop 2014-06-10 12:45:47 +0000 | |||
629 | @@ -0,0 +1,9 @@ | |||
630 | 1 | [Desktop Entry] | ||
631 | 2 | Type=Application | ||
632 | 3 | Terminal=false | ||
633 | 4 | Exec=webapp-container --enable-back-forward --webappModelSearchPath=. --webappUrlPatterns=https?://*.facebook.com/* | ||
634 | 5 | Name=Facebook | ||
635 | 6 | Icon=./facebook.png | ||
636 | 7 | X-Ubuntu-Touch=true | ||
637 | 8 | X-Ubuntu-StageHint=SideStage | ||
638 | 9 | X-Ubuntu-Single-Instance=true | ||
639 | 0 | 10 | ||
640 | === added file 'examples/facebook-share/webapp-facebook.json' | |||
641 | --- examples/facebook-share/webapp-facebook.json 1970-01-01 00:00:00 +0000 | |||
642 | +++ examples/facebook-share/webapp-facebook.json 2014-06-10 12:45:47 +0000 | |||
643 | @@ -0,0 +1,13 @@ | |||
644 | 1 | { | ||
645 | 2 | "template": "ubuntu-webapp", | ||
646 | 3 | "policy_groups": [ | ||
647 | 4 | "networking", | ||
648 | 5 | "audio", | ||
649 | 6 | "video", | ||
650 | 7 | "webview", | ||
651 | 8 | "location", | ||
652 | 9 | "content_exchange", | ||
653 | 10 | "content_exchange_source" | ||
654 | 11 | ], | ||
655 | 12 | "policy_version": 1.1 | ||
656 | 13 | } | ||
657 | 0 | 14 | ||
658 | === modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml' | |||
659 | --- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-05-16 16:29:35 +0000 | |||
660 | +++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2014-06-10 12:45:47 +0000 | |||
661 | @@ -413,6 +413,27 @@ | |||
662 | 413 | return null; | 413 | return null; |
663 | 414 | } | 414 | } |
664 | 415 | 415 | ||
665 | 416 | /*! | ||
666 | 417 | \internal | ||
667 | 418 | |||
668 | 419 | */ | ||
669 | 420 | function __getPolicyForContent(settings) { | ||
670 | 421 | // TODO: review this | ||
671 | 422 | function PassthroughPolicy() {}; | ||
672 | 423 | PassthroughPolicy.prototype.allowed = function(signature) { | ||
673 | 424 | return true; | ||
674 | 425 | }; | ||
675 | 426 | function RestrictedPolicy(restrictions) { | ||
676 | 427 | this.restrictions = restrictions || []; | ||
677 | 428 | }; | ||
678 | 429 | RestrictedPolicy.prototype.allowed = function(signature) { | ||
679 | 430 | return this.restrictions.some(function(e) { return e == signature; }); | ||
680 | 431 | }; | ||
681 | 432 | |||
682 | 433 | if (injectExtraUbuntuApis) | ||
683 | 434 | return new PassthroughPolicy(); | ||
684 | 435 | return new RestrictedPolicy(["ContentHub.onShareRequested"]) | ||
685 | 436 | } | ||
686 | 416 | 437 | ||
687 | 417 | /*! | 438 | /*! |
688 | 418 | \internal | 439 | \internal |
689 | @@ -524,6 +545,59 @@ | |||
690 | 524 | UnityBackends.get("hud").clearActions(); | 545 | UnityBackends.get("hud").clearActions(); |
691 | 525 | }, | 546 | }, |
692 | 526 | 547 | ||
693 | 548 | launchEmbeddedUI: function(name, callback, params) { | ||
694 | 549 | if ( ! model) { | ||
695 | 550 | print ("No model"); | ||
696 | 551 | return; | ||
697 | 552 | } | ||
698 | 553 | |||
699 | 554 | // TODO validate | ||
700 | 555 | var path = model.path(webapps.name); | ||
701 | 556 | console.debug ("PATH: " + path); | ||
702 | 557 | if (! path || path.length == 0) | ||
703 | 558 | return; | ||
704 | 559 | |||
705 | 560 | var backendDelegate = UnityBackends.backendDelegate; | ||
706 | 561 | |||
707 | 562 | var parentItem = backendDelegate.parentView(); | ||
708 | 563 | if ( ! parentItem || ! parentItem.visible || ! parentItem.height || ! parentItem.width) { | ||
709 | 564 | console.debug("Cannot launch the content peer picker UI, invalid parent item: " + parentItem); | ||
710 | 565 | callback({result: "cancelled"}); | ||
711 | 566 | return; | ||
712 | 567 | } | ||
713 | 568 | |||
714 | 569 | var p = parentItem.parent ? parentItem.parent : parentItem | ||
715 | 570 | |||
716 | 571 | var c; | ||
717 | 572 | function oncreated() { | ||
718 | 573 | //if (p) { | ||
719 | 574 | // p.visible = false; | ||
720 | 575 | //} | ||
721 | 576 | |||
722 | 577 | var ui = c.createObject(p, {"fileToShare": params.fileToShare.url, "visible": true}); | ||
723 | 578 | |||
724 | 579 | if ( ! ui.onCompleted) { | ||
725 | 580 | ui.destroy(); | ||
726 | 581 | return; | ||
727 | 582 | } | ||
728 | 583 | |||
729 | 584 | function _onCompleted(data) { | ||
730 | 585 | ui.visible = false; | ||
731 | 586 | p.visible = true; | ||
732 | 587 | ui.onCompleted.disconnect(_onCompleted); | ||
733 | 588 | ui.destroy(); | ||
734 | 589 | callback(data); | ||
735 | 590 | } | ||
736 | 591 | ui.onCompleted.connect(_onCompleted); | ||
737 | 592 | }; | ||
738 | 593 | |||
739 | 594 | c = Qt.createComponent(path + "/" + name + ".qml"); | ||
740 | 595 | if (c.status == Component.Ready) | ||
741 | 596 | oncreated() | ||
742 | 597 | else | ||
743 | 598 | c.statusChanged.connect(oncreated) | ||
744 | 599 | }, | ||
745 | 600 | |||
746 | 527 | Notification: { | 601 | Notification: { |
747 | 528 | showNotification: function (summary, body, iconUrl) { | 602 | showNotification: function (summary, body, iconUrl) { |
748 | 529 | if (!initialized) | 603 | if (!initialized) |
749 | @@ -641,17 +715,13 @@ | |||
750 | 641 | } | 715 | } |
751 | 642 | }, | 716 | }, |
752 | 643 | 717 | ||
756 | 644 | OnlineAccounts: __injectResourceIfExtraApisAreEnabled(function() { | 718 | OnlineAccounts: OnlineAccountsApiBackend.createOnlineAccountsApi(UnityBackends.backendDelegate), |
754 | 645 | return OnlineAccountsApiBackend.createOnlineAccountsApi(UnityBackends.backendDelegate) | ||
755 | 646 | }), | ||
757 | 647 | 719 | ||
758 | 648 | Alarm: __injectResourceIfExtraApisAreEnabled(function() { | 720 | Alarm: __injectResourceIfExtraApisAreEnabled(function() { |
759 | 649 | return AlarmApiBackend.createAlarmApi(UnityBackends.backendDelegate) | 721 | return AlarmApiBackend.createAlarmApi(UnityBackends.backendDelegate) |
760 | 650 | }), | 722 | }), |
761 | 651 | 723 | ||
765 | 652 | ContentHub: __injectResourceIfExtraApisAreEnabled(function() { | 724 | ContentHub: ContentHubApiBackend.createContentHubApi(UnityBackends.backendDelegate), |
763 | 653 | return ContentHubApiBackend.createContentHubApi(UnityBackends.backendDelegate) | ||
764 | 654 | }), | ||
766 | 655 | 725 | ||
767 | 656 | RuntimeApi: __injectResourceIfExtraApisAreEnabled(function() { | 726 | RuntimeApi: __injectResourceIfExtraApisAreEnabled(function() { |
768 | 657 | return RuntimeApiBackend.createRuntimeApi(UnityBackends.backendDelegate) | 727 | return RuntimeApiBackend.createRuntimeApi(UnityBackends.backendDelegate) |
769 | 658 | 728 | ||
770 | === modified file 'src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js' | |||
771 | --- src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js 2014-05-08 13:01:07 +0000 | |||
772 | +++ src/Ubuntu/UnityWebApps/bindings/content-hub/backend/content-hub.js 2014-06-10 12:45:47 +0000 | |||
773 | @@ -24,7 +24,7 @@ | |||
774 | 24 | * | 24 | * |
775 | 25 | */ | 25 | */ |
776 | 26 | 26 | ||
778 | 27 | function createContentHubApi(backendDelegate) { | 27 | function createContentHubApi(backendDelegate, accessPolicy) { |
779 | 28 | var PLUGIN_URI = 'Ubuntu.Content'; | 28 | var PLUGIN_URI = 'Ubuntu.Content'; |
780 | 29 | var VERSION = 0.1; | 29 | var VERSION = 0.1; |
781 | 30 | 30 | ||
782 | @@ -769,6 +769,20 @@ | |||
783 | 769 | }); | 769 | }); |
784 | 770 | }, | 770 | }, |
785 | 771 | 771 | ||
786 | 772 | onImportRequested: function(callback) { | ||
787 | 773 | _contenthub.onImportRequested.connect(function(importTransfer) { | ||
788 | 774 | var wrapped = new ContentTransfer(importTransfer); | ||
789 | 775 | callback(wrapped.serialize()); | ||
790 | 776 | }); | ||
791 | 777 | }, | ||
792 | 778 | |||
793 | 779 | onShareRequested: function(callback) { | ||
794 | 780 | _contenthub.shareRequested.connect(function(shareTransfer) { | ||
795 | 781 | var wrapped = new ContentTransfer(shareTransfer); | ||
796 | 782 | callback(wrapped.serialize()); | ||
797 | 783 | }); | ||
798 | 784 | }, | ||
799 | 785 | |||
800 | 772 | // Internal | 786 | // Internal |
801 | 773 | 787 | ||
802 | 774 | dispatchToObject: function(infos) { | 788 | dispatchToObject: function(infos) { |
803 | 775 | 789 | ||
804 | === modified file 'src/Ubuntu/UnityWebApps/bindings/content-hub/client/content-hub.js' | |||
805 | --- src/Ubuntu/UnityWebApps/bindings/content-hub/client/content-hub.js 2014-03-18 13:59:36 +0000 | |||
806 | +++ src/Ubuntu/UnityWebApps/bindings/content-hub/client/content-hub.js 2014-06-10 12:45:47 +0000 | |||
807 | @@ -836,6 +836,58 @@ | |||
808 | 836 | [callback]); | 836 | [callback]); |
809 | 837 | }, | 837 | }, |
810 | 838 | 838 | ||
811 | 839 | /** | ||
812 | 840 | * Sets a handler that is to be called when the current application is the | ||
813 | 841 | * target of an share request. | ||
814 | 842 | * | ||
815 | 843 | * @method onExportRequested | ||
816 | 844 | * @param callback {Function(ContentTransfer)} Function when one requests a resource to be shared. | ||
817 | 845 | * The corresponding ContentTransfer is provided as a parameter. | ||
818 | 846 | * | ||
819 | 847 | * @example | ||
820 | 848 | |||
821 | 849 | var api = external.getUnityObject(1.0); | ||
822 | 850 | var hub = api.ContentHub; | ||
823 | 851 | |||
824 | 852 | var transferState = hub.ContentTransfer.State; | ||
825 | 853 | |||
826 | 854 | function _shareRequested(transfer) { | ||
827 | 855 | }; | ||
828 | 856 | |||
829 | 857 | hub.onShareRequested(_shareRequested); | ||
830 | 858 | |||
831 | 859 | */ | ||
832 | 860 | onShareRequested: function(callback) { | ||
833 | 861 | backendBridge.call('ContentHub.onShareRequested', | ||
834 | 862 | [callback]); | ||
835 | 863 | }, | ||
836 | 864 | |||
837 | 865 | /** | ||
838 | 866 | * Sets a handler that is to be called when the current application is the | ||
839 | 867 | * target of an import request. | ||
840 | 868 | * | ||
841 | 869 | * @method onImportRequested | ||
842 | 870 | * @param callback {Function(ContentTransfer)} Function when one requests a resource to be imported. | ||
843 | 871 | * The corresponding ContentTransfer is provided as a parameter. | ||
844 | 872 | * | ||
845 | 873 | * @example | ||
846 | 874 | |||
847 | 875 | var api = external.getUnityObject(1.0); | ||
848 | 876 | var hub = api.ContentHub; | ||
849 | 877 | |||
850 | 878 | var transferState = hub.ContentTransfer.State; | ||
851 | 879 | |||
852 | 880 | function _importRequested(transfer) { | ||
853 | 881 | }; | ||
854 | 882 | |||
855 | 883 | hub.onImportRequested(_importRequested); | ||
856 | 884 | |||
857 | 885 | */ | ||
858 | 886 | onImportRequested: function(callback) { | ||
859 | 887 | backendBridge.call('ContentHub.onImportRequested', | ||
860 | 888 | [callback]); | ||
861 | 889 | }, | ||
862 | 890 | |||
863 | 839 | api: { | 891 | api: { |
864 | 840 | 892 | ||
865 | 841 | /** | 893 | /** |
866 | 842 | 894 | ||
867 | === modified file 'src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js' | |||
868 | --- src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js 2014-05-09 13:17:09 +0000 | |||
869 | +++ src/Ubuntu/UnityWebApps/bindings/online-accounts/backend/online-accounts.js 2014-06-10 12:45:47 +0000 | |||
870 | @@ -21,7 +21,7 @@ | |||
871 | 21 | * Online Accounts API backend binding | 21 | * Online Accounts API backend binding |
872 | 22 | * | 22 | * |
873 | 23 | */ | 23 | */ |
875 | 24 | function createOnlineAccountsApi(backendDelegate) { | 24 | function createOnlineAccountsApi(backendDelegate, accessPolicy) { |
876 | 25 | var PLUGIN_URI = 'Ubuntu.OnlineAccounts'; | 25 | var PLUGIN_URI = 'Ubuntu.OnlineAccounts'; |
877 | 26 | var VERSION = 0.1; | 26 | var VERSION = 0.1; |
878 | 27 | 27 | ||
879 | 28 | 28 | ||
880 | === modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp' | |||
881 | --- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-05-14 01:41:14 +0000 | |||
882 | +++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2014-06-10 12:45:47 +0000 | |||
883 | @@ -156,6 +156,7 @@ | |||
884 | 156 | roles[Scripts] = "scripts"; | 156 | roles[Scripts] = "scripts"; |
885 | 157 | roles[Chrome] = "chrome"; | 157 | roles[Chrome] = "chrome"; |
886 | 158 | roles[UserAgentOverride] = "useragent"; | 158 | roles[UserAgentOverride] = "useragent"; |
887 | 159 | roles[Path] = "path"; | ||
888 | 159 | } | 160 | } |
889 | 160 | return roles; | 161 | return roles; |
890 | 161 | } | 162 | } |
891 | @@ -337,6 +338,21 @@ | |||
892 | 337 | } | 338 | } |
893 | 338 | 339 | ||
894 | 339 | QString | 340 | QString |
895 | 341 | UnityWebappsAppModel::path(const QString & webappName) const { | ||
896 | 342 | if (!exists(webappName)) | ||
897 | 343 | return QString(); | ||
898 | 344 | |||
899 | 345 | int idx = getWebappIndex(webappName); | ||
900 | 346 | if (Q_UNLIKELY(idx == -1)) | ||
901 | 347 | { | ||
902 | 348 | qDebug() << "Invalid index for a supposedly existing webapp: " << webappName; | ||
903 | 349 | return QString(); | ||
904 | 350 | } | ||
905 | 351 | |||
906 | 352 | return data(idx, Path).toString(); | ||
907 | 353 | } | ||
908 | 354 | |||
909 | 355 | QString | ||
910 | 340 | UnityWebappsAppModel::userAgentOverrideFor(const QString & webappName) const | 356 | UnityWebappsAppModel::userAgentOverrideFor(const QString & webappName) const |
911 | 341 | { | 357 | { |
912 | 342 | if (!exists(webappName)) | 358 | if (!exists(webappName)) |
913 | @@ -543,6 +559,9 @@ | |||
914 | 543 | 559 | ||
915 | 544 | case UserAgentOverride: | 560 | case UserAgentOverride: |
916 | 545 | return webapp.data.manifest.userAgentOverride; | 561 | return webapp.data.manifest.userAgentOverride; |
917 | 562 | |||
918 | 563 | case Path: | ||
919 | 564 | return webapp.userscriptLocation; | ||
920 | 546 | } | 565 | } |
921 | 547 | 566 | ||
922 | 548 | return QVariant(); | 567 | return QVariant(); |
923 | 549 | 568 | ||
924 | === modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h' | |||
925 | --- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-05-08 15:20:47 +0000 | |||
926 | +++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2014-06-10 12:45:47 +0000 | |||
927 | @@ -58,7 +58,8 @@ | |||
928 | 58 | Scripts, | 58 | Scripts, |
929 | 59 | ScriptsContent, | 59 | ScriptsContent, |
930 | 60 | Chrome, | 60 | Chrome, |
932 | 61 | UserAgentOverride | 61 | UserAgentOverride, |
933 | 62 | Path | ||
934 | 62 | }; | 63 | }; |
935 | 63 | 64 | ||
936 | 64 | // QAbstractListModel implementation | 65 | // QAbstractListModel implementation |
937 | @@ -108,6 +109,11 @@ | |||
938 | 108 | */ | 109 | */ |
939 | 109 | Q_INVOKABLE QString userAgentOverrideFor(const QString & webappName) const; | 110 | Q_INVOKABLE QString userAgentOverrideFor(const QString & webappName) const; |
940 | 110 | 111 | ||
941 | 112 | /*! | ||
942 | 113 | * \brief | ||
943 | 114 | */ | ||
944 | 115 | Q_INVOKABLE QString path(const QString & webappName) const; | ||
945 | 116 | |||
946 | 111 | 117 | ||
947 | 112 | /*! | 118 | /*! |
948 | 113 | * \brief | 119 | * \brief |
949 | 114 | 120 | ||
950 | === modified file 'src/Ubuntu/UnityWebApps/unity-webapps-api.js.in' | |||
951 | --- src/Ubuntu/UnityWebApps/unity-webapps-api.js.in 2014-05-13 17:48:43 +0000 | |||
952 | +++ src/Ubuntu/UnityWebApps/unity-webapps-api.js.in 2014-06-10 12:45:47 +0000 | |||
953 | @@ -98,6 +98,12 @@ | |||
954 | 98 | clearActions: createArgumentsSanitizer (backend, [], 'clearActions'), | 98 | clearActions: createArgumentsSanitizer (backend, [], 'clearActions'), |
955 | 99 | 99 | ||
956 | 100 | /** | 100 | /** |
957 | 101 | */ | ||
958 | 102 | launchEmbeddedUI: function(name, callback, params) { | ||
959 | 103 | backend.call('launchEmbeddedUI', [name, callback, params]); | ||
960 | 104 | }, | ||
961 | 105 | |||
962 | 106 | /** | ||
963 | 101 | * | 107 | * |
964 | 102 | * MediaPlayer API | 108 | * MediaPlayer API |
965 | 103 | * | 109 | * |