manager.h
Go to the documentation of this file.
/*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_MANAGER_H_
#define LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_MANAGER_H_
#include <com/lomiri/location/connectivity/radio_cell.h>
#include <com/lomiri/location/connectivity/wireless_network.h>
#include <core/property.h>
#include <memory>
#include <string>
#include <vector>
namespace com
{
namespace lomiri
{
namespace location
{
namespace connectivity
{
enum class State
{
unknown = 0,
asleep = 10,
disconnected = 20,
disconnecting = 30,
connecting = 40,
connected_local = 50,
connected_site = 60,
connected_global = 70
};
std::ostream& operator<<(std::ostream& out, State state);
enum class Characteristics : std::uint32_t
{
none = 0,
connection_goes_via_wifi = 1 << 0,
connection_goes_via_wwan = 1 << 1,
connection_is_roaming = 1 << 2,
connection_has_monetary_costs = 1 << 3,
connection_is_volume_limited = 1 << 4,
connection_is_bandwith_limited = 1 << 5
};
Characteristics operator|(Characteristics l, Characteristics r);
Characteristics operator&(Characteristics l, Characteristics r);
std::ostream& operator<<(std::ostream& out, Characteristics characteristics);
class Manager
{
public:
struct Errors
{
Errors() = delete;
struct ConnectivityManagementNotSupported : public std::runtime_error
{
ConnectivityManagementNotSupported()
: std::runtime_error(
"Underlying platform does not provide support for connectivity mgmt.")
{
}
};
};
Manager(const Manager& rhs) = delete;
virtual ~Manager() = default;
Manager& operator=(const Manager& rhs) = delete;
bool operator==(const Manager& rhs) const = delete;
virtual const core::Property<State>& state() const = 0;
virtual const core::Property<bool>& is_wifi_enabled() const = 0;
virtual const core::Property<bool>& is_wwan_enabled() const = 0;
virtual const core::Property<bool>& is_wifi_hardware_enabled() const = 0;
virtual const core::Property<bool>& is_wwan_hardware_enabled() const = 0;
virtual const core::Property<Characteristics>& active_connection_characteristics() const = 0;
virtual void request_scan_for_wireless_networks() = 0;
virtual const core::Signal<>& wireless_network_scan_finished() const = 0;
virtual const core::Signal<WirelessNetwork::Ptr>& wireless_network_added() const = 0;
virtual const core::Signal<WirelessNetwork::Ptr>& wireless_network_removed() const = 0;
virtual void enumerate_visible_wireless_networks(const std::function<void(const WirelessNetwork::Ptr&)>&) const = 0;
virtual const core::Signal<RadioCell::Ptr>& connected_cell_added() const = 0;
virtual const core::Signal<RadioCell::Ptr>& connected_cell_removed() const = 0;
virtual void enumerate_connected_radio_cells(const std::function<void(const RadioCell::Ptr&)>&) const = 0;
protected:
Manager() = default;
};
const std::shared_ptr<Manager>& platform_default_manager();
}
}
}
}
#endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_CONNECTIVITY_MANAGER_H_
com::lomiri::location::connectivity::Manager
The Manager class encapsulates access to network/radio information.
Definition manager.h:97
com::lomiri::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::lomiri::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::lomiri::location::connectivity::Manager::Manager
Manager()=default
com::lomiri::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::lomiri::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::lomiri::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::lomiri::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::lomiri::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::lomiri::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::lomiri::location::connectivity::Manager::state
virtual const core::Property< State > & state() const =0
Returns the getable/observable connectivity state of the system.
com::lomiri::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::lomiri::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::lomiri::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::lomiri::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::lomiri::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::lomiri::location::connectivity
Definition bounded_integer.h:31
com::lomiri::location::connectivity::operator==
bool operator==(const RadioCell::Gsm &lhs, const RadioCell::Gsm &rhs)
Returns true iff lhs equals rhs.
com::lomiri::location::connectivity::State
State
Enumerates all known system connectivity states.
Definition manager.h:40
com::lomiri::location::connectivity::State::connected_global
@ connected_global
A network device is connected, with global network connectivity.
Definition manager.h:59
com::lomiri::location::connectivity::State::disconnecting
@ disconnecting
Network connections are being cleaned up.
Definition manager.h:48
com::lomiri::location::connectivity::State::disconnected
@ disconnected
There is no active network connection.
Definition manager.h:46
com::lomiri::location::connectivity::State::connected_local
@ connected_local
A network device is connected, but there is only link-local connectivity.
Definition manager.h:55
com::lomiri::location::connectivity::State::connecting
@ connecting
A network device is connecting to a network and there is no other available network connection.
Definition manager.h:53
com::lomiri::location::connectivity::State::unknown
@ unknown
Definition manager.h:42
com::lomiri::location::connectivity::State::asleep
@ asleep
Networking is inactive and all devices are disabled.
Definition manager.h:44
com::lomiri::location::connectivity::State::connected_site
@ connected_site
A network device is connected, but there is only site-local connectivity.
Definition manager.h:57
com::lomiri::location::connectivity::Characteristics
Characteristics
Summarizes characteristics of network connections.
Definition manager.h:67
com::lomiri::location::connectivity::Characteristics::connection_has_monetary_costs
@ connection_has_monetary_costs
The connection has monetary costs. No data should be transfered.
Definition manager.h:77
com::lomiri::location::connectivity::Characteristics::connection_is_roaming
@ connection_is_roaming
The connection goes via a roaming mobile-broadband connection.
Definition manager.h:75
com::lomiri::location::connectivity::Characteristics::none
@ none
Nothing special about the characteristics.
Definition manager.h:69
com::lomiri::location::connectivity::Characteristics::connection_is_volume_limited
@ connection_is_volume_limited
The connection is volume limited. No large files should be transfered.
Definition manager.h:79
com::lomiri::location::connectivity::Characteristics::connection_is_bandwith_limited
@ connection_is_bandwith_limited
the connection is bandwidth limited. Large transfer should be postponed.
Definition manager.h:81
com::lomiri::location::connectivity::Characteristics::connection_goes_via_wwan
@ connection_goes_via_wwan
The connection goes via a mobile-broadband connection.
Definition manager.h:73
com::lomiri::location::connectivity::Characteristics::connection_goes_via_wifi
@ connection_goes_via_wifi
The connection goes via wifi.
Definition manager.h:71
com::lomiri::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::lomiri::location::connectivity::operator&
Characteristics operator&(Characteristics l, Characteristics r)
Bitwise and operator for Characteristics flags.
com::lomiri::location::connectivity::operator<<
std::ostream & operator<<(std::ostream &out, State state)
Pretty prints the given state to the given output stream.
com::lomiri::location::connectivity::operator|
Characteristics operator|(Characteristics l, Characteristics r)
Bitwise or operator for Characteristics flags.
com::lomiri::location
Definition accuracy.h:28
com::lomiri
Definition accuracy.h:26
com
Definition accuracy.h:24
radio_cell.h
com::lomiri::location::connectivity::Manager::Errors::ConnectivityManagementNotSupported::ConnectivityManagementNotSupported
ConnectivityManagementNotSupported()
Definition manager.h:108
com::lomiri::location::connectivity::Manager::Errors::Errors
Errors()=delete
com::lomiri::location::connectivity::WirelessNetwork::Ptr
std::shared_ptr< WirelessNetwork > Ptr
Definition wireless_network.h:38
wireless_network.h