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 
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,
82 };
83 
86 
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  {
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_
bool operator==(const RadioCell::Gsm &lhs, const RadioCell::Gsm &rhs)
Returns true iff lhs equals rhs.
virtual void enumerate_visible_wireless_networks(const std::function< void(const WirelessNetwork::Ptr &)> &) const =0
Enumerates all wireless networks visible to the device.
Network connections are being cleaned up.
The connection goes via a roaming mobile-broadband connection.
virtual const core::Signal & wireless_network_scan_finished() const =0
wireless_network_scan_finished is emitted when a scan for wireless networks ends. ...
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 void request_scan_for_wireless_networks()=0
request_scan_for_wireless_networks schedules a scan for visible wireless networks.
STL namespace.
Definition: accuracy.h:23
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::Signal< WirelessNetwork::Ptr > & wireless_network_added() const =0
wireless_network_added is emitted whenever a new wifi becomes visible.
const std::shared_ptr< Manager > & platform_default_manager()
Provides access to a platform-specific implementation/instance of a connectivity manager.
A network device is connecting to a network and there is no other available network connection...
Characteristics operator|(Characteristics l, Characteristics r)
Bitwise or operator for Characteristics flags.
virtual const core::Property< bool > & is_wifi_enabled() const =0
Returns a getable/observable boolean property that indicates the state of the wifi subsystem...
There is no active network connection.
virtual const core::Property< Characteristics > & active_connection_characteristics() const =0
Returns a getable/observable property that describes the characteristics of the active network connec...
The connection has monetary costs. No data should be transfered.
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< 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.
A network device is connected, with global network connectivity.
the connection is bandwidth limited. Large transfer should be postponed.
A network device is connected, but there is only link-local connectivity.
Characteristics
Summarizes characteristics of network connections.
Definition: manager.h:66
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.
The connection goes via a mobile-broadband connection.
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 and operator for Characteristics flags.
Nothing special about the characteristics.
virtual const core::Signal< RadioCell::Ptr > & connected_cell_removed() const =0
connected_cell_removed is emitted whenever the underlying modem disconnects from a cell...
The ConnectivityManagementNotSupported struct is thrown if the underlying platform does not provide s...
Definition: manager.h:106
State
Enumerates all known system connectivity states.
Definition: manager.h:39
virtual const core::Property< State > & state() const =0
Returns the getable/observable connectivity state of the system.
The connection is volume limited. No large files should be transfered.
Networking is inactive and all devices are disabled.
A network device is connected, but there is only site-local connectivity.
The Manager class encapsulates access to network/radio information.
Definition: manager.h:96