API Documentation
Documentation for developing SailfishOS applicationsConnectivitySettings Class
(Sailfish::Mdm::ConnectivitySettings)The ConnectivitySettings class controls network connectivity. More...
Header: | #include <mdm-connectivity.h> |
Public Types
class | MobileNetworkAccessPointSettings |
flags | CellularTechnologies |
enum | CellularTechnology { TechnologyNone, Technology2G, Technology3G, Technology4G, Technology5G } |
enum | Mode { AsynchronousMode, SynchronousMode } |
Properties
- bluetoothEnabled : bool
- flightModeEnabled : bool
- ready : const bool
- wlanEnabled : bool
Public Functions
ConnectivitySettings(QObject *parent = Q_NULLPTR) | |
ConnectivitySettings(Mode mode, QObject *parent = Q_NULLPTR) | |
QMap<MobileNetworkAccessPointSettings::Type, MobileNetworkAccessPointSettings> | accessPointSettings(const QString &imsi) const |
bool | bluetoothEnabled() const |
bool | connectToMobileNetwork(const QString &imsi) |
bool | disconnectFromMobileNetwork(const QString &imsi) |
bool | flightModeEnabled() const |
QVector<NetworkService *> | getAvailableWifiServices() const |
QVector<NetworkService *> | getSavedWifiServices() const |
bool | isConnectedToMobileNetwork(const QString &imsi) const |
QStringList | mobileNetworkImsis() const |
QStringList | modemPaths() const |
QString | modemSimImsi(const QString &modemPath) const |
bool | ready() const |
bool | selectCellularTechnologies(const QString &modemPath, Sailfish::Mdm::ConnectivitySettings::CellularTechnologies techs) |
CellularTechnologies | selectedCellularTechnologies(const QString &modemPath) const |
bool | setAccessPointSettings(const QString &imsi, const MobileNetworkAccessPointSettings &settings) |
void | setBluetoothEnabled(bool value) |
void | setFlightModeEnabled(bool value) |
void | setWlanEnabled(bool value) |
QVector<CellularTechnologies> | supportedCellularTechnologies(const QString &modemPath) const |
bool | wlanEnabled() const |
Signals
void | bluetoothEnabledChanged() |
void | flightModeEnabledChanged() |
void | readyChanged() |
void | wifiServicesChanged() |
void | wlanEnabledChanged() |
Detailed Description
The ConnectivitySettings class controls network connectivity.
To use this class, clients must add the following to their qmake project:
CONFIG += link_pkgconfig PKGCONFIG += sailfishmdm
and then #include <mdm-connectivity.h>
.
Example of usage:
#include <mdm-connectivity.h> void enableOrDisableWlan(bool enable, QObject *parent) { Sailfish::Mdm::ConnectivitySettings *settings = new Sailfish::Mdm::ConnectivitySettings(parent); settings->setWlanEnabled(enable); }
Member Type Documentation
enum ConnectivitySettings::CellularTechnology
flags ConnectivitySettings::CellularTechnologies
This enum type specifies some cellular technologies which may be used by devices to connect to mobile voice or data networks.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::ConnectivitySettings::TechnologyNone | 0 | The device is using no technology or may use any technology to connect to mobile networks. |
Sailfish::Mdm::ConnectivitySettings::Technology2G | 1 | The device is using 2G or may use 2G technology to connect to mobile networks. |
Sailfish::Mdm::ConnectivitySettings::Technology3G | 2 | The device is using 3G or may use 3G technology to connect to mobile networks. |
Sailfish::Mdm::ConnectivitySettings::Technology4G | 4 | The device is using 4G or may use 4G technology to connect to mobile networks. |
Sailfish::Mdm::ConnectivitySettings::Technology5G | 8 | The device is using 5G or may use 5G technology to connect to mobile networks. |
The CellularTechnologies type is a typedef for QFlags<CellularTechnology>. It stores an OR combination of CellularTechnology values.
enum ConnectivitySettings::Mode
Describes whether settings are modified and retrieved synchronously or asynchronously.
Constant | Value | Description |
---|---|---|
Sailfish::Mdm::ConnectivitySettings::AsynchronousMode | 0 | When a setting is value is retrieved or modified, the method returns immediately; if the value is modified, the setting value does not change until the modification is confirmed by the backend libraries. |
Sailfish::Mdm::ConnectivitySettings::SynchronousMode | 1 | Attempts to retrieve or modify a setting block the current thread until the operation to retrieve or modify the property is completed. |
Property Documentation
bluetoothEnabled : bool
This property holds true if the Bluetooth adapter is enabled (powered on).
Note that flight mode may enable or disable the Bluetooth adapter independently.
This value is updated whenever the Bluetooth adapter enablement status changes, either due to user action, MDM application action, or flight-mode status change.
Access functions:
bool | bluetoothEnabled() const |
void | setBluetoothEnabled(bool value) |
Notifier signal:
void | bluetoothEnabledChanged() |
flightModeEnabled : bool
This property holds true if flight mode is enabled.
If flight mode is enabled, then by default, all radios and receivers (including cellular, WLAN, Bluetooth and GPS) will be disabled, however WLAN, Bluetooth and GPS may be enabled separately by the user.
Access functions:
bool | flightModeEnabled() const |
void | setFlightModeEnabled(bool value) |
Notifier signal:
void | flightModeEnabledChanged() |
ready : const bool
This property holds true when the connectivity settings have been initialised and can be queried or set.
Attempting to query or set settings prior to ready being true will have no effect.
Access functions:
bool | ready() const |
Notifier signal:
void | readyChanged() |
wlanEnabled : bool
This property holds true if the WLAN adapter is enabled (powered on).
Note that flight mode may enable or disable the WLAN adapter independently.
This value is updated whenever the WLAN adapter enablement status changes, either due to user action, MDM application action, or flight-mode status change.
Access functions:
bool | wlanEnabled() const |
void | setWlanEnabled(bool value) |
Notifier signal:
void | wlanEnabledChanged() |
Member Function Documentation
ConnectivitySettings::ConnectivitySettings(QObject *parent = Q_NULLPTR)
Creates a ConnectivitySettings instance with the given parent.
ConnectivitySettings::ConnectivitySettings(Mode mode, QObject *parent = Q_NULLPTR)
Default constructs an instance of ConnectivitySettings.
QMap<MobileNetworkAccessPointSettings::Type, MobileNetworkAccessPointSettings> ConnectivitySettings::accessPointSettings(const QString &imsi) const
Returns the mobile network access point settings associated with the given SIM subscriber number imsi.
Calling this method will set the SIM with the given imsi as the default data SIM.
If the given imsi does not identify a SIM card currently inserted into a valid SIM slot of the device, this method will return an empty map of settings.
See also setAccessPointSettings().
bool ConnectivitySettings::connectToMobileNetwork(const QString &imsi)
Connects to the mobile network via the SIM with the given imsi.
The currently set access point settings will be used when connecting to the mobile network.
Calling this method will set the SIM with the given imsi as the default data sim.
Returns true if the connection was established and the connection was able to be set as the default autoconnect connection, otherwise returns false.
bool ConnectivitySettings::disconnectFromMobileNetwork(const QString &imsi)
Disconnects from the mobile network to which the device is connected via the SIM with the given imsi.
Calling this method will set the SIM with the given imsi as the default data sim.
Returns true if the connection was disconnected and unset as the default autoconnect connection, otherwise returns false.
QVector<NetworkService *> ConnectivitySettings::getAvailableWifiServices() const
Attempts to retrieve a list of all available wifi services.
Note: This function will return an empty list when working in SynchronousMode
See also getSavedWifiServices().
QVector<NetworkService *> ConnectivitySettings::getSavedWifiServices() const
Attempts to retrieve a list of all saved wifi services.
Note: This function will return an empty list when working in SynchronousMode
See also getAvailableWifiServices().
bool ConnectivitySettings::isConnectedToMobileNetwork(const QString &imsi) const
Returns true if the device is connected to a mobile network via the SIM with the given imsi.
Calling this method will set the SIM with the given imsi as the default data sim.
QStringList ConnectivitySettings::mobileNetworkImsis() const
Returns all SIM IMSIs known on the device which have mobile network connectivity available.
QStringList ConnectivitySettings::modemPaths() const
Returns a list of valid modem paths from the device.
QString ConnectivitySettings::modemSimImsi(const QString &modemPath) const
Returns the IMSI of the SIM card which is inserted into the slot connected to the modem with the specified modemPath.
If no SIM card is inserted into the slot, or if the given modemPath does not identify a valid modem, this method will return a null string.
bool ConnectivitySettings::selectCellularTechnologies(const QString &modemPath, Sailfish::Mdm::ConnectivitySettings::CellularTechnologies techs)
Attempt to select the given set of cellular technologies techs for use by the modem with the specified modemPath. If the specified techs is Sailfish::Mdm::ConnectivitySettings::TechnologyNone
, it is assumed that the modem should be allowed to use any available technology to connect.
Returns false immediately if the given set of cellular technologies is not supported, otherwise returns false if the specified techs were unable to be selected; otherwise returns true.
CellularTechnologies ConnectivitySettings::selectedCellularTechnologies(const QString &modemPath) const
Returns the set of cellular technologies which are selected for use for the modem with the specified modemPath.
If no specific technology has been selected, the modem will use any available technology to connect to the mobile network, and Sailfish::Mdm::ConnectivitySettings::TechnologyNone
will be returned.
bool ConnectivitySettings::setAccessPointSettings(const QString &imsi, const MobileNetworkAccessPointSettings &settings)
Sets the access point settings for the given imsi to settings.
Note that the Access Point Name cannot contain underscore or space characters, and that you should ensure that the mobile network is disconnected prior to attempting to set the access point settings.
Calling this method will set the SIM with the given imsi as the default data sim.
Returns true if the given imsi identifies a SIM which is currently inserted into the device, and if all of the specified settings were able to be set for it, otherwise returns false.
See also accessPointSettings().
QVector<CellularTechnologies> ConnectivitySettings::supportedCellularTechnologies(const QString &modemPath) const
Returns the vector containing the sets of cellular technologies which are supported by the modem with the specified modemPath.
For example, a device might support "2G-only" mode, "2G plus 3G" mode, "2G plus 3G plus 4G" mode, and (if VoLTE is supported) "4G-only" mode.
If the specified modemPath is invalid, or if some other internal error occurs, an empty vector is returned.
[signal]
void ConnectivitySettings::wifiServicesChanged()
This signal is emitted whenever the wifi services changes.
See also getSavedWifiServices() and getAvailableWifiServices().