Merge lp:~thomas-voss/biometryd/extend-template-store-interface into lp:biometryd
- extend-template-store-interface
- Merge into trunk
Proposed by
Thomas Voß
Status: | Merged |
---|---|
Approved by: | Thomas Voß |
Approved revision: | 27 |
Merged at revision: | 26 |
Proposed branch: | lp:~thomas-voss/biometryd/extend-template-store-interface |
Merge into: | lp:biometryd |
Diff against target: |
553 lines (+246/-7) 16 files modified
include/biometry/devices/fingerprint_reader.h (+2/-0) include/biometry/template_store.h (+34/-2) src/biometry/dbus/interface.h (+34/-0) src/biometry/dbus/skeleton/template_store.cpp (+52/-0) src/biometry/dbus/skeleton/template_store.h (+8/-2) src/biometry/dbus/stub/template_store.cpp (+20/-0) src/biometry/dbus/stub/template_store.h (+2/-0) src/biometry/devices/dispatching.cpp (+10/-0) src/biometry/devices/dispatching.h (+2/-0) src/biometry/devices/dummy.cpp (+10/-0) src/biometry/devices/dummy.h (+2/-0) src/biometry/devices/fingerprint_reader.cpp (+10/-0) src/biometry/qml/Biometryd/plugin.cpp (+10/-0) tests/mock_device.h (+2/-0) tests/test_dbus_stub_skeleton.cpp (+8/-3) tests/test_dispatching_service_and_device.cpp (+40/-0) |
To merge this branch: | bzr merge lp:~thomas-voss/biometryd/extend-template-store-interface |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phablet Team | Pending | ||
Review via email: mp+297402@code.launchpad.net |
Commit message
Extend biometry:
list lists all known templates by id.
remove erases a specific template by id from the template store.
Description of the change
Extend biometry:
list lists all known templates by id.
remove erases a specific template by id from the template store.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'include/biometry/devices/fingerprint_reader.h' |
2 | --- include/biometry/devices/fingerprint_reader.h 2016-05-02 06:16:01 +0000 |
3 | +++ include/biometry/devices/fingerprint_reader.h 2016-06-14 21:15:36 +0000 |
4 | @@ -95,7 +95,9 @@ |
5 | |
6 | // From biometry::TemplateStore. |
7 | Operation<SizeQuery>::Ptr size(const Application& app, const User& user) override; |
8 | + Operation<List>::Ptr list(const Application& app, const User& user) override; |
9 | Operation<Enrollment>::Ptr enroll(const Application& app, const User& user) override; |
10 | + Operation<Removal>::Ptr remove(const Application& app, const User& user, TemplateStore::TemplateId id) override; |
11 | Operation<Clearance>::Ptr clear(const Application& app, const User& user) override; |
12 | |
13 | private: |
14 | |
15 | === modified file 'include/biometry/template_store.h' |
16 | --- include/biometry/template_store.h 2016-05-02 06:16:01 +0000 |
17 | +++ include/biometry/template_store.h 2016-06-14 21:15:36 +0000 |
18 | @@ -36,6 +36,9 @@ |
19 | class TemplateStore : public DoNotCopyOrMove |
20 | { |
21 | public: |
22 | + /// @brief TemplateId is a numeric uniquely identifying a biometric template. |
23 | + typedef std::uint64_t TemplateId; |
24 | + |
25 | /// @brief SizeQuery bundles the types passed to an observer of a size operation. |
26 | struct SizeQuery |
27 | { |
28 | @@ -45,13 +48,31 @@ |
29 | typedef std::uint32_t Result; ///< Describes the result of a SizeQuery operation. |
30 | }; |
31 | |
32 | + /// @brief List bundles the types passed to an observer of a size operation. |
33 | + struct List |
34 | + { |
35 | + typedef biometry::Progress Progress; ///< Progress information about the completion status of an operation. |
36 | + typedef std::string Reason; ///< Details about cancelation of an operation. |
37 | + typedef std::string Error; ///< Describes error conditions. |
38 | + typedef std::vector<TemplateId >Result; ///< Describes the result of a List operation. |
39 | + }; |
40 | + |
41 | /// @brief Enrollment bundles the types passed to an observer of enrollment operations. |
42 | struct Enrollment |
43 | { |
44 | typedef biometry::Progress Progress; ///< Progress information about the completion status of an operation. |
45 | typedef std::string Reason; ///< Details about cancelation of an operation. |
46 | typedef std::string Error; ///< Describes error conditions. |
47 | - typedef Void Result; ///< Describes the result of an enrollment operation. |
48 | + typedef TemplateId Result; ///< Describes the result of an Enrollment operation. |
49 | + }; |
50 | + |
51 | + /// @brief Remove bundles the types passed to an observer of a removal operation. |
52 | + struct Removal |
53 | + { |
54 | + typedef biometry::Progress Progress; ///< Progress information about the completion status of an operation. |
55 | + typedef std::string Reason; ///< Details about cancelation of an operation. |
56 | + typedef std::string Error; ///< Describes error conditions. |
57 | + typedef TemplateId Result; ///< Describes the result of an Enrollment operation. |
58 | }; |
59 | |
60 | /// @brief Clearance bundles the types passed to an observer of clearance operations. |
61 | @@ -60,7 +81,7 @@ |
62 | typedef biometry::Progress Progress; ///< Progress information about the completion status of an operation. |
63 | typedef std::string Reason; ///< Details about cancelation of an operation. |
64 | typedef std::string Error; ///< Describes error conditions. |
65 | - typedef Void Result; ///< Describes the result of an enrollment operation. |
66 | + typedef Void Result; ///< Describes the result of a Clearance operation. |
67 | }; |
68 | |
69 | /// @brief size() returns the number of templates known for user. |
70 | @@ -68,11 +89,22 @@ |
71 | /// @param user The user for which we want to query the number of known templates. |
72 | virtual Operation<SizeQuery>::Ptr size(const Application& app, const User& user) = 0; |
73 | |
74 | + /// @brief list returns an operation that yields the list of all templates enrolled for app and user. |
75 | + /// @param app The application requesting the information. |
76 | + /// @param user The user for which we want to query all enrolled templates. |
77 | + virtual Operation<List>::Ptr list(const Application& app, const User& user) = 0; |
78 | + |
79 | /// @brief enroll returns an operation that represents the enrollment of a new template for a user. |
80 | /// @param app The application requesting the enrollment operation. |
81 | /// @param user The user for which we want to enroll the new template. |
82 | virtual Operation<Enrollment>::Ptr enroll(const Application& app, const User& user) = 0; |
83 | |
84 | + /// @brief remove returns an operation that represents the removal of an individual template. |
85 | + /// @param app The application requesting the removal operation. |
86 | + /// @param user The user for which we want to remove a specific template. |
87 | + /// @param id The id of the template that should be removed. |
88 | + virtual Operation<Removal>::Ptr remove(const Application& app, const User& user, TemplateId id) = 0; |
89 | + |
90 | /// @brief clear returns an operation that represents removal of all templates associated to user. |
91 | /// @param app The application requesting the clear operation. |
92 | /// @param user The user for which we want to clear templates for. |
93 | |
94 | === modified file 'src/biometry/dbus/interface.h' |
95 | --- src/biometry/dbus/interface.h 2016-05-02 06:16:01 +0000 |
96 | +++ src/biometry/dbus/interface.h 2016-06-14 21:15:36 +0000 |
97 | @@ -193,6 +193,23 @@ |
98 | } |
99 | }; |
100 | |
101 | + struct List |
102 | + { |
103 | + static inline const std::string& name() |
104 | + { |
105 | + static const std::string s{"List"}; |
106 | + return s; |
107 | + } |
108 | + |
109 | + typedef biometry::dbus::interface::TemplateStore Interface; |
110 | + typedef core::dbus::types::ObjectPath ResultType; |
111 | + |
112 | + inline static const std::chrono::milliseconds default_timeout() |
113 | + { |
114 | + return std::chrono::seconds{1}; |
115 | + } |
116 | + }; |
117 | + |
118 | struct Enroll |
119 | { |
120 | static inline const std::string& name() |
121 | @@ -211,6 +228,23 @@ |
122 | } |
123 | }; |
124 | |
125 | + struct Remove |
126 | + { |
127 | + static inline const std::string& name() |
128 | + { |
129 | + static const std::string s{"Remove"}; |
130 | + return s; |
131 | + } |
132 | + |
133 | + typedef biometry::dbus::interface::TemplateStore Interface; |
134 | + typedef core::dbus::types::ObjectPath ResultType; |
135 | + |
136 | + inline static const std::chrono::milliseconds default_timeout() |
137 | + { |
138 | + return std::chrono::seconds{1}; |
139 | + } |
140 | + }; |
141 | + |
142 | struct Clear |
143 | { |
144 | static inline const std::string& name() |
145 | |
146 | === modified file 'src/biometry/dbus/skeleton/template_store.cpp' |
147 | --- src/biometry/dbus/skeleton/template_store.cpp 2016-05-04 12:17:44 +0000 |
148 | +++ src/biometry/dbus/skeleton/template_store.cpp 2016-06-14 21:15:36 +0000 |
149 | @@ -44,11 +44,21 @@ |
150 | return impl.get().size(app, user); |
151 | } |
152 | |
153 | +biometry::Operation<biometry::TemplateStore::List>::Ptr biometry::dbus::skeleton::TemplateStore::list(const biometry::Application& app, const biometry::User& user) |
154 | +{ |
155 | + return impl.get().list(app, user); |
156 | +} |
157 | + |
158 | biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr biometry::dbus::skeleton::TemplateStore::enroll(const biometry::Application& app, const biometry::User& user) |
159 | { |
160 | return impl.get().enroll(app, user); |
161 | } |
162 | |
163 | +biometry::Operation<biometry::TemplateStore::Removal>::Ptr biometry::dbus::skeleton::TemplateStore::remove(const biometry::Application& app, const biometry::User& user, biometry::TemplateStore::TemplateId id) |
164 | +{ |
165 | + return impl.get().remove(app, user, id); |
166 | +} |
167 | + |
168 | biometry::Operation<biometry::TemplateStore::Clearance>::Ptr biometry::dbus::skeleton::TemplateStore::clear(const biometry::Application& app, const biometry::User& user) |
169 | { |
170 | return impl.get().clear(app, user); |
171 | @@ -85,6 +95,27 @@ |
172 | this->bus->send(reply); |
173 | }); |
174 | |
175 | + object->install_method_handler<biometry::dbus::interface::TemplateStore::Methods::List>([this](const core::dbus::Message::Ptr& msg) |
176 | + { |
177 | + biometry::User user; biometry::Application app = biometry::Application::system(); |
178 | + auto reader = msg->reader(); reader >> app >> user; |
179 | + auto op = list(app, user); |
180 | + |
181 | + core::dbus::types::ObjectPath op_path |
182 | + { |
183 | + (boost::format{"%1%/operation/list/%2%"} % this->object->path().as_string() % util::counter<TemplateStore>().increment()).str() |
184 | + }; |
185 | + |
186 | + ops.list.synchronized([this, op_path, op](ListOps::ValueType& ops) |
187 | + { |
188 | + ops[op_path] = skeleton::Operation<List>::create_for_object(this->bus, this->service->add_object_for_path(op_path), op); |
189 | + }); |
190 | + |
191 | + auto reply = core::dbus::Message::make_method_return(msg); |
192 | + reply->writer() << op_path; |
193 | + this->bus->send(reply); |
194 | + }); |
195 | + |
196 | object->install_method_handler<biometry::dbus::interface::TemplateStore::Methods::Enroll>([this](const core::dbus::Message::Ptr& msg) |
197 | { |
198 | biometry::User user; biometry::Application app = biometry::Application::system(); |
199 | @@ -106,6 +137,27 @@ |
200 | this->bus->send(reply); |
201 | }); |
202 | |
203 | + object->install_method_handler<biometry::dbus::interface::TemplateStore::Methods::Remove>([this](const core::dbus::Message::Ptr& msg) |
204 | + { |
205 | + biometry::User user; biometry::Application app = biometry::Application::system(); biometry::TemplateStore::TemplateId id{0}; |
206 | + auto reader = msg->reader(); reader >> app >> user >> id; |
207 | + auto op = remove(app, user, id); |
208 | + |
209 | + core::dbus::types::ObjectPath op_path |
210 | + { |
211 | + (boost::format{"%1%/operation/remove/%2%"} % this->object->path().as_string() % util::counter<TemplateStore>().increment()).str() |
212 | + }; |
213 | + |
214 | + ops.remove.synchronized([this, op_path, op](RemoveOps::ValueType& ops) |
215 | + { |
216 | + ops[op_path] = skeleton::Operation<Removal>::create_for_object(this->bus, this->service->add_object_for_path(op_path), op); |
217 | + }); |
218 | + |
219 | + auto reply = core::dbus::Message::make_method_return(msg); |
220 | + reply->writer() << op_path; |
221 | + this->bus->send(reply); |
222 | + }); |
223 | + |
224 | object->install_method_handler<biometry::dbus::interface::TemplateStore::Methods::Clear>([this](const core::dbus::Message::Ptr& msg) |
225 | { |
226 | biometry::User user; biometry::Application app = biometry::Application::system(); |
227 | |
228 | === modified file 'src/biometry/dbus/skeleton/template_store.h' |
229 | --- src/biometry/dbus/skeleton/template_store.h 2016-05-04 12:17:44 +0000 |
230 | +++ src/biometry/dbus/skeleton/template_store.h 2016-06-14 21:15:36 +0000 |
231 | @@ -55,12 +55,16 @@ |
232 | // From biometry::Identifier. |
233 | // biometry::Operation<biometry::TemplateStore::Enrollment> |
234 | Operation<SizeQuery>::Ptr size(const Application&, const User&) override; |
235 | + Operation<List>::Ptr list(const Application& app, const User& user) override; |
236 | Operation<Enrollment>::Ptr enroll(const Application&, const User&) override; |
237 | + Operation<Removal>::Ptr remove(const Application& app, const User& user, TemplateStore::TemplateId id) override; |
238 | Operation<Clearance>::Ptr clear(const Application&, const User&) override; |
239 | |
240 | private: |
241 | typedef util::Synchronized<std::unordered_map<core::dbus::types::ObjectPath, Operation<SizeQuery>::Ptr>> SizeOps; |
242 | + typedef util::Synchronized<std::unordered_map<core::dbus::types::ObjectPath, Operation<List>::Ptr>> ListOps; |
243 | typedef util::Synchronized<std::unordered_map<core::dbus::types::ObjectPath, Operation<Enrollment>::Ptr>> EnrollOps; |
244 | + typedef util::Synchronized<std::unordered_map<core::dbus::types::ObjectPath, Operation<Removal>::Ptr>> RemoveOps; |
245 | typedef util::Synchronized<std::unordered_map<core::dbus::types::ObjectPath, Operation<Clearance>::Ptr>> ClearOps; |
246 | |
247 | /// @brief TemplateStore creates a new instance for the given remote service and object. |
248 | @@ -76,8 +80,10 @@ |
249 | struct |
250 | { |
251 | SizeOps size; |
252 | - EnrollOps enroll; |
253 | - ClearOps clear; |
254 | + ListOps list; |
255 | + EnrollOps enroll; |
256 | + RemoveOps remove; |
257 | + ClearOps clear; |
258 | } ops; |
259 | }; |
260 | } |
261 | |
262 | === modified file 'src/biometry/dbus/stub/template_store.cpp' |
263 | --- src/biometry/dbus/stub/template_store.cpp 2016-05-02 06:16:01 +0000 |
264 | +++ src/biometry/dbus/stub/template_store.cpp 2016-06-14 21:15:36 +0000 |
265 | @@ -44,6 +44,16 @@ |
266 | return Operation<SizeQuery>::create_for_object_and_service(bus, service, service->object_for_path(result.value())); |
267 | } |
268 | |
269 | +biometry::Operation<biometry::TemplateStore::List>::Ptr biometry::dbus::stub::TemplateStore::list(const biometry::Application& app, const biometry::User& user) |
270 | +{ |
271 | + auto result = object->transact_method< |
272 | + biometry::dbus::interface::TemplateStore::Methods::List, |
273 | + biometry::dbus::interface::TemplateStore::Methods::List::ResultType |
274 | + >(app, user); |
275 | + |
276 | + return Operation<List>::create_for_object_and_service(bus, service, service->object_for_path(result.value())); |
277 | +} |
278 | + |
279 | biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr biometry::dbus::stub::TemplateStore::enroll(const biometry::Application& app, const biometry::User& user) |
280 | { |
281 | auto result = object->transact_method< |
282 | @@ -54,6 +64,16 @@ |
283 | return Operation<Enrollment>::create_for_object_and_service(bus, service, service->object_for_path(result.value())); |
284 | } |
285 | |
286 | +biometry::Operation<biometry::TemplateStore::Removal>::Ptr biometry::dbus::stub::TemplateStore::remove(const biometry::Application& app, const biometry::User& user, biometry::TemplateStore::TemplateId id) |
287 | +{ |
288 | + auto result = object->transact_method< |
289 | + biometry::dbus::interface::TemplateStore::Methods::Remove, |
290 | + biometry::dbus::interface::TemplateStore::Methods::Remove::ResultType |
291 | + >(app, user, id); |
292 | + |
293 | + return Operation<Removal>::create_for_object_and_service(bus, service, service->object_for_path(result.value())); |
294 | +} |
295 | + |
296 | biometry::Operation<biometry::TemplateStore::Clearance>::Ptr biometry::dbus::stub::TemplateStore::clear(const biometry::Application& app, const biometry::User& user) |
297 | { |
298 | auto result = object->transact_method< |
299 | |
300 | === modified file 'src/biometry/dbus/stub/template_store.h' |
301 | --- src/biometry/dbus/stub/template_store.h 2016-05-02 06:16:01 +0000 |
302 | +++ src/biometry/dbus/stub/template_store.h 2016-06-14 21:15:36 +0000 |
303 | @@ -44,7 +44,9 @@ |
304 | // From biometry::Identifier. |
305 | // biometry::Operation<biometry::TemplateStore::Enrollment> |
306 | Operation<SizeQuery>::Ptr size(const Application&, const User&) override; |
307 | + Operation<TemplateStore::List>::Ptr list(const Application& app, const User& user) override; |
308 | Operation<Enrollment>::Ptr enroll(const Application&, const User&) override; |
309 | + Operation<TemplateStore::Removal>::Ptr remove(const Application& app, const User& user, TemplateStore::TemplateId id) override; |
310 | Operation<Clearance>::Ptr clear(const Application&, const User&) override; |
311 | |
312 | private: |
313 | |
314 | === modified file 'src/biometry/devices/dispatching.cpp' |
315 | --- src/biometry/devices/dispatching.cpp 2016-05-04 12:17:44 +0000 |
316 | +++ src/biometry/devices/dispatching.cpp 2016-06-14 21:15:36 +0000 |
317 | @@ -71,11 +71,21 @@ |
318 | return std::make_shared<DispatchingOperation<biometry::TemplateStore::SizeQuery>>(dispatcher, impl->template_store().size(app, user)); |
319 | } |
320 | |
321 | +biometry::Operation<biometry::TemplateStore::List>::Ptr biometry::devices::Dispatching::TemplateStore::list(const biometry::Application& app, const biometry::User& user) |
322 | +{ |
323 | + return std::make_shared<DispatchingOperation<biometry::TemplateStore::List>>(dispatcher, impl->template_store().list(app, user)); |
324 | +} |
325 | + |
326 | biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr biometry::devices::Dispatching::TemplateStore::enroll(const biometry::Application& app, const biometry::User& user) |
327 | { |
328 | return std::make_shared<DispatchingOperation<biometry::TemplateStore::Enrollment>>(dispatcher, impl->template_store().enroll(app, user)); |
329 | } |
330 | |
331 | +biometry::Operation<biometry::TemplateStore::Removal>::Ptr biometry::devices::Dispatching::TemplateStore::remove(const biometry::Application& app, const biometry::User& user, biometry::TemplateStore::TemplateId id) |
332 | +{ |
333 | + return std::make_shared<DispatchingOperation<biometry::TemplateStore::Removal>>(dispatcher, impl->template_store().remove(app, user, id)); |
334 | +} |
335 | + |
336 | biometry::Operation<biometry::TemplateStore::Clearance>::Ptr biometry::devices::Dispatching::TemplateStore::clear(const biometry::Application& app, const biometry::User& user) |
337 | { |
338 | return std::make_shared<DispatchingOperation<biometry::TemplateStore::Clearance>>(dispatcher, impl->template_store().clear(app, user)); |
339 | |
340 | === modified file 'src/biometry/devices/dispatching.h' |
341 | --- src/biometry/devices/dispatching.h 2016-05-04 12:17:44 +0000 |
342 | +++ src/biometry/devices/dispatching.h 2016-06-14 21:15:36 +0000 |
343 | @@ -50,7 +50,9 @@ |
344 | |
345 | // From biometry::TemplateStore. |
346 | biometry::Operation<biometry::TemplateStore::SizeQuery>::Ptr size(const biometry::Application& app, const biometry::User& user) override; |
347 | + biometry::Operation<biometry::TemplateStore::List>::Ptr list(const biometry::Application& app, const biometry::User& user) override; |
348 | biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr enroll(const biometry::Application& app, const biometry::User& user) override; |
349 | + biometry::Operation<biometry::TemplateStore::Removal>::Ptr remove(const biometry::Application& app, const biometry::User& user, biometry::TemplateStore::TemplateId id) override; |
350 | biometry::Operation<biometry::TemplateStore::Clearance>::Ptr clear(const biometry::Application& app, const biometry::User& user) override; |
351 | |
352 | private: |
353 | |
354 | === modified file 'src/biometry/devices/dummy.cpp' |
355 | --- src/biometry/devices/dummy.cpp 2016-05-11 14:39:41 +0000 |
356 | +++ src/biometry/devices/dummy.cpp 2016-06-14 21:15:36 +0000 |
357 | @@ -28,11 +28,21 @@ |
358 | return std::make_shared<Dummy::Operation<biometry::TemplateStore::SizeQuery>>(); |
359 | } |
360 | |
361 | +biometry::Operation<biometry::TemplateStore::List>::Ptr biometry::devices::Dummy::TemplateStore::list(const biometry::Application&, const biometry::User&) |
362 | +{ |
363 | + return std::make_shared<Dummy::Operation<biometry::TemplateStore::List>>(); |
364 | +} |
365 | + |
366 | biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr biometry::devices::Dummy::TemplateStore::enroll(const biometry::Application&, const biometry::User&) |
367 | { |
368 | return std::make_shared<Dummy::Operation<biometry::TemplateStore::Enrollment>>(); |
369 | } |
370 | |
371 | +biometry::Operation<biometry::TemplateStore::Removal>::Ptr biometry::devices::Dummy::TemplateStore::remove(const biometry::Application&, const biometry::User&, biometry::TemplateStore::TemplateId) |
372 | +{ |
373 | + return std::make_shared<Dummy::Operation<biometry::TemplateStore::Removal>>(); |
374 | +} |
375 | + |
376 | biometry::Operation<biometry::TemplateStore::Clearance>::Ptr biometry::devices::Dummy::TemplateStore::clear(const biometry::Application&, const biometry::User&) |
377 | { |
378 | return std::make_shared<Dummy::Operation<biometry::TemplateStore::Clearance>>(); |
379 | |
380 | === modified file 'src/biometry/devices/dummy.h' |
381 | --- src/biometry/devices/dummy.h 2016-05-11 14:39:41 +0000 |
382 | +++ src/biometry/devices/dummy.h 2016-06-14 21:15:36 +0000 |
383 | @@ -57,7 +57,9 @@ |
384 | public: |
385 | // From biometry::TemplateStore. |
386 | biometry::Operation<biometry::TemplateStore::SizeQuery>::Ptr size(const biometry::Application& app, const biometry::User& user) override; |
387 | + biometry::Operation<biometry::TemplateStore::List>::Ptr list(const biometry::Application& app, const biometry::User& user) override; |
388 | biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr enroll(const biometry::Application& app, const biometry::User& user) override; |
389 | + biometry::Operation<biometry::TemplateStore::Removal>::Ptr remove(const biometry::Application& app, const biometry::User& user, biometry::TemplateStore::TemplateId id) override; |
390 | biometry::Operation<biometry::TemplateStore::Clearance>::Ptr clear(const biometry::Application& app, const biometry::User& user) override; |
391 | }; |
392 | |
393 | |
394 | === modified file 'src/biometry/devices/fingerprint_reader.cpp' |
395 | --- src/biometry/devices/fingerprint_reader.cpp 2016-05-02 06:16:01 +0000 |
396 | +++ src/biometry/devices/fingerprint_reader.cpp 2016-06-14 21:15:36 +0000 |
397 | @@ -150,11 +150,21 @@ |
398 | return impl.get().size(app, user); |
399 | } |
400 | |
401 | +biometry::Operation<biometry::TemplateStore::List>::Ptr biometry::devices::FingerprintReader::TemplateStore::list(const Application& app, const User& user) |
402 | +{ |
403 | + return impl.get().list(app, user); |
404 | +} |
405 | + |
406 | biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr biometry::devices::FingerprintReader::TemplateStore::enroll(const Application& app, const User& user) |
407 | { |
408 | return impl.get().enroll(app, user); |
409 | } |
410 | |
411 | +biometry::Operation<biometry::TemplateStore::Removal>::Ptr biometry::devices::FingerprintReader::TemplateStore::remove(const Application& app, const User& user, TemplateId id) |
412 | +{ |
413 | + return impl.get().remove(app, user, id); |
414 | +} |
415 | + |
416 | biometry::Operation<biometry::TemplateStore::Clearance>::Ptr biometry::devices::FingerprintReader::TemplateStore::clear(const Application& app, const User& user) |
417 | { |
418 | return impl.get().clear(app, user); |
419 | |
420 | === modified file 'src/biometry/qml/Biometryd/plugin.cpp' |
421 | --- src/biometry/qml/Biometryd/plugin.cpp 2016-05-02 06:16:01 +0000 |
422 | +++ src/biometry/qml/Biometryd/plugin.cpp 2016-06-14 21:15:36 +0000 |
423 | @@ -46,11 +46,21 @@ |
424 | return biometry::Operation<SizeQuery>::Ptr{}; |
425 | } |
426 | |
427 | + biometry::Operation<biometry::TemplateStore::List>::Ptr list(const biometry::Application&, const biometry::User&) override |
428 | + { |
429 | + return biometry::Operation<List>::Ptr{}; |
430 | + } |
431 | + |
432 | biometry::Operation<Enrollment>::Ptr enroll(const biometry::Application&, const biometry::User&) override |
433 | { |
434 | return biometry::Operation<Enrollment>::Ptr{}; |
435 | } |
436 | |
437 | + biometry::Operation<Removal>::Ptr remove(const biometry::Application&, const biometry::User&, biometry::TemplateStore::TemplateId) override |
438 | + { |
439 | + return biometry::Operation<Removal>::Ptr{}; |
440 | + } |
441 | + |
442 | biometry::Operation<Clearance>::Ptr clear(const biometry::Application&, const biometry::User&) override |
443 | { |
444 | return biometry::Operation<Clearance>::Ptr{}; |
445 | |
446 | === modified file 'tests/mock_device.h' |
447 | --- tests/mock_device.h 2016-05-02 06:16:01 +0000 |
448 | +++ tests/mock_device.h 2016-06-14 21:15:36 +0000 |
449 | @@ -75,7 +75,9 @@ |
450 | struct MockTemplateStore : public biometry::TemplateStore |
451 | { |
452 | MOCK_METHOD2(size, biometry::Operation<SizeQuery>::Ptr(const biometry::Application&, const biometry::User&)); |
453 | + MOCK_METHOD2(list, biometry::Operation<List>::Ptr(const biometry::Application&, const biometry::User&)); |
454 | MOCK_METHOD2(enroll, biometry::Operation<Enrollment>::Ptr (const biometry::Application&, const biometry::User&)); |
455 | + MOCK_METHOD3(remove, biometry::Operation<Removal>::Ptr(const biometry::Application&, const biometry::User&, biometry::TemplateStore::TemplateId)); |
456 | MOCK_METHOD2(clear, biometry::Operation<Clearance>::Ptr(const biometry::Application&, const biometry::User&)); |
457 | }; |
458 | |
459 | |
460 | === modified file 'tests/test_dbus_stub_skeleton.cpp' |
461 | --- tests/test_dbus_stub_skeleton.cpp 2016-05-02 06:16:01 +0000 |
462 | +++ tests/test_dbus_stub_skeleton.cpp 2016-06-14 21:15:36 +0000 |
463 | @@ -134,7 +134,9 @@ |
464 | |
465 | auto template_store = std::make_shared<NiceMock<MockTemplateStore>>(); |
466 | ON_CALL(*template_store, size(_, _)).WillByDefault(Return(std::make_shared<MockOperation<biometry::TemplateStore::SizeQuery>>())); |
467 | + ON_CALL(*template_store, list(_, _)).WillByDefault(Return(std::make_shared<MockOperation<biometry::TemplateStore::List>>())); |
468 | ON_CALL(*template_store, enroll(_, _)).WillByDefault(Return(std::make_shared<MockOperation<biometry::TemplateStore::Enrollment>>())); |
469 | + ON_CALL(*template_store, remove(_, _, _)).WillByDefault(Return(std::make_shared<MockOperation<biometry::TemplateStore::Removal>>())); |
470 | ON_CALL(*template_store, clear(_, _)).WillByDefault(Return(std::make_shared<MockOperation<biometry::TemplateStore::Clearance>>())); |
471 | |
472 | auto device = std::make_shared<NiceMock<MockDevice>>(); |
473 | @@ -154,16 +156,19 @@ |
474 | auto app = biometry::Application::system(); |
475 | auto reason = biometry::Reason::unknown(); |
476 | auto user = biometry::User::current(); |
477 | + auto id = biometry::TemplateStore::TemplateId{42}; |
478 | |
479 | auto scope = stub_scope(); |
480 | auto service = biometry::dbus::stub::Service::create_for_bus(scope->bus); |
481 | auto device = service->default_device(); |
482 | |
483 | auto f1 = start<biometry::TemplateStore::SizeQuery>(device->template_store().size(app, user)); |
484 | - auto f2 = start<biometry::TemplateStore::Enrollment>(device->template_store().enroll(app, user)); |
485 | - auto f3 = start<biometry::TemplateStore::Clearance>(device->template_store().clear(app, user)); |
486 | + auto f2 = start<biometry::TemplateStore::List>(device->template_store().list(app, user)); |
487 | + auto f3 = start<biometry::TemplateStore::Enrollment>(device->template_store().enroll(app, user)); |
488 | + auto f4 = start<biometry::TemplateStore::Removal>(device->template_store().remove(app, user, id)); |
489 | + auto f5 = start<biometry::TemplateStore::Clearance>(device->template_store().clear(app, user)); |
490 | |
491 | - auto f4 = start<biometry::Identification>(device->identifier().identify_user(app, reason)); |
492 | + auto f6 = start<biometry::Identification>(device->identifier().identify_user(app, reason)); |
493 | |
494 | return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
495 | }; |
496 | |
497 | === modified file 'tests/test_dispatching_service_and_device.cpp' |
498 | --- tests/test_dispatching_service_and_device.cpp 2016-05-04 12:17:44 +0000 |
499 | +++ tests/test_dispatching_service_and_device.cpp 2016-06-14 21:15:36 +0000 |
500 | @@ -51,6 +51,26 @@ |
501 | op->start_with_observer(mock_observer); |
502 | } |
503 | |
504 | +TEST(DispatchingDevice, calls_into_dispatcher_for_template_store_list) |
505 | +{ |
506 | + using namespace testing; |
507 | + auto mock_observer = std::make_shared<NiceMock<MockObserver<biometry::TemplateStore::List>>>(); |
508 | + |
509 | + auto template_store = std::make_shared<NiceMock<MockTemplateStore>>(); |
510 | + ON_CALL(*template_store, list(_, _)).WillByDefault(Return(std::make_shared<NiceMock<MockOperation<biometry::TemplateStore::List>>>())); |
511 | + |
512 | + auto device = std::make_shared<NiceMock<MockDevice>>(); |
513 | + ON_CALL(*device, template_store()).WillByDefault(ReturnRef(*template_store)); |
514 | + |
515 | + auto dispatcher = std::make_shared<NiceMock<MockDispatcher>>(); |
516 | + EXPECT_CALL(*dispatcher, dispatch(_)).Times(1).WillOnce(Invoke([](const biometry::util::Dispatcher::Task& task) { task(); })); |
517 | + |
518 | + auto dispatching = std::make_shared<biometry::devices::Dispatching>(dispatcher, device); |
519 | + auto op = dispatching->template_store().list(biometry::Application::system(), biometry::User::current()); |
520 | + |
521 | + op->start_with_observer(mock_observer); |
522 | +} |
523 | + |
524 | TEST(DispatchingDevice, calls_into_dispatcher_for_template_store_size_enrollment) |
525 | { |
526 | using namespace testing; |
527 | @@ -71,6 +91,26 @@ |
528 | op->start_with_observer(mock_observer); |
529 | } |
530 | |
531 | +TEST(DispatchingDevice, calls_into_dispatcher_for_template_store_removal) |
532 | +{ |
533 | + using namespace testing; |
534 | + auto mock_observer = std::make_shared<NiceMock<MockObserver<biometry::TemplateStore::Removal>>>(); |
535 | + |
536 | + auto template_store = std::make_shared<NiceMock<MockTemplateStore>>(); |
537 | + ON_CALL(*template_store, remove(_, _, _)).WillByDefault(Return(std::make_shared<NiceMock<MockOperation<biometry::TemplateStore::Removal>>>())); |
538 | + |
539 | + auto device = std::make_shared<NiceMock<MockDevice>>(); |
540 | + ON_CALL(*device, template_store()).WillByDefault(ReturnRef(*template_store)); |
541 | + |
542 | + auto dispatcher = std::make_shared<NiceMock<MockDispatcher>>(); |
543 | + EXPECT_CALL(*dispatcher, dispatch(_)).Times(1).WillOnce(Invoke([](const biometry::util::Dispatcher::Task& task) { task(); })); |
544 | + |
545 | + auto dispatching = std::make_shared<biometry::devices::Dispatching>(dispatcher, device); |
546 | + auto op = dispatching->template_store().remove(biometry::Application::system(), biometry::User::current(), 42); |
547 | + |
548 | + op->start_with_observer(mock_observer); |
549 | +} |
550 | + |
551 | TEST(DispatchingDevice, calls_into_dispatcher_for_template_store_clearance) |
552 | { |
553 | using namespace testing; |