Merge lp:~ralsina/ubuntu-push-qml/make-example-click into lp:ubuntu-push-qml
- make-example-click
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~ralsina/ubuntu-push-qml/make-example-click |
Merge into: | lp:ubuntu-push-qml |
Diff against target: |
1811 lines (+649/-814) 45 files modified
CMakeLists.txt (+1/-15) debian/control (+2/-24) debian/qtdeclarative5-ubuntu-push-notifications-plugin.install (+0/-1) debian/rules (+1/-4) debian/ubuntu-push-example.install (+0/-6) debian/ubuntu-push-notifications-autopilot.install (+0/-1) example/Makefile (+22/-0) example/README (+28/-0) example/components/ChatClient.qml (+70/-0) example/hello.desktop (+8/-0) example/hello.json (+7/-0) example/helloHelper (+7/-0) example/helloHelper-apparmor.json (+6/-0) example/helloHelper.json (+3/-0) example/main.qml (+175/-0) example/manifest.json (+15/-0) example/push-example.qmlproject (+52/-0) example/tests/autopilot/push-example/__init__.py (+72/-0) example/tests/autopilot/push-example/test_main.py (+25/-0) example/tests/autopilot/run (+12/-0) example/tests/unit/tst_hellocomponent.qml (+50/-0) po/CMakeLists.txt (+0/-27) po/ar.po (+0/-17) po/ubuntu-push-qml.pot (+0/-19) src/CMakeLists.txt (+0/-1) src/Ubuntu/CMakeLists.txt (+0/-1) src/Ubuntu/ChatClientPushExample/CMakeLists.txt (+0/-41) src/Ubuntu/ChatClientPushExample/chatclient.cpp (+0/-109) src/Ubuntu/ChatClientPushExample/chatclient.h (+0/-30) src/Ubuntu/ChatClientPushExample/plugin.cpp (+0/-21) src/Ubuntu/ChatClientPushExample/plugin.h (+0/-17) src/Ubuntu/ChatClientPushExample/qmldir (+0/-2) src/Ubuntu/PushNotifications/pushclient.cpp (+72/-22) src/Ubuntu/PushNotifications/pushclient.h (+21/-7) src/example/CMakeLists.txt (+0/-20) src/example/ubuntu-push-example.desktop.in.in (+0/-15) src/example/ubuntu-push-example.qml (+0/-170) tests/CMakeLists.txt (+0/-2) tests/autopilot/CMakeLists.txt (+0/-7) tests/autopilot/ubuntu_push_qml/__init__.py (+0/-132) tests/autopilot/ubuntu_push_qml/main/__init__.py (+0/-1) tests/autopilot/ubuntu_push_qml/main/test_main.py (+0/-23) tests/unit/CMakeLists.txt (+0/-36) tests/unit/tst_QmlTests.cpp (+0/-3) tests/unit/tst_hellocomponent.qml (+0/-40) |
To merge this branch: | bzr merge lp:~ralsina/ubuntu-push-qml/make-example-click |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Sergio Schvezov | Approve | ||
Cris Dywan | Pending | ||
Review via email: mp+229428@code.launchpad.net |
Commit message
Make the example a click app, API updates.
Description of the change
Make the example a click app, API updates.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:19
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:20
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Sergio Schvezov (sergiusens) wrote : | # |
This diff (which fixes package building) plus inline comments:
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-08-04 17:01:31 +0000
+++ CMakeLists.txt 2014-08-05 06:51:47 +0000
@@ -52,7 +52,7 @@
file(GLOB_RECURSE I18N_SRC_FILES
RELATIVE ${CMAKE_
- src/example/**.qml src/example/
+ example/app/**.qml src/example/
list(SORT I18N_SRC_FILES)
# for dh_translations to extract the domain
=== removed file 'debian/
--- debian/
+++ debian/
@@ -1,1 +0,0 @@
-usr/lib/
=== modified file 'debian/rules'
--- debian/rules 2014-07-25 08:43:31 +0000
+++ debian/rules 2014-08-05 06:46:51 +0000
@@ -8,10 +8,7 @@
export DPKG_GENSYMBOLS
%:
- dh $@ --parallel --with translations
-
-override_
- dh_install --fail-missing
+ dh $@ --parallel --with translations --fail-missing
override_
# Override dh_translations to work around http://
=== modified file 'po/CMakeLists.txt'
--- po/CMakeLists.txt 2014-07-25 08:43:31 +0000
+++ po/CMakeLists.txt 2014-08-05 06:49:29 +0000
@@ -1,5 +1,3 @@
-project(
-
include(
find_program(
Sergio Schvezov (sergiusens) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:21
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:24
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Cris Dywan (kalikiana) wrote : | # |
E: Unable to locate package ubuntu-
For some reason J is looking for a non-existing package.
Roberto Alsina (ralsina) wrote : | # |
> E: Unable to locate package ubuntu-
>
> For some reason J is looking for a non-existing package.
Lovely. Probably a leftover mention somewhere...
Roberto Alsina (ralsina) wrote : | # |
> E: Unable to locate package ubuntu-
>
> For some reason J is looking for a non-existing package.
No mention of it anywhere in the source tree, so maybe it's something in Jenkins config? I have no idea :-(
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:25
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:26
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 2. By Roberto Alsina
-
remove translations, this package has no strings
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:26
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 3. By Roberto Alsina
-
force rebuild
Unmerged revisions
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2014-07-25 08:43:31 +0000 |
3 | +++ CMakeLists.txt 2014-08-07 11:51:38 +0000 |
4 | @@ -47,21 +47,7 @@ |
5 | |
6 | add_subdirectory(src) |
7 | |
8 | -enable_testing() |
9 | -add_subdirectory(tests) |
10 | - |
11 | file(GLOB_RECURSE I18N_SRC_FILES |
12 | RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} |
13 | - src/example/**.qml src/example/**.desktop.in) |
14 | + example/app/**.qml example/app/**.desktop.in) |
15 | list(SORT I18N_SRC_FILES) |
16 | - |
17 | -# for dh_translations to extract the domain |
18 | -# (regarding syntax consistency, see http://pad.lv/1181187) |
19 | -set (GETTEXT_PACKAGE "ubuntu-push-qml") |
20 | - |
21 | -add_subdirectory(po) |
22 | - |
23 | -install(FILES ubuntu-push-example.svg |
24 | - DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) |
25 | -install(FILES screenshot.png |
26 | - DESTINATION ${CMAKE_INSTALL_DATADIR}/ubuntu-push-example) |
27 | |
28 | === modified file 'debian/control' |
29 | --- debian/control 2014-07-25 08:43:31 +0000 |
30 | +++ debian/control 2014-08-07 11:51:38 +0000 |
31 | @@ -3,8 +3,8 @@ |
32 | Priority: optional |
33 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
34 | Build-Depends: cmake (>= 2.8.9), |
35 | + dbus-test-runner, |
36 | debhelper (>= 9), |
37 | - dh-translations, |
38 | hardening-wrapper, |
39 | python, |
40 | qt5-default, |
41 | @@ -12,6 +12,7 @@ |
42 | qtbase5-dev, |
43 | qtbase5-private-dev, |
44 | qtdeclarative5-dev, |
45 | + qtdeclarative5-dev-tools, |
46 | qtdeclarative5-private-dev, |
47 | qtdeclarative5-qtquick2-plugin, |
48 | qtdeclarative5-test-plugin, |
49 | @@ -21,17 +22,6 @@ |
50 | Homepage: https://launchpad.net/ubuntu-push-qml |
51 | Vcs-Bzr: https://code.launchpad.net/~ubuntu-push-hackers/ubuntu-push-qml/trunk |
52 | |
53 | -Package: ubuntu-push-example |
54 | -Architecture: any |
55 | -Multi-Arch: foreign |
56 | -Depends: ${misc:Depends}, |
57 | - ${shlibs:Depends}, |
58 | - qtdeclarative5-qtquick2-plugin, |
59 | - qtdeclarative5-ubuntu-push-notifications-plugin (= ${binary:Version}), |
60 | - qtdeclarative5-ubuntu-ui-toolkit-plugin, |
61 | -Description: Ubuntu Push Notifications Example |
62 | - A simple QML only example client. |
63 | - |
64 | Package: qtdeclarative5-ubuntu-push-notifications-plugin |
65 | Architecture: any |
66 | Multi-Arch: same |
67 | @@ -41,15 +31,3 @@ |
68 | qtdeclarative5-ubuntu-ui-toolkit-plugin, |
69 | Description: Ubuntu Push Notifications QML plugin |
70 | Register, receive and send push notifications. |
71 | - |
72 | -Package: ubuntu-push-notifications-autopilot |
73 | -Architecture: all |
74 | -Multi-Arch: foreign |
75 | -Depends: ${misc:Depends}, |
76 | - libautopilot-qt (>= 1.4), |
77 | - libqt5test5, |
78 | - ubuntu-ui-toolkit-autopilot, |
79 | - ubuntu-push-example (>= ${binary:Version}), |
80 | -Description: Ubuntu Push Notifications autopilot tests |
81 | - Register, receive and send push notifications. |
82 | - |
83 | |
84 | === removed file 'debian/qtdeclarative5-ubuntu-push-notifications-plugin.install' |
85 | --- debian/qtdeclarative5-ubuntu-push-notifications-plugin.install 2014-07-25 08:43:31 +0000 |
86 | +++ debian/qtdeclarative5-ubuntu-push-notifications-plugin.install 1970-01-01 00:00:00 +0000 |
87 | @@ -1,1 +0,0 @@ |
88 | -usr/lib/*/qt5/qml/Ubuntu/PushNotifications/* |
89 | |
90 | === modified file 'debian/rules' |
91 | --- debian/rules 2014-07-25 08:43:31 +0000 |
92 | +++ debian/rules 2014-08-07 11:51:38 +0000 |
93 | @@ -8,10 +8,7 @@ |
94 | export DPKG_GENSYMBOLS_CHECK_LEVEL=4 |
95 | |
96 | %: |
97 | - dh $@ --parallel --with translations |
98 | - |
99 | -override_dh_install: |
100 | - dh_install --fail-missing |
101 | + dh $@ --parallel --fail-missing |
102 | |
103 | override_dh_translations: |
104 | # Override dh_translations to work around http://pad.lv/1183262. |
105 | |
106 | === removed file 'debian/ubuntu-push-example.install' |
107 | --- debian/ubuntu-push-example.install 2014-07-25 08:43:31 +0000 |
108 | +++ debian/ubuntu-push-example.install 1970-01-01 00:00:00 +0000 |
109 | @@ -1,6 +0,0 @@ |
110 | -usr/share/ubuntu-push-example/*.qml |
111 | -usr/share/ubuntu-push-example/screenshot.png |
112 | -usr/share/applications/ubuntu-push-example.desktop |
113 | -usr/share/icons/hicolor/scalable/apps/ubuntu-push-example.svg |
114 | -usr/share/locale/*/LC_MESSAGES/ubuntu-push-qml.mo |
115 | -usr/lib/*/qt5/qml/Ubuntu/ChatClientPushExample/* |
116 | |
117 | === removed file 'debian/ubuntu-push-notifications-autopilot.install' |
118 | --- debian/ubuntu-push-notifications-autopilot.install 2014-07-25 08:43:31 +0000 |
119 | +++ debian/ubuntu-push-notifications-autopilot.install 1970-01-01 00:00:00 +0000 |
120 | @@ -1,1 +0,0 @@ |
121 | -usr/lib/python*/dist-packages/ubuntu_push_qml/* |
122 | |
123 | === added directory 'example' |
124 | === added file 'example/.excludes' |
125 | === added file 'example/Makefile' |
126 | --- example/Makefile 1970-01-01 00:00:00 +0000 |
127 | +++ example/Makefile 2014-08-07 11:51:38 +0000 |
128 | @@ -0,0 +1,22 @@ |
129 | +# More information: https://wiki.ubuntu.com/Touch/Testing |
130 | +# |
131 | +# Notes for autopilot tests: |
132 | +# ----------------------------------------------------------- |
133 | +# In order to run autopilot tests: |
134 | +# sudo apt-add-repository ppa:autopilot/ppa |
135 | +# sudo apt-get update |
136 | +# sudo apt-get install python-autopilot autopilot-qt |
137 | +############################################################# |
138 | + |
139 | +all: |
140 | + |
141 | +autopilot: |
142 | + chmod +x tests/autopilot/run |
143 | + tests/autopilot/run |
144 | + |
145 | +check: |
146 | + qmltestrunner -input tests/unit |
147 | + |
148 | +run: |
149 | + /usr/bin/qmlscene $@ push-example.qml |
150 | + |
151 | |
152 | === added file 'example/README' |
153 | --- example/README 1970-01-01 00:00:00 +0000 |
154 | +++ example/README 2014-08-07 11:51:38 +0000 |
155 | @@ -0,0 +1,28 @@ |
156 | +Example App for the QML notifications API. This is an example application |
157 | +showing how to use push notifications in Ubuntu Touch devices. |
158 | + |
159 | += Running on Ubuntu Touch = |
160 | + |
161 | +Since push is currently only meant for Ubuntu Touch devices, this is meant |
162 | +to be used in the emulator or on a real device. |
163 | + |
164 | +* Open the example project in Ubuntu-SDK |
165 | +* Build a click file |
166 | +* Run in the emulator or device |
167 | + |
168 | += Running on the desktop = |
169 | + |
170 | +This is more complicated but may be convenient while experimenting: |
171 | + |
172 | +* Install qtdeclarative5-ubuntu-push-notifications-plugin |
173 | +* Install ubuntu-push-client |
174 | +* Run ubuntu-push-client in trivial helper mode: |
175 | + |
176 | + UBUNTU_PUSH_USE_TRIVIAL_HELPER=1 ./ubuntu-push-client |
177 | + |
178 | +* Build click package |
179 | +* Install in your desktop: |
180 | + |
181 | + sudo click --all-users com.ubuntu.developer.push.ubuntu-push-example_0.1_all.click |
182 | + |
183 | +* Run example app from the SDK using the "Desktop" kit |
184 | |
185 | === added directory 'example/components' |
186 | === added file 'example/components/ChatClient.qml' |
187 | --- example/components/ChatClient.qml 1970-01-01 00:00:00 +0000 |
188 | +++ example/components/ChatClient.qml 2014-08-07 11:51:38 +0000 |
189 | @@ -0,0 +1,70 @@ |
190 | +import QtQuick 2.0 |
191 | +import Ubuntu.Components 0.1 |
192 | + |
193 | +Item { |
194 | + property string nick |
195 | + property string token |
196 | + property bool registered: false |
197 | + signal error (string msg) |
198 | + onNickChanged: {register()} |
199 | + onTokenChanged: {register()} |
200 | + function register() { |
201 | + if (nick && token) { |
202 | + console.log("registering ", nick, token); |
203 | + |
204 | + var req = new XMLHttpRequest(); |
205 | + req.open("post", "http://direct.ralsina.me:8001/register", true); |
206 | + req.setRequestHeader("Content-type", "application/json"); |
207 | + req.onreadystatechange = function() {//Call a function when the state changes. |
208 | + if(req.readyState == 4) { |
209 | + if (req.status == 200) { |
210 | + registered = true; |
211 | + } else { |
212 | + error(JSON.parse(req.responseText)["error"]); |
213 | + } |
214 | + } |
215 | + } |
216 | + req.send(JSON.stringify({ |
217 | + "nick" : nick, |
218 | + "token": token |
219 | + })) |
220 | + } |
221 | + } |
222 | + function sendMessage(message, annoying) { |
223 | + var to_nick = message["to"] |
224 | + var data = { |
225 | + "from_nick": nick, |
226 | + "from_token": token, |
227 | + "nick": to_nick, |
228 | + "data": { |
229 | + "message": message, |
230 | + "notification": {} |
231 | + } |
232 | + } |
233 | + if (annoying) { |
234 | + data["notification"] = { |
235 | + "card": { |
236 | + "summary": nick + " says: " + message["message"], |
237 | + "body": "", |
238 | + "popup": true, |
239 | + "persist": true, |
240 | + "actions": ["appid://com.ubuntu.developer.push.hello/hello/current-user-version"] |
241 | + } |
242 | + } |
243 | + } |
244 | + |
245 | + var req = new XMLHttpRequest(); |
246 | + req.open("post", "http://direct.ralsina.me:8001/message", true); |
247 | + req.setRequestHeader("Content-type", "application/json"); |
248 | + req.onreadystatechange = function() {//Call a function when the state changes. |
249 | + if(req.readyState == 4) { |
250 | + if (req.status == 200) { |
251 | + registered = true; |
252 | + } else { |
253 | + error(JSON.parse(req.responseText)["error"]); |
254 | + } |
255 | + } |
256 | + } |
257 | + req.send(JSON.stringify(data)) |
258 | + } |
259 | +} |
260 | |
261 | === added file 'example/hello.desktop' |
262 | --- example/hello.desktop 1970-01-01 00:00:00 +0000 |
263 | +++ example/hello.desktop 2014-08-07 11:51:38 +0000 |
264 | @@ -0,0 +1,8 @@ |
265 | +[Desktop Entry] |
266 | +Name=hello |
267 | +Exec=qmlscene $@ main.qml |
268 | +Icon=push-example.png |
269 | +Terminal=false |
270 | +Type=Application |
271 | +X-Ubuntu-Touch=true |
272 | + |
273 | |
274 | === added file 'example/hello.json' |
275 | --- example/hello.json 1970-01-01 00:00:00 +0000 |
276 | +++ example/hello.json 2014-08-07 11:51:38 +0000 |
277 | @@ -0,0 +1,7 @@ |
278 | +{ |
279 | + "policy_groups": [ |
280 | + "networking", |
281 | + "push-notification-client" |
282 | + ], |
283 | + "policy_version": 1.2 |
284 | +} |
285 | \ No newline at end of file |
286 | |
287 | === added file 'example/helloHelper' |
288 | --- example/helloHelper 1970-01-01 00:00:00 +0000 |
289 | +++ example/helloHelper 2014-08-07 11:51:38 +0000 |
290 | @@ -0,0 +1,7 @@ |
291 | +#!/usr/bin/python3 |
292 | + |
293 | +import sys |
294 | + |
295 | +f1, f2 = sys.argv[1:3] |
296 | + |
297 | +open(f2, "w").write(open(f1).read()) |
298 | |
299 | === added file 'example/helloHelper-apparmor.json' |
300 | --- example/helloHelper-apparmor.json 1970-01-01 00:00:00 +0000 |
301 | +++ example/helloHelper-apparmor.json 2014-08-07 11:51:38 +0000 |
302 | @@ -0,0 +1,6 @@ |
303 | +{ |
304 | + "policy_groups": [ |
305 | + "push-notification-client" |
306 | + ], |
307 | + "policy_version": 1.2 |
308 | +} |
309 | |
310 | === added file 'example/helloHelper.json' |
311 | --- example/helloHelper.json 1970-01-01 00:00:00 +0000 |
312 | +++ example/helloHelper.json 2014-08-07 11:51:38 +0000 |
313 | @@ -0,0 +1,3 @@ |
314 | +{ |
315 | + "exec": "helloHelper" |
316 | +} |
317 | |
318 | === added file 'example/main.qml' |
319 | --- example/main.qml 1970-01-01 00:00:00 +0000 |
320 | +++ example/main.qml 2014-08-07 11:51:38 +0000 |
321 | @@ -0,0 +1,175 @@ |
322 | +import QtQuick 2.0 |
323 | +import Ubuntu.Components 0.1 |
324 | +import Ubuntu.Components.ListItems 0.1 as ListItem |
325 | +import Ubuntu.PushNotifications 0.1 |
326 | +import "components" |
327 | + |
328 | +MainView { |
329 | + // objectName for functional testing purposes (autopilot-qt5) |
330 | + objectName: "mainView" |
331 | + |
332 | + // Note! applicationName needs to match the "name" field of the click manifest |
333 | + applicationName: "com.ubuntu.developer.push.hello" |
334 | + |
335 | + /* |
336 | + This property enables the application to change orientation |
337 | + when the device is rotated. The default is false. |
338 | + */ |
339 | + automaticOrientation: true |
340 | + |
341 | + width: units.gu(100) |
342 | + height: units.gu(75) |
343 | + ChatClient { |
344 | + id: chatClient |
345 | + onRegisteredChanged: {nickEdit.registered()} |
346 | + onError: {messageList.handle_error(msg)} |
347 | + } |
348 | + |
349 | + PushClient { |
350 | + id: pushClient |
351 | + Component.onCompleted: { |
352 | + notificationsChanged.connect(messageList.handle_notifications) |
353 | + error.connect(messageList.handle_error) |
354 | + } |
355 | + appId: "com.ubuntu.developer.push.hello_hello" |
356 | + } |
357 | + |
358 | + TextField { |
359 | + id: nickEdit |
360 | + focus: true |
361 | + placeholderText: "Your nickname" |
362 | + anchors.left: parent.left |
363 | + anchors.right: parent.right |
364 | + anchors.top: parent.top |
365 | + anchors.leftMargin: units.gu(.5) |
366 | + anchors.rightMargin: units.gu(.5) |
367 | + anchors.topMargin: units.gu(.5) |
368 | + function registered() { |
369 | + readOnly = true |
370 | + text = "Your nick is " + chatClient.nick |
371 | + messageEdit.focus = true |
372 | + messageEdit.enabled = true |
373 | + } |
374 | + onAccepted: { |
375 | + chatClient.nick = text |
376 | + chatClient.token = pushClient.token |
377 | + } |
378 | + } |
379 | + TextField { |
380 | + id: messageEdit |
381 | + anchors.right: annoyingSwitch.left |
382 | + anchors.left: parent.left |
383 | + anchors.top: nickEdit.bottom |
384 | + anchors.topMargin: units.gu(1) |
385 | + anchors.rightMargin: units.gu(1) |
386 | + anchors.leftMargin: units.gu(.5) |
387 | + placeholderText: "Your message" |
388 | + enabled: false |
389 | + onAccepted: { |
390 | + console.log("sending " + text) |
391 | + var idx = text.indexOf(":") |
392 | + var nick_to = text.substring(0, idx).trim() |
393 | + var msg = text.substring(idx+1, 9999).trim() |
394 | + var i = { |
395 | + "from" : chatClient.nick, |
396 | + "to" : nick_to, |
397 | + "message" : msg |
398 | + } |
399 | + chatClient.sendMessage(i, annoyingSwitch.checked) |
400 | + i["type"] = "sent" |
401 | + messagesModel.insert(0, i) |
402 | + text = "" |
403 | + } |
404 | + } |
405 | + Switch { |
406 | + id: annoyingSwitch |
407 | + anchors.right: parent.right |
408 | + anchors.top: nickEdit.bottom |
409 | + anchors.topMargin: units.gu(1) |
410 | + anchors.rightMargin: units.gu(.5) |
411 | + } |
412 | + |
413 | + ListModel { |
414 | + id: messagesModel |
415 | + ListElement { |
416 | + from: "" |
417 | + to: "" |
418 | + type: "info" |
419 | + message: "Register by typing your nick and pressing enter." |
420 | + } |
421 | + ListElement { |
422 | + from: "" |
423 | + to: "" |
424 | + type: "info" |
425 | + message: "Send messages in the form \"destination: hello\"" |
426 | + } |
427 | + ListElement { |
428 | + from: "" |
429 | + to: "" |
430 | + type: "info" |
431 | + message: "The switch on the right makes the message more annoying for the recipient." |
432 | + } |
433 | + } |
434 | + |
435 | + UbuntuShape { |
436 | + anchors.left: parent.left |
437 | + anchors.right: parent.right |
438 | + anchors.bottom: parent.bottom |
439 | + anchors.top: messageEdit.bottom |
440 | + anchors.topMargin: units.gu(1) |
441 | + ListView { |
442 | + id: messageList |
443 | + model: messagesModel |
444 | + anchors.fill: parent |
445 | + delegate: Rectangle { |
446 | + MouseArea { |
447 | + anchors.fill: parent |
448 | + onClicked: { |
449 | + if (from != "") { |
450 | + messageEdit.text = from + ": " |
451 | + messageEdit.focus = true |
452 | + } |
453 | + } |
454 | + } |
455 | + height: label.height + units.gu(2) |
456 | + width: parent.width |
457 | + Rectangle { |
458 | + color: { |
459 | + "info": "#E0E7AB", |
460 | + "received" : "#A2CFA5", |
461 | + "sent" : "#00FF00", |
462 | + "error" : "#FF0000"}[type] |
463 | + height: label.height + units.gu(1) |
464 | + anchors.fill: parent |
465 | + radius: 5 |
466 | + anchors.margins: units.gu(.5) |
467 | + Text { |
468 | + id: label |
469 | + text: "<b>" + from + (from?":":"") + "</b> " + message |
470 | + wrapMode: Text.Wrap |
471 | + width: parent.width - units.gu(1) |
472 | + x: units.gu(.5) |
473 | + horizontalAlignment: (type=="sent")?Text.AlignRight:Text.AlignLeft |
474 | + } |
475 | + } |
476 | + } |
477 | + |
478 | + function handle_error(error) { |
479 | + messagesModel.insert(0, { |
480 | + "from" : "", |
481 | + "to" : "", |
482 | + "type" : "error", |
483 | + "message" : "<b>ERROR: " + error + "</b>" |
484 | + }) |
485 | + } |
486 | + |
487 | + function handle_notifications(list) { |
488 | + list.forEach(function(notification) { |
489 | + var item = JSON.parse(notification) |
490 | + item["type"] = "received" |
491 | + messagesModel.insert(0, item) |
492 | + }) |
493 | + } |
494 | + } |
495 | + } |
496 | +} |
497 | |
498 | === added file 'example/manifest.json' |
499 | --- example/manifest.json 1970-01-01 00:00:00 +0000 |
500 | +++ example/manifest.json 2014-08-07 11:51:38 +0000 |
501 | @@ -0,0 +1,15 @@ |
502 | +{ |
503 | + "architecture": "all", |
504 | + "description": "Example app for Ubuntu push notifications.", |
505 | + "framework": "ubuntu-sdk-14.10-dev2", |
506 | + "hooks": { |
507 | + "hello": { |
508 | + "apparmor": "hello.json", |
509 | + "desktop": "hello.desktop" |
510 | + } |
511 | + }, |
512 | + "maintainer": "Roberto Alsina <roberto.alsina@canonical.com>", |
513 | + "name": "com.ubuntu.developer.push.ubuntu-push-example", |
514 | + "title": "ubuntu-push-example", |
515 | + "version": "0.1" |
516 | +} |
517 | \ No newline at end of file |
518 | |
519 | === added file 'example/push-example.png' |
520 | Binary files example/push-example.png 1970-01-01 00:00:00 +0000 and example/push-example.png 2014-08-07 11:51:38 +0000 differ |
521 | === added file 'example/push-example.qmlproject' |
522 | --- example/push-example.qmlproject 1970-01-01 00:00:00 +0000 |
523 | +++ example/push-example.qmlproject 2014-08-07 11:51:38 +0000 |
524 | @@ -0,0 +1,52 @@ |
525 | +import QmlProject 1.1 |
526 | + |
527 | +Project { |
528 | + mainFile: "main.qml" |
529 | + |
530 | + /* Include .qml, .js, and image files from current directory and subdirectories */ |
531 | + QmlFiles { |
532 | + directory: "." |
533 | + } |
534 | + JavaScriptFiles { |
535 | + directory: "." |
536 | + } |
537 | + ImageFiles { |
538 | + directory: "." |
539 | + } |
540 | + Files { |
541 | + filter: "*.desktop" |
542 | + } |
543 | + Files { |
544 | + filter: "www/*.html" |
545 | + } |
546 | + Files { |
547 | + filter: "Makefile" |
548 | + } |
549 | + Files { |
550 | + directory: "www" |
551 | + filter: "*" |
552 | + } |
553 | + Files { |
554 | + directory: "www/img/" |
555 | + filter: "*" |
556 | + } |
557 | + Files { |
558 | + directory: "www/css/" |
559 | + filter: "*" |
560 | + } |
561 | + Files { |
562 | + directory: "www/js/" |
563 | + filter: "*" |
564 | + } |
565 | + Files { |
566 | + directory: "tests/" |
567 | + filter: "*" |
568 | + } |
569 | + Files { |
570 | + directory: "debian" |
571 | + filter: "*" |
572 | + } |
573 | + /* List of plugin directories passed to QML runtime */ |
574 | + importPaths: [ "." ,"/usr/bin","/usr/lib/x86_64-linux-gnu/qt5/qml" ] |
575 | +} |
576 | + |
577 | |
578 | === added directory 'example/tests' |
579 | === added directory 'example/tests/autopilot' |
580 | === added directory 'example/tests/autopilot/push-example' |
581 | === added file 'example/tests/autopilot/push-example/__init__.py' |
582 | --- example/tests/autopilot/push-example/__init__.py 1970-01-01 00:00:00 +0000 |
583 | +++ example/tests/autopilot/push-example/__init__.py 2014-08-07 11:51:38 +0000 |
584 | @@ -0,0 +1,72 @@ |
585 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
586 | + |
587 | +"""Ubuntu Touch App autopilot tests.""" |
588 | + |
589 | +import os |
590 | +import subprocess |
591 | + |
592 | +from autopilot import input, platform |
593 | +from autopilot.matchers import Eventually |
594 | +from testtools.matchers import Equals |
595 | +from ubuntuuitoolkit import base, emulators |
596 | + |
597 | + |
598 | +def _get_module_include_path(): |
599 | + return os.path.join(get_path_to_source_root(), 'modules') |
600 | + |
601 | + |
602 | +def get_path_to_source_root(): |
603 | + return os.path.abspath( |
604 | + os.path.join( |
605 | + os.path.dirname(__file__), '..', '..', '..', '..')) |
606 | + |
607 | + |
608 | +class ClickAppTestCase(base.UbuntuUIToolkitAppTestCase): |
609 | + """Common test case that provides several useful methods for the tests.""" |
610 | + |
611 | + package_id = '' # TODO |
612 | + app_name = 'push-example' |
613 | + |
614 | + def setUp(self): |
615 | + super(ClickAppTestCase, self).setUp() |
616 | + self.pointing_device = input.Pointer(self.input_device_class.create()) |
617 | + self.launch_application() |
618 | + |
619 | + self.assertThat(self.main_view.visible, Eventually(Equals(True))) |
620 | + |
621 | + def launch_application(self): |
622 | + if platform.model() == 'Desktop': |
623 | + self._launch_application_from_desktop() |
624 | + else: |
625 | + self._launch_application_from_phablet() |
626 | + |
627 | + def _launch_application_from_desktop(self): |
628 | + app_qml_source_location = self._get_app_qml_source_path() |
629 | + if os.path.exists(app_qml_source_location): |
630 | + self.app = self.launch_test_application( |
631 | + base.get_qmlscene_launch_command(), |
632 | + '-I' + _get_module_include_path(), |
633 | + app_qml_source_location, |
634 | + app_type='qt', |
635 | + emulator_base=emulators.UbuntuUIToolkitEmulatorBase) |
636 | + else: |
637 | + raise NotImplementedError( |
638 | + "On desktop we can't install click packages yet, so we can " |
639 | + "only run from source.") |
640 | + |
641 | + def _get_app_qml_source_path(self): |
642 | + qml_file_name = '{0}.qml'.format(self.app_name) |
643 | + return os.path.join(self._get_path_to_app_source(), qml_file_name) |
644 | + |
645 | + def _get_path_to_app_source(self): |
646 | + return os.path.join(get_path_to_source_root(), self.app_name) |
647 | + |
648 | + def _launch_application_from_phablet(self): |
649 | + # On phablet, we only run the tests against the installed click |
650 | + # package. |
651 | + self.app = self.launch_click_package(self.pacakge_id, self.app_name) |
652 | + |
653 | + @property |
654 | + def main_view(self): |
655 | + return self.app.select_single(emulators.MainView) |
656 | + |
657 | |
658 | === added file 'example/tests/autopilot/push-example/test_main.py' |
659 | --- example/tests/autopilot/push-example/test_main.py 1970-01-01 00:00:00 +0000 |
660 | +++ example/tests/autopilot/push-example/test_main.py 2014-08-07 11:51:38 +0000 |
661 | @@ -0,0 +1,25 @@ |
662 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
663 | + |
664 | +"""Tests for the Hello World""" |
665 | + |
666 | +import os |
667 | + |
668 | +from autopilot.matchers import Eventually |
669 | +from testtools.matchers import Equals |
670 | + |
671 | +import push-example |
672 | + |
673 | + |
674 | +class MainViewTestCase(push-example.ClickAppTestCase): |
675 | + """Generic tests for the Hello World""" |
676 | + |
677 | + def test_initial_label(self): |
678 | + label = self.main_view.select_single(objectName='label') |
679 | + self.assertThat(label.text, Equals('Hello..')) |
680 | + |
681 | + def test_click_button_should_update_label(self): |
682 | + button = self.main_view.select_single(objectName='button') |
683 | + self.pointing_device.click_object(button) |
684 | + label = self.main_view.select_single(objectName='label') |
685 | + self.assertThat(label.text, Eventually(Equals('..world!'))) |
686 | + |
687 | |
688 | === added file 'example/tests/autopilot/run' |
689 | --- example/tests/autopilot/run 1970-01-01 00:00:00 +0000 |
690 | +++ example/tests/autopilot/run 2014-08-07 11:51:38 +0000 |
691 | @@ -0,0 +1,12 @@ |
692 | +#!/bin/bash |
693 | + |
694 | +if [[ -z `which autopilot` ]]; then |
695 | + echo "Autopilot is not installed. Skip" |
696 | + exit |
697 | +fi |
698 | + |
699 | +SCRIPTPATH=`dirname $0` |
700 | +pushd ${SCRIPTPATH} |
701 | +autopilot run push-example |
702 | +popd |
703 | + |
704 | |
705 | === added directory 'example/tests/unit' |
706 | === added file 'example/tests/unit/tst_hellocomponent.qml' |
707 | --- example/tests/unit/tst_hellocomponent.qml 1970-01-01 00:00:00 +0000 |
708 | +++ example/tests/unit/tst_hellocomponent.qml 2014-08-07 11:51:38 +0000 |
709 | @@ -0,0 +1,50 @@ |
710 | +import QtQuick 2.0 |
711 | +import QtTest 1.0 |
712 | +import Ubuntu.Components 0.1 |
713 | +import "../../components" |
714 | + |
715 | +// See more details @ http://qt-project.org/doc/qt-5.0/qtquick/qml-testcase.html |
716 | + |
717 | +// Execute tests with: |
718 | +// qmltestrunner |
719 | + |
720 | +Item { |
721 | + // The objects |
722 | + HelloComponent { |
723 | + id: objectUnderTest |
724 | + } |
725 | + |
726 | + TestCase { |
727 | + name: "HelloComponent" |
728 | + |
729 | + function init() { |
730 | + console.debug(">> init"); |
731 | + compare("",objectUnderTest.text,"text was not empty on init"); |
732 | + console.debug("<< init"); |
733 | + } |
734 | + |
735 | + function cleanup() { |
736 | + console.debug(">> cleanup"); |
737 | + console.debug("<< cleanup"); |
738 | + } |
739 | + |
740 | + function initTestCase() { |
741 | + console.debug(">> initTestCase"); |
742 | + console.debug("<< initTestCase"); |
743 | + } |
744 | + |
745 | + function cleanupTestCase() { |
746 | + console.debug(">> cleanupTestCase"); |
747 | + console.debug("<< cleanupTestCase"); |
748 | + } |
749 | + |
750 | + function test_canReadAndWriteText() { |
751 | + var expected = "Hello World"; |
752 | + |
753 | + objectUnderTest.text = expected; |
754 | + |
755 | + compare(expected,objectUnderTest.text,"expected did not equal result"); |
756 | + } |
757 | + } |
758 | +} |
759 | + |
760 | |
761 | === removed directory 'po' |
762 | === removed file 'po/CMakeLists.txt' |
763 | --- po/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
764 | +++ po/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
765 | @@ -1,27 +0,0 @@ |
766 | -project(ubuntu-push-translations) |
767 | - |
768 | -include(FindGettext) |
769 | -find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext) |
770 | - |
771 | -set(DOMAIN ${GETTEXT_PACKAGE}) |
772 | -set(POT_FILE ${DOMAIN}.pot) |
773 | -file(GLOB PO_FILES *.po) |
774 | - |
775 | -add_custom_target(${POT_FILE} |
776 | - COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} -o ${POT_FILE} |
777 | - -D ${CMAKE_SOURCE_DIR} |
778 | - --from-code=UTF-8 |
779 | - --c++ --qt --add-comments=TRANSLATORS |
780 | - --keyword=tr --keyword=tr:1,2 |
781 | - --package-name=ubuntu-push-qml |
782 | - --copyright-holder='Canonical Ltd.' |
783 | - ${I18N_SRC_FILES}) |
784 | - |
785 | -foreach(PO_FILE ${PO_FILES}) |
786 | - get_filename_component(LANG ${PO_FILE} NAME_WE) |
787 | - gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE}) |
788 | - set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES) |
789 | - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo |
790 | - DESTINATION ${INSTALL_DIR} |
791 | - RENAME ${DOMAIN}.mo) |
792 | -endforeach(PO_FILE) |
793 | |
794 | === removed file 'po/ar.po' |
795 | --- po/ar.po 2014-07-25 08:43:31 +0000 |
796 | +++ po/ar.po 1970-01-01 00:00:00 +0000 |
797 | @@ -1,17 +0,0 @@ |
798 | -# Arabic translation for ubuntu-push-qml |
799 | -# Copyright (c) 2013 Rosetta Contributors and Canonical Ltd 2013 |
800 | -# This file is distributed under the same license as the ubuntu-push-qml package. |
801 | -# FIRST AUTHOR <EMAIL@ADDRESS>, 2013. |
802 | -# |
803 | -msgid "" |
804 | -msgstr "" |
805 | -"Project-Id-Version: ubuntu-push-qml\n" |
806 | -"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" |
807 | -"POT-Creation-Date: 2014-04-10 16:28+0100\n" |
808 | -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
809 | -"Last-Translator: FULL NAME <EMAIL@ADDRESS\n" |
810 | -"Language-Team: LANGUAGE <LL@li.org>\n" |
811 | -"MIME-Version: 1.0\n" |
812 | -"Content-Type: text/plain; charset=UTF-8\n" |
813 | -"Content-Transfer-Encoding: 8bit\n" |
814 | - |
815 | |
816 | === removed file 'po/ubuntu-push-qml.pot' |
817 | --- po/ubuntu-push-qml.pot 2014-07-25 08:43:31 +0000 |
818 | +++ po/ubuntu-push-qml.pot 1970-01-01 00:00:00 +0000 |
819 | @@ -1,19 +0,0 @@ |
820 | -# SOME DESCRIPTIVE TITLE. |
821 | -# Copyright (C) YEAR Canonical Ltd. |
822 | -# This file is distributed under the same license as the PACKAGE package. |
823 | -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
824 | -# |
825 | -#, fuzzy |
826 | -msgid "" |
827 | -msgstr "" |
828 | -"Project-Id-Version: ubuntu-push-qml\n" |
829 | -"Report-Msgid-Bugs-To: \n" |
830 | -"POT-Creation-Date: 2014-04-10 16:28+0100\n" |
831 | -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
832 | -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
833 | -"Language-Team: LANGUAGE <LL@li.org>\n" |
834 | -"Language: \n" |
835 | -"MIME-Version: 1.0\n" |
836 | -"Content-Type: text/plain; charset=UTF-8\n" |
837 | -"Content-Transfer-Encoding: 8bit\n" |
838 | - |
839 | |
840 | === modified file 'src/CMakeLists.txt' |
841 | --- src/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
842 | +++ src/CMakeLists.txt 2014-08-07 11:51:38 +0000 |
843 | @@ -1,2 +1,1 @@ |
844 | add_subdirectory(Ubuntu) |
845 | -add_subdirectory(example) |
846 | |
847 | === modified file 'src/Ubuntu/CMakeLists.txt' |
848 | --- src/Ubuntu/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
849 | +++ src/Ubuntu/CMakeLists.txt 2014-08-07 11:51:38 +0000 |
850 | @@ -1,2 +1,1 @@ |
851 | add_subdirectory(PushNotifications) |
852 | -add_subdirectory(ChatClientPushExample) |
853 | |
854 | === removed directory 'src/Ubuntu/ChatClientPushExample' |
855 | === removed file 'src/Ubuntu/ChatClientPushExample/CMakeLists.txt' |
856 | --- src/Ubuntu/ChatClientPushExample/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
857 | +++ src/Ubuntu/ChatClientPushExample/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
858 | @@ -1,41 +0,0 @@ |
859 | -project(ubuntu-chat-client-push-example-plugin) |
860 | - |
861 | -execute_process( |
862 | - COMMAND qmake -query QT_INSTALL_QML |
863 | - OUTPUT_VARIABLE QT_INSTALL_QML |
864 | - OUTPUT_STRIP_TRAILING_WHITESPACE |
865 | -) |
866 | - |
867 | -set(QML_IMPORT ChatClientPushExample) |
868 | -set(IMPORTS_DIR "${QT_INSTALL_QML}/Ubuntu/${QML_IMPORT}") |
869 | -set(PLUGIN Ubuntu${QML_IMPORT}) |
870 | -set(PLUGIN_SRC plugin.cpp chatclient.cpp) |
871 | - |
872 | -add_library(${PLUGIN} MODULE ${PLUGIN_SRC}) |
873 | - |
874 | -qt5_use_modules(${PLUGIN} Core Gui Qml DBus) |
875 | - |
876 | -file(GLOB QML_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.qml qmldir *.js) |
877 | -install(TARGETS ${PLUGIN} DESTINATION ${IMPORTS_DIR}) |
878 | -install(FILES ${QML_FILES} DESTINATION ${IMPORTS_DIR}) |
879 | - |
880 | -add_custom_command( |
881 | - TARGET ${PLUGIN} |
882 | - POST_BUILD |
883 | - COMMAND "qmlplugindump" "Ubuntu.${QML_IMPORT}" "0.1" "${CMAKE_BINARY_DIR}/src" ">" "plugins.qmltypes" |
884 | - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" |
885 | - ) |
886 | -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/plugins.qmltypes |
887 | - DESTINATION ${IMPORTS_DIR}) |
888 | - |
889 | -if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) |
890 | - # copy qml files over to build dir to be able to import them uninstalled |
891 | - set(copied ${QML_FILES}) |
892 | - foreach(_file ${copied}) |
893 | - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file} |
894 | - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_file} |
895 | - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${_file} ${CMAKE_CURRENT_BINARY_DIR}/${_file}) |
896 | - endforeach(_file) |
897 | - add_custom_target(copy_ccpe_files_to_build_dir DEPENDS ${copied}) |
898 | - add_dependencies(${PLUGIN} copy_ccpe_files_to_build_dir) |
899 | -endif() |
900 | |
901 | === removed file 'src/Ubuntu/ChatClientPushExample/chatclient.cpp' |
902 | --- src/Ubuntu/ChatClientPushExample/chatclient.cpp 2014-07-25 08:43:31 +0000 |
903 | +++ src/Ubuntu/ChatClientPushExample/chatclient.cpp 1970-01-01 00:00:00 +0000 |
904 | @@ -1,109 +0,0 @@ |
905 | -#include "chatclient.h" |
906 | - |
907 | -#include <QDebug> |
908 | -#include <QJsonObject> |
909 | -#include <QJsonDocument> |
910 | -#include <QNetworkRequest> |
911 | - |
912 | -#define REGISTER_URL QUrl("http://direct.ralsina.me:8001/register") |
913 | -#define POST_URL QUrl("http://direct.ralsina.me:8001/message") |
914 | - |
915 | -ChatClient::ChatClient(QObject *parent) : |
916 | - QObject(parent) |
917 | -{ |
918 | - this->nam = new QNetworkAccessManager(this); |
919 | -} |
920 | - |
921 | -void ChatClient::registerNick(QString _nick, QString _token) { |
922 | - qDebug() << "registering nick" << _nick << _token; |
923 | - nick = _nick.toLower(); |
924 | - token = _token; |
925 | - QNetworkRequest req; |
926 | - req.setUrl(REGISTER_URL); |
927 | - req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); |
928 | - QJsonObject json; |
929 | - // Create JSON representation, will look like this: |
930 | - //{ |
931 | - // "nick": "joe", |
932 | - // "token": "asdasdasdasd==" |
933 | - //} |
934 | - |
935 | - json["nick"] = nick; |
936 | - json["token"] = token; |
937 | - QJsonDocument json_doc(json); |
938 | - qDebug() << "registering nick" << json_doc.toJson(); |
939 | - QNetworkReply *reply = this->nam->post(req, json_doc.toJson()); |
940 | - // Emit an error for network issues, emit registered for success |
941 | - connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleError(QNetworkReply::NetworkError))); |
942 | - connect(reply, SIGNAL(finished()), SIGNAL(registered())); |
943 | -} |
944 | - |
945 | -void ChatClient::sendMessage(QString msg, bool annoying) { |
946 | - // msg is a json object |
947 | - QJsonDocument msg_doc=QJsonDocument::fromJson(msg.toUtf8()); |
948 | - if (!msg_doc.isObject()) { |
949 | - emit error("Malformed message in sendMessage."); |
950 | - } |
951 | - QJsonObject message = msg_doc.object(); |
952 | - |
953 | - QString to_nick = message["to"].toString().toLower(); |
954 | - // Replace sender with recipient, so recipient sees who is sending |
955 | - QString realmsg = nick + " says: " + message["text"].toString().toLower().trimmed(); |
956 | - |
957 | - // Create JSON representation, will look like this: |
958 | - //{ |
959 | - // "from_nick": "alice", |
960 | - // "from_token": "foobar==", |
961 | - // "nick": "bob", |
962 | - // "data": { |
963 | - // "message": { |
964 | - // "message": "hello", |
965 | - // "from": "from_nick", |
966 | - // "to": "to_nick", |
967 | - // }, |
968 | - // "notification": { |
969 | - // "card": { |
970 | - // "summary": "nickname: hello", |
971 | - // "body": "", |
972 | - // "popup": true, |
973 | - // "persist": true |
974 | - // } |
975 | - // } |
976 | - // } |
977 | - //} |
978 | - QJsonObject json; |
979 | - QJsonObject notification; |
980 | - QJsonObject data; |
981 | - if (annoying) { |
982 | - QJsonObject card; |
983 | - card["summary"] = realmsg; |
984 | - card["body"] = ""; |
985 | - card["popup"] = true; |
986 | - card["persist"] = true; |
987 | - notification["card"] = card; |
988 | - } |
989 | - message["text"] = realmsg; |
990 | - data["message"] = message; |
991 | - data["notification"] = notification; |
992 | - json["data"] = data; |
993 | - json["nick"] = to_nick; |
994 | - json["from_nick"] = nick; |
995 | - json["from_token"] = this->token; |
996 | - QJsonDocument json_doc(json); |
997 | - |
998 | - QNetworkRequest req; |
999 | - req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); |
1000 | - req.setUrl(POST_URL); |
1001 | - qDebug() << "sending message to:" << to_nick << ":" << json_doc.toJson(); |
1002 | - QNetworkReply *reply = this->nam->post(req, json_doc.toJson()); |
1003 | - //Emit error for network issues, do nothing for success (no news is good news) |
1004 | - connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleError(QNetworkReply::NetworkError))); |
1005 | -} |
1006 | - |
1007 | -void ChatClient::handleError(QNetworkReply::NetworkError code) { |
1008 | - // Convert network errors into strings and pass along. |
1009 | - QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); |
1010 | - qDebug() << "HTTP error:" << reply->errorString(); |
1011 | - emit error(QString("Chat server said: ") + reply->errorString()); |
1012 | - reply->deleteLater(); |
1013 | -} |
1014 | |
1015 | === removed file 'src/Ubuntu/ChatClientPushExample/chatclient.h' |
1016 | --- src/Ubuntu/ChatClientPushExample/chatclient.h 2014-07-25 08:43:31 +0000 |
1017 | +++ src/Ubuntu/ChatClientPushExample/chatclient.h 1970-01-01 00:00:00 +0000 |
1018 | @@ -1,30 +0,0 @@ |
1019 | -#ifndef CHATCLIENT_H |
1020 | -#define CHATCLIENT_H |
1021 | - |
1022 | -#include <QObject> |
1023 | -#include <QNetworkAccessManager> |
1024 | -#include <QNetworkReply> |
1025 | - |
1026 | -class ChatClient : public QObject |
1027 | -{ |
1028 | - Q_OBJECT |
1029 | -public: |
1030 | - explicit ChatClient(QObject *parent = 0); |
1031 | - QString nick; |
1032 | - Q_PROPERTY(QString nick MEMBER nick); |
1033 | - |
1034 | -signals: |
1035 | - void error(QString); |
1036 | - void registered(); |
1037 | - |
1038 | -public slots: |
1039 | - void sendMessage(QString msg, bool annoying); |
1040 | - void registerNick(QString nick, QString token); |
1041 | - void handleError(QNetworkReply::NetworkError code); |
1042 | - |
1043 | -private: |
1044 | - QString token; |
1045 | - QNetworkAccessManager *nam; |
1046 | -}; |
1047 | - |
1048 | -#endif // CHATCLIENT_H |
1049 | |
1050 | === removed file 'src/Ubuntu/ChatClientPushExample/plugin.cpp' |
1051 | --- src/Ubuntu/ChatClientPushExample/plugin.cpp 2014-07-25 08:43:31 +0000 |
1052 | +++ src/Ubuntu/ChatClientPushExample/plugin.cpp 1970-01-01 00:00:00 +0000 |
1053 | @@ -1,21 +0,0 @@ |
1054 | -#include "plugin.h" |
1055 | -#include "chatclient.h" |
1056 | - |
1057 | -// Qt |
1058 | -#include <QtCore/QDir> |
1059 | -#include <QtCore/QStandardPaths> |
1060 | -#include <QtCore/QtGlobal> |
1061 | -#include <QtGui/QGuiApplication> |
1062 | -#include <QtQml> |
1063 | - |
1064 | -void UbuntuBrowserPlugin::initializeEngine(QQmlEngine* engine, const char* uri) |
1065 | -{ |
1066 | - QQmlExtensionPlugin::initializeEngine(engine, uri); |
1067 | -} |
1068 | - |
1069 | -void UbuntuBrowserPlugin::registerTypes(const char* uri) |
1070 | -{ |
1071 | - Q_ASSERT(uri == QLatin1String("Ubuntu.ChatClientPushExample")); |
1072 | - |
1073 | - qmlRegisterType<ChatClient>(uri, 0, 1, "ChatClient"); |
1074 | -} |
1075 | |
1076 | === removed file 'src/Ubuntu/ChatClientPushExample/plugin.h' |
1077 | --- src/Ubuntu/ChatClientPushExample/plugin.h 2014-07-25 08:43:31 +0000 |
1078 | +++ src/Ubuntu/ChatClientPushExample/plugin.h 1970-01-01 00:00:00 +0000 |
1079 | @@ -1,17 +0,0 @@ |
1080 | -#ifndef __PLUGIN_H__ |
1081 | -#define __PLUGIN_H__ |
1082 | - |
1083 | -// Qt |
1084 | -#include <QtQml/QQmlExtensionPlugin> |
1085 | - |
1086 | -class UbuntuBrowserPlugin : public QQmlExtensionPlugin |
1087 | -{ |
1088 | - Q_OBJECT |
1089 | - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
1090 | - |
1091 | -public: |
1092 | - void initializeEngine(QQmlEngine* engine, const char* uri); |
1093 | - void registerTypes(const char* uri); |
1094 | -}; |
1095 | - |
1096 | -#endif // __PLUGIN_H__ |
1097 | |
1098 | === removed file 'src/Ubuntu/ChatClientPushExample/qmldir' |
1099 | --- src/Ubuntu/ChatClientPushExample/qmldir 2014-07-25 08:43:31 +0000 |
1100 | +++ src/Ubuntu/ChatClientPushExample/qmldir 1970-01-01 00:00:00 +0000 |
1101 | @@ -1,2 +0,0 @@ |
1102 | -module Ubuntu.ChatClientPushExample |
1103 | -plugin UbuntuChatClientPushExample |
1104 | |
1105 | === modified file 'src/Ubuntu/PushNotifications/pushclient.cpp' |
1106 | --- src/Ubuntu/PushNotifications/pushclient.cpp 2014-07-25 08:43:31 +0000 |
1107 | +++ src/Ubuntu/PushNotifications/pushclient.cpp 2014-08-07 11:51:38 +0000 |
1108 | @@ -1,5 +1,4 @@ |
1109 | #include "pushclient.h" |
1110 | -#include <QDebug> |
1111 | #include <QtDBus/QDBusConnection> |
1112 | #include <QtDBus/QDBusMessage> |
1113 | #include <QTimer> |
1114 | @@ -16,41 +15,50 @@ |
1115 | { |
1116 | } |
1117 | |
1118 | -void PushClient::registerApp(QString appid) { |
1119 | - this->appid = appid; |
1120 | - |
1121 | - pkgname = appid.split("_").at(0); |
1122 | - pkgname = pkgname.replace(".","_2e").replace("-","_2f"); |
1123 | +void PushClient::registerApp(QString appId) { |
1124 | + if (appId == this->appId || appId == "") |
1125 | + return; |
1126 | + |
1127 | + this->appId = appId; |
1128 | + |
1129 | + pkgname = appId.split("_").at(0); |
1130 | + pkgname = pkgname.replace(".","_2e").replace("-","_2d"); |
1131 | + emit appIdChanged(appId); |
1132 | |
1133 | QString register_path(PUSH_PATH); |
1134 | register_path += "/" + pkgname; |
1135 | |
1136 | - qDebug() << "registering:" << appid; |
1137 | QDBusConnection bus = QDBusConnection::sessionBus(); |
1138 | |
1139 | // Register to the push client |
1140 | QDBusMessage message = QDBusMessage::createMethodCall(PUSH_SERVICE, register_path , PUSH_IFACE, "Register"); |
1141 | - message << appid; |
1142 | + message << appId; |
1143 | QDBusMessage token = bus.call(message); |
1144 | if (token.type() == QDBusMessage::ErrorMessage) { |
1145 | - qDebug() << "Error registering:" << token.errorMessage(); |
1146 | status = token.errorMessage(); |
1147 | + emit statusChanged(status); |
1148 | // This has to be delayed because the error signal is not connected yet |
1149 | QTimer::singleShot(200, this, SLOT(emitError())); |
1150 | return; |
1151 | } |
1152 | - // Usually we would not show this ;-) |
1153 | - qDebug() << "token" << token.arguments()[0].toStringList()[0]; |
1154 | this->token = token.arguments()[0].toStringList()[0]; |
1155 | |
1156 | // Connect to the notification signal |
1157 | QString postal_path(POSTAL_PATH); |
1158 | postal_path += "/" + pkgname; |
1159 | - qDebug() << postal_path << "-----------"; |
1160 | - qDebug() << "connecting:" << bus.connect(POSTAL_SERVICE, postal_path, POSTAL_IFACE, "Post", "s", this, SLOT(notified(QString))); |
1161 | + bus.connect(POSTAL_SERVICE, postal_path, POSTAL_IFACE, "Post", "s", this, SLOT(notified(QString))); |
1162 | |
1163 | // Do an initial fetch |
1164 | QTimer::singleShot(200, this, SLOT(getNotifications())); |
1165 | + emit tokenChanged(this->token); |
1166 | +} |
1167 | + |
1168 | +QString PushClient::getAppId() { |
1169 | + return appId; |
1170 | +} |
1171 | + |
1172 | +QString PushClient::getToken() { |
1173 | + return token; |
1174 | } |
1175 | |
1176 | void PushClient::emitError() |
1177 | @@ -60,7 +68,6 @@ |
1178 | |
1179 | void PushClient::notified(QString) |
1180 | { |
1181 | - qDebug() << "Notified"; |
1182 | this->getNotifications(); |
1183 | } |
1184 | |
1185 | @@ -71,12 +78,55 @@ |
1186 | QString path(POSTAL_PATH); |
1187 | path += "/" + pkgname; |
1188 | QDBusMessage message = QDBusMessage::createMethodCall(POSTAL_SERVICE, path, POSTAL_IFACE, "PopAll"); |
1189 | - message << this->appid; |
1190 | - QDBusMessage reply = bus.call(message); |
1191 | - if (reply.type() == QDBusMessage::ErrorMessage) { |
1192 | - qDebug() << "Error fetching notifications:" << reply.errorMessage(); |
1193 | - emit error(reply.errorMessage()); |
1194 | - } |
1195 | - qDebug() << "notifications:" << reply.arguments()[0].toStringList(); |
1196 | - emit newNotifications(reply.arguments()[0].toStringList()); |
1197 | + message << this->appId; |
1198 | + QDBusMessage reply = bus.call(message); |
1199 | + if (reply.type() == QDBusMessage::ErrorMessage) { |
1200 | + emit error(reply.errorMessage()); |
1201 | + } |
1202 | + emit notificationsChanged(reply.arguments()[0].toStringList()); |
1203 | +} |
1204 | + |
1205 | +QStringList PushClient::getPersistent() { |
1206 | + QDBusConnection bus = QDBusConnection::sessionBus(); |
1207 | + QString path(POSTAL_PATH); |
1208 | + path += "/" + pkgname; |
1209 | + QDBusMessage message = QDBusMessage::createMethodCall(POSTAL_SERVICE, path, POSTAL_IFACE, "ListPersistent"); |
1210 | + message << this->appId; |
1211 | + QDBusMessage reply = bus.call(message); |
1212 | + if (reply.type() == QDBusMessage::ErrorMessage) { |
1213 | + emit error(reply.errorMessage()); |
1214 | + } |
1215 | + return reply.arguments()[0].toStringList(); |
1216 | +} |
1217 | + |
1218 | +void PushClient::clearPersistent(QStringList tags) { |
1219 | + QDBusConnection bus = QDBusConnection::sessionBus(); |
1220 | + QString path(POSTAL_PATH); |
1221 | + path += "/" + pkgname; |
1222 | + QDBusMessage message = QDBusMessage::createMethodCall(POSTAL_SERVICE, path, POSTAL_IFACE, "ClearPersistent"); |
1223 | + message << this->appId << tags; |
1224 | + QDBusMessage reply = bus.call(message); |
1225 | + if (reply.type() == QDBusMessage::ErrorMessage) { |
1226 | + emit error(reply.errorMessage()); |
1227 | + } |
1228 | + emit persistentChanged(getPersistent()); |
1229 | +} |
1230 | + |
1231 | +void PushClient::setCount(int count) { |
1232 | + QDBusConnection bus = QDBusConnection::sessionBus(); |
1233 | + QString path(POSTAL_PATH); |
1234 | + bool visible = count != 0; |
1235 | + counter = count; |
1236 | + path += "/" + pkgname; |
1237 | + QDBusMessage message = QDBusMessage::createMethodCall(POSTAL_SERVICE, path, POSTAL_IFACE, "setCounter"); |
1238 | + message << this->appId << count << visible; |
1239 | + QDBusMessage reply = bus.call(message); |
1240 | + if (reply.type() == QDBusMessage::ErrorMessage) { |
1241 | + emit error(reply.errorMessage()); |
1242 | + } |
1243 | + emit countChanged(counter); |
1244 | +} |
1245 | + |
1246 | +int PushClient::getCount() { |
1247 | + return counter; |
1248 | } |
1249 | |
1250 | === modified file 'src/Ubuntu/PushNotifications/pushclient.h' |
1251 | --- src/Ubuntu/PushNotifications/pushclient.h 2014-07-25 08:43:31 +0000 |
1252 | +++ src/Ubuntu/PushNotifications/pushclient.h 2014-08-07 11:51:38 +0000 |
1253 | @@ -12,27 +12,41 @@ |
1254 | explicit PushClient(QObject *parent = 0); |
1255 | void registerApp(QString appid); |
1256 | QString getStatus() {return this->status;}; |
1257 | + QString getAppId(); |
1258 | + QString getToken(); |
1259 | + QStringList getPersistent(); |
1260 | + void clearPersistent(QStringList tags); |
1261 | + void setCount(int count); |
1262 | + int getCount(); |
1263 | |
1264 | - Q_PROPERTY(QString appid WRITE registerApp MEMBER appid); |
1265 | - Q_PROPERTY(QString token MEMBER token); |
1266 | - Q_PROPERTY(QStringList notifications NOTIFY newNotifications MEMBER notifications); |
1267 | - Q_PROPERTY(QString status READ getStatus); |
1268 | + Q_PROPERTY(QString appId WRITE registerApp READ getAppId NOTIFY appIdChanged); |
1269 | + Q_PROPERTY(QString token READ getToken NOTIFY tokenChanged); |
1270 | + Q_PROPERTY(QStringList notifications NOTIFY notificationsChanged); |
1271 | + Q_PROPERTY(QString status READ getStatus NOTIFY statusChanged); |
1272 | + Q_PROPERTY(QStringList persistent READ getPersistent NOTIFY persistentChanged); |
1273 | + Q_PROPERTY(int count READ getCount WRITE setCount NOTIFY countChanged) |
1274 | |
1275 | signals: |
1276 | - void newNotifications(QStringList); |
1277 | + void countChanged(int); |
1278 | + void notificationsChanged(QStringList); |
1279 | + void persistentChanged(QStringList); |
1280 | + void appIdChanged(QString); |
1281 | void error(QString); |
1282 | + void tokenChanged(QString); |
1283 | + void statusChanged(QString); |
1284 | |
1285 | public slots: |
1286 | void getNotifications(); |
1287 | - void notified(QString appid); |
1288 | + void notified(QString appId); |
1289 | void emitError(); |
1290 | |
1291 | private: |
1292 | - QString appid; |
1293 | + QString appId; |
1294 | QString pkgname; |
1295 | QString token; |
1296 | QString status; |
1297 | QStringList notifications; |
1298 | + int counter; |
1299 | }; |
1300 | |
1301 | #endif // PUSHCLIENT_H |
1302 | |
1303 | === removed directory 'src/example' |
1304 | === removed file 'src/example/CMakeLists.txt' |
1305 | --- src/example/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
1306 | +++ src/example/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1307 | @@ -1,20 +0,0 @@ |
1308 | -project(ubuntu-push-example) |
1309 | - |
1310 | -include_directories(${Qt5Quick_PRIVATE_INCLUDE_DIRS}) |
1311 | - |
1312 | -file(GLOB QML_FILES *.qml) |
1313 | -install(FILES ${QML_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/ubuntu-push-example) |
1314 | - |
1315 | -set(DESKTOP_FILE ubuntu-push-example.desktop) |
1316 | -set(EXEC "qmlscene ${CMAKE_INSTALL_DATADIR}/ubuntu-push-example/${DESKTOP_FILE} %f" ) |
1317 | -configure_file(${DESKTOP_FILE}.in.in ${DESKTOP_FILE}.in @ONLY) |
1318 | -file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE}) |
1319 | -file(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE}.in DESKTOP_FILE_CONTENTS) |
1320 | -foreach(LINE ${DESKTOP_FILE_CONTENTS}) |
1321 | - string(REGEX REPLACE "tr\\\(\"(.*)\"\\\)" "\\1" LINE "${LINE}") |
1322 | - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE} "${LINE}\n") |
1323 | -endforeach(LINE) |
1324 | - |
1325 | -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE} |
1326 | - DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) |
1327 | - |
1328 | |
1329 | === removed file 'src/example/ubuntu-push-example.desktop.in.in' |
1330 | --- src/example/ubuntu-push-example.desktop.in.in 2014-07-25 08:43:31 +0000 |
1331 | +++ src/example/ubuntu-push-example.desktop.in.in 1970-01-01 00:00:00 +0000 |
1332 | @@ -1,15 +0,0 @@ |
1333 | -[Desktop Entry] |
1334 | -Version=1.0 |
1335 | -Name=tr("Ubuntu Push Notification Example") |
1336 | -GenericName=tr("Push Notification Example") |
1337 | -Comment=tr("Push notifications around") |
1338 | -Type=Application |
1339 | -Icon=ubuntu-push-example |
1340 | -Exec=@EXEC |
1341 | -Terminal=false |
1342 | -Categories=Network;WebBrowser; |
1343 | -Keywords=Internet;WWW;Browser;Web;Explorer |
1344 | -X-Ubuntu-Touch=true |
1345 | -X-Ubuntu-Gettext-Domain=ubuntu-push-example |
1346 | -X-Ubuntu-Single-Instance=true |
1347 | -X-Screenshot=@CMAKE_INSTALL_FULL_DATADIR@/ubuntu-push-example/screenshot.png |
1348 | |
1349 | === removed file 'src/example/ubuntu-push-example.qml' |
1350 | --- src/example/ubuntu-push-example.qml 2014-07-25 08:43:31 +0000 |
1351 | +++ src/example/ubuntu-push-example.qml 1970-01-01 00:00:00 +0000 |
1352 | @@ -1,170 +0,0 @@ |
1353 | -import QtQuick 2.0 |
1354 | -import Ubuntu.Components 0.1 |
1355 | -import Ubuntu.Components.ListItems 0.1 as ListItem |
1356 | -import Ubuntu.PushNotifications 0.1 |
1357 | -import Ubuntu.ChatClientPushExample 0.1 |
1358 | - |
1359 | -/*! |
1360 | - \brief MainView with Tabs element. |
1361 | - First Tab has a single Label and |
1362 | - second Tab has a single ToolbarAction. |
1363 | -*/ |
1364 | - |
1365 | -MainView { |
1366 | - // objectName for functional testing purposes (autopilot-qt5) |
1367 | - objectName: "mainView" |
1368 | - |
1369 | - // Note! applicationName needs to match the "name" field of the click manifest |
1370 | - applicationName: "com.ubuntu.developer.push.hello" |
1371 | - |
1372 | - /* |
1373 | - This property enables the application to change orientation |
1374 | - when the device is rotated. The default is false. |
1375 | - */ |
1376 | - automaticOrientation: true |
1377 | - |
1378 | - width: units.gu(100) |
1379 | - height: units.gu(75) |
1380 | - ChatClient { |
1381 | - id: chatClient |
1382 | - onError: messageList.handle_error |
1383 | - onRegistered: nickEdit.registered |
1384 | - } |
1385 | - |
1386 | - PushClient { |
1387 | - id: pushClient |
1388 | - onNewNotifications: messageList.handle_notifications |
1389 | - onError: messageList.handle_error |
1390 | - appid: "com.ubuntu.developer.push.hello_hello" |
1391 | - |
1392 | - } |
1393 | - |
1394 | - TextField { |
1395 | - id: nickEdit |
1396 | - focus: true |
1397 | - placeholderText: "Your nickname" |
1398 | - anchors.left: parent.left |
1399 | - anchors.right: parent.right |
1400 | - anchors.top: parent.top |
1401 | - anchors.leftMargin: units.gu(.5) |
1402 | - anchors.rightMargin: units.gu(.5) |
1403 | - anchors.topMargin: units.gu(.5) |
1404 | - function registered() { |
1405 | - readOnly = true |
1406 | - text = "Your nick is " + chatClient.nick |
1407 | - messageEdit.focus = true |
1408 | - } |
1409 | - onAccepted: chatClient.registerNick(text, pushClient.token) |
1410 | - } |
1411 | - TextField { |
1412 | - id: messageEdit |
1413 | - anchors.right: annoyingSwitch.left |
1414 | - anchors.left: parent.left |
1415 | - anchors.top: nickEdit.bottom |
1416 | - anchors.topMargin: units.gu(1) |
1417 | - anchors.rightMargin: units.gu(1) |
1418 | - anchors.leftMargin: units.gu(.5) |
1419 | - placeholderText: "Your message" |
1420 | - onAccepted: { |
1421 | - console.log("sending " + text) |
1422 | - messagesModel.insert(0, { |
1423 | - "from" : chatClient.nick, |
1424 | - "to" : "", |
1425 | - "type": "sent", |
1426 | - "message" : text |
1427 | - }) |
1428 | - chatClient.sendMessage(text, annoyingSwitch.checked) |
1429 | - text = "" |
1430 | - } |
1431 | - } |
1432 | - Switch { |
1433 | - id: annoyingSwitch |
1434 | - anchors.right: parent.right |
1435 | - anchors.top: nickEdit.bottom |
1436 | - anchors.topMargin: units.gu(1) |
1437 | - anchors.rightMargin: units.gu(.5) |
1438 | - } |
1439 | - |
1440 | - ListModel { |
1441 | - id: messagesModel |
1442 | - ListElement { |
1443 | - from: "" |
1444 | - to: "" |
1445 | - type: "info" |
1446 | - message: "Register by typing your nick and pressing enter." |
1447 | - } |
1448 | - ListElement { |
1449 | - from: "" |
1450 | - to: "" |
1451 | - type: "info" |
1452 | - message: "Send messages in the form \"destination: hello\"" |
1453 | - } |
1454 | - ListElement { |
1455 | - from: "" |
1456 | - to: "" |
1457 | - type: "info" |
1458 | - message: "The switch on the right makes the message more annoying for the recipient." |
1459 | - } |
1460 | - } |
1461 | - |
1462 | - UbuntuShape { |
1463 | - anchors.left: parent.left |
1464 | - anchors.right: parent.right |
1465 | - anchors.bottom: parent.bottom |
1466 | - anchors.top: messageEdit.bottom |
1467 | - anchors.topMargin: units.gu(1) |
1468 | - ListView { |
1469 | - id: messageList |
1470 | - model: messagesModel |
1471 | - anchors.fill: parent |
1472 | - delegate: Rectangle { |
1473 | - MouseArea { |
1474 | - anchors.fill: parent |
1475 | - onClicked: { |
1476 | - if (from != "") { |
1477 | - messageEdit.text = from + ": " |
1478 | - messageEdit.focus = true |
1479 | - } |
1480 | - } |
1481 | - } |
1482 | - height: label.height + units.gu(2) |
1483 | - width: parent.width |
1484 | - Rectangle { |
1485 | - color: { |
1486 | - "info": "#E0E7AB", |
1487 | - "received" : "#A2CFA5", |
1488 | - "sent" : "#00FF00", |
1489 | - "error" : "#FF0000"}[type] |
1490 | - height: label.height + units.gu(1) |
1491 | - anchors.fill: parent |
1492 | - radius: 5 |
1493 | - anchors.margins: units.gu(.5) |
1494 | - Text { |
1495 | - id: label |
1496 | - text: "<b>" + from + (from?":":"") + "</b> " + message // FIXME: make better |
1497 | - wrapMode: Text.Wrap |
1498 | - width: parent.width - units.gu(1) |
1499 | - x: units.gu(.5) |
1500 | - } |
1501 | - } |
1502 | - } |
1503 | - |
1504 | - function handle_error(error) { |
1505 | - messagesModel.insert(0, { |
1506 | - "from" : "", |
1507 | - "to" : "", |
1508 | - "type" : "error", |
1509 | - "message" : "<b>ERROR: " + error + "</b>" |
1510 | - }) |
1511 | - } |
1512 | - |
1513 | - function handle_notifications(list) { |
1514 | - list.forEach(function(notification) { |
1515 | - var item = JSON.parse(notification) |
1516 | - item["type"] = "received" |
1517 | - messagesModel.insert(0, item) |
1518 | - }) |
1519 | - } |
1520 | - } |
1521 | - } |
1522 | -} |
1523 | |
1524 | === removed directory 'tests' |
1525 | === removed file 'tests/CMakeLists.txt' |
1526 | --- tests/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
1527 | +++ tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1528 | @@ -1,2 +0,0 @@ |
1529 | -add_subdirectory(autopilot) |
1530 | -add_subdirectory(unit) |
1531 | |
1532 | === removed directory 'tests/autopilot' |
1533 | === removed file 'tests/autopilot/CMakeLists.txt' |
1534 | --- tests/autopilot/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
1535 | +++ tests/autopilot/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1536 | @@ -1,7 +0,0 @@ |
1537 | -execute_process(COMMAND python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" |
1538 | - OUTPUT_VARIABLE PYTHON_PACKAGE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) |
1539 | - |
1540 | -install(DIRECTORY ubuntu_push_qml |
1541 | - DESTINATION ${PYTHON_PACKAGE_DIR} |
1542 | - ) |
1543 | - |
1544 | |
1545 | === removed directory 'tests/autopilot/ubuntu_push_qml' |
1546 | === removed file 'tests/autopilot/ubuntu_push_qml/__init__.py' |
1547 | --- tests/autopilot/ubuntu_push_qml/__init__.py 2014-07-25 08:43:31 +0000 |
1548 | +++ tests/autopilot/ubuntu_push_qml/__init__.py 1970-01-01 00:00:00 +0000 |
1549 | @@ -1,132 +0,0 @@ |
1550 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
1551 | - |
1552 | -"""Ubuntu Touch App autopilot tests.""" |
1553 | - |
1554 | -from os import remove |
1555 | -import os.path |
1556 | -from tempfile import mktemp |
1557 | -import subprocess |
1558 | - |
1559 | -from autopilot.input import Mouse, Touch, Pointer |
1560 | -from autopilot.matchers import Eventually |
1561 | -from autopilot.platform import model |
1562 | -from testtools.matchers import Is, Not, Equals |
1563 | -from autopilot.testcase import AutopilotTestCase |
1564 | - |
1565 | -def get_module_include_path(): |
1566 | - return os.path.abspath( |
1567 | - os.path.join( |
1568 | - os.path.dirname(__file__), |
1569 | - '..', |
1570 | - '..', |
1571 | - '..', |
1572 | - '..', |
1573 | - 'backend', |
1574 | - 'modules') |
1575 | - ) |
1576 | - |
1577 | - |
1578 | -class UbuntuTouchAppTestCase(AutopilotTestCase): |
1579 | - """A common test case class that provides several useful methods for the tests.""" |
1580 | - |
1581 | - if model() == 'Desktop': |
1582 | - scenarios = [ |
1583 | - ('with mouse', dict(input_device_class=Mouse)) |
1584 | - ] |
1585 | - else: |
1586 | - scenarios = [ |
1587 | - ('with touch', dict(input_device_class=Touch)) |
1588 | - ] |
1589 | - |
1590 | - @property |
1591 | - def main_window(self): |
1592 | - return MainWindow(self.app) |
1593 | - |
1594 | - |
1595 | - def setUp(self): |
1596 | - self.pointing_device = Pointer(self.input_device_class.create()) |
1597 | - super(UbuntuTouchAppTestCase, self).setUp() |
1598 | - self.launch_test_qml() |
1599 | - |
1600 | - |
1601 | - def launch_test_qml(self): |
1602 | - # If the test class has defined a 'test_qml' class attribute then we |
1603 | - # write it to disk and launch it inside the QML Scene. If not, then we |
1604 | - # silently do nothing (presumably the test has something else planned). |
1605 | - arch = subprocess.check_output(["dpkg-architecture", |
1606 | - "-qDEB_HOST_MULTIARCH"]).strip() |
1607 | - if hasattr(self, 'test_qml') and isinstance(self.test_qml, basestring): |
1608 | - qml_path = mktemp(suffix='.qml') |
1609 | - open(qml_path, 'w').write(self.test_qml) |
1610 | - self.addCleanup(remove, qml_path) |
1611 | - |
1612 | - self.app = self.launch_test_application( |
1613 | - "/usr/lib/" + arch + "/qt5/bin/qmlscene", |
1614 | - "-I", get_module_include_path(), |
1615 | - qml_path, |
1616 | - app_type='qt') |
1617 | - |
1618 | - if hasattr(self, 'test_qml_file') and isinstance(self.test_qml_file, basestring): |
1619 | - qml_path = self.test_qml_file |
1620 | - self.app = self.launch_test_application( |
1621 | - "/usr/lib/" + arch + "/qt5/bin/qmlscene", |
1622 | - "-I", get_module_include_path(), |
1623 | - qml_path, |
1624 | - app_type='qt') |
1625 | - |
1626 | - self.assertThat(self.get_qml_view().visible, Eventually(Equals(True))) |
1627 | - |
1628 | - |
1629 | - def get_qml_view(self): |
1630 | - """Get the main QML view""" |
1631 | - |
1632 | - return self.app.select_single("QQuickView") |
1633 | - |
1634 | - def get_mainview(self): |
1635 | - """Get the QML MainView""" |
1636 | - |
1637 | - mainView = self.app.select_single("MainView") |
1638 | - self.assertThat(mainView, Not(Is(None))) |
1639 | - return mainView |
1640 | - |
1641 | - |
1642 | - def get_object(self,objectName): |
1643 | - """Get a object based on the objectName""" |
1644 | - |
1645 | - obj = self.app.select_single(objectName=objectName) |
1646 | - self.assertThat(obj, Not(Is(None))) |
1647 | - return obj |
1648 | - |
1649 | - |
1650 | - def mouse_click(self,objectName): |
1651 | - """Move mouse on top of the object and click on it""" |
1652 | - |
1653 | - obj = self.get_object(objectName) |
1654 | - self.pointing_device.move_to_object(obj) |
1655 | - self.pointing_device.click() |
1656 | - |
1657 | - |
1658 | - def mouse_press(self,objectName): |
1659 | - """Move mouse on top of the object and press mouse button (without releasing it)""" |
1660 | - |
1661 | - obj = self.get_object(objectName) |
1662 | - self.pointing_device.move_to_object(obj) |
1663 | - self.pointing_device.press() |
1664 | - |
1665 | - |
1666 | - def mouse_release(self): |
1667 | - """Release mouse button""" |
1668 | - |
1669 | - self.pointing_device.release() |
1670 | - |
1671 | - |
1672 | - def type_string(self, string): |
1673 | - """Type a string with keyboard""" |
1674 | - |
1675 | - self.keyboard.type(string) |
1676 | - |
1677 | - |
1678 | - def type_key(self, key): |
1679 | - """Type a single key with keyboard""" |
1680 | - |
1681 | - self.keyboard.key(key) |
1682 | |
1683 | === removed directory 'tests/autopilot/ubuntu_push_qml/main' |
1684 | === removed file 'tests/autopilot/ubuntu_push_qml/main/__init__.py' |
1685 | --- tests/autopilot/ubuntu_push_qml/main/__init__.py 2014-07-25 08:43:31 +0000 |
1686 | +++ tests/autopilot/ubuntu_push_qml/main/__init__.py 1970-01-01 00:00:00 +0000 |
1687 | @@ -1,1 +0,0 @@ |
1688 | -""" A main.qml test suite """ |
1689 | |
1690 | === removed file 'tests/autopilot/ubuntu_push_qml/main/test_main.py' |
1691 | --- tests/autopilot/ubuntu_push_qml/main/test_main.py 2014-07-25 08:43:31 +0000 |
1692 | +++ tests/autopilot/ubuntu_push_qml/main/test_main.py 1970-01-01 00:00:00 +0000 |
1693 | @@ -1,23 +0,0 @@ |
1694 | -# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
1695 | - |
1696 | -"""Tests for the Hello World""" |
1697 | - |
1698 | -from autopilot.matchers import Eventually |
1699 | -from textwrap import dedent |
1700 | -from testtools.matchers import Is, Not, Equals |
1701 | -from testtools import skip |
1702 | -import os |
1703 | -from ubuntu_push_qml import UbuntuTouchAppTestCase |
1704 | - |
1705 | - |
1706 | -class MainTests(UbuntuTouchAppTestCase): |
1707 | - """Generic tests for the Hello World""" |
1708 | - |
1709 | - test_qml_file = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)),"../../../../../share/ubuntu-push-example/ubuntu-push-example.qml") |
1710 | - |
1711 | - def test_0_can_select_mainView(self): |
1712 | - """Must be able to select the mainview.""" |
1713 | - |
1714 | - mainView = self.get_mainview() |
1715 | - self.assertThat(mainView.visible,Eventually(Equals(True))) |
1716 | - |
1717 | |
1718 | === removed directory 'tests/unit' |
1719 | === removed file 'tests/unit/CMakeLists.txt' |
1720 | --- tests/unit/CMakeLists.txt 2014-07-25 08:43:31 +0000 |
1721 | +++ tests/unit/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1722 | @@ -1,36 +0,0 @@ |
1723 | -set(XVFB_COMMAND) |
1724 | -find_program(XVFBRUN xvfb-run) |
1725 | -if(XVFBRUN) |
1726 | - set(XVFB_COMMAND ${XVFBRUN} -s "-screen 0 640x480x24" -a) |
1727 | -else() |
1728 | - message(WARNING "Cannot find xvfb-run.") |
1729 | -endif() |
1730 | - |
1731 | -set(TEST tst_QmlTests) |
1732 | -add_executable(${TEST} tst_QmlTests.cpp) |
1733 | -qt5_use_modules(${TEST} Core Qml Quick Test QuickTest) |
1734 | -add_test(${TEST} ${XVFB_COMMAND} ${CMAKE_CURRENT_BINARY_DIR}/${TEST} -import ${CMAKE_BINARY_DIR}/src) |
1735 | - |
1736 | -# copy qml files under test to build dir |
1737 | -set(out_qml_files) |
1738 | -file(GLOB_RECURSE qmlFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.qml) |
1739 | -foreach(qmlFile ${qmlFiles}) |
1740 | - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/undertest/${qmlFile} |
1741 | - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${qmlFile} |
1742 | - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${qmlFile} ${CMAKE_CURRENT_BINARY_DIR}/undertest/${qmlFile}) |
1743 | - list(APPEND out_qml_files undertest/${qmlFile}) |
1744 | -endforeach(qmlFile) |
1745 | -add_custom_target(copy_qml_files_under_test_to_build_dir DEPENDS ${out_qml_files}) |
1746 | -add_dependencies(${TEST} copy_qml_files_under_test_to_build_dir) |
1747 | - |
1748 | -if(NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) |
1749 | - # copy qml test files to build dir |
1750 | - file(GLOB qmlTestFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.qml) |
1751 | - foreach(qmlTestFile ${qmlTestFiles}) |
1752 | - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${qmlTestFile} |
1753 | - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${qmlTestFile} |
1754 | - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${qmlTestFile} ${CMAKE_CURRENT_BINARY_DIR}/${qmlTestFile}) |
1755 | - endforeach(qmlTestFile) |
1756 | - add_custom_target(copy_qml_test_files_to_build_dir DEPENDS ${qmlTestFiles}) |
1757 | - add_dependencies(${TEST} copy_qml_test_files_to_build_dir) |
1758 | -endif() |
1759 | |
1760 | === removed file 'tests/unit/tst_QmlTests.cpp' |
1761 | --- tests/unit/tst_QmlTests.cpp 2014-07-25 08:43:31 +0000 |
1762 | +++ tests/unit/tst_QmlTests.cpp 1970-01-01 00:00:00 +0000 |
1763 | @@ -1,3 +0,0 @@ |
1764 | -#include <QtQuickTest/quicktest.h> |
1765 | -QUICK_TEST_MAIN(QmlTests) |
1766 | - |
1767 | |
1768 | === removed file 'tests/unit/tst_hellocomponent.qml' |
1769 | --- tests/unit/tst_hellocomponent.qml 2014-07-25 08:43:31 +0000 |
1770 | +++ tests/unit/tst_hellocomponent.qml 1970-01-01 00:00:00 +0000 |
1771 | @@ -1,40 +0,0 @@ |
1772 | -import QtQuick 2.0 |
1773 | -import QtTest 1.0 |
1774 | -import Ubuntu.Components 0.1 |
1775 | -import Ubuntu.PushNotifications 0.1 |
1776 | -import Ubuntu.ChatClientPushExample 0.1 |
1777 | - |
1778 | -// See more details @ http://qt-project.org/doc/qt-5.0/qtquick/qml-testcase.html |
1779 | - |
1780 | -// Execute tests with: |
1781 | -// qmltestrunner |
1782 | - |
1783 | -Item { |
1784 | - TestCase { |
1785 | - name: "HelloComponent" |
1786 | - |
1787 | - function init() { |
1788 | - console.debug(">> init"); |
1789 | - console.debug("<< init"); |
1790 | - } |
1791 | - |
1792 | - function cleanup() { |
1793 | - console.debug(">> cleanup"); |
1794 | - console.debug("<< cleanup"); |
1795 | - } |
1796 | - |
1797 | - function initTestCase() { |
1798 | - console.debug(">> initTestCase"); |
1799 | - console.debug("<< initTestCase"); |
1800 | - } |
1801 | - |
1802 | - function cleanupTestCase() { |
1803 | - console.debug(">> cleanupTestCase"); |
1804 | - console.debug("<< cleanupTestCase"); |
1805 | - } |
1806 | - |
1807 | - function test_canReadAndWriteText() { |
1808 | - compare("a","a","expected did not equal result"); |
1809 | - } |
1810 | - } |
1811 | -} |
FAILED: Continuous integration, rev:17 jenkins. qa.ubuntu. com/job/ ubuntu- push-qml- ci/5/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- utopic- touch/2969/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- utopic/ 2354/console jenkins. qa.ubuntu. com/job/ ubuntu- push-qml- utopic- amd64-ci/ 5/console jenkins. qa.ubuntu. com/job/ ubuntu- push-qml- utopic- armhf-ci/ 5/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- armhf/4212/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- utopic- amd64/2620/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- push-qml- ci/5/rebuild
http://