2
* Copyright (C) 2016 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Thomas Voß <thomas.voss@canonical.com>
20
#include <biometry/dbus/stub/service.h>
22
#include <biometry/dbus/interface.h>
23
#include <biometry/dbus/stub/device.h>
25
biometry::dbus::stub::Service::Ptr biometry::dbus::stub::Service::create_for_bus(const core::dbus::Bus::Ptr& bus)
27
auto service = core::dbus::Service::use_service(bus, biometry::dbus::interface::Service::name());
28
auto object = service->object_for_path(biometry::dbus::interface::Service::path());
29
return Ptr{new Service{bus, service, object}};
32
// From biometry::Service.
33
std::shared_ptr<biometry::Device> biometry::dbus::stub::Service::default_device() const
35
auto result = object->transact_method<
36
biometry::dbus::interface::Service::Methods::DefaultDevice,
37
biometry::dbus::interface::Service::Methods::DefaultDevice::ResultType
40
if (result.is_error())
41
throw std::runtime_error{result.error().print()};
43
return std::make_shared<biometry::dbus::stub::Device>(bus, service, service->object_for_path(result.value()));
46
biometry::dbus::stub::Service::Service(const core::dbus::Bus::Ptr& bus, const core::dbus::Service::Ptr& service, const core::dbus::Object::Ptr& object)