2
* Copyright © 2012-2013 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3,
6
* as published by the Free Software Foundation.
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>
19
#include <com/ubuntu/location/service/harvester.h>
21
#include <com/ubuntu/location/logging.h>
23
namespace location = com::ubuntu::location;
25
location::service::Harvester::Harvester(const location::service::Harvester::Configuration& configuration)
26
: config(configuration),
31
location::service::Harvester::~Harvester()
36
/** @brief Report updated position to the harvester instance. */
37
void location::service::Harvester::report_position_update(const location::Update<location::Position>& update)
39
VLOG(10) << "Reference location changed: " << update;
41
if (not is_running.load())
44
std::vector<location::connectivity::WirelessNetwork::Ptr> visible_wifis;
45
config.connectivity_manager->enumerate_visible_wireless_networks([&visible_wifis](location::connectivity::WirelessNetwork::Ptr wifi)
47
VLOG(10) << "Got a visible wifi: " << *wifi << std::endl;
48
visible_wifis.push_back(wifi);
51
std::vector<location::connectivity::RadioCell::Ptr> connected_cells;
52
config.connectivity_manager->enumerate_connected_radio_cells([&connected_cells](location::connectivity::RadioCell::Ptr cell)
54
VLOG(10) << "Got a cell: " << *cell << std::endl;
55
connected_cells.push_back(cell);
58
config.reporter->report(update, visible_wifis, connected_cells);
61
void location::service::Harvester::start()
63
if (is_running.load())
66
is_running.exchange(true);
68
config.reporter->start();
71
void location::service::Harvester::stop()
73
if (not is_running.load())
76
is_running.exchange(false);
78
config.reporter->stop();