~thomas-voss/biometryd/remove-obsolete-configuration-header

« back to all changes in this revision

Viewing changes to src/biometry/dbus/stub/service.cpp

  • Committer: Thomas Voß
  • Date: 2016-05-02 06:16:01 UTC
  • Revision ID: thomas.voss@canonical.com-20160502061601-vqzwfw4c0rxfna04
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 
17
 *
 
18
 */
 
19
 
 
20
#include <biometry/dbus/stub/service.h>
 
21
 
 
22
#include <biometry/dbus/interface.h>
 
23
#include <biometry/dbus/stub/device.h>
 
24
 
 
25
biometry::dbus::stub::Service::Ptr biometry::dbus::stub::Service::create_for_bus(const core::dbus::Bus::Ptr& bus)
 
26
{
 
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}};
 
30
}
 
31
 
 
32
// From biometry::Service.
 
33
std::shared_ptr<biometry::Device> biometry::dbus::stub::Service::default_device() const
 
34
{
 
35
    auto result = object->transact_method<
 
36
            biometry::dbus::interface::Service::Methods::DefaultDevice,
 
37
            biometry::dbus::interface::Service::Methods::DefaultDevice::ResultType
 
38
    >();
 
39
 
 
40
    if (result.is_error())
 
41
        throw std::runtime_error{result.error().print()};
 
42
 
 
43
    return std::make_shared<biometry::dbus::stub::Device>(bus, service, service->object_for_path(result.value()));
 
44
}
 
45
 
 
46
biometry::dbus::stub::Service::Service(const core::dbus::Bus::Ptr& bus, const core::dbus::Service::Ptr& service, const core::dbus::Object::Ptr& object)
 
47
    : bus{bus},
 
48
      service{service},
 
49
      object{object}
 
50
{
 
51
}