lomiri-location-service ..
An aggregating location service providing positioning and geocoding capabilities to applications.
manager.h
Go to the documentation of this file.
1/*
2 * Copyright © 2012-2013 Canonical Ltd.
3 *
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.
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#ifndef LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_MANAGER_H_
19#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_MANAGER_H_
20
23
24#include <core/property.h>
25
26#include <memory>
27#include <string>
28#include <vector>
29
30namespace com
31{
32namespace lomiri
33{
34namespace location
35{
36namespace connectivity
37{
39enum class State
40{
42 unknown = 0,
44 asleep = 10,
46 disconnected = 20,
48 disconnecting = 30,
53 connecting = 40,
55 connected_local = 50,
57 connected_site = 60,
60};
61
63std::ostream& operator<<(std::ostream& out, State state);
64
66enum class Characteristics : std::uint32_t
67{
69 none = 0,
75 connection_is_roaming = 1 << 2,
82};
83
86
89
91std::ostream& operator<<(std::ostream& out, Characteristics characteristics);
92
97{
98public:
99 struct Errors
100 {
101 Errors() = delete;
106 struct ConnectivityManagementNotSupported : public std::runtime_error
107 {
109 : std::runtime_error(
110 "Underlying platform does not provide support for connectivity mgmt.")
111 {
112 }
113 };
114 };
115
117 Manager(const Manager& rhs) = delete;
118 virtual ~Manager() = default;
119
120 Manager& operator=(const Manager& rhs) = delete;
121 bool operator==(const Manager& rhs) const = delete;
127 virtual const core::Property<State>& state() const = 0;
128
134 virtual const core::Property<bool>& is_wifi_enabled() const = 0;
135
141 virtual const core::Property<bool>& is_wwan_enabled() const = 0;
142
148 virtual const core::Property<bool>& is_wifi_hardware_enabled() const = 0;
149
155 virtual const core::Property<bool>& is_wwan_hardware_enabled() const = 0;
156
157
162 virtual const core::Property<Characteristics>& active_connection_characteristics() const = 0;
163
178
186 virtual const core::Signal<>& wireless_network_scan_finished() const = 0;
187
191 virtual const core::Signal<WirelessNetwork::Ptr>& wireless_network_added() const = 0;
192
196 virtual const core::Signal<WirelessNetwork::Ptr>& wireless_network_removed() const = 0;
197
201 virtual void enumerate_visible_wireless_networks(const std::function<void(const WirelessNetwork::Ptr&)>&) const = 0;
202
206 virtual const core::Signal<RadioCell::Ptr>& connected_cell_added() const = 0;
207
211 virtual const core::Signal<RadioCell::Ptr>& connected_cell_removed() const = 0;
212
216 virtual void enumerate_connected_radio_cells(const std::function<void(const RadioCell::Ptr&)>&) const = 0;
217
218protected:
219 Manager() = default;
220};
221
227const std::shared_ptr<Manager>& platform_default_manager();
228}
229}
230}
231}
232
233#endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_MANAGER_H_
The Manager class encapsulates access to network/radio information.
Definition manager.h:97
virtual const core::Signal< RadioCell::Ptr > & connected_cell_added() const =0
connected_cell_added is emitted whenever the underlying modem connects to a new cell.
virtual const core::Property< bool > & is_wifi_enabled() const =0
Returns a getable/observable boolean property that indicates the state of the wifi subsystem.
virtual const core::Signal & wireless_network_scan_finished() const =0
wireless_network_scan_finished is emitted when a scan for wireless networks ends.
virtual const core::Signal< RadioCell::Ptr > & connected_cell_removed() const =0
connected_cell_removed is emitted whenever the underlying modem disconnects from a cell.
virtual void enumerate_visible_wireless_networks(const std::function< void(const WirelessNetwork::Ptr &)> &) const =0
Enumerates all wireless networks visible to the device.
virtual void request_scan_for_wireless_networks()=0
request_scan_for_wireless_networks schedules a scan for visible wireless networks.
virtual const core::Property< bool > & is_wifi_hardware_enabled() const =0
Returns a getable/observable boolean property that indicates the state of the wifi hardware.
virtual const core::Property< bool > & is_wwan_hardware_enabled() const =0
Returns a getable/observable boolean property that indicates the state of the wwan hardware.
virtual const core::Property< State > & state() const =0
Returns the getable/observable connectivity state of the system.
virtual const core::Signal< WirelessNetwork::Ptr > & wireless_network_added() const =0
wireless_network_added is emitted whenever a new wifi becomes visible.
virtual const core::Property< Characteristics > & active_connection_characteristics() const =0
Returns a getable/observable property that describes the characteristics of the active network connec...
virtual void enumerate_connected_radio_cells(const std::function< void(const RadioCell::Ptr &)> &) const =0
Enumerates all radio cells that the device is connected to.
virtual const core::Property< bool > & is_wwan_enabled() const =0
Returns a getable/observable boolean property that indicates the state of the wwan subsystem.
virtual const core::Signal< WirelessNetwork::Ptr > & wireless_network_removed() const =0
wireless_network_removed is emitted whenever a wifi disappears.
bool operator==(const RadioCell::Gsm &lhs, const RadioCell::Gsm &rhs)
Returns true iff lhs equals rhs.
State
Enumerates all known system connectivity states.
Definition manager.h:40
@ connected_global
A network device is connected, with global network connectivity.
@ disconnecting
Network connections are being cleaned up.
@ disconnected
There is no active network connection.
@ connected_local
A network device is connected, but there is only link-local connectivity.
@ connecting
A network device is connecting to a network and there is no other available network connection.
@ asleep
Networking is inactive and all devices are disabled.
@ connected_site
A network device is connected, but there is only site-local connectivity.
Characteristics
Summarizes characteristics of network connections.
Definition manager.h:67
@ connection_has_monetary_costs
The connection has monetary costs. No data should be transfered.
@ connection_is_roaming
The connection goes via a roaming mobile-broadband connection.
@ none
Nothing special about the characteristics.
@ connection_is_volume_limited
The connection is volume limited. No large files should be transfered.
@ connection_is_bandwith_limited
the connection is bandwidth limited. Large transfer should be postponed.
@ connection_goes_via_wwan
The connection goes via a mobile-broadband connection.
@ connection_goes_via_wifi
The connection goes via wifi.
const std::shared_ptr< Manager > & platform_default_manager()
Provides access to a platform-specific implementation/instance of a connectivity manager.
Characteristics operator&(Characteristics l, Characteristics r)
Bitwise and operator for Characteristics flags.
std::ostream & operator<<(std::ostream &out, State state)
Pretty prints the given state to the given output stream.
Characteristics operator|(Characteristics l, Characteristics r)
Bitwise or operator for Characteristics flags.
Definition accuracy.h:24
The ConnectivityManagementNotSupported struct is thrown if the underlying platform does not provide s...
Definition manager.h:107