ubuntu-location-service: /build/location-service-git/src/location-service/include/location_service/com/ubuntu/location/connectivity/manager.h Source File

ubuntu-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_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_
20
21 #include <com/ubuntu/location/connectivity/radio_cell.h>
22 #include <com/ubuntu/location/connectivity/wireless_network.h>
23
24 #include <core/property.h>
25
26 #include <memory>
27 #include <string>
28 #include <vector>
29
30 namespace com
31 {
32 namespace ubuntu
33 {
34 namespace location
35 {
36 namespace connectivity
37 {
39 enum 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,
59 connected_global = 70
60 };
61
63 std::ostream& operator<<(std::ostream& out, State state);
64
66 enum class Characteristics : std::uint32_t
67 {
69 none = 0,
71 connection_goes_via_wifi = 1 << 0,
73 connection_goes_via_wwan = 1 << 1,
75 connection_is_roaming = 1 << 2,
77 connection_has_monetary_costs = 1 << 3,
79 connection_is_volume_limited = 1 << 4,
81 connection_is_bandwith_limited = 1 << 5
82 };
83
85 Characteristics operator|(Characteristics l, Characteristics r);
86
88 Characteristics operator&(Characteristics l, Characteristics r);
89
91 std::ostream& operator<<(std::ostream& out, Characteristics characteristics);
92
96 class Manager
97 {
98 public:
99 struct Errors
100 {
101 Errors() = delete;
106 struct ConnectivityManagementNotSupported : public std::runtime_error
107 {
108 ConnectivityManagementNotSupported()
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
177 virtual void request_scan_for_wireless_networks() = 0;
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
218 protected:
219 Manager() = default;
220 };
221
227 const std::shared_ptr<Manager>& platform_default_manager();
228 }
229 }
230 }
231 }
232
233 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_
com::ubuntu::location::connectivity::Manager
The Manager class encapsulates access to network/radio information.
Definition: manager.h:97
com::ubuntu::location::connectivity::Manager::wireless_network_removed
virtual const core::Signal< WirelessNetwork::Ptr > & wireless_network_removed() const =0
wireless_network_removed is emitted whenever a wifi disappears.
com::ubuntu::location::connectivity::Manager::Manager
Manager()=default
com::ubuntu::location::connectivity::Manager::wireless_network_scan_finished
virtual const core::Signal & wireless_network_scan_finished() const =0
wireless_network_scan_finished is emitted when a scan for wireless networks ends.
com::ubuntu::location::connectivity::Manager::enumerate_visible_wireless_networks
virtual void enumerate_visible_wireless_networks(const std::function< void(const WirelessNetwork::Ptr &)> &) const =0
Enumerates all wireless networks visible to the device.
com::ubuntu::location::connectivity::Manager::is_wwan_enabled
virtual const core::Property< bool > & is_wwan_enabled() const =0
Returns a getable/observable boolean property that indicates the state of the wwan subsystem.
com::ubuntu::location::connectivity::Manager::request_scan_for_wireless_networks
virtual void request_scan_for_wireless_networks()=0
request_scan_for_wireless_networks schedules a scan for visible wireless networks.
com::ubuntu::location::connectivity::Manager::active_connection_characteristics
virtual const core::Property< Characteristics > & active_connection_characteristics() const =0
Returns a getable/observable property that describes the characteristics of the active network connec...
com::ubuntu::location::connectivity::Manager::is_wwan_hardware_enabled
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.
com::ubuntu::location::connectivity::Manager::is_wifi_enabled
virtual const core::Property< bool > & is_wifi_enabled() const =0
Returns a getable/observable boolean property that indicates the state of the wifi subsystem.
com::ubuntu::location::connectivity::Manager::connected_cell_added
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.
com::ubuntu::location::connectivity::Manager::wireless_network_added
virtual const core::Signal< WirelessNetwork::Ptr > & wireless_network_added() const =0
wireless_network_added is emitted whenever a new wifi becomes visible.
com::ubuntu::location::connectivity::Manager::connected_cell_removed
virtual const core::Signal< RadioCell::Ptr > & connected_cell_removed() const =0
connected_cell_removed is emitted whenever the underlying modem disconnects from a cell.
com::ubuntu::location::connectivity::Manager::enumerate_connected_radio_cells
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.
com::ubuntu::location::connectivity::Manager::state
virtual const core::Property< State > & state() const =0
Returns the getable/observable connectivity state of the system.
com::ubuntu::location::connectivity::Manager::is_wifi_hardware_enabled
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.
com::ubuntu::location::connectivity::operator<<
std::ostream & operator<<(std::ostream &out, State state)
Pretty prints the given state to the given output stream.
com::ubuntu::location::connectivity::operator|
Characteristics operator|(Characteristics l, Characteristics r)
Bitwise or operator for Characteristics flags.
com::ubuntu::location::connectivity::platform_default_manager
const std::shared_ptr< Manager > & platform_default_manager()
Provides access to a platform-specific implementation/instance of a connectivity manager.
com::ubuntu::location::connectivity::State
State
Enumerates all known system connectivity states.
Definition: manager.h:40
com::ubuntu::location::connectivity::State::connected_global
@ connected_global
A network device is connected, with global network connectivity.
com::ubuntu::location::connectivity::State::disconnecting
@ disconnecting
Network connections are being cleaned up.
com::ubuntu::location::connectivity::State::disconnected
@ disconnected
There is no active network connection.
com::ubuntu::location::connectivity::State::connected_local
@ connected_local
A network device is connected, but there is only link-local connectivity.
com::ubuntu::location::connectivity::State::connecting
@ connecting
A network device is connecting to a network and there is no other available network connection.
com::ubuntu::location::connectivity::State::unknown
@ unknown
com::ubuntu::location::connectivity::State::asleep
@ asleep
Networking is inactive and all devices are disabled.
com::ubuntu::location::connectivity::State::connected_site
@ connected_site
A network device is connected, but there is only site-local connectivity.
com::ubuntu::location::connectivity::Characteristics
Characteristics
Summarizes characteristics of network connections.
Definition: manager.h:67
com::ubuntu::location::connectivity::Characteristics::connection_has_monetary_costs
@ connection_has_monetary_costs
The connection has monetary costs. No data should be transfered.
com::ubuntu::location::connectivity::Characteristics::connection_is_roaming
@ connection_is_roaming
The connection goes via a roaming mobile-broadband connection.
com::ubuntu::location::connectivity::Characteristics::none
@ none
Nothing special about the characteristics.
com::ubuntu::location::connectivity::Characteristics::connection_is_volume_limited
@ connection_is_volume_limited
The connection is volume limited. No large files should be transfered.
com::ubuntu::location::connectivity::Characteristics::connection_is_bandwith_limited
@ connection_is_bandwith_limited
the connection is bandwidth limited. Large transfer should be postponed.
com::ubuntu::location::connectivity::Characteristics::connection_goes_via_wwan
@ connection_goes_via_wwan
The connection goes via a mobile-broadband connection.
com::ubuntu::location::connectivity::Characteristics::connection_goes_via_wifi
@ connection_goes_via_wifi
The connection goes via wifi.
com::ubuntu::location::connectivity::operator&
Characteristics operator&(Characteristics l, Characteristics r)
Bitwise and operator for Characteristics flags.
com::ubuntu::location::connectivity::operator==
bool operator==(const RadioCell::Gsm &lhs, const RadioCell::Gsm &rhs)
Returns true iff lhs equals rhs.
com
Definition: accuracy.h:24
radio_cell.h
com::ubuntu::location::connectivity::Manager::Errors::ConnectivityManagementNotSupported
The ConnectivityManagementNotSupported struct is thrown if the underlying platform does not provide s...
Definition: manager.h:107
com::ubuntu::location::connectivity::Manager::Errors::ConnectivityManagementNotSupported::ConnectivityManagementNotSupported
ConnectivityManagementNotSupported()
Definition: manager.h:108
com::ubuntu::location::connectivity::Manager::Errors
Definition: manager.h:100
com::ubuntu::location::connectivity::Manager::Errors::Errors
Errors()=delete
com::ubuntu::location::connectivity::WirelessNetwork::Ptr
std::shared_ptr< WirelessNetwork > Ptr
Definition: wireless_network.h:38
wireless_network.h