16
16
* Authored by: Thomas Voß <thomas.voss@canonical.com>
18
#include <com/ubuntu/location/service/stub.h>
19
#include <com/ubuntu/location/service/session/stub.h>
18
#include <location/service/stub.h>
19
#include <location/service/session/stub.h>
21
#include <com/ubuntu/location/logging.h>
21
#include <location/logging.h>
23
23
#include <core/dbus/property.h>
25
namespace cul = com::ubuntu::location;
26
namespace culs = com::ubuntu::location::service;
27
namespace culss = com::ubuntu::location::service::session;
29
25
namespace dbus = core::dbus;
31
struct culs::Stub::Private
27
struct location::service::Stub::Private
33
29
Private(const dbus::Bus::Ptr& connection,
34
30
const dbus::Object::Ptr& object)
37
state(object->get_property<culs::Interface::Properties::State>()),
38
does_satellite_based_positioning(object->get_property<culs::Interface::Properties::DoesSatelliteBasedPositioning>()),
39
does_report_cell_and_wifi_ids(object->get_property<culs::Interface::Properties::DoesReportCellAndWifiIds>()),
40
is_online(object->get_property<culs::Interface::Properties::IsOnline>()),
41
visible_space_vehicles(object->get_property<culs::Interface::Properties::VisibleSpaceVehicles>())
33
state(object->get_property<location::service::Interface::Properties::State>()),
34
does_satellite_based_positioning(object->get_property<location::service::Interface::Properties::DoesSatelliteBasedPositioning>()),
35
does_report_cell_and_wifi_ids(object->get_property<location::service::Interface::Properties::DoesReportCellAndWifiIds>()),
36
is_online(object->get_property<location::service::Interface::Properties::IsOnline>()),
37
visible_space_vehicles(object->get_property<location::service::Interface::Properties::VisibleSpaceVehicles>())
45
41
dbus::Bus::Ptr bus;
46
42
dbus::Object::Ptr object;
47
std::shared_ptr<dbus::Property<culs::Interface::Properties::State>> state;
48
std::shared_ptr<dbus::Property<culs::Interface::Properties::DoesSatelliteBasedPositioning>> does_satellite_based_positioning;
49
std::shared_ptr<dbus::Property<culs::Interface::Properties::DoesReportCellAndWifiIds>> does_report_cell_and_wifi_ids;
50
std::shared_ptr<dbus::Property<culs::Interface::Properties::IsOnline>> is_online;
51
std::shared_ptr<dbus::Property<culs::Interface::Properties::VisibleSpaceVehicles>> visible_space_vehicles;
43
std::shared_ptr<dbus::Property<location::service::Interface::Properties::State>> state;
44
std::shared_ptr<dbus::Property<location::service::Interface::Properties::DoesSatelliteBasedPositioning>> does_satellite_based_positioning;
45
std::shared_ptr<dbus::Property<location::service::Interface::Properties::DoesReportCellAndWifiIds>> does_report_cell_and_wifi_ids;
46
std::shared_ptr<dbus::Property<location::service::Interface::Properties::IsOnline>> is_online;
47
std::shared_ptr<dbus::Property<location::service::Interface::Properties::VisibleSpaceVehicles>> visible_space_vehicles;
54
culs::Stub::Stub(const dbus::Bus::Ptr& connection) : dbus::Stub<culs::Interface>(connection),
55
d(new Private{connection, access_service()->object_for_path(culs::Interface::path())})
59
culs::Stub::~Stub() noexcept
63
culss::Interface::Ptr culs::Stub::create_session_for_criteria(const cul::Criteria& criteria)
50
location::service::Stub::Stub(const dbus::Bus::Ptr& connection) : dbus::Stub<location::service::Interface>(connection),
51
d(new Private{connection, access_service()->object_for_path(location::service::Interface::path())})
55
location::service::Stub::~Stub() noexcept
59
location::service::session::Interface::Ptr location::service::Stub::create_session_for_criteria(const location::Criteria& criteria)
65
61
auto op = d->object->transact_method<
66
culs::Interface::CreateSessionForCriteria,
67
culs::Interface::CreateSessionForCriteria::ResultType
62
location::service::Interface::CreateSessionForCriteria,
63
location::service::Interface::CreateSessionForCriteria::ResultType
73
69
throw std::runtime_error(ss.str());
76
return culss::Interface::Ptr(new culss::Stub{d->bus, op.value()});
72
return location::service::session::Interface::Ptr(new location::service::session::Stub{d->bus, op.value()});
79
const core::Property<culs::State>& culs::Stub::state() const
75
const core::Property<location::service::State>& location::service::Stub::state() const
84
core::Property<bool>& culs::Stub::does_satellite_based_positioning()
80
core::Property<bool>& location::service::Stub::does_satellite_based_positioning()
86
82
return *d->does_satellite_based_positioning;
89
core::Property<bool>& culs::Stub::does_report_cell_and_wifi_ids()
85
core::Property<bool>& location::service::Stub::does_report_cell_and_wifi_ids()
91
87
return *d->does_report_cell_and_wifi_ids;
94
core::Property<bool>& culs::Stub::is_online()
90
core::Property<bool>& location::service::Stub::is_online()
96
92
return *d->is_online;
99
core::Property<std::map<cul::SpaceVehicle::Key, cul::SpaceVehicle>>& culs::Stub::visible_space_vehicles()
95
core::Property<std::map<location::SpaceVehicle::Key, location::SpaceVehicle>>& location::service::Stub::visible_space_vehicles()
101
97
return *d->visible_space_vehicles;