Merge lp:~michihenning/storage-framework/merge-devel into lp:storage-framework
- merge-devel
- Merge into trunk
Proposed by
Michi Henning
Status: | Merged |
---|---|
Approved by: | James Henstridge |
Approved revision: | no longer in the source branch. |
Merged at revision: | 15 |
Proposed branch: | lp:~michihenning/storage-framework/merge-devel |
Merge into: | lp:storage-framework |
Diff against target: |
3789 lines (+1688/-685) 66 files modified
CMakeLists.txt (+2/-1) data/registry.xml (+21/-24) debian/changelog (+9/-0) debian/control (+5/-90) debian/control.in (+15/-2) debian/storage-framework-registry.install (+2/-0) demo/demo.qml (+1/-1) demo/provider_test/provider-test.cpp (+1/-1) include/unity/storage/internal/AccountDetails.h (+60/-0) include/unity/storage/internal/ActivityNotifier.h (+57/-0) include/unity/storage/internal/EnvVars.h (+51/-0) include/unity/storage/internal/InactivityTimer.h (+60/-0) include/unity/storage/internal/TraceMessageHandler.h (+3/-0) include/unity/storage/qt/Account.h (+4/-1) include/unity/storage/qt/AccountsJob.h (+2/-5) include/unity/storage/qt/Runtime.h (+3/-3) include/unity/storage/qt/internal/AccountImpl.h (+6/-19) include/unity/storage/qt/internal/AccountsJobImpl.h (+18/-10) include/unity/storage/qt/internal/Handler.h (+2/-2) include/unity/storage/qt/internal/RuntimeImpl.h (+7/-8) include/unity/storage/registry/Registry.h (+35/-0) include/unity/storage/registry/internal/ListAccountsHandler.h (+70/-0) include/unity/storage/registry/internal/RegistryAdaptor.h (+71/-0) include/unity/storage/registry/internal/qdbus-last-error-msg.h (+41/-0) src/CMakeLists.txt (+1/-0) src/internal/AccountDetails.cpp (+108/-0) src/internal/CMakeLists.txt (+8/-0) src/internal/EnvVars.cpp (+81/-0) src/internal/InactivityTimer.cpp (+82/-0) src/internal/TraceMessageHandler.cpp (+20/-3) src/qt/Account.cpp (+10/-0) src/qt/AccountsJob.cpp (+2/-8) src/qt/CMakeLists.txt (+10/-3) src/qt/Runtime.cpp (+4/-4) src/qt/client/internal/remote_client/RuntimeImpl.cpp (+1/-1) src/qt/internal/AccountImpl.cpp (+27/-49) src/qt/internal/AccountsJobImpl.cpp (+50/-69) src/qt/internal/ItemImpl.cpp (+10/-8) src/qt/internal/ItemListJobImpl.cpp (+4/-6) src/qt/internal/MultiItemListJobImpl.cpp (+1/-4) src/qt/internal/RuntimeImpl.cpp (+24/-22) src/qt/internal/validate.cpp (+75/-63) src/registry/CMakeLists.txt (+47/-0) src/registry/com.canonical.StorageFramework.Registry.service.in (+3/-0) src/registry/internal/ListAccountsHandler.cpp (+127/-0) src/registry/internal/RegistryAdaptor.cpp (+55/-0) src/registry/internal/qdbus-last-error-msg.cpp (+49/-0) src/registry/main.cpp (+95/-0) tests/CMakeLists.txt (+1/-6) tests/copyright/check_copyright.sh (+13/-7) tests/headers/CMakeLists.txt (+2/-2) tests/headers/compile_headers.py (+11/-8) tests/local-client/local-client_test.cpp (+4/-0) tests/provider-AccountData/AccountData_test.cpp (+4/-0) tests/provider-DBusPeerCache/DBusPeerCache_test.cpp (+4/-0) tests/provider-ProviderInterface/TestProvider.cpp (+5/-5) tests/registry/CMakeLists.txt (+20/-0) tests/registry/registry_test.cpp (+27/-0) tests/remote-client-v1/remote-client-v1_test.cpp (+4/-4) tests/remote-client/CMakeLists.txt (+1/-1) tests/remote-client/remote-client_test.cpp (+131/-81) tests/utils/DBusEnvironment.cpp (+9/-0) tests/utils/DBusEnvironment.h (+1/-0) tests/utils/ProviderFixture.h (+4/-0) tests/utils/com.ubuntu.OnlineAccounts.Manager.xml (+0/-153) tests/utils/fake-online-accounts-daemon.py (+7/-11) |
To merge this branch: | bzr merge lp:~michihenning/storage-framework/merge-devel |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Henstridge | Approve | ||
Review via email: mp+312873@code.launchpad.net |
Commit message
Merge devel at r99. Updated changelog.
Description of the change
Merged devel at r99. Updated changelog.
To post a comment you must log in.
- 15. By CI Train Bot Account
-
* Fix for lp:1644577, fail list job if metadata for any item is incorrect.
* Always emit itemsReady(), even if list is empty.
* Improvements to error logging and detail in error messages: lp:1644577
* Added separate registry service.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2016-10-31 09:03:32 +0000 | |||
3 | +++ CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
4 | @@ -104,7 +104,7 @@ | |||
5 | 104 | include(CTest) | 104 | include(CTest) |
6 | 105 | enable_testing() | 105 | enable_testing() |
7 | 106 | 106 | ||
9 | 107 | include(EnableCoverageReport) | 107 | find_package(CoverageReport) |
10 | 108 | 108 | ||
11 | 109 | include(GNUInstallDirs) | 109 | include(GNUInstallDirs) |
12 | 110 | 110 | ||
13 | @@ -138,6 +138,7 @@ | |||
14 | 138 | storage-framework-qt-local-client | 138 | storage-framework-qt-local-client |
15 | 139 | sf-provider-objects | 139 | sf-provider-objects |
16 | 140 | storage-framework-provider | 140 | storage-framework-provider |
17 | 141 | storage-framework-registry | ||
18 | 141 | FILTER | 142 | FILTER |
19 | 142 | ${CMAKE_SOURCE_DIR}/tests/* | 143 | ${CMAKE_SOURCE_DIR}/tests/* |
20 | 143 | ${CMAKE_BINARY_DIR}/* | 144 | ${CMAKE_BINARY_DIR}/* |
21 | 144 | 145 | ||
22 | === modified file 'data/registry.xml' | |||
23 | --- data/registry.xml 2016-05-04 14:32:07 +0000 | |||
24 | +++ data/registry.xml 2016-12-12 02:53:43 +0000 | |||
25 | @@ -3,33 +3,30 @@ | |||
26 | 3 | <node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> | 3 | <node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> |
27 | 4 | <!-- | 4 | <!-- |
28 | 5 | com.canonical.StorageFramework.Registry: | 5 | com.canonical.StorageFramework.Registry: |
33 | 6 | @short_description: Interface to query the backend registry | 6 | @short_description: Interface to retrieve providers that are configured in online accounts |
30 | 7 | |||
31 | 8 | Inteface to query the repository of backends that are | ||
32 | 9 | available. | ||
34 | 10 | --> | 7 | --> |
35 | 11 | <interface name="com.canonical.StorageFramework.Registry"> | 8 | <interface name="com.canonical.StorageFramework.Registry"> |
36 | 12 | |||
37 | 13 | <!-- | 9 | <!-- |
57 | 14 | GetBackend: | 10 | List: |
58 | 15 | @short_description: request access to a storage account | 11 | @short_description: Get the list of accounts |
59 | 16 | @service_id: if not empty, restrict results to accounts | 12 | @accounts: Returned list of accounts. |
60 | 17 | matching this service ID. | 13 | |
61 | 18 | @bus_name: the bus name of the storage provider | 14 | Returns the list of provider accounts that are available |
62 | 19 | @path: the object path of the storage account at the provider | 15 | in online accounts. In essence, this method is a proxy |
63 | 20 | 16 | for the OnlineAccounts::Manager::availableAccounts() method. | |
64 | 21 | Interactively prompt the user to pick a storage account for | 17 | |
65 | 22 | use by the application, and return the D-Bus endpoint that can | 18 | The returned values are structs with the following members: |
66 | 23 | be used to communicate with the associated provider. | 19 | - bus name (e.g. "com.canonical.StorageFramework.Provider.OwnCloud") |
67 | 24 | 20 | - object path (e.g. "/provider/7") | |
68 | 25 | As this involves user interaction, the caller should use a | 21 | - ID (e.g. 7, used for object path) |
69 | 26 | relatively long time out for this method call. | 22 | - service ID (e.g. "storage-provider-owncloud") |
70 | 27 | --> | 23 | - display name (e.g. "michi.henning@canonical.com") |
71 | 28 | <method name="GetProvider"> | 24 | - translated provider name (e.g. "OwnCloud") |
72 | 29 | <arg type="s" name="service_id" direction="in" /> | 25 | - icon name |
73 | 30 | 26 | --> | |
74 | 31 | <arg type="s" name="bus_name" direction="out" /> | 27 | <method name="ListAccounts"> |
75 | 32 | <arg type="o" name="path" direction="out" /> | 28 | <arg type="a(soussss)" name="accounts" direction="out"/> |
76 | 29 | <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList<unity::storage::internal::AccountDetails>"/> | ||
77 | 33 | </method> | 30 | </method> |
78 | 34 | </interface> | 31 | </interface> |
79 | 35 | </node> | 32 | </node> |
80 | 36 | 33 | ||
81 | === modified file 'debian/changelog' | |||
82 | --- debian/changelog 2016-11-04 12:22:33 +0000 | |||
83 | +++ debian/changelog 2016-12-12 02:53:43 +0000 | |||
84 | @@ -1,3 +1,12 @@ | |||
85 | 1 | storage-framework (0.2+17.04.20161104-0ubuntu2) UNRELEASED; urgency=medium | ||
86 | 2 | |||
87 | 3 | * Fix for lp:1644577, fail list job if metadata for any item is incorrect. | ||
88 | 4 | * Always emit itemsReady(), even if list is empty. | ||
89 | 5 | * Improvements to error logging and detail in error messages: lp:1644577 | ||
90 | 6 | * Added separate registry service. | ||
91 | 7 | |||
92 | 8 | -- Michi Henning <michi.henning@canonical.com> Fri, 09 Dec 2016 11:35:17 +1000 | ||
93 | 9 | |||
94 | 1 | storage-framework (0.2+17.04.20161104-0ubuntu1) zesty; urgency=medium | 10 | storage-framework (0.2+17.04.20161104-0ubuntu1) zesty; urgency=medium |
95 | 2 | 11 | ||
96 | 3 | [ Michi Henning ] | 12 | [ Michi Henning ] |
97 | 4 | 13 | ||
98 | === modified file 'debian/control' | |||
99 | --- debian/control 2016-11-04 12:22:33 +0000 | |||
100 | +++ debian/control 2016-12-12 02:53:43 +0000 | |||
101 | @@ -1,98 +1,13 @@ | |||
102 | 1 | # This file is autogenerated. DO NOT EDIT! | 1 | # This file is autogenerated. DO NOT EDIT! |
103 | 2 | # | 2 | # |
104 | 3 | # Modifications should be made to ./debian/control.in instead. | 3 | # Modifications should be made to ./debian/control.in instead. |
106 | 4 | # This file is regenerated automatically in the clean target. | 4 | # This file is regenerated automatically by bileto. |
107 | 5 | # | 5 | # |
108 | 6 | Source: storage-framework | 6 | Source: storage-framework |
139 | 7 | Section: libs | 7 | |
140 | 8 | Priority: optional | 8 | # DO NOT EDIT THIS FILE. WE REALLY MEAN IT! |
111 | 9 | Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com> | ||
112 | 10 | Standards-Version: 3.9.6 | ||
113 | 11 | Build-Depends: cmake, | ||
114 | 12 | cmake-extras (>= 0.4), | ||
115 | 13 | debhelper (>= 9), | ||
116 | 14 | devscripts, | ||
117 | 15 | doxygen, | ||
118 | 16 | google-mock, | ||
119 | 17 | libapparmor-dev, | ||
120 | 18 | libboost-filesystem-dev (>= 1.58) | libboost-filesystem1.58-dev, | ||
121 | 19 | libboost-system-dev (>= 1.58) | libboost-system1.58-dev, | ||
122 | 20 | libboost-thread-dev (>= 1.58) | libboost-thread1.58-dev, | ||
123 | 21 | libglib2.0-dev, | ||
124 | 22 | libgtest-dev, | ||
125 | 23 | libonline-accounts-qt-dev, | ||
126 | 24 | libqtdbustest1-dev, | ||
127 | 25 | libunity-api-dev, | ||
128 | 26 | lsb-release, | ||
129 | 27 | python3-dbus, | ||
130 | 28 | python3-gi, | ||
131 | 29 | qtbase5-dev, | ||
132 | 30 | qtbase5-dev-tools, | ||
133 | 31 | qtdeclarative5-dev, | ||
134 | 32 | Homepage: https://launchpad.net/storage-framework | ||
135 | 33 | # if you don't have have commit access to this branch but would like to upload | ||
136 | 34 | # directly to Ubuntu, don't worry: your changes will be merged back into the | ||
137 | 35 | # upstream branch | ||
138 | 36 | Vcs-Bzr: lp:storage-framework | ||
141 | 37 | 9 | ||
142 | 38 | Package: libstorage-framework-provider-1-5 | 10 | Package: libstorage-framework-provider-1-5 |
143 | 39 | Architecture: any | 11 | Architecture: any |
203 | 40 | Multi-Arch: same | 12 | Description: DO NOT EDIT THIS FILE, IT IS GENERATED FROM control.in |
204 | 41 | Pre-Depends: ${misc:Pre-Depends}, | 13 | DO NOT EDIT THIS FILE |
146 | 42 | Depends: ${misc:Depends}, | ||
147 | 43 | ${shlibs:Depends}, | ||
148 | 44 | Description: Library for Storage Framework providers | ||
149 | 45 | Server-side runtime support for provider implementations. | ||
150 | 46 | |||
151 | 47 | Package: libstorage-framework-qt-client-1-0 | ||
152 | 48 | Architecture: any | ||
153 | 49 | Multi-Arch: same | ||
154 | 50 | Pre-Depends: ${misc:Pre-Depends}, | ||
155 | 51 | Depends: ${misc:Depends}, | ||
156 | 52 | ${shlibs:Depends}, | ||
157 | 53 | Description: Client library for the Storage Framework (API v1, soon to be removed) | ||
158 | 54 | Runtime support for storage framework clients. | ||
159 | 55 | |||
160 | 56 | Package: libstorage-framework-qt-client-2-0 | ||
161 | 57 | Architecture: any | ||
162 | 58 | Multi-Arch: same | ||
163 | 59 | Pre-Depends: ${misc:Pre-Depends}, | ||
164 | 60 | Depends: ${misc:Depends}, | ||
165 | 61 | ${shlibs:Depends}, | ||
166 | 62 | Description: Client library for the Storage Framework | ||
167 | 63 | Runtime support for storage framework clients. | ||
168 | 64 | |||
169 | 65 | Package: libstorage-framework-qt-local-client-1-0 | ||
170 | 66 | Architecture: any | ||
171 | 67 | Multi-Arch: same | ||
172 | 68 | Pre-Depends: ${misc:Pre-Depends}, | ||
173 | 69 | Depends: ${misc:Depends}, | ||
174 | 70 | ${shlibs:Depends}, | ||
175 | 71 | Description: Client library for the Storage Framework backed by the local file system | ||
176 | 72 | A version of the client-side API that implements a local | ||
177 | 73 | file system provider. This is intended mainly for testing; | ||
178 | 74 | it allows application code to use the storage framework | ||
179 | 75 | API without requiring use of DBus and cloud service account. | ||
180 | 76 | |||
181 | 77 | Package: storage-framework-client-dev | ||
182 | 78 | Section: libdevel | ||
183 | 79 | Architecture: any | ||
184 | 80 | Multi-Arch: same | ||
185 | 81 | Pre-Depends: ${misc:Pre-Depends}, | ||
186 | 82 | Depends: libstorage-framework-qt-client-1-0 (= ${binary:Version}), | ||
187 | 83 | libstorage-framework-qt-local-client-1-0 (= ${binary:Version}), | ||
188 | 84 | qtbase5-dev, | ||
189 | 85 | ${misc:Depends}, | ||
190 | 86 | Description: Header files for the Storage Framework client libraries | ||
191 | 87 | Development C++ headers for the client side API. | ||
192 | 88 | |||
193 | 89 | Package: storage-framework-provider-dev | ||
194 | 90 | Section: libdevel | ||
195 | 91 | Architecture: any | ||
196 | 92 | Multi-Arch: same | ||
197 | 93 | Pre-Depends: ${misc:Pre-Depends}, | ||
198 | 94 | Depends: libstorage-framework-provider-1-5 (= ${binary:Version}), | ||
199 | 95 | libboost-thread-dev (>= 1.58) | libboost-thread1.58-dev, | ||
200 | 96 | ${misc:Depends}, | ||
201 | 97 | Description: Header files for the Storage Framework provider library | ||
202 | 98 | Development C++ headers for the provider API. | ||
205 | 99 | 14 | ||
206 | === modified file 'debian/control.in' | |||
207 | --- debian/control.in 2016-09-30 01:47:57 +0000 | |||
208 | +++ debian/control.in 2016-12-12 02:53:43 +0000 | |||
209 | @@ -4,9 +4,8 @@ | |||
210 | 4 | Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com> | 4 | Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
211 | 5 | Standards-Version: 3.9.6 | 5 | Standards-Version: 3.9.6 |
212 | 6 | Build-Depends: cmake, | 6 | Build-Depends: cmake, |
214 | 7 | cmake-extras (>= 0.4), | 7 | cmake-extras (>= 0.10), |
215 | 8 | debhelper (>= 9), | 8 | debhelper (>= 9), |
216 | 9 | devscripts, | ||
217 | 10 | doxygen, | 9 | doxygen, |
218 | 11 | google-mock, | 10 | google-mock, |
219 | 12 | libapparmor-dev, | 11 | libapparmor-dev, |
220 | @@ -18,6 +17,7 @@ | |||
221 | 18 | libonline-accounts-qt-dev, | 17 | libonline-accounts-qt-dev, |
222 | 19 | libqtdbustest1-dev, | 18 | libqtdbustest1-dev, |
223 | 20 | libunity-api-dev, | 19 | libunity-api-dev, |
224 | 20 | licensecheck | devscripts (<< 2.16.6), | ||
225 | 21 | lsb-release, | 21 | lsb-release, |
226 | 22 | python3-dbus, | 22 | python3-dbus, |
227 | 23 | python3-gi, | 23 | python3-gi, |
228 | @@ -48,12 +48,24 @@ | |||
229 | 48 | Description: Client library for the Storage Framework (API v1, soon to be removed) | 48 | Description: Client library for the Storage Framework (API v1, soon to be removed) |
230 | 49 | Runtime support for storage framework clients. | 49 | Runtime support for storage framework clients. |
231 | 50 | 50 | ||
232 | 51 | Package: storage-framework-registry | ||
233 | 52 | Architecture: any | ||
234 | 53 | Multi-Arch: foreign | ||
235 | 54 | Pre-Depends: ${misc:Pre-Depends}, | ||
236 | 55 | Depends: ${misc:Depends}, | ||
237 | 56 | ${shlibs:Depends}, | ||
238 | 57 | # TODO: should be removed once online accounts is fixed: lp:1643421 | ||
239 | 58 | online-accounts-daemon, | ||
240 | 59 | Description: Registry for the Storage Framework | ||
241 | 60 | DBus service that provides access to provider account information. | ||
242 | 61 | |||
243 | 51 | Package: libstorage-framework-qt-client-2-0 | 62 | Package: libstorage-framework-qt-client-2-0 |
244 | 52 | Architecture: any | 63 | Architecture: any |
245 | 53 | Multi-Arch: same | 64 | Multi-Arch: same |
246 | 54 | Pre-Depends: ${misc:Pre-Depends}, | 65 | Pre-Depends: ${misc:Pre-Depends}, |
247 | 55 | Depends: ${misc:Depends}, | 66 | Depends: ${misc:Depends}, |
248 | 56 | ${shlibs:Depends}, | 67 | ${shlibs:Depends}, |
249 | 68 | storage-framework-registry | ||
250 | 57 | Description: Client library for the Storage Framework | 69 | Description: Client library for the Storage Framework |
251 | 58 | Runtime support for storage framework clients. | 70 | Runtime support for storage framework clients. |
252 | 59 | 71 | ||
253 | @@ -76,6 +88,7 @@ | |||
254 | 76 | Pre-Depends: ${misc:Pre-Depends}, | 88 | Pre-Depends: ${misc:Pre-Depends}, |
255 | 77 | Depends: libstorage-framework-qt-client-1-0 (= ${binary:Version}), | 89 | Depends: libstorage-framework-qt-client-1-0 (= ${binary:Version}), |
256 | 78 | libstorage-framework-qt-local-client-1-0 (= ${binary:Version}), | 90 | libstorage-framework-qt-local-client-1-0 (= ${binary:Version}), |
257 | 91 | libstorage-framework-qt-client-2-0 (= ${binary:Version}), | ||
258 | 79 | qtbase5-dev, | 92 | qtbase5-dev, |
259 | 80 | ${misc:Depends}, | 93 | ${misc:Depends}, |
260 | 81 | Description: Header files for the Storage Framework client libraries | 94 | Description: Header files for the Storage Framework client libraries |
261 | 82 | 95 | ||
262 | === added file 'debian/storage-framework-registry.install' | |||
263 | --- debian/storage-framework-registry.install 1970-01-01 00:00:00 +0000 | |||
264 | +++ debian/storage-framework-registry.install 2016-12-12 02:53:43 +0000 | |||
265 | @@ -0,0 +1,2 @@ | |||
266 | 1 | usr/lib/*/*/storage-framework-registry | ||
267 | 2 | usr/share/dbus-1/services/com.canonical.StorageFramework.Registry.service | ||
268 | 0 | 3 | ||
269 | === modified file 'demo/demo.qml' | |||
270 | --- demo/demo.qml 2016-11-04 10:52:10 +0000 | |||
271 | +++ demo/demo.qml 2016-12-12 02:53:43 +0000 | |||
272 | @@ -48,7 +48,7 @@ | |||
273 | 48 | for (var i = 0; i < accounts.length; i++) { | 48 | for (var i = 0; i < accounts.length; i++) { |
274 | 49 | console.log("Account " + i + ": busName = " + accounts[i].busName()); | 49 | console.log("Account " + i + ": busName = " + accounts[i].busName()); |
275 | 50 | console.log("Account " + i + ": objectPath = " + accounts[i].objectPath()); | 50 | console.log("Account " + i + ": objectPath = " + accounts[i].objectPath()); |
277 | 51 | console.log("Account " + i + ": displayName = " + accounts[i].displayName); | 51 | console.log("Account " + i + ": name = " + accounts[i].name); |
278 | 52 | } | 52 | } |
279 | 53 | } | 53 | } |
280 | 54 | } | 54 | } |
281 | 55 | 55 | ||
282 | === modified file 'demo/provider_test/provider-test.cpp' | |||
283 | --- demo/provider_test/provider-test.cpp 2016-11-03 02:43:43 +0000 | |||
284 | +++ demo/provider_test/provider-test.cpp 2016-12-12 02:53:43 +0000 | |||
285 | @@ -314,7 +314,7 @@ | |||
286 | 314 | int main(int argc, char **argv) | 314 | int main(int argc, char **argv) |
287 | 315 | { | 315 | { |
288 | 316 | const std::string bus_name = "com.canonical.StorageFramework.Provider.ProviderTest"; | 316 | const std::string bus_name = "com.canonical.StorageFramework.Provider.ProviderTest"; |
290 | 317 | std::string account_service_id = "google-drive-scope"; | 317 | std::string account_service_id = "storage-provider-test"; |
291 | 318 | if (argc > 1) | 318 | if (argc > 1) |
292 | 319 | { | 319 | { |
293 | 320 | account_service_id = argv[1]; | 320 | account_service_id = argv[1]; |
294 | 321 | 321 | ||
295 | === added file 'include/unity/storage/internal/AccountDetails.h' | |||
296 | --- include/unity/storage/internal/AccountDetails.h 1970-01-01 00:00:00 +0000 | |||
297 | +++ include/unity/storage/internal/AccountDetails.h 2016-12-12 02:53:43 +0000 | |||
298 | @@ -0,0 +1,60 @@ | |||
299 | 1 | /* | ||
300 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
301 | 3 | * | ||
302 | 4 | * This program is free software: you can redistribute it and/or modify | ||
303 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
304 | 6 | * published by the Free Software Foundation. | ||
305 | 7 | * | ||
306 | 8 | * This program is distributed in the hope that it will be useful, | ||
307 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
308 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
309 | 11 | * GNU Lesser General Public License for more details. | ||
310 | 12 | * | ||
311 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
312 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
313 | 15 | * | ||
314 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
315 | 17 | */ | ||
316 | 18 | |||
317 | 19 | #pragma once | ||
318 | 20 | |||
319 | 21 | #pragma GCC diagnostic push | ||
320 | 22 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
321 | 23 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
322 | 24 | #pragma GCC diagnostic ignored "-Wswitch-default" | ||
323 | 25 | #include <QDBusArgument> | ||
324 | 26 | #pragma GCC diagnostic pop | ||
325 | 27 | |||
326 | 28 | namespace unity | ||
327 | 29 | { | ||
328 | 30 | namespace storage | ||
329 | 31 | { | ||
330 | 32 | namespace internal | ||
331 | 33 | { | ||
332 | 34 | |||
333 | 35 | struct AccountDetails | ||
334 | 36 | { | ||
335 | 37 | QString busName; | ||
336 | 38 | QDBusObjectPath objectPath; | ||
337 | 39 | quint32 id; | ||
338 | 40 | QString serviceId; | ||
339 | 41 | QString displayName; | ||
340 | 42 | QString providerName; | ||
341 | 43 | QString iconName; | ||
342 | 44 | }; | ||
343 | 45 | |||
344 | 46 | bool operator==(AccountDetails const& lhs, AccountDetails const& rhs); | ||
345 | 47 | bool operator!=(AccountDetails const& lhs, AccountDetails const& rhs); | ||
346 | 48 | bool operator<(AccountDetails const& lhs, AccountDetails const& rhs); | ||
347 | 49 | bool operator<=(AccountDetails const& lhs, AccountDetails const& rhs); | ||
348 | 50 | bool operator>(AccountDetails const& lhs, AccountDetails const& rhs); | ||
349 | 51 | bool operator>=(AccountDetails const& lhs, AccountDetails const& rhs); | ||
350 | 52 | |||
351 | 53 | QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::AccountDetails const& account); | ||
352 | 54 | QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::AccountDetails& account); | ||
353 | 55 | |||
354 | 56 | } // namespace internal | ||
355 | 57 | } // namespace storage | ||
356 | 58 | } // namespace unity | ||
357 | 59 | |||
358 | 60 | Q_DECLARE_METATYPE(unity::storage::internal::AccountDetails) | ||
359 | 0 | 61 | ||
360 | === added file 'include/unity/storage/internal/ActivityNotifier.h' | |||
361 | --- include/unity/storage/internal/ActivityNotifier.h 1970-01-01 00:00:00 +0000 | |||
362 | +++ include/unity/storage/internal/ActivityNotifier.h 2016-12-12 02:53:43 +0000 | |||
363 | @@ -0,0 +1,57 @@ | |||
364 | 1 | /* | ||
365 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
366 | 3 | * | ||
367 | 4 | * This program is free software: you can redistribute it and/or modify | ||
368 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
369 | 6 | * published by the Free Software Foundation. | ||
370 | 7 | * | ||
371 | 8 | * This program is distributed in the hope that it will be useful, | ||
372 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
373 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
374 | 11 | * GNU Lesser General Public License for more details. | ||
375 | 12 | * | ||
376 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
377 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
378 | 15 | * | ||
379 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
380 | 17 | */ | ||
381 | 18 | |||
382 | 19 | #pragma once | ||
383 | 20 | |||
384 | 21 | #include <unity/storage/internal/InactivityTimer.h> | ||
385 | 22 | |||
386 | 23 | #include <cassert> | ||
387 | 24 | #include <memory> | ||
388 | 25 | |||
389 | 26 | namespace unity | ||
390 | 27 | { | ||
391 | 28 | namespace storage | ||
392 | 29 | { | ||
393 | 30 | namespace internal | ||
394 | 31 | { | ||
395 | 32 | |||
396 | 33 | class InactivityTimer; | ||
397 | 34 | |||
398 | 35 | class ActivityNotifier | ||
399 | 36 | { | ||
400 | 37 | public: | ||
401 | 38 | ActivityNotifier(std::shared_ptr<InactivityTimer> const& timer) | ||
402 | 39 | : timer_(timer) | ||
403 | 40 | { | ||
404 | 41 | assert(timer); | ||
405 | 42 | |||
406 | 43 | timer_->request_started(); | ||
407 | 44 | } | ||
408 | 45 | |||
409 | 46 | ~ActivityNotifier() | ||
410 | 47 | { | ||
411 | 48 | timer_->request_finished(); | ||
412 | 49 | } | ||
413 | 50 | |||
414 | 51 | private: | ||
415 | 52 | std::shared_ptr<InactivityTimer> timer_; | ||
416 | 53 | }; | ||
417 | 54 | |||
418 | 55 | } // namespace internal | ||
419 | 56 | } // namespace storage | ||
420 | 57 | } // namespace unity | ||
421 | 0 | 58 | ||
422 | === added file 'include/unity/storage/internal/EnvVars.h' | |||
423 | --- include/unity/storage/internal/EnvVars.h 1970-01-01 00:00:00 +0000 | |||
424 | +++ include/unity/storage/internal/EnvVars.h 2016-12-12 02:53:43 +0000 | |||
425 | @@ -0,0 +1,51 @@ | |||
426 | 1 | /* | ||
427 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
428 | 3 | * | ||
429 | 4 | * This program is free software: you can redistribute it and/or modify | ||
430 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
431 | 6 | * published by the Free Software Foundation. | ||
432 | 7 | * | ||
433 | 8 | * This program is distributed in the hope that it will be useful, | ||
434 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
435 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
436 | 11 | * GNU Lesser General Public License for more details. | ||
437 | 12 | * | ||
438 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
439 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
440 | 15 | * | ||
441 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
442 | 17 | */ | ||
443 | 18 | |||
444 | 19 | #pragma once | ||
445 | 20 | |||
446 | 21 | #include <unity/storage/registry/Registry.h> | ||
447 | 22 | |||
448 | 23 | #include <string> | ||
449 | 24 | |||
450 | 25 | namespace unity | ||
451 | 26 | { | ||
452 | 27 | namespace storage | ||
453 | 28 | { | ||
454 | 29 | namespace internal | ||
455 | 30 | { | ||
456 | 31 | |||
457 | 32 | constexpr char const* REGISTRY_IDLE_TIMEOUT = "SF_REGISTRY_IDLE_TIMEOUT"; // Seconds, 0 means "never" | ||
458 | 33 | constexpr int REGISTRY_IDLE_TIMEOUT_DFLT = 30; | ||
459 | 34 | |||
460 | 35 | // Helper class to make retrieval of environment variables type-safe and | ||
461 | 36 | // to sanity check the setting, if applicable. Also returns a default | ||
462 | 37 | // setting, if applicable. | ||
463 | 38 | |||
464 | 39 | class EnvVars | ||
465 | 40 | { | ||
466 | 41 | public: | ||
467 | 42 | static int registry_timeout_ms(); | ||
468 | 43 | |||
469 | 44 | // Returns value of var_name in the environment, if set, and an empty string otherwise. | ||
470 | 45 | // Can be used for any environment variable, not just the ones defined above. | ||
471 | 46 | static std::string get(char const* var_name); | ||
472 | 47 | }; | ||
473 | 48 | |||
474 | 49 | } // namespace internal | ||
475 | 50 | } // namespace storage | ||
476 | 51 | } // namespace unity | ||
477 | 0 | 52 | ||
478 | === added file 'include/unity/storage/internal/InactivityTimer.h' | |||
479 | --- include/unity/storage/internal/InactivityTimer.h 1970-01-01 00:00:00 +0000 | |||
480 | +++ include/unity/storage/internal/InactivityTimer.h 2016-12-12 02:53:43 +0000 | |||
481 | @@ -0,0 +1,60 @@ | |||
482 | 1 | /* | ||
483 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
484 | 3 | * | ||
485 | 4 | * This program is free software: you can redistribute it and/or modify | ||
486 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
487 | 6 | * published by the Free Software Foundation. | ||
488 | 7 | * | ||
489 | 8 | * This program is distributed in the hope that it will be useful, | ||
490 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
491 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
492 | 11 | * GNU Lesser General Public License for more details. | ||
493 | 12 | * | ||
494 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
495 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
496 | 15 | * | ||
497 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
498 | 17 | */ | ||
499 | 18 | |||
500 | 19 | #pragma once | ||
501 | 20 | |||
502 | 21 | #pragma GCC diagnostic push | ||
503 | 22 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
504 | 23 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
505 | 24 | #pragma GCC diagnostic ignored "-Wswitch-default" | ||
506 | 25 | #include <QTimer> | ||
507 | 26 | #pragma GCC diagnostic pop | ||
508 | 27 | |||
509 | 28 | #include <functional> | ||
510 | 29 | |||
511 | 30 | namespace unity | ||
512 | 31 | { | ||
513 | 32 | namespace storage | ||
514 | 33 | { | ||
515 | 34 | namespace internal | ||
516 | 35 | { | ||
517 | 36 | |||
518 | 37 | class InactivityTimer : public QObject | ||
519 | 38 | { | ||
520 | 39 | Q_OBJECT | ||
521 | 40 | |||
522 | 41 | public: | ||
523 | 42 | InactivityTimer(int timeout_ms, std::function<void()> timeout_func); | ||
524 | 43 | ~InactivityTimer(); | ||
525 | 44 | |||
526 | 45 | void request_started(); | ||
527 | 46 | void request_finished(); | ||
528 | 47 | |||
529 | 48 | private Q_SLOTS: | ||
530 | 49 | void timeout(); | ||
531 | 50 | |||
532 | 51 | private: | ||
533 | 52 | int timeout_ms_; | ||
534 | 53 | std::function<void()> timeout_func_; | ||
535 | 54 | QTimer timer_; | ||
536 | 55 | int32_t num_requests_; | ||
537 | 56 | }; | ||
538 | 57 | |||
539 | 58 | } // namespace internal | ||
540 | 59 | } // namespace storage | ||
541 | 60 | } // namespace unity | ||
542 | 0 | 61 | ||
543 | === modified file 'include/unity/storage/internal/TraceMessageHandler.h' | |||
544 | --- include/unity/storage/internal/TraceMessageHandler.h 2016-08-25 05:18:37 +0000 | |||
545 | +++ include/unity/storage/internal/TraceMessageHandler.h 2016-12-12 02:53:43 +0000 | |||
546 | @@ -35,7 +35,10 @@ | |||
547 | 35 | class TraceMessageHandler final | 35 | class TraceMessageHandler final |
548 | 36 | { | 36 | { |
549 | 37 | public: | 37 | public: |
550 | 38 | TraceMessageHandler(); | ||
551 | 38 | TraceMessageHandler(std::string const& prog_name); | 39 | TraceMessageHandler(std::string const& prog_name); |
552 | 40 | TraceMessageHandler(QString const& prog_name); | ||
553 | 41 | TraceMessageHandler(char const* prog_name); | ||
554 | 39 | ~TraceMessageHandler(); | 42 | ~TraceMessageHandler(); |
555 | 40 | 43 | ||
556 | 41 | private: | 44 | private: |
557 | 42 | 45 | ||
558 | === modified file 'include/unity/storage/qt/Account.h' | |||
559 | --- include/unity/storage/qt/Account.h 2016-11-03 06:41:00 +0000 | |||
560 | +++ include/unity/storage/qt/Account.h 2016-12-12 02:53:43 +0000 | |||
561 | @@ -47,6 +47,8 @@ | |||
562 | 47 | Q_PROPERTY(QString busName READ busName FINAL) | 47 | Q_PROPERTY(QString busName READ busName FINAL) |
563 | 48 | Q_PROPERTY(QString objectPath READ objectPath FINAL) | 48 | Q_PROPERTY(QString objectPath READ objectPath FINAL) |
564 | 49 | Q_PROPERTY(QString displayName READ displayName FINAL) | 49 | Q_PROPERTY(QString displayName READ displayName FINAL) |
565 | 50 | Q_PROPERTY(QString providerName READ providerName FINAL) | ||
566 | 51 | Q_PROPERTY(QString iconName READ iconName FINAL) | ||
567 | 50 | 52 | ||
568 | 51 | public: | 53 | public: |
569 | 52 | Account(); | 54 | Account(); |
570 | @@ -60,7 +62,8 @@ | |||
571 | 60 | QString busName() const; | 62 | QString busName() const; |
572 | 61 | QString objectPath() const; | 63 | QString objectPath() const; |
573 | 62 | QString displayName() const; | 64 | QString displayName() const; |
575 | 63 | // TODO: add more methods to retrieve additional info, such as description, icon ID, and service name. | 65 | QString providerName() const; |
576 | 66 | QString iconName() const; | ||
577 | 64 | 67 | ||
578 | 65 | Q_INVOKABLE unity::storage::qt::ItemListJob* roots(QStringList const& keys = QStringList()) const; | 68 | Q_INVOKABLE unity::storage::qt::ItemListJob* roots(QStringList const& keys = QStringList()) const; |
579 | 66 | Q_INVOKABLE unity::storage::qt::ItemJob* get(QString const& itemId, QStringList const& keys = QStringList()) const; | 69 | Q_INVOKABLE unity::storage::qt::ItemJob* get(QString const& itemId, QStringList const& keys = QStringList()) const; |
580 | 67 | 70 | ||
581 | === modified file 'include/unity/storage/qt/AccountsJob.h' | |||
582 | --- include/unity/storage/qt/AccountsJob.h 2016-11-02 02:54:48 +0000 | |||
583 | +++ include/unity/storage/qt/AccountsJob.h 2016-12-12 02:53:43 +0000 | |||
584 | @@ -34,12 +34,10 @@ | |||
585 | 34 | { | 34 | { |
586 | 35 | 35 | ||
587 | 36 | class AccountsJobImpl; | 36 | class AccountsJobImpl; |
588 | 37 | class RuntimeImpl; | ||
589 | 38 | 37 | ||
590 | 39 | } // namespace internal | 38 | } // namespace internal |
591 | 40 | 39 | ||
592 | 41 | class Account; | 40 | class Account; |
593 | 42 | class Runtime; | ||
594 | 43 | class StorageError; | 41 | class StorageError; |
595 | 44 | 42 | ||
596 | 45 | class Q_DECL_EXPORT AccountsJob final : public QObject | 43 | class Q_DECL_EXPORT AccountsJob final : public QObject |
597 | @@ -65,14 +63,13 @@ | |||
598 | 65 | void statusChanged(unity::storage::qt::AccountsJob::Status status) const; | 63 | void statusChanged(unity::storage::qt::AccountsJob::Status status) const; |
599 | 66 | 64 | ||
600 | 67 | private: | 65 | private: |
603 | 68 | AccountsJob(std::shared_ptr<internal::RuntimeImpl> const& runtime); | 66 | AccountsJob(std::unique_ptr<internal::AccountsJobImpl> accounts_job_impl); |
602 | 69 | AccountsJob(StorageError const& error); | ||
604 | 70 | 67 | ||
605 | 71 | QVariantList accountsAsVariantList() const; | 68 | QVariantList accountsAsVariantList() const; |
606 | 72 | 69 | ||
607 | 73 | std::unique_ptr<internal::AccountsJobImpl> const p_; | 70 | std::unique_ptr<internal::AccountsJobImpl> const p_; |
608 | 74 | 71 | ||
610 | 75 | friend class internal::RuntimeImpl; | 72 | friend class internal::AccountsJobImpl; |
611 | 76 | }; | 73 | }; |
612 | 77 | 74 | ||
613 | 78 | } // namespace qt | 75 | } // namespace qt |
614 | 79 | 76 | ||
615 | === modified file 'include/unity/storage/qt/Runtime.h' | |||
616 | --- include/unity/storage/qt/Runtime.h 2016-11-02 02:54:48 +0000 | |||
617 | +++ include/unity/storage/qt/Runtime.h 2016-12-12 02:53:43 +0000 | |||
618 | @@ -66,9 +66,9 @@ | |||
619 | 66 | 66 | ||
620 | 67 | Account make_test_account(QString const& bus_name, | 67 | Account make_test_account(QString const& bus_name, |
621 | 68 | QString const& object_path, | 68 | QString const& object_path, |
625 | 69 | QString const& id = "", | 69 | quint32 id = 999, |
626 | 70 | QString const& serviceId = "", | 70 | QString const& service_id = "", |
627 | 71 | QString const& displayName = "") const; | 71 | QString const& name = "") const; |
628 | 72 | 72 | ||
629 | 73 | private: | 73 | private: |
630 | 74 | std::shared_ptr<internal::RuntimeImpl> p_; | 74 | std::shared_ptr<internal::RuntimeImpl> p_; |
631 | 75 | 75 | ||
632 | === modified file 'include/unity/storage/qt/internal/AccountImpl.h' | |||
633 | --- include/unity/storage/qt/internal/AccountImpl.h 2016-11-03 06:41:00 +0000 | |||
634 | +++ include/unity/storage/qt/internal/AccountImpl.h 2016-12-12 02:53:43 +0000 | |||
635 | @@ -19,10 +19,7 @@ | |||
636 | 19 | #pragma once | 19 | #pragma once |
637 | 20 | 20 | ||
638 | 21 | #include <unity/storage/qt/Item.h> | 21 | #include <unity/storage/qt/Item.h> |
643 | 22 | 22 | #include <unity/storage/internal/AccountDetails.h> | |
640 | 23 | #include <QString> | ||
641 | 24 | |||
642 | 25 | #include <memory> | ||
644 | 26 | 23 | ||
645 | 27 | class ProviderInterface; | 24 | class ProviderInterface; |
646 | 28 | 25 | ||
647 | @@ -50,6 +47,8 @@ | |||
648 | 50 | QString busName() const; | 47 | QString busName() const; |
649 | 51 | QString objectPath() const; | 48 | QString objectPath() const; |
650 | 52 | QString displayName() const; | 49 | QString displayName() const; |
651 | 50 | QString providerName() const; | ||
652 | 51 | QString iconName() const; | ||
653 | 53 | 52 | ||
654 | 54 | ItemListJob* roots(QStringList const& keys) const; | 53 | ItemListJob* roots(QStringList const& keys) const; |
655 | 55 | ItemJob* get(QString const& itemId, QStringList const& keys) const; | 54 | ItemJob* get(QString const& itemId, QStringList const& keys) const; |
656 | @@ -67,26 +66,14 @@ | |||
657 | 67 | std::shared_ptr<ProviderInterface> provider() const; | 66 | std::shared_ptr<ProviderInterface> provider() const; |
658 | 68 | 67 | ||
659 | 69 | static Account make_account(std::shared_ptr<RuntimeImpl> const& runtime_impl, | 68 | static Account make_account(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
665 | 70 | QString const& bus_name, | 69 | storage::internal::AccountDetails const& details); |
661 | 71 | QString const& object_path, | ||
662 | 72 | QString const& id, | ||
663 | 73 | QString const& service_id, | ||
664 | 74 | QString const& display_name); | ||
666 | 75 | 70 | ||
667 | 76 | private: | 71 | private: |
668 | 77 | AccountImpl(std::shared_ptr<RuntimeImpl> const& runtime_impl, | 72 | AccountImpl(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
674 | 78 | QString const& bus_name, | 73 | storage::internal::AccountDetails const& details); |
670 | 79 | QString const& object_path, | ||
671 | 80 | QString const& id, | ||
672 | 81 | QString const& service_id, | ||
673 | 82 | QString const& display_name); | ||
675 | 83 | 74 | ||
676 | 84 | bool is_valid_; | 75 | bool is_valid_; |
682 | 85 | QString bus_name_; | 76 | storage::internal::AccountDetails details_; |
678 | 86 | QString object_path_; | ||
679 | 87 | QString id_; | ||
680 | 88 | QString service_id_; | ||
681 | 89 | QString display_name_; | ||
683 | 90 | std::weak_ptr<RuntimeImpl> runtime_impl_; | 77 | std::weak_ptr<RuntimeImpl> runtime_impl_; |
684 | 91 | std::shared_ptr<ProviderInterface> provider_; | 78 | std::shared_ptr<ProviderInterface> provider_; |
685 | 92 | 79 | ||
686 | 93 | 80 | ||
687 | === modified file 'include/unity/storage/qt/internal/AccountsJobImpl.h' | |||
688 | --- include/unity/storage/qt/internal/AccountsJobImpl.h 2016-11-02 02:54:48 +0000 | |||
689 | +++ include/unity/storage/qt/internal/AccountsJobImpl.h 2016-12-12 02:53:43 +0000 | |||
690 | @@ -18,9 +18,14 @@ | |||
691 | 18 | 18 | ||
692 | 19 | #pragma once | 19 | #pragma once |
693 | 20 | 20 | ||
694 | 21 | #include <unity/storage/internal/AccountDetails.h> | ||
695 | 21 | #include <unity/storage/qt/AccountsJob.h> | 22 | #include <unity/storage/qt/AccountsJob.h> |
696 | 22 | 23 | ||
698 | 23 | #include <QTimer> | 24 | #pragma GCC diagnostic push |
699 | 25 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
700 | 26 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
701 | 27 | #include <QDBusPendingReply> | ||
702 | 28 | #pragma GCC diagnostic pop | ||
703 | 24 | 29 | ||
704 | 25 | namespace unity | 30 | namespace unity |
705 | 26 | { | 31 | { |
706 | @@ -31,12 +36,16 @@ | |||
707 | 31 | namespace internal | 36 | namespace internal |
708 | 32 | { | 37 | { |
709 | 33 | 38 | ||
710 | 39 | class RuntimeImpl; | ||
711 | 40 | |||
712 | 34 | class AccountsJobImpl : public QObject | 41 | class AccountsJobImpl : public QObject |
713 | 35 | { | 42 | { |
714 | 36 | Q_OBJECT | 43 | Q_OBJECT |
715 | 37 | public: | 44 | public: |
718 | 38 | AccountsJobImpl(AccountsJob* public_instance, std::shared_ptr<RuntimeImpl> const& runtime_impl); | 45 | AccountsJobImpl(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
719 | 39 | AccountsJobImpl(AccountsJob* public_instance, StorageError const& error); | 46 | QString const& method, |
720 | 47 | QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply); | ||
721 | 48 | AccountsJobImpl(StorageError const& error); | ||
722 | 40 | virtual ~AccountsJobImpl() = default; | 49 | virtual ~AccountsJobImpl() = default; |
723 | 41 | 50 | ||
724 | 42 | bool isValid() const; | 51 | bool isValid() const; |
725 | @@ -45,21 +54,20 @@ | |||
726 | 45 | QList<Account> accounts() const; | 54 | QList<Account> accounts() const; |
727 | 46 | QVariantList accountsAsVariantList() const; | 55 | QVariantList accountsAsVariantList() const; |
728 | 47 | 56 | ||
732 | 48 | private Q_SLOTS: | 57 | static AccountsJob* make_job(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
733 | 49 | void manager_ready(); | 58 | QString const& method, |
734 | 50 | void timeout(); | 59 | QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply); |
735 | 60 | static AccountsJob* make_job(StorageError const& e); | ||
736 | 51 | 61 | ||
737 | 52 | private: | 62 | private: |
738 | 53 | std::shared_ptr<RuntimeImpl> get_runtime_impl(QString const& method) const; | 63 | std::shared_ptr<RuntimeImpl> get_runtime_impl(QString const& method) const; |
739 | 54 | void initialize_accounts(); | ||
740 | 55 | AccountsJob::Status emit_status_changed(AccountsJob::Status new_status) const; | 64 | AccountsJob::Status emit_status_changed(AccountsJob::Status new_status) const; |
741 | 56 | 65 | ||
743 | 57 | AccountsJob* const public_instance_; | 66 | AccountsJob* public_instance_; |
744 | 58 | AccountsJob::Status status_; | 67 | AccountsJob::Status status_; |
745 | 59 | StorageError error_; | 68 | StorageError error_; |
746 | 60 | QList<unity::storage::qt::Account> accounts_; | ||
747 | 61 | std::weak_ptr<RuntimeImpl> const runtime_impl_; | 69 | std::weak_ptr<RuntimeImpl> const runtime_impl_; |
749 | 62 | QTimer timer_; | 70 | QList<Account> accounts_; |
750 | 63 | 71 | ||
751 | 64 | friend class unity::storage::qt::AccountsJob; | 72 | friend class unity::storage::qt::AccountsJob; |
752 | 65 | }; | 73 | }; |
753 | 66 | 74 | ||
754 | === modified file 'include/unity/storage/qt/internal/Handler.h' | |||
755 | --- include/unity/storage/qt/internal/Handler.h 2016-11-04 04:13:45 +0000 | |||
756 | +++ include/unity/storage/qt/internal/Handler.h 2016-12-12 02:53:43 +0000 | |||
757 | @@ -71,7 +71,7 @@ | |||
758 | 71 | case StorageError::Type::NoError: | 71 | case StorageError::Type::NoError: |
759 | 72 | { | 72 | { |
760 | 73 | // LCOV_EXCL_START | 73 | // LCOV_EXCL_START |
762 | 74 | QString msg = "impossible provider exception: " + e.errorString(); | 74 | QString msg = "impossible service exception: " + e.errorString(); |
763 | 75 | qCritical().noquote() << msg; | 75 | qCritical().noquote() << msg; |
764 | 76 | e = StorageErrorImpl::local_comms_error(msg); | 76 | e = StorageErrorImpl::local_comms_error(msg); |
765 | 77 | break; | 77 | break; |
766 | @@ -82,7 +82,7 @@ | |||
767 | 82 | case StorageError::Type::ResourceError: | 82 | case StorageError::Type::ResourceError: |
768 | 83 | { | 83 | { |
769 | 84 | // Log these errors because they are unexpected. | 84 | // Log these errors because they are unexpected. |
771 | 85 | QString msg = "provider exception: " + e.errorString(); | 85 | QString msg = "service exception: " + e.errorString(); |
772 | 86 | qCritical().noquote() << msg; | 86 | qCritical().noquote() << msg; |
773 | 87 | break; | 87 | break; |
774 | 88 | } | 88 | } |
775 | 89 | 89 | ||
776 | === modified file 'include/unity/storage/qt/internal/RuntimeImpl.h' | |||
777 | --- include/unity/storage/qt/internal/RuntimeImpl.h 2016-09-22 01:52:20 +0000 | |||
778 | +++ include/unity/storage/qt/internal/RuntimeImpl.h 2016-12-12 02:53:43 +0000 | |||
779 | @@ -24,10 +24,11 @@ | |||
780 | 24 | #pragma GCC diagnostic push | 24 | #pragma GCC diagnostic push |
781 | 25 | #pragma GCC diagnostic ignored "-Wcast-align" | 25 | #pragma GCC diagnostic ignored "-Wcast-align" |
782 | 26 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | 26 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
783 | 27 | #include <OnlineAccounts/Manager> | ||
784 | 28 | #include <QDBusConnection> | 27 | #include <QDBusConnection> |
785 | 29 | #pragma GCC diagnostic pop | 28 | #pragma GCC diagnostic pop |
786 | 30 | 29 | ||
787 | 30 | class RegistryInterface; | ||
788 | 31 | |||
789 | 31 | namespace unity | 32 | namespace unity |
790 | 32 | { | 33 | { |
791 | 33 | namespace storage | 34 | namespace storage |
792 | @@ -45,7 +46,7 @@ | |||
793 | 45 | { | 46 | { |
794 | 46 | public: | 47 | public: |
795 | 47 | RuntimeImpl(); | 48 | RuntimeImpl(); |
797 | 48 | RuntimeImpl(QDBusConnection const& bus); | 49 | RuntimeImpl(QDBusConnection const& conn); |
798 | 49 | RuntimeImpl(RuntimeImpl const&) = delete; | 50 | RuntimeImpl(RuntimeImpl const&) = delete; |
799 | 50 | RuntimeImpl(RuntimeImpl&&) = delete; | 51 | RuntimeImpl(RuntimeImpl&&) = delete; |
800 | 51 | ~RuntimeImpl(); | 52 | ~RuntimeImpl(); |
801 | @@ -58,19 +59,17 @@ | |||
802 | 58 | AccountsJob* accounts() const; | 59 | AccountsJob* accounts() const; |
803 | 59 | StorageError shutdown(); | 60 | StorageError shutdown(); |
804 | 60 | 61 | ||
805 | 61 | std::shared_ptr<OnlineAccounts::Manager> accounts_manager() const; | ||
806 | 62 | |||
807 | 63 | Account make_test_account(QString const& bus_name, | 62 | Account make_test_account(QString const& bus_name, |
808 | 64 | QString const& object_path, | 63 | QString const& object_path, |
812 | 65 | QString const& owner_id, | 64 | quint32 id, |
813 | 66 | QString const& owner, | 65 | QString const& service_id, |
814 | 67 | QString const& description); | 66 | QString const& display_name); |
815 | 68 | 67 | ||
816 | 69 | private: | 68 | private: |
817 | 70 | bool is_valid_; | 69 | bool is_valid_; |
818 | 71 | StorageError error_; | 70 | StorageError error_; |
819 | 72 | QDBusConnection conn_; | 71 | QDBusConnection conn_; |
821 | 73 | std::shared_ptr<OnlineAccounts::Manager> accounts_manager_; | 72 | std::unique_ptr<RegistryInterface> registry_; |
822 | 74 | 73 | ||
823 | 75 | friend class unity::storage::qt::Runtime; | 74 | friend class unity::storage::qt::Runtime; |
824 | 76 | }; | 75 | }; |
825 | 77 | 76 | ||
826 | === added directory 'include/unity/storage/registry' | |||
827 | === added file 'include/unity/storage/registry/Registry.h' | |||
828 | --- include/unity/storage/registry/Registry.h 1970-01-01 00:00:00 +0000 | |||
829 | +++ include/unity/storage/registry/Registry.h 2016-12-12 02:53:43 +0000 | |||
830 | @@ -0,0 +1,35 @@ | |||
831 | 1 | /* | ||
832 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
833 | 3 | * | ||
834 | 4 | * This program is free software: you can redistribute it and/or modify | ||
835 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
836 | 6 | * published by the Free Software Foundation. | ||
837 | 7 | * | ||
838 | 8 | * This program is distributed in the hope that it will be useful, | ||
839 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
840 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
841 | 11 | * GNU Lesser General Public License for more details. | ||
842 | 12 | * | ||
843 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
844 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
845 | 15 | * | ||
846 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
847 | 17 | */ | ||
848 | 18 | |||
849 | 19 | #pragma once | ||
850 | 20 | |||
851 | 21 | #include <QString> | ||
852 | 22 | |||
853 | 23 | namespace unity | ||
854 | 24 | { | ||
855 | 25 | namespace storage | ||
856 | 26 | { | ||
857 | 27 | namespace registry | ||
858 | 28 | { | ||
859 | 29 | |||
860 | 30 | static QString const BUS_NAME(QStringLiteral("com.canonical.StorageFramework.Registry")); | ||
861 | 31 | static QString const OBJECT_PATH(QStringLiteral("/com/canonical/StorageFramework/Registry")); | ||
862 | 32 | |||
863 | 33 | } // namespace registry | ||
864 | 34 | } // namespace storage | ||
865 | 35 | } // namespace unity | ||
866 | 0 | 36 | ||
867 | === added directory 'include/unity/storage/registry/internal' | |||
868 | === added file 'include/unity/storage/registry/internal/ListAccountsHandler.h' | |||
869 | --- include/unity/storage/registry/internal/ListAccountsHandler.h 1970-01-01 00:00:00 +0000 | |||
870 | +++ include/unity/storage/registry/internal/ListAccountsHandler.h 2016-12-12 02:53:43 +0000 | |||
871 | @@ -0,0 +1,70 @@ | |||
872 | 1 | /* | ||
873 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
874 | 3 | * | ||
875 | 4 | * This program is free software: you can redistribute it and/or modify | ||
876 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
877 | 6 | * published by the Free Software Foundation. | ||
878 | 7 | * | ||
879 | 8 | * This program is distributed in the hope that it will be useful, | ||
880 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
881 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
882 | 11 | * GNU Lesser General Public License for more details. | ||
883 | 12 | * | ||
884 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
885 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
886 | 15 | * | ||
887 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
888 | 17 | */ | ||
889 | 18 | |||
890 | 19 | #pragma once | ||
891 | 20 | |||
892 | 21 | #include <unity/storage/internal/ActivityNotifier.h> | ||
893 | 22 | |||
894 | 23 | #pragma GCC diagnostic push | ||
895 | 24 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
896 | 25 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
897 | 26 | #include <OnlineAccounts/Manager> | ||
898 | 27 | #include <QDBusConnection> | ||
899 | 28 | #include <QDBusMessage> | ||
900 | 29 | #include <QTimer> | ||
901 | 30 | #pragma GCC diagnostic pop | ||
902 | 31 | |||
903 | 32 | namespace unity | ||
904 | 33 | { | ||
905 | 34 | namespace storage | ||
906 | 35 | { | ||
907 | 36 | namespace registry | ||
908 | 37 | { | ||
909 | 38 | namespace internal | ||
910 | 39 | { | ||
911 | 40 | |||
912 | 41 | class ListAccountsHandler : public QObject | ||
913 | 42 | { | ||
914 | 43 | Q_OBJECT | ||
915 | 44 | |||
916 | 45 | public: | ||
917 | 46 | ListAccountsHandler(QDBusConnection const& conn, | ||
918 | 47 | QDBusMessage const& msg, | ||
919 | 48 | std::shared_ptr<storage::internal::InactivityTimer> const& timer); | ||
920 | 49 | ~ListAccountsHandler(); | ||
921 | 50 | |||
922 | 51 | private Q_SLOTS: | ||
923 | 52 | void manager_ready(); | ||
924 | 53 | void timeout(); | ||
925 | 54 | |||
926 | 55 | private: | ||
927 | 56 | void initialize_manager(); | ||
928 | 57 | |||
929 | 58 | QDBusConnection const conn_; | ||
930 | 59 | QDBusMessage const msg_; | ||
931 | 60 | OnlineAccounts::Manager manager_; | ||
932 | 61 | QTimer timer_; | ||
933 | 62 | storage::internal::ActivityNotifier activity_notifier_; // RAII guard variable | ||
934 | 63 | |||
935 | 64 | Q_DISABLE_COPY(ListAccountsHandler) | ||
936 | 65 | }; | ||
937 | 66 | |||
938 | 67 | } // namespace internal | ||
939 | 68 | } // namespace registry | ||
940 | 69 | } // namespace storage | ||
941 | 70 | } // namespace unity | ||
942 | 0 | 71 | ||
943 | === added file 'include/unity/storage/registry/internal/RegistryAdaptor.h' | |||
944 | --- include/unity/storage/registry/internal/RegistryAdaptor.h 1970-01-01 00:00:00 +0000 | |||
945 | +++ include/unity/storage/registry/internal/RegistryAdaptor.h 2016-12-12 02:53:43 +0000 | |||
946 | @@ -0,0 +1,71 @@ | |||
947 | 1 | /* | ||
948 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
949 | 3 | * | ||
950 | 4 | * This program is free software: you can redistribute it and/or modify | ||
951 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
952 | 6 | * published by the Free Software Foundation. | ||
953 | 7 | * | ||
954 | 8 | * This program is distributed in the hope that it will be useful, | ||
955 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
956 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
957 | 11 | * GNU Lesser General Public License for more details. | ||
958 | 12 | * | ||
959 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
960 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
961 | 15 | * | ||
962 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
963 | 17 | */ | ||
964 | 18 | |||
965 | 19 | #pragma once | ||
966 | 20 | |||
967 | 21 | #include <unity/storage/internal/AccountDetails.h> | ||
968 | 22 | |||
969 | 23 | #pragma GCC diagnostic push | ||
970 | 24 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
971 | 25 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
972 | 26 | #include <QDBusConnection> | ||
973 | 27 | #include <QDBusContext> | ||
974 | 28 | #pragma GCC diagnostic pop | ||
975 | 29 | |||
976 | 30 | #include <memory> | ||
977 | 31 | |||
978 | 32 | namespace unity | ||
979 | 33 | { | ||
980 | 34 | namespace storage | ||
981 | 35 | { | ||
982 | 36 | namespace internal | ||
983 | 37 | { | ||
984 | 38 | |||
985 | 39 | class InactivityTimer; | ||
986 | 40 | |||
987 | 41 | } // namespace internal | ||
988 | 42 | |||
989 | 43 | namespace registry | ||
990 | 44 | { | ||
991 | 45 | namespace internal | ||
992 | 46 | { | ||
993 | 47 | |||
994 | 48 | class RegistryAdaptor : public QObject, protected QDBusContext | ||
995 | 49 | { | ||
996 | 50 | Q_OBJECT | ||
997 | 51 | |||
998 | 52 | public: | ||
999 | 53 | RegistryAdaptor(QDBusConnection const& conn, | ||
1000 | 54 | std::shared_ptr<storage::internal::InactivityTimer> const& timer, | ||
1001 | 55 | QObject* parent = nullptr); | ||
1002 | 56 | ~RegistryAdaptor(); | ||
1003 | 57 | |||
1004 | 58 | public Q_SLOTS: | ||
1005 | 59 | QList<unity::storage::internal::AccountDetails> ListAccounts(); | ||
1006 | 60 | |||
1007 | 61 | private: | ||
1008 | 62 | QDBusConnection conn_; | ||
1009 | 63 | std::shared_ptr<storage::internal::InactivityTimer> timer_; | ||
1010 | 64 | |||
1011 | 65 | Q_DISABLE_COPY(RegistryAdaptor) | ||
1012 | 66 | }; | ||
1013 | 67 | |||
1014 | 68 | } // namespace internal | ||
1015 | 69 | } // namespace registry | ||
1016 | 70 | } // namespace storage | ||
1017 | 71 | } // namespace unity | ||
1018 | 0 | 72 | ||
1019 | === added file 'include/unity/storage/registry/internal/qdbus-last-error-msg.h' | |||
1020 | --- include/unity/storage/registry/internal/qdbus-last-error-msg.h 1970-01-01 00:00:00 +0000 | |||
1021 | +++ include/unity/storage/registry/internal/qdbus-last-error-msg.h 2016-12-12 02:53:43 +0000 | |||
1022 | @@ -0,0 +1,41 @@ | |||
1023 | 1 | /* | ||
1024 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
1025 | 3 | * | ||
1026 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1027 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1028 | 6 | * published by the Free Software Foundation. | ||
1029 | 7 | * | ||
1030 | 8 | * This program is distributed in the hope that it will be useful, | ||
1031 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1032 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1033 | 11 | * GNU Lesser General Public License for more details. | ||
1034 | 12 | * | ||
1035 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1036 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1037 | 15 | * | ||
1038 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
1039 | 17 | */ | ||
1040 | 18 | |||
1041 | 19 | #pragma once | ||
1042 | 20 | |||
1043 | 21 | #pragma GCC diagnostic push | ||
1044 | 22 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
1045 | 23 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
1046 | 24 | #include <QDBusConnection> | ||
1047 | 25 | #pragma GCC diagnostic pop | ||
1048 | 26 | |||
1049 | 27 | namespace unity | ||
1050 | 28 | { | ||
1051 | 29 | namespace storage | ||
1052 | 30 | { | ||
1053 | 31 | namespace registry | ||
1054 | 32 | { | ||
1055 | 33 | namespace internal | ||
1056 | 34 | { | ||
1057 | 35 | |||
1058 | 36 | QString last_error_msg(QDBusConnection const& conn); | ||
1059 | 37 | |||
1060 | 38 | } // namespace internal | ||
1061 | 39 | } // namespace registry | ||
1062 | 40 | } // namespace storage | ||
1063 | 41 | } // namespace unity | ||
1064 | 0 | 42 | ||
1065 | === modified file 'src/CMakeLists.txt' | |||
1066 | --- src/CMakeLists.txt 2016-07-06 00:59:42 +0000 | |||
1067 | +++ src/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
1068 | @@ -1,3 +1,4 @@ | |||
1069 | 1 | add_subdirectory(internal) | 1 | add_subdirectory(internal) |
1070 | 2 | add_subdirectory(provider) | 2 | add_subdirectory(provider) |
1071 | 3 | add_subdirectory(qt) | 3 | add_subdirectory(qt) |
1072 | 4 | add_subdirectory(registry) | ||
1073 | 4 | 5 | ||
1074 | === added file 'src/internal/AccountDetails.cpp' | |||
1075 | --- src/internal/AccountDetails.cpp 1970-01-01 00:00:00 +0000 | |||
1076 | +++ src/internal/AccountDetails.cpp 2016-12-12 02:53:43 +0000 | |||
1077 | @@ -0,0 +1,108 @@ | |||
1078 | 1 | /* | ||
1079 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
1080 | 3 | * | ||
1081 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1082 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1083 | 6 | * published by the Free Software Foundation. | ||
1084 | 7 | * | ||
1085 | 8 | * This program is distributed in the hope that it will be useful, | ||
1086 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1087 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1088 | 11 | * GNU Lesser General Public License for more details. | ||
1089 | 12 | * | ||
1090 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1091 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1092 | 15 | * | ||
1093 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
1094 | 17 | */ | ||
1095 | 18 | |||
1096 | 19 | #include <unity/storage/internal/AccountDetails.h> | ||
1097 | 20 | |||
1098 | 21 | using namespace unity::storage::internal; | ||
1099 | 22 | |||
1100 | 23 | namespace unity | ||
1101 | 24 | { | ||
1102 | 25 | namespace storage | ||
1103 | 26 | { | ||
1104 | 27 | namespace internal | ||
1105 | 28 | { | ||
1106 | 29 | |||
1107 | 30 | bool operator==(AccountDetails const& lhs, AccountDetails const& rhs) | ||
1108 | 31 | { | ||
1109 | 32 | return lhs.id == rhs.id | ||
1110 | 33 | && lhs.serviceId == rhs.serviceId | ||
1111 | 34 | && lhs.displayName == rhs.displayName; | ||
1112 | 35 | } | ||
1113 | 36 | |||
1114 | 37 | bool operator!=(AccountDetails const& lhs, AccountDetails const& rhs) | ||
1115 | 38 | { | ||
1116 | 39 | return !(lhs == rhs); | ||
1117 | 40 | } | ||
1118 | 41 | |||
1119 | 42 | bool operator<(AccountDetails const& lhs, AccountDetails const& rhs) | ||
1120 | 43 | { | ||
1121 | 44 | if (lhs.id < rhs.id) | ||
1122 | 45 | { | ||
1123 | 46 | return true; | ||
1124 | 47 | } | ||
1125 | 48 | if (lhs.id > rhs.id) | ||
1126 | 49 | { | ||
1127 | 50 | return false; | ||
1128 | 51 | } | ||
1129 | 52 | if (lhs.serviceId < rhs.serviceId) | ||
1130 | 53 | { | ||
1131 | 54 | return true; | ||
1132 | 55 | } | ||
1133 | 56 | if (lhs.serviceId > rhs.serviceId) | ||
1134 | 57 | { | ||
1135 | 58 | return false; | ||
1136 | 59 | } | ||
1137 | 60 | return lhs.displayName < rhs.displayName; | ||
1138 | 61 | } | ||
1139 | 62 | |||
1140 | 63 | bool operator<=(AccountDetails const& lhs, AccountDetails const& rhs) | ||
1141 | 64 | { | ||
1142 | 65 | return lhs < rhs || lhs == rhs; | ||
1143 | 66 | } | ||
1144 | 67 | |||
1145 | 68 | bool operator>(AccountDetails const& lhs, AccountDetails const& rhs) | ||
1146 | 69 | { | ||
1147 | 70 | return !(lhs <= rhs); | ||
1148 | 71 | } | ||
1149 | 72 | |||
1150 | 73 | bool operator>=(AccountDetails const& lhs, AccountDetails const& rhs) | ||
1151 | 74 | { | ||
1152 | 75 | return !(lhs < rhs); | ||
1153 | 76 | } | ||
1154 | 77 | |||
1155 | 78 | QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::AccountDetails const& account) | ||
1156 | 79 | { | ||
1157 | 80 | argument.beginStructure(); | ||
1158 | 81 | argument << account.busName; | ||
1159 | 82 | argument << account.objectPath; | ||
1160 | 83 | argument << account.id; | ||
1161 | 84 | argument << account.serviceId; | ||
1162 | 85 | argument << account.displayName; | ||
1163 | 86 | argument << account.providerName; | ||
1164 | 87 | argument << account.iconName; | ||
1165 | 88 | argument.endStructure(); | ||
1166 | 89 | return argument; | ||
1167 | 90 | } | ||
1168 | 91 | |||
1169 | 92 | QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::AccountDetails& account) | ||
1170 | 93 | { | ||
1171 | 94 | argument.beginStructure(); | ||
1172 | 95 | argument >> account.busName; | ||
1173 | 96 | argument >> account.objectPath; | ||
1174 | 97 | argument >> account.id; | ||
1175 | 98 | argument >> account.serviceId; | ||
1176 | 99 | argument >> account.displayName; | ||
1177 | 100 | argument >> account.providerName; | ||
1178 | 101 | argument >> account.iconName; | ||
1179 | 102 | argument.endStructure(); | ||
1180 | 103 | return argument; | ||
1181 | 104 | } | ||
1182 | 105 | |||
1183 | 106 | } // namespace internal | ||
1184 | 107 | } // namespace storage | ||
1185 | 108 | } // namespace unity | ||
1186 | 0 | 109 | ||
1187 | === modified file 'src/internal/CMakeLists.txt' | |||
1188 | --- src/internal/CMakeLists.txt 2016-08-12 06:19:22 +0000 | |||
1189 | +++ src/internal/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
1190 | @@ -1,10 +1,18 @@ | |||
1191 | 1 | set(src | 1 | set(src |
1192 | 2 | AccountDetails.cpp | ||
1193 | 2 | dbusmarshal.cpp | 3 | dbusmarshal.cpp |
1194 | 4 | EnvVars.cpp | ||
1195 | 5 | InactivityTimer.cpp | ||
1196 | 3 | safe_strerror.cpp | 6 | safe_strerror.cpp |
1197 | 4 | TraceMessageHandler.cpp | 7 | TraceMessageHandler.cpp |
1198 | 8 | ${CMAKE_SOURCE_DIR}/include/unity/storage/internal/InactivityTimer.h | ||
1199 | 5 | ) | 9 | ) |
1200 | 6 | 10 | ||
1201 | 11 | |||
1202 | 7 | add_library(storage-framework-common-internal STATIC ${src}) | 12 | add_library(storage-framework-common-internal STATIC ${src}) |
1203 | 13 | |||
1204 | 14 | set_target_properties(storage-framework-common-internal PROPERTIES AUTOMOC TRUE) | ||
1205 | 15 | |||
1206 | 8 | target_link_libraries(storage-framework-common-internal | 16 | target_link_libraries(storage-framework-common-internal |
1207 | 9 | Qt5::DBus | 17 | Qt5::DBus |
1208 | 10 | ) | 18 | ) |
1209 | 11 | 19 | ||
1210 | === added file 'src/internal/EnvVars.cpp' | |||
1211 | --- src/internal/EnvVars.cpp 1970-01-01 00:00:00 +0000 | |||
1212 | +++ src/internal/EnvVars.cpp 2016-12-12 02:53:43 +0000 | |||
1213 | @@ -0,0 +1,81 @@ | |||
1214 | 1 | /* | ||
1215 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
1216 | 3 | * | ||
1217 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1218 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1219 | 6 | * published by the Free Software Foundation. | ||
1220 | 7 | * | ||
1221 | 8 | * This program is distributed in the hope that it will be useful, | ||
1222 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1223 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1224 | 11 | * GNU Lesser General Public License for more details. | ||
1225 | 12 | * | ||
1226 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1227 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1228 | 15 | * | ||
1229 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
1230 | 17 | */ | ||
1231 | 18 | |||
1232 | 19 | #include <unity/storage/internal/EnvVars.h> | ||
1233 | 20 | |||
1234 | 21 | #include <cassert> | ||
1235 | 22 | #include <QDebug> | ||
1236 | 23 | |||
1237 | 24 | #include <stdlib.h> | ||
1238 | 25 | |||
1239 | 26 | using namespace std; | ||
1240 | 27 | |||
1241 | 28 | namespace unity | ||
1242 | 29 | { | ||
1243 | 30 | namespace storage | ||
1244 | 31 | { | ||
1245 | 32 | namespace internal | ||
1246 | 33 | { | ||
1247 | 34 | |||
1248 | 35 | int EnvVars::registry_timeout_ms() | ||
1249 | 36 | { | ||
1250 | 37 | int const dflt_val = REGISTRY_IDLE_TIMEOUT_DFLT * 1000; | ||
1251 | 38 | |||
1252 | 39 | auto const val = get(REGISTRY_IDLE_TIMEOUT); | ||
1253 | 40 | if (val.empty()) | ||
1254 | 41 | { | ||
1255 | 42 | return dflt_val; | ||
1256 | 43 | } | ||
1257 | 44 | try | ||
1258 | 45 | { | ||
1259 | 46 | size_t pos; | ||
1260 | 47 | auto int_val = stoi(val, &pos); | ||
1261 | 48 | if (pos != val.size()) | ||
1262 | 49 | { | ||
1263 | 50 | throw invalid_argument("unexpected trailing character(s)"); | ||
1264 | 51 | } | ||
1265 | 52 | if (int_val < 0) | ||
1266 | 53 | { | ||
1267 | 54 | throw invalid_argument("value must be >= 0"); | ||
1268 | 55 | } | ||
1269 | 56 | return int_val; | ||
1270 | 57 | } | ||
1271 | 58 | catch (std::exception const& e) | ||
1272 | 59 | { | ||
1273 | 60 | qWarning().noquote().nospace() << "Invalid setting of env var " << QString::fromStdString(REGISTRY_IDLE_TIMEOUT) | ||
1274 | 61 | << " (\"" << QString::fromStdString(val) << "\"): " << e.what(); | ||
1275 | 62 | qWarning().nospace() << "Using default value of " << REGISTRY_IDLE_TIMEOUT_DFLT; | ||
1276 | 63 | } | ||
1277 | 64 | return dflt_val; | ||
1278 | 65 | } | ||
1279 | 66 | |||
1280 | 67 | string EnvVars::get(char const* var_name) | ||
1281 | 68 | { | ||
1282 | 69 | assert(var_name != nullptr); | ||
1283 | 70 | |||
1284 | 71 | auto p = getenv(var_name); | ||
1285 | 72 | if (!p) | ||
1286 | 73 | { | ||
1287 | 74 | return string(); | ||
1288 | 75 | } | ||
1289 | 76 | return string(p); | ||
1290 | 77 | } | ||
1291 | 78 | |||
1292 | 79 | } // namespace internal | ||
1293 | 80 | } // namespace storage | ||
1294 | 81 | } // namespace unity | ||
1295 | 0 | 82 | ||
1296 | === added file 'src/internal/InactivityTimer.cpp' | |||
1297 | --- src/internal/InactivityTimer.cpp 1970-01-01 00:00:00 +0000 | |||
1298 | +++ src/internal/InactivityTimer.cpp 2016-12-12 02:53:43 +0000 | |||
1299 | @@ -0,0 +1,82 @@ | |||
1300 | 1 | /* | ||
1301 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
1302 | 3 | * | ||
1303 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1304 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1305 | 6 | * published by the Free Software Foundation. | ||
1306 | 7 | * | ||
1307 | 8 | * This program is distributed in the hope that it will be useful, | ||
1308 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1309 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1310 | 11 | * GNU Lesser General Public License for more details. | ||
1311 | 12 | * | ||
1312 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1313 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1314 | 15 | * | ||
1315 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
1316 | 17 | */ | ||
1317 | 18 | |||
1318 | 19 | #include <unity/storage/internal/InactivityTimer.h> | ||
1319 | 20 | |||
1320 | 21 | #include <QDebug> | ||
1321 | 22 | |||
1322 | 23 | #include <cassert> | ||
1323 | 24 | |||
1324 | 25 | namespace unity | ||
1325 | 26 | { | ||
1326 | 27 | namespace storage | ||
1327 | 28 | { | ||
1328 | 29 | namespace internal | ||
1329 | 30 | { | ||
1330 | 31 | |||
1331 | 32 | InactivityTimer::InactivityTimer(int timeout_ms, std::function<void()> timeout_func) | ||
1332 | 33 | : timeout_ms_(timeout_ms) | ||
1333 | 34 | , timeout_func_(timeout_func) | ||
1334 | 35 | , num_requests_(0) | ||
1335 | 36 | { | ||
1336 | 37 | assert(timeout_ms_ >= 0); | ||
1337 | 38 | assert(timeout_func); | ||
1338 | 39 | |||
1339 | 40 | connect(&timer_, &QTimer::timeout, this, &InactivityTimer::timeout); | ||
1340 | 41 | } | ||
1341 | 42 | |||
1342 | 43 | InactivityTimer::~InactivityTimer() = default; | ||
1343 | 44 | |||
1344 | 45 | void InactivityTimer::request_started() | ||
1345 | 46 | { | ||
1346 | 47 | assert(num_requests_ >= 0); | ||
1347 | 48 | |||
1348 | 49 | if (num_requests_++ == 0) | ||
1349 | 50 | { | ||
1350 | 51 | timer_.stop(); | ||
1351 | 52 | } | ||
1352 | 53 | } | ||
1353 | 54 | |||
1354 | 55 | void InactivityTimer::request_finished() | ||
1355 | 56 | { | ||
1356 | 57 | assert(num_requests_ > 0); | ||
1357 | 58 | |||
1358 | 59 | if (--num_requests_ == 0) | ||
1359 | 60 | { | ||
1360 | 61 | timer_.start(timeout_ms_); | ||
1361 | 62 | } | ||
1362 | 63 | } | ||
1363 | 64 | |||
1364 | 65 | void InactivityTimer::timeout() | ||
1365 | 66 | { | ||
1366 | 67 | timer_.stop(); | ||
1367 | 68 | disconnect(this); | ||
1368 | 69 | try | ||
1369 | 70 | { | ||
1370 | 71 | timeout_func_(); | ||
1371 | 72 | } | ||
1372 | 73 | catch (std::exception const& e) | ||
1373 | 74 | { | ||
1374 | 75 | auto msg = QString("InactivityTimer::timeout(): exception from timeout callback: ") + e.what(); | ||
1375 | 76 | qWarning().nospace() << msg; | ||
1376 | 77 | } | ||
1377 | 78 | } | ||
1378 | 79 | |||
1379 | 80 | } // namespace internal | ||
1380 | 81 | } // namespace storage | ||
1381 | 82 | } // namespace unity | ||
1382 | 0 | 83 | ||
1383 | === modified file 'src/internal/TraceMessageHandler.cpp' | |||
1384 | --- src/internal/TraceMessageHandler.cpp 2016-08-12 06:19:22 +0000 | |||
1385 | +++ src/internal/TraceMessageHandler.cpp 2016-12-12 02:53:43 +0000 | |||
1386 | @@ -80,10 +80,27 @@ | |||
1387 | 80 | 80 | ||
1388 | 81 | } // namespace | 81 | } // namespace |
1389 | 82 | 82 | ||
1390 | 83 | TraceMessageHandler::TraceMessageHandler() | ||
1391 | 84 | : old_message_handler_(qInstallMessageHandler(trace_message_handler)) | ||
1392 | 85 | { | ||
1393 | 86 | } | ||
1394 | 87 | |||
1395 | 83 | TraceMessageHandler::TraceMessageHandler(string const& prog_name) | 88 | TraceMessageHandler::TraceMessageHandler(string const& prog_name) |
1399 | 84 | { | 89 | : TraceMessageHandler() |
1400 | 85 | prefix = prog_name; | 90 | { |
1401 | 86 | old_message_handler_ = qInstallMessageHandler(trace_message_handler); | 91 | prefix = prog_name; |
1402 | 92 | } | ||
1403 | 93 | |||
1404 | 94 | TraceMessageHandler::TraceMessageHandler(QString const& prog_name) | ||
1405 | 95 | : TraceMessageHandler() | ||
1406 | 96 | { | ||
1407 | 97 | prefix = prog_name.toStdString(); | ||
1408 | 98 | } | ||
1409 | 99 | |||
1410 | 100 | TraceMessageHandler::TraceMessageHandler(char const* prog_name) | ||
1411 | 101 | : TraceMessageHandler() | ||
1412 | 102 | { | ||
1413 | 103 | prefix = prog_name; | ||
1414 | 87 | } | 104 | } |
1415 | 88 | 105 | ||
1416 | 89 | TraceMessageHandler::~TraceMessageHandler() | 106 | TraceMessageHandler::~TraceMessageHandler() |
1417 | 90 | 107 | ||
1418 | === modified file 'src/qt/Account.cpp' | |||
1419 | --- src/qt/Account.cpp 2016-11-03 06:41:00 +0000 | |||
1420 | +++ src/qt/Account.cpp 2016-12-12 02:53:43 +0000 | |||
1421 | @@ -93,6 +93,16 @@ | |||
1422 | 93 | return p_->displayName(); | 93 | return p_->displayName(); |
1423 | 94 | } | 94 | } |
1424 | 95 | 95 | ||
1425 | 96 | QString Account::providerName() const | ||
1426 | 97 | { | ||
1427 | 98 | return p_->providerName(); | ||
1428 | 99 | } | ||
1429 | 100 | |||
1430 | 101 | QString Account::iconName() const | ||
1431 | 102 | { | ||
1432 | 103 | return p_->iconName(); | ||
1433 | 104 | } | ||
1434 | 105 | |||
1435 | 96 | ItemListJob* Account::roots(QStringList const& keys) const | 106 | ItemListJob* Account::roots(QStringList const& keys) const |
1436 | 97 | { | 107 | { |
1437 | 98 | return p_->roots(keys); | 108 | return p_->roots(keys); |
1438 | 99 | 109 | ||
1439 | === modified file 'src/qt/AccountsJob.cpp' | |||
1440 | --- src/qt/AccountsJob.cpp 2016-11-02 02:54:48 +0000 | |||
1441 | +++ src/qt/AccountsJob.cpp 2016-12-12 02:53:43 +0000 | |||
1442 | @@ -18,7 +18,6 @@ | |||
1443 | 18 | 18 | ||
1444 | 19 | #include <unity/storage/qt/AccountsJob.h> | 19 | #include <unity/storage/qt/AccountsJob.h> |
1445 | 20 | 20 | ||
1446 | 21 | #include <unity/storage/qt/Account.h> | ||
1447 | 22 | #include <unity/storage/qt/internal/AccountsJobImpl.h> | 21 | #include <unity/storage/qt/internal/AccountsJobImpl.h> |
1448 | 23 | 22 | ||
1449 | 24 | #include <QVariant> | 23 | #include <QVariant> |
1450 | @@ -33,13 +32,8 @@ | |||
1451 | 33 | namespace qt | 32 | namespace qt |
1452 | 34 | { | 33 | { |
1453 | 35 | 34 | ||
1461 | 36 | AccountsJob::AccountsJob(shared_ptr<internal::RuntimeImpl> const& runtime) | 35 | AccountsJob::AccountsJob(unique_ptr<internal::AccountsJobImpl> accounts_job_impl) |
1462 | 37 | : p_(new internal::AccountsJobImpl(this, runtime)) | 36 | : p_(move(accounts_job_impl)) |
1456 | 38 | { | ||
1457 | 39 | } | ||
1458 | 40 | |||
1459 | 41 | AccountsJob::AccountsJob(StorageError const& error) | ||
1460 | 42 | : p_(new internal::AccountsJobImpl(this, error)) | ||
1463 | 43 | { | 37 | { |
1464 | 44 | } | 38 | } |
1465 | 45 | 39 | ||
1466 | 46 | 40 | ||
1467 | === modified file 'src/qt/CMakeLists.txt' | |||
1468 | --- src/qt/CMakeLists.txt 2016-10-12 08:08:48 +0000 | |||
1469 | +++ src/qt/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
1470 | @@ -4,11 +4,20 @@ | |||
1471 | 4 | CLASSNAME ProviderInterface | 4 | CLASSNAME ProviderInterface |
1472 | 5 | INCLUDE unity/storage/internal/dbusmarshal.h | 5 | INCLUDE unity/storage/internal/dbusmarshal.h |
1473 | 6 | ) | 6 | ) |
1474 | 7 | |||
1475 | 8 | qt5_add_dbus_interface(generated_files | 7 | qt5_add_dbus_interface(generated_files |
1476 | 9 | ${CMAKE_SOURCE_DIR}/data/provider.xml | 8 | ${CMAKE_SOURCE_DIR}/data/provider.xml |
1477 | 10 | ProviderInterface | 9 | ProviderInterface |
1478 | 11 | ) | 10 | ) |
1479 | 11 | |||
1480 | 12 | set_source_files_properties(${CMAKE_SOURCE_DIR}/data/registry.xml PROPERTIES | ||
1481 | 13 | CLASSNAME RegistryInterface | ||
1482 | 14 | INCLUDE unity/storage/internal/AccountDetails.h | ||
1483 | 15 | ) | ||
1484 | 16 | qt5_add_dbus_interface(generated_files | ||
1485 | 17 | ${CMAKE_SOURCE_DIR}/data/registry.xml | ||
1486 | 18 | RegistryInterface | ||
1487 | 19 | ) | ||
1488 | 20 | |||
1489 | 12 | set_source_files_properties(${generated_files} dbusmarshal.cpp PROPERTIES | 21 | set_source_files_properties(${generated_files} dbusmarshal.cpp PROPERTIES |
1490 | 13 | COMPILE_FLAGS "-Wno-ctor-dtor-privacy -Wno-missing-field-initializers" | 22 | COMPILE_FLAGS "-Wno-ctor-dtor-privacy -Wno-missing-field-initializers" |
1491 | 14 | GENERATED TRUE | 23 | GENERATED TRUE |
1492 | @@ -71,7 +80,6 @@ | |||
1493 | 71 | target_include_directories(storage-framework-qt-client-v2 PRIVATE | 80 | target_include_directories(storage-framework-qt-client-v2 PRIVATE |
1494 | 72 | ${Qt5DBus_INCLUDE_DIRS} | 81 | ${Qt5DBus_INCLUDE_DIRS} |
1495 | 73 | ${Qt5Network_INCLUDE_DIRS} | 82 | ${Qt5Network_INCLUDE_DIRS} |
1496 | 74 | ${ONLINEACCOUNTS_DEPS_INCLUDE_DIRS} | ||
1497 | 75 | ) | 83 | ) |
1498 | 76 | set_target_properties(storage-framework-qt-client-v2 PROPERTIES | 84 | set_target_properties(storage-framework-qt-client-v2 PROPERTIES |
1499 | 77 | AUTOMOC TRUE | 85 | AUTOMOC TRUE |
1500 | @@ -85,7 +93,6 @@ | |||
1501 | 85 | Qt5::Core | 93 | Qt5::Core |
1502 | 86 | Qt5::DBus | 94 | Qt5::DBus |
1503 | 87 | Qt5::Network | 95 | Qt5::Network |
1504 | 88 | ${ONLINEACCOUNTS_DEPS_LDFLAGS} | ||
1505 | 89 | ) | 96 | ) |
1506 | 90 | install( | 97 | install( |
1507 | 91 | TARGETS storage-framework-qt-client-v2 | 98 | TARGETS storage-framework-qt-client-v2 |
1508 | 92 | 99 | ||
1509 | === modified file 'src/qt/Runtime.cpp' | |||
1510 | --- src/qt/Runtime.cpp 2016-09-22 01:52:20 +0000 | |||
1511 | +++ src/qt/Runtime.cpp 2016-12-12 02:53:43 +0000 | |||
1512 | @@ -70,11 +70,11 @@ | |||
1513 | 70 | 70 | ||
1514 | 71 | Account Runtime::make_test_account(QString const& bus_name, | 71 | Account Runtime::make_test_account(QString const& bus_name, |
1515 | 72 | QString const& object_path, | 72 | QString const& object_path, |
1519 | 73 | QString const& owner_id, | 73 | quint32 id, |
1520 | 74 | QString const& owner, | 74 | QString const& service_id, |
1521 | 75 | QString const& description) const | 75 | QString const& display_name) const |
1522 | 76 | { | 76 | { |
1524 | 77 | return p_->make_test_account(bus_name, object_path, owner_id, owner, description); | 77 | return p_->make_test_account(bus_name, object_path, id, service_id, display_name); |
1525 | 78 | } | 78 | } |
1526 | 79 | 79 | ||
1527 | 80 | } // namespace qt | 80 | } // namespace qt |
1528 | 81 | 81 | ||
1529 | === modified file 'src/qt/client/internal/remote_client/RuntimeImpl.cpp' | |||
1530 | --- src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-11-02 09:32:53 +0000 | |||
1531 | +++ src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-12-12 02:53:43 +0000 | |||
1532 | @@ -47,7 +47,7 @@ | |||
1533 | 47 | 47 | ||
1534 | 48 | static const map<QString, QString> BUS_NAMES = | 48 | static const map<QString, QString> BUS_NAMES = |
1535 | 49 | { | 49 | { |
1537 | 50 | { "google-drive-scope", "com.canonical.StorageFramework.Provider.ProviderTest" }, | 50 | { "storage-provider-test", "com.canonical.StorageFramework.Provider.ProviderTest" }, |
1538 | 51 | { "com.canonical.scopes.mcloud_mcloud_mcloud", "com.canonical.StorageFramework.Provider.McloudProvider" }, | 51 | { "com.canonical.scopes.mcloud_mcloud_mcloud", "com.canonical.StorageFramework.Provider.McloudProvider" }, |
1539 | 52 | { "storage-provider-owncloud", "com.canonical.StorageFramework.Provider.OwnCloud" }, | 52 | { "storage-provider-owncloud", "com.canonical.StorageFramework.Provider.OwnCloud" }, |
1540 | 53 | { "storage-provider-onedrive", "com.canonical.StorageFramework.Provider.OnedriveProvider" }, | 53 | { "storage-provider-onedrive", "com.canonical.StorageFramework.Provider.OnedriveProvider" }, |
1541 | 54 | 54 | ||
1542 | === modified file 'src/qt/internal/AccountImpl.cpp' | |||
1543 | --- src/qt/internal/AccountImpl.cpp 2016-11-03 06:41:00 +0000 | |||
1544 | +++ src/qt/internal/AccountImpl.cpp 2016-12-12 02:53:43 +0000 | |||
1545 | @@ -48,37 +48,39 @@ | |||
1546 | 48 | } | 48 | } |
1547 | 49 | 49 | ||
1548 | 50 | AccountImpl::AccountImpl(shared_ptr<RuntimeImpl> const& runtime_impl, | 50 | AccountImpl::AccountImpl(shared_ptr<RuntimeImpl> const& runtime_impl, |
1554 | 51 | QString const& bus_name, | 51 | storage::internal::AccountDetails const& details) |
1550 | 52 | QString const& object_path, | ||
1551 | 53 | QString const& id, | ||
1552 | 54 | QString const& service_id, | ||
1553 | 55 | QString const& display_name) | ||
1555 | 56 | : is_valid_(true) | 52 | : is_valid_(true) |
1561 | 57 | , bus_name_(bus_name) | 53 | , details_(details) |
1557 | 58 | , object_path_(object_path) | ||
1558 | 59 | , id_(id) | ||
1559 | 60 | , service_id_(service_id) | ||
1560 | 61 | , display_name_(display_name) | ||
1562 | 62 | , runtime_impl_(runtime_impl) | 54 | , runtime_impl_(runtime_impl) |
1564 | 63 | , provider_(new ProviderInterface(bus_name, object_path, runtime_impl->connection())) | 55 | , provider_(new ProviderInterface(details.busName, details.objectPath.path(), runtime_impl->connection())) |
1565 | 64 | { | 56 | { |
1568 | 65 | assert(!bus_name.isEmpty()); | 57 | assert(!details.busName.isEmpty()); |
1569 | 66 | assert(!object_path.isEmpty()); | 58 | assert(!details.objectPath.path().isEmpty()); |
1570 | 67 | } | 59 | } |
1571 | 68 | 60 | ||
1572 | 69 | QString AccountImpl::busName() const | 61 | QString AccountImpl::busName() const |
1573 | 70 | { | 62 | { |
1575 | 71 | return is_valid_ ? bus_name_ : ""; | 63 | return is_valid_ ? details_.busName : ""; |
1576 | 72 | } | 64 | } |
1577 | 73 | 65 | ||
1578 | 74 | QString AccountImpl::objectPath() const | 66 | QString AccountImpl::objectPath() const |
1579 | 75 | { | 67 | { |
1581 | 76 | return is_valid_ ? object_path_ : ""; | 68 | return is_valid_ ? details_.objectPath.path() : QDBusObjectPath().path(); |
1582 | 77 | } | 69 | } |
1583 | 78 | 70 | ||
1584 | 79 | QString AccountImpl::displayName() const | 71 | QString AccountImpl::displayName() const |
1585 | 80 | { | 72 | { |
1587 | 81 | return is_valid_ ? display_name_ : ""; | 73 | return is_valid_ ? details_.displayName : ""; |
1588 | 74 | } | ||
1589 | 75 | |||
1590 | 76 | QString AccountImpl::providerName() const | ||
1591 | 77 | { | ||
1592 | 78 | return is_valid_ ? details_.providerName : ""; | ||
1593 | 79 | } | ||
1594 | 80 | |||
1595 | 81 | QString AccountImpl::iconName() const | ||
1596 | 82 | { | ||
1597 | 83 | return is_valid_ ? details_.iconName : ""; | ||
1598 | 82 | } | 84 | } |
1599 | 83 | 85 | ||
1600 | 84 | ItemListJob* AccountImpl::roots(QStringList const& keys) const | 86 | ItemListJob* AccountImpl::roots(QStringList const& keys) const |
1601 | @@ -101,7 +103,8 @@ | |||
1602 | 101 | { | 103 | { |
1603 | 102 | if (md.type != ItemType::root) | 104 | if (md.type != ItemType::root) |
1604 | 103 | { | 105 | { |
1606 | 104 | QString msg = method + ": provider returned non-root item type: " + QString::number(int(md.type)); | 106 | QString msg = method + ": provider returned non-root item type: " + QString::number(int(md.type)) + |
1607 | 107 | " (id = " + md.item_id + ")"; | ||
1608 | 105 | qCritical().noquote() << msg; | 108 | qCritical().noquote() << msg; |
1609 | 106 | throw StorageErrorImpl::local_comms_error(msg); | 109 | throw StorageErrorImpl::local_comms_error(msg); |
1610 | 107 | } | 110 | } |
1611 | @@ -141,10 +144,7 @@ | |||
1612 | 141 | { | 144 | { |
1613 | 142 | if (is_valid_) | 145 | if (is_valid_) |
1614 | 143 | { | 146 | { |
1619 | 144 | return other.is_valid_ | 147 | return other.is_valid_ && details_ == other.details_; |
1616 | 145 | && id_ == other.id_ | ||
1617 | 146 | && service_id_ == other.service_id_ | ||
1618 | 147 | && display_name_ == other.display_name_; | ||
1620 | 148 | } | 148 | } |
1621 | 149 | return !other.is_valid_; | 149 | return !other.is_valid_; |
1622 | 150 | } | 150 | } |
1623 | @@ -164,24 +164,7 @@ | |||
1624 | 164 | { | 164 | { |
1625 | 165 | return false; | 165 | return false; |
1626 | 166 | } | 166 | } |
1645 | 167 | assert(is_valid_ && other.is_valid_); | 167 | return details_ < other.details_; |
1628 | 168 | if (id_ < other.id_) | ||
1629 | 169 | { | ||
1630 | 170 | return true; | ||
1631 | 171 | } | ||
1632 | 172 | if (id_ > other.id_) | ||
1633 | 173 | { | ||
1634 | 174 | return false; | ||
1635 | 175 | } | ||
1636 | 176 | if (service_id_ < other.service_id_) | ||
1637 | 177 | { | ||
1638 | 178 | return true; | ||
1639 | 179 | } | ||
1640 | 180 | if (service_id_ > other.service_id_) | ||
1641 | 181 | { | ||
1642 | 182 | return false; | ||
1643 | 183 | } | ||
1644 | 184 | return display_name_ < other.display_name_; | ||
1646 | 185 | } | 168 | } |
1647 | 186 | 169 | ||
1648 | 187 | bool AccountImpl::operator<=(AccountImpl const& other) const | 170 | bool AccountImpl::operator<=(AccountImpl const& other) const |
1649 | @@ -215,21 +198,16 @@ | |||
1650 | 215 | { | 198 | { |
1651 | 216 | return 0; | 199 | return 0; |
1652 | 217 | } | 200 | } |
1657 | 218 | size_t hash = 0; | 201 | size_t hash = details_.id; |
1658 | 219 | boost::hash_combine(hash, qHash(service_id_)); | 202 | boost::hash_combine(hash, qHash(details_.serviceId)); |
1659 | 220 | boost::hash_combine(hash, qHash(id_)); | 203 | boost::hash_combine(hash, qHash(details_.displayName)); |
1656 | 221 | boost::hash_combine(hash, qHash(display_name_)); | ||
1660 | 222 | return hash; | 204 | return hash; |
1661 | 223 | } | 205 | } |
1662 | 224 | 206 | ||
1663 | 225 | Account AccountImpl::make_account(shared_ptr<RuntimeImpl> const& runtime, | 207 | Account AccountImpl::make_account(shared_ptr<RuntimeImpl> const& runtime, |
1669 | 226 | QString const& bus_name, | 208 | storage::internal::AccountDetails const& details) |
1665 | 227 | QString const& object_path, | ||
1666 | 228 | QString const& id, | ||
1667 | 229 | QString const& service_id, | ||
1668 | 230 | QString const& display_name) | ||
1670 | 231 | { | 209 | { |
1672 | 232 | shared_ptr<AccountImpl> p(new AccountImpl(runtime, bus_name, object_path, id, service_id, display_name)); | 210 | shared_ptr<AccountImpl> p(new AccountImpl(runtime, details)); |
1673 | 233 | return Account(p); | 211 | return Account(p); |
1674 | 234 | } | 212 | } |
1675 | 235 | 213 | ||
1676 | 236 | 214 | ||
1677 | === modified file 'src/qt/internal/AccountsJobImpl.cpp' | |||
1678 | --- src/qt/internal/AccountsJobImpl.cpp 2016-11-03 07:33:40 +0000 | |||
1679 | +++ src/qt/internal/AccountsJobImpl.cpp 2016-12-12 02:53:43 +0000 | |||
1680 | @@ -18,12 +18,12 @@ | |||
1681 | 18 | 18 | ||
1682 | 19 | #include <unity/storage/qt/internal/AccountsJobImpl.h> | 19 | #include <unity/storage/qt/internal/AccountsJobImpl.h> |
1683 | 20 | 20 | ||
1684 | 21 | #include "RegistryInterface.h" | ||
1685 | 21 | #include <unity/storage/qt/internal/AccountImpl.h> | 22 | #include <unity/storage/qt/internal/AccountImpl.h> |
1686 | 23 | #include <unity/storage/qt/internal/Handler.h> | ||
1687 | 22 | #include <unity/storage/qt/internal/RuntimeImpl.h> | 24 | #include <unity/storage/qt/internal/RuntimeImpl.h> |
1688 | 23 | #include <unity/storage/qt/internal/StorageErrorImpl.h> | 25 | #include <unity/storage/qt/internal/StorageErrorImpl.h> |
1689 | 24 | 26 | ||
1690 | 25 | #include <OnlineAccounts/Account> | ||
1691 | 26 | |||
1692 | 27 | #include <cassert> | 27 | #include <cassert> |
1693 | 28 | 28 | ||
1694 | 29 | using namespace std; | 29 | using namespace std; |
1695 | @@ -37,38 +37,45 @@ | |||
1696 | 37 | namespace internal | 37 | namespace internal |
1697 | 38 | { | 38 | { |
1698 | 39 | 39 | ||
1717 | 40 | namespace | 40 | AccountsJobImpl::AccountsJobImpl(shared_ptr<RuntimeImpl> const& runtime_impl, |
1718 | 41 | { | 41 | QString const& method, |
1719 | 42 | 42 | QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply) | |
1720 | 43 | // TODO: We retrieve the accounts directly from online accounts until we have a working registry. | 43 | : status_(AccountsJob::Status::Loading) |
1703 | 44 | |||
1704 | 45 | static map<QString, QString> const BUS_NAMES = | ||
1705 | 46 | { | ||
1706 | 47 | { "google-drive-scope", "com.canonical.StorageFramework.Provider.ProviderTest" }, | ||
1707 | 48 | { "com.canonical.scopes.mcloud_mcloud_mcloud", "com.canonical.StorageFramework.Provider.McloudProvider" }, | ||
1708 | 49 | { "storage-provider-owncloud", "com.canonical.StorageFramework.Provider.OwnCloud" }, | ||
1709 | 50 | { "storage-provider-onedrive", "com.canonical.StorageFramework.Provider.OnedriveProvider" }, | ||
1710 | 51 | }; | ||
1711 | 52 | |||
1712 | 53 | } // namespace | ||
1713 | 54 | |||
1714 | 55 | AccountsJobImpl::AccountsJobImpl(AccountsJob* public_instance, shared_ptr<RuntimeImpl> const& runtime_impl) | ||
1715 | 56 | : public_instance_(public_instance) | ||
1716 | 57 | , status_(AccountsJob::Status::Loading) | ||
1721 | 58 | , runtime_impl_(runtime_impl) | 44 | , runtime_impl_(runtime_impl) |
1722 | 59 | { | 45 | { |
1723 | 60 | assert(public_instance); | ||
1724 | 61 | assert(runtime_impl); | 46 | assert(runtime_impl); |
1725 | 62 | 47 | ||
1727 | 63 | initialize_accounts(); | 48 | auto process_reply = [this, method](decltype(reply)& r) |
1728 | 49 | { | ||
1729 | 50 | auto runtime = get_runtime_impl(method); | ||
1730 | 51 | if (!runtime || !runtime->isValid()) | ||
1731 | 52 | { | ||
1732 | 53 | return; | ||
1733 | 54 | } | ||
1734 | 55 | |||
1735 | 56 | for (auto const& ad : r.value()) | ||
1736 | 57 | { | ||
1737 | 58 | auto a = AccountImpl::make_account(runtime, ad); | ||
1738 | 59 | accounts_.append(a); | ||
1739 | 60 | } | ||
1740 | 61 | status_ = AccountsJob::Status::Finished; | ||
1741 | 62 | Q_EMIT public_instance_->statusChanged(status_); | ||
1742 | 63 | }; | ||
1743 | 64 | |||
1744 | 65 | auto process_error = [this](StorageError const& error) | ||
1745 | 66 | { | ||
1746 | 67 | error_ = error; | ||
1747 | 68 | status_ = AccountsJob::Status::Error; | ||
1748 | 69 | Q_EMIT public_instance_->statusChanged(status_); | ||
1749 | 70 | }; | ||
1750 | 71 | |||
1751 | 72 | new Handler<QList<storage::internal::AccountDetails>>(this, reply, process_reply, process_error); | ||
1752 | 64 | } | 73 | } |
1753 | 65 | 74 | ||
1757 | 66 | AccountsJobImpl::AccountsJobImpl(AccountsJob* public_instance, StorageError const& error) | 75 | AccountsJobImpl::AccountsJobImpl(StorageError const& error) |
1758 | 67 | : public_instance_(public_instance) | 76 | : status_(AccountsJob::Status::Error) |
1756 | 68 | , status_(AccountsJob::Status::Loading) | ||
1759 | 69 | , error_(error) | 77 | , error_(error) |
1760 | 70 | { | 78 | { |
1761 | 71 | assert(public_instance); | ||
1762 | 72 | assert(error.type() != StorageError::Type::NoError); | 79 | assert(error.type() != StorageError::Type::NoError); |
1763 | 73 | 80 | ||
1764 | 74 | status_ = emit_status_changed(AccountsJob::Status::Error); | 81 | status_ = emit_status_changed(AccountsJob::Status::Error); |
1765 | @@ -113,21 +120,27 @@ | |||
1766 | 113 | return account_list; | 120 | return account_list; |
1767 | 114 | } | 121 | } |
1768 | 115 | 122 | ||
1770 | 116 | void AccountsJobImpl::manager_ready() | 123 | AccountsJob* AccountsJobImpl::make_job(shared_ptr<RuntimeImpl> const& runtime, |
1771 | 124 | QString const& method, | ||
1772 | 125 | QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply) | ||
1773 | 117 | { | 126 | { |
1777 | 118 | timer_.stop(); | 127 | unique_ptr<AccountsJobImpl> impl(new AccountsJobImpl(runtime, method, reply)); |
1778 | 119 | disconnect(this); | 128 | auto job = new AccountsJob(move(impl)); |
1779 | 120 | initialize_accounts(); | 129 | job->p_->public_instance_ = job; |
1780 | 130 | return job; | ||
1781 | 121 | } | 131 | } |
1782 | 122 | 132 | ||
1785 | 123 | // LCOV_EXCL_START | 133 | AccountsJob* AccountsJobImpl::make_job(StorageError const& error) |
1784 | 124 | void AccountsJobImpl::timeout() | ||
1786 | 125 | { | 134 | { |
1790 | 126 | disconnect(this); | 135 | unique_ptr<AccountsJobImpl> impl(new AccountsJobImpl(error)); |
1791 | 127 | error_ = StorageErrorImpl::local_comms_error("AccountsJob(): timeout retrieving Online accounts"); | 136 | auto job = new AccountsJob(move(impl)); |
1792 | 128 | status_ = emit_status_changed(AccountsJob::Status::Error); | 137 | job->p_->public_instance_ = job; |
1793 | 138 | QMetaObject::invokeMethod(job, | ||
1794 | 139 | "statusChanged", | ||
1795 | 140 | Qt::QueuedConnection, | ||
1796 | 141 | Q_ARG(unity::storage::qt::AccountsJob::Status, job->p_->status_)); | ||
1797 | 142 | return job; | ||
1798 | 129 | } | 143 | } |
1799 | 130 | // LCOV_EXCL_STOP | ||
1800 | 131 | 144 | ||
1801 | 132 | AccountsJob::Status AccountsJobImpl::emit_status_changed(AccountsJob::Status new_status) const | 145 | AccountsJob::Status AccountsJobImpl::emit_status_changed(AccountsJob::Status new_status) const |
1802 | 133 | { | 146 | { |
1803 | @@ -152,43 +165,11 @@ | |||
1804 | 152 | auto This = const_cast<AccountsJobImpl*>(this); | 165 | auto This = const_cast<AccountsJobImpl*>(this); |
1805 | 153 | This->error_ = StorageErrorImpl::runtime_destroyed_error(msg); | 166 | This->error_ = StorageErrorImpl::runtime_destroyed_error(msg); |
1806 | 154 | This->status_ = emit_status_changed(AccountsJob::Status::Error); | 167 | This->status_ = emit_status_changed(AccountsJob::Status::Error); |
1807 | 168 | return nullptr; | ||
1808 | 155 | } | 169 | } |
1809 | 156 | return runtime; | 170 | return runtime; |
1810 | 157 | } | 171 | } |
1811 | 158 | 172 | ||
1812 | 159 | void AccountsJobImpl::initialize_accounts() | ||
1813 | 160 | { | ||
1814 | 161 | auto runtime = get_runtime_impl("AccountsJob()"); | ||
1815 | 162 | assert(runtime); | ||
1816 | 163 | |||
1817 | 164 | auto manager = runtime->accounts_manager(); | ||
1818 | 165 | if (!manager->isReady()) | ||
1819 | 166 | { | ||
1820 | 167 | connect(manager.get(), &OnlineAccounts::Manager::ready, this, &AccountsJobImpl::manager_ready); | ||
1821 | 168 | connect(&timer_, &QTimer::timeout, this, &AccountsJobImpl::timeout); | ||
1822 | 169 | timer_.setSingleShot(true); | ||
1823 | 170 | timer_.start(30000); // TODO: Need config for this eventually. | ||
1824 | 171 | return; | ||
1825 | 172 | } | ||
1826 | 173 | |||
1827 | 174 | for (auto const map_entry : BUS_NAMES) | ||
1828 | 175 | { | ||
1829 | 176 | auto service_id = map_entry.first; | ||
1830 | 177 | for (auto const& a : manager->availableAccounts(service_id)) | ||
1831 | 178 | { | ||
1832 | 179 | auto object_path = QStringLiteral("/provider/%1").arg(a->id()); | ||
1833 | 180 | auto bus_name = map_entry.second; | ||
1834 | 181 | accounts_.append(AccountImpl::make_account(runtime, | ||
1835 | 182 | bus_name, | ||
1836 | 183 | object_path, | ||
1837 | 184 | QString::number(a->id()), | ||
1838 | 185 | a->serviceId(), | ||
1839 | 186 | a->displayName())); | ||
1840 | 187 | } | ||
1841 | 188 | } | ||
1842 | 189 | status_ = emit_status_changed(AccountsJob::Status::Finished); | ||
1843 | 190 | } | ||
1844 | 191 | |||
1845 | 192 | } // namespace internal | 173 | } // namespace internal |
1846 | 193 | } // namespace qt | 174 | } // namespace qt |
1847 | 194 | } // namespace storage | 175 | } // namespace storage |
1848 | 195 | 176 | ||
1849 | === modified file 'src/qt/internal/ItemImpl.cpp' | |||
1850 | --- src/qt/internal/ItemImpl.cpp 2016-11-03 03:41:24 +0000 | |||
1851 | +++ src/qt/internal/ItemImpl.cpp 2016-12-12 02:53:43 +0000 | |||
1852 | @@ -153,7 +153,7 @@ | |||
1853 | 153 | { | 153 | { |
1854 | 154 | if (md.type == ItemType::file) | 154 | if (md.type == ItemType::file) |
1855 | 155 | { | 155 | { |
1857 | 156 | QString msg = method + ": provider returned a file as a parent"; | 156 | QString msg = method + ": provider returned a file as a parent (id = " + md.item_id + ")"; |
1858 | 157 | qCritical().noquote() << msg; | 157 | qCritical().noquote() << msg; |
1859 | 158 | throw StorageErrorImpl::local_comms_error(msg); | 158 | throw StorageErrorImpl::local_comms_error(msg); |
1860 | 159 | } | 159 | } |
1861 | @@ -178,7 +178,8 @@ | |||
1862 | 178 | || | 178 | || |
1863 | 179 | (md_.type != ItemType::file && md.type == ItemType::file)) | 179 | (md_.type != ItemType::file && md.type == ItemType::file)) |
1864 | 180 | { | 180 | { |
1866 | 181 | QString msg = method + ": source and target item type differ"; | 181 | QString msg = method + "provider error: source and target item type differ (source id = " + |
1867 | 182 | md_.item_id + ", target id = " + md.item_id + ")"; | ||
1868 | 182 | qCritical().noquote() << msg; | 183 | qCritical().noquote() << msg; |
1869 | 183 | throw StorageErrorImpl::local_comms_error(msg); | 184 | throw StorageErrorImpl::local_comms_error(msg); |
1870 | 184 | } | 185 | } |
1871 | @@ -203,7 +204,7 @@ | |||
1872 | 203 | { | 204 | { |
1873 | 204 | if (md.type == ItemType::root) | 205 | if (md.type == ItemType::root) |
1874 | 205 | { | 206 | { |
1876 | 206 | QString msg = method + ": impossible root item returned by provider"; | 207 | QString msg = method + ": impossible root item returned by provider (id = " + md.item_id + ")"; |
1877 | 207 | qCritical().noquote() << msg; | 208 | qCritical().noquote() << msg; |
1878 | 208 | throw StorageErrorImpl::local_comms_error(msg); | 209 | throw StorageErrorImpl::local_comms_error(msg); |
1879 | 209 | } | 210 | } |
1880 | @@ -211,7 +212,8 @@ | |||
1881 | 211 | || | 212 | || |
1882 | 212 | (md_.type != ItemType::file && md.type == ItemType::file)) | 213 | (md_.type != ItemType::file && md.type == ItemType::file)) |
1883 | 213 | { | 214 | { |
1885 | 214 | QString msg = method + ": provider error: source and target item type differ"; | 215 | QString msg = method + ": provider error: source and target item type differ (source id = " + |
1886 | 216 | md_.item_id + ", target id = " + md.item_id + ")"; | ||
1887 | 215 | qCritical().noquote() << msg; | 217 | qCritical().noquote() << msg; |
1888 | 216 | throw StorageErrorImpl::local_comms_error(msg); | 218 | throw StorageErrorImpl::local_comms_error(msg); |
1889 | 217 | } | 219 | } |
1890 | @@ -266,7 +268,7 @@ | |||
1891 | 266 | { | 268 | { |
1892 | 267 | if (md.type != storage::ItemType::file) | 269 | if (md.type != storage::ItemType::file) |
1893 | 268 | { | 270 | { |
1895 | 269 | QString msg = method + ": impossible folder item returned by provider"; | 271 | QString msg = method + ": impossible folder item returned by provider (id = " + md.item_id + ")"; |
1896 | 270 | qCritical().noquote() << msg; | 272 | qCritical().noquote() << msg; |
1897 | 271 | throw StorageErrorImpl::local_comms_error(msg); | 273 | throw StorageErrorImpl::local_comms_error(msg); |
1898 | 272 | } | 274 | } |
1899 | @@ -318,7 +320,7 @@ | |||
1900 | 318 | { | 320 | { |
1901 | 319 | if (md.type == storage::ItemType::root) | 321 | if (md.type == storage::ItemType::root) |
1902 | 320 | { | 322 | { |
1904 | 321 | QString msg = method + ": impossible root item returned by provider"; | 323 | QString msg = method + ": impossible root item returned by provider (id = " + md.item_id + ")"; |
1905 | 322 | qCritical().noquote() << msg; | 324 | qCritical().noquote() << msg; |
1906 | 323 | throw StorageErrorImpl::local_comms_error(msg); | 325 | throw StorageErrorImpl::local_comms_error(msg); |
1907 | 324 | } | 326 | } |
1908 | @@ -379,7 +381,7 @@ | |||
1909 | 379 | { | 381 | { |
1910 | 380 | return; | 382 | return; |
1911 | 381 | } | 383 | } |
1913 | 382 | QString msg = method + ": impossible file item returned by provider"; | 384 | QString msg = method + ": impossible file item returned by provider (id = " + md.item_id + ")"; |
1914 | 383 | qCritical().noquote() << msg; | 385 | qCritical().noquote() << msg; |
1915 | 384 | throw StorageErrorImpl::local_comms_error(msg); | 386 | throw StorageErrorImpl::local_comms_error(msg); |
1916 | 385 | }; | 387 | }; |
1917 | @@ -423,7 +425,7 @@ | |||
1918 | 423 | { | 425 | { |
1919 | 424 | if (md.type != storage::ItemType::file) | 426 | if (md.type != storage::ItemType::file) |
1920 | 425 | { | 427 | { |
1922 | 426 | QString msg = method + ": impossible folder item returned by provider"; | 428 | QString msg = method + ": impossible folder item returned by provider (id = " + md.item_id + ")"; |
1923 | 427 | qCritical().noquote() << msg; | 429 | qCritical().noquote() << msg; |
1924 | 428 | throw StorageErrorImpl::local_comms_error(msg); | 430 | throw StorageErrorImpl::local_comms_error(msg); |
1925 | 429 | } | 431 | } |
1926 | 430 | 432 | ||
1927 | === modified file 'src/qt/internal/ItemListJobImpl.cpp' | |||
1928 | --- src/qt/internal/ItemListJobImpl.cpp 2016-10-12 07:23:15 +0000 | |||
1929 | +++ src/qt/internal/ItemListJobImpl.cpp 2016-12-12 02:53:43 +0000 | |||
1930 | @@ -62,16 +62,14 @@ | |||
1931 | 62 | auto item = ItemImpl::make_item(method_, md, account_impl_); | 62 | auto item = ItemImpl::make_item(method_, md, account_impl_); |
1932 | 63 | items.append(item); | 63 | items.append(item); |
1933 | 64 | } | 64 | } |
1935 | 65 | catch (StorageError const&) | 65 | catch (StorageError const& e) |
1936 | 66 | { | 66 | { |
1937 | 67 | // Bad metadata received from provider, validate_() or make_item() have logged it. | 67 | // Bad metadata received from provider, validate_() or make_item() have logged it. |
1938 | 68 | error_ = e; | ||
1939 | 68 | } | 69 | } |
1940 | 69 | } | 70 | } |
1946 | 70 | status_ = ItemListJob::Status::Finished; | 71 | status_ = error_.type() == StorageError::NoError ? ItemListJob::Finished : ItemListJob::Error; |
1947 | 71 | if (!items.isEmpty()) | 72 | Q_EMIT public_instance_->itemsReady(items); |
1943 | 72 | { | ||
1944 | 73 | Q_EMIT public_instance_->itemsReady(items); | ||
1945 | 74 | } | ||
1948 | 75 | Q_EMIT public_instance_->statusChanged(status_); | 73 | Q_EMIT public_instance_->statusChanged(status_); |
1949 | 76 | }; | 74 | }; |
1950 | 77 | 75 | ||
1951 | 78 | 76 | ||
1952 | === modified file 'src/qt/internal/MultiItemListJobImpl.cpp' | |||
1953 | --- src/qt/internal/MultiItemListJobImpl.cpp 2016-10-12 07:23:15 +0000 | |||
1954 | +++ src/qt/internal/MultiItemListJobImpl.cpp 2016-12-12 02:53:43 +0000 | |||
1955 | @@ -86,10 +86,7 @@ | |||
1956 | 86 | { | 86 | { |
1957 | 87 | status_ = ItemListJob::Status::Finished; | 87 | status_ = ItemListJob::Status::Finished; |
1958 | 88 | } | 88 | } |
1963 | 89 | if (!items.isEmpty()) | 89 | Q_EMIT public_instance_->itemsReady(items); |
1960 | 90 | { | ||
1961 | 91 | Q_EMIT public_instance_->itemsReady(items); | ||
1962 | 92 | } | ||
1964 | 93 | if (token.isEmpty()) | 90 | if (token.isEmpty()) |
1965 | 94 | { | 91 | { |
1966 | 95 | Q_EMIT public_instance_->statusChanged(status_); | 92 | Q_EMIT public_instance_->statusChanged(status_); |
1967 | 96 | 93 | ||
1968 | === modified file 'src/qt/internal/RuntimeImpl.cpp' | |||
1969 | --- src/qt/internal/RuntimeImpl.cpp 2016-10-10 05:24:16 +0000 | |||
1970 | +++ src/qt/internal/RuntimeImpl.cpp 2016-12-12 02:53:43 +0000 | |||
1971 | @@ -18,15 +18,17 @@ | |||
1972 | 18 | 18 | ||
1973 | 19 | #include <unity/storage/qt/internal/RuntimeImpl.h> | 19 | #include <unity/storage/qt/internal/RuntimeImpl.h> |
1974 | 20 | 20 | ||
1975 | 21 | #include "RegistryInterface.h" | ||
1976 | 21 | #include <unity/storage/internal/dbusmarshal.h> | 22 | #include <unity/storage/internal/dbusmarshal.h> |
1978 | 22 | #include <unity/storage/qt/AccountsJob.h> | 23 | #include <unity/storage/internal/EnvVars.h> |
1979 | 23 | #include <unity/storage/qt/internal/AccountImpl.h> | 24 | #include <unity/storage/qt/internal/AccountImpl.h> |
1980 | 25 | #include <unity/storage/qt/internal/AccountsJobImpl.h> | ||
1981 | 24 | #include <unity/storage/qt/internal/StorageErrorImpl.h> | 26 | #include <unity/storage/qt/internal/StorageErrorImpl.h> |
1982 | 25 | #include <unity/storage/qt/Item.h> | ||
1983 | 26 | #include <unity/storage/qt/ItemJob.h> | 27 | #include <unity/storage/qt/ItemJob.h> |
1984 | 27 | #include <unity/storage/qt/ItemListJob.h> | 28 | #include <unity/storage/qt/ItemListJob.h> |
1985 | 28 | #include <unity/storage/qt/Runtime.h> | 29 | #include <unity/storage/qt/Runtime.h> |
1986 | 29 | #include <unity/storage/qt/VoidJob.h> | 30 | #include <unity/storage/qt/VoidJob.h> |
1987 | 31 | #include <unity/storage/registry/Registry.h> | ||
1988 | 30 | 32 | ||
1989 | 31 | #include <QDBusError> | 33 | #include <QDBusError> |
1990 | 32 | #include <QDBusMetaType> | 34 | #include <QDBusMetaType> |
1991 | @@ -57,6 +59,9 @@ | |||
1992 | 57 | 59 | ||
1993 | 58 | qDBusRegisterMetaType<unity::storage::internal::ItemMetadata>(); | 60 | qDBusRegisterMetaType<unity::storage::internal::ItemMetadata>(); |
1994 | 59 | qDBusRegisterMetaType<QList<unity::storage::internal::ItemMetadata>>(); | 61 | qDBusRegisterMetaType<QList<unity::storage::internal::ItemMetadata>>(); |
1995 | 62 | |||
1996 | 63 | qDBusRegisterMetaType<unity::storage::internal::AccountDetails>(); | ||
1997 | 64 | qDBusRegisterMetaType<QList<unity::storage::internal::AccountDetails>>(); | ||
1998 | 60 | } | 65 | } |
1999 | 61 | 66 | ||
2000 | 62 | } | 67 | } |
2001 | @@ -66,10 +71,12 @@ | |||
2002 | 66 | { | 71 | { |
2003 | 67 | } | 72 | } |
2004 | 68 | 73 | ||
2006 | 69 | RuntimeImpl::RuntimeImpl(QDBusConnection const& bus) | 74 | RuntimeImpl::RuntimeImpl(QDBusConnection const& conn) |
2007 | 70 | : is_valid_(true) | 75 | : is_valid_(true) |
2010 | 71 | , conn_(bus) | 76 | , conn_(conn) |
2011 | 72 | , accounts_manager_(new OnlineAccounts::Manager("", conn_)) | 77 | , registry_(new RegistryInterface(storage::registry::BUS_NAME, |
2012 | 78 | storage::registry::OBJECT_PATH, | ||
2013 | 79 | conn_)) | ||
2014 | 73 | { | 80 | { |
2015 | 74 | register_meta_types(); | 81 | register_meta_types(); |
2016 | 75 | } | 82 | } |
2017 | @@ -96,13 +103,17 @@ | |||
2018 | 96 | 103 | ||
2019 | 97 | AccountsJob* RuntimeImpl::accounts() const | 104 | AccountsJob* RuntimeImpl::accounts() const |
2020 | 98 | { | 105 | { |
2021 | 106 | QString const method = "Runtime::accounts()"; | ||
2022 | 107 | |||
2023 | 99 | if (!is_valid_) | 108 | if (!is_valid_) |
2024 | 100 | { | 109 | { |
2025 | 101 | QString msg = "Runtime::accounts(): Runtime was destroyed previously"; | 110 | QString msg = "Runtime::accounts(): Runtime was destroyed previously"; |
2027 | 102 | return new AccountsJob(StorageErrorImpl::runtime_destroyed_error(msg)); | 111 | return AccountsJobImpl::make_job(StorageErrorImpl::runtime_destroyed_error(msg)); |
2028 | 103 | } | 112 | } |
2031 | 104 | auto This = const_cast<RuntimeImpl*>(this); | 113 | |
2032 | 105 | return new AccountsJob(This->shared_from_this()); | 114 | auto reply = registry_->ListAccounts(); |
2033 | 115 | auto This = const_pointer_cast<RuntimeImpl>(shared_from_this()); | ||
2034 | 116 | return AccountsJobImpl::make_job(This, method, reply); | ||
2035 | 106 | } | 117 | } |
2036 | 107 | 118 | ||
2037 | 108 | StorageError RuntimeImpl::shutdown() | 119 | StorageError RuntimeImpl::shutdown() |
2038 | @@ -116,23 +127,14 @@ | |||
2039 | 116 | return error_; | 127 | return error_; |
2040 | 117 | } | 128 | } |
2041 | 118 | 129 | ||
2042 | 119 | shared_ptr<OnlineAccounts::Manager> RuntimeImpl::accounts_manager() const | ||
2043 | 120 | { | ||
2044 | 121 | return accounts_manager_; | ||
2045 | 122 | } | ||
2046 | 123 | |||
2047 | 124 | Account RuntimeImpl::make_test_account(QString const& bus_name, | 130 | Account RuntimeImpl::make_test_account(QString const& bus_name, |
2048 | 125 | QString const& object_path, | 131 | QString const& object_path, |
2052 | 126 | QString const& owner_id, | 132 | quint32 id, |
2053 | 127 | QString const& owner, | 133 | QString const& service_id, |
2054 | 128 | QString const& description) | 134 | QString const& name) |
2055 | 129 | { | 135 | { |
2062 | 130 | return AccountImpl::make_account(shared_from_this(), | 136 | storage::internal::AccountDetails ad{bus_name, QDBusObjectPath(object_path), id, service_id, name, "", ""}; |
2063 | 131 | bus_name, | 137 | return AccountImpl::make_account(shared_from_this(), ad); |
2058 | 132 | object_path, | ||
2059 | 133 | owner_id, | ||
2060 | 134 | owner, | ||
2061 | 135 | description); | ||
2064 | 136 | } | 138 | } |
2065 | 137 | 139 | ||
2066 | 138 | } // namespace internal | 140 | } // namespace internal |
2067 | 139 | 141 | ||
2068 | === modified file 'src/qt/internal/validate.cpp' | |||
2069 | --- src/qt/internal/validate.cpp 2016-11-02 06:06:32 +0000 | |||
2070 | +++ src/qt/internal/validate.cpp 2016-12-12 02:53:43 +0000 | |||
2071 | @@ -110,69 +110,81 @@ | |||
2072 | 110 | { | 110 | { |
2073 | 111 | using namespace unity::storage::metadata; | 111 | using namespace unity::storage::metadata; |
2074 | 112 | 112 | ||
2138 | 113 | QString prefix = method + ": received invalid metadata from provider: "; | 113 | QString prefix = method + ": received invalid metadata from provider"; |
2139 | 114 | 114 | if (!md.item_id.isEmpty()) | |
2140 | 115 | // Basic sanity checks for mandatory fields. | 115 | { |
2141 | 116 | if (md.item_id.isEmpty()) | 116 | prefix += " (id = " + md.item_id + ")"; |
2142 | 117 | { | 117 | } |
2143 | 118 | throw StorageErrorImpl::local_comms_error(prefix + "item_id cannot be empty"); | 118 | prefix += ": "; |
2144 | 119 | } | 119 | |
2145 | 120 | if (md.type != ItemType::root) | 120 | try |
2146 | 121 | { | 121 | { |
2147 | 122 | if (md.parent_ids.isEmpty()) | 122 | // Basic sanity checks for mandatory fields. |
2148 | 123 | { | 123 | if (md.item_id.isEmpty()) |
2149 | 124 | throw StorageErrorImpl::local_comms_error(prefix + "file or folder must have at least one parent ID"); | 124 | { |
2150 | 125 | } | 125 | throw StorageErrorImpl::local_comms_error(prefix + "item_id cannot be empty"); |
2151 | 126 | for (int i = 0; i < md.parent_ids.size(); ++i) | 126 | } |
2152 | 127 | { | 127 | if (md.type != ItemType::root) |
2153 | 128 | if (md.parent_ids.at(i).isEmpty()) | 128 | { |
2154 | 129 | { | 129 | if (md.parent_ids.isEmpty()) |
2155 | 130 | throw StorageErrorImpl::local_comms_error(prefix + "parent_id of file or folder cannot be empty"); | 130 | { |
2156 | 131 | } | 131 | throw StorageErrorImpl::local_comms_error(prefix + "file or folder must have at least one parent ID"); |
2157 | 132 | } | 132 | } |
2158 | 133 | } | 133 | for (int i = 0; i < md.parent_ids.size(); ++i) |
2159 | 134 | if (md.type == ItemType::root && !md.parent_ids.isEmpty()) | 134 | { |
2160 | 135 | { | 135 | if (md.parent_ids.at(i).isEmpty()) |
2161 | 136 | throw StorageErrorImpl::local_comms_error(prefix + "parent_ids of root must be empty"); | 136 | { |
2162 | 137 | } | 137 | throw StorageErrorImpl::local_comms_error(prefix + "parent_id of file or folder cannot be empty"); |
2163 | 138 | if (md.type != ItemType::root) // Dropbox does not support metadata for roots. | 138 | } |
2164 | 139 | { | 139 | } |
2165 | 140 | if (md.name.isEmpty()) | 140 | } |
2166 | 141 | { | 141 | if (md.type == ItemType::root && !md.parent_ids.isEmpty()) |
2167 | 142 | throw StorageErrorImpl::local_comms_error(prefix + "name cannot be empty"); | 142 | { |
2168 | 143 | } | 143 | throw StorageErrorImpl::local_comms_error(prefix + "parent_ids of root must be empty"); |
2169 | 144 | } | 144 | } |
2170 | 145 | if (md.type == ItemType::file && md.etag.isEmpty()) // WebDav doesn't do etag for folders. | 145 | if (md.type != ItemType::root) // Dropbox does not support metadata for roots. |
2171 | 146 | { | 146 | { |
2172 | 147 | throw StorageErrorImpl::local_comms_error(prefix + "etag of a file cannot be empty"); | 147 | if (md.name.isEmpty()) |
2173 | 148 | } | 148 | { |
2174 | 149 | 149 | throw StorageErrorImpl::local_comms_error(prefix + "name cannot be empty"); | |
2175 | 150 | // Sanity check metadata to make sure only known metadata keys appear. | 150 | } |
2176 | 151 | QMapIterator<QString, QVariant> actual(md.metadata); | 151 | } |
2177 | 152 | while (actual.hasNext()) | 152 | if (md.type == ItemType::file && md.etag.isEmpty()) // WebDav doesn't do etag for folders. |
2178 | 153 | { | 153 | { |
2179 | 154 | actual.next(); | 154 | throw StorageErrorImpl::local_comms_error(prefix + "etag of a file cannot be empty"); |
2180 | 155 | auto known = known_metadata.find(actual.key().toStdString()); | 155 | } |
2181 | 156 | if (known == known_metadata.end()) | 156 | |
2182 | 157 | { | 157 | // Sanity check metadata to make sure only known metadata keys appear. |
2183 | 158 | qWarning().noquote().nospace() << prefix << "unknown metadata key: \"" << actual.key() << "\""; | 158 | QMapIterator<QString, QVariant> actual(md.metadata); |
2184 | 159 | } | 159 | while (actual.hasNext()) |
2185 | 160 | else | 160 | { |
2186 | 161 | { | 161 | actual.next(); |
2187 | 162 | validate_type_and_value(prefix, actual, known); | 162 | auto known = known_metadata.find(actual.key().toStdString()); |
2188 | 163 | } | 163 | if (known == known_metadata.end()) |
2189 | 164 | } | 164 | { |
2190 | 165 | 165 | qWarning().noquote().nospace() << prefix << "unknown metadata key: \"" << actual.key() << "\""; | |
2191 | 166 | // Sanity check metadata to make sure that mandatory fields are present. | 166 | } |
2192 | 167 | if (md.type == ItemType::file) | 167 | else |
2193 | 168 | { | 168 | { |
2194 | 169 | if (!md.metadata.contains(metadata::SIZE_IN_BYTES) || | 169 | validate_type_and_value(prefix, actual, known); |
2195 | 170 | !md.metadata.contains(metadata::LAST_MODIFIED_TIME)) | 170 | } |
2196 | 171 | { | 171 | } |
2197 | 172 | QString msg = prefix + "missing key \"" + metadata::SIZE_IN_BYTES + "\" " | 172 | |
2198 | 173 | "in metadata for \"" + md.item_id + "\""; | 173 | // Sanity check metadata to make sure that mandatory fields are present. |
2199 | 174 | throw StorageErrorImpl::local_comms_error(msg); | 174 | if (md.type == ItemType::file) |
2200 | 175 | } | 175 | { |
2201 | 176 | if (!md.metadata.contains(metadata::SIZE_IN_BYTES) || | ||
2202 | 177 | !md.metadata.contains(metadata::LAST_MODIFIED_TIME)) | ||
2203 | 178 | { | ||
2204 | 179 | QString msg = prefix + "missing key \"" + metadata::SIZE_IN_BYTES + "\" in metadata"; | ||
2205 | 180 | throw StorageErrorImpl::local_comms_error(msg); | ||
2206 | 181 | } | ||
2207 | 182 | } | ||
2208 | 183 | } | ||
2209 | 184 | catch (StorageError const& e) | ||
2210 | 185 | { | ||
2211 | 186 | qCritical().noquote() << e.errorString(); | ||
2212 | 187 | throw; | ||
2213 | 176 | } | 188 | } |
2214 | 177 | } | 189 | } |
2215 | 178 | 190 | ||
2216 | 179 | 191 | ||
2217 | === added directory 'src/registry' | |||
2218 | === added file 'src/registry/CMakeLists.txt' | |||
2219 | --- src/registry/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2220 | +++ src/registry/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
2221 | @@ -0,0 +1,47 @@ | |||
2222 | 1 | include_directories( | ||
2223 | 2 | ${CMAKE_CURRENT_BINARY_DIR} | ||
2224 | 3 | ${ONLINEACCOUNTS_DEPS_INCLUDE_DIRS} | ||
2225 | 4 | ) | ||
2226 | 5 | |||
2227 | 6 | set(TARGET "storage-framework-registry") | ||
2228 | 7 | |||
2229 | 8 | qt5_add_dbus_adaptor(adaptor_files | ||
2230 | 9 | ${CMAKE_SOURCE_DIR}/data/registry.xml | ||
2231 | 10 | unity/storage/registry/internal/RegistryAdaptor.h | ||
2232 | 11 | unity::storage::registry::internal::RegistryAdaptor | ||
2233 | 12 | ) | ||
2234 | 13 | |||
2235 | 14 | set_source_files_properties(${adaptor_files} PROPERTIES | ||
2236 | 15 | COMPILE_FLAGS "-Wno-ctor-dtor-privacy -Wno-missing-field-initializers" | ||
2237 | 16 | GENERATED TRUE | ||
2238 | 17 | ) | ||
2239 | 18 | |||
2240 | 19 | add_executable(${TARGET} | ||
2241 | 20 | internal/ListAccountsHandler.cpp | ||
2242 | 21 | internal/qdbus-last-error-msg.cpp | ||
2243 | 22 | internal/RegistryAdaptor.cpp | ||
2244 | 23 | main.cpp | ||
2245 | 24 | ${CMAKE_SOURCE_DIR}/include/unity/storage/registry/internal/ListAccountsHandler.h | ||
2246 | 25 | ${CMAKE_SOURCE_DIR}/include/unity/storage/registry/internal/RegistryAdaptor.h | ||
2247 | 26 | ${adaptor_files}) | ||
2248 | 27 | |||
2249 | 28 | set_target_properties(${TARGET} PROPERTIES AUTOMOC TRUE) | ||
2250 | 29 | |||
2251 | 30 | target_link_libraries(${TARGET} | ||
2252 | 31 | storage-framework-common-internal | ||
2253 | 32 | Qt5::Core | ||
2254 | 33 | Qt5::DBus | ||
2255 | 34 | ${ONLINEACCOUNTS_DEPS_LDFLAGS} | ||
2256 | 35 | ) | ||
2257 | 36 | |||
2258 | 37 | install( | ||
2259 | 38 | TARGETS ${TARGET} | ||
2260 | 39 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} | ||
2261 | 40 | ) | ||
2262 | 41 | |||
2263 | 42 | configure_file(com.canonical.StorageFramework.Registry.service.in com.canonical.StorageFramework.Registry.service) | ||
2264 | 43 | |||
2265 | 44 | install( | ||
2266 | 45 | FILES ${CMAKE_CURRENT_BINARY_DIR}/com.canonical.StorageFramework.Registry.service | ||
2267 | 46 | DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services | ||
2268 | 47 | ) | ||
2269 | 0 | 48 | ||
2270 | === added file 'src/registry/com.canonical.StorageFramework.Registry.service.in' | |||
2271 | --- src/registry/com.canonical.StorageFramework.Registry.service.in 1970-01-01 00:00:00 +0000 | |||
2272 | +++ src/registry/com.canonical.StorageFramework.Registry.service.in 2016-12-12 02:53:43 +0000 | |||
2273 | @@ -0,0 +1,3 @@ | |||
2274 | 1 | [D-BUS Service] | ||
2275 | 2 | Name=com.canonical.StorageFramework.Registry | ||
2276 | 3 | Exec=@CMAKE_INSTALL_FULL_LIBDIR@/@PROJECT_NAME@/storage-framework-registry | ||
2277 | 0 | 4 | ||
2278 | === added directory 'src/registry/internal' | |||
2279 | === added file 'src/registry/internal/ListAccountsHandler.cpp' | |||
2280 | --- src/registry/internal/ListAccountsHandler.cpp 1970-01-01 00:00:00 +0000 | |||
2281 | +++ src/registry/internal/ListAccountsHandler.cpp 2016-12-12 02:53:43 +0000 | |||
2282 | @@ -0,0 +1,127 @@ | |||
2283 | 1 | /* | ||
2284 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
2285 | 3 | * | ||
2286 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2287 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2288 | 6 | * published by the Free Software Foundation. | ||
2289 | 7 | * | ||
2290 | 8 | * This program is distributed in the hope that it will be useful, | ||
2291 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2292 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2293 | 11 | * GNU Lesser General Public License for more details. | ||
2294 | 12 | * | ||
2295 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2296 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2297 | 15 | * | ||
2298 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
2299 | 17 | */ | ||
2300 | 18 | |||
2301 | 19 | #include <unity/storage/registry/internal/ListAccountsHandler.h> | ||
2302 | 20 | |||
2303 | 21 | #include <unity/storage/internal/AccountDetails.h> | ||
2304 | 22 | #include <unity/storage/registry/internal/qdbus-last-error-msg.h> | ||
2305 | 23 | |||
2306 | 24 | #include <OnlineAccounts/Account> | ||
2307 | 25 | #include <QDebug> | ||
2308 | 26 | |||
2309 | 27 | using namespace std; | ||
2310 | 28 | |||
2311 | 29 | namespace unity | ||
2312 | 30 | { | ||
2313 | 31 | namespace storage | ||
2314 | 32 | { | ||
2315 | 33 | namespace registry | ||
2316 | 34 | { | ||
2317 | 35 | namespace internal | ||
2318 | 36 | { | ||
2319 | 37 | |||
2320 | 38 | ListAccountsHandler::ListAccountsHandler(QDBusConnection const& conn, | ||
2321 | 39 | QDBusMessage const& msg, | ||
2322 | 40 | shared_ptr<storage::internal::InactivityTimer> const& timer) | ||
2323 | 41 | : conn_(conn) | ||
2324 | 42 | , msg_(msg) | ||
2325 | 43 | , manager_("", conn) | ||
2326 | 44 | , activity_notifier_(timer) | ||
2327 | 45 | { | ||
2328 | 46 | connect(&manager_, &OnlineAccounts::Manager::ready, this, &ListAccountsHandler::manager_ready); | ||
2329 | 47 | connect(&timer_, &QTimer::timeout, this, &ListAccountsHandler::timeout); | ||
2330 | 48 | timer_.setSingleShot(true); | ||
2331 | 49 | timer_.start(25000); // TODO: Need config for this eventually. | ||
2332 | 50 | } | ||
2333 | 51 | |||
2334 | 52 | ListAccountsHandler::~ListAccountsHandler() = default; | ||
2335 | 53 | |||
2336 | 54 | namespace | ||
2337 | 55 | { | ||
2338 | 56 | |||
2339 | 57 | // TODO: This is a hack until Online Accounts is updated to give us the provider ID, provider name, and icon name. | ||
2340 | 58 | |||
2341 | 59 | struct ProviderDetails | ||
2342 | 60 | { | ||
2343 | 61 | char const* bus_name; | ||
2344 | 62 | char const* provider_name; | ||
2345 | 63 | }; | ||
2346 | 64 | |||
2347 | 65 | static map<QString, ProviderDetails> const BUS_NAMES = | ||
2348 | 66 | { | ||
2349 | 67 | { "storage-provider-test", { "com.canonical.StorageFramework.Provider.ProviderTest", "Test Provider" } }, | ||
2350 | 68 | { "com.canonical.scopes.mcloud_mcloud_mcloud", { "com.canonical.StorageFramework.Provider.McloudProvider", "mcloud" } }, | ||
2351 | 69 | { "storage-provider-owncloud", { "com.canonical.StorageFramework.Provider.OwnCloud", "ownCloud" } }, | ||
2352 | 70 | { "storage-provider-onedrive", { "com.canonical.StorageFramework.Provider.OnedriveProvider", "OneDrive" } }, | ||
2353 | 71 | }; | ||
2354 | 72 | |||
2355 | 73 | } // namespace | ||
2356 | 74 | |||
2357 | 75 | void ListAccountsHandler::manager_ready() | ||
2358 | 76 | { | ||
2359 | 77 | timer_.stop(); | ||
2360 | 78 | disconnect(this); | ||
2361 | 79 | deleteLater(); | ||
2362 | 80 | |||
2363 | 81 | QList<storage::internal::AccountDetails> accounts; | ||
2364 | 82 | for (auto const& acct : manager_.availableAccounts()) | ||
2365 | 83 | { | ||
2366 | 84 | auto const it = BUS_NAMES.find(acct->serviceId()); | ||
2367 | 85 | if (it == BUS_NAMES.end()) | ||
2368 | 86 | { | ||
2369 | 87 | continue; | ||
2370 | 88 | } | ||
2371 | 89 | |||
2372 | 90 | storage::internal::AccountDetails ad; | ||
2373 | 91 | ad.busName = it->second.bus_name; | ||
2374 | 92 | ad.objectPath = QDBusObjectPath(QStringLiteral("/provider/%1").arg(acct->id())); | ||
2375 | 93 | ad.id = acct->id(); | ||
2376 | 94 | ad.serviceId = acct->serviceId(); | ||
2377 | 95 | ad.displayName = acct->displayName(); | ||
2378 | 96 | ad.providerName = it->second.provider_name; | ||
2379 | 97 | ad.iconName = ""; | ||
2380 | 98 | |||
2381 | 99 | accounts.append(ad); | ||
2382 | 100 | } | ||
2383 | 101 | |||
2384 | 102 | if (!conn_.send(msg_.createReply(QVariant::fromValue(accounts)))) | ||
2385 | 103 | { | ||
2386 | 104 | auto msg = last_error_msg(conn_); | ||
2387 | 105 | qCritical().noquote() << "ListAccounts(): could not send DBus reply" + msg; | ||
2388 | 106 | } | ||
2389 | 107 | } | ||
2390 | 108 | |||
2391 | 109 | void ListAccountsHandler::timeout() | ||
2392 | 110 | { | ||
2393 | 111 | disconnect(this); | ||
2394 | 112 | deleteLater(); | ||
2395 | 113 | |||
2396 | 114 | QString err = QString("cannot contact Online Accounts: request timed out after ") + | ||
2397 | 115 | QString::number(timer_.interval()) + " ms"; | ||
2398 | 116 | qCritical().noquote() << err; | ||
2399 | 117 | if (!conn_.send(msg_.createErrorReply(QDBusError::Other, err))) | ||
2400 | 118 | { | ||
2401 | 119 | auto msg = last_error_msg(conn_); | ||
2402 | 120 | qCritical().noquote() << "ListAccounts(): could not send DBus error reply" + msg; | ||
2403 | 121 | } | ||
2404 | 122 | } | ||
2405 | 123 | |||
2406 | 124 | } // namespace internal | ||
2407 | 125 | } // namespace registry | ||
2408 | 126 | } // namespace storage | ||
2409 | 127 | } // namespace unity | ||
2410 | 0 | 128 | ||
2411 | === added file 'src/registry/internal/RegistryAdaptor.cpp' | |||
2412 | --- src/registry/internal/RegistryAdaptor.cpp 1970-01-01 00:00:00 +0000 | |||
2413 | +++ src/registry/internal/RegistryAdaptor.cpp 2016-12-12 02:53:43 +0000 | |||
2414 | @@ -0,0 +1,55 @@ | |||
2415 | 1 | /* | ||
2416 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
2417 | 3 | * | ||
2418 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2419 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2420 | 6 | * published by the Free Software Foundation. | ||
2421 | 7 | * | ||
2422 | 8 | * This program is distributed in the hope that it will be useful, | ||
2423 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2424 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2425 | 11 | * GNU Lesser General Public License for more details. | ||
2426 | 12 | * | ||
2427 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2428 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2429 | 15 | * | ||
2430 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
2431 | 17 | */ | ||
2432 | 18 | |||
2433 | 19 | #include <unity/storage/registry/internal/RegistryAdaptor.h> | ||
2434 | 20 | |||
2435 | 21 | #include <unity/storage/registry/internal/ListAccountsHandler.h> | ||
2436 | 22 | |||
2437 | 23 | using namespace std; | ||
2438 | 24 | |||
2439 | 25 | namespace unity | ||
2440 | 26 | { | ||
2441 | 27 | namespace storage | ||
2442 | 28 | { | ||
2443 | 29 | namespace registry | ||
2444 | 30 | { | ||
2445 | 31 | namespace internal | ||
2446 | 32 | { | ||
2447 | 33 | |||
2448 | 34 | RegistryAdaptor::RegistryAdaptor(QDBusConnection const& conn, | ||
2449 | 35 | shared_ptr<storage::internal::InactivityTimer> const& timer, | ||
2450 | 36 | QObject* parent) | ||
2451 | 37 | : QObject(parent) | ||
2452 | 38 | , conn_(conn) | ||
2453 | 39 | , timer_(timer) | ||
2454 | 40 | { | ||
2455 | 41 | } | ||
2456 | 42 | |||
2457 | 43 | RegistryAdaptor::~RegistryAdaptor() = default; | ||
2458 | 44 | |||
2459 | 45 | QList<unity::storage::internal::AccountDetails> RegistryAdaptor::ListAccounts() | ||
2460 | 46 | { | ||
2461 | 47 | new ListAccountsHandler(conn_, message(), timer_); // Handler deletes itself once done. | ||
2462 | 48 | setDelayedReply(true); | ||
2463 | 49 | return QList<unity::storage::internal::AccountDetails>(); | ||
2464 | 50 | } | ||
2465 | 51 | |||
2466 | 52 | } // namespace internal | ||
2467 | 53 | } // namespace registry | ||
2468 | 54 | } // namespace storage | ||
2469 | 55 | } // namespace unity | ||
2470 | 0 | 56 | ||
2471 | === added file 'src/registry/internal/qdbus-last-error-msg.cpp' | |||
2472 | --- src/registry/internal/qdbus-last-error-msg.cpp 1970-01-01 00:00:00 +0000 | |||
2473 | +++ src/registry/internal/qdbus-last-error-msg.cpp 2016-12-12 02:53:43 +0000 | |||
2474 | @@ -0,0 +1,49 @@ | |||
2475 | 1 | /* | ||
2476 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
2477 | 3 | * | ||
2478 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2479 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2480 | 6 | * published by the Free Software Foundation. | ||
2481 | 7 | * | ||
2482 | 8 | * This program is distributed in the hope that it will be useful, | ||
2483 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2484 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2485 | 11 | * GNU Lesser General Public License for more details. | ||
2486 | 12 | * | ||
2487 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2488 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2489 | 15 | * | ||
2490 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
2491 | 17 | */ | ||
2492 | 18 | |||
2493 | 19 | #include <unity/storage/registry/internal/qdbus-last-error-msg.h> | ||
2494 | 20 | |||
2495 | 21 | #pragma GCC diagnostic push | ||
2496 | 22 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
2497 | 23 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
2498 | 24 | #include <QDBusError> | ||
2499 | 25 | #pragma GCC diagnostic pop | ||
2500 | 26 | |||
2501 | 27 | namespace unity | ||
2502 | 28 | { | ||
2503 | 29 | namespace storage | ||
2504 | 30 | { | ||
2505 | 31 | namespace registry | ||
2506 | 32 | { | ||
2507 | 33 | namespace internal | ||
2508 | 34 | { | ||
2509 | 35 | |||
2510 | 36 | QString last_error_msg(QDBusConnection const& conn) | ||
2511 | 37 | { | ||
2512 | 38 | auto msg = conn.lastError().message(); | ||
2513 | 39 | if (!msg.isEmpty()) | ||
2514 | 40 | { | ||
2515 | 41 | msg = ": " + msg; | ||
2516 | 42 | } | ||
2517 | 43 | return msg; | ||
2518 | 44 | } | ||
2519 | 45 | |||
2520 | 46 | } // namespace internal | ||
2521 | 47 | } // namespace registry | ||
2522 | 48 | } // namespace storage | ||
2523 | 49 | } // namespace unity | ||
2524 | 0 | 50 | ||
2525 | === added file 'src/registry/main.cpp' | |||
2526 | --- src/registry/main.cpp 1970-01-01 00:00:00 +0000 | |||
2527 | +++ src/registry/main.cpp 2016-12-12 02:53:43 +0000 | |||
2528 | @@ -0,0 +1,95 @@ | |||
2529 | 1 | /* | ||
2530 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
2531 | 3 | * | ||
2532 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2533 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2534 | 6 | * published by the Free Software Foundation. | ||
2535 | 7 | * | ||
2536 | 8 | * This program is distributed in the hope that it will be useful, | ||
2537 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2538 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2539 | 11 | * GNU Lesser General Public License for more details. | ||
2540 | 12 | * | ||
2541 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2542 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2543 | 15 | * | ||
2544 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
2545 | 17 | */ | ||
2546 | 18 | |||
2547 | 19 | #include "registryadaptor.h" | ||
2548 | 20 | #include <unity/storage/internal/EnvVars.h> | ||
2549 | 21 | #include <unity/storage/internal/InactivityTimer.h> | ||
2550 | 22 | #include <unity/storage/internal/TraceMessageHandler.h> | ||
2551 | 23 | #include <unity/storage/registry/internal/qdbus-last-error-msg.h> | ||
2552 | 24 | #include <unity/storage/registry/internal/RegistryAdaptor.h> | ||
2553 | 25 | #include <unity/storage/registry/Registry.h> | ||
2554 | 26 | |||
2555 | 27 | #pragma GCC diagnostic push | ||
2556 | 28 | #pragma GCC diagnostic ignored "-Wcast-align" | ||
2557 | 29 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
2558 | 30 | #include <QCoreApplication> | ||
2559 | 31 | #include <QDBusArgument> | ||
2560 | 32 | #include <QDBusError> | ||
2561 | 33 | #include <QFileInfo> | ||
2562 | 34 | #pragma GCC diagnostic pop | ||
2563 | 35 | |||
2564 | 36 | using namespace unity::storage; | ||
2565 | 37 | using namespace unity::storage::registry::internal; | ||
2566 | 38 | using namespace std; | ||
2567 | 39 | |||
2568 | 40 | int main(int argc, char* argv[]) | ||
2569 | 41 | { | ||
2570 | 42 | auto const prog_name = QFileInfo(argv[0]).fileName(); | ||
2571 | 43 | internal::TraceMessageHandler message_handler(prog_name); | ||
2572 | 44 | |||
2573 | 45 | int rc = 1; | ||
2574 | 46 | try | ||
2575 | 47 | { | ||
2576 | 48 | QCoreApplication app(argc, argv); | ||
2577 | 49 | |||
2578 | 50 | auto conn = QDBusConnection::sessionBus(); | ||
2579 | 51 | |||
2580 | 52 | int const timeout_ms = internal::EnvVars::registry_timeout_ms(); | ||
2581 | 53 | auto timeout_func = [&app, timeout_ms] | ||
2582 | 54 | { | ||
2583 | 55 | qInfo().noquote().nospace() << "Exiting after " << QString::number(timeout_ms) << " ms of idle time"; | ||
2584 | 56 | app.quit(); | ||
2585 | 57 | }; | ||
2586 | 58 | auto inactivity_timer = make_shared<unity::storage::internal::InactivityTimer>(timeout_ms, timeout_func); | ||
2587 | 59 | |||
2588 | 60 | registry::internal::RegistryAdaptor registry_adaptor(conn, inactivity_timer); | ||
2589 | 61 | new ::RegistryAdaptor(®istry_adaptor); | ||
2590 | 62 | |||
2591 | 63 | auto const& object_path = registry::OBJECT_PATH; | ||
2592 | 64 | if (!conn.registerObject(object_path, ®istry_adaptor)) | ||
2593 | 65 | { | ||
2594 | 66 | auto msg = last_error_msg(conn); | ||
2595 | 67 | throw runtime_error(string("Could not register object path ") + | ||
2596 | 68 | object_path.toStdString() + msg.toStdString()); | ||
2597 | 69 | } | ||
2598 | 70 | |||
2599 | 71 | qDBusRegisterMetaType<unity::storage::internal::AccountDetails>(); | ||
2600 | 72 | qDBusRegisterMetaType<QList<unity::storage::internal::AccountDetails>>(); | ||
2601 | 73 | |||
2602 | 74 | auto const& bus_name = registry::BUS_NAME; | ||
2603 | 75 | if (!conn.registerService(bus_name)) | ||
2604 | 76 | { | ||
2605 | 77 | auto msg = last_error_msg(conn); | ||
2606 | 78 | throw runtime_error(string("Could not acquire DBus name ") + bus_name.toStdString() + msg.toStdString()); | ||
2607 | 79 | } | ||
2608 | 80 | |||
2609 | 81 | rc = app.exec(); | ||
2610 | 82 | |||
2611 | 83 | if (!conn.unregisterService(bus_name)) | ||
2612 | 84 | { | ||
2613 | 85 | auto msg = last_error_msg(conn); | ||
2614 | 86 | throw runtime_error(string("Could not release DBus name ") + bus_name.toStdString() + msg.toStdString()); | ||
2615 | 87 | } | ||
2616 | 88 | } | ||
2617 | 89 | catch (std::exception const& e) | ||
2618 | 90 | { | ||
2619 | 91 | qCritical().noquote() << e.what(); | ||
2620 | 92 | } | ||
2621 | 93 | |||
2622 | 94 | return rc; | ||
2623 | 95 | } | ||
2624 | 0 | 96 | ||
2625 | === modified file 'tests/CMakeLists.txt' | |||
2626 | --- tests/CMakeLists.txt 2016-09-08 08:33:59 +0000 | |||
2627 | +++ tests/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
2628 | @@ -1,10 +1,4 @@ | |||
2629 | 1 | # We add -g so we get debug info for the gtest stack frames with gdb. | ||
2630 | 2 | # The warnings are suppressed so we get a noise-free build for gtest and gmock. | ||
2631 | 3 | |||
2632 | 4 | set(old_cxx_flags ${CMAKE_CXX_FLAGS}) | ||
2633 | 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wno-old-style-cast -Wno-missing-field-initializers") | ||
2634 | 6 | find_package(GMock) | 1 | find_package(GMock) |
2635 | 7 | set(CMAKE_CXX_FLAGS ${old_cxx_flags}) | ||
2636 | 8 | 2 | ||
2637 | 9 | configure_file(testsetup.h.in testsetup.h @ONLY) | 3 | configure_file(testsetup.h.in testsetup.h @ONLY) |
2638 | 10 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | 4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
2639 | @@ -12,6 +6,7 @@ | |||
2640 | 12 | add_subdirectory(utils) | 6 | add_subdirectory(utils) |
2641 | 13 | 7 | ||
2642 | 14 | set(unit_test_dirs | 8 | set(unit_test_dirs |
2643 | 9 | registry | ||
2644 | 15 | local-client | 10 | local-client |
2645 | 16 | remote-client | 11 | remote-client |
2646 | 17 | remote-client-v1 | 12 | remote-client-v1 |
2647 | 18 | 13 | ||
2648 | === modified file 'tests/copyright/check_copyright.sh' | |||
2649 | --- tests/copyright/check_copyright.sh 2016-11-04 10:52:10 +0000 | |||
2650 | +++ tests/copyright/check_copyright.sh 2016-12-12 02:53:43 +0000 | |||
2651 | @@ -22,6 +22,8 @@ | |||
2652 | 22 | # Check that we have acceptable license information in our source files. | 22 | # Check that we have acceptable license information in our source files. |
2653 | 23 | # | 23 | # |
2654 | 24 | 24 | ||
2655 | 25 | set -eu | ||
2656 | 26 | |||
2657 | 25 | usage() | 27 | usage() |
2658 | 26 | { | 28 | { |
2659 | 27 | echo "usage: check_copyright dir [ignore_dir]" >&2 | 29 | echo "usage: check_copyright dir [ignore_dir]" >&2 |
2660 | @@ -31,6 +33,9 @@ | |||
2661 | 31 | [ $# -lt 1 ] && usage | 33 | [ $# -lt 1 ] && usage |
2662 | 32 | [ $# -gt 2 ] && usage | 34 | [ $# -gt 2 ] && usage |
2663 | 33 | 35 | ||
2664 | 36 | source_dir="$1" | ||
2665 | 37 | ignore_dir="${2:-}" | ||
2666 | 38 | |||
2667 | 34 | ignore_pat="\\.sci$|\\.swp$|\\.bzr|debian|qmldir|HACKING|ubsan-suppress|valgrind-suppress|\\.txt$|\\.xml$|\\.in$|\\.dox$|\\.yaml$" | 39 | ignore_pat="\\.sci$|\\.swp$|\\.bzr|debian|qmldir|HACKING|ubsan-suppress|valgrind-suppress|\\.txt$|\\.xml$|\\.in$|\\.dox$|\\.yaml$" |
2668 | 35 | 40 | ||
2669 | 36 | # | 41 | # |
2670 | @@ -39,15 +44,16 @@ | |||
2671 | 39 | # the output with grep -F, so we don't get false positives from licensecheck. | 44 | # the output with grep -F, so we don't get false positives from licensecheck. |
2672 | 40 | # | 45 | # |
2673 | 41 | 46 | ||
2679 | 42 | [ $# -eq 2 ] && ignore_dir="$2" | 47 | licensecheck -i "$ignore_pat" -r "$source_dir" > licensecheck.log |
2680 | 43 | 48 | if [ -n "$ignore_dir" ]; then | |
2681 | 44 | if [ -n "$ignore_dir" ] | 49 | cat licensecheck.log | grep -v -F "$ignore_dir" | grep "No copyright" > filtered.log || : |
2677 | 45 | then | ||
2678 | 46 | licensecheck -i "$ignore_pat" -r "$1" | grep -F "$ignore_dir" -v | grep 'No copyright' | ||
2682 | 47 | else | 50 | else |
2684 | 48 | licensecheck -i "$ignore_pat" -r "$1" | grep 'No copyright' | 51 | cat licensecheck.log | grep "No copyright" > filtered.log || : |
2685 | 49 | fi | 52 | fi |
2686 | 50 | 53 | ||
2688 | 51 | [ $? -eq 0 ] && exit 1 | 54 | if [ -s filtered.log ]; then |
2689 | 55 | cat filtered.log | ||
2690 | 56 | exit 1 | ||
2691 | 57 | fi | ||
2692 | 52 | 58 | ||
2693 | 53 | exit 0 | 59 | exit 0 |
2694 | 54 | 60 | ||
2695 | === modified file 'tests/headers/CMakeLists.txt' | |||
2696 | --- tests/headers/CMakeLists.txt 2016-09-08 08:33:59 +0000 | |||
2697 | +++ tests/headers/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
2698 | @@ -41,14 +41,14 @@ | |||
2699 | 41 | add_test(stand-alone-${location}-headers | 41 | add_test(stand-alone-${location}-headers |
2700 | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/compile_headers.py | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/compile_headers.py |
2701 | 43 | ${extra_defines} | 43 | ${extra_defines} |
2703 | 44 | ${public_inc_dir} ${CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER_ARG1} -fPIC -fsyntax-only -I${root_inc_dir} -I${public_inc_dir} ${other_inc_dirs} ${CMAKE_CXX_FLAGS} ${extra_inc_dirs}") | 44 | ${public_inc_dir} ${CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER_ARG1} -fPIC -I${root_inc_dir} -I${public_inc_dir} ${other_inc_dirs} ${CMAKE_CXX_FLAGS} ${extra_inc_dirs}") |
2704 | 45 | 45 | ||
2705 | 46 | # Test that each internal header compiles stand-alone. | 46 | # Test that each internal header compiles stand-alone. |
2706 | 47 | if (IS_DIRECTORY ${internal_inc_dir}) | 47 | if (IS_DIRECTORY ${internal_inc_dir}) |
2707 | 48 | add_test(stand-alone-${location}-internal-headers | 48 | add_test(stand-alone-${location}-internal-headers |
2708 | 49 | ${CMAKE_CURRENT_SOURCE_DIR}/compile_headers.py | 49 | ${CMAKE_CURRENT_SOURCE_DIR}/compile_headers.py |
2709 | 50 | ${extra_defines} | 50 | ${extra_defines} |
2711 | 51 | ${internal_inc_dir} ${CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER_ARG1} -fPIC -fsyntax-only -I${root_inc_dir} -I${internal_inc_dir} ${other_inc_dirs} ${CMAKE_CXX_FLAGS} ${extra_inc_dirs}") | 51 | ${internal_inc_dir} ${CMAKE_CXX_COMPILER} "${CMAKE_CXX_COMPILER_ARG1} -fPIC -I${root_inc_dir} -I${internal_inc_dir} ${other_inc_dirs} ${CMAKE_CXX_FLAGS} ${extra_inc_dirs}") |
2712 | 52 | endif() | 52 | endif() |
2713 | 53 | 53 | ||
2714 | 54 | if (NOT ${public_inc_dir} MATCHES "/internal/") | 54 | if (NOT ${public_inc_dir} MATCHES "/internal/") |
2715 | 55 | 55 | ||
2716 | === modified file 'tests/headers/compile_headers.py' | |||
2717 | --- tests/headers/compile_headers.py 2016-08-22 04:35:33 +0000 | |||
2718 | +++ tests/headers/compile_headers.py 2016-12-12 02:53:43 +0000 | |||
2719 | @@ -52,7 +52,6 @@ | |||
2720 | 52 | import shlex | 52 | import shlex |
2721 | 53 | import subprocess | 53 | import subprocess |
2722 | 54 | import sys | 54 | import sys |
2723 | 55 | import tempfile | ||
2724 | 56 | import concurrent.futures, multiprocessing | 55 | import concurrent.futures, multiprocessing |
2725 | 57 | 56 | ||
2726 | 58 | # | 57 | # |
2727 | @@ -74,16 +73,20 @@ | |||
2728 | 74 | # | 73 | # |
2729 | 75 | def run_compiler(hdr, compiler, copts, define, verbose, hdr_dir): | 74 | def run_compiler(hdr, compiler, copts, define, verbose, hdr_dir): |
2730 | 76 | try: | 75 | try: |
2732 | 77 | src = tempfile.NamedTemporaryFile(suffix='.cpp', dir='.') | 76 | compile_dir = "./.header_tests" |
2733 | 77 | os.makedirs(compile_dir, exist_ok=True) | ||
2734 | 78 | src_name = os.path.join(compile_dir, hdr) + ".cpp" | ||
2735 | 79 | |||
2736 | 80 | if not os.path.exists(src_name): | ||
2737 | 81 | src_fd = os.open(src_name, os.O_WRONLY | os.O_CREAT) | ||
2738 | 82 | src = os.fdopen(src_fd, 'w') | ||
2739 | 83 | src.write("#include <" + hdr + ">" + "\n") | ||
2740 | 84 | src.write("#include <" + hdr + ">" + "\n") # To test that double-inclusion is safe | ||
2741 | 78 | 85 | ||
2742 | 79 | # Add any extra defines to the command line. | 86 | # Add any extra defines to the command line. |
2743 | 80 | for flag in define: | 87 | for flag in define: |
2744 | 81 | copts = "-D" + flag + " " + copts | 88 | copts = "-D" + flag + " " + copts |
2745 | 82 | 89 | ||
2746 | 83 | src.write(bytes("#include <" + hdr + ">" + "\n", 'UTF-8')) | ||
2747 | 84 | src.flush() # Need this to make the file visible | ||
2748 | 85 | src_name = os.path.join('.', src.name) | ||
2749 | 86 | |||
2750 | 87 | if verbose: | 90 | if verbose: |
2751 | 88 | print(compiler + " -c " + src_name + " " + copts) | 91 | print(compiler + " -c " + src_name + " " + copts) |
2752 | 89 | 92 | ||
2753 | @@ -91,13 +94,13 @@ | |||
2754 | 91 | if status != 0: | 94 | if status != 0: |
2755 | 92 | message("cannot compile \"" + hdr + "\"") # Yes, write to stdout because this is expected output | 95 | message("cannot compile \"" + hdr + "\"") # Yes, write to stdout because this is expected output |
2756 | 93 | 96 | ||
2758 | 94 | obj = os.path.splitext(src_name)[0] + ".o" | 97 | obj = hdr + ".o" |
2759 | 95 | try: | 98 | try: |
2760 | 96 | os.unlink(obj) | 99 | os.unlink(obj) |
2761 | 97 | except: | 100 | except: |
2762 | 98 | pass | 101 | pass |
2763 | 99 | 102 | ||
2765 | 100 | gcov = os.path.splitext(src_name)[0] + ".gcno" | 103 | gcov = hdr + ".gcno" |
2766 | 101 | try: | 104 | try: |
2767 | 102 | os.unlink(gcov) | 105 | os.unlink(gcov) |
2768 | 103 | except: | 106 | except: |
2769 | 104 | 107 | ||
2770 | === modified file 'tests/local-client/local-client_test.cpp' | |||
2771 | --- tests/local-client/local-client_test.cpp 2016-08-26 04:45:56 +0000 | |||
2772 | +++ tests/local-client/local-client_test.cpp 2016-12-12 02:53:43 +0000 | |||
2773 | @@ -21,7 +21,11 @@ | |||
2774 | 21 | #include <unity/storage/qt/client/internal/local_client/boost_filesystem.h> | 21 | #include <unity/storage/qt/client/internal/local_client/boost_filesystem.h> |
2775 | 22 | #include <unity/storage/qt/client/internal/local_client/tmpfile_prefix.h> | 22 | #include <unity/storage/qt/client/internal/local_client/tmpfile_prefix.h> |
2776 | 23 | 23 | ||
2777 | 24 | #pragma GCC diagnostic push | ||
2778 | 25 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
2779 | 24 | #include <gtest/gtest.h> | 26 | #include <gtest/gtest.h> |
2780 | 27 | #pragma GCC diagnostic pop | ||
2781 | 28 | |||
2782 | 25 | #include <QCoreApplication> | 29 | #include <QCoreApplication> |
2783 | 26 | #include <QFile> | 30 | #include <QFile> |
2784 | 27 | #include <QFutureWatcher> | 31 | #include <QFutureWatcher> |
2785 | 28 | 32 | ||
2786 | === modified file 'tests/provider-AccountData/AccountData_test.cpp' | |||
2787 | --- tests/provider-AccountData/AccountData_test.cpp 2016-09-28 11:58:35 +0000 | |||
2788 | +++ tests/provider-AccountData/AccountData_test.cpp 2016-12-12 02:53:43 +0000 | |||
2789 | @@ -22,7 +22,11 @@ | |||
2790 | 22 | 22 | ||
2791 | 23 | #include <utils/DBusEnvironment.h> | 23 | #include <utils/DBusEnvironment.h> |
2792 | 24 | 24 | ||
2793 | 25 | #pragma GCC diagnostic push | ||
2794 | 26 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
2795 | 25 | #include <gtest/gtest.h> | 27 | #include <gtest/gtest.h> |
2796 | 28 | #pragma GCC diagnostic pop | ||
2797 | 29 | |||
2798 | 26 | #include <OnlineAccounts/Account> | 30 | #include <OnlineAccounts/Account> |
2799 | 27 | #include <OnlineAccounts/Manager> | 31 | #include <OnlineAccounts/Manager> |
2800 | 28 | #include <QCoreApplication> | 32 | #include <QCoreApplication> |
2801 | 29 | 33 | ||
2802 | === modified file 'tests/provider-DBusPeerCache/DBusPeerCache_test.cpp' | |||
2803 | --- tests/provider-DBusPeerCache/DBusPeerCache_test.cpp 2016-07-28 03:10:57 +0000 | |||
2804 | +++ tests/provider-DBusPeerCache/DBusPeerCache_test.cpp 2016-12-12 02:53:43 +0000 | |||
2805 | @@ -20,7 +20,11 @@ | |||
2806 | 20 | 20 | ||
2807 | 21 | #include <utils/DBusEnvironment.h> | 21 | #include <utils/DBusEnvironment.h> |
2808 | 22 | 22 | ||
2809 | 23 | #pragma GCC diagnostic push | ||
2810 | 24 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
2811 | 23 | #include <gtest/gtest.h> | 25 | #include <gtest/gtest.h> |
2812 | 26 | #pragma GCC diagnostic pop | ||
2813 | 27 | |||
2814 | 24 | #include <OnlineAccounts/Account> | 28 | #include <OnlineAccounts/Account> |
2815 | 25 | #include <OnlineAccounts/Manager> | 29 | #include <OnlineAccounts/Manager> |
2816 | 26 | #include <QCoreApplication> | 30 | #include <QCoreApplication> |
2817 | 27 | 31 | ||
2818 | === modified file 'tests/provider-ProviderInterface/TestProvider.cpp' | |||
2819 | --- tests/provider-ProviderInterface/TestProvider.cpp 2016-11-03 02:43:43 +0000 | |||
2820 | +++ tests/provider-ProviderInterface/TestProvider.cpp 2016-12-12 02:53:43 +0000 | |||
2821 | @@ -87,7 +87,7 @@ | |||
2822 | 87 | boost::future<Item> TestUploadJob::finish() | 87 | boost::future<Item> TestUploadJob::finish() |
2823 | 88 | { | 88 | { |
2824 | 89 | boost::promise<Item> p; | 89 | boost::promise<Item> p; |
2826 | 90 | printf("TestUploadJob::finish(): %d read of expected %d\n", (int) bytes_read_, (int) size_); | 90 | printf("TestUploadJob::finish(): %d read of expected %d\n", int(bytes_read_), int(size_)); |
2827 | 91 | notifier_.setEnabled(false); | 91 | notifier_.setEnabled(false); |
2828 | 92 | drain(); | 92 | drain(); |
2829 | 93 | if (bytes_read_ == size_) | 93 | if (bytes_read_ == size_) |
2830 | @@ -139,7 +139,7 @@ | |||
2831 | 139 | 139 | ||
2832 | 140 | void TestUploadJob::read_some() | 140 | void TestUploadJob::read_some() |
2833 | 141 | { | 141 | { |
2835 | 142 | printf("TestUploadJob::read_some(): %d read of expected %d\n", (int) bytes_read_, (int) size_); | 142 | printf("TestUploadJob::read_some(): %d read of expected %d\n", int(bytes_read_), int(size_)); |
2836 | 143 | 143 | ||
2837 | 144 | char buf[5]; | 144 | char buf[5]; |
2838 | 145 | ssize_t n_read = read(read_socket(), buf, sizeof(buf)); | 145 | ssize_t n_read = read(read_socket(), buf, sizeof(buf)); |
2839 | @@ -248,7 +248,7 @@ | |||
2840 | 248 | boost::future<void> TestDownloadJob::finish() | 248 | boost::future<void> TestDownloadJob::finish() |
2841 | 249 | { | 249 | { |
2842 | 250 | boost::promise<void> p; | 250 | boost::promise<void> p; |
2844 | 251 | if (bytes_written_ < (ssize_t)data_.size()) | 251 | if (bytes_written_ < ssize_t(data_.size())) |
2845 | 252 | { | 252 | { |
2846 | 253 | p.set_exception(LogicException("Not all data read")); | 253 | p.set_exception(LogicException("Not all data read")); |
2847 | 254 | } | 254 | } |
2848 | @@ -261,14 +261,14 @@ | |||
2849 | 261 | 261 | ||
2850 | 262 | void TestDownloadJob::write_some() | 262 | void TestDownloadJob::write_some() |
2851 | 263 | { | 263 | { |
2853 | 264 | if (bytes_written_ >= (ssize_t)data_.size()) { | 264 | if (bytes_written_ >= ssize_t(data_.size())) { |
2854 | 265 | report_complete(); | 265 | report_complete(); |
2855 | 266 | timer_.stop(); | 266 | timer_.stop(); |
2856 | 267 | return; | 267 | return; |
2857 | 268 | } | 268 | } |
2858 | 269 | 269 | ||
2859 | 270 | ssize_t n_written = write(write_socket(), data_.data() + bytes_written_, | 270 | ssize_t n_written = write(write_socket(), data_.data() + bytes_written_, |
2861 | 271 | min(data_.size() - bytes_written_, (size_t)2)); | 271 | min(data_.size() - bytes_written_, size_t(2))); |
2862 | 272 | if (n_written < 0) | 272 | if (n_written < 0) |
2863 | 273 | { | 273 | { |
2864 | 274 | int error_code = errno; | 274 | int error_code = errno; |
2865 | 275 | 275 | ||
2866 | === added directory 'tests/registry' | |||
2867 | === added file 'tests/registry/CMakeLists.txt' | |||
2868 | --- tests/registry/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2869 | +++ tests/registry/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
2870 | @@ -0,0 +1,20 @@ | |||
2871 | 1 | add_executable(registry_test registry_test.cpp) | ||
2872 | 2 | #set_target_properties(remote-client_test PROPERTIES AUTOMOC TRUE) | ||
2873 | 3 | |||
2874 | 4 | #add_definitions(-DTEST_DIR="${CMAKE_CURRENT_BINARY_DIR}" -DBOOST_THREAD_VERSION=4) | ||
2875 | 5 | #include_directories(${GLIB_DEPS_INCLUDE_DIRS}) | ||
2876 | 6 | |||
2877 | 7 | #target_link_libraries(remote-client_test | ||
2878 | 8 | # storage-framework-provider | ||
2879 | 9 | # storage-framework-qt-client-v2 | ||
2880 | 10 | # Qt5::Network | ||
2881 | 11 | # Qt5::Test | ||
2882 | 12 | # ${Boost_LIBRARIES} | ||
2883 | 13 | # ${GLIB_DEPS_LIBRARIES} | ||
2884 | 14 | # testutils | ||
2885 | 15 | # gtest | ||
2886 | 16 | #) | ||
2887 | 17 | add_test(registry registry_test) | ||
2888 | 18 | #add_dependencies(remote-client_test qt-client-all-headers provider-test) | ||
2889 | 19 | |||
2890 | 20 | #set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} PARENT_SCOPE) | ||
2891 | 0 | 21 | ||
2892 | === added file 'tests/registry/registry_test.cpp' | |||
2893 | --- tests/registry/registry_test.cpp 1970-01-01 00:00:00 +0000 | |||
2894 | +++ tests/registry/registry_test.cpp 2016-12-12 02:53:43 +0000 | |||
2895 | @@ -0,0 +1,27 @@ | |||
2896 | 1 | /* | ||
2897 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
2898 | 3 | * | ||
2899 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2900 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2901 | 6 | * published by the Free Software Foundation. | ||
2902 | 7 | * | ||
2903 | 8 | * This program is distributed in the hope that it will be useful, | ||
2904 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2905 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2906 | 11 | * GNU Lesser General Public License for more details. | ||
2907 | 12 | * | ||
2908 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2909 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2910 | 15 | * | ||
2911 | 16 | * Authors: Michi Henning <michi.henning@canonical.com> | ||
2912 | 17 | */ | ||
2913 | 18 | |||
2914 | 19 | int main(int argc, char** argv) | ||
2915 | 20 | { | ||
2916 | 21 | #if 0 | ||
2917 | 22 | QCoreApplication app(argc, argv); | ||
2918 | 23 | |||
2919 | 24 | ::testing::InitGoogleTest(&argc, argv); | ||
2920 | 25 | return RUN_ALL_TESTS(); | ||
2921 | 26 | #endif | ||
2922 | 27 | } | ||
2923 | 0 | 28 | ||
2924 | === modified file 'tests/remote-client-v1/remote-client-v1_test.cpp' | |||
2925 | --- tests/remote-client-v1/remote-client-v1_test.cpp 2016-09-26 02:37:03 +0000 | |||
2926 | +++ tests/remote-client-v1/remote-client-v1_test.cpp 2016-12-12 02:53:43 +0000 | |||
2927 | @@ -56,7 +56,7 @@ | |||
2928 | 56 | void SetUp() override | 56 | void SetUp() override |
2929 | 57 | { | 57 | { |
2930 | 58 | dbus_.reset(new DBusEnvironment); | 58 | dbus_.reset(new DBusEnvironment); |
2932 | 59 | dbus_->add_demo_provider("google-drive-scope"); | 59 | dbus_->add_demo_provider("storage-provider-test"); |
2933 | 60 | dbus_->start_services(); | 60 | dbus_->start_services(); |
2934 | 61 | } | 61 | } |
2935 | 62 | 62 | ||
2936 | @@ -150,7 +150,7 @@ | |||
2937 | 150 | } | 150 | } |
2938 | 151 | for (auto acc : accounts) | 151 | for (auto acc : accounts) |
2939 | 152 | { | 152 | { |
2941 | 153 | if (acc->owner_id() == "google-drive-scope") | 153 | if (acc->owner_id() == "storage-provider-test") |
2942 | 154 | { | 154 | { |
2943 | 155 | return acc; | 155 | return acc; |
2944 | 156 | } | 156 | } |
2945 | @@ -198,8 +198,8 @@ | |||
2946 | 198 | auto acc = get_account(runtime); | 198 | auto acc = get_account(runtime); |
2947 | 199 | EXPECT_EQ(runtime, acc->runtime()); | 199 | EXPECT_EQ(runtime, acc->runtime()); |
2948 | 200 | EXPECT_EQ("", acc->owner()); | 200 | EXPECT_EQ("", acc->owner()); |
2951 | 201 | EXPECT_EQ("google-drive-scope", acc->owner_id()); | 201 | EXPECT_EQ("storage-provider-test", acc->owner_id()); |
2952 | 202 | EXPECT_EQ("Fake google account", acc->description()); | 202 | EXPECT_EQ("Fake test account", acc->description()); |
2953 | 203 | } | 203 | } |
2954 | 204 | 204 | ||
2955 | 205 | TEST_F(RuntimeTest, roots) | 205 | TEST_F(RuntimeTest, roots) |
2956 | 206 | 206 | ||
2957 | === modified file 'tests/remote-client/CMakeLists.txt' | |||
2958 | --- tests/remote-client/CMakeLists.txt 2016-09-08 08:33:59 +0000 | |||
2959 | +++ tests/remote-client/CMakeLists.txt 2016-12-12 02:53:43 +0000 | |||
2960 | @@ -15,6 +15,6 @@ | |||
2961 | 15 | gtest | 15 | gtest |
2962 | 16 | ) | 16 | ) |
2963 | 17 | add_test(remote-client remote-client_test) | 17 | add_test(remote-client remote-client_test) |
2965 | 18 | add_dependencies(remote-client_test qt-client-all-headers provider-test) | 18 | add_dependencies(remote-client_test qt-client-all-headers storage-framework-registry) |
2966 | 19 | 19 | ||
2967 | 20 | set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} PARENT_SCOPE) | 20 | set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} PARENT_SCOPE) |
2968 | 21 | 21 | ||
2969 | === modified file 'tests/remote-client/remote-client_test.cpp' | |||
2970 | --- tests/remote-client/remote-client_test.cpp 2016-11-04 07:33:07 +0000 | |||
2971 | +++ tests/remote-client/remote-client_test.cpp 2016-12-12 02:53:43 +0000 | |||
2972 | @@ -22,7 +22,11 @@ | |||
2973 | 22 | #include <utils/gtest_printer.h> | 22 | #include <utils/gtest_printer.h> |
2974 | 23 | #include <utils/ProviderFixture.h> | 23 | #include <utils/ProviderFixture.h> |
2975 | 24 | 24 | ||
2976 | 25 | #pragma GCC diagnostic push | ||
2977 | 26 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
2978 | 25 | #include <gtest/gtest.h> | 27 | #include <gtest/gtest.h> |
2979 | 28 | #pragma GCC diagnostic pop | ||
2980 | 29 | |||
2981 | 26 | #include <QSignalSpy> | 30 | #include <QSignalSpy> |
2982 | 27 | 31 | ||
2983 | 28 | #include <unordered_set> | 32 | #include <unordered_set> |
2984 | @@ -121,77 +125,77 @@ | |||
2985 | 121 | 125 | ||
2986 | 122 | { | 126 | { |
2987 | 123 | auto acc = runtime_->make_test_account(service_connection_->baseService(), object_path(), | 127 | auto acc = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
2989 | 124 | "id", "sid", "displayName"); | 128 | 99, "sid", "name"); |
2990 | 125 | EXPECT_TRUE(acc.isValid()); | 129 | EXPECT_TRUE(acc.isValid()); |
2991 | 126 | EXPECT_EQ(service_connection_->baseService(), acc.busName()); | 130 | EXPECT_EQ(service_connection_->baseService(), acc.busName()); |
2992 | 127 | EXPECT_EQ(object_path(), acc.objectPath()); | 131 | EXPECT_EQ(object_path(), acc.objectPath()); |
2994 | 128 | EXPECT_EQ("displayName", acc.displayName()); | 132 | EXPECT_EQ("name", acc.displayName()); |
2995 | 129 | 133 | ||
2996 | 130 | // Copy constructor | 134 | // Copy constructor |
2997 | 131 | Account a2(acc); | 135 | Account a2(acc); |
2998 | 132 | EXPECT_TRUE(a2.isValid()); | 136 | EXPECT_TRUE(a2.isValid()); |
2999 | 133 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); | 137 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); |
3000 | 134 | EXPECT_EQ(object_path(), a2.objectPath()); | 138 | EXPECT_EQ(object_path(), a2.objectPath()); |
3002 | 135 | EXPECT_EQ("displayName", a2.displayName()); | 139 | EXPECT_EQ("name", a2.displayName()); |
3003 | 136 | 140 | ||
3004 | 137 | // Move constructor | 141 | // Move constructor |
3005 | 138 | Account a3(move(a2)); | 142 | Account a3(move(a2)); |
3006 | 139 | EXPECT_TRUE(a3.isValid()); | 143 | EXPECT_TRUE(a3.isValid()); |
3007 | 140 | EXPECT_EQ(service_connection_->baseService(), a3.busName()); | 144 | EXPECT_EQ(service_connection_->baseService(), a3.busName()); |
3008 | 141 | EXPECT_EQ(object_path(), a3.objectPath()); | 145 | EXPECT_EQ(object_path(), a3.objectPath()); |
3010 | 142 | EXPECT_EQ("displayName", a3.displayName()); | 146 | EXPECT_EQ("name", a3.displayName()); |
3011 | 143 | 147 | ||
3012 | 144 | // Moved-from object must be invalid | 148 | // Moved-from object must be invalid |
3013 | 145 | EXPECT_FALSE(a2.isValid()); | 149 | EXPECT_FALSE(a2.isValid()); |
3014 | 146 | 150 | ||
3015 | 147 | // Moved-from object must be assignable | 151 | // Moved-from object must be assignable |
3016 | 148 | auto a4 = runtime_->make_test_account(service_connection_->baseService(), object_path(), | 152 | auto a4 = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
3018 | 149 | "id4", "sid4", "displayName4"); | 153 | 99, "sid4", "name4"); |
3019 | 150 | a2 = a4; | 154 | a2 = a4; |
3020 | 151 | EXPECT_TRUE(a2.isValid()); | 155 | EXPECT_TRUE(a2.isValid()); |
3021 | 152 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); | 156 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); |
3022 | 153 | EXPECT_EQ(object_path(), a2.objectPath()); | 157 | EXPECT_EQ(object_path(), a2.objectPath()); |
3024 | 154 | EXPECT_EQ("displayName4", a2.displayName()); | 158 | EXPECT_EQ("name4", a2.displayName()); |
3025 | 155 | } | 159 | } |
3026 | 156 | 160 | ||
3027 | 157 | { | 161 | { |
3030 | 158 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "id", "sid", "dn"); | 162 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 99, "sid", "dn"); |
3031 | 159 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "id2", "sid2", "dn2"); | 163 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 100, "sid2", "n2"); |
3032 | 160 | 164 | ||
3033 | 161 | // Copy assignment | 165 | // Copy assignment |
3034 | 162 | a1 = a2; | 166 | a1 = a2; |
3035 | 163 | EXPECT_TRUE(a2.isValid()); | 167 | EXPECT_TRUE(a2.isValid()); |
3036 | 164 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); | 168 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); |
3037 | 165 | EXPECT_EQ(object_path(), a1.objectPath()); | 169 | EXPECT_EQ(object_path(), a1.objectPath()); |
3039 | 166 | EXPECT_EQ("dn2", a1.displayName()); | 170 | EXPECT_EQ("n2", a1.displayName()); |
3040 | 167 | 171 | ||
3041 | 168 | // Self-assignment | 172 | // Self-assignment |
3042 | 169 | a2 = a2; | 173 | a2 = a2; |
3043 | 170 | EXPECT_TRUE(a2.isValid()); | 174 | EXPECT_TRUE(a2.isValid()); |
3044 | 171 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); | 175 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); |
3045 | 172 | EXPECT_EQ(object_path(), a1.objectPath()); | 176 | EXPECT_EQ(object_path(), a1.objectPath()); |
3047 | 173 | EXPECT_EQ("dn2", a1.displayName()); | 177 | EXPECT_EQ("n2", a1.displayName()); |
3048 | 174 | 178 | ||
3049 | 175 | // Move assignment | 179 | // Move assignment |
3050 | 176 | auto a3 = runtime_->make_test_account(service_connection_->baseService(), object_path(), | 180 | auto a3 = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
3052 | 177 | "id3", "sid3", "dn3"); | 181 | 101, "sid3", "n3"); |
3053 | 178 | a1 = move(a3); | 182 | a1 = move(a3); |
3054 | 179 | EXPECT_TRUE(a1.isValid()); | 183 | EXPECT_TRUE(a1.isValid()); |
3055 | 180 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); | 184 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); |
3056 | 181 | EXPECT_EQ(object_path(), a1.objectPath()); | 185 | EXPECT_EQ(object_path(), a1.objectPath()); |
3058 | 182 | EXPECT_EQ("dn3", a1.displayName()); | 186 | EXPECT_EQ("n3", a1.displayName()); |
3059 | 183 | 187 | ||
3060 | 184 | // Moved-from object must be invalid | 188 | // Moved-from object must be invalid |
3061 | 185 | EXPECT_FALSE(a3.isValid()); | 189 | EXPECT_FALSE(a3.isValid()); |
3062 | 186 | 190 | ||
3063 | 187 | // Moved-from object must be assignable | 191 | // Moved-from object must be assignable |
3064 | 188 | auto a4 = runtime_->make_test_account(service_connection_->baseService(), object_path(), | 192 | auto a4 = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
3066 | 189 | "id4", "sid4", "dn4"); | 193 | 102, "sid4", "n4"); |
3067 | 190 | a2 = a4; | 194 | a2 = a4; |
3068 | 191 | EXPECT_TRUE(a2.isValid()); | 195 | EXPECT_TRUE(a2.isValid()); |
3069 | 192 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); | 196 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); |
3070 | 193 | EXPECT_EQ(object_path(), a2.objectPath()); | 197 | EXPECT_EQ(object_path(), a2.objectPath()); |
3072 | 194 | EXPECT_EQ("dn4", a2.displayName()); | 198 | EXPECT_EQ("n4", a2.displayName()); |
3073 | 195 | } | 199 | } |
3074 | 196 | } | 200 | } |
3075 | 197 | 201 | ||
3076 | @@ -231,8 +235,8 @@ | |||
3077 | 231 | 235 | ||
3078 | 232 | { | 236 | { |
3079 | 233 | // a1 < a2 for ID | 237 | // a1 < a2 for ID |
3082 | 234 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "x", "x"); | 238 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "x", "x"); |
3083 | 235 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "b", "x", "x"); | 239 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 2, "x", "x"); |
3084 | 236 | 240 | ||
3085 | 237 | EXPECT_FALSE(a1 == a2); | 241 | EXPECT_FALSE(a1 == a2); |
3086 | 238 | EXPECT_TRUE(a1 != a2); | 242 | EXPECT_TRUE(a1 != a2); |
3087 | @@ -252,8 +256,8 @@ | |||
3088 | 252 | 256 | ||
3089 | 253 | { | 257 | { |
3090 | 254 | // a1 < a2 for service ID | 258 | // a1 < a2 for service ID |
3093 | 255 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "x"); | 259 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "x"); |
3094 | 256 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "b", "x"); | 260 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "b", "x"); |
3095 | 257 | 261 | ||
3096 | 258 | EXPECT_FALSE(a1 == a2); | 262 | EXPECT_FALSE(a1 == a2); |
3097 | 259 | EXPECT_TRUE(a1 != a2); | 263 | EXPECT_TRUE(a1 != a2); |
3098 | @@ -273,8 +277,8 @@ | |||
3099 | 273 | 277 | ||
3100 | 274 | { | 278 | { |
3101 | 275 | // a1 < a2 for display name | 279 | // a1 < a2 for display name |
3104 | 276 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); | 280 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
3105 | 277 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "b"); | 281 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "b"); |
3106 | 278 | 282 | ||
3107 | 279 | EXPECT_FALSE(a1 == a2); | 283 | EXPECT_FALSE(a1 == a2); |
3108 | 280 | EXPECT_TRUE(a1 != a2); | 284 | EXPECT_TRUE(a1 != a2); |
3109 | @@ -294,8 +298,8 @@ | |||
3110 | 294 | 298 | ||
3111 | 295 | { | 299 | { |
3112 | 296 | // a1 == a2 | 300 | // a1 == a2 |
3115 | 297 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); | 301 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
3116 | 298 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); | 302 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
3117 | 299 | 303 | ||
3118 | 300 | EXPECT_TRUE(a1 == a2); | 304 | EXPECT_TRUE(a1 == a2); |
3119 | 301 | EXPECT_FALSE(a1 != a2); | 305 | EXPECT_FALSE(a1 != a2); |
3120 | @@ -319,14 +323,14 @@ | |||
3121 | 319 | unordered_set<Account>(); // Just to show that this works. | 323 | unordered_set<Account>(); // Just to show that this works. |
3122 | 320 | 324 | ||
3123 | 321 | Account a1; | 325 | Account a1; |
3127 | 322 | EXPECT_EQ(0, hash<Account>()(a1)); | 326 | EXPECT_EQ(0u, hash<Account>()(a1)); |
3128 | 323 | EXPECT_EQ(0, a1.hash()); | 327 | EXPECT_EQ(0u, a1.hash()); |
3129 | 324 | EXPECT_EQ(0, qHash(a1)); | 328 | EXPECT_EQ(0u, qHash(a1)); |
3130 | 325 | 329 | ||
3132 | 326 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); | 330 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
3133 | 327 | // Due to different return types (size_t vs uint), hash() and qHash() do not return the same value. | 331 | // Due to different return types (size_t vs uint), hash() and qHash() do not return the same value. |
3136 | 328 | EXPECT_NE(0, a2.hash()); | 332 | EXPECT_NE(0u, a2.hash()); |
3137 | 329 | EXPECT_NE(0, qHash(a2)); | 333 | EXPECT_NE(0u, qHash(a2)); |
3138 | 330 | } | 334 | } |
3139 | 331 | 335 | ||
3140 | 332 | TEST_F(AccountTest, accounts) | 336 | TEST_F(AccountTest, accounts) |
3141 | @@ -347,17 +351,29 @@ | |||
3142 | 347 | EXPECT_EQ(AccountsJob::Status::Finished, j->status()); | 351 | EXPECT_EQ(AccountsJob::Status::Finished, j->status()); |
3143 | 348 | EXPECT_EQ(StorageError::Type::NoError, j->error().type()); | 352 | EXPECT_EQ(StorageError::Type::NoError, j->error().type()); |
3144 | 349 | 353 | ||
3145 | 350 | EXPECT_TRUE(runtime_->connection().isConnected()); // Just for coverage. | ||
3146 | 351 | |||
3147 | 352 | auto accounts = j->accounts(); | 354 | auto accounts = j->accounts(); |
3148 | 355 | EXPECT_GT(accounts.size(), 0); | ||
3149 | 353 | 356 | ||
3153 | 354 | // We don't check the contents of accounts here because we are using the real online accounts manager | 357 | // The fake online accounts service includes a "com.canonical.StorageFramework.Provider.ProviderTest" account. |
3154 | 355 | // in this test. This means that the number and kind of accounts that are returned depends | 358 | bool found = false; |
3155 | 356 | // on what provider accounts the test user has configured. | 359 | for (auto const& a : accounts) |
3156 | 360 | { | ||
3157 | 361 | qDebug() << a.busName(); | ||
3158 | 362 | if (a.busName() == "com.canonical.StorageFramework.Provider.ProviderTest") | ||
3159 | 363 | { | ||
3160 | 364 | found = true; | ||
3161 | 365 | EXPECT_EQ("Test Provider", a.providerName()); | ||
3162 | 366 | // TODO: add tests for the other account properties. | ||
3163 | 367 | break; | ||
3164 | 368 | } | ||
3165 | 369 | } | ||
3166 | 370 | EXPECT_TRUE(found); | ||
3167 | 357 | } | 371 | } |
3168 | 358 | 372 | ||
3169 | 359 | TEST_F(AccountTest, runtime_destroyed) | 373 | TEST_F(AccountTest, runtime_destroyed) |
3170 | 360 | { | 374 | { |
3171 | 375 | EXPECT_TRUE(runtime_->connection().isConnected()); // Just for coverage. | ||
3172 | 376 | |||
3173 | 361 | EXPECT_EQ(StorageError::Type::NoError, runtime_->shutdown().type()); // Destroy runtime. | 377 | EXPECT_EQ(StorageError::Type::NoError, runtime_->shutdown().type()); // Destroy runtime. |
3174 | 362 | 378 | ||
3175 | 363 | AccountsJob* j = runtime_->accounts(); | 379 | AccountsJob* j = runtime_->accounts(); |
3176 | @@ -504,11 +520,23 @@ | |||
3177 | 504 | QSignalSpy ready_spy(j.get(), &ItemListJob::itemsReady); | 520 | QSignalSpy ready_spy(j.get(), &ItemListJob::itemsReady); |
3178 | 505 | QSignalSpy status_spy(j.get(), &ItemListJob::statusChanged); | 521 | QSignalSpy status_spy(j.get(), &ItemListJob::statusChanged); |
3179 | 506 | status_spy.wait(SIGNAL_WAIT_TIME); | 522 | status_spy.wait(SIGNAL_WAIT_TIME); |
3185 | 507 | auto arg = status_spy.takeFirst(); | 523 | { |
3186 | 508 | 524 | auto arg = status_spy.takeFirst(); | |
3187 | 509 | // Bad metadata is ignored, so status is finished, and itemsReady was never called. | 525 | EXPECT_EQ(ItemListJob::Status::Error, qvariant_cast<ItemListJob::Status>(arg.at(0))); |
3188 | 510 | EXPECT_EQ(ItemListJob::Status::Finished, qvariant_cast<ItemListJob::Status>(arg.at(0))); | 526 | } |
3189 | 511 | EXPECT_EQ(0, status_spy.count()); | 527 | |
3190 | 528 | if (ready_spy.count() != 1) | ||
3191 | 529 | { | ||
3192 | 530 | ready_spy.wait(SIGNAL_WAIT_TIME); | ||
3193 | 531 | } | ||
3194 | 532 | auto arg = ready_spy.takeFirst(); | ||
3195 | 533 | auto items = qvariant_cast<QList<Item>>(arg.at(0)); | ||
3196 | 534 | EXPECT_EQ(0, items.size()); | ||
3197 | 535 | |||
3198 | 536 | EXPECT_EQ(ItemListJob::Status::Error, j->status()); | ||
3199 | 537 | EXPECT_EQ(StorageError::Type::LocalCommsError, j->error().type()); | ||
3200 | 538 | EXPECT_EQ("LocalCommsError: Account::roots(): provider returned non-root item type: 0 (id = root_id)", | ||
3201 | 539 | j->error().errorString()); | ||
3202 | 512 | } | 540 | } |
3203 | 513 | 541 | ||
3204 | 514 | TEST_F(GetTest, basic) | 542 | TEST_F(GetTest, basic) |
3205 | @@ -679,8 +707,9 @@ | |||
3206 | 679 | spy.wait(SIGNAL_WAIT_TIME); | 707 | spy.wait(SIGNAL_WAIT_TIME); |
3207 | 680 | 708 | ||
3208 | 681 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 709 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3211 | 682 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: " | 710 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3212 | 683 | "file or folder must have at least one parent ID", j->error().errorString()); | 711 | "file or folder must have at least one parent ID" |
3213 | 712 | , j->error().errorString()); | ||
3214 | 684 | } | 713 | } |
3215 | 685 | 714 | ||
3216 | 686 | TEST_F(MetadataTest, empty_parent) | 715 | TEST_F(MetadataTest, empty_parent) |
3217 | @@ -693,8 +722,9 @@ | |||
3218 | 693 | spy.wait(SIGNAL_WAIT_TIME); | 722 | spy.wait(SIGNAL_WAIT_TIME); |
3219 | 694 | 723 | ||
3220 | 695 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 724 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3223 | 696 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: " | 725 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3224 | 697 | "parent_id of file or folder cannot be empty", j->error().errorString()); | 726 | "parent_id of file or folder cannot be empty", |
3225 | 727 | j->error().errorString()); | ||
3226 | 698 | } | 728 | } |
3227 | 699 | 729 | ||
3228 | 700 | TEST_F(MetadataTest, root_with_parent) | 730 | TEST_F(MetadataTest, root_with_parent) |
3229 | @@ -707,8 +737,9 @@ | |||
3230 | 707 | spy.wait(SIGNAL_WAIT_TIME); | 737 | spy.wait(SIGNAL_WAIT_TIME); |
3231 | 708 | 738 | ||
3232 | 709 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 739 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3235 | 710 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: " | 740 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = root_id): " |
3236 | 711 | "parent_ids of root must be empty", j->error().errorString()); | 741 | "parent_ids of root must be empty", |
3237 | 742 | j->error().errorString()); | ||
3238 | 712 | } | 743 | } |
3239 | 713 | 744 | ||
3240 | 714 | TEST_F(MetadataTest, empty_name) | 745 | TEST_F(MetadataTest, empty_name) |
3241 | @@ -721,8 +752,9 @@ | |||
3242 | 721 | spy.wait(SIGNAL_WAIT_TIME); | 752 | spy.wait(SIGNAL_WAIT_TIME); |
3243 | 722 | 753 | ||
3244 | 723 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 754 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3247 | 724 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: " | 755 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3248 | 725 | "name cannot be empty", j->error().errorString()); | 756 | "name cannot be empty", |
3249 | 757 | j->error().errorString()); | ||
3250 | 726 | } | 758 | } |
3251 | 727 | 759 | ||
3252 | 728 | TEST_F(MetadataTest, empty_etag) | 760 | TEST_F(MetadataTest, empty_etag) |
3253 | @@ -735,8 +767,9 @@ | |||
3254 | 735 | spy.wait(SIGNAL_WAIT_TIME); | 767 | spy.wait(SIGNAL_WAIT_TIME); |
3255 | 736 | 768 | ||
3256 | 737 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 769 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3259 | 738 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: " | 770 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3260 | 739 | "etag of a file cannot be empty", j->error().errorString()); | 771 | "etag of a file cannot be empty", |
3261 | 772 | j->error().errorString()); | ||
3262 | 740 | } | 773 | } |
3263 | 741 | 774 | ||
3264 | 742 | TEST_F(MetadataTest, unknown_key) | 775 | TEST_F(MetadataTest, unknown_key) |
3265 | @@ -762,8 +795,9 @@ | |||
3266 | 762 | spy.wait(SIGNAL_WAIT_TIME); | 795 | spy.wait(SIGNAL_WAIT_TIME); |
3267 | 763 | 796 | ||
3268 | 764 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 797 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3271 | 765 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: " | 798 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3272 | 766 | "missing key \"size_in_bytes\" in metadata for \"child_id\"", j->error().errorString()); | 799 | "missing key \"size_in_bytes\" in metadata", |
3273 | 800 | j->error().errorString()); | ||
3274 | 767 | } | 801 | } |
3275 | 768 | 802 | ||
3276 | 769 | TEST_F(MetadataTest, wrong_type_for_time) | 803 | TEST_F(MetadataTest, wrong_type_for_time) |
3277 | @@ -776,8 +810,9 @@ | |||
3278 | 776 | spy.wait(SIGNAL_WAIT_TIME); | 810 | spy.wait(SIGNAL_WAIT_TIME); |
3279 | 777 | 811 | ||
3280 | 778 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 812 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3283 | 779 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: last_modified_time: " | 813 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3284 | 780 | "expected value of type QString, but received value of type qlonglong", j->error().errorString()); | 814 | "last_modified_time: expected value of type QString, but received value of type qlonglong", |
3285 | 815 | j->error().errorString()); | ||
3286 | 781 | } | 816 | } |
3287 | 782 | 817 | ||
3288 | 783 | TEST_F(MetadataTest, bad_parse_for_time) | 818 | TEST_F(MetadataTest, bad_parse_for_time) |
3289 | @@ -790,8 +825,9 @@ | |||
3290 | 790 | spy.wait(SIGNAL_WAIT_TIME); | 825 | spy.wait(SIGNAL_WAIT_TIME); |
3291 | 791 | 826 | ||
3292 | 792 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 827 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3295 | 793 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: last_modified_time: " | 828 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3296 | 794 | "value \"xyz\" does not parse as ISO-8601 date", j->error().errorString()); | 829 | "last_modified_time: value \"xyz\" does not parse as ISO-8601 date", |
3297 | 830 | j->error().errorString()); | ||
3298 | 795 | } | 831 | } |
3299 | 796 | 832 | ||
3300 | 797 | TEST_F(MetadataTest, missing_timezone) | 833 | TEST_F(MetadataTest, missing_timezone) |
3301 | @@ -804,8 +840,9 @@ | |||
3302 | 804 | spy.wait(SIGNAL_WAIT_TIME); | 840 | spy.wait(SIGNAL_WAIT_TIME); |
3303 | 805 | 841 | ||
3304 | 806 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 842 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3307 | 807 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: last_modified_time: " | 843 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3308 | 808 | "value \"2007-04-05T14:30\" lacks a time zone specification", j->error().errorString()); | 844 | "last_modified_time: value \"2007-04-05T14:30\" lacks a time zone specification", |
3309 | 845 | j->error().errorString()); | ||
3310 | 809 | } | 846 | } |
3311 | 810 | 847 | ||
3312 | 811 | TEST_F(MetadataTest, wrong_type_for_size) | 848 | TEST_F(MetadataTest, wrong_type_for_size) |
3313 | @@ -818,8 +855,9 @@ | |||
3314 | 818 | spy.wait(SIGNAL_WAIT_TIME); | 855 | spy.wait(SIGNAL_WAIT_TIME); |
3315 | 819 | 856 | ||
3316 | 820 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 857 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3319 | 821 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: size_in_bytes: " | 858 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3320 | 822 | "expected value of type qlonglong, but received value of type QString", j->error().errorString()); | 859 | "size_in_bytes: expected value of type qlonglong, but received value of type QString", |
3321 | 860 | j->error().errorString()); | ||
3322 | 823 | } | 861 | } |
3323 | 824 | 862 | ||
3324 | 825 | TEST_F(MetadataTest, negative_size) | 863 | TEST_F(MetadataTest, negative_size) |
3325 | @@ -832,8 +870,9 @@ | |||
3326 | 832 | spy.wait(SIGNAL_WAIT_TIME); | 870 | spy.wait(SIGNAL_WAIT_TIME); |
3327 | 833 | 871 | ||
3328 | 834 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 872 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3331 | 835 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider: size_in_bytes: " | 873 | EXPECT_EQ("LocalCommsError: Account::get(): received invalid metadata from provider (id = child_id): " |
3332 | 836 | "expected value >= 0, but received -1", j->error().errorString()); | 874 | "size_in_bytes: expected value >= 0, but received -1", |
3333 | 875 | j->error().errorString()); | ||
3334 | 837 | } | 876 | } |
3335 | 838 | 877 | ||
3336 | 839 | TEST_F(DeleteTest, basic) | 878 | TEST_F(DeleteTest, basic) |
3337 | @@ -1121,9 +1160,9 @@ | |||
3338 | 1121 | 1160 | ||
3339 | 1122 | unordered_set<Item>(); // Just to show that this works. | 1161 | unordered_set<Item>(); // Just to show that this works. |
3340 | 1123 | 1162 | ||
3344 | 1124 | EXPECT_EQ(0, hash<Item>()(i1)); | 1163 | EXPECT_EQ(0u, hash<Item>()(i1)); |
3345 | 1125 | EXPECT_EQ(0, i1.hash()); | 1164 | EXPECT_EQ(0u, i1.hash()); |
3346 | 1126 | EXPECT_EQ(0, qHash(i1)); | 1165 | EXPECT_EQ(0u, qHash(i1)); |
3347 | 1127 | } | 1166 | } |
3348 | 1128 | 1167 | ||
3349 | 1129 | { | 1168 | { |
3350 | @@ -1155,15 +1194,15 @@ | |||
3351 | 1155 | EXPECT_FALSE(i2 > i1); | 1194 | EXPECT_FALSE(i2 > i1); |
3352 | 1156 | EXPECT_FALSE(i2 >= i1); | 1195 | EXPECT_FALSE(i2 >= i1); |
3353 | 1157 | 1196 | ||
3356 | 1158 | EXPECT_NE(0, i1.hash()); | 1197 | EXPECT_NE(0u, i1.hash()); |
3357 | 1159 | EXPECT_NE(0, qHash(i1)); | 1198 | EXPECT_NE(0u, qHash(i1)); |
3358 | 1160 | } | 1199 | } |
3359 | 1161 | 1200 | ||
3360 | 1162 | { | 1201 | { |
3361 | 1163 | // Both items valid with identical metadata, but different accounts (a1 < a2). | 1202 | // Both items valid with identical metadata, but different accounts (a1 < a2). |
3362 | 1164 | 1203 | ||
3365 | 1165 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "x", "x"); | 1204 | auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "x", "x"); |
3366 | 1166 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "b", "x", "x"); | 1205 | auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 2, "x", "x"); |
3367 | 1167 | 1206 | ||
3368 | 1168 | Item i1; | 1207 | Item i1; |
3369 | 1169 | Item i2; | 1208 | Item i2; |
3370 | @@ -1485,7 +1524,7 @@ | |||
3371 | 1485 | auto arg = spy.takeFirst(); | 1524 | auto arg = spy.takeFirst(); |
3372 | 1486 | EXPECT_EQ(ItemListJob::Status::Error, qvariant_cast<ItemListJob::Status>(arg.at(0))); | 1525 | EXPECT_EQ(ItemListJob::Status::Error, qvariant_cast<ItemListJob::Status>(arg.at(0))); |
3373 | 1487 | 1526 | ||
3375 | 1488 | EXPECT_EQ("Item::parents(): provider returned a file as a parent", j->error().message()); | 1527 | EXPECT_EQ("Item::parents(): provider returned a file as a parent (id = root_id)", j->error().message()); |
3376 | 1489 | } | 1528 | } |
3377 | 1490 | } | 1529 | } |
3378 | 1491 | 1530 | ||
3379 | @@ -1639,11 +1678,12 @@ | |||
3380 | 1639 | { | 1678 | { |
3381 | 1640 | set_provider(unique_ptr<provider::ProviderBase>(new MockProvider())); | 1679 | set_provider(unique_ptr<provider::ProviderBase>(new MockProvider())); |
3382 | 1641 | 1680 | ||
3384 | 1642 | auto test_account = runtime_->make_test_account(service_connection_->baseService(), object_path(), "test_account"); | 1681 | auto acc1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1); |
3385 | 1682 | auto acc2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 2); | ||
3386 | 1643 | 1683 | ||
3387 | 1644 | Item root1; | 1684 | Item root1; |
3388 | 1645 | { | 1685 | { |
3390 | 1646 | unique_ptr<ItemJob> j(test_account.get("root_id")); | 1686 | unique_ptr<ItemJob> j(acc1.get("root_id")); |
3391 | 1647 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); | 1687 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); |
3392 | 1648 | spy.wait(SIGNAL_WAIT_TIME); | 1688 | spy.wait(SIGNAL_WAIT_TIME); |
3393 | 1649 | root1 = j->item(); | 1689 | root1 = j->item(); |
3394 | @@ -1652,7 +1692,7 @@ | |||
3395 | 1652 | 1692 | ||
3396 | 1653 | Item root2; | 1693 | Item root2; |
3397 | 1654 | { | 1694 | { |
3399 | 1655 | unique_ptr<ItemJob> j(acc_.get("root_id")); | 1695 | unique_ptr<ItemJob> j(acc2.get("root_id")); |
3400 | 1656 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); | 1696 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); |
3401 | 1657 | spy.wait(SIGNAL_WAIT_TIME); | 1697 | spy.wait(SIGNAL_WAIT_TIME); |
3402 | 1658 | root2 = j->item(); | 1698 | root2 = j->item(); |
3403 | @@ -1661,7 +1701,7 @@ | |||
3404 | 1661 | 1701 | ||
3405 | 1662 | Item child; | 1702 | Item child; |
3406 | 1663 | { | 1703 | { |
3408 | 1664 | unique_ptr<ItemJob> j(acc_.get("child_id")); | 1704 | unique_ptr<ItemJob> j(acc2.get("child_id")); |
3409 | 1665 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); | 1705 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); |
3410 | 1666 | spy.wait(SIGNAL_WAIT_TIME); | 1706 | spy.wait(SIGNAL_WAIT_TIME); |
3411 | 1667 | child = j->item(); | 1707 | child = j->item(); |
3412 | @@ -1751,7 +1791,9 @@ | |||
3413 | 1751 | EXPECT_FALSE(j->isValid()); | 1791 | EXPECT_FALSE(j->isValid()); |
3414 | 1752 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 1792 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3415 | 1753 | EXPECT_EQ(StorageError::Type::LocalCommsError, j->error().type()); | 1793 | EXPECT_EQ(StorageError::Type::LocalCommsError, j->error().type()); |
3417 | 1754 | EXPECT_EQ("LocalCommsError: Item::copy(): source and target item type differ", j->error().errorString()); | 1794 | EXPECT_EQ("LocalCommsError: Item::copy()provider error: source and target item type differ " |
3418 | 1795 | "(source id = child_id, target id = new_item_id)", | ||
3419 | 1796 | j->error().errorString()); | ||
3420 | 1755 | } | 1797 | } |
3421 | 1756 | 1798 | ||
3422 | 1757 | TEST_F(MoveTest, basic) | 1799 | TEST_F(MoveTest, basic) |
3423 | @@ -1863,7 +1905,8 @@ | |||
3424 | 1863 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 1905 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3425 | 1864 | EXPECT_EQ(StorageError::Type::LocalCommsError, j->error().type()); | 1906 | EXPECT_EQ(StorageError::Type::LocalCommsError, j->error().type()); |
3426 | 1865 | EXPECT_EQ("LocalCommsError", j->error().name()); | 1907 | EXPECT_EQ("LocalCommsError", j->error().name()); |
3428 | 1866 | EXPECT_EQ("LocalCommsError: Item::move(): impossible root item returned by provider", j->error().errorString()); | 1908 | EXPECT_EQ("LocalCommsError: Item::move(): impossible root item returned by provider (id = root_id)", |
3429 | 1909 | j->error().errorString()); | ||
3430 | 1867 | } | 1910 | } |
3431 | 1868 | 1911 | ||
3432 | 1869 | TEST_F(MoveTest, type_mismatch) | 1912 | TEST_F(MoveTest, type_mismatch) |
3433 | @@ -1899,7 +1942,8 @@ | |||
3434 | 1899 | EXPECT_FALSE(j->isValid()); | 1942 | EXPECT_FALSE(j->isValid()); |
3435 | 1900 | EXPECT_EQ(ItemJob::Status::Error, j->status()); | 1943 | EXPECT_EQ(ItemJob::Status::Error, j->status()); |
3436 | 1901 | EXPECT_EQ(StorageError::Type::LocalCommsError, j->error().type()); | 1944 | EXPECT_EQ(StorageError::Type::LocalCommsError, j->error().type()); |
3438 | 1902 | EXPECT_EQ("LocalCommsError: Item::move(): provider error: source and target item type differ", | 1945 | EXPECT_EQ("LocalCommsError: Item::move(): provider error: source and target item type differ " |
3439 | 1946 | "(source id = child_id, target id = child_id)", | ||
3440 | 1903 | j->error().errorString()); | 1947 | j->error().errorString()); |
3441 | 1904 | } | 1948 | } |
3442 | 1905 | 1949 | ||
3443 | @@ -2094,7 +2138,7 @@ | |||
3444 | 2094 | auto status = qvariant_cast<ItemJob::Status>(arg.at(0)); | 2138 | auto status = qvariant_cast<ItemJob::Status>(arg.at(0)); |
3445 | 2095 | EXPECT_EQ(ItemJob::Status::Error, status); | 2139 | EXPECT_EQ(ItemJob::Status::Error, status); |
3446 | 2096 | 2140 | ||
3448 | 2097 | EXPECT_EQ("LocalCommsError: Item::createFolder(): impossible file item returned by provider", | 2141 | EXPECT_EQ("LocalCommsError: Item::createFolder(): impossible file item returned by provider (id = new_folder_id)", |
3449 | 2098 | j->error().errorString()); | 2142 | j->error().errorString()); |
3450 | 2099 | } | 2143 | } |
3451 | 2100 | 2144 | ||
3452 | @@ -2157,7 +2201,10 @@ | |||
3453 | 2157 | QSignalSpy ready_spy(j.get(), &ItemListJob::itemsReady); | 2201 | QSignalSpy ready_spy(j.get(), &ItemListJob::itemsReady); |
3454 | 2158 | QSignalSpy status_spy(j.get(), &ItemListJob::statusChanged); | 2202 | QSignalSpy status_spy(j.get(), &ItemListJob::statusChanged); |
3455 | 2159 | status_spy.wait(SIGNAL_WAIT_TIME); | 2203 | status_spy.wait(SIGNAL_WAIT_TIME); |
3457 | 2160 | ASSERT_EQ(0, ready_spy.count()); | 2204 | if (ready_spy.count() == 0) |
3458 | 2205 | { | ||
3459 | 2206 | ASSERT_TRUE(ready_spy.wait(SIGNAL_WAIT_TIME)); | ||
3460 | 2207 | } | ||
3461 | 2161 | 2208 | ||
3462 | 2162 | EXPECT_EQ(ItemListJob::Status::Finished, j->status()); | 2209 | EXPECT_EQ(ItemListJob::Status::Finished, j->status()); |
3463 | 2163 | 2210 | ||
3464 | @@ -2303,7 +2350,8 @@ | |||
3465 | 2303 | auto arg = spy.takeFirst(); | 2350 | auto arg = spy.takeFirst(); |
3466 | 2304 | EXPECT_EQ(ItemListJob::Status::Error, qvariant_cast<ItemListJob::Status>(arg.at(0))); | 2351 | EXPECT_EQ(ItemListJob::Status::Error, qvariant_cast<ItemListJob::Status>(arg.at(0))); |
3467 | 2305 | 2352 | ||
3469 | 2306 | EXPECT_EQ("LocalCommsError: Item::list(): impossible root item returned by provider", j->error().errorString()); | 2353 | EXPECT_EQ("LocalCommsError: Item::list(): impossible root item returned by provider (id = child_id)", |
3470 | 2354 | j->error().errorString()); | ||
3471 | 2307 | } | 2355 | } |
3472 | 2308 | 2356 | ||
3473 | 2309 | TEST_F(ListTest, runtime_destroyed_while_item_list_job_running) | 2357 | TEST_F(ListTest, runtime_destroyed_while_item_list_job_running) |
3474 | @@ -3026,7 +3074,7 @@ | |||
3475 | 3026 | 3074 | ||
3476 | 3027 | unique_ptr<Uploader> uploader(child.createUploader(Item::ConflictPolicy::IgnoreConflict, 20)); | 3075 | unique_ptr<Uploader> uploader(child.createUploader(Item::ConflictPolicy::IgnoreConflict, 20)); |
3477 | 3028 | EXPECT_FALSE(uploader->isValid()); | 3076 | EXPECT_FALSE(uploader->isValid()); |
3479 | 3029 | EXPECT_EQ(Downloader::Status::Error, uploader->status()); | 3077 | EXPECT_EQ(Uploader::Status::Error, uploader->status()); |
3480 | 3030 | EXPECT_EQ(StorageError::RuntimeDestroyed, uploader->error().type()); | 3078 | EXPECT_EQ(StorageError::RuntimeDestroyed, uploader->error().type()); |
3481 | 3031 | EXPECT_EQ("RuntimeDestroyed: Item::createUploader(): Runtime was destroyed previously", | 3079 | EXPECT_EQ("RuntimeDestroyed: Item::createUploader(): Runtime was destroyed previously", |
3482 | 3032 | uploader->error().errorString()); | 3080 | uploader->error().errorString()); |
3483 | @@ -3370,7 +3418,8 @@ | |||
3484 | 3370 | 3418 | ||
3485 | 3371 | EXPECT_EQ(Uploader::Status::Error, uploader->status()); | 3419 | EXPECT_EQ(Uploader::Status::Error, uploader->status()); |
3486 | 3372 | EXPECT_EQ(StorageError::Type::LocalCommsError, uploader->error().type()); | 3420 | EXPECT_EQ(StorageError::Type::LocalCommsError, uploader->error().type()); |
3488 | 3373 | EXPECT_EQ("Item::createUploader(): impossible folder item returned by provider", uploader->error().message()); | 3421 | EXPECT_EQ("Item::createUploader(): impossible folder item returned by provider (id = some_id)", |
3489 | 3422 | uploader->error().message()); | ||
3490 | 3374 | } | 3423 | } |
3491 | 3375 | 3424 | ||
3492 | 3376 | TEST_F(UploadTest, cancel_success) | 3425 | TEST_F(UploadTest, cancel_success) |
3493 | @@ -3702,7 +3751,8 @@ | |||
3494 | 3702 | EXPECT_EQ(Uploader::Status::Error, qvariant_cast<Uploader::Status>(arg.at(0))); | 3751 | EXPECT_EQ(Uploader::Status::Error, qvariant_cast<Uploader::Status>(arg.at(0))); |
3495 | 3703 | 3752 | ||
3496 | 3704 | EXPECT_EQ(StorageError::Type::LocalCommsError, uploader->error().type()); | 3753 | EXPECT_EQ(StorageError::Type::LocalCommsError, uploader->error().type()); |
3498 | 3705 | EXPECT_EQ("Item::createFile(): impossible folder item returned by provider", uploader->error().message()); | 3754 | EXPECT_EQ("Item::createFile(): impossible folder item returned by provider (id = some_id)", |
3499 | 3755 | uploader->error().message()); | ||
3500 | 3706 | } | 3756 | } |
3501 | 3707 | 3757 | ||
3502 | 3708 | TEST_F(CreateFileTest, exists) | 3758 | TEST_F(CreateFileTest, exists) |
3503 | 3709 | 3759 | ||
3504 | === modified file 'tests/utils/DBusEnvironment.cpp' | |||
3505 | --- tests/utils/DBusEnvironment.cpp 2016-08-04 10:12:01 +0000 | |||
3506 | +++ tests/utils/DBusEnvironment.cpp 2016-12-12 02:53:43 +0000 | |||
3507 | @@ -17,6 +17,7 @@ | |||
3508 | 17 | */ | 17 | */ |
3509 | 18 | 18 | ||
3510 | 19 | #include "DBusEnvironment.h" | 19 | #include "DBusEnvironment.h" |
3511 | 20 | #include <unity/storage/registry/Registry.h> | ||
3512 | 20 | 21 | ||
3513 | 21 | #include <testsetup.h> | 22 | #include <testsetup.h> |
3514 | 22 | 23 | ||
3515 | @@ -27,6 +28,9 @@ | |||
3516 | 27 | char const ACCOUNTS_BUS_NAME[] = "com.ubuntu.OnlineAccounts.Manager"; | 28 | char const ACCOUNTS_BUS_NAME[] = "com.ubuntu.OnlineAccounts.Manager"; |
3517 | 28 | char const FAKE_ACCOUNTS_SERVICE[] = TEST_SRC_DIR "/utils/fake-online-accounts-daemon.py"; | 29 | char const FAKE_ACCOUNTS_SERVICE[] = TEST_SRC_DIR "/utils/fake-online-accounts-daemon.py"; |
3518 | 29 | 30 | ||
3519 | 31 | char const REGISTRY_TEST_BUS_NAME[] = "com.ubuntu.StorageFramework.TestRegistry"; | ||
3520 | 32 | char const REGISTRY_SERVICE[] = TEST_BIN_DIR "/../src/registry/storage-framework-registry"; | ||
3521 | 33 | |||
3522 | 30 | char const DEMO_PROVIDER_BUS_NAME[] = "com.canonical.StorageFramework.Provider.ProviderTest"; | 34 | char const DEMO_PROVIDER_BUS_NAME[] = "com.canonical.StorageFramework.Provider.ProviderTest"; |
3523 | 31 | char const DEMO_PROVIDER_SERVICE[] = TEST_BIN_DIR "/../demo/provider_test/provider-test"; | 35 | char const DEMO_PROVIDER_SERVICE[] = TEST_BIN_DIR "/../demo/provider_test/provider-test"; |
3524 | 32 | } | 36 | } |
3525 | @@ -38,6 +42,11 @@ | |||
3526 | 38 | ACCOUNTS_BUS_NAME, QDBusConnection::SessionBus, | 42 | ACCOUNTS_BUS_NAME, QDBusConnection::SessionBus, |
3527 | 39 | FAKE_ACCOUNTS_SERVICE, {})); | 43 | FAKE_ACCOUNTS_SERVICE, {})); |
3528 | 40 | runner_->registerService(accounts_service_); | 44 | runner_->registerService(accounts_service_); |
3529 | 45 | |||
3530 | 46 | registry_service_.reset(new QtDBusTest::QProcessDBusService( | ||
3531 | 47 | unity::storage::registry::BUS_NAME, QDBusConnection::SessionBus, | ||
3532 | 48 | REGISTRY_SERVICE, {})); | ||
3533 | 49 | runner_->registerService(registry_service_); | ||
3534 | 41 | } | 50 | } |
3535 | 42 | 51 | ||
3536 | 43 | DBusEnvironment::~DBusEnvironment() | 52 | DBusEnvironment::~DBusEnvironment() |
3537 | 44 | 53 | ||
3538 | === modified file 'tests/utils/DBusEnvironment.h' | |||
3539 | --- tests/utils/DBusEnvironment.h 2016-08-04 10:12:01 +0000 | |||
3540 | +++ tests/utils/DBusEnvironment.h 2016-12-12 02:53:43 +0000 | |||
3541 | @@ -45,5 +45,6 @@ | |||
3542 | 45 | private: | 45 | private: |
3543 | 46 | std::unique_ptr<QtDBusTest::DBusTestRunner> runner_; | 46 | std::unique_ptr<QtDBusTest::DBusTestRunner> runner_; |
3544 | 47 | QSharedPointer<QtDBusTest::QProcessDBusService> accounts_service_; | 47 | QSharedPointer<QtDBusTest::QProcessDBusService> accounts_service_; |
3545 | 48 | QSharedPointer<QtDBusTest::QProcessDBusService> registry_service_; | ||
3546 | 48 | QSharedPointer<QtDBusTest::QProcessDBusService> demo_provider_; | 49 | QSharedPointer<QtDBusTest::QProcessDBusService> demo_provider_; |
3547 | 49 | }; | 50 | }; |
3548 | 50 | 51 | ||
3549 | === modified file 'tests/utils/ProviderFixture.h' | |||
3550 | --- tests/utils/ProviderFixture.h 2016-09-26 02:37:03 +0000 | |||
3551 | +++ tests/utils/ProviderFixture.h 2016-12-12 02:53:43 +0000 | |||
3552 | @@ -23,7 +23,11 @@ | |||
3553 | 23 | #include <utils/DBusEnvironment.h> | 23 | #include <utils/DBusEnvironment.h> |
3554 | 24 | #include <utils/ProviderClient.h> | 24 | #include <utils/ProviderClient.h> |
3555 | 25 | 25 | ||
3556 | 26 | #pragma GCC diagnostic push | ||
3557 | 27 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" | ||
3558 | 26 | #include <gtest/gtest.h> | 28 | #include <gtest/gtest.h> |
3559 | 29 | #pragma GCC diagnostic pop | ||
3560 | 30 | |||
3561 | 27 | #include <OnlineAccounts/Account> | 31 | #include <OnlineAccounts/Account> |
3562 | 28 | #include <OnlineAccounts/Manager> | 32 | #include <OnlineAccounts/Manager> |
3563 | 29 | #include <QDBusConnection> | 33 | #include <QDBusConnection> |
3564 | 30 | 34 | ||
3565 | === removed file 'tests/utils/com.ubuntu.OnlineAccounts.Manager.xml' | |||
3566 | --- tests/utils/com.ubuntu.OnlineAccounts.Manager.xml 2016-07-12 02:25:26 +0000 | |||
3567 | +++ tests/utils/com.ubuntu.OnlineAccounts.Manager.xml 1970-01-01 00:00:00 +0000 | |||
3568 | @@ -1,153 +0,0 @@ | |||
3569 | 1 | <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" | ||
3570 | 2 | "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | ||
3571 | 3 | |||
3572 | 4 | <node name="/com/ubuntu/OnlineAccounts/Manager"> | ||
3573 | 5 | <interface name="com.ubuntu.OnlineAccounts.Manager"> | ||
3574 | 6 | |||
3575 | 7 | <!-- | ||
3576 | 8 | Global concepts: | ||
3577 | 9 | |||
3578 | 10 | Clients are identified by their "applicationId", which is the | ||
3579 | 11 | "<package>_<app>" of the client. | ||
3580 | 12 | |||
3581 | 13 | The "serviceId" is an application-specific name for an account provider. | ||
3582 | 14 | That is, the "serviceId" contains the information about the application | ||
3583 | 15 | which will use it, and the account provider (e.g. "google", "facebook"). | ||
3584 | 16 | "serviceId"s are backed by files shipped with the application, which can | ||
3585 | 17 | contain application/account-provider specific information, such as the | ||
3586 | 18 | ClientId and ClientSecret to be used when authentication with OAuth 2.0. | ||
3587 | 19 | An application can ship more than one "serviceId", if they refer to | ||
3588 | 20 | different account providers; that is, one application can have a | ||
3589 | 21 | serviceId for Google and one for Facebook, but the same application | ||
3590 | 22 | cannot have one for GMail and another for Picasa. | ||
3591 | 23 | --> | ||
3592 | 24 | |||
3593 | 25 | <!-- | ||
3594 | 26 | GetAccounts: returns a list of account IDs that satisfy the given | ||
3595 | 27 | filters. | ||
3596 | 28 | |||
3597 | 29 | Allowed keys for the "filters" parameter (any combination is allowed, | ||
3598 | 30 | though not all combinations might make sense): | ||
3599 | 31 | |||
3600 | 32 | - "applicationId" ("s"): the "<package>_<app>" of the client. An | ||
3601 | 33 | unconfined application can specify this in order to restrict the set | ||
3602 | 34 | of results to only those accounts that the application has been | ||
3603 | 35 | authorized to use. For confined apps, OA will deduce the | ||
3604 | 36 | applicationId from the apparmor label of the caller. | ||
3605 | 37 | |||
3606 | 38 | - "serviceId" ("s"): if the application wants to list only those | ||
3607 | 39 | accounts coming from a specific provider (e.g., "Facebook"). | ||
3608 | 40 | |||
3609 | 41 | - "accountId" ("u"): the ID of an account. | ||
3610 | 42 | |||
3611 | 43 | In any case, an application will receive only those accounts which the | ||
3612 | 44 | user has authorized the application to use. See | ||
3613 | 45 | http://wiki.ubuntu.com/OnlineAccounts | ||
3614 | 46 | for an overview of the UI experience. | ||
3615 | 47 | |||
3616 | 48 | Disabled accounts will not be returned. | ||
3617 | 49 | --> | ||
3618 | 50 | <method name="GetAccounts"> | ||
3619 | 51 | <arg name="filters" type="a{sv}" direction="in" /> | ||
3620 | 52 | <!-- | ||
3621 | 53 | The return value is a list of account IDs paired with a dictionary of account data. | ||
3622 | 54 | This will always include: | ||
3623 | 55 | - "serviceId" (s) | ||
3624 | 56 | - "displayName" (s) | ||
3625 | 57 | Other settings stored on the account will also be included, such as the | ||
3626 | 58 | server address and port of an owncloud or IMAP account, but we haven't | ||
3627 | 59 | defined exactly how. Possibly, all account-specific keys will be | ||
3628 | 60 | prefixed by "settings/", in order not to clash with the keys defined at | ||
3629 | 61 | the framework level. | ||
3630 | 62 | --> | ||
3631 | 63 | <arg name="accounts" type="a(ua{sv})" direction="out" /> | ||
3632 | 64 | <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap"/> | ||
3633 | 65 | <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" | ||
3634 | 66 | value="QList<AccountInfo>"/> | ||
3635 | 67 | </method> | ||
3636 | 68 | |||
3637 | 69 | <!-- | ||
3638 | 70 | Authenticate: request authentication credentials for the given | ||
3639 | 71 | account ID in the context of a particular service. | ||
3640 | 72 | |||
3641 | 73 | If "interactive" is false, an error will be returned if | ||
3642 | 74 | user interaction would be required to retrieve the | ||
3643 | 75 | credentials. | ||
3644 | 76 | |||
3645 | 77 | If "invalidate" is true, any stored credentials will be | ||
3646 | 78 | ignored and new credentials will be requested from the account | ||
3647 | 79 | provider. | ||
3648 | 80 | --> | ||
3649 | 81 | <method name="Authenticate"> | ||
3650 | 82 | <arg name="accountId" type="u" direction="in" /> | ||
3651 | 83 | <arg name="serviceId" type="s" direction="in" /> | ||
3652 | 84 | <arg name="interactive" type="b" direction="in" /> | ||
3653 | 85 | <arg name="invalidate" type="b" direction="in" /> | ||
3654 | 86 | <!-- | ||
3655 | 87 | This dictionary can be used to specify OAuth client keys or permission | ||
3656 | 88 | scopes. While it's possible to statically define them a the "serviceId" | ||
3657 | 89 | level, some apps might want to change this information at runtime. | ||
3658 | 90 | Possible use cases: | ||
3659 | 91 | 1) OAuth keys are retrieved from a server (so that they can be updated | ||
3660 | 92 | when the old ones are revoked). | ||
3661 | 93 | 2) An app might want to use different keys when talking to GMail and | ||
3662 | 94 | Picasa. | ||
3663 | 95 | 3) The scope list can also be dynamic, and depending on how the user is | ||
3664 | 96 | using the app. | ||
3665 | 97 | 4) SASL: the parameters would contain the latest challenge got from the | ||
3666 | 98 | server. | ||
3667 | 99 | --> | ||
3668 | 100 | <arg name="parameters" type="a{sv}" direction="in" /> | ||
3669 | 101 | <arg name="credentials" type="a{sv}" direction="out" /> | ||
3670 | 102 | <annotation name="org.qtproject.QtDBus.QtTypeName.In4" value="QVariantMap"/> | ||
3671 | 103 | <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | ||
3672 | 104 | </method> | ||
3673 | 105 | |||
3674 | 106 | <!-- | ||
3675 | 107 | RequestAccess: register a new account for use with the given | ||
3676 | 108 | service. | ||
3677 | 109 | This method also performs the authentication, since that's what apps | ||
3678 | 110 | would do as soon as they get the account. | ||
3679 | 111 | --> | ||
3680 | 112 | <method name="RequestAccess"> | ||
3681 | 113 | <arg name="serviceId" type="s" direction="in" /> | ||
3682 | 114 | <arg name="parameters" type="a{sv}" direction="in" /> | ||
3683 | 115 | <arg name="account" type="(ua{sv})" direction="out" /> | ||
3684 | 116 | <arg name="credentials" type="a{sv}" direction="out" /> | ||
3685 | 117 | <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/> | ||
3686 | 118 | <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="AccountInfo"/> | ||
3687 | 119 | <annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="QVariantMap"/> | ||
3688 | 120 | </method> | ||
3689 | 121 | |||
3690 | 122 | <!-- | ||
3691 | 123 | AccountChanged: emitted when account details are changed. | ||
3692 | 124 | |||
3693 | 125 | The apparmor policy will NOT ALLOW confined applications to receive | ||
3694 | 126 | this signal on the account manager object path (which might be | ||
3695 | 127 | /com/ubuntu/OnlineAccounts/Manager). Only unconfined applications will | ||
3696 | 128 | be able to listen to this signal from that object path. | ||
3697 | 129 | |||
3698 | 130 | Confined apps will have to catch this signal from a different object path: | ||
3699 | 131 | /com/ubuntu/OnlineAccounts/Manager/@{APP_PKGNAME_DBUS}, which will | ||
3700 | 132 | deliver the signal only for those accounts which the app has been | ||
3701 | 133 | authorized to use. | ||
3702 | 134 | --> | ||
3703 | 135 | <signal name="AccountChanged"> | ||
3704 | 136 | <!-- | ||
3705 | 137 | The serviceId will also be included in the "account" dictionary. The | ||
3706 | 138 | reason for having it also here is to allow clients to filter D-Bus | ||
3707 | 139 | messages by arg0. This can be important for unconfined clients, which | ||
3708 | 140 | would otherwise be woken up by any account change, even those not | ||
3709 | 141 | relevant to them. | ||
3710 | 142 | --> | ||
3711 | 143 | <arg name="serviceId" type="s" /> | ||
3712 | 144 | <!-- | ||
3713 | 145 | The dictionary contains a changeType key, type "u", whose value is | ||
3714 | 146 | enum { enabled, disabled, changed } | ||
3715 | 147 | --> | ||
3716 | 148 | <arg name="account" type="(ua{sv})" /> | ||
3717 | 149 | <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="AccountInfo"/> | ||
3718 | 150 | </signal> | ||
3719 | 151 | |||
3720 | 152 | </interface> | ||
3721 | 153 | </node> | ||
3722 | 154 | 0 | ||
3723 | === modified file 'tests/utils/fake-online-accounts-daemon.py' | |||
3724 | --- tests/utils/fake-online-accounts-daemon.py 2016-11-01 03:36:29 +0000 | |||
3725 | +++ tests/utils/fake-online-accounts-daemon.py 2016-12-12 02:53:43 +0000 | |||
3726 | @@ -17,7 +17,6 @@ | |||
3727 | 17 | 17 | ||
3728 | 18 | """A fake version of the OnlineAccounts D-Bus service.""" | 18 | """A fake version of the OnlineAccounts D-Bus service.""" |
3729 | 19 | 19 | ||
3730 | 20 | import os | ||
3731 | 21 | import sys | 20 | import sys |
3732 | 22 | 21 | ||
3733 | 23 | import dbus.service | 22 | import dbus.service |
3734 | @@ -28,9 +27,6 @@ | |||
3735 | 28 | OBJECT_PATH = "/com/ubuntu/OnlineAccounts/Manager" | 27 | OBJECT_PATH = "/com/ubuntu/OnlineAccounts/Manager" |
3736 | 29 | OA_IFACE = "com.ubuntu.OnlineAccounts.Manager" | 28 | OA_IFACE = "com.ubuntu.OnlineAccounts.Manager" |
3737 | 30 | 29 | ||
3738 | 31 | INTERFACE_XML = os.path.join(os.path.dirname(__file__), | ||
3739 | 32 | "com.ubuntu.OnlineAccounts.Manager.xml") | ||
3740 | 33 | |||
3741 | 34 | AUTH_OAUTH1 = 1 | 30 | AUTH_OAUTH1 = 1 |
3742 | 35 | AUTH_OAUTH2 = 2 | 31 | AUTH_OAUTH2 = 2 |
3743 | 36 | AUTH_PASSWORD = 3 | 32 | AUTH_PASSWORD = 3 |
3744 | @@ -90,16 +86,16 @@ | |||
3745 | 90 | }, signature="sv") | 86 | }, signature="sv") |
3746 | 91 | 87 | ||
3747 | 92 | class Account: | 88 | class Account: |
3749 | 93 | def __init__(self, account_id, display_name, service_id, credentials, settings=None): | 89 | def __init__(self, account_id, name, service_id, credentials, settings=None): |
3750 | 94 | self.account_id = account_id | 90 | self.account_id = account_id |
3752 | 95 | self.display_name = display_name | 91 | self.name = name |
3753 | 96 | self.service_id = service_id | 92 | self.service_id = service_id |
3754 | 97 | self.credentials = credentials | 93 | self.credentials = credentials |
3755 | 98 | self.settings = settings | 94 | self.settings = settings |
3756 | 99 | 95 | ||
3757 | 100 | def serialise(self): | 96 | def serialise(self): |
3758 | 101 | account_info = dbus.Dictionary({ | 97 | account_info = dbus.Dictionary({ |
3760 | 102 | "displayName": dbus.String(self.display_name), | 98 | "displayName": dbus.String(self.name), |
3761 | 103 | "serviceId": dbus.String(self.service_id), | 99 | "serviceId": dbus.String(self.service_id), |
3762 | 104 | "authMethod": dbus.Int32(self.credentials.method), | 100 | "authMethod": dbus.Int32(self.credentials.method), |
3763 | 105 | }, signature="sv") | 101 | }, signature="sv") |
3764 | @@ -114,12 +110,12 @@ | |||
3765 | 114 | self.accounts = accounts | 110 | self.accounts = accounts |
3766 | 115 | 111 | ||
3767 | 116 | @dbus.service.method(dbus_interface=OA_IFACE, | 112 | @dbus.service.method(dbus_interface=OA_IFACE, |
3769 | 117 | in_signature="a{sv}", out_signature="a(ua{sv})") | 113 | in_signature="a{sv}", out_signature="a(ua{sv})aa{sv}") |
3770 | 118 | def GetAccounts(self, filters): | 114 | def GetAccounts(self, filters): |
3771 | 119 | #print("GetAccounts %r" % filters) | 115 | #print("GetAccounts %r" % filters) |
3772 | 120 | sys.stdout.flush() | 116 | sys.stdout.flush() |
3773 | 121 | return dbus.Array([a.serialise() for a in self.accounts], | 117 | return dbus.Array([a.serialise() for a in self.accounts], |
3775 | 122 | signature="a(ua{sv})") | 118 | signature="a(ua{sv})"), dbus.Array(signature="a{sv}") |
3776 | 123 | 119 | ||
3777 | 124 | @dbus.service.method(dbus_interface=OA_IFACE, | 120 | @dbus.service.method(dbus_interface=OA_IFACE, |
3778 | 125 | in_signature="usbba{sv}", out_signature="a{sv}") | 121 | in_signature="usbba{sv}", out_signature="a{sv}") |
3779 | @@ -178,8 +174,8 @@ | |||
3780 | 178 | Account(4, "Password host account", "password-host-service", | 174 | Account(4, "Password host account", "password-host-service", |
3781 | 179 | Password_Bug1628473("joe", "secret"), | 175 | Password_Bug1628473("joe", "secret"), |
3782 | 180 | {"host": "http://www.example.com/"}), | 176 | {"host": "http://www.example.com/"}), |
3785 | 181 | Account(42, "Fake google account", "google-drive-scope", | 177 | Account(42, "Fake test account", "storage-provider-test", |
3786 | 182 | OAuth2("fake-google-access-token", 0, [])), | 178 | OAuth2("fake-test-access-token", 0, [])), |
3787 | 183 | Account(99, "Fake mcloud account", "com.canonical.scopes.mcloud_mcloud_mcloud", | 179 | Account(99, "Fake mcloud account", "com.canonical.scopes.mcloud_mcloud_mcloud", |
3788 | 184 | OAuth2("fake-mcloud-access-token", 0, [])), | 180 | OAuth2("fake-mcloud-access-token", 0, [])), |
3789 | 185 | ] | 181 | ] |
Looks good.