Merge lp:~michihenning/storage-framework/registry into lp:storage-framework/devel
- registry
- Merge into devel
Status: | Merged |
---|---|
Approved by: | James Henstridge |
Approved revision: | 122 |
Merged at revision: | 99 |
Proposed branch: | lp:~michihenning/storage-framework/registry |
Merge into: | lp:storage-framework/devel |
Diff against target: |
2636 lines (+1457/-276) 52 files modified
CMakeLists.txt (+1/-0) data/registry.xml (+21/-24) debian/control (+12/-0) debian/control.in (+12/-0) 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 (+25/-48) src/qt/internal/AccountsJobImpl.cpp (+50/-69) src/qt/internal/RuntimeImpl.cpp (+24/-22) 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/-0) 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 (+47/-34) tests/utils/DBusEnvironment.cpp (+9/-0) tests/utils/DBusEnvironment.h (+1/-0) tests/utils/fake-online-accounts-daemon.py (+5/-5) |
To merge this branch: | bzr merge lp:~michihenning/storage-framework/registry |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Henstridge | Approve | ||
unity-api-1-bot | continuous-integration | Approve | |
Review via email: mp+310254@code.launchpad.net |
Commit message
Added a separate registry service.
Description of the change
Added a separate registry service.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:94
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:97
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:98
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:98
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:99
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:99
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:99
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:101
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 108. By Michi Henning
-
Remove prog_name from accounts manager; it doesn't work.
- 109. By Michi Henning
-
Merged devel.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:109
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
Lots of inline comments.
Michi Henning (michihenning) wrote : | # |
Thanks for the very thorough review! I've replied to a few comments inline. I think I've addressed all the issues, thanks!
- 110. By Michi Henning
-
Removed env var for registry bus name.
- 111. By Michi Henning
-
Using o dbus format for bus name, and u dbus format for account id.
Renamed AccountDetails members and Account methods to be clearer. - 112. By Michi Henning
-
Use QDBusObjectPath instead of QString.
- 113. By Michi Henning
-
Use unique pointer for RegistryInterface.
- 114. By Michi Henning
-
Removed redundant QDBusArgument inserter/extractor.
Fixed macros for install locations.
One more rename of provider_id -> bus_name. - 115. By Michi Henning
-
Registry in separate package.
- 116. By Michi Henning
-
Fix install path in registry .install file.
- 117. By Michi Henning
-
Make ubuntu-
system- settings- online- accounts a runtime dependency.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:117
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
Replies to inline comments. Still need to look at your subsequent changes.
- 118. By Michi Henning
-
Review comments from James.
- 119. By Michi Henning
-
Merged devel.
Michi Henning (michihenning) wrote : | # |
Just pushed the branch. Sorry for being dense about the rodata for the QStrings. But, as you said, it's moot--I've removed the methods altogether.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:119
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
Okay, looking at the most recent code my only suggestions are:
1. As mentioned in mardy's reply on bug 1643421, it would be better to depend on online-
2. My suggestion to make unity::
3. Was there any reason why you changed AccountDetails.
4. In ListAccountsHan
- 120. By Michi Henning
-
Review comments from James.
Michi Henning (michihenning) wrote : | # |
> 3. Was there any reason why you changed AccountDetails.
> Is there something wrong with the terminology on libonline-
I find displayName rather confusing because it suggests translation. But, in fact, that name is the identity of the account in the cloud service. So, it's the name of the account, whether for display or otherwise.
> 4. In ListAccountsHan
> AccountDetails object, unless I'm missing something. Can we do something
> about the test coverage, or would you like to do that in a follow up branch?
Thanks for spotting that! The registry test target is currently a stub, I'm going to push another branch to get proper coverage.
I've made the other changes.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:120
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:120
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
Sorry for the delay in following up.
I still feel that it would be better to follow the naming convention of libonline-accounts for name vs. displayName. My default policy would be to maintain the same naming unless we've got a compelling reason to be different.
Additionally, to me "name" has connotations of uniqueness or the ability to be used as a key, while "display name" does not. The display name for an online-accounts account is certainly not unique, and could very well be blank.
- 121. By Michi Henning
-
Merged devel.
- 122. By Michi Henning
-
Account::name() -> Account:
:displayName( )
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:122
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2016-10-31 09:03:32 +0000 |
3 | +++ CMakeLists.txt 2016-11-28 11:06:57 +0000 |
4 | @@ -138,6 +138,7 @@ |
5 | storage-framework-qt-local-client |
6 | sf-provider-objects |
7 | storage-framework-provider |
8 | + storage-framework-registry |
9 | FILTER |
10 | ${CMAKE_SOURCE_DIR}/tests/* |
11 | ${CMAKE_BINARY_DIR}/* |
12 | |
13 | === modified file 'data/registry.xml' |
14 | --- data/registry.xml 2016-05-04 14:32:07 +0000 |
15 | +++ data/registry.xml 2016-11-28 11:06:57 +0000 |
16 | @@ -3,33 +3,30 @@ |
17 | <node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> |
18 | <!-- |
19 | com.canonical.StorageFramework.Registry: |
20 | - @short_description: Interface to query the backend registry |
21 | - |
22 | - Inteface to query the repository of backends that are |
23 | - available. |
24 | + @short_description: Interface to retrieve providers that are configured in online accounts |
25 | --> |
26 | <interface name="com.canonical.StorageFramework.Registry"> |
27 | - |
28 | <!-- |
29 | - GetBackend: |
30 | - @short_description: request access to a storage account |
31 | - @service_id: if not empty, restrict results to accounts |
32 | - matching this service ID. |
33 | - @bus_name: the bus name of the storage provider |
34 | - @path: the object path of the storage account at the provider |
35 | - |
36 | - Interactively prompt the user to pick a storage account for |
37 | - use by the application, and return the D-Bus endpoint that can |
38 | - be used to communicate with the associated provider. |
39 | - |
40 | - As this involves user interaction, the caller should use a |
41 | - relatively long time out for this method call. |
42 | - --> |
43 | - <method name="GetProvider"> |
44 | - <arg type="s" name="service_id" direction="in" /> |
45 | - |
46 | - <arg type="s" name="bus_name" direction="out" /> |
47 | - <arg type="o" name="path" direction="out" /> |
48 | + List: |
49 | + @short_description: Get the list of accounts |
50 | + @accounts: Returned list of accounts. |
51 | + |
52 | + Returns the list of provider accounts that are available |
53 | + in online accounts. In essence, this method is a proxy |
54 | + for the OnlineAccounts::Manager::availableAccounts() method. |
55 | + |
56 | + The returned values are structs with the following members: |
57 | + - bus name (e.g. "com.canonical.StorageFramework.Provider.OwnCloud") |
58 | + - object path (e.g. "/provider/7") |
59 | + - ID (e.g. 7, used for object path) |
60 | + - service ID (e.g. "storage-provider-owncloud") |
61 | + - display name (e.g. "michi.henning@canonical.com") |
62 | + - translated provider name (e.g. "OwnCloud") |
63 | + - icon name |
64 | + --> |
65 | + <method name="ListAccounts"> |
66 | + <arg type="a(soussss)" name="accounts" direction="out"/> |
67 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList<unity::storage::internal::AccountDetails>"/> |
68 | </method> |
69 | </interface> |
70 | </node> |
71 | |
72 | === modified file 'debian/control' |
73 | --- debian/control 2016-11-18 06:03:02 +0000 |
74 | +++ debian/control 2016-11-28 11:06:57 +0000 |
75 | @@ -53,12 +53,24 @@ |
76 | Description: Client library for the Storage Framework (API v1, soon to be removed) |
77 | Runtime support for storage framework clients. |
78 | |
79 | +Package: storage-framework-registry |
80 | +Architecture: any |
81 | +Multi-Arch: foreign |
82 | +Pre-Depends: ${misc:Pre-Depends}, |
83 | +Depends: ${misc:Depends}, |
84 | + ${shlibs:Depends}, |
85 | +# TODO: should be removed once online accounts is fixed: lp:1643421 |
86 | + online-accounts-daemon, |
87 | +Description: Registry for the Storage Framework |
88 | + DBus service that provides access to provider account information. |
89 | + |
90 | Package: libstorage-framework-qt-client-2-0 |
91 | Architecture: any |
92 | Multi-Arch: same |
93 | Pre-Depends: ${misc:Pre-Depends}, |
94 | Depends: ${misc:Depends}, |
95 | ${shlibs:Depends}, |
96 | + storage-framework-registry |
97 | Description: Client library for the Storage Framework |
98 | Runtime support for storage framework clients. |
99 | |
100 | |
101 | === modified file 'debian/control.in' |
102 | --- debian/control.in 2016-11-18 06:03:02 +0000 |
103 | +++ debian/control.in 2016-11-28 11:06:57 +0000 |
104 | @@ -48,12 +48,24 @@ |
105 | Description: Client library for the Storage Framework (API v1, soon to be removed) |
106 | Runtime support for storage framework clients. |
107 | |
108 | +Package: storage-framework-registry |
109 | +Architecture: any |
110 | +Multi-Arch: foreign |
111 | +Pre-Depends: ${misc:Pre-Depends}, |
112 | +Depends: ${misc:Depends}, |
113 | + ${shlibs:Depends}, |
114 | +# TODO: should be removed once online accounts is fixed: lp:1643421 |
115 | + online-accounts-daemon, |
116 | +Description: Registry for the Storage Framework |
117 | + DBus service that provides access to provider account information. |
118 | + |
119 | Package: libstorage-framework-qt-client-2-0 |
120 | Architecture: any |
121 | Multi-Arch: same |
122 | Pre-Depends: ${misc:Pre-Depends}, |
123 | Depends: ${misc:Depends}, |
124 | ${shlibs:Depends}, |
125 | + storage-framework-registry |
126 | Description: Client library for the Storage Framework |
127 | Runtime support for storage framework clients. |
128 | |
129 | |
130 | === added file 'debian/storage-framework-registry.install' |
131 | --- debian/storage-framework-registry.install 1970-01-01 00:00:00 +0000 |
132 | +++ debian/storage-framework-registry.install 2016-11-28 11:06:57 +0000 |
133 | @@ -0,0 +1,2 @@ |
134 | +usr/lib/*/*/storage-framework-registry |
135 | +usr/share/dbus-1/services/com.canonical.StorageFramework.Registry.service |
136 | |
137 | === modified file 'demo/demo.qml' |
138 | --- demo/demo.qml 2016-11-04 10:52:10 +0000 |
139 | +++ demo/demo.qml 2016-11-28 11:06:57 +0000 |
140 | @@ -48,7 +48,7 @@ |
141 | for (var i = 0; i < accounts.length; i++) { |
142 | console.log("Account " + i + ": busName = " + accounts[i].busName()); |
143 | console.log("Account " + i + ": objectPath = " + accounts[i].objectPath()); |
144 | - console.log("Account " + i + ": displayName = " + accounts[i].displayName); |
145 | + console.log("Account " + i + ": name = " + accounts[i].name); |
146 | } |
147 | } |
148 | } |
149 | |
150 | === modified file 'demo/provider_test/provider-test.cpp' |
151 | --- demo/provider_test/provider-test.cpp 2016-11-03 02:43:43 +0000 |
152 | +++ demo/provider_test/provider-test.cpp 2016-11-28 11:06:57 +0000 |
153 | @@ -314,7 +314,7 @@ |
154 | int main(int argc, char **argv) |
155 | { |
156 | const std::string bus_name = "com.canonical.StorageFramework.Provider.ProviderTest"; |
157 | - std::string account_service_id = "google-drive-scope"; |
158 | + std::string account_service_id = "storage-provider-test"; |
159 | if (argc > 1) |
160 | { |
161 | account_service_id = argv[1]; |
162 | |
163 | === added file 'include/unity/storage/internal/AccountDetails.h' |
164 | --- include/unity/storage/internal/AccountDetails.h 1970-01-01 00:00:00 +0000 |
165 | +++ include/unity/storage/internal/AccountDetails.h 2016-11-28 11:06:57 +0000 |
166 | @@ -0,0 +1,60 @@ |
167 | +/* |
168 | + * Copyright (C) 2016 Canonical Ltd |
169 | + * |
170 | + * This program is free software: you can redistribute it and/or modify |
171 | + * it under the terms of the GNU Lesser General Public License version 3 as |
172 | + * published by the Free Software Foundation. |
173 | + * |
174 | + * This program is distributed in the hope that it will be useful, |
175 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
176 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
177 | + * GNU Lesser General Public License for more details. |
178 | + * |
179 | + * You should have received a copy of the GNU Lesser General Public License |
180 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
181 | + * |
182 | + * Authors: Michi Henning <michi.henning@canonical.com> |
183 | + */ |
184 | + |
185 | +#pragma once |
186 | + |
187 | +#pragma GCC diagnostic push |
188 | +#pragma GCC diagnostic ignored "-Wcast-align" |
189 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
190 | +#pragma GCC diagnostic ignored "-Wswitch-default" |
191 | +#include <QDBusArgument> |
192 | +#pragma GCC diagnostic pop |
193 | + |
194 | +namespace unity |
195 | +{ |
196 | +namespace storage |
197 | +{ |
198 | +namespace internal |
199 | +{ |
200 | + |
201 | +struct AccountDetails |
202 | +{ |
203 | + QString busName; |
204 | + QDBusObjectPath objectPath; |
205 | + quint32 id; |
206 | + QString serviceId; |
207 | + QString displayName; |
208 | + QString providerName; |
209 | + QString iconName; |
210 | +}; |
211 | + |
212 | +bool operator==(AccountDetails const& lhs, AccountDetails const& rhs); |
213 | +bool operator!=(AccountDetails const& lhs, AccountDetails const& rhs); |
214 | +bool operator<(AccountDetails const& lhs, AccountDetails const& rhs); |
215 | +bool operator<=(AccountDetails const& lhs, AccountDetails const& rhs); |
216 | +bool operator>(AccountDetails const& lhs, AccountDetails const& rhs); |
217 | +bool operator>=(AccountDetails const& lhs, AccountDetails const& rhs); |
218 | + |
219 | +QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::AccountDetails const& account); |
220 | +QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::AccountDetails& account); |
221 | + |
222 | +} // namespace internal |
223 | +} // namespace storage |
224 | +} // namespace unity |
225 | + |
226 | +Q_DECLARE_METATYPE(unity::storage::internal::AccountDetails) |
227 | |
228 | === added file 'include/unity/storage/internal/ActivityNotifier.h' |
229 | --- include/unity/storage/internal/ActivityNotifier.h 1970-01-01 00:00:00 +0000 |
230 | +++ include/unity/storage/internal/ActivityNotifier.h 2016-11-28 11:06:57 +0000 |
231 | @@ -0,0 +1,57 @@ |
232 | +/* |
233 | + * Copyright (C) 2016 Canonical Ltd |
234 | + * |
235 | + * This program is free software: you can redistribute it and/or modify |
236 | + * it under the terms of the GNU Lesser General Public License version 3 as |
237 | + * published by the Free Software Foundation. |
238 | + * |
239 | + * This program is distributed in the hope that it will be useful, |
240 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
241 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
242 | + * GNU Lesser General Public License for more details. |
243 | + * |
244 | + * You should have received a copy of the GNU Lesser General Public License |
245 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
246 | + * |
247 | + * Authors: Michi Henning <michi.henning@canonical.com> |
248 | + */ |
249 | + |
250 | +#pragma once |
251 | + |
252 | +#include <unity/storage/internal/InactivityTimer.h> |
253 | + |
254 | +#include <cassert> |
255 | +#include <memory> |
256 | + |
257 | +namespace unity |
258 | +{ |
259 | +namespace storage |
260 | +{ |
261 | +namespace internal |
262 | +{ |
263 | + |
264 | +class InactivityTimer; |
265 | + |
266 | +class ActivityNotifier |
267 | +{ |
268 | +public: |
269 | + ActivityNotifier(std::shared_ptr<InactivityTimer> const& timer) |
270 | + : timer_(timer) |
271 | + { |
272 | + assert(timer); |
273 | + |
274 | + timer_->request_started(); |
275 | + } |
276 | + |
277 | + ~ActivityNotifier() |
278 | + { |
279 | + timer_->request_finished(); |
280 | + } |
281 | + |
282 | +private: |
283 | + std::shared_ptr<InactivityTimer> timer_; |
284 | +}; |
285 | + |
286 | +} // namespace internal |
287 | +} // namespace storage |
288 | +} // namespace unity |
289 | |
290 | === added file 'include/unity/storage/internal/EnvVars.h' |
291 | --- include/unity/storage/internal/EnvVars.h 1970-01-01 00:00:00 +0000 |
292 | +++ include/unity/storage/internal/EnvVars.h 2016-11-28 11:06:57 +0000 |
293 | @@ -0,0 +1,51 @@ |
294 | +/* |
295 | + * Copyright (C) 2016 Canonical Ltd |
296 | + * |
297 | + * This program is free software: you can redistribute it and/or modify |
298 | + * it under the terms of the GNU Lesser General Public License version 3 as |
299 | + * published by the Free Software Foundation. |
300 | + * |
301 | + * This program is distributed in the hope that it will be useful, |
302 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
303 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
304 | + * GNU Lesser General Public License for more details. |
305 | + * |
306 | + * You should have received a copy of the GNU Lesser General Public License |
307 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
308 | + * |
309 | + * Authors: Michi Henning <michi.henning@canonical.com> |
310 | + */ |
311 | + |
312 | +#pragma once |
313 | + |
314 | +#include <unity/storage/registry/Registry.h> |
315 | + |
316 | +#include <string> |
317 | + |
318 | +namespace unity |
319 | +{ |
320 | +namespace storage |
321 | +{ |
322 | +namespace internal |
323 | +{ |
324 | + |
325 | +constexpr char const* REGISTRY_IDLE_TIMEOUT = "SF_REGISTRY_IDLE_TIMEOUT"; // Seconds, 0 means "never" |
326 | +constexpr int REGISTRY_IDLE_TIMEOUT_DFLT = 30; |
327 | + |
328 | +// Helper class to make retrieval of environment variables type-safe and |
329 | +// to sanity check the setting, if applicable. Also returns a default |
330 | +// setting, if applicable. |
331 | + |
332 | +class EnvVars |
333 | +{ |
334 | +public: |
335 | + static int registry_timeout_ms(); |
336 | + |
337 | + // Returns value of var_name in the environment, if set, and an empty string otherwise. |
338 | + // Can be used for any environment variable, not just the ones defined above. |
339 | + static std::string get(char const* var_name); |
340 | +}; |
341 | + |
342 | +} // namespace internal |
343 | +} // namespace storage |
344 | +} // namespace unity |
345 | |
346 | === added file 'include/unity/storage/internal/InactivityTimer.h' |
347 | --- include/unity/storage/internal/InactivityTimer.h 1970-01-01 00:00:00 +0000 |
348 | +++ include/unity/storage/internal/InactivityTimer.h 2016-11-28 11:06:57 +0000 |
349 | @@ -0,0 +1,60 @@ |
350 | +/* |
351 | + * Copyright (C) 2016 Canonical Ltd |
352 | + * |
353 | + * This program is free software: you can redistribute it and/or modify |
354 | + * it under the terms of the GNU Lesser General Public License version 3 as |
355 | + * published by the Free Software Foundation. |
356 | + * |
357 | + * This program is distributed in the hope that it will be useful, |
358 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
359 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
360 | + * GNU Lesser General Public License for more details. |
361 | + * |
362 | + * You should have received a copy of the GNU Lesser General Public License |
363 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
364 | + * |
365 | + * Authors: Michi Henning <michi.henning@canonical.com> |
366 | + */ |
367 | + |
368 | +#pragma once |
369 | + |
370 | +#pragma GCC diagnostic push |
371 | +#pragma GCC diagnostic ignored "-Wcast-align" |
372 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
373 | +#pragma GCC diagnostic ignored "-Wswitch-default" |
374 | +#include <QTimer> |
375 | +#pragma GCC diagnostic pop |
376 | + |
377 | +#include <functional> |
378 | + |
379 | +namespace unity |
380 | +{ |
381 | +namespace storage |
382 | +{ |
383 | +namespace internal |
384 | +{ |
385 | + |
386 | +class InactivityTimer : public QObject |
387 | +{ |
388 | + Q_OBJECT |
389 | + |
390 | +public: |
391 | + InactivityTimer(int timeout_ms, std::function<void()> timeout_func); |
392 | + ~InactivityTimer(); |
393 | + |
394 | + void request_started(); |
395 | + void request_finished(); |
396 | + |
397 | +private Q_SLOTS: |
398 | + void timeout(); |
399 | + |
400 | +private: |
401 | + int timeout_ms_; |
402 | + std::function<void()> timeout_func_; |
403 | + QTimer timer_; |
404 | + int32_t num_requests_; |
405 | +}; |
406 | + |
407 | +} // namespace internal |
408 | +} // namespace storage |
409 | +} // namespace unity |
410 | |
411 | === modified file 'include/unity/storage/internal/TraceMessageHandler.h' |
412 | --- include/unity/storage/internal/TraceMessageHandler.h 2016-08-25 05:18:37 +0000 |
413 | +++ include/unity/storage/internal/TraceMessageHandler.h 2016-11-28 11:06:57 +0000 |
414 | @@ -35,7 +35,10 @@ |
415 | class TraceMessageHandler final |
416 | { |
417 | public: |
418 | + TraceMessageHandler(); |
419 | TraceMessageHandler(std::string const& prog_name); |
420 | + TraceMessageHandler(QString const& prog_name); |
421 | + TraceMessageHandler(char const* prog_name); |
422 | ~TraceMessageHandler(); |
423 | |
424 | private: |
425 | |
426 | === modified file 'include/unity/storage/qt/Account.h' |
427 | --- include/unity/storage/qt/Account.h 2016-11-03 06:41:00 +0000 |
428 | +++ include/unity/storage/qt/Account.h 2016-11-28 11:06:57 +0000 |
429 | @@ -47,6 +47,8 @@ |
430 | Q_PROPERTY(QString busName READ busName FINAL) |
431 | Q_PROPERTY(QString objectPath READ objectPath FINAL) |
432 | Q_PROPERTY(QString displayName READ displayName FINAL) |
433 | + Q_PROPERTY(QString providerName READ providerName FINAL) |
434 | + Q_PROPERTY(QString iconName READ iconName FINAL) |
435 | |
436 | public: |
437 | Account(); |
438 | @@ -60,7 +62,8 @@ |
439 | QString busName() const; |
440 | QString objectPath() const; |
441 | QString displayName() const; |
442 | - // TODO: add more methods to retrieve additional info, such as description, icon ID, and service name. |
443 | + QString providerName() const; |
444 | + QString iconName() const; |
445 | |
446 | Q_INVOKABLE unity::storage::qt::ItemListJob* roots(QStringList const& keys = QStringList()) const; |
447 | Q_INVOKABLE unity::storage::qt::ItemJob* get(QString const& itemId, QStringList const& keys = QStringList()) const; |
448 | |
449 | === modified file 'include/unity/storage/qt/AccountsJob.h' |
450 | --- include/unity/storage/qt/AccountsJob.h 2016-11-02 02:54:48 +0000 |
451 | +++ include/unity/storage/qt/AccountsJob.h 2016-11-28 11:06:57 +0000 |
452 | @@ -34,12 +34,10 @@ |
453 | { |
454 | |
455 | class AccountsJobImpl; |
456 | -class RuntimeImpl; |
457 | |
458 | } // namespace internal |
459 | |
460 | class Account; |
461 | -class Runtime; |
462 | class StorageError; |
463 | |
464 | class Q_DECL_EXPORT AccountsJob final : public QObject |
465 | @@ -65,14 +63,13 @@ |
466 | void statusChanged(unity::storage::qt::AccountsJob::Status status) const; |
467 | |
468 | private: |
469 | - AccountsJob(std::shared_ptr<internal::RuntimeImpl> const& runtime); |
470 | - AccountsJob(StorageError const& error); |
471 | + AccountsJob(std::unique_ptr<internal::AccountsJobImpl> accounts_job_impl); |
472 | |
473 | QVariantList accountsAsVariantList() const; |
474 | |
475 | std::unique_ptr<internal::AccountsJobImpl> const p_; |
476 | |
477 | - friend class internal::RuntimeImpl; |
478 | + friend class internal::AccountsJobImpl; |
479 | }; |
480 | |
481 | } // namespace qt |
482 | |
483 | === modified file 'include/unity/storage/qt/Runtime.h' |
484 | --- include/unity/storage/qt/Runtime.h 2016-11-02 02:54:48 +0000 |
485 | +++ include/unity/storage/qt/Runtime.h 2016-11-28 11:06:57 +0000 |
486 | @@ -66,9 +66,9 @@ |
487 | |
488 | Account make_test_account(QString const& bus_name, |
489 | QString const& object_path, |
490 | - QString const& id = "", |
491 | - QString const& serviceId = "", |
492 | - QString const& displayName = "") const; |
493 | + quint32 id = 999, |
494 | + QString const& service_id = "", |
495 | + QString const& name = "") const; |
496 | |
497 | private: |
498 | std::shared_ptr<internal::RuntimeImpl> p_; |
499 | |
500 | === modified file 'include/unity/storage/qt/internal/AccountImpl.h' |
501 | --- include/unity/storage/qt/internal/AccountImpl.h 2016-11-03 06:41:00 +0000 |
502 | +++ include/unity/storage/qt/internal/AccountImpl.h 2016-11-28 11:06:57 +0000 |
503 | @@ -19,10 +19,7 @@ |
504 | #pragma once |
505 | |
506 | #include <unity/storage/qt/Item.h> |
507 | - |
508 | -#include <QString> |
509 | - |
510 | -#include <memory> |
511 | +#include <unity/storage/internal/AccountDetails.h> |
512 | |
513 | class ProviderInterface; |
514 | |
515 | @@ -50,6 +47,8 @@ |
516 | QString busName() const; |
517 | QString objectPath() const; |
518 | QString displayName() const; |
519 | + QString providerName() const; |
520 | + QString iconName() const; |
521 | |
522 | ItemListJob* roots(QStringList const& keys) const; |
523 | ItemJob* get(QString const& itemId, QStringList const& keys) const; |
524 | @@ -67,26 +66,14 @@ |
525 | std::shared_ptr<ProviderInterface> provider() const; |
526 | |
527 | static Account make_account(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
528 | - QString const& bus_name, |
529 | - QString const& object_path, |
530 | - QString const& id, |
531 | - QString const& service_id, |
532 | - QString const& display_name); |
533 | + storage::internal::AccountDetails const& details); |
534 | |
535 | private: |
536 | AccountImpl(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
537 | - QString const& bus_name, |
538 | - QString const& object_path, |
539 | - QString const& id, |
540 | - QString const& service_id, |
541 | - QString const& display_name); |
542 | + storage::internal::AccountDetails const& details); |
543 | |
544 | bool is_valid_; |
545 | - QString bus_name_; |
546 | - QString object_path_; |
547 | - QString id_; |
548 | - QString service_id_; |
549 | - QString display_name_; |
550 | + storage::internal::AccountDetails details_; |
551 | std::weak_ptr<RuntimeImpl> runtime_impl_; |
552 | std::shared_ptr<ProviderInterface> provider_; |
553 | |
554 | |
555 | === modified file 'include/unity/storage/qt/internal/AccountsJobImpl.h' |
556 | --- include/unity/storage/qt/internal/AccountsJobImpl.h 2016-11-02 02:54:48 +0000 |
557 | +++ include/unity/storage/qt/internal/AccountsJobImpl.h 2016-11-28 11:06:57 +0000 |
558 | @@ -18,9 +18,14 @@ |
559 | |
560 | #pragma once |
561 | |
562 | +#include <unity/storage/internal/AccountDetails.h> |
563 | #include <unity/storage/qt/AccountsJob.h> |
564 | |
565 | -#include <QTimer> |
566 | +#pragma GCC diagnostic push |
567 | +#pragma GCC diagnostic ignored "-Wcast-align" |
568 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
569 | +#include <QDBusPendingReply> |
570 | +#pragma GCC diagnostic pop |
571 | |
572 | namespace unity |
573 | { |
574 | @@ -31,12 +36,16 @@ |
575 | namespace internal |
576 | { |
577 | |
578 | +class RuntimeImpl; |
579 | + |
580 | class AccountsJobImpl : public QObject |
581 | { |
582 | Q_OBJECT |
583 | public: |
584 | - AccountsJobImpl(AccountsJob* public_instance, std::shared_ptr<RuntimeImpl> const& runtime_impl); |
585 | - AccountsJobImpl(AccountsJob* public_instance, StorageError const& error); |
586 | + AccountsJobImpl(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
587 | + QString const& method, |
588 | + QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply); |
589 | + AccountsJobImpl(StorageError const& error); |
590 | virtual ~AccountsJobImpl() = default; |
591 | |
592 | bool isValid() const; |
593 | @@ -45,21 +54,20 @@ |
594 | QList<Account> accounts() const; |
595 | QVariantList accountsAsVariantList() const; |
596 | |
597 | -private Q_SLOTS: |
598 | - void manager_ready(); |
599 | - void timeout(); |
600 | + static AccountsJob* make_job(std::shared_ptr<RuntimeImpl> const& runtime_impl, |
601 | + QString const& method, |
602 | + QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply); |
603 | + static AccountsJob* make_job(StorageError const& e); |
604 | |
605 | private: |
606 | std::shared_ptr<RuntimeImpl> get_runtime_impl(QString const& method) const; |
607 | - void initialize_accounts(); |
608 | AccountsJob::Status emit_status_changed(AccountsJob::Status new_status) const; |
609 | |
610 | - AccountsJob* const public_instance_; |
611 | + AccountsJob* public_instance_; |
612 | AccountsJob::Status status_; |
613 | StorageError error_; |
614 | - QList<unity::storage::qt::Account> accounts_; |
615 | std::weak_ptr<RuntimeImpl> const runtime_impl_; |
616 | - QTimer timer_; |
617 | + QList<Account> accounts_; |
618 | |
619 | friend class unity::storage::qt::AccountsJob; |
620 | }; |
621 | |
622 | === modified file 'include/unity/storage/qt/internal/Handler.h' |
623 | --- include/unity/storage/qt/internal/Handler.h 2016-11-04 04:13:45 +0000 |
624 | +++ include/unity/storage/qt/internal/Handler.h 2016-11-28 11:06:57 +0000 |
625 | @@ -71,7 +71,7 @@ |
626 | case StorageError::Type::NoError: |
627 | { |
628 | // LCOV_EXCL_START |
629 | - QString msg = "impossible provider exception: " + e.errorString(); |
630 | + QString msg = "impossible service exception: " + e.errorString(); |
631 | qCritical().noquote() << msg; |
632 | e = StorageErrorImpl::local_comms_error(msg); |
633 | break; |
634 | @@ -82,7 +82,7 @@ |
635 | case StorageError::Type::ResourceError: |
636 | { |
637 | // Log these errors because they are unexpected. |
638 | - QString msg = "provider exception: " + e.errorString(); |
639 | + QString msg = "service exception: " + e.errorString(); |
640 | qCritical().noquote() << msg; |
641 | break; |
642 | } |
643 | |
644 | === modified file 'include/unity/storage/qt/internal/RuntimeImpl.h' |
645 | --- include/unity/storage/qt/internal/RuntimeImpl.h 2016-09-22 01:52:20 +0000 |
646 | +++ include/unity/storage/qt/internal/RuntimeImpl.h 2016-11-28 11:06:57 +0000 |
647 | @@ -24,10 +24,11 @@ |
648 | #pragma GCC diagnostic push |
649 | #pragma GCC diagnostic ignored "-Wcast-align" |
650 | #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
651 | -#include <OnlineAccounts/Manager> |
652 | #include <QDBusConnection> |
653 | #pragma GCC diagnostic pop |
654 | |
655 | +class RegistryInterface; |
656 | + |
657 | namespace unity |
658 | { |
659 | namespace storage |
660 | @@ -45,7 +46,7 @@ |
661 | { |
662 | public: |
663 | RuntimeImpl(); |
664 | - RuntimeImpl(QDBusConnection const& bus); |
665 | + RuntimeImpl(QDBusConnection const& conn); |
666 | RuntimeImpl(RuntimeImpl const&) = delete; |
667 | RuntimeImpl(RuntimeImpl&&) = delete; |
668 | ~RuntimeImpl(); |
669 | @@ -58,19 +59,17 @@ |
670 | AccountsJob* accounts() const; |
671 | StorageError shutdown(); |
672 | |
673 | - std::shared_ptr<OnlineAccounts::Manager> accounts_manager() const; |
674 | - |
675 | Account make_test_account(QString const& bus_name, |
676 | QString const& object_path, |
677 | - QString const& owner_id, |
678 | - QString const& owner, |
679 | - QString const& description); |
680 | + quint32 id, |
681 | + QString const& service_id, |
682 | + QString const& display_name); |
683 | |
684 | private: |
685 | bool is_valid_; |
686 | StorageError error_; |
687 | QDBusConnection conn_; |
688 | - std::shared_ptr<OnlineAccounts::Manager> accounts_manager_; |
689 | + std::unique_ptr<RegistryInterface> registry_; |
690 | |
691 | friend class unity::storage::qt::Runtime; |
692 | }; |
693 | |
694 | === added directory 'include/unity/storage/registry' |
695 | === added file 'include/unity/storage/registry/Registry.h' |
696 | --- include/unity/storage/registry/Registry.h 1970-01-01 00:00:00 +0000 |
697 | +++ include/unity/storage/registry/Registry.h 2016-11-28 11:06:57 +0000 |
698 | @@ -0,0 +1,35 @@ |
699 | +/* |
700 | + * Copyright (C) 2016 Canonical Ltd |
701 | + * |
702 | + * This program is free software: you can redistribute it and/or modify |
703 | + * it under the terms of the GNU Lesser General Public License version 3 as |
704 | + * published by the Free Software Foundation. |
705 | + * |
706 | + * This program is distributed in the hope that it will be useful, |
707 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
708 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
709 | + * GNU Lesser General Public License for more details. |
710 | + * |
711 | + * You should have received a copy of the GNU Lesser General Public License |
712 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
713 | + * |
714 | + * Authors: Michi Henning <michi.henning@canonical.com> |
715 | + */ |
716 | + |
717 | +#pragma once |
718 | + |
719 | +#include <QString> |
720 | + |
721 | +namespace unity |
722 | +{ |
723 | +namespace storage |
724 | +{ |
725 | +namespace registry |
726 | +{ |
727 | + |
728 | +static QString const BUS_NAME(QStringLiteral("com.canonical.StorageFramework.Registry")); |
729 | +static QString const OBJECT_PATH(QStringLiteral("/com/canonical/StorageFramework/Registry")); |
730 | + |
731 | +} // namespace registry |
732 | +} // namespace storage |
733 | +} // namespace unity |
734 | |
735 | === added directory 'include/unity/storage/registry/internal' |
736 | === added file 'include/unity/storage/registry/internal/ListAccountsHandler.h' |
737 | --- include/unity/storage/registry/internal/ListAccountsHandler.h 1970-01-01 00:00:00 +0000 |
738 | +++ include/unity/storage/registry/internal/ListAccountsHandler.h 2016-11-28 11:06:57 +0000 |
739 | @@ -0,0 +1,70 @@ |
740 | +/* |
741 | + * Copyright (C) 2016 Canonical Ltd |
742 | + * |
743 | + * This program is free software: you can redistribute it and/or modify |
744 | + * it under the terms of the GNU Lesser General Public License version 3 as |
745 | + * published by the Free Software Foundation. |
746 | + * |
747 | + * This program is distributed in the hope that it will be useful, |
748 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
749 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
750 | + * GNU Lesser General Public License for more details. |
751 | + * |
752 | + * You should have received a copy of the GNU Lesser General Public License |
753 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
754 | + * |
755 | + * Authors: Michi Henning <michi.henning@canonical.com> |
756 | + */ |
757 | + |
758 | +#pragma once |
759 | + |
760 | +#include <unity/storage/internal/ActivityNotifier.h> |
761 | + |
762 | +#pragma GCC diagnostic push |
763 | +#pragma GCC diagnostic ignored "-Wcast-align" |
764 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
765 | +#include <OnlineAccounts/Manager> |
766 | +#include <QDBusConnection> |
767 | +#include <QDBusMessage> |
768 | +#include <QTimer> |
769 | +#pragma GCC diagnostic pop |
770 | + |
771 | +namespace unity |
772 | +{ |
773 | +namespace storage |
774 | +{ |
775 | +namespace registry |
776 | +{ |
777 | +namespace internal |
778 | +{ |
779 | + |
780 | +class ListAccountsHandler : public QObject |
781 | +{ |
782 | + Q_OBJECT |
783 | + |
784 | +public: |
785 | + ListAccountsHandler(QDBusConnection const& conn, |
786 | + QDBusMessage const& msg, |
787 | + std::shared_ptr<storage::internal::InactivityTimer> const& timer); |
788 | + ~ListAccountsHandler(); |
789 | + |
790 | +private Q_SLOTS: |
791 | + void manager_ready(); |
792 | + void timeout(); |
793 | + |
794 | +private: |
795 | + void initialize_manager(); |
796 | + |
797 | + QDBusConnection const conn_; |
798 | + QDBusMessage const msg_; |
799 | + OnlineAccounts::Manager manager_; |
800 | + QTimer timer_; |
801 | + storage::internal::ActivityNotifier activity_notifier_; // RAII guard variable |
802 | + |
803 | + Q_DISABLE_COPY(ListAccountsHandler) |
804 | +}; |
805 | + |
806 | +} // namespace internal |
807 | +} // namespace registry |
808 | +} // namespace storage |
809 | +} // namespace unity |
810 | |
811 | === added file 'include/unity/storage/registry/internal/RegistryAdaptor.h' |
812 | --- include/unity/storage/registry/internal/RegistryAdaptor.h 1970-01-01 00:00:00 +0000 |
813 | +++ include/unity/storage/registry/internal/RegistryAdaptor.h 2016-11-28 11:06:57 +0000 |
814 | @@ -0,0 +1,71 @@ |
815 | +/* |
816 | + * Copyright (C) 2016 Canonical Ltd |
817 | + * |
818 | + * This program is free software: you can redistribute it and/or modify |
819 | + * it under the terms of the GNU Lesser General Public License version 3 as |
820 | + * published by the Free Software Foundation. |
821 | + * |
822 | + * This program is distributed in the hope that it will be useful, |
823 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
824 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
825 | + * GNU Lesser General Public License for more details. |
826 | + * |
827 | + * You should have received a copy of the GNU Lesser General Public License |
828 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
829 | + * |
830 | + * Authors: Michi Henning <michi.henning@canonical.com> |
831 | + */ |
832 | + |
833 | +#pragma once |
834 | + |
835 | +#include <unity/storage/internal/AccountDetails.h> |
836 | + |
837 | +#pragma GCC diagnostic push |
838 | +#pragma GCC diagnostic ignored "-Wcast-align" |
839 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
840 | +#include <QDBusConnection> |
841 | +#include <QDBusContext> |
842 | +#pragma GCC diagnostic pop |
843 | + |
844 | +#include <memory> |
845 | + |
846 | +namespace unity |
847 | +{ |
848 | +namespace storage |
849 | +{ |
850 | +namespace internal |
851 | +{ |
852 | + |
853 | +class InactivityTimer; |
854 | + |
855 | +} // namespace internal |
856 | + |
857 | +namespace registry |
858 | +{ |
859 | +namespace internal |
860 | +{ |
861 | + |
862 | +class RegistryAdaptor : public QObject, protected QDBusContext |
863 | +{ |
864 | + Q_OBJECT |
865 | + |
866 | +public: |
867 | + RegistryAdaptor(QDBusConnection const& conn, |
868 | + std::shared_ptr<storage::internal::InactivityTimer> const& timer, |
869 | + QObject* parent = nullptr); |
870 | + ~RegistryAdaptor(); |
871 | + |
872 | +public Q_SLOTS: |
873 | + QList<unity::storage::internal::AccountDetails> ListAccounts(); |
874 | + |
875 | +private: |
876 | + QDBusConnection conn_; |
877 | + std::shared_ptr<storage::internal::InactivityTimer> timer_; |
878 | + |
879 | + Q_DISABLE_COPY(RegistryAdaptor) |
880 | +}; |
881 | + |
882 | +} // namespace internal |
883 | +} // namespace registry |
884 | +} // namespace storage |
885 | +} // namespace unity |
886 | |
887 | === added file 'include/unity/storage/registry/internal/qdbus-last-error-msg.h' |
888 | --- include/unity/storage/registry/internal/qdbus-last-error-msg.h 1970-01-01 00:00:00 +0000 |
889 | +++ include/unity/storage/registry/internal/qdbus-last-error-msg.h 2016-11-28 11:06:57 +0000 |
890 | @@ -0,0 +1,41 @@ |
891 | +/* |
892 | + * Copyright (C) 2016 Canonical Ltd |
893 | + * |
894 | + * This program is free software: you can redistribute it and/or modify |
895 | + * it under the terms of the GNU Lesser General Public License version 3 as |
896 | + * published by the Free Software Foundation. |
897 | + * |
898 | + * This program is distributed in the hope that it will be useful, |
899 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
900 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
901 | + * GNU Lesser General Public License for more details. |
902 | + * |
903 | + * You should have received a copy of the GNU Lesser General Public License |
904 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
905 | + * |
906 | + * Authors: Michi Henning <michi.henning@canonical.com> |
907 | + */ |
908 | + |
909 | +#pragma once |
910 | + |
911 | +#pragma GCC diagnostic push |
912 | +#pragma GCC diagnostic ignored "-Wcast-align" |
913 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
914 | +#include <QDBusConnection> |
915 | +#pragma GCC diagnostic pop |
916 | + |
917 | +namespace unity |
918 | +{ |
919 | +namespace storage |
920 | +{ |
921 | +namespace registry |
922 | +{ |
923 | +namespace internal |
924 | +{ |
925 | + |
926 | +QString last_error_msg(QDBusConnection const& conn); |
927 | + |
928 | +} // namespace internal |
929 | +} // namespace registry |
930 | +} // namespace storage |
931 | +} // namespace unity |
932 | |
933 | === modified file 'src/CMakeLists.txt' |
934 | --- src/CMakeLists.txt 2016-07-06 00:59:42 +0000 |
935 | +++ src/CMakeLists.txt 2016-11-28 11:06:57 +0000 |
936 | @@ -1,3 +1,4 @@ |
937 | add_subdirectory(internal) |
938 | add_subdirectory(provider) |
939 | add_subdirectory(qt) |
940 | +add_subdirectory(registry) |
941 | |
942 | === added file 'src/internal/AccountDetails.cpp' |
943 | --- src/internal/AccountDetails.cpp 1970-01-01 00:00:00 +0000 |
944 | +++ src/internal/AccountDetails.cpp 2016-11-28 11:06:57 +0000 |
945 | @@ -0,0 +1,108 @@ |
946 | +/* |
947 | + * Copyright (C) 2016 Canonical Ltd |
948 | + * |
949 | + * This program is free software: you can redistribute it and/or modify |
950 | + * it under the terms of the GNU Lesser General Public License version 3 as |
951 | + * published by the Free Software Foundation. |
952 | + * |
953 | + * This program is distributed in the hope that it will be useful, |
954 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
955 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
956 | + * GNU Lesser General Public License for more details. |
957 | + * |
958 | + * You should have received a copy of the GNU Lesser General Public License |
959 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
960 | + * |
961 | + * Authors: Michi Henning <michi.henning@canonical.com> |
962 | + */ |
963 | + |
964 | +#include <unity/storage/internal/AccountDetails.h> |
965 | + |
966 | +using namespace unity::storage::internal; |
967 | + |
968 | +namespace unity |
969 | +{ |
970 | +namespace storage |
971 | +{ |
972 | +namespace internal |
973 | +{ |
974 | + |
975 | +bool operator==(AccountDetails const& lhs, AccountDetails const& rhs) |
976 | +{ |
977 | + return lhs.id == rhs.id |
978 | + && lhs.serviceId == rhs.serviceId |
979 | + && lhs.displayName == rhs.displayName; |
980 | +} |
981 | + |
982 | +bool operator!=(AccountDetails const& lhs, AccountDetails const& rhs) |
983 | +{ |
984 | + return !(lhs == rhs); |
985 | +} |
986 | + |
987 | +bool operator<(AccountDetails const& lhs, AccountDetails const& rhs) |
988 | +{ |
989 | + if (lhs.id < rhs.id) |
990 | + { |
991 | + return true; |
992 | + } |
993 | + if (lhs.id > rhs.id) |
994 | + { |
995 | + return false; |
996 | + } |
997 | + if (lhs.serviceId < rhs.serviceId) |
998 | + { |
999 | + return true; |
1000 | + } |
1001 | + if (lhs.serviceId > rhs.serviceId) |
1002 | + { |
1003 | + return false; |
1004 | + } |
1005 | + return lhs.displayName < rhs.displayName; |
1006 | +} |
1007 | + |
1008 | +bool operator<=(AccountDetails const& lhs, AccountDetails const& rhs) |
1009 | +{ |
1010 | + return lhs < rhs || lhs == rhs; |
1011 | +} |
1012 | + |
1013 | +bool operator>(AccountDetails const& lhs, AccountDetails const& rhs) |
1014 | +{ |
1015 | + return !(lhs <= rhs); |
1016 | +} |
1017 | + |
1018 | +bool operator>=(AccountDetails const& lhs, AccountDetails const& rhs) |
1019 | +{ |
1020 | + return !(lhs < rhs); |
1021 | +} |
1022 | + |
1023 | +QDBusArgument& operator<<(QDBusArgument& argument, storage::internal::AccountDetails const& account) |
1024 | +{ |
1025 | + argument.beginStructure(); |
1026 | + argument << account.busName; |
1027 | + argument << account.objectPath; |
1028 | + argument << account.id; |
1029 | + argument << account.serviceId; |
1030 | + argument << account.displayName; |
1031 | + argument << account.providerName; |
1032 | + argument << account.iconName; |
1033 | + argument.endStructure(); |
1034 | + return argument; |
1035 | +} |
1036 | + |
1037 | +QDBusArgument const& operator>>(QDBusArgument const& argument, storage::internal::AccountDetails& account) |
1038 | +{ |
1039 | + argument.beginStructure(); |
1040 | + argument >> account.busName; |
1041 | + argument >> account.objectPath; |
1042 | + argument >> account.id; |
1043 | + argument >> account.serviceId; |
1044 | + argument >> account.displayName; |
1045 | + argument >> account.providerName; |
1046 | + argument >> account.iconName; |
1047 | + argument.endStructure(); |
1048 | + return argument; |
1049 | +} |
1050 | + |
1051 | +} // namespace internal |
1052 | +} // namespace storage |
1053 | +} // namespace unity |
1054 | |
1055 | === modified file 'src/internal/CMakeLists.txt' |
1056 | --- src/internal/CMakeLists.txt 2016-08-12 06:19:22 +0000 |
1057 | +++ src/internal/CMakeLists.txt 2016-11-28 11:06:57 +0000 |
1058 | @@ -1,10 +1,18 @@ |
1059 | set(src |
1060 | + AccountDetails.cpp |
1061 | dbusmarshal.cpp |
1062 | + EnvVars.cpp |
1063 | + InactivityTimer.cpp |
1064 | safe_strerror.cpp |
1065 | TraceMessageHandler.cpp |
1066 | + ${CMAKE_SOURCE_DIR}/include/unity/storage/internal/InactivityTimer.h |
1067 | ) |
1068 | |
1069 | + |
1070 | add_library(storage-framework-common-internal STATIC ${src}) |
1071 | + |
1072 | +set_target_properties(storage-framework-common-internal PROPERTIES AUTOMOC TRUE) |
1073 | + |
1074 | target_link_libraries(storage-framework-common-internal |
1075 | Qt5::DBus |
1076 | ) |
1077 | |
1078 | === added file 'src/internal/EnvVars.cpp' |
1079 | --- src/internal/EnvVars.cpp 1970-01-01 00:00:00 +0000 |
1080 | +++ src/internal/EnvVars.cpp 2016-11-28 11:06:57 +0000 |
1081 | @@ -0,0 +1,81 @@ |
1082 | +/* |
1083 | + * Copyright (C) 2016 Canonical Ltd |
1084 | + * |
1085 | + * This program is free software: you can redistribute it and/or modify |
1086 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1087 | + * published by the Free Software Foundation. |
1088 | + * |
1089 | + * This program is distributed in the hope that it will be useful, |
1090 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1091 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1092 | + * GNU Lesser General Public License for more details. |
1093 | + * |
1094 | + * You should have received a copy of the GNU Lesser General Public License |
1095 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1096 | + * |
1097 | + * Authors: Michi Henning <michi.henning@canonical.com> |
1098 | + */ |
1099 | + |
1100 | +#include <unity/storage/internal/EnvVars.h> |
1101 | + |
1102 | +#include <cassert> |
1103 | +#include <QDebug> |
1104 | + |
1105 | +#include <stdlib.h> |
1106 | + |
1107 | +using namespace std; |
1108 | + |
1109 | +namespace unity |
1110 | +{ |
1111 | +namespace storage |
1112 | +{ |
1113 | +namespace internal |
1114 | +{ |
1115 | + |
1116 | +int EnvVars::registry_timeout_ms() |
1117 | +{ |
1118 | + int const dflt_val = REGISTRY_IDLE_TIMEOUT_DFLT * 1000; |
1119 | + |
1120 | + auto const val = get(REGISTRY_IDLE_TIMEOUT); |
1121 | + if (val.empty()) |
1122 | + { |
1123 | + return dflt_val; |
1124 | + } |
1125 | + try |
1126 | + { |
1127 | + size_t pos; |
1128 | + auto int_val = stoi(val, &pos); |
1129 | + if (pos != val.size()) |
1130 | + { |
1131 | + throw invalid_argument("unexpected trailing character(s)"); |
1132 | + } |
1133 | + if (int_val < 0) |
1134 | + { |
1135 | + throw invalid_argument("value must be >= 0"); |
1136 | + } |
1137 | + return int_val; |
1138 | + } |
1139 | + catch (std::exception const& e) |
1140 | + { |
1141 | + qWarning().noquote().nospace() << "Invalid setting of env var " << QString::fromStdString(REGISTRY_IDLE_TIMEOUT) |
1142 | + << " (\"" << QString::fromStdString(val) << "\"): " << e.what(); |
1143 | + qWarning().nospace() << "Using default value of " << REGISTRY_IDLE_TIMEOUT_DFLT; |
1144 | + } |
1145 | + return dflt_val; |
1146 | +} |
1147 | + |
1148 | +string EnvVars::get(char const* var_name) |
1149 | +{ |
1150 | + assert(var_name != nullptr); |
1151 | + |
1152 | + auto p = getenv(var_name); |
1153 | + if (!p) |
1154 | + { |
1155 | + return string(); |
1156 | + } |
1157 | + return string(p); |
1158 | +} |
1159 | + |
1160 | +} // namespace internal |
1161 | +} // namespace storage |
1162 | +} // namespace unity |
1163 | |
1164 | === added file 'src/internal/InactivityTimer.cpp' |
1165 | --- src/internal/InactivityTimer.cpp 1970-01-01 00:00:00 +0000 |
1166 | +++ src/internal/InactivityTimer.cpp 2016-11-28 11:06:57 +0000 |
1167 | @@ -0,0 +1,82 @@ |
1168 | +/* |
1169 | + * Copyright (C) 2016 Canonical Ltd |
1170 | + * |
1171 | + * This program is free software: you can redistribute it and/or modify |
1172 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1173 | + * published by the Free Software Foundation. |
1174 | + * |
1175 | + * This program is distributed in the hope that it will be useful, |
1176 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1177 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1178 | + * GNU Lesser General Public License for more details. |
1179 | + * |
1180 | + * You should have received a copy of the GNU Lesser General Public License |
1181 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1182 | + * |
1183 | + * Authors: Michi Henning <michi.henning@canonical.com> |
1184 | + */ |
1185 | + |
1186 | +#include <unity/storage/internal/InactivityTimer.h> |
1187 | + |
1188 | +#include <QDebug> |
1189 | + |
1190 | +#include <cassert> |
1191 | + |
1192 | +namespace unity |
1193 | +{ |
1194 | +namespace storage |
1195 | +{ |
1196 | +namespace internal |
1197 | +{ |
1198 | + |
1199 | +InactivityTimer::InactivityTimer(int timeout_ms, std::function<void()> timeout_func) |
1200 | + : timeout_ms_(timeout_ms) |
1201 | + , timeout_func_(timeout_func) |
1202 | + , num_requests_(0) |
1203 | +{ |
1204 | + assert(timeout_ms_ >= 0); |
1205 | + assert(timeout_func); |
1206 | + |
1207 | + connect(&timer_, &QTimer::timeout, this, &InactivityTimer::timeout); |
1208 | +} |
1209 | + |
1210 | +InactivityTimer::~InactivityTimer() = default; |
1211 | + |
1212 | +void InactivityTimer::request_started() |
1213 | +{ |
1214 | + assert(num_requests_ >= 0); |
1215 | + |
1216 | + if (num_requests_++ == 0) |
1217 | + { |
1218 | + timer_.stop(); |
1219 | + } |
1220 | +} |
1221 | + |
1222 | +void InactivityTimer::request_finished() |
1223 | +{ |
1224 | + assert(num_requests_ > 0); |
1225 | + |
1226 | + if (--num_requests_ == 0) |
1227 | + { |
1228 | + timer_.start(timeout_ms_); |
1229 | + } |
1230 | +} |
1231 | + |
1232 | +void InactivityTimer::timeout() |
1233 | +{ |
1234 | + timer_.stop(); |
1235 | + disconnect(this); |
1236 | + try |
1237 | + { |
1238 | + timeout_func_(); |
1239 | + } |
1240 | + catch (std::exception const& e) |
1241 | + { |
1242 | + auto msg = QString("InactivityTimer::timeout(): exception from timeout callback: ") + e.what(); |
1243 | + qWarning().nospace() << msg; |
1244 | + } |
1245 | +} |
1246 | + |
1247 | +} // namespace internal |
1248 | +} // namespace storage |
1249 | +} // namespace unity |
1250 | |
1251 | === modified file 'src/internal/TraceMessageHandler.cpp' |
1252 | --- src/internal/TraceMessageHandler.cpp 2016-08-12 06:19:22 +0000 |
1253 | +++ src/internal/TraceMessageHandler.cpp 2016-11-28 11:06:57 +0000 |
1254 | @@ -80,10 +80,27 @@ |
1255 | |
1256 | } // namespace |
1257 | |
1258 | +TraceMessageHandler::TraceMessageHandler() |
1259 | + : old_message_handler_(qInstallMessageHandler(trace_message_handler)) |
1260 | +{ |
1261 | +} |
1262 | + |
1263 | TraceMessageHandler::TraceMessageHandler(string const& prog_name) |
1264 | -{ |
1265 | - prefix = prog_name; |
1266 | - old_message_handler_ = qInstallMessageHandler(trace_message_handler); |
1267 | + : TraceMessageHandler() |
1268 | +{ |
1269 | + prefix = prog_name; |
1270 | +} |
1271 | + |
1272 | +TraceMessageHandler::TraceMessageHandler(QString const& prog_name) |
1273 | + : TraceMessageHandler() |
1274 | +{ |
1275 | + prefix = prog_name.toStdString(); |
1276 | +} |
1277 | + |
1278 | +TraceMessageHandler::TraceMessageHandler(char const* prog_name) |
1279 | + : TraceMessageHandler() |
1280 | +{ |
1281 | + prefix = prog_name; |
1282 | } |
1283 | |
1284 | TraceMessageHandler::~TraceMessageHandler() |
1285 | |
1286 | === modified file 'src/qt/Account.cpp' |
1287 | --- src/qt/Account.cpp 2016-11-03 06:41:00 +0000 |
1288 | +++ src/qt/Account.cpp 2016-11-28 11:06:57 +0000 |
1289 | @@ -93,6 +93,16 @@ |
1290 | return p_->displayName(); |
1291 | } |
1292 | |
1293 | +QString Account::providerName() const |
1294 | +{ |
1295 | + return p_->providerName(); |
1296 | +} |
1297 | + |
1298 | +QString Account::iconName() const |
1299 | +{ |
1300 | + return p_->iconName(); |
1301 | +} |
1302 | + |
1303 | ItemListJob* Account::roots(QStringList const& keys) const |
1304 | { |
1305 | return p_->roots(keys); |
1306 | |
1307 | === modified file 'src/qt/AccountsJob.cpp' |
1308 | --- src/qt/AccountsJob.cpp 2016-11-02 02:54:48 +0000 |
1309 | +++ src/qt/AccountsJob.cpp 2016-11-28 11:06:57 +0000 |
1310 | @@ -18,7 +18,6 @@ |
1311 | |
1312 | #include <unity/storage/qt/AccountsJob.h> |
1313 | |
1314 | -#include <unity/storage/qt/Account.h> |
1315 | #include <unity/storage/qt/internal/AccountsJobImpl.h> |
1316 | |
1317 | #include <QVariant> |
1318 | @@ -33,13 +32,8 @@ |
1319 | namespace qt |
1320 | { |
1321 | |
1322 | -AccountsJob::AccountsJob(shared_ptr<internal::RuntimeImpl> const& runtime) |
1323 | - : p_(new internal::AccountsJobImpl(this, runtime)) |
1324 | -{ |
1325 | -} |
1326 | - |
1327 | -AccountsJob::AccountsJob(StorageError const& error) |
1328 | - : p_(new internal::AccountsJobImpl(this, error)) |
1329 | +AccountsJob::AccountsJob(unique_ptr<internal::AccountsJobImpl> accounts_job_impl) |
1330 | + : p_(move(accounts_job_impl)) |
1331 | { |
1332 | } |
1333 | |
1334 | |
1335 | === modified file 'src/qt/CMakeLists.txt' |
1336 | --- src/qt/CMakeLists.txt 2016-10-12 08:08:48 +0000 |
1337 | +++ src/qt/CMakeLists.txt 2016-11-28 11:06:57 +0000 |
1338 | @@ -4,11 +4,20 @@ |
1339 | CLASSNAME ProviderInterface |
1340 | INCLUDE unity/storage/internal/dbusmarshal.h |
1341 | ) |
1342 | - |
1343 | qt5_add_dbus_interface(generated_files |
1344 | ${CMAKE_SOURCE_DIR}/data/provider.xml |
1345 | ProviderInterface |
1346 | ) |
1347 | + |
1348 | +set_source_files_properties(${CMAKE_SOURCE_DIR}/data/registry.xml PROPERTIES |
1349 | + CLASSNAME RegistryInterface |
1350 | + INCLUDE unity/storage/internal/AccountDetails.h |
1351 | +) |
1352 | +qt5_add_dbus_interface(generated_files |
1353 | + ${CMAKE_SOURCE_DIR}/data/registry.xml |
1354 | + RegistryInterface |
1355 | +) |
1356 | + |
1357 | set_source_files_properties(${generated_files} dbusmarshal.cpp PROPERTIES |
1358 | COMPILE_FLAGS "-Wno-ctor-dtor-privacy -Wno-missing-field-initializers" |
1359 | GENERATED TRUE |
1360 | @@ -71,7 +80,6 @@ |
1361 | target_include_directories(storage-framework-qt-client-v2 PRIVATE |
1362 | ${Qt5DBus_INCLUDE_DIRS} |
1363 | ${Qt5Network_INCLUDE_DIRS} |
1364 | - ${ONLINEACCOUNTS_DEPS_INCLUDE_DIRS} |
1365 | ) |
1366 | set_target_properties(storage-framework-qt-client-v2 PROPERTIES |
1367 | AUTOMOC TRUE |
1368 | @@ -85,7 +93,6 @@ |
1369 | Qt5::Core |
1370 | Qt5::DBus |
1371 | Qt5::Network |
1372 | - ${ONLINEACCOUNTS_DEPS_LDFLAGS} |
1373 | ) |
1374 | install( |
1375 | TARGETS storage-framework-qt-client-v2 |
1376 | |
1377 | === modified file 'src/qt/Runtime.cpp' |
1378 | --- src/qt/Runtime.cpp 2016-09-22 01:52:20 +0000 |
1379 | +++ src/qt/Runtime.cpp 2016-11-28 11:06:57 +0000 |
1380 | @@ -70,11 +70,11 @@ |
1381 | |
1382 | Account Runtime::make_test_account(QString const& bus_name, |
1383 | QString const& object_path, |
1384 | - QString const& owner_id, |
1385 | - QString const& owner, |
1386 | - QString const& description) const |
1387 | + quint32 id, |
1388 | + QString const& service_id, |
1389 | + QString const& display_name) const |
1390 | { |
1391 | - return p_->make_test_account(bus_name, object_path, owner_id, owner, description); |
1392 | + return p_->make_test_account(bus_name, object_path, id, service_id, display_name); |
1393 | } |
1394 | |
1395 | } // namespace qt |
1396 | |
1397 | === modified file 'src/qt/client/internal/remote_client/RuntimeImpl.cpp' |
1398 | --- src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-11-02 09:32:53 +0000 |
1399 | +++ src/qt/client/internal/remote_client/RuntimeImpl.cpp 2016-11-28 11:06:57 +0000 |
1400 | @@ -47,7 +47,7 @@ |
1401 | |
1402 | static const map<QString, QString> BUS_NAMES = |
1403 | { |
1404 | - { "google-drive-scope", "com.canonical.StorageFramework.Provider.ProviderTest" }, |
1405 | + { "storage-provider-test", "com.canonical.StorageFramework.Provider.ProviderTest" }, |
1406 | { "com.canonical.scopes.mcloud_mcloud_mcloud", "com.canonical.StorageFramework.Provider.McloudProvider" }, |
1407 | { "storage-provider-owncloud", "com.canonical.StorageFramework.Provider.OwnCloud" }, |
1408 | { "storage-provider-onedrive", "com.canonical.StorageFramework.Provider.OnedriveProvider" }, |
1409 | |
1410 | === modified file 'src/qt/internal/AccountImpl.cpp' |
1411 | --- src/qt/internal/AccountImpl.cpp 2016-11-25 03:23:55 +0000 |
1412 | +++ src/qt/internal/AccountImpl.cpp 2016-11-28 11:06:57 +0000 |
1413 | @@ -48,37 +48,39 @@ |
1414 | } |
1415 | |
1416 | AccountImpl::AccountImpl(shared_ptr<RuntimeImpl> const& runtime_impl, |
1417 | - QString const& bus_name, |
1418 | - QString const& object_path, |
1419 | - QString const& id, |
1420 | - QString const& service_id, |
1421 | - QString const& display_name) |
1422 | + storage::internal::AccountDetails const& details) |
1423 | : is_valid_(true) |
1424 | - , bus_name_(bus_name) |
1425 | - , object_path_(object_path) |
1426 | - , id_(id) |
1427 | - , service_id_(service_id) |
1428 | - , display_name_(display_name) |
1429 | + , details_(details) |
1430 | , runtime_impl_(runtime_impl) |
1431 | - , provider_(new ProviderInterface(bus_name, object_path, runtime_impl->connection())) |
1432 | + , provider_(new ProviderInterface(details.busName, details.objectPath.path(), runtime_impl->connection())) |
1433 | { |
1434 | - assert(!bus_name.isEmpty()); |
1435 | - assert(!object_path.isEmpty()); |
1436 | + assert(!details.busName.isEmpty()); |
1437 | + assert(!details.objectPath.path().isEmpty()); |
1438 | } |
1439 | |
1440 | QString AccountImpl::busName() const |
1441 | { |
1442 | - return is_valid_ ? bus_name_ : ""; |
1443 | + return is_valid_ ? details_.busName : ""; |
1444 | } |
1445 | |
1446 | QString AccountImpl::objectPath() const |
1447 | { |
1448 | - return is_valid_ ? object_path_ : ""; |
1449 | + return is_valid_ ? details_.objectPath.path() : QDBusObjectPath().path(); |
1450 | } |
1451 | |
1452 | QString AccountImpl::displayName() const |
1453 | { |
1454 | - return is_valid_ ? display_name_ : ""; |
1455 | + return is_valid_ ? details_.displayName : ""; |
1456 | +} |
1457 | + |
1458 | +QString AccountImpl::providerName() const |
1459 | +{ |
1460 | + return is_valid_ ? details_.providerName : ""; |
1461 | +} |
1462 | + |
1463 | +QString AccountImpl::iconName() const |
1464 | +{ |
1465 | + return is_valid_ ? details_.iconName : ""; |
1466 | } |
1467 | |
1468 | ItemListJob* AccountImpl::roots(QStringList const& keys) const |
1469 | @@ -142,10 +144,7 @@ |
1470 | { |
1471 | if (is_valid_) |
1472 | { |
1473 | - return other.is_valid_ |
1474 | - && id_ == other.id_ |
1475 | - && service_id_ == other.service_id_ |
1476 | - && display_name_ == other.display_name_; |
1477 | + return other.is_valid_ && details_ == other.details_; |
1478 | } |
1479 | return !other.is_valid_; |
1480 | } |
1481 | @@ -165,24 +164,7 @@ |
1482 | { |
1483 | return false; |
1484 | } |
1485 | - assert(is_valid_ && other.is_valid_); |
1486 | - if (id_ < other.id_) |
1487 | - { |
1488 | - return true; |
1489 | - } |
1490 | - if (id_ > other.id_) |
1491 | - { |
1492 | - return false; |
1493 | - } |
1494 | - if (service_id_ < other.service_id_) |
1495 | - { |
1496 | - return true; |
1497 | - } |
1498 | - if (service_id_ > other.service_id_) |
1499 | - { |
1500 | - return false; |
1501 | - } |
1502 | - return display_name_ < other.display_name_; |
1503 | + return details_ < other.details_; |
1504 | } |
1505 | |
1506 | bool AccountImpl::operator<=(AccountImpl const& other) const |
1507 | @@ -216,21 +198,16 @@ |
1508 | { |
1509 | return 0; |
1510 | } |
1511 | - size_t hash = 0; |
1512 | - boost::hash_combine(hash, qHash(service_id_)); |
1513 | - boost::hash_combine(hash, qHash(id_)); |
1514 | - boost::hash_combine(hash, qHash(display_name_)); |
1515 | + size_t hash = details_.id; |
1516 | + boost::hash_combine(hash, qHash(details_.serviceId)); |
1517 | + boost::hash_combine(hash, qHash(details_.displayName)); |
1518 | return hash; |
1519 | } |
1520 | |
1521 | Account AccountImpl::make_account(shared_ptr<RuntimeImpl> const& runtime, |
1522 | - QString const& bus_name, |
1523 | - QString const& object_path, |
1524 | - QString const& id, |
1525 | - QString const& service_id, |
1526 | - QString const& display_name) |
1527 | + storage::internal::AccountDetails const& details) |
1528 | { |
1529 | - shared_ptr<AccountImpl> p(new AccountImpl(runtime, bus_name, object_path, id, service_id, display_name)); |
1530 | + shared_ptr<AccountImpl> p(new AccountImpl(runtime, details)); |
1531 | return Account(p); |
1532 | } |
1533 | |
1534 | |
1535 | === modified file 'src/qt/internal/AccountsJobImpl.cpp' |
1536 | --- src/qt/internal/AccountsJobImpl.cpp 2016-11-03 07:33:40 +0000 |
1537 | +++ src/qt/internal/AccountsJobImpl.cpp 2016-11-28 11:06:57 +0000 |
1538 | @@ -18,12 +18,12 @@ |
1539 | |
1540 | #include <unity/storage/qt/internal/AccountsJobImpl.h> |
1541 | |
1542 | +#include "RegistryInterface.h" |
1543 | #include <unity/storage/qt/internal/AccountImpl.h> |
1544 | +#include <unity/storage/qt/internal/Handler.h> |
1545 | #include <unity/storage/qt/internal/RuntimeImpl.h> |
1546 | #include <unity/storage/qt/internal/StorageErrorImpl.h> |
1547 | |
1548 | -#include <OnlineAccounts/Account> |
1549 | - |
1550 | #include <cassert> |
1551 | |
1552 | using namespace std; |
1553 | @@ -37,38 +37,45 @@ |
1554 | namespace internal |
1555 | { |
1556 | |
1557 | -namespace |
1558 | -{ |
1559 | - |
1560 | -// TODO: We retrieve the accounts directly from online accounts until we have a working registry. |
1561 | - |
1562 | -static map<QString, QString> const BUS_NAMES = |
1563 | -{ |
1564 | - { "google-drive-scope", "com.canonical.StorageFramework.Provider.ProviderTest" }, |
1565 | - { "com.canonical.scopes.mcloud_mcloud_mcloud", "com.canonical.StorageFramework.Provider.McloudProvider" }, |
1566 | - { "storage-provider-owncloud", "com.canonical.StorageFramework.Provider.OwnCloud" }, |
1567 | - { "storage-provider-onedrive", "com.canonical.StorageFramework.Provider.OnedriveProvider" }, |
1568 | -}; |
1569 | - |
1570 | -} // namespace |
1571 | - |
1572 | -AccountsJobImpl::AccountsJobImpl(AccountsJob* public_instance, shared_ptr<RuntimeImpl> const& runtime_impl) |
1573 | - : public_instance_(public_instance) |
1574 | - , status_(AccountsJob::Status::Loading) |
1575 | +AccountsJobImpl::AccountsJobImpl(shared_ptr<RuntimeImpl> const& runtime_impl, |
1576 | + QString const& method, |
1577 | + QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply) |
1578 | + : status_(AccountsJob::Status::Loading) |
1579 | , runtime_impl_(runtime_impl) |
1580 | { |
1581 | - assert(public_instance); |
1582 | assert(runtime_impl); |
1583 | |
1584 | - initialize_accounts(); |
1585 | + auto process_reply = [this, method](decltype(reply)& r) |
1586 | + { |
1587 | + auto runtime = get_runtime_impl(method); |
1588 | + if (!runtime || !runtime->isValid()) |
1589 | + { |
1590 | + return; |
1591 | + } |
1592 | + |
1593 | + for (auto const& ad : r.value()) |
1594 | + { |
1595 | + auto a = AccountImpl::make_account(runtime, ad); |
1596 | + accounts_.append(a); |
1597 | + } |
1598 | + status_ = AccountsJob::Status::Finished; |
1599 | + Q_EMIT public_instance_->statusChanged(status_); |
1600 | + }; |
1601 | + |
1602 | + auto process_error = [this](StorageError const& error) |
1603 | + { |
1604 | + error_ = error; |
1605 | + status_ = AccountsJob::Status::Error; |
1606 | + Q_EMIT public_instance_->statusChanged(status_); |
1607 | + }; |
1608 | + |
1609 | + new Handler<QList<storage::internal::AccountDetails>>(this, reply, process_reply, process_error); |
1610 | } |
1611 | |
1612 | -AccountsJobImpl::AccountsJobImpl(AccountsJob* public_instance, StorageError const& error) |
1613 | - : public_instance_(public_instance) |
1614 | - , status_(AccountsJob::Status::Loading) |
1615 | +AccountsJobImpl::AccountsJobImpl(StorageError const& error) |
1616 | + : status_(AccountsJob::Status::Error) |
1617 | , error_(error) |
1618 | { |
1619 | - assert(public_instance); |
1620 | assert(error.type() != StorageError::Type::NoError); |
1621 | |
1622 | status_ = emit_status_changed(AccountsJob::Status::Error); |
1623 | @@ -113,21 +120,27 @@ |
1624 | return account_list; |
1625 | } |
1626 | |
1627 | -void AccountsJobImpl::manager_ready() |
1628 | +AccountsJob* AccountsJobImpl::make_job(shared_ptr<RuntimeImpl> const& runtime, |
1629 | + QString const& method, |
1630 | + QDBusPendingReply<QList<storage::internal::AccountDetails>>& reply) |
1631 | { |
1632 | - timer_.stop(); |
1633 | - disconnect(this); |
1634 | - initialize_accounts(); |
1635 | + unique_ptr<AccountsJobImpl> impl(new AccountsJobImpl(runtime, method, reply)); |
1636 | + auto job = new AccountsJob(move(impl)); |
1637 | + job->p_->public_instance_ = job; |
1638 | + return job; |
1639 | } |
1640 | |
1641 | -// LCOV_EXCL_START |
1642 | -void AccountsJobImpl::timeout() |
1643 | +AccountsJob* AccountsJobImpl::make_job(StorageError const& error) |
1644 | { |
1645 | - disconnect(this); |
1646 | - error_ = StorageErrorImpl::local_comms_error("AccountsJob(): timeout retrieving Online accounts"); |
1647 | - status_ = emit_status_changed(AccountsJob::Status::Error); |
1648 | + unique_ptr<AccountsJobImpl> impl(new AccountsJobImpl(error)); |
1649 | + auto job = new AccountsJob(move(impl)); |
1650 | + job->p_->public_instance_ = job; |
1651 | + QMetaObject::invokeMethod(job, |
1652 | + "statusChanged", |
1653 | + Qt::QueuedConnection, |
1654 | + Q_ARG(unity::storage::qt::AccountsJob::Status, job->p_->status_)); |
1655 | + return job; |
1656 | } |
1657 | -// LCOV_EXCL_STOP |
1658 | |
1659 | AccountsJob::Status AccountsJobImpl::emit_status_changed(AccountsJob::Status new_status) const |
1660 | { |
1661 | @@ -152,43 +165,11 @@ |
1662 | auto This = const_cast<AccountsJobImpl*>(this); |
1663 | This->error_ = StorageErrorImpl::runtime_destroyed_error(msg); |
1664 | This->status_ = emit_status_changed(AccountsJob::Status::Error); |
1665 | + return nullptr; |
1666 | } |
1667 | return runtime; |
1668 | } |
1669 | |
1670 | -void AccountsJobImpl::initialize_accounts() |
1671 | -{ |
1672 | - auto runtime = get_runtime_impl("AccountsJob()"); |
1673 | - assert(runtime); |
1674 | - |
1675 | - auto manager = runtime->accounts_manager(); |
1676 | - if (!manager->isReady()) |
1677 | - { |
1678 | - connect(manager.get(), &OnlineAccounts::Manager::ready, this, &AccountsJobImpl::manager_ready); |
1679 | - connect(&timer_, &QTimer::timeout, this, &AccountsJobImpl::timeout); |
1680 | - timer_.setSingleShot(true); |
1681 | - timer_.start(30000); // TODO: Need config for this eventually. |
1682 | - return; |
1683 | - } |
1684 | - |
1685 | - for (auto const map_entry : BUS_NAMES) |
1686 | - { |
1687 | - auto service_id = map_entry.first; |
1688 | - for (auto const& a : manager->availableAccounts(service_id)) |
1689 | - { |
1690 | - auto object_path = QStringLiteral("/provider/%1").arg(a->id()); |
1691 | - auto bus_name = map_entry.second; |
1692 | - accounts_.append(AccountImpl::make_account(runtime, |
1693 | - bus_name, |
1694 | - object_path, |
1695 | - QString::number(a->id()), |
1696 | - a->serviceId(), |
1697 | - a->displayName())); |
1698 | - } |
1699 | - } |
1700 | - status_ = emit_status_changed(AccountsJob::Status::Finished); |
1701 | -} |
1702 | - |
1703 | } // namespace internal |
1704 | } // namespace qt |
1705 | } // namespace storage |
1706 | |
1707 | === modified file 'src/qt/internal/RuntimeImpl.cpp' |
1708 | --- src/qt/internal/RuntimeImpl.cpp 2016-10-10 05:24:16 +0000 |
1709 | +++ src/qt/internal/RuntimeImpl.cpp 2016-11-28 11:06:57 +0000 |
1710 | @@ -18,15 +18,17 @@ |
1711 | |
1712 | #include <unity/storage/qt/internal/RuntimeImpl.h> |
1713 | |
1714 | +#include "RegistryInterface.h" |
1715 | #include <unity/storage/internal/dbusmarshal.h> |
1716 | -#include <unity/storage/qt/AccountsJob.h> |
1717 | +#include <unity/storage/internal/EnvVars.h> |
1718 | #include <unity/storage/qt/internal/AccountImpl.h> |
1719 | +#include <unity/storage/qt/internal/AccountsJobImpl.h> |
1720 | #include <unity/storage/qt/internal/StorageErrorImpl.h> |
1721 | -#include <unity/storage/qt/Item.h> |
1722 | #include <unity/storage/qt/ItemJob.h> |
1723 | #include <unity/storage/qt/ItemListJob.h> |
1724 | #include <unity/storage/qt/Runtime.h> |
1725 | #include <unity/storage/qt/VoidJob.h> |
1726 | +#include <unity/storage/registry/Registry.h> |
1727 | |
1728 | #include <QDBusError> |
1729 | #include <QDBusMetaType> |
1730 | @@ -57,6 +59,9 @@ |
1731 | |
1732 | qDBusRegisterMetaType<unity::storage::internal::ItemMetadata>(); |
1733 | qDBusRegisterMetaType<QList<unity::storage::internal::ItemMetadata>>(); |
1734 | + |
1735 | + qDBusRegisterMetaType<unity::storage::internal::AccountDetails>(); |
1736 | + qDBusRegisterMetaType<QList<unity::storage::internal::AccountDetails>>(); |
1737 | } |
1738 | |
1739 | } |
1740 | @@ -66,10 +71,12 @@ |
1741 | { |
1742 | } |
1743 | |
1744 | -RuntimeImpl::RuntimeImpl(QDBusConnection const& bus) |
1745 | +RuntimeImpl::RuntimeImpl(QDBusConnection const& conn) |
1746 | : is_valid_(true) |
1747 | - , conn_(bus) |
1748 | - , accounts_manager_(new OnlineAccounts::Manager("", conn_)) |
1749 | + , conn_(conn) |
1750 | + , registry_(new RegistryInterface(storage::registry::BUS_NAME, |
1751 | + storage::registry::OBJECT_PATH, |
1752 | + conn_)) |
1753 | { |
1754 | register_meta_types(); |
1755 | } |
1756 | @@ -96,13 +103,17 @@ |
1757 | |
1758 | AccountsJob* RuntimeImpl::accounts() const |
1759 | { |
1760 | + QString const method = "Runtime::accounts()"; |
1761 | + |
1762 | if (!is_valid_) |
1763 | { |
1764 | QString msg = "Runtime::accounts(): Runtime was destroyed previously"; |
1765 | - return new AccountsJob(StorageErrorImpl::runtime_destroyed_error(msg)); |
1766 | + return AccountsJobImpl::make_job(StorageErrorImpl::runtime_destroyed_error(msg)); |
1767 | } |
1768 | - auto This = const_cast<RuntimeImpl*>(this); |
1769 | - return new AccountsJob(This->shared_from_this()); |
1770 | + |
1771 | + auto reply = registry_->ListAccounts(); |
1772 | + auto This = const_pointer_cast<RuntimeImpl>(shared_from_this()); |
1773 | + return AccountsJobImpl::make_job(This, method, reply); |
1774 | } |
1775 | |
1776 | StorageError RuntimeImpl::shutdown() |
1777 | @@ -116,23 +127,14 @@ |
1778 | return error_; |
1779 | } |
1780 | |
1781 | -shared_ptr<OnlineAccounts::Manager> RuntimeImpl::accounts_manager() const |
1782 | -{ |
1783 | - return accounts_manager_; |
1784 | -} |
1785 | - |
1786 | Account RuntimeImpl::make_test_account(QString const& bus_name, |
1787 | QString const& object_path, |
1788 | - QString const& owner_id, |
1789 | - QString const& owner, |
1790 | - QString const& description) |
1791 | + quint32 id, |
1792 | + QString const& service_id, |
1793 | + QString const& name) |
1794 | { |
1795 | - return AccountImpl::make_account(shared_from_this(), |
1796 | - bus_name, |
1797 | - object_path, |
1798 | - owner_id, |
1799 | - owner, |
1800 | - description); |
1801 | + storage::internal::AccountDetails ad{bus_name, QDBusObjectPath(object_path), id, service_id, name, "", ""}; |
1802 | + return AccountImpl::make_account(shared_from_this(), ad); |
1803 | } |
1804 | |
1805 | } // namespace internal |
1806 | |
1807 | === added directory 'src/registry' |
1808 | === added file 'src/registry/CMakeLists.txt' |
1809 | --- src/registry/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1810 | +++ src/registry/CMakeLists.txt 2016-11-28 11:06:57 +0000 |
1811 | @@ -0,0 +1,47 @@ |
1812 | +include_directories( |
1813 | + ${CMAKE_CURRENT_BINARY_DIR} |
1814 | + ${ONLINEACCOUNTS_DEPS_INCLUDE_DIRS} |
1815 | +) |
1816 | + |
1817 | +set(TARGET "storage-framework-registry") |
1818 | + |
1819 | +qt5_add_dbus_adaptor(adaptor_files |
1820 | + ${CMAKE_SOURCE_DIR}/data/registry.xml |
1821 | + unity/storage/registry/internal/RegistryAdaptor.h |
1822 | + unity::storage::registry::internal::RegistryAdaptor |
1823 | +) |
1824 | + |
1825 | +set_source_files_properties(${adaptor_files} PROPERTIES |
1826 | + COMPILE_FLAGS "-Wno-ctor-dtor-privacy -Wno-missing-field-initializers" |
1827 | + GENERATED TRUE |
1828 | +) |
1829 | + |
1830 | +add_executable(${TARGET} |
1831 | + internal/ListAccountsHandler.cpp |
1832 | + internal/qdbus-last-error-msg.cpp |
1833 | + internal/RegistryAdaptor.cpp |
1834 | + main.cpp |
1835 | + ${CMAKE_SOURCE_DIR}/include/unity/storage/registry/internal/ListAccountsHandler.h |
1836 | + ${CMAKE_SOURCE_DIR}/include/unity/storage/registry/internal/RegistryAdaptor.h |
1837 | + ${adaptor_files}) |
1838 | + |
1839 | +set_target_properties(${TARGET} PROPERTIES AUTOMOC TRUE) |
1840 | + |
1841 | +target_link_libraries(${TARGET} |
1842 | + storage-framework-common-internal |
1843 | + Qt5::Core |
1844 | + Qt5::DBus |
1845 | + ${ONLINEACCOUNTS_DEPS_LDFLAGS} |
1846 | +) |
1847 | + |
1848 | +install( |
1849 | + TARGETS ${TARGET} |
1850 | + RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME} |
1851 | +) |
1852 | + |
1853 | +configure_file(com.canonical.StorageFramework.Registry.service.in com.canonical.StorageFramework.Registry.service) |
1854 | + |
1855 | +install( |
1856 | + FILES ${CMAKE_CURRENT_BINARY_DIR}/com.canonical.StorageFramework.Registry.service |
1857 | + DESTINATION ${CMAKE_INSTALL_DATADIR}/dbus-1/services |
1858 | +) |
1859 | |
1860 | === added file 'src/registry/com.canonical.StorageFramework.Registry.service.in' |
1861 | --- src/registry/com.canonical.StorageFramework.Registry.service.in 1970-01-01 00:00:00 +0000 |
1862 | +++ src/registry/com.canonical.StorageFramework.Registry.service.in 2016-11-28 11:06:57 +0000 |
1863 | @@ -0,0 +1,3 @@ |
1864 | +[D-BUS Service] |
1865 | +Name=com.canonical.StorageFramework.Registry |
1866 | +Exec=@CMAKE_INSTALL_FULL_LIBDIR@/@PROJECT_NAME@/storage-framework-registry |
1867 | |
1868 | === added directory 'src/registry/internal' |
1869 | === added file 'src/registry/internal/ListAccountsHandler.cpp' |
1870 | --- src/registry/internal/ListAccountsHandler.cpp 1970-01-01 00:00:00 +0000 |
1871 | +++ src/registry/internal/ListAccountsHandler.cpp 2016-11-28 11:06:57 +0000 |
1872 | @@ -0,0 +1,127 @@ |
1873 | +/* |
1874 | + * Copyright (C) 2016 Canonical Ltd |
1875 | + * |
1876 | + * This program is free software: you can redistribute it and/or modify |
1877 | + * it under the terms of the GNU Lesser General Public License version 3 as |
1878 | + * published by the Free Software Foundation. |
1879 | + * |
1880 | + * This program is distributed in the hope that it will be useful, |
1881 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1882 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1883 | + * GNU Lesser General Public License for more details. |
1884 | + * |
1885 | + * You should have received a copy of the GNU Lesser General Public License |
1886 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1887 | + * |
1888 | + * Authors: Michi Henning <michi.henning@canonical.com> |
1889 | + */ |
1890 | + |
1891 | +#include <unity/storage/registry/internal/ListAccountsHandler.h> |
1892 | + |
1893 | +#include <unity/storage/internal/AccountDetails.h> |
1894 | +#include <unity/storage/registry/internal/qdbus-last-error-msg.h> |
1895 | + |
1896 | +#include <OnlineAccounts/Account> |
1897 | +#include <QDebug> |
1898 | + |
1899 | +using namespace std; |
1900 | + |
1901 | +namespace unity |
1902 | +{ |
1903 | +namespace storage |
1904 | +{ |
1905 | +namespace registry |
1906 | +{ |
1907 | +namespace internal |
1908 | +{ |
1909 | + |
1910 | +ListAccountsHandler::ListAccountsHandler(QDBusConnection const& conn, |
1911 | + QDBusMessage const& msg, |
1912 | + shared_ptr<storage::internal::InactivityTimer> const& timer) |
1913 | + : conn_(conn) |
1914 | + , msg_(msg) |
1915 | + , manager_("", conn) |
1916 | + , activity_notifier_(timer) |
1917 | +{ |
1918 | + connect(&manager_, &OnlineAccounts::Manager::ready, this, &ListAccountsHandler::manager_ready); |
1919 | + connect(&timer_, &QTimer::timeout, this, &ListAccountsHandler::timeout); |
1920 | + timer_.setSingleShot(true); |
1921 | + timer_.start(25000); // TODO: Need config for this eventually. |
1922 | +} |
1923 | + |
1924 | +ListAccountsHandler::~ListAccountsHandler() = default; |
1925 | + |
1926 | +namespace |
1927 | +{ |
1928 | + |
1929 | +// TODO: This is a hack until Online Accounts is updated to give us the provider ID, provider name, and icon name. |
1930 | + |
1931 | +struct ProviderDetails |
1932 | +{ |
1933 | + char const* bus_name; |
1934 | + char const* provider_name; |
1935 | +}; |
1936 | + |
1937 | +static map<QString, ProviderDetails> const BUS_NAMES = |
1938 | +{ |
1939 | + { "storage-provider-test", { "com.canonical.StorageFramework.Provider.ProviderTest", "Test Provider" } }, |
1940 | + { "com.canonical.scopes.mcloud_mcloud_mcloud", { "com.canonical.StorageFramework.Provider.McloudProvider", "mcloud" } }, |
1941 | + { "storage-provider-owncloud", { "com.canonical.StorageFramework.Provider.OwnCloud", "ownCloud" } }, |
1942 | + { "storage-provider-onedrive", { "com.canonical.StorageFramework.Provider.OnedriveProvider", "OneDrive" } }, |
1943 | +}; |
1944 | + |
1945 | +} // namespace |
1946 | + |
1947 | +void ListAccountsHandler::manager_ready() |
1948 | +{ |
1949 | + timer_.stop(); |
1950 | + disconnect(this); |
1951 | + deleteLater(); |
1952 | + |
1953 | + QList<storage::internal::AccountDetails> accounts; |
1954 | + for (auto const& acct : manager_.availableAccounts()) |
1955 | + { |
1956 | + auto const it = BUS_NAMES.find(acct->serviceId()); |
1957 | + if (it == BUS_NAMES.end()) |
1958 | + { |
1959 | + continue; |
1960 | + } |
1961 | + |
1962 | + storage::internal::AccountDetails ad; |
1963 | + ad.busName = it->second.bus_name; |
1964 | + ad.objectPath = QDBusObjectPath(QStringLiteral("/provider/%1").arg(acct->id())); |
1965 | + ad.id = acct->id(); |
1966 | + ad.serviceId = acct->serviceId(); |
1967 | + ad.displayName = acct->displayName(); |
1968 | + ad.providerName = it->second.provider_name; |
1969 | + ad.iconName = ""; |
1970 | + |
1971 | + accounts.append(ad); |
1972 | + } |
1973 | + |
1974 | + if (!conn_.send(msg_.createReply(QVariant::fromValue(accounts)))) |
1975 | + { |
1976 | + auto msg = last_error_msg(conn_); |
1977 | + qCritical().noquote() << "ListAccounts(): could not send DBus reply" + msg; |
1978 | + } |
1979 | +} |
1980 | + |
1981 | +void ListAccountsHandler::timeout() |
1982 | +{ |
1983 | + disconnect(this); |
1984 | + deleteLater(); |
1985 | + |
1986 | + QString err = QString("cannot contact Online Accounts: request timed out after ") + |
1987 | + QString::number(timer_.interval()) + " ms"; |
1988 | + qCritical().noquote() << err; |
1989 | + if (!conn_.send(msg_.createErrorReply(QDBusError::Other, err))) |
1990 | + { |
1991 | + auto msg = last_error_msg(conn_); |
1992 | + qCritical().noquote() << "ListAccounts(): could not send DBus error reply" + msg; |
1993 | + } |
1994 | +} |
1995 | + |
1996 | +} // namespace internal |
1997 | +} // namespace registry |
1998 | +} // namespace storage |
1999 | +} // namespace unity |
2000 | |
2001 | === added file 'src/registry/internal/RegistryAdaptor.cpp' |
2002 | --- src/registry/internal/RegistryAdaptor.cpp 1970-01-01 00:00:00 +0000 |
2003 | +++ src/registry/internal/RegistryAdaptor.cpp 2016-11-28 11:06:57 +0000 |
2004 | @@ -0,0 +1,55 @@ |
2005 | +/* |
2006 | + * Copyright (C) 2016 Canonical Ltd |
2007 | + * |
2008 | + * This program is free software: you can redistribute it and/or modify |
2009 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2010 | + * published by the Free Software Foundation. |
2011 | + * |
2012 | + * This program is distributed in the hope that it will be useful, |
2013 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2014 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2015 | + * GNU Lesser General Public License for more details. |
2016 | + * |
2017 | + * You should have received a copy of the GNU Lesser General Public License |
2018 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2019 | + * |
2020 | + * Authors: Michi Henning <michi.henning@canonical.com> |
2021 | + */ |
2022 | + |
2023 | +#include <unity/storage/registry/internal/RegistryAdaptor.h> |
2024 | + |
2025 | +#include <unity/storage/registry/internal/ListAccountsHandler.h> |
2026 | + |
2027 | +using namespace std; |
2028 | + |
2029 | +namespace unity |
2030 | +{ |
2031 | +namespace storage |
2032 | +{ |
2033 | +namespace registry |
2034 | +{ |
2035 | +namespace internal |
2036 | +{ |
2037 | + |
2038 | +RegistryAdaptor::RegistryAdaptor(QDBusConnection const& conn, |
2039 | + shared_ptr<storage::internal::InactivityTimer> const& timer, |
2040 | + QObject* parent) |
2041 | + : QObject(parent) |
2042 | + , conn_(conn) |
2043 | + , timer_(timer) |
2044 | +{ |
2045 | +} |
2046 | + |
2047 | +RegistryAdaptor::~RegistryAdaptor() = default; |
2048 | + |
2049 | +QList<unity::storage::internal::AccountDetails> RegistryAdaptor::ListAccounts() |
2050 | +{ |
2051 | + new ListAccountsHandler(conn_, message(), timer_); // Handler deletes itself once done. |
2052 | + setDelayedReply(true); |
2053 | + return QList<unity::storage::internal::AccountDetails>(); |
2054 | +} |
2055 | + |
2056 | +} // namespace internal |
2057 | +} // namespace registry |
2058 | +} // namespace storage |
2059 | +} // namespace unity |
2060 | |
2061 | === added file 'src/registry/internal/qdbus-last-error-msg.cpp' |
2062 | --- src/registry/internal/qdbus-last-error-msg.cpp 1970-01-01 00:00:00 +0000 |
2063 | +++ src/registry/internal/qdbus-last-error-msg.cpp 2016-11-28 11:06:57 +0000 |
2064 | @@ -0,0 +1,49 @@ |
2065 | +/* |
2066 | + * Copyright (C) 2016 Canonical Ltd |
2067 | + * |
2068 | + * This program is free software: you can redistribute it and/or modify |
2069 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2070 | + * published by the Free Software Foundation. |
2071 | + * |
2072 | + * This program is distributed in the hope that it will be useful, |
2073 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2074 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2075 | + * GNU Lesser General Public License for more details. |
2076 | + * |
2077 | + * You should have received a copy of the GNU Lesser General Public License |
2078 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2079 | + * |
2080 | + * Authors: Michi Henning <michi.henning@canonical.com> |
2081 | + */ |
2082 | + |
2083 | +#include <unity/storage/registry/internal/qdbus-last-error-msg.h> |
2084 | + |
2085 | +#pragma GCC diagnostic push |
2086 | +#pragma GCC diagnostic ignored "-Wcast-align" |
2087 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
2088 | +#include <QDBusError> |
2089 | +#pragma GCC diagnostic pop |
2090 | + |
2091 | +namespace unity |
2092 | +{ |
2093 | +namespace storage |
2094 | +{ |
2095 | +namespace registry |
2096 | +{ |
2097 | +namespace internal |
2098 | +{ |
2099 | + |
2100 | +QString last_error_msg(QDBusConnection const& conn) |
2101 | +{ |
2102 | + auto msg = conn.lastError().message(); |
2103 | + if (!msg.isEmpty()) |
2104 | + { |
2105 | + msg = ": " + msg; |
2106 | + } |
2107 | + return msg; |
2108 | +} |
2109 | + |
2110 | +} // namespace internal |
2111 | +} // namespace registry |
2112 | +} // namespace storage |
2113 | +} // namespace unity |
2114 | |
2115 | === added file 'src/registry/main.cpp' |
2116 | --- src/registry/main.cpp 1970-01-01 00:00:00 +0000 |
2117 | +++ src/registry/main.cpp 2016-11-28 11:06:57 +0000 |
2118 | @@ -0,0 +1,95 @@ |
2119 | +/* |
2120 | + * Copyright (C) 2016 Canonical Ltd |
2121 | + * |
2122 | + * This program is free software: you can redistribute it and/or modify |
2123 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2124 | + * published by the Free Software Foundation. |
2125 | + * |
2126 | + * This program is distributed in the hope that it will be useful, |
2127 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2128 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2129 | + * GNU Lesser General Public License for more details. |
2130 | + * |
2131 | + * You should have received a copy of the GNU Lesser General Public License |
2132 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2133 | + * |
2134 | + * Authors: Michi Henning <michi.henning@canonical.com> |
2135 | + */ |
2136 | + |
2137 | +#include "registryadaptor.h" |
2138 | +#include <unity/storage/internal/EnvVars.h> |
2139 | +#include <unity/storage/internal/InactivityTimer.h> |
2140 | +#include <unity/storage/internal/TraceMessageHandler.h> |
2141 | +#include <unity/storage/registry/internal/qdbus-last-error-msg.h> |
2142 | +#include <unity/storage/registry/internal/RegistryAdaptor.h> |
2143 | +#include <unity/storage/registry/Registry.h> |
2144 | + |
2145 | +#pragma GCC diagnostic push |
2146 | +#pragma GCC diagnostic ignored "-Wcast-align" |
2147 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
2148 | +#include <QCoreApplication> |
2149 | +#include <QDBusArgument> |
2150 | +#include <QDBusError> |
2151 | +#include <QFileInfo> |
2152 | +#pragma GCC diagnostic pop |
2153 | + |
2154 | +using namespace unity::storage; |
2155 | +using namespace unity::storage::registry::internal; |
2156 | +using namespace std; |
2157 | + |
2158 | +int main(int argc, char* argv[]) |
2159 | +{ |
2160 | + auto const prog_name = QFileInfo(argv[0]).fileName(); |
2161 | + internal::TraceMessageHandler message_handler(prog_name); |
2162 | + |
2163 | + int rc = 1; |
2164 | + try |
2165 | + { |
2166 | + QCoreApplication app(argc, argv); |
2167 | + |
2168 | + auto conn = QDBusConnection::sessionBus(); |
2169 | + |
2170 | + int const timeout_ms = internal::EnvVars::registry_timeout_ms(); |
2171 | + auto timeout_func = [&app, timeout_ms] |
2172 | + { |
2173 | + qInfo().noquote().nospace() << "Exiting after " << QString::number(timeout_ms) << " ms of idle time"; |
2174 | + app.quit(); |
2175 | + }; |
2176 | + auto inactivity_timer = make_shared<unity::storage::internal::InactivityTimer>(timeout_ms, timeout_func); |
2177 | + |
2178 | + registry::internal::RegistryAdaptor registry_adaptor(conn, inactivity_timer); |
2179 | + new ::RegistryAdaptor(®istry_adaptor); |
2180 | + |
2181 | + auto const& object_path = registry::OBJECT_PATH; |
2182 | + if (!conn.registerObject(object_path, ®istry_adaptor)) |
2183 | + { |
2184 | + auto msg = last_error_msg(conn); |
2185 | + throw runtime_error(string("Could not register object path ") + |
2186 | + object_path.toStdString() + msg.toStdString()); |
2187 | + } |
2188 | + |
2189 | + qDBusRegisterMetaType<unity::storage::internal::AccountDetails>(); |
2190 | + qDBusRegisterMetaType<QList<unity::storage::internal::AccountDetails>>(); |
2191 | + |
2192 | + auto const& bus_name = registry::BUS_NAME; |
2193 | + if (!conn.registerService(bus_name)) |
2194 | + { |
2195 | + auto msg = last_error_msg(conn); |
2196 | + throw runtime_error(string("Could not acquire DBus name ") + bus_name.toStdString() + msg.toStdString()); |
2197 | + } |
2198 | + |
2199 | + rc = app.exec(); |
2200 | + |
2201 | + if (!conn.unregisterService(bus_name)) |
2202 | + { |
2203 | + auto msg = last_error_msg(conn); |
2204 | + throw runtime_error(string("Could not release DBus name ") + bus_name.toStdString() + msg.toStdString()); |
2205 | + } |
2206 | + } |
2207 | + catch (std::exception const& e) |
2208 | + { |
2209 | + qCritical().noquote() << e.what(); |
2210 | + } |
2211 | + |
2212 | + return rc; |
2213 | +} |
2214 | |
2215 | === modified file 'tests/CMakeLists.txt' |
2216 | --- tests/CMakeLists.txt 2016-11-23 03:03:58 +0000 |
2217 | +++ tests/CMakeLists.txt 2016-11-28 11:06:57 +0000 |
2218 | @@ -6,6 +6,7 @@ |
2219 | add_subdirectory(utils) |
2220 | |
2221 | set(unit_test_dirs |
2222 | + registry |
2223 | local-client |
2224 | remote-client |
2225 | remote-client-v1 |
2226 | |
2227 | === added directory 'tests/registry' |
2228 | === added file 'tests/registry/CMakeLists.txt' |
2229 | --- tests/registry/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2230 | +++ tests/registry/CMakeLists.txt 2016-11-28 11:06:57 +0000 |
2231 | @@ -0,0 +1,20 @@ |
2232 | +add_executable(registry_test registry_test.cpp) |
2233 | +#set_target_properties(remote-client_test PROPERTIES AUTOMOC TRUE) |
2234 | + |
2235 | +#add_definitions(-DTEST_DIR="${CMAKE_CURRENT_BINARY_DIR}" -DBOOST_THREAD_VERSION=4) |
2236 | +#include_directories(${GLIB_DEPS_INCLUDE_DIRS}) |
2237 | + |
2238 | +#target_link_libraries(remote-client_test |
2239 | +# storage-framework-provider |
2240 | +# storage-framework-qt-client-v2 |
2241 | +# Qt5::Network |
2242 | +# Qt5::Test |
2243 | +# ${Boost_LIBRARIES} |
2244 | +# ${GLIB_DEPS_LIBRARIES} |
2245 | +# testutils |
2246 | +# gtest |
2247 | +#) |
2248 | +add_test(registry registry_test) |
2249 | +#add_dependencies(remote-client_test qt-client-all-headers provider-test) |
2250 | + |
2251 | +#set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} PARENT_SCOPE) |
2252 | |
2253 | === added file 'tests/registry/registry_test.cpp' |
2254 | --- tests/registry/registry_test.cpp 1970-01-01 00:00:00 +0000 |
2255 | +++ tests/registry/registry_test.cpp 2016-11-28 11:06:57 +0000 |
2256 | @@ -0,0 +1,27 @@ |
2257 | +/* |
2258 | + * Copyright (C) 2016 Canonical Ltd |
2259 | + * |
2260 | + * This program is free software: you can redistribute it and/or modify |
2261 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2262 | + * published by the Free Software Foundation. |
2263 | + * |
2264 | + * This program is distributed in the hope that it will be useful, |
2265 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2266 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2267 | + * GNU Lesser General Public License for more details. |
2268 | + * |
2269 | + * You should have received a copy of the GNU Lesser General Public License |
2270 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2271 | + * |
2272 | + * Authors: Michi Henning <michi.henning@canonical.com> |
2273 | + */ |
2274 | + |
2275 | +int main(int argc, char** argv) |
2276 | +{ |
2277 | +#if 0 |
2278 | + QCoreApplication app(argc, argv); |
2279 | + |
2280 | + ::testing::InitGoogleTest(&argc, argv); |
2281 | + return RUN_ALL_TESTS(); |
2282 | +#endif |
2283 | +} |
2284 | |
2285 | === modified file 'tests/remote-client-v1/remote-client-v1_test.cpp' |
2286 | --- tests/remote-client-v1/remote-client-v1_test.cpp 2016-09-26 02:37:03 +0000 |
2287 | +++ tests/remote-client-v1/remote-client-v1_test.cpp 2016-11-28 11:06:57 +0000 |
2288 | @@ -56,7 +56,7 @@ |
2289 | void SetUp() override |
2290 | { |
2291 | dbus_.reset(new DBusEnvironment); |
2292 | - dbus_->add_demo_provider("google-drive-scope"); |
2293 | + dbus_->add_demo_provider("storage-provider-test"); |
2294 | dbus_->start_services(); |
2295 | } |
2296 | |
2297 | @@ -150,7 +150,7 @@ |
2298 | } |
2299 | for (auto acc : accounts) |
2300 | { |
2301 | - if (acc->owner_id() == "google-drive-scope") |
2302 | + if (acc->owner_id() == "storage-provider-test") |
2303 | { |
2304 | return acc; |
2305 | } |
2306 | @@ -198,8 +198,8 @@ |
2307 | auto acc = get_account(runtime); |
2308 | EXPECT_EQ(runtime, acc->runtime()); |
2309 | EXPECT_EQ("", acc->owner()); |
2310 | - EXPECT_EQ("google-drive-scope", acc->owner_id()); |
2311 | - EXPECT_EQ("Fake google account", acc->description()); |
2312 | + EXPECT_EQ("storage-provider-test", acc->owner_id()); |
2313 | + EXPECT_EQ("Fake test account", acc->description()); |
2314 | } |
2315 | |
2316 | TEST_F(RuntimeTest, roots) |
2317 | |
2318 | === modified file 'tests/remote-client/CMakeLists.txt' |
2319 | --- tests/remote-client/CMakeLists.txt 2016-09-08 08:33:59 +0000 |
2320 | +++ tests/remote-client/CMakeLists.txt 2016-11-28 11:06:57 +0000 |
2321 | @@ -15,6 +15,6 @@ |
2322 | gtest |
2323 | ) |
2324 | add_test(remote-client remote-client_test) |
2325 | -add_dependencies(remote-client_test qt-client-all-headers provider-test) |
2326 | +add_dependencies(remote-client_test qt-client-all-headers storage-framework-registry) |
2327 | |
2328 | set(UNIT_TEST_TARGETS ${UNIT_TEST_TARGETS} PARENT_SCOPE) |
2329 | |
2330 | === modified file 'tests/remote-client/remote-client_test.cpp' |
2331 | --- tests/remote-client/remote-client_test.cpp 2016-11-25 23:42:08 +0000 |
2332 | +++ tests/remote-client/remote-client_test.cpp 2016-11-28 11:06:57 +0000 |
2333 | @@ -125,77 +125,77 @@ |
2334 | |
2335 | { |
2336 | auto acc = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
2337 | - "id", "sid", "displayName"); |
2338 | + 99, "sid", "name"); |
2339 | EXPECT_TRUE(acc.isValid()); |
2340 | EXPECT_EQ(service_connection_->baseService(), acc.busName()); |
2341 | EXPECT_EQ(object_path(), acc.objectPath()); |
2342 | - EXPECT_EQ("displayName", acc.displayName()); |
2343 | + EXPECT_EQ("name", acc.displayName()); |
2344 | |
2345 | // Copy constructor |
2346 | Account a2(acc); |
2347 | EXPECT_TRUE(a2.isValid()); |
2348 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); |
2349 | EXPECT_EQ(object_path(), a2.objectPath()); |
2350 | - EXPECT_EQ("displayName", a2.displayName()); |
2351 | + EXPECT_EQ("name", a2.displayName()); |
2352 | |
2353 | // Move constructor |
2354 | Account a3(move(a2)); |
2355 | EXPECT_TRUE(a3.isValid()); |
2356 | EXPECT_EQ(service_connection_->baseService(), a3.busName()); |
2357 | EXPECT_EQ(object_path(), a3.objectPath()); |
2358 | - EXPECT_EQ("displayName", a3.displayName()); |
2359 | + EXPECT_EQ("name", a3.displayName()); |
2360 | |
2361 | // Moved-from object must be invalid |
2362 | EXPECT_FALSE(a2.isValid()); |
2363 | |
2364 | // Moved-from object must be assignable |
2365 | auto a4 = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
2366 | - "id4", "sid4", "displayName4"); |
2367 | + 99, "sid4", "name4"); |
2368 | a2 = a4; |
2369 | EXPECT_TRUE(a2.isValid()); |
2370 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); |
2371 | EXPECT_EQ(object_path(), a2.objectPath()); |
2372 | - EXPECT_EQ("displayName4", a2.displayName()); |
2373 | + EXPECT_EQ("name4", a2.displayName()); |
2374 | } |
2375 | |
2376 | { |
2377 | - auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "id", "sid", "dn"); |
2378 | - auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "id2", "sid2", "dn2"); |
2379 | + auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 99, "sid", "dn"); |
2380 | + auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 100, "sid2", "n2"); |
2381 | |
2382 | // Copy assignment |
2383 | a1 = a2; |
2384 | EXPECT_TRUE(a2.isValid()); |
2385 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); |
2386 | EXPECT_EQ(object_path(), a1.objectPath()); |
2387 | - EXPECT_EQ("dn2", a1.displayName()); |
2388 | + EXPECT_EQ("n2", a1.displayName()); |
2389 | |
2390 | // Self-assignment |
2391 | a2 = a2; |
2392 | EXPECT_TRUE(a2.isValid()); |
2393 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); |
2394 | EXPECT_EQ(object_path(), a1.objectPath()); |
2395 | - EXPECT_EQ("dn2", a1.displayName()); |
2396 | + EXPECT_EQ("n2", a1.displayName()); |
2397 | |
2398 | // Move assignment |
2399 | auto a3 = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
2400 | - "id3", "sid3", "dn3"); |
2401 | + 101, "sid3", "n3"); |
2402 | a1 = move(a3); |
2403 | EXPECT_TRUE(a1.isValid()); |
2404 | EXPECT_EQ(service_connection_->baseService(), a1.busName()); |
2405 | EXPECT_EQ(object_path(), a1.objectPath()); |
2406 | - EXPECT_EQ("dn3", a1.displayName()); |
2407 | + EXPECT_EQ("n3", a1.displayName()); |
2408 | |
2409 | // Moved-from object must be invalid |
2410 | EXPECT_FALSE(a3.isValid()); |
2411 | |
2412 | // Moved-from object must be assignable |
2413 | auto a4 = runtime_->make_test_account(service_connection_->baseService(), object_path(), |
2414 | - "id4", "sid4", "dn4"); |
2415 | + 102, "sid4", "n4"); |
2416 | a2 = a4; |
2417 | EXPECT_TRUE(a2.isValid()); |
2418 | EXPECT_EQ(service_connection_->baseService(), a2.busName()); |
2419 | EXPECT_EQ(object_path(), a2.objectPath()); |
2420 | - EXPECT_EQ("dn4", a2.displayName()); |
2421 | + EXPECT_EQ("n4", a2.displayName()); |
2422 | } |
2423 | } |
2424 | |
2425 | @@ -235,8 +235,8 @@ |
2426 | |
2427 | { |
2428 | // a1 < a2 for ID |
2429 | - auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "x", "x"); |
2430 | - auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "b", "x", "x"); |
2431 | + auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "x", "x"); |
2432 | + auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 2, "x", "x"); |
2433 | |
2434 | EXPECT_FALSE(a1 == a2); |
2435 | EXPECT_TRUE(a1 != a2); |
2436 | @@ -256,8 +256,8 @@ |
2437 | |
2438 | { |
2439 | // a1 < a2 for service ID |
2440 | - auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "x"); |
2441 | - auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "b", "x"); |
2442 | + auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "x"); |
2443 | + auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "b", "x"); |
2444 | |
2445 | EXPECT_FALSE(a1 == a2); |
2446 | EXPECT_TRUE(a1 != a2); |
2447 | @@ -277,8 +277,8 @@ |
2448 | |
2449 | { |
2450 | // a1 < a2 for display name |
2451 | - auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); |
2452 | - auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "b"); |
2453 | + auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
2454 | + auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "b"); |
2455 | |
2456 | EXPECT_FALSE(a1 == a2); |
2457 | EXPECT_TRUE(a1 != a2); |
2458 | @@ -298,8 +298,8 @@ |
2459 | |
2460 | { |
2461 | // a1 == a2 |
2462 | - auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); |
2463 | - auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); |
2464 | + auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
2465 | + auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
2466 | |
2467 | EXPECT_TRUE(a1 == a2); |
2468 | EXPECT_FALSE(a1 != a2); |
2469 | @@ -327,7 +327,7 @@ |
2470 | EXPECT_EQ(0u, a1.hash()); |
2471 | EXPECT_EQ(0u, qHash(a1)); |
2472 | |
2473 | - auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "a", "a"); |
2474 | + auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "a", "a"); |
2475 | // Due to different return types (size_t vs uint), hash() and qHash() do not return the same value. |
2476 | EXPECT_NE(0u, a2.hash()); |
2477 | EXPECT_NE(0u, qHash(a2)); |
2478 | @@ -351,17 +351,29 @@ |
2479 | EXPECT_EQ(AccountsJob::Status::Finished, j->status()); |
2480 | EXPECT_EQ(StorageError::Type::NoError, j->error().type()); |
2481 | |
2482 | - EXPECT_TRUE(runtime_->connection().isConnected()); // Just for coverage. |
2483 | - |
2484 | auto accounts = j->accounts(); |
2485 | + EXPECT_GT(accounts.size(), 0); |
2486 | |
2487 | - // We don't check the contents of accounts here because we are using the real online accounts manager |
2488 | - // in this test. This means that the number and kind of accounts that are returned depends |
2489 | - // on what provider accounts the test user has configured. |
2490 | + // The fake online accounts service includes a "com.canonical.StorageFramework.Provider.ProviderTest" account. |
2491 | + bool found = false; |
2492 | + for (auto const& a : accounts) |
2493 | + { |
2494 | + qDebug() << a.busName(); |
2495 | + if (a.busName() == "com.canonical.StorageFramework.Provider.ProviderTest") |
2496 | + { |
2497 | + found = true; |
2498 | + EXPECT_EQ("Test Provider", a.providerName()); |
2499 | + // TODO: add tests for the other account properties. |
2500 | + break; |
2501 | + } |
2502 | + } |
2503 | + EXPECT_TRUE(found); |
2504 | } |
2505 | |
2506 | TEST_F(AccountTest, runtime_destroyed) |
2507 | { |
2508 | + EXPECT_TRUE(runtime_->connection().isConnected()); // Just for coverage. |
2509 | + |
2510 | EXPECT_EQ(StorageError::Type::NoError, runtime_->shutdown().type()); // Destroy runtime. |
2511 | |
2512 | AccountsJob* j = runtime_->accounts(); |
2513 | @@ -1189,8 +1201,8 @@ |
2514 | { |
2515 | // Both items valid with identical metadata, but different accounts (a1 < a2). |
2516 | |
2517 | - auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "a", "x", "x"); |
2518 | - auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), "b", "x", "x"); |
2519 | + auto a1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1, "x", "x"); |
2520 | + auto a2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 2, "x", "x"); |
2521 | |
2522 | Item i1; |
2523 | Item i2; |
2524 | @@ -1666,11 +1678,12 @@ |
2525 | { |
2526 | set_provider(unique_ptr<provider::ProviderBase>(new MockProvider())); |
2527 | |
2528 | - auto test_account = runtime_->make_test_account(service_connection_->baseService(), object_path(), "test_account"); |
2529 | + auto acc1 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 1); |
2530 | + auto acc2 = runtime_->make_test_account(service_connection_->baseService(), object_path(), 2); |
2531 | |
2532 | Item root1; |
2533 | { |
2534 | - unique_ptr<ItemJob> j(test_account.get("root_id")); |
2535 | + unique_ptr<ItemJob> j(acc1.get("root_id")); |
2536 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); |
2537 | spy.wait(SIGNAL_WAIT_TIME); |
2538 | root1 = j->item(); |
2539 | @@ -1679,7 +1692,7 @@ |
2540 | |
2541 | Item root2; |
2542 | { |
2543 | - unique_ptr<ItemJob> j(acc_.get("root_id")); |
2544 | + unique_ptr<ItemJob> j(acc2.get("root_id")); |
2545 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); |
2546 | spy.wait(SIGNAL_WAIT_TIME); |
2547 | root2 = j->item(); |
2548 | @@ -1688,7 +1701,7 @@ |
2549 | |
2550 | Item child; |
2551 | { |
2552 | - unique_ptr<ItemJob> j(acc_.get("child_id")); |
2553 | + unique_ptr<ItemJob> j(acc2.get("child_id")); |
2554 | QSignalSpy spy(j.get(), &ItemJob::statusChanged); |
2555 | spy.wait(SIGNAL_WAIT_TIME); |
2556 | child = j->item(); |
2557 | |
2558 | === modified file 'tests/utils/DBusEnvironment.cpp' |
2559 | --- tests/utils/DBusEnvironment.cpp 2016-08-04 10:12:01 +0000 |
2560 | +++ tests/utils/DBusEnvironment.cpp 2016-11-28 11:06:57 +0000 |
2561 | @@ -17,6 +17,7 @@ |
2562 | */ |
2563 | |
2564 | #include "DBusEnvironment.h" |
2565 | +#include <unity/storage/registry/Registry.h> |
2566 | |
2567 | #include <testsetup.h> |
2568 | |
2569 | @@ -27,6 +28,9 @@ |
2570 | char const ACCOUNTS_BUS_NAME[] = "com.ubuntu.OnlineAccounts.Manager"; |
2571 | char const FAKE_ACCOUNTS_SERVICE[] = TEST_SRC_DIR "/utils/fake-online-accounts-daemon.py"; |
2572 | |
2573 | +char const REGISTRY_TEST_BUS_NAME[] = "com.ubuntu.StorageFramework.TestRegistry"; |
2574 | +char const REGISTRY_SERVICE[] = TEST_BIN_DIR "/../src/registry/storage-framework-registry"; |
2575 | + |
2576 | char const DEMO_PROVIDER_BUS_NAME[] = "com.canonical.StorageFramework.Provider.ProviderTest"; |
2577 | char const DEMO_PROVIDER_SERVICE[] = TEST_BIN_DIR "/../demo/provider_test/provider-test"; |
2578 | } |
2579 | @@ -38,6 +42,11 @@ |
2580 | ACCOUNTS_BUS_NAME, QDBusConnection::SessionBus, |
2581 | FAKE_ACCOUNTS_SERVICE, {})); |
2582 | runner_->registerService(accounts_service_); |
2583 | + |
2584 | + registry_service_.reset(new QtDBusTest::QProcessDBusService( |
2585 | + unity::storage::registry::BUS_NAME, QDBusConnection::SessionBus, |
2586 | + REGISTRY_SERVICE, {})); |
2587 | + runner_->registerService(registry_service_); |
2588 | } |
2589 | |
2590 | DBusEnvironment::~DBusEnvironment() |
2591 | |
2592 | === modified file 'tests/utils/DBusEnvironment.h' |
2593 | --- tests/utils/DBusEnvironment.h 2016-08-04 10:12:01 +0000 |
2594 | +++ tests/utils/DBusEnvironment.h 2016-11-28 11:06:57 +0000 |
2595 | @@ -45,5 +45,6 @@ |
2596 | private: |
2597 | std::unique_ptr<QtDBusTest::DBusTestRunner> runner_; |
2598 | QSharedPointer<QtDBusTest::QProcessDBusService> accounts_service_; |
2599 | + QSharedPointer<QtDBusTest::QProcessDBusService> registry_service_; |
2600 | QSharedPointer<QtDBusTest::QProcessDBusService> demo_provider_; |
2601 | }; |
2602 | |
2603 | === modified file 'tests/utils/fake-online-accounts-daemon.py' |
2604 | --- tests/utils/fake-online-accounts-daemon.py 2016-11-16 06:08:56 +0000 |
2605 | +++ tests/utils/fake-online-accounts-daemon.py 2016-11-28 11:06:57 +0000 |
2606 | @@ -86,16 +86,16 @@ |
2607 | }, signature="sv") |
2608 | |
2609 | class Account: |
2610 | - def __init__(self, account_id, display_name, service_id, credentials, settings=None): |
2611 | + def __init__(self, account_id, name, service_id, credentials, settings=None): |
2612 | self.account_id = account_id |
2613 | - self.display_name = display_name |
2614 | + self.name = name |
2615 | self.service_id = service_id |
2616 | self.credentials = credentials |
2617 | self.settings = settings |
2618 | |
2619 | def serialise(self): |
2620 | account_info = dbus.Dictionary({ |
2621 | - "displayName": dbus.String(self.display_name), |
2622 | + "displayName": dbus.String(self.name), |
2623 | "serviceId": dbus.String(self.service_id), |
2624 | "authMethod": dbus.Int32(self.credentials.method), |
2625 | }, signature="sv") |
2626 | @@ -174,8 +174,8 @@ |
2627 | Account(4, "Password host account", "password-host-service", |
2628 | Password_Bug1628473("joe", "secret"), |
2629 | {"host": "http://www.example.com/"}), |
2630 | - Account(42, "Fake google account", "google-drive-scope", |
2631 | - OAuth2("fake-google-access-token", 0, [])), |
2632 | + Account(42, "Fake test account", "storage-provider-test", |
2633 | + OAuth2("fake-test-access-token", 0, [])), |
2634 | Account(99, "Fake mcloud account", "com.canonical.scopes.mcloud_mcloud_mcloud", |
2635 | OAuth2("fake-mcloud-access-token", 0, [])), |
2636 | ] |
FAILED: Continuous integration, rev:93 /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/190/ /jenkins. canonical. com/unity- api-1/job/ build/1011/ console /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/1018 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 812/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= yakkety/ 812/console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-storage- framework- ci/190/ rebuild
https:/