Merge lp:~zsombi/ubuntu-ui-toolkit/rtm-to-staging into lp:ubuntu-ui-toolkit/staging
- rtm-to-staging
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 1407 |
Merged at revision: | 1407 |
Proposed branch: | lp:~zsombi/ubuntu-ui-toolkit/rtm-to-staging |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
2582 lines (+352/-1002) 19 files modified
components.api (+78/-0) debian/changelog (+28/-0) modules/Ubuntu/Components/11/Haptics.qml (+181/-0) modules/Ubuntu/Components/AbstractButton.qml (+6/-12) modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml (+1/-6) modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.cpp (+0/-226) modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.h (+0/-55) modules/Ubuntu/Components/plugin/plugin.pro (+2/-2) modules/Ubuntu/Components/plugin/ucserviceproperties.cpp (+0/-317) modules/Ubuntu/Components/plugin/ucserviceproperties.h (+0/-83) modules/Ubuntu/Components/plugin/ucserviceproperties_p.h (+0/-53) modules/Ubuntu/Components/qmldir (+3/-0) tests/unit/runtest.sh (+1/-0) tests/unit/tst_components/tst_haptics.qml (+52/-0) tests/unit_x11/tst_serviceproperties/IncomingCallVibrateWatcher.qml (+0/-31) tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher.qml (+0/-31) tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher2.qml (+0/-32) tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp (+0/-146) tests/unit_x11/tst_serviceproperties/tst_serviceproperties.pro (+0/-8) |
To merge this branch: | bzr merge lp:~zsombi/ubuntu-ui-toolkit/rtm-to-staging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Zoltan Balogh | Approve | ||
Review via email: mp+249220@code.launchpad.net |
Commit message
RTM branch diff merge.
Description of the change
RTM branch diff merge.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1406
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1407
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'components.api' | |||
2 | --- components.api 2015-02-06 11:49:35 +0000 | |||
3 | +++ components.api 2015-02-11 08:57:32 +0000 | |||
4 | @@ -62,6 +62,11 @@ | |||
5 | 62 | property string fadeStyle | 62 | property string fadeStyle |
6 | 63 | readonly property bool running | 63 | readonly property bool running |
7 | 64 | readonly property int status | 64 | readonly property int status |
8 | 65 | Haptics 0.1 1.0 | ||
9 | 66 | Object | ||
10 | 67 | readonly property bool enabled | ||
11 | 68 | property HapticsEffect effect | ||
12 | 69 | function play(customEffect) | ||
13 | 65 | Header 0.1 1.0 | 70 | Header 0.1 1.0 |
14 | 66 | AppHeader | 71 | AppHeader |
15 | 67 | property string _for_autopilot | 72 | property string _for_autopilot |
16 | @@ -693,6 +698,64 @@ | |||
17 | 693 | name: "QAbstractProxyModel" | 698 | name: "QAbstractProxyModel" |
18 | 694 | prototype: "QAbstractItemModel" | 699 | prototype: "QAbstractItemModel" |
19 | 695 | Property { name: "sourceModel"; type: "QAbstractItemModel"; isPointer: true } | 700 | Property { name: "sourceModel"; type: "QAbstractItemModel"; isPointer: true } |
20 | 701 | name: "QDeclarativeFeedbackActuator" | ||
21 | 702 | prototype: "QObject" | ||
22 | 703 | exports: ["QtFeedback/Actuator 5.0"] | ||
23 | 704 | name: "Capability" | ||
24 | 705 | name: "State" | ||
25 | 706 | Property { name: "actuatorId"; type: "int"; isReadonly: true } | ||
26 | 707 | Property { name: "name"; type: "string"; isReadonly: true } | ||
27 | 708 | Property { name: "state"; type: "State"; isReadonly: true } | ||
28 | 709 | Property { name: "valid"; type: "bool"; isReadonly: true } | ||
29 | 710 | Property { name: "enabled"; type: "bool" } | ||
30 | 711 | Method { | ||
31 | 712 | name: "isCapabilitySupported" | ||
32 | 713 | Parameter { name: "capability"; type: "Capability" } | ||
33 | 714 | name: "QDeclarativeFeedbackEffect" | ||
34 | 715 | prototype: "QObject" | ||
35 | 716 | exports: ["QtFeedback/Feedback 5.0", "QtFeedback/FeedbackEffect 5.0"] | ||
36 | 717 | name: "Duration" | ||
37 | 718 | name: "State" | ||
38 | 719 | name: "ErrorType" | ||
39 | 720 | Property { name: "running"; type: "bool" } | ||
40 | 721 | Property { name: "paused"; type: "bool" } | ||
41 | 722 | Property { name: "duration"; type: "int" } | ||
42 | 723 | Property { name: "state"; type: "State" } | ||
43 | 724 | Property { name: "error"; type: "ErrorType"; isReadonly: true } | ||
44 | 725 | Method { name: "updateState" } | ||
45 | 726 | Method { name: "start" } | ||
46 | 727 | Method { name: "stop" } | ||
47 | 728 | Method { name: "pause" } | ||
48 | 729 | name: "QDeclarativeFileEffect" | ||
49 | 730 | prototype: "QDeclarativeFeedbackEffect" | ||
50 | 731 | exports: ["QtFeedback/FileEffect 5.0"] | ||
51 | 732 | Property { name: "loaded"; type: "bool" } | ||
52 | 733 | Property { name: "source"; type: "QUrl" } | ||
53 | 734 | Property { name: "supportedMimeTypes"; type: "QStringList"; isReadonly: true } | ||
54 | 735 | Method { name: "load" } | ||
55 | 736 | Method { name: "unload" } | ||
56 | 737 | name: "QDeclarativeHapticsEffect" | ||
57 | 738 | prototype: "QDeclarativeFeedbackEffect" | ||
58 | 739 | exports: ["QtFeedback/HapticsEffect 5.0"] | ||
59 | 740 | Property { | ||
60 | 741 | name: "availableActuators" | ||
61 | 742 | Property { name: "intensity"; type: "double" } | ||
62 | 743 | Property { name: "attackTime"; type: "int" } | ||
63 | 744 | Property { name: "attackIntensity"; type: "double" } | ||
64 | 745 | Property { name: "fadeTime"; type: "int" } | ||
65 | 746 | Property { name: "fadeIntensity"; type: "double" } | ||
66 | 747 | Property { name: "period"; type: "int" } | ||
67 | 748 | Property { name: "actuator"; type: "QDeclarativeFeedbackActuator"; isPointer: true } | ||
68 | 749 | name: "QDeclarativeThemeEffect" | ||
69 | 750 | prototype: "QObject" | ||
70 | 751 | exports: ["QtFeedback/EffectPlayer 5.0", "QtFeedback/ThemeEffect 5.0"] | ||
71 | 752 | name: "Effect" | ||
72 | 753 | Property { name: "supported"; type: "bool"; isReadonly: true } | ||
73 | 754 | Property { name: "effect"; type: "Effect" } | ||
74 | 755 | Method { name: "play" } | ||
75 | 756 | Method { | ||
76 | 757 | name: "play" | ||
77 | 758 | Parameter { name: "effect"; type: "Effect" } | ||
78 | 696 | name: "QSortFilterProxyModel" | 759 | name: "QSortFilterProxyModel" |
79 | 697 | prototype: "QAbstractProxyModel" | 760 | prototype: "QAbstractProxyModel" |
80 | 698 | Property { name: "filterRegExp"; type: "QRegExp" } | 761 | Property { name: "filterRegExp"; type: "QRegExp" } |
81 | @@ -1056,6 +1119,21 @@ | |||
82 | 1056 | name: "tag" | 1119 | name: "tag" |
83 | 1057 | Parameter { name: "context"; type: "string" } | 1120 | Parameter { name: "context"; type: "string" } |
84 | 1058 | Parameter { name: "text"; type: "string" } | 1121 | Parameter { name: "text"; type: "string" } |
85 | 1122 | prototype: "QObject" | ||
86 | 1123 | name: "Haptics" | ||
87 | 1124 | exports: ["Haptics -1.-1"] | ||
88 | 1125 | Property { name: "enabled"; type: "bool"; isReadonly: true } | ||
89 | 1126 | Property { name: "effect"; type: "QDeclarativeHapticsEffect"; isReadonly: true; isPointer: true } | ||
90 | 1127 | Method { | ||
91 | 1128 | name: "play" | ||
92 | 1129 | Parameter { name: "customEffect"; type: "QVariant" } | ||
93 | 1130 | Property { name: "__defaultPropertyFix"; type: "QObject"; isList: true; isReadonly: true } | ||
94 | 1131 | Property { name: "children"; type: "QObject"; isList: true; isReadonly: true } | ||
95 | 1132 | prototype: "QObject" | ||
96 | 1133 | name: "Object" | ||
97 | 1134 | exports: ["Object -1.-1"] | ||
98 | 1135 | Property { name: "__defaultPropertyFix"; type: "QObject"; isList: true; isReadonly: true } | ||
99 | 1136 | Property { name: "children"; type: "QObject"; isList: true; isReadonly: true } | ||
100 | 1059 | name: "ULConditionalLayout" | 1137 | name: "ULConditionalLayout" |
101 | 1060 | prototype: "QObject" | 1138 | prototype: "QObject" |
102 | 1061 | exports: ["ConditionalLayout 0.1", "ConditionalLayout 1.0"] | 1139 | exports: ["ConditionalLayout 0.1", "ConditionalLayout 1.0"] |
103 | 1062 | 1140 | ||
104 | === modified file 'debian/changelog' | |||
105 | --- debian/changelog 2015-01-14 13:51:28 +0000 | |||
106 | +++ debian/changelog 2015-02-11 08:57:32 +0000 | |||
107 | @@ -227,6 +227,34 @@ | |||
108 | 227 | 227 | ||
109 | 228 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Sun, 02 Nov 2014 13:01:56 +0000 | 228 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Sun, 02 Nov 2014 13:01:56 +0000 |
110 | 229 | 229 | ||
111 | 230 | ubuntu-ui-toolkit (1.1.1298+15.04.20150209~rtm-0ubuntu1) 14.09; urgency=medium | ||
112 | 231 | |||
113 | 232 | [ Zsombor Egri ] | ||
114 | 233 | * isHapticsFeedbackEnabled context property exposed to drive | ||
115 | 234 | HapticsFeedback in AbstractButton. (LP: #1391877) | ||
116 | 235 | * Haptics singleton component to provide toolkit wide default and | ||
117 | 236 | custom feedback functionaity controlled by system settings. (LP: | ||
118 | 237 | #1391877) | ||
119 | 238 | |||
120 | 239 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 09 Feb 2015 13:10:45 +0000 | ||
121 | 240 | |||
122 | 241 | ubuntu-ui-toolkit (1.1.1298+15.04.20150202~rtm-0ubuntu1) 14.09; urgency=medium | ||
123 | 242 | |||
124 | 243 | [ Tim Peeters ] | ||
125 | 244 | * Port "In Progress" translation fix from staging to rtm. (LP: | ||
126 | 245 | #1391617, #1081607) | ||
127 | 246 | |||
128 | 247 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 02 Feb 2015 09:11:21 +0000 | ||
129 | 248 | |||
130 | 249 | ubuntu-ui-toolkit (1.1.1298+15.04.20150116~rtm-0ubuntu1) 14.09; urgency=low | ||
131 | 250 | |||
132 | 251 | [ Florian Boucault ] | ||
133 | 252 | * ActivityIndicator: make its animation rely solely on the rendering | ||
134 | 253 | thread so that it does not stop spinning if the main thread is | ||
135 | 254 | blocked. (LP: #1411376) | ||
136 | 255 | |||
137 | 256 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Fri, 16 Jan 2015 10:17:50 +0000 | ||
138 | 257 | |||
139 | 230 | ubuntu-ui-toolkit (1.1.1298+15.04.20141111.2~rtm-0ubuntu1) 14.09; urgency=low | 258 | ubuntu-ui-toolkit (1.1.1298+15.04.20141111.2~rtm-0ubuntu1) 14.09; urgency=low |
140 | 231 | 259 | ||
141 | 232 | [ Ubuntu daily release ] | 260 | [ Ubuntu daily release ] |
142 | 233 | 261 | ||
143 | === added file 'modules/Ubuntu/Components/11/Haptics.qml' | |||
144 | --- modules/Ubuntu/Components/11/Haptics.qml 1970-01-01 00:00:00 +0000 | |||
145 | +++ modules/Ubuntu/Components/11/Haptics.qml 2015-02-11 08:57:32 +0000 | |||
146 | @@ -0,0 +1,181 @@ | |||
147 | 1 | /* | ||
148 | 2 | * Copyright 2014 Canonical Ltd. | ||
149 | 3 | * | ||
150 | 4 | * This program is free software; you can redistribute it and/or modify | ||
151 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
152 | 6 | * the Free Software Foundation; version 3. | ||
153 | 7 | * | ||
154 | 8 | * This program is distributed in the hope that it will be useful, | ||
155 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
156 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
157 | 11 | * GNU Lesser General Public License for more details. | ||
158 | 12 | * | ||
159 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
160 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
161 | 15 | */ | ||
162 | 16 | |||
163 | 17 | pragma Singleton | ||
164 | 18 | import QtQuick 2.0 | ||
165 | 19 | import QtFeedback 5.0 | ||
166 | 20 | import Ubuntu.Components 1.1 | ||
167 | 21 | |||
168 | 22 | /*! | ||
169 | 23 | \qmltype Haptics | ||
170 | 24 | \inqmlmodule Ubuntu.Components 1.1 | ||
171 | 25 | \ingroup ubuntu-services | ||
172 | 26 | \brief Singleton defining the haptics feedback used in components, where execution | ||
173 | 27 | of the feedback is controlled by the system settings. | ||
174 | 28 | |||
175 | 29 | Supports global feedback as well as custom feedback. Global feedback can be | ||
176 | 30 | configured through its properties, and \l play function will play the default | ||
177 | 31 | configuration, or a custom one if parameter is given. | ||
178 | 32 | |||
179 | 33 | Example of using Haptics: | ||
180 | 34 | \qml | ||
181 | 35 | import QtQuick 2.3 | ||
182 | 36 | import Ubuntu.Components 1.1 | ||
183 | 37 | |||
184 | 38 | Item { | ||
185 | 39 | implicitWidth: units.gu(20) | ||
186 | 40 | implicitHeight: units.gu(5) | ||
187 | 41 | |||
188 | 42 | Label { | ||
189 | 43 | text: "Press me" | ||
190 | 44 | anchors.fill: parent | ||
191 | 45 | horizontalAlignment: Text.AlignHCenter | ||
192 | 46 | verticalAlignment: Text.AlignVCenter | ||
193 | 47 | } | ||
194 | 48 | MouseArea { | ||
195 | 49 | anchors.fill: parent | ||
196 | 50 | onClicked: Haptics.play() | ||
197 | 51 | } | ||
198 | 52 | } | ||
199 | 53 | \endqml | ||
200 | 54 | |||
201 | 55 | Custom effects can be played as follows: | ||
202 | 56 | \qml | ||
203 | 57 | import QtQuick 2.3 | ||
204 | 58 | import Ubuntu.Components 1.1 | ||
205 | 59 | |||
206 | 60 | Item { | ||
207 | 61 | implicitWidth: units.gu(20) | ||
208 | 62 | implicitHeight: units.gu(5) | ||
209 | 63 | |||
210 | 64 | Label { | ||
211 | 65 | text: "Press me" | ||
212 | 66 | anchors.fill: parent | ||
213 | 67 | horizontalAlignment: Text.AlignHCenter | ||
214 | 68 | verticalAlignment: Text.AlignVCenter | ||
215 | 69 | } | ||
216 | 70 | MouseArea { | ||
217 | 71 | anchors.fill: parent | ||
218 | 72 | onClicked: Haptics.play({duration: 25, attackIntensity: 0.7}) | ||
219 | 73 | } | ||
220 | 74 | } | ||
221 | 75 | \endqml | ||
222 | 76 | |||
223 | 77 | \note Though the \l effect property exposes \c start, \c stop and \c pause | ||
224 | 78 | functions, use those only if you want to have feedback independent on what the | ||
225 | 79 | system setting is. | ||
226 | 80 | */ | ||
227 | 81 | Object { | ||
228 | 82 | |||
229 | 83 | /*! | ||
230 | 84 | \qmlproperty bool enabled | ||
231 | 85 | \readonly | ||
232 | 86 | The property specifies whether the haptics feedback is enabled or not by the system. | ||
233 | 87 | */ | ||
234 | 88 | readonly property alias enabled: vibra.otherVibrate | ||
235 | 89 | |||
236 | 90 | /*! | ||
237 | 91 | \qmlproperty HapticsEffect effect | ||
238 | 92 | The property defines the settings of the haptics effect used by the component. | ||
239 | 93 | The default setting is a haptics effect with a duration of 10 milliseconds | ||
240 | 94 | with an intensity of 1.0, having fading time of 50 millisecods and fading | ||
241 | 95 | intensity 0.0, and attack time of 50 milliseconds and with an intensity of | ||
242 | 96 | 0.0. | ||
243 | 97 | */ | ||
244 | 98 | property alias effect: effect | ||
245 | 99 | |||
246 | 100 | /*! | ||
247 | 101 | \qmlmethod play([customEffect]) | ||
248 | 102 | The function plays the feedback with the configuration specified in \l effect | ||
249 | 103 | if no parameter is given. Custom effect can be played by specifying the effect | ||
250 | 104 | properties in a JSON object in \c customEffect. | ||
251 | 105 | |||
252 | 106 | The function will exit unconditionaly if playing the effects is blocked by | ||
253 | 107 | system settings. | ||
254 | 108 | |||
255 | 109 | The function will not stop any ongoing haptics effect played, if that one | ||
256 | 110 | was a default haptics effect. In case of custom effects, the previous effect | ||
257 | 111 | will be stopped, and settings will be restored before the new haptics will | ||
258 | 112 | be played. The custom settings properties (the ones which are required to | ||
259 | 113 | be different from the ones defined in the \l effect) must be specified in | ||
260 | 114 | the parameter in a JSON object. | ||
261 | 115 | */ | ||
262 | 116 | function play(customEffect) { | ||
263 | 117 | if (!vibra.otherVibrate) { | ||
264 | 118 | return; | ||
265 | 119 | } | ||
266 | 120 | if (effectData.data) { | ||
267 | 121 | // we have a custom effect playing, stop it | ||
268 | 122 | effect.stop(); | ||
269 | 123 | } | ||
270 | 124 | if (effect.running) { | ||
271 | 125 | // this is a global effect, leave | ||
272 | 126 | return; | ||
273 | 127 | } | ||
274 | 128 | if (customEffect) { | ||
275 | 129 | effectData.backup(customEffect); | ||
276 | 130 | } | ||
277 | 131 | effect.start(); | ||
278 | 132 | } | ||
279 | 133 | |||
280 | 134 | QtObject { | ||
281 | 135 | id: effectData | ||
282 | 136 | property var data | ||
283 | 137 | |||
284 | 138 | function backup(customEffect) { | ||
285 | 139 | data = customEffect; | ||
286 | 140 | for (var p in data) { | ||
287 | 141 | var value = data[p]; | ||
288 | 142 | data[p] = effect[p]; | ||
289 | 143 | effect[p] = value; | ||
290 | 144 | } | ||
291 | 145 | } | ||
292 | 146 | function restore() { | ||
293 | 147 | for (var p in data) { | ||
294 | 148 | effect[p] = data[p]; | ||
295 | 149 | } | ||
296 | 150 | data = undefined; | ||
297 | 151 | } | ||
298 | 152 | } | ||
299 | 153 | |||
300 | 154 | // local feedback component used to play feedback | ||
301 | 155 | HapticsEffect { | ||
302 | 156 | id: effect | ||
303 | 157 | attackIntensity: 0.0 | ||
304 | 158 | attackTime: 50 | ||
305 | 159 | intensity: 1.0 | ||
306 | 160 | duration: 10 | ||
307 | 161 | fadeTime: 50 | ||
308 | 162 | fadeIntensity: 0.0 | ||
309 | 163 | |||
310 | 164 | onStateChanged: { | ||
311 | 165 | if (state == HapticsEffect.Stopped) { | ||
312 | 166 | effectData.restore(); | ||
313 | 167 | } | ||
314 | 168 | } | ||
315 | 169 | } | ||
316 | 170 | |||
317 | 171 | // watch system settings for otherVibrate | ||
318 | 172 | ServiceProperties { | ||
319 | 173 | objectName: "system_effect_settings" | ||
320 | 174 | id: vibra | ||
321 | 175 | service: "org.freedesktop.Accounts" | ||
322 | 176 | serviceInterface: "org.freedesktop.Accounts" | ||
323 | 177 | path: "/org/freedesktop/Accounts" | ||
324 | 178 | adaptorInterface: "com.ubuntu.touch.AccountsService.Sound" | ||
325 | 179 | property bool otherVibrate: true | ||
326 | 180 | } | ||
327 | 181 | } | ||
328 | 0 | 182 | ||
329 | === modified file 'modules/Ubuntu/Components/AbstractButton.qml' | |||
330 | --- modules/Ubuntu/Components/AbstractButton.qml 2014-12-03 14:43:27 +0000 | |||
331 | +++ modules/Ubuntu/Components/AbstractButton.qml 2015-02-11 08:57:32 +0000 | |||
332 | @@ -15,7 +15,6 @@ | |||
333 | 15 | */ | 15 | */ |
334 | 16 | 16 | ||
335 | 17 | import QtQuick 2.0 | 17 | import QtQuick 2.0 |
336 | 18 | import QtFeedback 5.0 | ||
337 | 19 | import Ubuntu.Components 1.1 | 18 | import Ubuntu.Components 1.1 |
338 | 20 | 19 | ||
339 | 21 | /*! | 20 | /*! |
340 | @@ -83,16 +82,6 @@ | |||
341 | 83 | 82 | ||
342 | 84 | activeFocusOnPress: true | 83 | activeFocusOnPress: true |
343 | 85 | 84 | ||
344 | 86 | HapticsEffect { | ||
345 | 87 | id: pressEffect | ||
346 | 88 | attackIntensity: 0.0 | ||
347 | 89 | attackTime: 50 | ||
348 | 90 | intensity: 1.0 | ||
349 | 91 | duration: 10 | ||
350 | 92 | fadeTime: 50 | ||
351 | 93 | fadeIntensity: 0.0 | ||
352 | 94 | } | ||
353 | 95 | |||
354 | 96 | MouseArea { | 85 | MouseArea { |
355 | 97 | id: mouseArea | 86 | id: mouseArea |
356 | 98 | anchors.fill: parent | 87 | anchors.fill: parent |
357 | @@ -100,9 +89,14 @@ | |||
358 | 100 | // as it might occlude the newly assigned mouse area. | 89 | // as it might occlude the newly assigned mouse area. |
359 | 101 | hoverEnabled: true | 90 | hoverEnabled: true |
360 | 102 | 91 | ||
361 | 92 | // invoke Haptics singleton earlier than we press the button, | ||
362 | 93 | // so we give some time for the singleton to sync settings with the service | ||
363 | 94 | property bool hapticsEnabled: Haptics.enabled | ||
364 | 95 | |||
365 | 103 | onClicked: { | 96 | onClicked: { |
366 | 104 | if (button.__acceptEvents) { | 97 | if (button.__acceptEvents) { |
368 | 105 | pressEffect.start() | 98 | // FIXME (Vivid) call this in the style rather than from AbstractButton |
369 | 99 | Haptics.play(); | ||
370 | 106 | button.clicked() | 100 | button.clicked() |
371 | 107 | } | 101 | } |
372 | 108 | } | 102 | } |
373 | 109 | 103 | ||
374 | === modified file 'modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml' | |||
375 | --- modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml 2014-07-08 10:59:01 +0000 | |||
376 | +++ modules/Ubuntu/Components/Themes/Ambiance/ActivityIndicatorStyle.qml 2015-02-11 08:57:32 +0000 | |||
377 | @@ -28,12 +28,7 @@ | |||
378 | 28 | verticalAlignment: Image.AlignVCenter | 28 | verticalAlignment: Image.AlignVCenter |
379 | 29 | source: "artwork/spinner.png" | 29 | source: "artwork/spinner.png" |
380 | 30 | 30 | ||
387 | 31 | /* | 31 | RotationAnimator on rotation { |
382 | 32 | Changed from RotationAnimator to RotationAnimation to | ||
383 | 33 | work around bug: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1338602 | ||
384 | 34 | "Activity Indicator crashes in QML/Widget mixed applications" | ||
385 | 35 | */ | ||
386 | 36 | RotationAnimation on rotation { | ||
388 | 37 | running: styledItem.running | 32 | running: styledItem.running |
389 | 38 | from: 0 | 33 | from: 0 |
390 | 39 | to: 360 | 34 | to: 360 |
391 | 40 | 35 | ||
392 | === added file 'modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.cpp' | |||
393 | --- modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.cpp 1970-01-01 00:00:00 +0000 | |||
394 | +++ modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.cpp 2015-02-11 08:57:32 +0000 | |||
395 | @@ -0,0 +1,226 @@ | |||
396 | 1 | /* | ||
397 | 2 | * Copyright 2014 Canonical Ltd. | ||
398 | 3 | * | ||
399 | 4 | * This program is free software; you can redistribute it and/or modify | ||
400 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
401 | 6 | * the Free Software Foundation; version 3. | ||
402 | 7 | * | ||
403 | 8 | * This program is distributed in the hope that it will be useful, | ||
404 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
405 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
406 | 11 | * GNU Lesser General Public License for more details. | ||
407 | 12 | * | ||
408 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
409 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
410 | 15 | */ | ||
411 | 16 | |||
412 | 17 | #include "dbuspropertywatcher_p.h" | ||
413 | 18 | #include <QtDBus/QDBusReply> | ||
414 | 19 | #include <unistd.h> | ||
415 | 20 | #include <sys/types.h> | ||
416 | 21 | #include "i18n.h" | ||
417 | 22 | #include <QtQml/QQmlInfo> | ||
418 | 23 | |||
419 | 24 | #define DYNAMIC_PROPERTY "__q_property" | ||
420 | 25 | |||
421 | 26 | UCServicePropertiesPrivate *createServicePropertiesAdapter(UCServiceProperties *owner) | ||
422 | 27 | { | ||
423 | 28 | return new DBusServiceProperties(owner); | ||
424 | 29 | } | ||
425 | 30 | |||
426 | 31 | DBusServiceProperties::DBusServiceProperties(UCServiceProperties *qq) | ||
427 | 32 | : UCServicePropertiesPrivate(qq) | ||
428 | 33 | , connection("") | ||
429 | 34 | , watcher(0) | ||
430 | 35 | , iface(0) | ||
431 | 36 | { | ||
432 | 37 | } | ||
433 | 38 | |||
434 | 39 | bool DBusServiceProperties::init() | ||
435 | 40 | { | ||
436 | 41 | // crear previous connections | ||
437 | 42 | setStatus(UCServiceProperties::Inactive); | ||
438 | 43 | delete iface; | ||
439 | 44 | iface = 0; | ||
440 | 45 | delete watcher; | ||
441 | 46 | watcher = 0; | ||
442 | 47 | setError(QString()); | ||
443 | 48 | |||
444 | 49 | if (service.isEmpty() || path.isEmpty()) { | ||
445 | 50 | setStatus(UCServiceProperties::ConnectionError); | ||
446 | 51 | setError(UbuntuI18n::instance().tr("No service/path specified")); | ||
447 | 52 | return false; | ||
448 | 53 | } | ||
449 | 54 | |||
450 | 55 | switch (type) { | ||
451 | 56 | case UCServiceProperties::System: | ||
452 | 57 | { | ||
453 | 58 | connection = QDBusConnection::systemBus(); | ||
454 | 59 | break; | ||
455 | 60 | } | ||
456 | 61 | case UCServiceProperties::Session: | ||
457 | 62 | { | ||
458 | 63 | connection = QDBusConnection::sessionBus(); | ||
459 | 64 | break; | ||
460 | 65 | } | ||
461 | 66 | default: | ||
462 | 67 | { | ||
463 | 68 | setStatus(UCServiceProperties::ConnectionError); | ||
464 | 69 | setError(UbuntuI18n::instance().tr("Invalid bus type: %1.").arg(type)); | ||
465 | 70 | return false; | ||
466 | 71 | } | ||
467 | 72 | } | ||
468 | 73 | |||
469 | 74 | Q_Q(UCServiceProperties); | ||
470 | 75 | // connect dbus watcher to catch OwnerChanged | ||
471 | 76 | watcher = new QDBusServiceWatcher(service, connection, QDBusServiceWatcher::WatchForOwnerChange, q); | ||
472 | 77 | // connect interface | ||
473 | 78 | iface = new QDBusInterface(service, path, interface, connection, q); | ||
474 | 79 | if (!iface->isValid()) { | ||
475 | 80 | setStatus(UCServiceProperties::ConnectionError); | ||
476 | 81 | setError(iface->lastError().message()); | ||
477 | 82 | return false; | ||
478 | 83 | } | ||
479 | 84 | // connect watcher to get owner changes | ||
480 | 85 | QObject::connect(watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), | ||
481 | 86 | this, SLOT(changeServiceOwner(QString,QString,QString))); | ||
482 | 87 | return setupInterface(); | ||
483 | 88 | } | ||
484 | 89 | |||
485 | 90 | /* | ||
486 | 91 | * Connect dbus signal identified by (service, path, iface, name) quaduple to a | ||
487 | 92 | * slot to receive property changes. | ||
488 | 93 | */ | ||
489 | 94 | bool DBusServiceProperties::setupInterface() | ||
490 | 95 | { | ||
491 | 96 | QDBusReply<QDBusObjectPath> dbusObjectPath = iface->call("FindUserById", qlonglong(getuid())); | ||
492 | 97 | if (dbusObjectPath.isValid()) { | ||
493 | 98 | objectPath = dbusObjectPath.value().path(); | ||
494 | 99 | iface->connection().connect( | ||
495 | 100 | service, | ||
496 | 101 | objectPath, | ||
497 | 102 | "org.freedesktop.DBus.Properties", | ||
498 | 103 | "PropertiesChanged", | ||
499 | 104 | this, | ||
500 | 105 | SLOT(updateProperties(QString,QVariantMap,QStringList))); | ||
501 | 106 | return true; | ||
502 | 107 | } | ||
503 | 108 | |||
504 | 109 | setStatus(UCServiceProperties::ConnectionError); | ||
505 | 110 | setError(dbusObjectPath.error().message()); | ||
506 | 111 | return false; | ||
507 | 112 | } | ||
508 | 113 | |||
509 | 114 | bool DBusServiceProperties::fetchPropertyValues() | ||
510 | 115 | { | ||
511 | 116 | scannedProperties = properties; | ||
512 | 117 | Q_FOREACH(QString property, properties) { | ||
513 | 118 | readProperty(property); | ||
514 | 119 | } | ||
515 | 120 | return true; | ||
516 | 121 | } | ||
517 | 122 | |||
518 | 123 | /* | ||
519 | 124 | * Reads a property value from the adaptorInterface asynchronously. | ||
520 | 125 | */ | ||
521 | 126 | bool DBusServiceProperties::readProperty(const QString &property) | ||
522 | 127 | { | ||
523 | 128 | if ((status < UCServiceProperties::Synchronizing) || objectPath.isEmpty()) { | ||
524 | 129 | return false; | ||
525 | 130 | } | ||
526 | 131 | Q_Q(UCServiceProperties); | ||
527 | 132 | QDBusInterface readIFace(iface->interface(), objectPath, "org.freedesktop.DBus.Properties", connection); | ||
528 | 133 | if (!readIFace.isValid()) { | ||
529 | 134 | // report invalid interface only if the property's first letter was with capital one! | ||
530 | 135 | if (property[0].isUpper()) { | ||
531 | 136 | warning(readIFace.lastError().message()); | ||
532 | 137 | } | ||
533 | 138 | return false; | ||
534 | 139 | } | ||
535 | 140 | QDBusPendingCall pending = readIFace.asyncCall("Get", adaptor, property); | ||
536 | 141 | if (pending.isError()) { | ||
537 | 142 | warning(pending.error().message()); | ||
538 | 143 | return false; | ||
539 | 144 | } | ||
540 | 145 | QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pending, q); | ||
541 | 146 | QObject::connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), | ||
542 | 147 | this, SLOT(readFinished(QDBusPendingCallWatcher*))); | ||
543 | 148 | |||
544 | 149 | // set a dynamic property so we know which property are we reading | ||
545 | 150 | callWatcher->setProperty(DYNAMIC_PROPERTY, property); | ||
546 | 151 | return true; | ||
547 | 152 | } | ||
548 | 153 | |||
549 | 154 | /* | ||
550 | 155 | * Writes a property value to theadaptorInterface synchronously. It is for pure testing purposes. | ||
551 | 156 | */ | ||
552 | 157 | bool DBusServiceProperties::testProperty(const QString &property, const QVariant &value) | ||
553 | 158 | { | ||
554 | 159 | if (objectPath.isEmpty()) { | ||
555 | 160 | return false; | ||
556 | 161 | } | ||
557 | 162 | QDBusInterface writeIFace(iface->interface(), objectPath, "org.freedesktop.DBus.Properties", connection); | ||
558 | 163 | if (!writeIFace.isValid()) { | ||
559 | 164 | // invalid interface | ||
560 | 165 | return false; | ||
561 | 166 | } | ||
562 | 167 | QDBusMessage msg = writeIFace.call("Set", adaptor, property, QVariant::fromValue(QDBusVariant(value))); | ||
563 | 168 | return msg.type() == QDBusMessage::ReplyMessage; | ||
564 | 169 | } | ||
565 | 170 | |||
566 | 171 | /* | ||
567 | 172 | * Slot called when the async read operation finishes. | ||
568 | 173 | */ | ||
569 | 174 | void DBusServiceProperties::readFinished(QDBusPendingCallWatcher *call) | ||
570 | 175 | { | ||
571 | 176 | Q_Q(UCServiceProperties); | ||
572 | 177 | QDBusPendingReply<QVariant> reply = *call; | ||
573 | 178 | QString property = call->property(DYNAMIC_PROPERTY).toString(); | ||
574 | 179 | scannedProperties.removeAll(property); | ||
575 | 180 | if (reply.isError()) { | ||
576 | 181 | // remove the property from being watched, as it has no property like that | ||
577 | 182 | properties.removeAll(property); | ||
578 | 183 | if (property[0].isUpper()) { | ||
579 | 184 | // report error! | ||
580 | 185 | warning(reply.error().message()); | ||
581 | 186 | } | ||
582 | 187 | } else { | ||
583 | 188 | // update watched property value | ||
584 | 189 | // make sure we have lower case when the property value is updated | ||
585 | 190 | property[0] = property[0].toLower(); | ||
586 | 191 | q->setProperty(property.toLocal8Bit().constData(), reply.value()); | ||
587 | 192 | } | ||
588 | 193 | |||
589 | 194 | if ((status == UCServiceProperties::Synchronizing) && scannedProperties.isEmpty()) { | ||
590 | 195 | // set status to active | ||
591 | 196 | setStatus(UCServiceProperties::Active); | ||
592 | 197 | } | ||
593 | 198 | |||
594 | 199 | // delete watcher | ||
595 | 200 | call->deleteLater(); | ||
596 | 201 | } | ||
597 | 202 | |||
598 | 203 | /* | ||
599 | 204 | * Slot called when service owner is changed. | ||
600 | 205 | */ | ||
601 | 206 | void DBusServiceProperties::changeServiceOwner(const QString &serviceName, const QString &oldOwner, const QString &newOwner) | ||
602 | 207 | { | ||
603 | 208 | Q_UNUSED(oldOwner); | ||
604 | 209 | Q_UNUSED(newOwner); | ||
605 | 210 | if (serviceName != service) { | ||
606 | 211 | return; | ||
607 | 212 | } | ||
608 | 213 | setupInterface(); | ||
609 | 214 | } | ||
610 | 215 | |||
611 | 216 | /* | ||
612 | 217 | * Slot called when the properties are changed in the service. | ||
613 | 218 | */ | ||
614 | 219 | void DBusServiceProperties::updateProperties(const QString &onInterface, const QVariantMap &map, const QStringList &invalidated) | ||
615 | 220 | { | ||
616 | 221 | Q_UNUSED(onInterface); | ||
617 | 222 | Q_UNUSED(map); | ||
618 | 223 | Q_FOREACH(const QString &property, invalidated) { | ||
619 | 224 | readProperty(property); | ||
620 | 225 | } | ||
621 | 226 | } | ||
622 | 0 | 227 | ||
623 | === removed file 'modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.cpp' | |||
624 | --- modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.cpp 2014-12-03 08:26:33 +0000 | |||
625 | +++ modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.cpp 1970-01-01 00:00:00 +0000 | |||
626 | @@ -1,226 +0,0 @@ | |||
627 | 1 | /* | ||
628 | 2 | * Copyright 2014 Canonical Ltd. | ||
629 | 3 | * | ||
630 | 4 | * This program is free software; you can redistribute it and/or modify | ||
631 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
632 | 6 | * the Free Software Foundation; version 3. | ||
633 | 7 | * | ||
634 | 8 | * This program is distributed in the hope that it will be useful, | ||
635 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
636 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
637 | 11 | * GNU Lesser General Public License for more details. | ||
638 | 12 | * | ||
639 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
640 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
641 | 15 | */ | ||
642 | 16 | |||
643 | 17 | #include "dbuspropertywatcher_p.h" | ||
644 | 18 | #include <QtDBus/QDBusReply> | ||
645 | 19 | #include <unistd.h> | ||
646 | 20 | #include <sys/types.h> | ||
647 | 21 | #include "i18n.h" | ||
648 | 22 | #include <QtQml/QQmlInfo> | ||
649 | 23 | |||
650 | 24 | #define DYNAMIC_PROPERTY "__q_property" | ||
651 | 25 | |||
652 | 26 | UCServicePropertiesPrivate *createServicePropertiesAdapter(UCServiceProperties *owner) | ||
653 | 27 | { | ||
654 | 28 | return new DBusServiceProperties(owner); | ||
655 | 29 | } | ||
656 | 30 | |||
657 | 31 | DBusServiceProperties::DBusServiceProperties(UCServiceProperties *qq) | ||
658 | 32 | : UCServicePropertiesPrivate(qq) | ||
659 | 33 | , connection("") | ||
660 | 34 | , watcher(0) | ||
661 | 35 | , iface(0) | ||
662 | 36 | { | ||
663 | 37 | } | ||
664 | 38 | |||
665 | 39 | bool DBusServiceProperties::init() | ||
666 | 40 | { | ||
667 | 41 | // crear previous connections | ||
668 | 42 | setStatus(UCServiceProperties::Inactive); | ||
669 | 43 | delete iface; | ||
670 | 44 | iface = 0; | ||
671 | 45 | delete watcher; | ||
672 | 46 | watcher = 0; | ||
673 | 47 | setError(QString()); | ||
674 | 48 | |||
675 | 49 | if (service.isEmpty() || path.isEmpty()) { | ||
676 | 50 | setStatus(UCServiceProperties::ConnectionError); | ||
677 | 51 | setError(UbuntuI18n::instance().tr("No service/path specified")); | ||
678 | 52 | return false; | ||
679 | 53 | } | ||
680 | 54 | |||
681 | 55 | switch (type) { | ||
682 | 56 | case UCServiceProperties::System: | ||
683 | 57 | { | ||
684 | 58 | connection = QDBusConnection::systemBus(); | ||
685 | 59 | break; | ||
686 | 60 | } | ||
687 | 61 | case UCServiceProperties::Session: | ||
688 | 62 | { | ||
689 | 63 | connection = QDBusConnection::sessionBus(); | ||
690 | 64 | break; | ||
691 | 65 | } | ||
692 | 66 | default: | ||
693 | 67 | { | ||
694 | 68 | setStatus(UCServiceProperties::ConnectionError); | ||
695 | 69 | setError(UbuntuI18n::instance().tr("Invalid bus type: %1.").arg(type)); | ||
696 | 70 | return false; | ||
697 | 71 | } | ||
698 | 72 | } | ||
699 | 73 | |||
700 | 74 | Q_Q(UCServiceProperties); | ||
701 | 75 | // connect dbus watcher to catch OwnerChanged | ||
702 | 76 | watcher = new QDBusServiceWatcher(service, connection, QDBusServiceWatcher::WatchForOwnerChange, q); | ||
703 | 77 | // connect interface | ||
704 | 78 | iface = new QDBusInterface(service, path, interface, connection, q); | ||
705 | 79 | if (!iface->isValid()) { | ||
706 | 80 | setStatus(UCServiceProperties::ConnectionError); | ||
707 | 81 | setError(iface->lastError().message()); | ||
708 | 82 | return false; | ||
709 | 83 | } | ||
710 | 84 | // connect watcher to get owner changes | ||
711 | 85 | QObject::connect(watcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), | ||
712 | 86 | this, SLOT(changeServiceOwner(QString,QString,QString))); | ||
713 | 87 | return setupInterface(); | ||
714 | 88 | } | ||
715 | 89 | |||
716 | 90 | /* | ||
717 | 91 | * Connect dbus signal identified by (service, path, iface, name) quaduple to a | ||
718 | 92 | * slot to receive property changes. | ||
719 | 93 | */ | ||
720 | 94 | bool DBusServiceProperties::setupInterface() | ||
721 | 95 | { | ||
722 | 96 | QDBusReply<QDBusObjectPath> dbusObjectPath = iface->call("FindUserById", qlonglong(getuid())); | ||
723 | 97 | if (dbusObjectPath.isValid()) { | ||
724 | 98 | objectPath = dbusObjectPath.value().path(); | ||
725 | 99 | iface->connection().connect( | ||
726 | 100 | service, | ||
727 | 101 | objectPath, | ||
728 | 102 | "org.freedesktop.DBus.Properties", | ||
729 | 103 | "PropertiesChanged", | ||
730 | 104 | this, | ||
731 | 105 | SLOT(updateProperties(QString,QVariantMap,QStringList))); | ||
732 | 106 | return true; | ||
733 | 107 | } | ||
734 | 108 | |||
735 | 109 | setStatus(UCServiceProperties::ConnectionError); | ||
736 | 110 | setError(dbusObjectPath.error().message()); | ||
737 | 111 | return false; | ||
738 | 112 | } | ||
739 | 113 | |||
740 | 114 | bool DBusServiceProperties::fetchPropertyValues() | ||
741 | 115 | { | ||
742 | 116 | scannedProperties = properties; | ||
743 | 117 | Q_FOREACH(QString property, properties) { | ||
744 | 118 | readProperty(property); | ||
745 | 119 | } | ||
746 | 120 | return true; | ||
747 | 121 | } | ||
748 | 122 | |||
749 | 123 | /* | ||
750 | 124 | * Reads a property value from the adaptorInterface asynchronously. | ||
751 | 125 | */ | ||
752 | 126 | bool DBusServiceProperties::readProperty(const QString &property) | ||
753 | 127 | { | ||
754 | 128 | if ((status < UCServiceProperties::Synchronizing) || objectPath.isEmpty()) { | ||
755 | 129 | return false; | ||
756 | 130 | } | ||
757 | 131 | Q_Q(UCServiceProperties); | ||
758 | 132 | QDBusInterface readIFace(iface->interface(), objectPath, "org.freedesktop.DBus.Properties", connection); | ||
759 | 133 | if (!readIFace.isValid()) { | ||
760 | 134 | // report invalid interface only if the property's first letter was with capital one! | ||
761 | 135 | if (property[0].isUpper()) { | ||
762 | 136 | qmlInfo(q) << readIFace.lastError().message(); | ||
763 | 137 | } | ||
764 | 138 | return false; | ||
765 | 139 | } | ||
766 | 140 | QDBusPendingCall pending = readIFace.asyncCall("Get", adaptor, property); | ||
767 | 141 | if (pending.isError()) { | ||
768 | 142 | qmlInfo(q) << pending.error().message(); | ||
769 | 143 | return false; | ||
770 | 144 | } | ||
771 | 145 | QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pending, q); | ||
772 | 146 | QObject::connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), | ||
773 | 147 | this, SLOT(readFinished(QDBusPendingCallWatcher*))); | ||
774 | 148 | |||
775 | 149 | // set a dynamic property so we know which property are we reading | ||
776 | 150 | callWatcher->setProperty(DYNAMIC_PROPERTY, property); | ||
777 | 151 | return true; | ||
778 | 152 | } | ||
779 | 153 | |||
780 | 154 | /* | ||
781 | 155 | * Writes a property value to theadaptorInterface synchronously. It is for pure testing purposes. | ||
782 | 156 | */ | ||
783 | 157 | bool DBusServiceProperties::testProperty(const QString &property, const QVariant &value) | ||
784 | 158 | { | ||
785 | 159 | if (objectPath.isEmpty()) { | ||
786 | 160 | return false; | ||
787 | 161 | } | ||
788 | 162 | QDBusInterface writeIFace(iface->interface(), objectPath, "org.freedesktop.DBus.Properties", connection); | ||
789 | 163 | if (!writeIFace.isValid()) { | ||
790 | 164 | // invalid interface | ||
791 | 165 | return false; | ||
792 | 166 | } | ||
793 | 167 | QDBusMessage msg = writeIFace.call("Set", adaptor, property, QVariant::fromValue(QDBusVariant(value))); | ||
794 | 168 | return msg.type() == QDBusMessage::ReplyMessage; | ||
795 | 169 | } | ||
796 | 170 | |||
797 | 171 | /* | ||
798 | 172 | * Slot called when the async read operation finishes. | ||
799 | 173 | */ | ||
800 | 174 | void DBusServiceProperties::readFinished(QDBusPendingCallWatcher *call) | ||
801 | 175 | { | ||
802 | 176 | Q_Q(UCServiceProperties); | ||
803 | 177 | QDBusPendingReply<QVariant> reply = *call; | ||
804 | 178 | QString property = call->property(DYNAMIC_PROPERTY).toString(); | ||
805 | 179 | scannedProperties.removeAll(property); | ||
806 | 180 | if (reply.isError()) { | ||
807 | 181 | // remove the property from being watched, as it has no property like that | ||
808 | 182 | properties.removeAll(property); | ||
809 | 183 | if (property[0].isUpper()) { | ||
810 | 184 | // report error! | ||
811 | 185 | qmlInfo(q) << reply.error().message(); | ||
812 | 186 | } | ||
813 | 187 | } else { | ||
814 | 188 | // update watched property value | ||
815 | 189 | // make sure we have lower case when the property value is updated | ||
816 | 190 | property[0] = property[0].toLower(); | ||
817 | 191 | q->setProperty(property.toLocal8Bit().constData(), reply.value()); | ||
818 | 192 | } | ||
819 | 193 | |||
820 | 194 | if ((status == UCServiceProperties::Synchronizing) && scannedProperties.isEmpty()) { | ||
821 | 195 | // set status to active | ||
822 | 196 | setStatus(UCServiceProperties::Active); | ||
823 | 197 | } | ||
824 | 198 | |||
825 | 199 | // delete watcher | ||
826 | 200 | call->deleteLater(); | ||
827 | 201 | } | ||
828 | 202 | |||
829 | 203 | /* | ||
830 | 204 | * Slot called when service owner is changed. | ||
831 | 205 | */ | ||
832 | 206 | void DBusServiceProperties::changeServiceOwner(const QString &serviceName, const QString &oldOwner, const QString &newOwner) | ||
833 | 207 | { | ||
834 | 208 | Q_UNUSED(oldOwner); | ||
835 | 209 | Q_UNUSED(newOwner); | ||
836 | 210 | if (serviceName != service) { | ||
837 | 211 | return; | ||
838 | 212 | } | ||
839 | 213 | setupInterface(); | ||
840 | 214 | } | ||
841 | 215 | |||
842 | 216 | /* | ||
843 | 217 | * Slot called when the properties are changed in the service. | ||
844 | 218 | */ | ||
845 | 219 | void DBusServiceProperties::updateProperties(const QString &onInterface, const QVariantMap &map, const QStringList &invalidated) | ||
846 | 220 | { | ||
847 | 221 | Q_UNUSED(onInterface); | ||
848 | 222 | Q_UNUSED(map); | ||
849 | 223 | Q_FOREACH(const QString &property, invalidated) { | ||
850 | 224 | readProperty(property); | ||
851 | 225 | } | ||
852 | 226 | } | ||
853 | 227 | 0 | ||
854 | === added file 'modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.h' | |||
855 | --- modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.h 1970-01-01 00:00:00 +0000 | |||
856 | +++ modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.h 2015-02-11 08:57:32 +0000 | |||
857 | @@ -0,0 +1,55 @@ | |||
858 | 1 | /* | ||
859 | 2 | * Copyright 2014 Canonical Ltd. | ||
860 | 3 | * | ||
861 | 4 | * This program is free software; you can redistribute it and/or modify | ||
862 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
863 | 6 | * the Free Software Foundation; version 3. | ||
864 | 7 | * | ||
865 | 8 | * This program is distributed in the hope that it will be useful, | ||
866 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
867 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
868 | 11 | * GNU Lesser General Public License for more details. | ||
869 | 12 | * | ||
870 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
871 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
872 | 15 | */ | ||
873 | 16 | |||
874 | 17 | #ifndef DBUSPROPERTYWATCHER_P_H | ||
875 | 18 | #define DBUSPROPERTYWATCHER_P_H | ||
876 | 19 | |||
877 | 20 | #include <QtCore/QObject> | ||
878 | 21 | #include <QtDBus/QDBusConnection> | ||
879 | 22 | #include <QtDBus/QDBusServiceWatcher> | ||
880 | 23 | #include <QtDBus/QDBusInterface> | ||
881 | 24 | |||
882 | 25 | #include "ucserviceproperties_p.h" | ||
883 | 26 | |||
884 | 27 | class QDBusPendingCallWatcher; | ||
885 | 28 | class DBusServiceProperties : public QObject, public UCServicePropertiesPrivate | ||
886 | 29 | { | ||
887 | 30 | Q_OBJECT | ||
888 | 31 | Q_DECLARE_PUBLIC(UCServiceProperties) | ||
889 | 32 | public: | ||
890 | 33 | DBusServiceProperties(UCServiceProperties *qq); | ||
891 | 34 | |||
892 | 35 | bool init(); | ||
893 | 36 | bool fetchPropertyValues(); | ||
894 | 37 | bool readProperty(const QString &property); | ||
895 | 38 | // for testing purposes only!!! | ||
896 | 39 | bool testProperty(const QString &property, const QVariant &value); | ||
897 | 40 | |||
898 | 41 | QStringList scannedProperties; | ||
899 | 42 | QDBusConnection connection; | ||
900 | 43 | QDBusServiceWatcher *watcher; | ||
901 | 44 | QDBusInterface *iface; | ||
902 | 45 | QString objectPath; | ||
903 | 46 | |||
904 | 47 | bool setupInterface(); | ||
905 | 48 | |||
906 | 49 | public Q_SLOTS: | ||
907 | 50 | void readFinished(QDBusPendingCallWatcher *watcher); | ||
908 | 51 | void changeServiceOwner(const QString &serviceName, const QString &oldOwner, const QString &newOwner); | ||
909 | 52 | void updateProperties(const QString &iface, const QVariantMap &map, const QStringList &invalidated); | ||
910 | 53 | }; | ||
911 | 54 | |||
912 | 55 | #endif // DBUSPROPERTYWATCHER_P_H | ||
913 | 0 | 56 | ||
914 | === removed file 'modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.h' | |||
915 | --- modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.h 2014-12-03 08:26:33 +0000 | |||
916 | +++ modules/Ubuntu/Components/plugin/adapters/dbuspropertywatcher_p.h 1970-01-01 00:00:00 +0000 | |||
917 | @@ -1,55 +0,0 @@ | |||
918 | 1 | /* | ||
919 | 2 | * Copyright 2014 Canonical Ltd. | ||
920 | 3 | * | ||
921 | 4 | * This program is free software; you can redistribute it and/or modify | ||
922 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
923 | 6 | * the Free Software Foundation; version 3. | ||
924 | 7 | * | ||
925 | 8 | * This program is distributed in the hope that it will be useful, | ||
926 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
927 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
928 | 11 | * GNU Lesser General Public License for more details. | ||
929 | 12 | * | ||
930 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
931 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
932 | 15 | */ | ||
933 | 16 | |||
934 | 17 | #ifndef DBUSPROPERTYWATCHER_P_H | ||
935 | 18 | #define DBUSPROPERTYWATCHER_P_H | ||
936 | 19 | |||
937 | 20 | #include <QtCore/QObject> | ||
938 | 21 | #include <QtDBus/QDBusConnection> | ||
939 | 22 | #include <QtDBus/QDBusServiceWatcher> | ||
940 | 23 | #include <QtDBus/QDBusInterface> | ||
941 | 24 | |||
942 | 25 | #include "ucserviceproperties_p.h" | ||
943 | 26 | |||
944 | 27 | class QDBusPendingCallWatcher; | ||
945 | 28 | class DBusServiceProperties : public QObject, public UCServicePropertiesPrivate | ||
946 | 29 | { | ||
947 | 30 | Q_OBJECT | ||
948 | 31 | Q_DECLARE_PUBLIC(UCServiceProperties) | ||
949 | 32 | public: | ||
950 | 33 | DBusServiceProperties(UCServiceProperties *qq); | ||
951 | 34 | |||
952 | 35 | bool init(); | ||
953 | 36 | bool fetchPropertyValues(); | ||
954 | 37 | bool readProperty(const QString &property); | ||
955 | 38 | // for testing purposes only!!! | ||
956 | 39 | bool testProperty(const QString &property, const QVariant &value); | ||
957 | 40 | |||
958 | 41 | QStringList scannedProperties; | ||
959 | 42 | QDBusConnection connection; | ||
960 | 43 | QDBusServiceWatcher *watcher; | ||
961 | 44 | QDBusInterface *iface; | ||
962 | 45 | QString objectPath; | ||
963 | 46 | |||
964 | 47 | bool setupInterface(); | ||
965 | 48 | |||
966 | 49 | public Q_SLOTS: | ||
967 | 50 | void readFinished(QDBusPendingCallWatcher *watcher); | ||
968 | 51 | void changeServiceOwner(const QString &serviceName, const QString &oldOwner, const QString &newOwner); | ||
969 | 52 | void updateProperties(const QString &iface, const QVariantMap &map, const QStringList &invalidated); | ||
970 | 53 | }; | ||
971 | 54 | |||
972 | 55 | #endif // DBUSPROPERTYWATCHER_P_H | ||
973 | 56 | 0 | ||
974 | === modified file 'modules/Ubuntu/Components/plugin/plugin.pro' | |||
975 | --- modules/Ubuntu/Components/plugin/plugin.pro 2015-01-22 06:26:27 +0000 | |||
976 | +++ modules/Ubuntu/Components/plugin/plugin.pro 2015-02-11 08:57:32 +0000 | |||
977 | @@ -67,13 +67,13 @@ | |||
978 | 67 | ucactioncontext.h \ | 67 | ucactioncontext.h \ |
979 | 68 | ucactionmanager.h \ | 68 | ucactionmanager.h \ |
980 | 69 | adapters/actionsproxy_p.h \ | 69 | adapters/actionsproxy_p.h \ |
981 | 70 | adapters/dbuspropertywatcher_p.h \ | ||
982 | 70 | uclistitem.h \ | 71 | uclistitem.h \ |
983 | 71 | uclistitem_p.h \ | 72 | uclistitem_p.h \ |
984 | 72 | uclistitemactions.h \ | 73 | uclistitemactions.h \ |
985 | 73 | uclistitemactions_p.h \ | 74 | uclistitemactions_p.h \ |
986 | 74 | propertychange_p.h \ | 75 | propertychange_p.h \ |
987 | 75 | uclistitemstyle.h \ | 76 | uclistitemstyle.h \ |
988 | 76 | adapters\dbuspropertywatcher_p.h \ | ||
989 | 77 | ucserviceproperties.h \ | 77 | ucserviceproperties.h \ |
990 | 78 | ucserviceproperties_p.h | 78 | ucserviceproperties_p.h |
991 | 79 | 79 | ||
992 | @@ -112,6 +112,7 @@ | |||
993 | 112 | ucactioncontext.cpp \ | 112 | ucactioncontext.cpp \ |
994 | 113 | ucactionmanager.cpp \ | 113 | ucactionmanager.cpp \ |
995 | 114 | adapters/actionsproxy_p.cpp \ | 114 | adapters/actionsproxy_p.cpp \ |
996 | 115 | adapters/dbuspropertywatcher_p.cpp \ | ||
997 | 115 | uclistitem.cpp \ | 116 | uclistitem.cpp \ |
998 | 116 | uclistitemactions.cpp \ | 117 | uclistitemactions.cpp \ |
999 | 117 | propertychange_p.cpp \ | 118 | propertychange_p.cpp \ |
1000 | @@ -119,7 +120,6 @@ | |||
1001 | 119 | ucviewitemsattached.cpp \ | 120 | ucviewitemsattached.cpp \ |
1002 | 120 | uclistitemattached.cpp \ | 121 | uclistitemattached.cpp \ |
1003 | 121 | ucactionpanel_p.cpp \ | 122 | ucactionpanel_p.cpp \ |
1004 | 122 | adapters\dbuspropertywatcher_p.cpp \ | ||
1005 | 123 | ucserviceproperties.cpp | 123 | ucserviceproperties.cpp |
1006 | 124 | 124 | ||
1007 | 125 | # adapters | 125 | # adapters |
1008 | 126 | 126 | ||
1009 | === added file 'modules/Ubuntu/Components/plugin/ucserviceproperties.cpp' | |||
1010 | --- modules/Ubuntu/Components/plugin/ucserviceproperties.cpp 1970-01-01 00:00:00 +0000 | |||
1011 | +++ modules/Ubuntu/Components/plugin/ucserviceproperties.cpp 2015-02-11 08:57:32 +0000 | |||
1012 | @@ -0,0 +1,327 @@ | |||
1013 | 1 | /* | ||
1014 | 2 | * Copyright 2014 Canonical Ltd. | ||
1015 | 3 | * | ||
1016 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1017 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1018 | 6 | * the Free Software Foundation; version 3. | ||
1019 | 7 | * | ||
1020 | 8 | * This program is distributed in the hope that it will be useful, | ||
1021 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1022 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1023 | 11 | * GNU Lesser General Public License for more details. | ||
1024 | 12 | * | ||
1025 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1026 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1027 | 15 | */ | ||
1028 | 16 | |||
1029 | 17 | #include "ucserviceproperties.h" | ||
1030 | 18 | #include "ucserviceproperties_p.h" | ||
1031 | 19 | #include "i18n.h" | ||
1032 | 20 | #include <QtQml/QQmlInfo> | ||
1033 | 21 | #include <QtCore/QMetaProperty> | ||
1034 | 22 | #include <QtQml/QQmlProperty> | ||
1035 | 23 | #include <QtQml/private/qqmlproperty_p.h> | ||
1036 | 24 | |||
1037 | 25 | UCServicePropertiesPrivate::UCServicePropertiesPrivate(UCServiceProperties *qq) | ||
1038 | 26 | : q_ptr(qq) | ||
1039 | 27 | , ready(false) | ||
1040 | 28 | , status(UCServiceProperties::Inactive) | ||
1041 | 29 | , type(UCServiceProperties::System) | ||
1042 | 30 | { | ||
1043 | 31 | } | ||
1044 | 32 | |||
1045 | 33 | UCServicePropertiesPrivate::~UCServicePropertiesPrivate() | ||
1046 | 34 | { | ||
1047 | 35 | } | ||
1048 | 36 | |||
1049 | 37 | UCServicePropertiesPrivate *UCServicePropertiesPrivate::get(UCServiceProperties *service) | ||
1050 | 38 | { | ||
1051 | 39 | return service->d_func(); | ||
1052 | 40 | } | ||
1053 | 41 | |||
1054 | 42 | void UCServicePropertiesPrivate::warning(const QString &message) | ||
1055 | 43 | { | ||
1056 | 44 | QByteArray suppressWarnings = qgetenv("SUPPRESS_SERVICEPROPERTIES_WARNINGS"); | ||
1057 | 45 | if ((suppressWarnings == "yes") || (suppressWarnings == "1")) { | ||
1058 | 46 | return; | ||
1059 | 47 | } | ||
1060 | 48 | qmlInfo(q_ptr) << message; | ||
1061 | 49 | } | ||
1062 | 50 | |||
1063 | 51 | void UCServicePropertiesPrivate::setError(const QString &msg) | ||
1064 | 52 | { | ||
1065 | 53 | if (error == msg) { | ||
1066 | 54 | return; | ||
1067 | 55 | } | ||
1068 | 56 | error = msg; | ||
1069 | 57 | Q_EMIT q_ptr->errorChanged(); | ||
1070 | 58 | } | ||
1071 | 59 | |||
1072 | 60 | void UCServicePropertiesPrivate::setStatus(UCServiceProperties::Status status) | ||
1073 | 61 | { | ||
1074 | 62 | if (this->status == status) { | ||
1075 | 63 | return; | ||
1076 | 64 | } | ||
1077 | 65 | this->status = status; | ||
1078 | 66 | Q_EMIT q_ptr->statusChanged(); | ||
1079 | 67 | } | ||
1080 | 68 | |||
1081 | 69 | void printLocked(UCServiceProperties *owner) | ||
1082 | 70 | { | ||
1083 | 71 | UCServicePropertiesPrivate::get(owner)-> | ||
1084 | 72 | warning(UbuntuI18n::instance().tr("Changing connection parameters forbidden.")); | ||
1085 | 73 | } | ||
1086 | 74 | |||
1087 | 75 | /*! | ||
1088 | 76 | * \qmltype ServiceProperties | ||
1089 | 77 | * \instantiates UCServiceProperties | ||
1090 | 78 | * \inqmlmodule Ubuntu.Components 1.1 | ||
1091 | 79 | * \since Ubuntu.Components 1.1 | ||
1092 | 80 | * \ingroup ubuntu-services | ||
1093 | 81 | * \brief The component enables accessing service properties from QML. | ||
1094 | 82 | * | ||
1095 | 83 | * The services accessed by the component are ones providing their interfaces | ||
1096 | 84 | * through DBus. The component is specialized to read properties exposed by these | ||
1097 | 85 | * services, andf to keep these property values up to date. It is not meant to | ||
1098 | 86 | * access signals or slots exposed, nor to change the values of the properties | ||
1099 | 87 | * watched. | ||
1100 | 88 | * | ||
1101 | 89 | * Properties watched should be declared within the body of the component like | ||
1102 | 90 | * any other QML property, preferably defining a default value for them. The component | ||
1103 | 91 | * will enumerate these properties and will ask the service to provide values for | ||
1104 | 92 | * those. When enumerating properties, each property will be checked twice, with | ||
1105 | 93 | * the case specified as well as with the first letter capitalized. | ||
1106 | 94 | * \qml | ||
1107 | 95 | * import QtQuick 2.3 | ||
1108 | 96 | * import Ubuntu.Components 1.1 | ||
1109 | 97 | * | ||
1110 | 98 | * ServiceProperties { | ||
1111 | 99 | * service: "org.freenode.AccountsService" | ||
1112 | 100 | * path: "/org/freenode/AccountsService" | ||
1113 | 101 | * serviceInterface: "org.freenode.AccountsService" | ||
1114 | 102 | * adaptorInterface: "com.ubuntu.touch.Accounts.Sound" | ||
1115 | 103 | * // listing properties to watch | ||
1116 | 104 | * // each property name existence will be checked against the current case | ||
1117 | 105 | * // as well as with first character capitalized | ||
1118 | 106 | * property bool incomingCallVibrate: true | ||
1119 | 107 | * } | ||
1120 | 108 | * \endqml | ||
1121 | 109 | * | ||
1122 | 110 | * Note that there are few properties which must be set in order the component | ||
1123 | 111 | * to work. These are \l service, \l path and \l adaptorInterface. Also, once | ||
1124 | 112 | * specified, \l service, \l serviceInterface and \l adaptorInterface values | ||
1125 | 113 | * should not be changed as it cannot be guaranteed that properties watched will | ||
1126 | 114 | * be available on those service. Therefore any change on these properties after | ||
1127 | 115 | * the component completion will be ignored. Property bindings on properties | ||
1128 | 116 | * watched will be ignored as well, as service will report changes in these property | ||
1129 | 117 | * values. | ||
1130 | 118 | * | ||
1131 | 119 | * The service is connected once the component gets completed (Component.onCompleted). | ||
1132 | 120 | * The \l error property specifies any error occured during connection, and the | ||
1133 | 121 | * \l status property notifies whether the connection to the service is active or not. | ||
1134 | 122 | * | ||
1135 | 123 | * \note Pay attention when chosing the service watched, and set your application's | ||
1136 | 124 | * AppArmor rights to ensure a successful service connection. | ||
1137 | 125 | */ | ||
1138 | 126 | UCServiceProperties::UCServiceProperties(QObject *parent) | ||
1139 | 127 | : QObject(parent) | ||
1140 | 128 | , d_ptr(createServicePropertiesAdapter(this)) | ||
1141 | 129 | { | ||
1142 | 130 | } | ||
1143 | 131 | UCServiceProperties::~UCServiceProperties() | ||
1144 | 132 | { | ||
1145 | 133 | delete d_ptr; | ||
1146 | 134 | d_ptr = 0; | ||
1147 | 135 | } | ||
1148 | 136 | |||
1149 | 137 | void UCServiceProperties::classBegin() | ||
1150 | 138 | { | ||
1151 | 139 | } | ||
1152 | 140 | |||
1153 | 141 | void UCServiceProperties::componentComplete() | ||
1154 | 142 | { | ||
1155 | 143 | Q_D(UCServiceProperties); | ||
1156 | 144 | d->ready = true; | ||
1157 | 145 | // enumerate properties | ||
1158 | 146 | const QMetaObject *mo = metaObject(); | ||
1159 | 147 | for (int i = mo->propertyOffset(); i < mo->propertyCount(); i++) { | ||
1160 | 148 | const QMetaProperty prop = mo->property(i); | ||
1161 | 149 | QString property(prop.name()); | ||
1162 | 150 | |||
1163 | 151 | // check the binding on the property and warn if there is one. | ||
1164 | 152 | QQmlProperty qmlProperty(this, property); | ||
1165 | 153 | if (QQmlPropertyPrivate::binding(qmlProperty)) { | ||
1166 | 154 | d->warning(UbuntuI18n::instance(). | ||
1167 | 155 | tr("Binding detected on property '%1' will be removed by the service updates."). | ||
1168 | 156 | arg(property)); | ||
1169 | 157 | } | ||
1170 | 158 | // insert both the declared and capitalized first character properties | ||
1171 | 159 | d->properties << property; | ||
1172 | 160 | property[0] = property[0].toUpper(); | ||
1173 | 161 | d->properties << property; | ||
1174 | 162 | } | ||
1175 | 163 | // initialize DBus | ||
1176 | 164 | if (d->init()) { | ||
1177 | 165 | d->setStatus(UCServiceProperties::Synchronizing); | ||
1178 | 166 | d->fetchPropertyValues(); | ||
1179 | 167 | } | ||
1180 | 168 | } | ||
1181 | 169 | |||
1182 | 170 | /*! | ||
1183 | 171 | * \qmlproperty enum ServiceProperties::type | ||
1184 | 172 | * Specifies the DBus connection session type. It can get the following values: | ||
1185 | 173 | * \list | ||
1186 | 174 | * \li - \e ServiceProperties.System when system bus is used (default) | ||
1187 | 175 | * \li - \e ServiceProperties.Session when session bus is used | ||
1188 | 176 | * \endlist | ||
1189 | 177 | */ | ||
1190 | 178 | UCServiceProperties::ServiceType UCServiceProperties::type() const | ||
1191 | 179 | { | ||
1192 | 180 | Q_D(const UCServiceProperties); | ||
1193 | 181 | return d->type; | ||
1194 | 182 | } | ||
1195 | 183 | void UCServiceProperties::setType(ServiceType type) | ||
1196 | 184 | { | ||
1197 | 185 | Q_D(UCServiceProperties); | ||
1198 | 186 | if (d->type == type) { | ||
1199 | 187 | return; | ||
1200 | 188 | } | ||
1201 | 189 | if (d->ready) { | ||
1202 | 190 | printLocked(this); | ||
1203 | 191 | return; | ||
1204 | 192 | } | ||
1205 | 193 | d->type = type; | ||
1206 | 194 | Q_EMIT typeChanged(); | ||
1207 | 195 | } | ||
1208 | 196 | |||
1209 | 197 | /*! | ||
1210 | 198 | * \qmlproperty string ServiceProperties::service | ||
1211 | 199 | * The proeprty specifies the DBus service URI. It is mandatory to be specified. | ||
1212 | 200 | */ | ||
1213 | 201 | QString UCServiceProperties::service() const | ||
1214 | 202 | { | ||
1215 | 203 | Q_D(const UCServiceProperties); | ||
1216 | 204 | return d->service; | ||
1217 | 205 | } | ||
1218 | 206 | void UCServiceProperties::setService(const QString &value) | ||
1219 | 207 | { | ||
1220 | 208 | Q_D(UCServiceProperties); | ||
1221 | 209 | if (d->service == value) { | ||
1222 | 210 | return; | ||
1223 | 211 | } | ||
1224 | 212 | if (d->ready) { | ||
1225 | 213 | printLocked(this); | ||
1226 | 214 | return; | ||
1227 | 215 | } | ||
1228 | 216 | d->service = value; | ||
1229 | 217 | Q_EMIT serviceChanged(); | ||
1230 | 218 | } | ||
1231 | 219 | |||
1232 | 220 | /*! | ||
1233 | 221 | * \qmlproperty string ServiceProperties::path | ||
1234 | 222 | * The property specifies the DBus service connection path. It is mandatory to be | ||
1235 | 223 | * specified. | ||
1236 | 224 | */ | ||
1237 | 225 | QString UCServiceProperties::path() const | ||
1238 | 226 | { | ||
1239 | 227 | Q_D(const UCServiceProperties); | ||
1240 | 228 | return d->path; | ||
1241 | 229 | } | ||
1242 | 230 | void UCServiceProperties::setPath(const QString &value) | ||
1243 | 231 | { | ||
1244 | 232 | Q_D(UCServiceProperties); | ||
1245 | 233 | if (d->path == value) { | ||
1246 | 234 | return; | ||
1247 | 235 | } | ||
1248 | 236 | d->path = value; | ||
1249 | 237 | Q_EMIT pathChanged(); | ||
1250 | 238 | if (d->ready) { | ||
1251 | 239 | // need to re-initialize connections | ||
1252 | 240 | d->init(); | ||
1253 | 241 | } | ||
1254 | 242 | } | ||
1255 | 243 | |||
1256 | 244 | /*! | ||
1257 | 245 | * \qmlproperty string ServiceProperties::serviceInterface | ||
1258 | 246 | * The property specifies the service intertface. If it is an empty string, the | ||
1259 | 247 | * component will refer to the merging of all interfaces found in the service. | ||
1260 | 248 | */ | ||
1261 | 249 | QString UCServiceProperties::interface() const | ||
1262 | 250 | { | ||
1263 | 251 | Q_D(const UCServiceProperties); | ||
1264 | 252 | return d->interface; | ||
1265 | 253 | } | ||
1266 | 254 | void UCServiceProperties::setInterface(const QString &value) | ||
1267 | 255 | { | ||
1268 | 256 | Q_D(UCServiceProperties); | ||
1269 | 257 | if (d->interface == value) { | ||
1270 | 258 | return; | ||
1271 | 259 | } | ||
1272 | 260 | if (d->ready) { | ||
1273 | 261 | printLocked(this); | ||
1274 | 262 | return; | ||
1275 | 263 | } | ||
1276 | 264 | d->interface = value; | ||
1277 | 265 | Q_EMIT serviceInterfaceChanged(); | ||
1278 | 266 | } | ||
1279 | 267 | /*! | ||
1280 | 268 | * \qmlproperty string ServiceProperties::adaptorInterface | ||
1281 | 269 | * The proeprty specifies the dbus adaptor interface which provides the properties | ||
1282 | 270 | * watched. This can be a different interface that the one specified in \l serviceInterface, | ||
1283 | 271 | * and in the same way, it can be empty, in which case all the properties from all | ||
1284 | 272 | * interfaces of the service will be watched. | ||
1285 | 273 | */ | ||
1286 | 274 | QString UCServiceProperties::adaptor() const | ||
1287 | 275 | { | ||
1288 | 276 | Q_D(const UCServiceProperties); | ||
1289 | 277 | return d->adaptor; | ||
1290 | 278 | } | ||
1291 | 279 | void UCServiceProperties::setAdaptor(const QString &value) | ||
1292 | 280 | { | ||
1293 | 281 | Q_D(UCServiceProperties); | ||
1294 | 282 | if (d->adaptor == value) { | ||
1295 | 283 | return; | ||
1296 | 284 | } | ||
1297 | 285 | if (d->ready) { | ||
1298 | 286 | printLocked(this); | ||
1299 | 287 | return; | ||
1300 | 288 | } | ||
1301 | 289 | d->adaptor = value; | ||
1302 | 290 | Q_EMIT adaptorInterfaceChanged(); | ||
1303 | 291 | } | ||
1304 | 292 | |||
1305 | 293 | /*! | ||
1306 | 294 | * \qmlproperty string ServiceProperties::error | ||
1307 | 295 | * The property is set with a human readablestring each time an error occurrs | ||
1308 | 296 | * during the service connection. Empty string means no error. | ||
1309 | 297 | */ | ||
1310 | 298 | QString UCServiceProperties::error() | ||
1311 | 299 | { | ||
1312 | 300 | Q_D(UCServiceProperties); | ||
1313 | 301 | return d->error; | ||
1314 | 302 | } | ||
1315 | 303 | |||
1316 | 304 | /*! | ||
1317 | 305 | * \qmlproperty enum ServiceProperties::status | ||
1318 | 306 | * The property presents the status of the component. | ||
1319 | 307 | * \list | ||
1320 | 308 | * \li - \e ServiceProperties.Inactive - the component is inactive, initial state | ||
1321 | 309 | * \li - \e ServiceProperties.ConnectionError - there was a connection error, the | ||
1322 | 310 | * \l error contains the error string. | ||
1323 | 311 | * \li - \e ServiceProperties.Synchronizing - the connection to the service succeeded, | ||
1324 | 312 | * and the properties are being synchronized; | ||
1325 | 313 | * \li - \e ServiceProperties.Active - the service watcher is active and initial | ||
1326 | 314 | * property synchronization completed. | ||
1327 | 315 | * \endlist | ||
1328 | 316 | * \note While the status is set to \e Synchronizing, the properties are checked | ||
1329 | 317 | * against their existence in the service. Each proeprty will be checked as declared | ||
1330 | 318 | * as well with capital first letter. If neither of these exists in the service, | ||
1331 | 319 | * it will be reported in the \l error property separately. | ||
1332 | 320 | */ | ||
1333 | 321 | UCServiceProperties::Status UCServiceProperties::status() const | ||
1334 | 322 | { | ||
1335 | 323 | Q_D(const UCServiceProperties); | ||
1336 | 324 | return d->status; | ||
1337 | 325 | } | ||
1338 | 326 | |||
1339 | 327 | #include "moc_ucserviceproperties.cpp" | ||
1340 | 0 | 328 | ||
1341 | === removed file 'modules/Ubuntu/Components/plugin/ucserviceproperties.cpp' | |||
1342 | --- modules/Ubuntu/Components/plugin/ucserviceproperties.cpp 2014-12-03 08:26:33 +0000 | |||
1343 | +++ modules/Ubuntu/Components/plugin/ucserviceproperties.cpp 1970-01-01 00:00:00 +0000 | |||
1344 | @@ -1,317 +0,0 @@ | |||
1345 | 1 | /* | ||
1346 | 2 | * Copyright 2014 Canonical Ltd. | ||
1347 | 3 | * | ||
1348 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1349 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1350 | 6 | * the Free Software Foundation; version 3. | ||
1351 | 7 | * | ||
1352 | 8 | * This program is distributed in the hope that it will be useful, | ||
1353 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1354 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1355 | 11 | * GNU Lesser General Public License for more details. | ||
1356 | 12 | * | ||
1357 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1358 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1359 | 15 | */ | ||
1360 | 16 | |||
1361 | 17 | #include "ucserviceproperties.h" | ||
1362 | 18 | #include "ucserviceproperties_p.h" | ||
1363 | 19 | #include "i18n.h" | ||
1364 | 20 | #include <QtQml/QQmlInfo> | ||
1365 | 21 | #include <QtCore/QMetaProperty> | ||
1366 | 22 | #include <QtQml/QQmlProperty> | ||
1367 | 23 | #include <QtQml/private/qqmlproperty_p.h> | ||
1368 | 24 | |||
1369 | 25 | UCServicePropertiesPrivate::UCServicePropertiesPrivate(UCServiceProperties *qq) | ||
1370 | 26 | : q_ptr(qq) | ||
1371 | 27 | , ready(false) | ||
1372 | 28 | , status(UCServiceProperties::Inactive) | ||
1373 | 29 | , type(UCServiceProperties::System) | ||
1374 | 30 | { | ||
1375 | 31 | } | ||
1376 | 32 | |||
1377 | 33 | UCServicePropertiesPrivate::~UCServicePropertiesPrivate() | ||
1378 | 34 | { | ||
1379 | 35 | } | ||
1380 | 36 | |||
1381 | 37 | UCServicePropertiesPrivate *UCServicePropertiesPrivate::get(UCServiceProperties *service) | ||
1382 | 38 | { | ||
1383 | 39 | return service->d_func(); | ||
1384 | 40 | } | ||
1385 | 41 | |||
1386 | 42 | void UCServicePropertiesPrivate::setError(const QString &msg) | ||
1387 | 43 | { | ||
1388 | 44 | if (error == msg) { | ||
1389 | 45 | return; | ||
1390 | 46 | } | ||
1391 | 47 | error = msg; | ||
1392 | 48 | Q_EMIT q_ptr->errorChanged(); | ||
1393 | 49 | } | ||
1394 | 50 | |||
1395 | 51 | void UCServicePropertiesPrivate::setStatus(UCServiceProperties::Status status) | ||
1396 | 52 | { | ||
1397 | 53 | if (this->status == status) { | ||
1398 | 54 | return; | ||
1399 | 55 | } | ||
1400 | 56 | this->status = status; | ||
1401 | 57 | Q_EMIT q_ptr->statusChanged(); | ||
1402 | 58 | } | ||
1403 | 59 | |||
1404 | 60 | void printLocked(UCServiceProperties *owner) | ||
1405 | 61 | { | ||
1406 | 62 | qmlInfo(owner) << UbuntuI18n::instance().tr("Changing connection parameters forbidden."); | ||
1407 | 63 | } | ||
1408 | 64 | |||
1409 | 65 | /*! | ||
1410 | 66 | * \qmltype ServiceProperties | ||
1411 | 67 | * \instantiates UCServiceProperties | ||
1412 | 68 | * \inqmlmodule Ubuntu.Components 1.1 | ||
1413 | 69 | * \since Ubuntu.Components 1.1 | ||
1414 | 70 | * \ingroup ubuntu-services | ||
1415 | 71 | * \brief The component enables accessing service properties from QML. | ||
1416 | 72 | * | ||
1417 | 73 | * The services accessed by the component are ones providing their interfaces | ||
1418 | 74 | * through DBus. The component is specialized to read properties exposed by these | ||
1419 | 75 | * services, andf to keep these property values up to date. It is not meant to | ||
1420 | 76 | * access signals or slots exposed, nor to change the values of the properties | ||
1421 | 77 | * watched. | ||
1422 | 78 | * | ||
1423 | 79 | * Properties watched should be declared within the body of the component like | ||
1424 | 80 | * any other QML property, preferably defining a default value for them. The component | ||
1425 | 81 | * will enumerate these properties and will ask the service to provide values for | ||
1426 | 82 | * those. When enumerating properties, each property will be checked twice, with | ||
1427 | 83 | * the case specified as well as with the first letter capitalized. | ||
1428 | 84 | * \qml | ||
1429 | 85 | * import QtQuick 2.3 | ||
1430 | 86 | * import Ubuntu.Components 1.1 | ||
1431 | 87 | * | ||
1432 | 88 | * ServiceProperties { | ||
1433 | 89 | * service: "org.freenode.AccountsService" | ||
1434 | 90 | * path: "/org/freenode/AccountsService" | ||
1435 | 91 | * serviceInterface: "org.freenode.AccountsService" | ||
1436 | 92 | * adaptorInterface: "com.ubuntu.touch.Accounts.Sound" | ||
1437 | 93 | * // listing properties to watch | ||
1438 | 94 | * // each property name existence will be checked against the current case | ||
1439 | 95 | * // as well as with first character capitalized | ||
1440 | 96 | * property bool incomingCallVibrate: true | ||
1441 | 97 | * } | ||
1442 | 98 | * \endqml | ||
1443 | 99 | * | ||
1444 | 100 | * Note that there are few properties which must be set in order the component | ||
1445 | 101 | * to work. These are \l service, \l path and \l adaptorInterface. Also, once | ||
1446 | 102 | * specified, \l service, \l serviceInterface and \l adaptorInterface values | ||
1447 | 103 | * should not be changed as it cannot be guaranteed that properties watched will | ||
1448 | 104 | * be available on those service. Therefore any change on these properties after | ||
1449 | 105 | * the component completion will be ignored. Property bindings on properties | ||
1450 | 106 | * watched will be ignored as well, as service will report changes in these property | ||
1451 | 107 | * values. | ||
1452 | 108 | * | ||
1453 | 109 | * The service is connected once the component gets completed (Component.onCompleted). | ||
1454 | 110 | * The \l error property specifies any error occured during connection, and the | ||
1455 | 111 | * \l status property notifies whether the connection to the service is active or not. | ||
1456 | 112 | * | ||
1457 | 113 | * \note Pay attention when chosing the service watched, and set your application's | ||
1458 | 114 | * AppArmor rights to ensure a successful service connection. | ||
1459 | 115 | */ | ||
1460 | 116 | UCServiceProperties::UCServiceProperties(QObject *parent) | ||
1461 | 117 | : QObject(parent) | ||
1462 | 118 | , d_ptr(createServicePropertiesAdapter(this)) | ||
1463 | 119 | { | ||
1464 | 120 | } | ||
1465 | 121 | UCServiceProperties::~UCServiceProperties() | ||
1466 | 122 | { | ||
1467 | 123 | delete d_ptr; | ||
1468 | 124 | d_ptr = 0; | ||
1469 | 125 | } | ||
1470 | 126 | |||
1471 | 127 | void UCServiceProperties::classBegin() | ||
1472 | 128 | { | ||
1473 | 129 | } | ||
1474 | 130 | |||
1475 | 131 | void UCServiceProperties::componentComplete() | ||
1476 | 132 | { | ||
1477 | 133 | Q_D(UCServiceProperties); | ||
1478 | 134 | d->ready = true; | ||
1479 | 135 | // enumerate properties | ||
1480 | 136 | const QMetaObject *mo = metaObject(); | ||
1481 | 137 | for (int i = mo->propertyOffset(); i < mo->propertyCount(); i++) { | ||
1482 | 138 | const QMetaProperty prop = mo->property(i); | ||
1483 | 139 | QString property(prop.name()); | ||
1484 | 140 | |||
1485 | 141 | // check the binding on the property and warn if there is one. | ||
1486 | 142 | QQmlProperty qmlProperty(this, property); | ||
1487 | 143 | if (QQmlPropertyPrivate::binding(qmlProperty)) { | ||
1488 | 144 | qmlInfo(this) << UbuntuI18n::instance(). | ||
1489 | 145 | tr("Binding detected on property '%1' will be removed by the service updates."). | ||
1490 | 146 | arg(property); | ||
1491 | 147 | } | ||
1492 | 148 | // insert both the declared and capitalized first character properties | ||
1493 | 149 | d->properties << property; | ||
1494 | 150 | property[0] = property[0].toUpper(); | ||
1495 | 151 | d->properties << property; | ||
1496 | 152 | } | ||
1497 | 153 | // initialize DBus | ||
1498 | 154 | if (d->init()) { | ||
1499 | 155 | d->setStatus(UCServiceProperties::Synchronizing); | ||
1500 | 156 | d->fetchPropertyValues(); | ||
1501 | 157 | } | ||
1502 | 158 | } | ||
1503 | 159 | |||
1504 | 160 | /*! | ||
1505 | 161 | * \qmlproperty enum ServiceProperties::type | ||
1506 | 162 | * Specifies the DBus connection session type. It can get the following values: | ||
1507 | 163 | * \list | ||
1508 | 164 | * \li - \e ServiceProperties.System when system bus is used (default) | ||
1509 | 165 | * \li - \e ServiceProperties.Session when session bus is used | ||
1510 | 166 | * \endlist | ||
1511 | 167 | */ | ||
1512 | 168 | UCServiceProperties::ServiceType UCServiceProperties::type() const | ||
1513 | 169 | { | ||
1514 | 170 | Q_D(const UCServiceProperties); | ||
1515 | 171 | return d->type; | ||
1516 | 172 | } | ||
1517 | 173 | void UCServiceProperties::setType(ServiceType type) | ||
1518 | 174 | { | ||
1519 | 175 | Q_D(UCServiceProperties); | ||
1520 | 176 | if (d->type == type) { | ||
1521 | 177 | return; | ||
1522 | 178 | } | ||
1523 | 179 | if (d->ready) { | ||
1524 | 180 | printLocked(this); | ||
1525 | 181 | return; | ||
1526 | 182 | } | ||
1527 | 183 | d->type = type; | ||
1528 | 184 | Q_EMIT typeChanged(); | ||
1529 | 185 | } | ||
1530 | 186 | |||
1531 | 187 | /*! | ||
1532 | 188 | * \qmlproperty string ServiceProperties::service | ||
1533 | 189 | * The proeprty specifies the DBus service URI. It is mandatory to be specified. | ||
1534 | 190 | */ | ||
1535 | 191 | QString UCServiceProperties::service() const | ||
1536 | 192 | { | ||
1537 | 193 | Q_D(const UCServiceProperties); | ||
1538 | 194 | return d->service; | ||
1539 | 195 | } | ||
1540 | 196 | void UCServiceProperties::setService(const QString &value) | ||
1541 | 197 | { | ||
1542 | 198 | Q_D(UCServiceProperties); | ||
1543 | 199 | if (d->service == value) { | ||
1544 | 200 | return; | ||
1545 | 201 | } | ||
1546 | 202 | if (d->ready) { | ||
1547 | 203 | printLocked(this); | ||
1548 | 204 | return; | ||
1549 | 205 | } | ||
1550 | 206 | d->service = value; | ||
1551 | 207 | Q_EMIT serviceChanged(); | ||
1552 | 208 | } | ||
1553 | 209 | |||
1554 | 210 | /*! | ||
1555 | 211 | * \qmlproperty string ServiceProperties::path | ||
1556 | 212 | * The property specifies the DBus service connection path. It is mandatory to be | ||
1557 | 213 | * specified. | ||
1558 | 214 | */ | ||
1559 | 215 | QString UCServiceProperties::path() const | ||
1560 | 216 | { | ||
1561 | 217 | Q_D(const UCServiceProperties); | ||
1562 | 218 | return d->path; | ||
1563 | 219 | } | ||
1564 | 220 | void UCServiceProperties::setPath(const QString &value) | ||
1565 | 221 | { | ||
1566 | 222 | Q_D(UCServiceProperties); | ||
1567 | 223 | if (d->path == value) { | ||
1568 | 224 | return; | ||
1569 | 225 | } | ||
1570 | 226 | d->path = value; | ||
1571 | 227 | Q_EMIT pathChanged(); | ||
1572 | 228 | if (d->ready) { | ||
1573 | 229 | // need to re-initialize connections | ||
1574 | 230 | d->init(); | ||
1575 | 231 | } | ||
1576 | 232 | } | ||
1577 | 233 | |||
1578 | 234 | /*! | ||
1579 | 235 | * \qmlproperty string ServiceProperties::serviceInterface | ||
1580 | 236 | * The property specifies the service intertface. If it is an empty string, the | ||
1581 | 237 | * component will refer to the merging of all interfaces found in the service. | ||
1582 | 238 | */ | ||
1583 | 239 | QString UCServiceProperties::interface() const | ||
1584 | 240 | { | ||
1585 | 241 | Q_D(const UCServiceProperties); | ||
1586 | 242 | return d->interface; | ||
1587 | 243 | } | ||
1588 | 244 | void UCServiceProperties::setInterface(const QString &value) | ||
1589 | 245 | { | ||
1590 | 246 | Q_D(UCServiceProperties); | ||
1591 | 247 | if (d->interface == value) { | ||
1592 | 248 | return; | ||
1593 | 249 | } | ||
1594 | 250 | if (d->ready) { | ||
1595 | 251 | printLocked(this); | ||
1596 | 252 | return; | ||
1597 | 253 | } | ||
1598 | 254 | d->interface = value; | ||
1599 | 255 | Q_EMIT serviceInterfaceChanged(); | ||
1600 | 256 | } | ||
1601 | 257 | /*! | ||
1602 | 258 | * \qmlproperty string ServiceProperties::adaptorInterface | ||
1603 | 259 | * The proeprty specifies the dbus adaptor interface which provides the properties | ||
1604 | 260 | * watched. This can be a different interface that the one specified in \l serviceInterface, | ||
1605 | 261 | * and in the same way, it can be empty, in which case all the properties from all | ||
1606 | 262 | * interfaces of the service will be watched. | ||
1607 | 263 | */ | ||
1608 | 264 | QString UCServiceProperties::adaptor() const | ||
1609 | 265 | { | ||
1610 | 266 | Q_D(const UCServiceProperties); | ||
1611 | 267 | return d->adaptor; | ||
1612 | 268 | } | ||
1613 | 269 | void UCServiceProperties::setAdaptor(const QString &value) | ||
1614 | 270 | { | ||
1615 | 271 | Q_D(UCServiceProperties); | ||
1616 | 272 | if (d->adaptor == value) { | ||
1617 | 273 | return; | ||
1618 | 274 | } | ||
1619 | 275 | if (d->ready) { | ||
1620 | 276 | printLocked(this); | ||
1621 | 277 | return; | ||
1622 | 278 | } | ||
1623 | 279 | d->adaptor = value; | ||
1624 | 280 | Q_EMIT adaptorInterfaceChanged(); | ||
1625 | 281 | } | ||
1626 | 282 | |||
1627 | 283 | /*! | ||
1628 | 284 | * \qmlproperty string ServiceProperties::error | ||
1629 | 285 | * The property is set with a human readablestring each time an error occurrs | ||
1630 | 286 | * during the service connection. Empty string means no error. | ||
1631 | 287 | */ | ||
1632 | 288 | QString UCServiceProperties::error() | ||
1633 | 289 | { | ||
1634 | 290 | Q_D(UCServiceProperties); | ||
1635 | 291 | return d->error; | ||
1636 | 292 | } | ||
1637 | 293 | |||
1638 | 294 | /*! | ||
1639 | 295 | * \qmlproperty enum ServiceProperties::status | ||
1640 | 296 | * The property presents the status of the component. | ||
1641 | 297 | * \list | ||
1642 | 298 | * \li - \e ServiceProperties.Inactive - the component is inactive, initial state | ||
1643 | 299 | * \li - \e ServiceProperties.ConnectionError - there was a connection error, the | ||
1644 | 300 | * \l error contains the error string. | ||
1645 | 301 | * \li - \e ServiceProperties.Synchronizing - the connection to the service succeeded, | ||
1646 | 302 | * and the properties are being synchronized; | ||
1647 | 303 | * \li - \e ServiceProperties.Active - the service watcher is active and initial | ||
1648 | 304 | * property synchronization completed. | ||
1649 | 305 | * \endlist | ||
1650 | 306 | * \note While the status is set to \e Synchronizing, the properties are checked | ||
1651 | 307 | * against their existence in the service. Each proeprty will be checked as declared | ||
1652 | 308 | * as well with capital first letter. If neither of these exists in the service, | ||
1653 | 309 | * it will be reported in the \l error property separately. | ||
1654 | 310 | */ | ||
1655 | 311 | UCServiceProperties::Status UCServiceProperties::status() const | ||
1656 | 312 | { | ||
1657 | 313 | Q_D(const UCServiceProperties); | ||
1658 | 314 | return d->status; | ||
1659 | 315 | } | ||
1660 | 316 | |||
1661 | 317 | #include "moc_ucserviceproperties.cpp" | ||
1662 | 318 | 0 | ||
1663 | === added file 'modules/Ubuntu/Components/plugin/ucserviceproperties.h' | |||
1664 | --- modules/Ubuntu/Components/plugin/ucserviceproperties.h 1970-01-01 00:00:00 +0000 | |||
1665 | +++ modules/Ubuntu/Components/plugin/ucserviceproperties.h 2015-02-11 08:57:32 +0000 | |||
1666 | @@ -0,0 +1,83 @@ | |||
1667 | 1 | /* | ||
1668 | 2 | * Copyright 2014 Canonical Ltd. | ||
1669 | 3 | * | ||
1670 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1671 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1672 | 6 | * the Free Software Foundation; version 3. | ||
1673 | 7 | * | ||
1674 | 8 | * This program is distributed in the hope that it will be useful, | ||
1675 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1676 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1677 | 11 | * GNU Lesser General Public License for more details. | ||
1678 | 12 | * | ||
1679 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1680 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1681 | 15 | */ | ||
1682 | 16 | |||
1683 | 17 | #ifndef UCSERVICEPROPERTIES_H | ||
1684 | 18 | #define UCSERVICEPROPERTIES_H | ||
1685 | 19 | |||
1686 | 20 | #include <QtCore/QObject> | ||
1687 | 21 | #include <QtQml/QQmlParserStatus> | ||
1688 | 22 | |||
1689 | 23 | class UCServicePropertiesPrivate; | ||
1690 | 24 | class UCServiceProperties : public QObject, public QQmlParserStatus | ||
1691 | 25 | { | ||
1692 | 26 | Q_OBJECT | ||
1693 | 27 | Q_INTERFACES(QQmlParserStatus) | ||
1694 | 28 | |||
1695 | 29 | Q_PROPERTY(ServiceType type READ type WRITE setType NOTIFY typeChanged REVISION 1) | ||
1696 | 30 | Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged REVISION 1) | ||
1697 | 31 | Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged REVISION 1) | ||
1698 | 32 | Q_PROPERTY(QString serviceInterface READ interface WRITE setInterface NOTIFY serviceInterfaceChanged REVISION 1) | ||
1699 | 33 | Q_PROPERTY(QString adaptorInterface READ adaptor WRITE setAdaptor NOTIFY adaptorInterfaceChanged REVISION 1) | ||
1700 | 34 | Q_PROPERTY(QString error READ error NOTIFY errorChanged REVISION 1) | ||
1701 | 35 | Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION 1) | ||
1702 | 36 | |||
1703 | 37 | Q_ENUMS(ServiceType Status) | ||
1704 | 38 | public: | ||
1705 | 39 | enum ServiceType { | ||
1706 | 40 | Undefined, | ||
1707 | 41 | System, | ||
1708 | 42 | Session | ||
1709 | 43 | }; | ||
1710 | 44 | enum Status { | ||
1711 | 45 | Inactive, | ||
1712 | 46 | ConnectionError, | ||
1713 | 47 | Synchronizing, | ||
1714 | 48 | Active | ||
1715 | 49 | }; | ||
1716 | 50 | |||
1717 | 51 | explicit UCServiceProperties(QObject *parent = 0); | ||
1718 | 52 | ~UCServiceProperties(); | ||
1719 | 53 | void classBegin(); | ||
1720 | 54 | void componentComplete(); | ||
1721 | 55 | |||
1722 | 56 | ServiceType type() const; | ||
1723 | 57 | void setType(ServiceType type); | ||
1724 | 58 | QString service() const; | ||
1725 | 59 | void setService(const QString &value); | ||
1726 | 60 | QString path() const; | ||
1727 | 61 | void setPath(const QString &value); | ||
1728 | 62 | QString interface() const; | ||
1729 | 63 | void setInterface(const QString &value); | ||
1730 | 64 | QString adaptor() const; | ||
1731 | 65 | void setAdaptor(const QString &value); | ||
1732 | 66 | QString error(); | ||
1733 | 67 | Status status() const; | ||
1734 | 68 | |||
1735 | 69 | Q_SIGNALS: | ||
1736 | 70 | void typeChanged(); | ||
1737 | 71 | void serviceChanged(); | ||
1738 | 72 | void pathChanged(); | ||
1739 | 73 | void serviceInterfaceChanged(); | ||
1740 | 74 | void adaptorInterfaceChanged(); | ||
1741 | 75 | void errorChanged(); | ||
1742 | 76 | void statusChanged(); | ||
1743 | 77 | |||
1744 | 78 | private: | ||
1745 | 79 | UCServicePropertiesPrivate *d_ptr; | ||
1746 | 80 | Q_DECLARE_PRIVATE_D(d_ptr, UCServiceProperties) | ||
1747 | 81 | }; | ||
1748 | 82 | |||
1749 | 83 | #endif // UCSERVICEPROPERTIES_H | ||
1750 | 0 | 84 | ||
1751 | === removed file 'modules/Ubuntu/Components/plugin/ucserviceproperties.h' | |||
1752 | --- modules/Ubuntu/Components/plugin/ucserviceproperties.h 2014-12-03 08:26:33 +0000 | |||
1753 | +++ modules/Ubuntu/Components/plugin/ucserviceproperties.h 1970-01-01 00:00:00 +0000 | |||
1754 | @@ -1,83 +0,0 @@ | |||
1755 | 1 | /* | ||
1756 | 2 | * Copyright 2014 Canonical Ltd. | ||
1757 | 3 | * | ||
1758 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1759 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1760 | 6 | * the Free Software Foundation; version 3. | ||
1761 | 7 | * | ||
1762 | 8 | * This program is distributed in the hope that it will be useful, | ||
1763 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1764 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1765 | 11 | * GNU Lesser General Public License for more details. | ||
1766 | 12 | * | ||
1767 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1768 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1769 | 15 | */ | ||
1770 | 16 | |||
1771 | 17 | #ifndef UCSERVICEPROPERTIES_H | ||
1772 | 18 | #define UCSERVICEPROPERTIES_H | ||
1773 | 19 | |||
1774 | 20 | #include <QtCore/QObject> | ||
1775 | 21 | #include <QtQml/QQmlParserStatus> | ||
1776 | 22 | |||
1777 | 23 | class UCServicePropertiesPrivate; | ||
1778 | 24 | class UCServiceProperties : public QObject, public QQmlParserStatus | ||
1779 | 25 | { | ||
1780 | 26 | Q_OBJECT | ||
1781 | 27 | Q_INTERFACES(QQmlParserStatus) | ||
1782 | 28 | |||
1783 | 29 | Q_PROPERTY(ServiceType type READ type WRITE setType NOTIFY typeChanged REVISION 1) | ||
1784 | 30 | Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged REVISION 1) | ||
1785 | 31 | Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged REVISION 1) | ||
1786 | 32 | Q_PROPERTY(QString serviceInterface READ interface WRITE setInterface NOTIFY serviceInterfaceChanged REVISION 1) | ||
1787 | 33 | Q_PROPERTY(QString adaptorInterface READ adaptor WRITE setAdaptor NOTIFY adaptorInterfaceChanged REVISION 1) | ||
1788 | 34 | Q_PROPERTY(QString error READ error NOTIFY errorChanged REVISION 1) | ||
1789 | 35 | Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION 1) | ||
1790 | 36 | |||
1791 | 37 | Q_ENUMS(ServiceType Status) | ||
1792 | 38 | public: | ||
1793 | 39 | enum ServiceType { | ||
1794 | 40 | Undefined, | ||
1795 | 41 | System, | ||
1796 | 42 | Session | ||
1797 | 43 | }; | ||
1798 | 44 | enum Status { | ||
1799 | 45 | Inactive, | ||
1800 | 46 | ConnectionError, | ||
1801 | 47 | Synchronizing, | ||
1802 | 48 | Active | ||
1803 | 49 | }; | ||
1804 | 50 | |||
1805 | 51 | explicit UCServiceProperties(QObject *parent = 0); | ||
1806 | 52 | ~UCServiceProperties(); | ||
1807 | 53 | void classBegin(); | ||
1808 | 54 | void componentComplete(); | ||
1809 | 55 | |||
1810 | 56 | ServiceType type() const; | ||
1811 | 57 | void setType(ServiceType type); | ||
1812 | 58 | QString service() const; | ||
1813 | 59 | void setService(const QString &value); | ||
1814 | 60 | QString path() const; | ||
1815 | 61 | void setPath(const QString &value); | ||
1816 | 62 | QString interface() const; | ||
1817 | 63 | void setInterface(const QString &value); | ||
1818 | 64 | QString adaptor() const; | ||
1819 | 65 | void setAdaptor(const QString &value); | ||
1820 | 66 | QString error(); | ||
1821 | 67 | Status status() const; | ||
1822 | 68 | |||
1823 | 69 | Q_SIGNALS: | ||
1824 | 70 | void typeChanged(); | ||
1825 | 71 | void serviceChanged(); | ||
1826 | 72 | void pathChanged(); | ||
1827 | 73 | void serviceInterfaceChanged(); | ||
1828 | 74 | void adaptorInterfaceChanged(); | ||
1829 | 75 | void errorChanged(); | ||
1830 | 76 | void statusChanged(); | ||
1831 | 77 | |||
1832 | 78 | private: | ||
1833 | 79 | UCServicePropertiesPrivate *d_ptr; | ||
1834 | 80 | Q_DECLARE_PRIVATE_D(d_ptr, UCServiceProperties) | ||
1835 | 81 | }; | ||
1836 | 82 | |||
1837 | 83 | #endif // UCSERVICEPROPERTIES_H | ||
1838 | 84 | 0 | ||
1839 | === added file 'modules/Ubuntu/Components/plugin/ucserviceproperties_p.h' | |||
1840 | --- modules/Ubuntu/Components/plugin/ucserviceproperties_p.h 1970-01-01 00:00:00 +0000 | |||
1841 | +++ modules/Ubuntu/Components/plugin/ucserviceproperties_p.h 2015-02-11 08:57:32 +0000 | |||
1842 | @@ -0,0 +1,54 @@ | |||
1843 | 1 | /* | ||
1844 | 2 | * Copyright 2014 Canonical Ltd. | ||
1845 | 3 | * | ||
1846 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1847 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1848 | 6 | * the Free Software Foundation; version 3. | ||
1849 | 7 | * | ||
1850 | 8 | * This program is distributed in the hope that it will be useful, | ||
1851 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1852 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1853 | 11 | * GNU Lesser General Public License for more details. | ||
1854 | 12 | * | ||
1855 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1856 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1857 | 15 | */ | ||
1858 | 16 | |||
1859 | 17 | #ifndef UCSERVICEPROPERTIES_P_H | ||
1860 | 18 | #define UCSERVICEPROPERTIES_P_H | ||
1861 | 19 | |||
1862 | 20 | #include "ucserviceproperties.h" | ||
1863 | 21 | #include <QtCore/QStringList> | ||
1864 | 22 | |||
1865 | 23 | class UCServicePropertiesPrivate | ||
1866 | 24 | { | ||
1867 | 25 | public: | ||
1868 | 26 | UCServicePropertiesPrivate(UCServiceProperties *qq); | ||
1869 | 27 | virtual ~UCServicePropertiesPrivate(); | ||
1870 | 28 | |||
1871 | 29 | static UCServicePropertiesPrivate *get(UCServiceProperties *service); | ||
1872 | 30 | void warning(const QString &message); | ||
1873 | 31 | void setError(const QString &msg); | ||
1874 | 32 | void setStatus(UCServiceProperties::Status status); | ||
1875 | 33 | |||
1876 | 34 | virtual bool init() = 0; | ||
1877 | 35 | virtual bool fetchPropertyValues() = 0; | ||
1878 | 36 | virtual bool readProperty(const QString &property) = 0; | ||
1879 | 37 | virtual bool testProperty(const QString &property, const QVariant &value) = 0; | ||
1880 | 38 | |||
1881 | 39 | // data | ||
1882 | 40 | UCServiceProperties *q_ptr; | ||
1883 | 41 | bool ready:1; | ||
1884 | 42 | UCServiceProperties::Status status; | ||
1885 | 43 | UCServiceProperties::ServiceType type; | ||
1886 | 44 | QString service; | ||
1887 | 45 | QString path; | ||
1888 | 46 | QString interface; | ||
1889 | 47 | QString adaptor; | ||
1890 | 48 | QString error; | ||
1891 | 49 | QStringList properties; | ||
1892 | 50 | }; | ||
1893 | 51 | |||
1894 | 52 | UCServicePropertiesPrivate *createServicePropertiesAdapter(UCServiceProperties *owner); | ||
1895 | 53 | |||
1896 | 54 | #endif // UCSERVICEPROPERTIES_P_H | ||
1897 | 0 | 55 | ||
1898 | === removed file 'modules/Ubuntu/Components/plugin/ucserviceproperties_p.h' | |||
1899 | --- modules/Ubuntu/Components/plugin/ucserviceproperties_p.h 2014-12-03 08:26:33 +0000 | |||
1900 | +++ modules/Ubuntu/Components/plugin/ucserviceproperties_p.h 1970-01-01 00:00:00 +0000 | |||
1901 | @@ -1,53 +0,0 @@ | |||
1902 | 1 | /* | ||
1903 | 2 | * Copyright 2014 Canonical Ltd. | ||
1904 | 3 | * | ||
1905 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1906 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1907 | 6 | * the Free Software Foundation; version 3. | ||
1908 | 7 | * | ||
1909 | 8 | * This program is distributed in the hope that it will be useful, | ||
1910 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1911 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1912 | 11 | * GNU Lesser General Public License for more details. | ||
1913 | 12 | * | ||
1914 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1915 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1916 | 15 | */ | ||
1917 | 16 | |||
1918 | 17 | #ifndef UCSERVICEPROPERTIES_P_H | ||
1919 | 18 | #define UCSERVICEPROPERTIES_P_H | ||
1920 | 19 | |||
1921 | 20 | #include "ucserviceproperties.h" | ||
1922 | 21 | #include <QtCore/QStringList> | ||
1923 | 22 | |||
1924 | 23 | class UCServicePropertiesPrivate | ||
1925 | 24 | { | ||
1926 | 25 | public: | ||
1927 | 26 | UCServicePropertiesPrivate(UCServiceProperties *qq); | ||
1928 | 27 | virtual ~UCServicePropertiesPrivate(); | ||
1929 | 28 | |||
1930 | 29 | static UCServicePropertiesPrivate *get(UCServiceProperties *service); | ||
1931 | 30 | void setError(const QString &msg); | ||
1932 | 31 | void setStatus(UCServiceProperties::Status status); | ||
1933 | 32 | |||
1934 | 33 | virtual bool init() = 0; | ||
1935 | 34 | virtual bool fetchPropertyValues() = 0; | ||
1936 | 35 | virtual bool readProperty(const QString &property) = 0; | ||
1937 | 36 | virtual bool testProperty(const QString &property, const QVariant &value) = 0; | ||
1938 | 37 | |||
1939 | 38 | // data | ||
1940 | 39 | UCServiceProperties *q_ptr; | ||
1941 | 40 | bool ready:1; | ||
1942 | 41 | UCServiceProperties::Status status; | ||
1943 | 42 | UCServiceProperties::ServiceType type; | ||
1944 | 43 | QString service; | ||
1945 | 44 | QString path; | ||
1946 | 45 | QString interface; | ||
1947 | 46 | QString adaptor; | ||
1948 | 47 | QString error; | ||
1949 | 48 | QStringList properties; | ||
1950 | 49 | }; | ||
1951 | 50 | |||
1952 | 51 | UCServicePropertiesPrivate *createServicePropertiesAdapter(UCServiceProperties *owner); | ||
1953 | 52 | |||
1954 | 53 | #endif // UCSERVICEPROPERTIES_P_H | ||
1955 | 54 | 0 | ||
1956 | === modified file 'modules/Ubuntu/Components/qmldir' | |||
1957 | --- modules/Ubuntu/Components/qmldir 2015-01-26 17:01:21 +0000 | |||
1958 | +++ modules/Ubuntu/Components/qmldir 2015-02-11 08:57:32 +0000 | |||
1959 | @@ -105,3 +105,6 @@ | |||
1960 | 105 | StyledItem 1.1 StyledItem.qml | 105 | StyledItem 1.1 StyledItem.qml |
1961 | 106 | singleton UbuntuColors 1.1 11/UbuntuColors.qml | 106 | singleton UbuntuColors 1.1 11/UbuntuColors.qml |
1962 | 107 | internal MainViewBase MainViewBase.qml | 107 | internal MainViewBase MainViewBase.qml |
1963 | 108 | |||
1964 | 109 | singleton Haptics 0.1 11/Haptics.qml | ||
1965 | 110 | singleton Haptics 1.0 11/Haptics.qml | ||
1966 | 108 | 111 | ||
1967 | === modified file 'tests/unit/runtest.sh' | |||
1968 | --- tests/unit/runtest.sh 2015-01-20 09:56:46 +0000 | |||
1969 | +++ tests/unit/runtest.sh 2015-02-11 08:57:32 +0000 | |||
1970 | @@ -63,6 +63,7 @@ | |||
1971 | 63 | 63 | ||
1972 | 64 | QML2_IMPORT_PATH=${_IMPORT_PATH} UBUNTU_UI_TOOLKIT_THEMES_PATH=${_THEMES_PATH} \ | 64 | QML2_IMPORT_PATH=${_IMPORT_PATH} UBUNTU_UI_TOOLKIT_THEMES_PATH=${_THEMES_PATH} \ |
1973 | 65 | ALARM_BACKEND=memory \ | 65 | ALARM_BACKEND=memory \ |
1974 | 66 | SUPPRESS_SERVICEPROPERTIES_WARNINGS=yes \ | ||
1975 | 66 | $_CMD $_ARGS 2>&1 | grep -v 'QFontDatabase: Cannot find font directory' | 67 | $_CMD $_ARGS 2>&1 | grep -v 'QFontDatabase: Cannot find font directory' |
1976 | 67 | # Note: Get first command before the pipe, $? would be ambiguous | 68 | # Note: Get first command before the pipe, $? would be ambiguous |
1977 | 68 | RESULT=${PIPESTATUS[0]} | 69 | RESULT=${PIPESTATUS[0]} |
1978 | 69 | 70 | ||
1979 | === added file 'tests/unit/tst_components/tst_haptics.qml' | |||
1980 | --- tests/unit/tst_components/tst_haptics.qml 1970-01-01 00:00:00 +0000 | |||
1981 | +++ tests/unit/tst_components/tst_haptics.qml 2015-02-11 08:57:32 +0000 | |||
1982 | @@ -0,0 +1,52 @@ | |||
1983 | 1 | /* | ||
1984 | 2 | * Copyright 2014 Canonical Ltd. | ||
1985 | 3 | * | ||
1986 | 4 | * This program is free software; you can redistribute it and/or modify | ||
1987 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
1988 | 6 | * the Free Software Foundation; version 3. | ||
1989 | 7 | * | ||
1990 | 8 | * This program is distributed in the hope that it will be useful, | ||
1991 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1992 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1993 | 11 | * GNU Lesser General Public License for more details. | ||
1994 | 12 | * | ||
1995 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1996 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1997 | 15 | */ | ||
1998 | 16 | |||
1999 | 17 | import QtQuick 2.3 | ||
2000 | 18 | import QtTest 1.0 | ||
2001 | 19 | import Ubuntu.Components 1.1 | ||
2002 | 20 | import Ubuntu.Test 1.0 | ||
2003 | 21 | import QtFeedback 5.0 | ||
2004 | 22 | |||
2005 | 23 | UbuntuTestCase { | ||
2006 | 24 | name: "HapticsAPI" | ||
2007 | 25 | |||
2008 | 26 | function waitForHapticsCompleted() { | ||
2009 | 27 | tryCompareFunction(function() { return Haptics.effect.state; }, HapticsEffect.Stopped, 1000); | ||
2010 | 28 | } | ||
2011 | 29 | |||
2012 | 30 | function test_0_defaults() { | ||
2013 | 31 | verify(Haptics.hasOwnProperty("enabled"), "missing property 'enabled'"); | ||
2014 | 32 | verify(Haptics.hasOwnProperty("effect"), "missing property 'effect'"); | ||
2015 | 33 | verify(Haptics.hasOwnProperty("play"), "missing function 'play'"); | ||
2016 | 34 | } | ||
2017 | 35 | |||
2018 | 36 | function test_play() { | ||
2019 | 37 | Haptics.play(); | ||
2020 | 38 | if (Haptics.enabled) { | ||
2021 | 39 | waitForHapticsCompleted(); | ||
2022 | 40 | } | ||
2023 | 41 | } | ||
2024 | 42 | |||
2025 | 43 | function test_custom_play() { | ||
2026 | 44 | Haptics.play({attackTime: 10, attackIntensity: 0.5, duration: 1200}); | ||
2027 | 45 | if (Haptics.enabled && Haptics.effect.running) { | ||
2028 | 46 | compare(Haptics.effect.attackTime, 10, "attack time not modified"); | ||
2029 | 47 | compare(Haptics.effect.attackIntensity, 0.5, "attack intensity not modified"); | ||
2030 | 48 | compare(Haptics.effect.duration, 400, "duration not modified"); | ||
2031 | 49 | waitForHapticsCompleted(); | ||
2032 | 50 | } | ||
2033 | 51 | } | ||
2034 | 52 | } | ||
2035 | 0 | 53 | ||
2036 | === added directory 'tests/unit_x11/tst_serviceproperties' | |||
2037 | === removed directory 'tests/unit_x11/tst_serviceproperties' | |||
2038 | === added file 'tests/unit_x11/tst_serviceproperties/IncomingCallVibrateWatcher.qml' | |||
2039 | --- tests/unit_x11/tst_serviceproperties/IncomingCallVibrateWatcher.qml 1970-01-01 00:00:00 +0000 | |||
2040 | +++ tests/unit_x11/tst_serviceproperties/IncomingCallVibrateWatcher.qml 2015-02-11 08:57:32 +0000 | |||
2041 | @@ -0,0 +1,31 @@ | |||
2042 | 1 | /* | ||
2043 | 2 | * Copyright 2014 Canonical Ltd. | ||
2044 | 3 | * | ||
2045 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2046 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2047 | 6 | * the Free Software Foundation; version 3. | ||
2048 | 7 | * | ||
2049 | 8 | * This program is distributed in the hope that it will be useful, | ||
2050 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2051 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2052 | 11 | * GNU Lesser General Public License for more details. | ||
2053 | 12 | * | ||
2054 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2055 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2056 | 15 | */ | ||
2057 | 16 | |||
2058 | 17 | import QtQuick 2.3 | ||
2059 | 18 | import Ubuntu.Components 1.1 | ||
2060 | 19 | |||
2061 | 20 | Item { | ||
2062 | 21 | property alias service: service | ||
2063 | 22 | ServiceProperties { | ||
2064 | 23 | id: service | ||
2065 | 24 | service: "org.freedesktop.Accounts" | ||
2066 | 25 | serviceInterface: "org.freedesktop.Accounts" | ||
2067 | 26 | path: "/org/freedesktop/Accounts" | ||
2068 | 27 | adaptorInterface: "com.ubuntu.touch.AccountsService.Sound" | ||
2069 | 28 | |||
2070 | 29 | property bool incomingCallVibrate: true | ||
2071 | 30 | } | ||
2072 | 31 | } | ||
2073 | 0 | 32 | ||
2074 | === removed file 'tests/unit_x11/tst_serviceproperties/IncomingCallVibrateWatcher.qml' | |||
2075 | --- tests/unit_x11/tst_serviceproperties/IncomingCallVibrateWatcher.qml 2014-12-03 08:26:33 +0000 | |||
2076 | +++ tests/unit_x11/tst_serviceproperties/IncomingCallVibrateWatcher.qml 1970-01-01 00:00:00 +0000 | |||
2077 | @@ -1,31 +0,0 @@ | |||
2078 | 1 | /* | ||
2079 | 2 | * Copyright 2014 Canonical Ltd. | ||
2080 | 3 | * | ||
2081 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2082 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2083 | 6 | * the Free Software Foundation; version 3. | ||
2084 | 7 | * | ||
2085 | 8 | * This program is distributed in the hope that it will be useful, | ||
2086 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2087 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2088 | 11 | * GNU Lesser General Public License for more details. | ||
2089 | 12 | * | ||
2090 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2091 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2092 | 15 | */ | ||
2093 | 16 | |||
2094 | 17 | import QtQuick 2.3 | ||
2095 | 18 | import Ubuntu.Components 1.1 | ||
2096 | 19 | |||
2097 | 20 | Item { | ||
2098 | 21 | property alias service: service | ||
2099 | 22 | ServiceProperties { | ||
2100 | 23 | id: service | ||
2101 | 24 | service: "org.freedesktop.Accounts" | ||
2102 | 25 | serviceInterface: "org.freedesktop.Accounts" | ||
2103 | 26 | path: "/org/freedesktop/Accounts" | ||
2104 | 27 | adaptorInterface: "com.ubuntu.touch.AccountsService.Sound" | ||
2105 | 28 | |||
2106 | 29 | property bool incomingCallVibrate: true | ||
2107 | 30 | } | ||
2108 | 31 | } | ||
2109 | 32 | 0 | ||
2110 | === added file 'tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher.qml' | |||
2111 | --- tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher.qml 1970-01-01 00:00:00 +0000 | |||
2112 | +++ tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher.qml 2015-02-11 08:57:32 +0000 | |||
2113 | @@ -0,0 +1,31 @@ | |||
2114 | 1 | /* | ||
2115 | 2 | * Copyright 2014 Canonical Ltd. | ||
2116 | 3 | * | ||
2117 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2118 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2119 | 6 | * the Free Software Foundation; version 3. | ||
2120 | 7 | * | ||
2121 | 8 | * This program is distributed in the hope that it will be useful, | ||
2122 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2123 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2124 | 11 | * GNU Lesser General Public License for more details. | ||
2125 | 12 | * | ||
2126 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2127 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2128 | 15 | */ | ||
2129 | 16 | |||
2130 | 17 | import QtQuick 2.3 | ||
2131 | 18 | import Ubuntu.Components 1.1 | ||
2132 | 19 | |||
2133 | 20 | Item { | ||
2134 | 21 | property alias service: service | ||
2135 | 22 | ServiceProperties { | ||
2136 | 23 | id: service | ||
2137 | 24 | service: "org.freedesktop.Accounts" | ||
2138 | 25 | serviceInterface: "org.freedesktop.Accounts" | ||
2139 | 26 | path: "/org/freedesktop/Accounts" | ||
2140 | 27 | adaptorInterface: "com.ubuntu.touch.AccountsService.Sound" | ||
2141 | 28 | |||
2142 | 29 | property bool thisIsAnInvalidPropertyToWatch: true | ||
2143 | 30 | } | ||
2144 | 31 | } | ||
2145 | 0 | 32 | ||
2146 | === removed file 'tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher.qml' | |||
2147 | --- tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher.qml 2014-12-03 08:26:33 +0000 | |||
2148 | +++ tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher.qml 1970-01-01 00:00:00 +0000 | |||
2149 | @@ -1,31 +0,0 @@ | |||
2150 | 1 | /* | ||
2151 | 2 | * Copyright 2014 Canonical Ltd. | ||
2152 | 3 | * | ||
2153 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2154 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2155 | 6 | * the Free Software Foundation; version 3. | ||
2156 | 7 | * | ||
2157 | 8 | * This program is distributed in the hope that it will be useful, | ||
2158 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2159 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2160 | 11 | * GNU Lesser General Public License for more details. | ||
2161 | 12 | * | ||
2162 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2163 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2164 | 15 | */ | ||
2165 | 16 | |||
2166 | 17 | import QtQuick 2.3 | ||
2167 | 18 | import Ubuntu.Components 1.1 | ||
2168 | 19 | |||
2169 | 20 | Item { | ||
2170 | 21 | property alias service: service | ||
2171 | 22 | ServiceProperties { | ||
2172 | 23 | id: service | ||
2173 | 24 | service: "org.freedesktop.Accounts" | ||
2174 | 25 | serviceInterface: "org.freedesktop.Accounts" | ||
2175 | 26 | path: "/org/freedesktop/Accounts" | ||
2176 | 27 | adaptorInterface: "com.ubuntu.touch.AccountsService.Sound" | ||
2177 | 28 | |||
2178 | 29 | property bool thisIsAnInvalidPropertyToWatch: true | ||
2179 | 30 | } | ||
2180 | 31 | } | ||
2181 | 32 | 0 | ||
2182 | === added file 'tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher2.qml' | |||
2183 | --- tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher2.qml 1970-01-01 00:00:00 +0000 | |||
2184 | +++ tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher2.qml 2015-02-11 08:57:32 +0000 | |||
2185 | @@ -0,0 +1,32 @@ | |||
2186 | 1 | /* | ||
2187 | 2 | * Copyright 2014 Canonical Ltd. | ||
2188 | 3 | * | ||
2189 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2190 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2191 | 6 | * the Free Software Foundation; version 3. | ||
2192 | 7 | * | ||
2193 | 8 | * This program is distributed in the hope that it will be useful, | ||
2194 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2195 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2196 | 11 | * GNU Lesser General Public License for more details. | ||
2197 | 12 | * | ||
2198 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2199 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2200 | 15 | */ | ||
2201 | 16 | |||
2202 | 17 | import QtQuick 2.3 | ||
2203 | 18 | import Ubuntu.Components 1.1 | ||
2204 | 19 | |||
2205 | 20 | Item { | ||
2206 | 21 | property alias service: service | ||
2207 | 22 | ServiceProperties { | ||
2208 | 23 | id: service | ||
2209 | 24 | service: "org.freedesktop.Accounts" | ||
2210 | 25 | serviceInterface: "org.freedesktop.Accounts" | ||
2211 | 26 | path: "/org/freedesktop/Accounts" | ||
2212 | 27 | adaptorInterface: "com.ubuntu.touch.AccountsService.Sound" | ||
2213 | 28 | |||
2214 | 29 | property bool thisIsAnInvalidPropertyToWatch: true | ||
2215 | 30 | property bool incomingCallVibrate: true | ||
2216 | 31 | } | ||
2217 | 32 | } | ||
2218 | 0 | 33 | ||
2219 | === removed file 'tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher2.qml' | |||
2220 | --- tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher2.qml 2014-12-03 08:26:33 +0000 | |||
2221 | +++ tests/unit_x11/tst_serviceproperties/InvalidPropertyWatcher2.qml 1970-01-01 00:00:00 +0000 | |||
2222 | @@ -1,32 +0,0 @@ | |||
2223 | 1 | /* | ||
2224 | 2 | * Copyright 2014 Canonical Ltd. | ||
2225 | 3 | * | ||
2226 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2227 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2228 | 6 | * the Free Software Foundation; version 3. | ||
2229 | 7 | * | ||
2230 | 8 | * This program is distributed in the hope that it will be useful, | ||
2231 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2232 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2233 | 11 | * GNU Lesser General Public License for more details. | ||
2234 | 12 | * | ||
2235 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2236 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2237 | 15 | */ | ||
2238 | 16 | |||
2239 | 17 | import QtQuick 2.3 | ||
2240 | 18 | import Ubuntu.Components 1.1 | ||
2241 | 19 | |||
2242 | 20 | Item { | ||
2243 | 21 | property alias service: service | ||
2244 | 22 | ServiceProperties { | ||
2245 | 23 | id: service | ||
2246 | 24 | service: "org.freedesktop.Accounts" | ||
2247 | 25 | serviceInterface: "org.freedesktop.Accounts" | ||
2248 | 26 | path: "/org/freedesktop/Accounts" | ||
2249 | 27 | adaptorInterface: "com.ubuntu.touch.AccountsService.Sound" | ||
2250 | 28 | |||
2251 | 29 | property bool thisIsAnInvalidPropertyToWatch: true | ||
2252 | 30 | property bool incomingCallVibrate: true | ||
2253 | 31 | } | ||
2254 | 32 | } | ||
2255 | 33 | 0 | ||
2256 | === added file 'tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp' | |||
2257 | --- tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp 1970-01-01 00:00:00 +0000 | |||
2258 | +++ tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp 2015-02-11 08:57:32 +0000 | |||
2259 | @@ -0,0 +1,146 @@ | |||
2260 | 1 | /* | ||
2261 | 2 | * Copyright 2014 Canonical Ltd. | ||
2262 | 3 | * | ||
2263 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2264 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2265 | 6 | * the Free Software Foundation; version 3. | ||
2266 | 7 | * | ||
2267 | 8 | * This program is distributed in the hope that it will be useful, | ||
2268 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2269 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2270 | 11 | * GNU Lesser General Public License for more details. | ||
2271 | 12 | * | ||
2272 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2273 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2274 | 15 | */ | ||
2275 | 16 | |||
2276 | 17 | #include "uctestcase.h" | ||
2277 | 18 | #include "ucserviceproperties.h" | ||
2278 | 19 | #include "ucserviceproperties_p.h" | ||
2279 | 20 | #include <QtCore/QString> | ||
2280 | 21 | #include <QtCore/QDebug> | ||
2281 | 22 | #include <QtTest/QTest> | ||
2282 | 23 | #include <QtTest/QSignalSpy> | ||
2283 | 24 | |||
2284 | 25 | class tst_ServiceProperties : public QObject | ||
2285 | 26 | { | ||
2286 | 27 | Q_OBJECT | ||
2287 | 28 | |||
2288 | 29 | public: | ||
2289 | 30 | tst_ServiceProperties() {} | ||
2290 | 31 | |||
2291 | 32 | private: | ||
2292 | 33 | |||
2293 | 34 | QString error; | ||
2294 | 35 | |||
2295 | 36 | // FIXME use UbuntuTestCase::ignoreWaring in Vivid | ||
2296 | 37 | void ignoreWarning(const QString& fileName, uint line, uint column, const QString& message, uint occurences=1) | ||
2297 | 38 | { | ||
2298 | 39 | for (uint i = 0; i < occurences; i++) { | ||
2299 | 40 | QString url(QUrl::fromLocalFile(QFileInfo(fileName).absoluteFilePath()).toEncoded()); | ||
2300 | 41 | QString warning(QString("%1:%2:%3: %4").arg(url).arg(line).arg(column).arg(message)); | ||
2301 | 42 | QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); | ||
2302 | 43 | } | ||
2303 | 44 | } | ||
2304 | 45 | |||
2305 | 46 | |||
2306 | 47 | private Q_SLOTS: | ||
2307 | 48 | |||
2308 | 49 | void initTestCase() | ||
2309 | 50 | { | ||
2310 | 51 | // check if the connection is possible, otherwise we must skip all tests | ||
2311 | 52 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("IncomingCallVibrateWatcher.qml")); | ||
2312 | 53 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2313 | 54 | QVERIFY(watcher); | ||
2314 | 55 | if (watcher->status() == UCServiceProperties::Synchronizing || | ||
2315 | 56 | watcher->status() == UCServiceProperties::Inactive) { | ||
2316 | 57 | QSignalSpy wait(watcher, SIGNAL(statusChanged())); | ||
2317 | 58 | wait.wait(); | ||
2318 | 59 | } | ||
2319 | 60 | if (watcher->status() == UCServiceProperties::ConnectionError) { | ||
2320 | 61 | error = "Skip test: " + watcher->error(); | ||
2321 | 62 | } | ||
2322 | 63 | } | ||
2323 | 64 | |||
2324 | 65 | void test_change_property() | ||
2325 | 66 | { | ||
2326 | 67 | if (!error.isEmpty()) { | ||
2327 | 68 | QSKIP(qPrintable(error)); | ||
2328 | 69 | } | ||
2329 | 70 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("IncomingCallVibrateWatcher.qml")); | ||
2330 | 71 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2331 | 72 | QVERIFY(watcher); | ||
2332 | 73 | |||
2333 | 74 | bool backup = watcher->property("incomingCallVibrate").toBool(); | ||
2334 | 75 | UCServicePropertiesPrivate *pWatcher = UCServicePropertiesPrivate::get(watcher); | ||
2335 | 76 | QSignalSpy spy(watcher, SIGNAL(incomingCallVibrateChanged())); | ||
2336 | 77 | pWatcher->testProperty("IncomingCallVibrate", !backup); | ||
2337 | 78 | spy.wait(400); | ||
2338 | 79 | QCOMPARE(spy.count(), 1); | ||
2339 | 80 | QCOMPARE(watcher->property("incomingCallVibrate").toBool(), !backup); | ||
2340 | 81 | |||
2341 | 82 | // restore value | ||
2342 | 83 | spy.clear(); | ||
2343 | 84 | pWatcher->testProperty("IncomingCallVibrate", backup); | ||
2344 | 85 | spy.wait(400); | ||
2345 | 86 | } | ||
2346 | 87 | |||
2347 | 88 | void test_invalid_property() | ||
2348 | 89 | { | ||
2349 | 90 | if (!error.isEmpty()) { | ||
2350 | 91 | QSKIP(qPrintable(error)); | ||
2351 | 92 | } | ||
2352 | 93 | ignoreWarning("InvalidPropertyWatcher.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'"); | ||
2353 | 94 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("InvalidPropertyWatcher.qml")); | ||
2354 | 95 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2355 | 96 | QVERIFY(watcher); | ||
2356 | 97 | // error should not be set | ||
2357 | 98 | QCOMPARE(watcher->property("error").toString(), QString()); | ||
2358 | 99 | } | ||
2359 | 100 | |||
2360 | 101 | void test_one_valid_one_invalid_property() | ||
2361 | 102 | { | ||
2362 | 103 | if (!error.isEmpty()) { | ||
2363 | 104 | QSKIP(qPrintable(error)); | ||
2364 | 105 | } | ||
2365 | 106 | ignoreWarning("InvalidPropertyWatcher2.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'"); | ||
2366 | 107 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("InvalidPropertyWatcher2.qml")); | ||
2367 | 108 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2368 | 109 | QVERIFY(watcher); | ||
2369 | 110 | // error should not be set | ||
2370 | 111 | QCOMPARE(watcher->property("error").toString(), QString()); | ||
2371 | 112 | } | ||
2372 | 113 | |||
2373 | 114 | void test_change_connection_props_data() | ||
2374 | 115 | { | ||
2375 | 116 | QTest::addColumn<QString>("property"); | ||
2376 | 117 | QTest::addColumn<QString>("value"); | ||
2377 | 118 | |||
2378 | 119 | QTest::newRow("Changing servcie") << "service" << "anything.else"; | ||
2379 | 120 | QTest::newRow("Changing interface") << "serviceInterface" << "anything.else"; | ||
2380 | 121 | QTest::newRow("Changing adaptor") << "adaptorInterface" << "anything.else"; | ||
2381 | 122 | } | ||
2382 | 123 | void test_change_connection_props() | ||
2383 | 124 | { | ||
2384 | 125 | QFETCH(QString, property); | ||
2385 | 126 | QFETCH(QString, value); | ||
2386 | 127 | |||
2387 | 128 | if (!error.isEmpty()) { | ||
2388 | 129 | QSKIP(qPrintable(error)); | ||
2389 | 130 | } | ||
2390 | 131 | ignoreWarning("IncomingCallVibrateWatcher.qml", 22, 5, "QML ServiceProperties: Changing connection parameters forbidden."); | ||
2391 | 132 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("IncomingCallVibrateWatcher.qml")); | ||
2392 | 133 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2393 | 134 | QVERIFY(watcher); | ||
2394 | 135 | |||
2395 | 136 | // try to change the property | ||
2396 | 137 | watcher->setProperty(property.toLocal8Bit().constData(), value); | ||
2397 | 138 | // no error should be reported | ||
2398 | 139 | QCOMPARE(watcher->property("error").toString(), QString()); | ||
2399 | 140 | } | ||
2400 | 141 | |||
2401 | 142 | }; | ||
2402 | 143 | |||
2403 | 144 | QTEST_MAIN(tst_ServiceProperties) | ||
2404 | 145 | |||
2405 | 146 | #include "tst_serviceproperties.moc" | ||
2406 | 0 | 147 | ||
2407 | === removed file 'tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp' | |||
2408 | --- tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp 2014-12-03 10:22:17 +0000 | |||
2409 | +++ tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp 1970-01-01 00:00:00 +0000 | |||
2410 | @@ -1,146 +0,0 @@ | |||
2411 | 1 | /* | ||
2412 | 2 | * Copyright 2014 Canonical Ltd. | ||
2413 | 3 | * | ||
2414 | 4 | * This program is free software; you can redistribute it and/or modify | ||
2415 | 5 | * it under the terms of the GNU Lesser General Public License as published by | ||
2416 | 6 | * the Free Software Foundation; version 3. | ||
2417 | 7 | * | ||
2418 | 8 | * This program is distributed in the hope that it will be useful, | ||
2419 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2420 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2421 | 11 | * GNU Lesser General Public License for more details. | ||
2422 | 12 | * | ||
2423 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2424 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2425 | 15 | */ | ||
2426 | 16 | |||
2427 | 17 | #include "uctestcase.h" | ||
2428 | 18 | #include "ucserviceproperties.h" | ||
2429 | 19 | #include "ucserviceproperties_p.h" | ||
2430 | 20 | #include <QtCore/QString> | ||
2431 | 21 | #include <QtCore/QDebug> | ||
2432 | 22 | #include <QtTest/QTest> | ||
2433 | 23 | #include <QtTest/QSignalSpy> | ||
2434 | 24 | |||
2435 | 25 | class tst_ServiceProperties : public QObject | ||
2436 | 26 | { | ||
2437 | 27 | Q_OBJECT | ||
2438 | 28 | |||
2439 | 29 | public: | ||
2440 | 30 | tst_ServiceProperties() {} | ||
2441 | 31 | |||
2442 | 32 | private: | ||
2443 | 33 | |||
2444 | 34 | QString error; | ||
2445 | 35 | |||
2446 | 36 | // FIXME use UbuntuTestCase::ignoreWaring in Vivid | ||
2447 | 37 | void ignoreWarning(const QString& fileName, uint line, uint column, const QString& message, uint occurences=1) | ||
2448 | 38 | { | ||
2449 | 39 | for (uint i = 0; i < occurences; i++) { | ||
2450 | 40 | QString url(QUrl::fromLocalFile(QFileInfo(fileName).absoluteFilePath()).toEncoded()); | ||
2451 | 41 | QString warning(QString("%1:%2:%3: %4").arg(url).arg(line).arg(column).arg(message)); | ||
2452 | 42 | QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); | ||
2453 | 43 | } | ||
2454 | 44 | } | ||
2455 | 45 | |||
2456 | 46 | |||
2457 | 47 | private Q_SLOTS: | ||
2458 | 48 | |||
2459 | 49 | void initTestCase() | ||
2460 | 50 | { | ||
2461 | 51 | // check if the connection is possible, otherwise we must skip all tests | ||
2462 | 52 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("IncomingCallVibrateWatcher.qml")); | ||
2463 | 53 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2464 | 54 | QVERIFY(watcher); | ||
2465 | 55 | if (watcher->status() == UCServiceProperties::Synchronizing || | ||
2466 | 56 | watcher->status() == UCServiceProperties::Inactive) { | ||
2467 | 57 | QSignalSpy wait(watcher, SIGNAL(statusChanged())); | ||
2468 | 58 | wait.wait(); | ||
2469 | 59 | } | ||
2470 | 60 | if (watcher->status() == UCServiceProperties::ConnectionError) { | ||
2471 | 61 | error = "Skip test: " + watcher->error(); | ||
2472 | 62 | } | ||
2473 | 63 | } | ||
2474 | 64 | |||
2475 | 65 | void test_change_property() | ||
2476 | 66 | { | ||
2477 | 67 | if (!error.isEmpty()) { | ||
2478 | 68 | QSKIP(qPrintable(error)); | ||
2479 | 69 | } | ||
2480 | 70 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("IncomingCallVibrateWatcher.qml")); | ||
2481 | 71 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2482 | 72 | QVERIFY(watcher); | ||
2483 | 73 | |||
2484 | 74 | bool backup = watcher->property("incomingCallVibrate").toBool(); | ||
2485 | 75 | UCServicePropertiesPrivate *pWatcher = UCServicePropertiesPrivate::get(watcher); | ||
2486 | 76 | QSignalSpy spy(watcher, SIGNAL(incomingCallVibrateChanged())); | ||
2487 | 77 | pWatcher->testProperty("IncomingCallVibrate", !backup); | ||
2488 | 78 | spy.wait(400); | ||
2489 | 79 | QCOMPARE(spy.count(), 1); | ||
2490 | 80 | QCOMPARE(watcher->property("incomingCallVibrate").toBool(), !backup); | ||
2491 | 81 | |||
2492 | 82 | // restore value | ||
2493 | 83 | spy.clear(); | ||
2494 | 84 | pWatcher->testProperty("IncomingCallVibrate", backup); | ||
2495 | 85 | spy.wait(400); | ||
2496 | 86 | } | ||
2497 | 87 | |||
2498 | 88 | void test_invalid_property() | ||
2499 | 89 | { | ||
2500 | 90 | if (!error.isEmpty()) { | ||
2501 | 91 | QSKIP(qPrintable(error)); | ||
2502 | 92 | } | ||
2503 | 93 | ignoreWarning("InvalidPropertyWatcher.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'"); | ||
2504 | 94 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("InvalidPropertyWatcher.qml")); | ||
2505 | 95 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2506 | 96 | QVERIFY(watcher); | ||
2507 | 97 | // error should not be set | ||
2508 | 98 | QCOMPARE(watcher->property("error").toString(), QString()); | ||
2509 | 99 | } | ||
2510 | 100 | |||
2511 | 101 | void test_one_valid_one_invalid_property() | ||
2512 | 102 | { | ||
2513 | 103 | if (!error.isEmpty()) { | ||
2514 | 104 | QSKIP(qPrintable(error)); | ||
2515 | 105 | } | ||
2516 | 106 | ignoreWarning("InvalidPropertyWatcher2.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'"); | ||
2517 | 107 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("InvalidPropertyWatcher2.qml")); | ||
2518 | 108 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2519 | 109 | QVERIFY(watcher); | ||
2520 | 110 | // error should not be set | ||
2521 | 111 | QCOMPARE(watcher->property("error").toString(), QString()); | ||
2522 | 112 | } | ||
2523 | 113 | |||
2524 | 114 | void test_change_connection_props_data() | ||
2525 | 115 | { | ||
2526 | 116 | QTest::addColumn<QString>("property"); | ||
2527 | 117 | QTest::addColumn<QString>("value"); | ||
2528 | 118 | |||
2529 | 119 | QTest::newRow("Changing servcie") << "service" << "anything.else"; | ||
2530 | 120 | QTest::newRow("Changing interface") << "serviceInterface" << "anything.else"; | ||
2531 | 121 | QTest::newRow("Changing adaptor") << "adaptorInterface" << "anything.else"; | ||
2532 | 122 | } | ||
2533 | 123 | void test_change_connection_props() | ||
2534 | 124 | { | ||
2535 | 125 | QFETCH(QString, property); | ||
2536 | 126 | QFETCH(QString, value); | ||
2537 | 127 | |||
2538 | 128 | if (!error.isEmpty()) { | ||
2539 | 129 | QSKIP(qPrintable(error)); | ||
2540 | 130 | } | ||
2541 | 131 | ignoreWarning("IncomingCallVibrateWatcher.qml", 22, 5, "QML ServiceProperties: Changing connection parameters forbidden."); | ||
2542 | 132 | QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("IncomingCallVibrateWatcher.qml")); | ||
2543 | 133 | UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>()); | ||
2544 | 134 | QVERIFY(watcher); | ||
2545 | 135 | |||
2546 | 136 | // try to change the property | ||
2547 | 137 | watcher->setProperty(property.toLocal8Bit().constData(), value); | ||
2548 | 138 | // no error should be reported | ||
2549 | 139 | QCOMPARE(watcher->property("error").toString(), QString()); | ||
2550 | 140 | } | ||
2551 | 141 | |||
2552 | 142 | }; | ||
2553 | 143 | |||
2554 | 144 | QTEST_MAIN(tst_ServiceProperties) | ||
2555 | 145 | |||
2556 | 146 | #include "tst_serviceproperties.moc" | ||
2557 | 147 | 0 | ||
2558 | === added file 'tests/unit_x11/tst_serviceproperties/tst_serviceproperties.pro' | |||
2559 | --- tests/unit_x11/tst_serviceproperties/tst_serviceproperties.pro 1970-01-01 00:00:00 +0000 | |||
2560 | +++ tests/unit_x11/tst_serviceproperties/tst_serviceproperties.pro 2015-02-11 08:57:32 +0000 | |||
2561 | @@ -0,0 +1,8 @@ | |||
2562 | 1 | include(../test-include.pri) | ||
2563 | 2 | SOURCES += \ | ||
2564 | 3 | tst_serviceproperties.cpp | ||
2565 | 4 | |||
2566 | 5 | OTHER_FILES += \ | ||
2567 | 6 | IncomingCallVibrateWatcher.qml \ | ||
2568 | 7 | InvalidPropertyWatcher.qml \ | ||
2569 | 8 | InvalidPropertyWatcher2.qml | ||
2570 | 0 | 9 | ||
2571 | === removed file 'tests/unit_x11/tst_serviceproperties/tst_serviceproperties.pro' | |||
2572 | --- tests/unit_x11/tst_serviceproperties/tst_serviceproperties.pro 2014-12-03 08:26:33 +0000 | |||
2573 | +++ tests/unit_x11/tst_serviceproperties/tst_serviceproperties.pro 1970-01-01 00:00:00 +0000 | |||
2574 | @@ -1,8 +0,0 @@ | |||
2575 | 1 | include(../test-include.pri) | ||
2576 | 2 | SOURCES += \ | ||
2577 | 3 | tst_serviceproperties.cpp | ||
2578 | 4 | |||
2579 | 5 | OTHER_FILES += \ | ||
2580 | 6 | IncomingCallVibrateWatcher.qml \ | ||
2581 | 7 | InvalidPropertyWatcher.qml \ | ||
2582 | 8 | InvalidPropertyWatcher2.qml |
Looks good