36
void culpg::Provider::start()
33
void location::providers::geoclue::Provider::start()
38
35
if (!worker.joinable())
39
36
worker = std::move(std::thread{std::bind(&dbus::Bus::run, bus)});
42
void culpg::Provider::stop()
39
void location::providers::geoclue::Provider::stop()
45
42
if (worker.joinable())
49
void culpg::Provider::on_position_changed(const fd::Geoclue::Position::Signals::PositionChanged::ArgumentType& arg)
46
void location::providers::geoclue::Provider::on_position_changed(const fd::Geoclue::Position::Signals::PositionChanged::ArgumentType& arg)
51
48
fd::Geoclue::Position::FieldFlags flags{static_cast<unsigned long>(std::get<0>(arg))};
49
location::Position pos
54
51
flags.test(fd::Geoclue::Position::Field::latitude) ?
55
cul::wgs84::Latitude{std::get<2>(arg)* cul::units::Degrees} : cul::wgs84::Latitude{},
52
location::wgs84::Latitude{std::get<2>(arg)* location::units::Degrees} : location::wgs84::Latitude{},
56
53
flags.test(fd::Geoclue::Position::Field::longitude) ?
57
cul::wgs84::Longitude{std::get<3>(arg)* cul::units::Degrees} : cul::wgs84::Longitude{}
54
location::wgs84::Longitude{std::get<3>(arg)* location::units::Degrees} : location::wgs84::Longitude{}
60
57
if (flags.test(fd::Geoclue::Position::Field::altitude))
61
pos.altitude = cul::wgs84::Altitude{std::get<4>(arg)* cul::units::Meters};
58
pos.altitude = location::wgs84::Altitude{std::get<4>(arg)* location::units::Meters};
63
cul::Update<cul::Position> update(pos);
60
location::Update<location::Position> update(pos);
64
61
mutable_updates().position(update);
67
void culpg::Provider::on_velocity_changed(const fd::Geoclue::Velocity::Signals::VelocityChanged::ArgumentType& arg)
64
void location::providers::geoclue::Provider::on_velocity_changed(const fd::Geoclue::Velocity::Signals::VelocityChanged::ArgumentType& arg)
69
66
fd::Geoclue::Velocity::FieldFlags flags{static_cast<unsigned long>(std::get<0>(arg))};
72
69
if (flags.test(fd::Geoclue::Velocity::Field::speed))
74
cul::Update<cul::Velocity> update
71
location::Update<location::Velocity> update
76
std::get<2>(arg) * cul::units::MetersPerSecond,
73
std::get<2>(arg) * location::units::MetersPerSecond,
74
location::Clock::now()
79
76
mutable_updates().velocity(update);
82
79
if (flags.test(fd::Geoclue::Velocity::Field::direction))
84
cul::Update<cul::Heading> update
81
location::Update<location::Heading> update
86
std::get<3>(arg) * cul::units::Degrees,
83
std::get<3>(arg) * location::units::Degrees,
84
location::Clock::now()
90
87
mutable_updates().heading(update);
94
cul::Provider::Ptr culpg::Provider::create_instance(const cul::ProviderFactory::Configuration& config)
91
location::Provider::Ptr location::providers::geoclue::Provider::create_instance(const location::ProviderFactory::Configuration& config)
96
culpg::Provider::Configuration pConfig;
93
location::providers::geoclue::Provider::Configuration pConfig;
97
94
pConfig.name = config.count(Configuration::key_name()) > 0 ?
98
95
config.get<std::string>(Configuration::key_name()) : throw std::runtime_error("Missing bus-name");
99
96
pConfig.path = config.count(Configuration::key_path()) > 0 ?
100
97
config.get<std::string>(Configuration::key_path()) : throw std::runtime_error("Missing bus-path");
101
return cul::Provider::Ptr{new culpg::Provider{pConfig}};
98
return location::Provider::Ptr{new location::providers::geoclue::Provider{pConfig}};
104
culpg::Provider::Provider(const culpg::Provider::Configuration& config)
105
: com::ubuntu::location::Provider(config.features, config.requirements),
101
location::providers::geoclue::Provider::Provider(const location::providers::geoclue::Provider::Configuration& config)
102
: location::Provider(config.features, config.requirements),
106
103
bus(the_session_bus()),
107
104
service(dbus::Service::use_service(bus, config.name)),
108
105
object(service->object_for_path(config.path)),
110
107
signal_velocity_changed(object->get_signal<fd::Geoclue::Velocity::Signals::VelocityChanged>())
112
109
position_updates_connection = signal_position_changed->connect(
113
std::bind(&culpg::Provider::on_position_changed, this, std::placeholders::_1));
110
std::bind(&location::providers::geoclue::Provider::on_position_changed, this, std::placeholders::_1));
114
111
velocity_updates_connection = signal_velocity_changed->connect(
115
std::bind(&culpg::Provider::on_velocity_changed, this, std::placeholders::_1));
112
std::bind(&location::providers::geoclue::Provider::on_velocity_changed, this, std::placeholders::_1));
117
114
auto info = object->invoke_method_synchronously<
118
115
fd::Geoclue::GetProviderInfo,
127
124
<< static_cast<fd::Geoclue::Status>(status.value()) << "]" <<std::endl;
130
culpg::Provider::~Provider() noexcept
127
location::providers::geoclue::Provider::~Provider() noexcept
135
bool culpg::Provider::matches_criteria(const cul::Criteria&)
132
bool location::providers::geoclue::Provider::matches_criteria(const location::Criteria&)
140
void culpg::Provider::start_position_updates()
137
void location::providers::geoclue::Provider::start_position_updates()
145
void culpg::Provider::stop_position_updates()
142
void location::providers::geoclue::Provider::stop_position_updates()
150
void culpg::Provider::start_velocity_updates()
147
void location::providers::geoclue::Provider::start_velocity_updates()
155
void culpg::Provider::stop_velocity_updates()
152
void location::providers::geoclue::Provider::stop_velocity_updates()
160
void culpg::Provider::start_heading_updates()
157
void location::providers::geoclue::Provider::start_heading_updates()
165
void culpg::Provider::stop_heading_updates()
162
void location::providers::geoclue::Provider::stop_heading_updates()