connectivity.h
Go to the documentation of this file.
/*
* Copyright © 2014 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/>.
*
* Authors:
* Pete Woods <pete.woods@canonical.com>
*/
#pragma once
#include <QAbstractListModel>
#include <QDBusConnection>
#include <QObject>
#include <QStringList>
#include <functional>
#include <memory>
#include <lomiri/util/DefinesPtrs.h>
#include <connectivityqt/vpn-connections-list-model.h>
#include <QDBusObjectPath>
namespace connectivityqt
{
class Sim;
class Q_DECL_EXPORT Connectivity: public QObject
{
Q_OBJECT
public:
LOMIRI_DEFINES_PTRS(Connectivity);
Q_DISABLE_COPY(Connectivity)
Q_ENUMS(Limitations)
Q_ENUMS(Status)
static void registerMetaTypes();
enum class Limitations
{
Bandwidth
};
enum class Status
{
Offline,
Connecting,
Online
};
Connectivity(const QDBusConnection& sessionConnection = QDBusConnection::sessionBus(), QObject* parent = 0);
Connectivity(const std::function<void(QObject*)>& objectOwner,
const QDBusConnection& sessionConnection = QDBusConnection::sessionBus(),
QObject* parent = 0);
~Connectivity();
Q_PROPERTY(bool flightMode READ flightMode WRITE setFlightMode NOTIFY flightModeUpdated)
bool flightMode() const;
Q_PROPERTY(bool online READ online NOTIFY onlineUpdated)
bool online() const;
Q_PROPERTY(bool limitedBandwidth READ limitedBandwidth NOTIFY limitedBandwidthUpdated)
bool limitedBandwidth() const;
Q_PROPERTY(QVector<connectivityqt::Connectivity::Limitations> Limitations READ limitations NOTIFY limitationsUpdated)
QVector<connectivityqt::Connectivity::Limitations> limitations() const;
Q_PROPERTY(connectivityqt::Connectivity::Status status READ status NOTIFY statusUpdated)
connectivityqt::Connectivity::Status status() const;
Q_PROPERTY(bool wifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
bool wifiEnabled() const;
Q_PROPERTY(bool unstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated)
bool unstoppableOperationHappening() const;
Q_PROPERTY(bool flightModeSwitchEnabled READ flightModeSwitchEnabled NOTIFY flightModeSwitchEnabledUpdated)
bool flightModeSwitchEnabled() const;
Q_PROPERTY(bool wifiSwitchEnabled READ wifiSwitchEnabled NOTIFY wifiSwitchEnabledUpdated)
bool wifiSwitchEnabled() const;
Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
bool hotspotSwitchEnabled() const;
Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableUpdated)
bool modemAvailable() const;
Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)
QByteArray hotspotSsid() const;
Q_PROPERTY(QString hotspotPassword READ hotspotPassword WRITE setHotspotPassword NOTIFY hotspotPasswordUpdated)
QString hotspotPassword() const;
Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledUpdated)
bool hotspotEnabled() const;
Q_PROPERTY(QString hotspotMode READ hotspotMode WRITE setHotspotMode NOTIFY hotspotModeUpdated)
QString hotspotMode() const;
Q_PROPERTY(QString hotspotAuth READ hotspotAuth WRITE setHotspotAuth NOTIFY hotspotAuthUpdated)
QString hotspotAuth() const;
Q_PROPERTY(bool hotspotStored READ hotspotStored NOTIFY hotspotStoredUpdated)
bool hotspotStored() const;
Q_PROPERTY(bool initialized READ isInitialized NOTIFY initialized)
bool isInitialized() const;
Q_PROPERTY(QAbstractItemModel* vpnConnections READ vpnConnections NOTIFY vpnConnectionsUpdated)
QAbstractItemModel* vpnConnections() const;
Q_PROPERTY(bool mobileDataEnabled
READ mobileDataEnabled
WRITE setMobileDataEnabled
NOTIFY mobileDataEnabledUpdated)
bool mobileDataEnabled() const;
Q_PROPERTY(Sim* simForMobileData
READ simForMobileData
WRITE setSimForMobileData
NOTIFY simForMobileDataUpdated)
Sim* simForMobileData() const;
Q_PROPERTY(QAbstractItemModel* modems
READ modems
CONSTANT)
QAbstractItemModel* modems() const;
Q_PROPERTY(QAbstractItemModel* sims
READ sims
CONSTANT)
QAbstractItemModel* sims() const;
public Q_SLOTS:
void setFlightMode(bool enabled);
void setwifiEnabled(bool enabled);
void setHotspotEnabled(bool active);
void setHotspotSsid(const QByteArray& ssid);
void setHotspotPassword(const QString& password);
void setHotspotMode(const QString& mode);
void setHotspotAuth(const QString& auth);
void setMobileDataEnabled(bool enabled);
void setSimForMobileData(Sim *sim);
Q_SIGNALS:
void flightModeUpdated(bool);
void onlineUpdated(bool value);
void limitedBandwidthUpdated(bool value);
void limitationsUpdated(const QVector<connectivityqt::Connectivity::Limitations>&);
void statusUpdated(connectivityqt::Connectivity::Status value);
void wifiEnabledUpdated(bool);
void unstoppableOperationHappeningUpdated(bool);
void flightModeSwitchEnabledUpdated(bool);
void wifiSwitchEnabledUpdated(bool);
void hotspotSwitchEnabledUpdated(bool);
void hotspotSsidUpdated(const QByteArray& name);
void hotspotPasswordUpdated(const QString& password);
void modemAvailableUpdated(bool);
void hotspotEnabledUpdated(bool);
void hotspotModeUpdated(const QString& mode);
void hotspotAuthUpdated(const QString& auth);
void hotspotStoredUpdated(bool);
void reportError(int reason);
void initialized();
void vpnConnectionsUpdated(QAbstractItemModel*);
void mobileDataEnabledUpdated(bool);
void simForMobileDataUpdated(Sim* sim);
protected:
class Priv;
std::shared_ptr<Priv> d;
private:
void onReportError(int reason);
};
}
Q_DECLARE_METATYPE(connectivityqt::Connectivity::Limitations)
Q_DECLARE_METATYPE(QVector<connectivityqt::Connectivity::Limitations>)
Q_DECLARE_METATYPE(connectivityqt::Connectivity::Status)
connectivityqt::Connectivity
Definition connectivity.h:41
connectivityqt::Connectivity::setMobileDataEnabled
void setMobileDataEnabled(bool enabled)
Definition connectivity.cpp:421
connectivityqt::Connectivity::hotspotEnabled
bool hotspotEnabled
Definition connectivity.h:127
connectivityqt::Connectivity::initialized
bool initialized
Definition connectivity.h:139
connectivityqt::Connectivity::flightModeUpdated
void flightModeUpdated(bool)
connectivityqt::Connectivity::LOMIRI_DEFINES_PTRS
LOMIRI_DEFINES_PTRS(Connectivity)
connectivityqt::Connectivity::setHotspotPassword
void setHotspotPassword(const QString &password)
Definition connectivity.cpp:378
connectivityqt::Connectivity::hotspotModeUpdated
void hotspotModeUpdated(const QString &mode)
connectivityqt::Connectivity::wifiSwitchEnabledUpdated
void wifiSwitchEnabledUpdated(bool)
connectivityqt::Connectivity::hotspotStoredUpdated
void hotspotStoredUpdated(bool)
connectivityqt::Connectivity::status
connectivityqt::Connectivity::Status status
Definition connectivity.h:100
connectivityqt::Connectivity::limitationsUpdated
void limitationsUpdated(const QVector< connectivityqt::Connectivity::Limitations > &)
connectivityqt::Connectivity::vpnConnectionsUpdated
void vpnConnectionsUpdated(QAbstractItemModel *)
connectivityqt::Connectivity::reportError
void reportError(int reason)
connectivityqt::Connectivity::simForMobileDataUpdated
void simForMobileDataUpdated(Sim *sim)
connectivityqt::Connectivity::Connectivity
Connectivity(const QDBusConnection &sessionConnection=QDBusConnection::sessionBus(), QObject *parent=0)
Definition connectivity.cpp:212
connectivityqt::Connectivity::wifiEnabled
bool wifiEnabled
Definition connectivity.h:103
connectivityqt::Connectivity::sims
QAbstractItemModel * sims
Definition connectivity.h:156
connectivityqt::Connectivity::hotspotPasswordUpdated
void hotspotPasswordUpdated(const QString &password)
connectivityqt::Connectivity::setSimForMobileData
void setSimForMobileData(Sim *sim)
Definition connectivity.cpp:432
connectivityqt::Connectivity::hotspotSwitchEnabledUpdated
void hotspotSwitchEnabledUpdated(bool)
connectivityqt::Connectivity::vpnConnections
QAbstractItemModel * vpnConnections
Definition connectivity.h:142
connectivityqt::Connectivity::hotspotPassword
QString hotspotPassword
Definition connectivity.h:124
connectivityqt::Connectivity::mobileDataEnabledUpdated
void mobileDataEnabledUpdated(bool)
connectivityqt::Connectivity::statusUpdated
void statusUpdated(connectivityqt::Connectivity::Status value)
connectivityqt::Connectivity::setHotspotAuth
void setHotspotAuth(const QString &auth)
Definition connectivity.cpp:396
connectivityqt::Connectivity::wifiEnabledUpdated
void wifiEnabledUpdated(bool)
connectivityqt::Connectivity::hotspotEnabledUpdated
void hotspotEnabledUpdated(bool)
connectivityqt::Connectivity::simForMobileData
Sim * simForMobileData
Definition connectivity.h:148
connectivityqt::Connectivity::setHotspotMode
void setHotspotMode(const QString &mode)
Definition connectivity.cpp:391
connectivityqt::Connectivity::onlineUpdated
void onlineUpdated(bool value)
connectivityqt::Connectivity::hotspotAuthUpdated
void hotspotAuthUpdated(const QString &auth)
connectivityqt::Connectivity::hotspotStored
bool hotspotStored
Definition connectivity.h:136
connectivityqt::Connectivity::hotspotMode
QString hotspotMode
Definition connectivity.h:130
connectivityqt::Connectivity::mobileDataEnabled
bool mobileDataEnabled
Definition connectivity.h:145
connectivityqt::Connectivity::hotspotSsidUpdated
void hotspotSsidUpdated(const QByteArray &name)
connectivityqt::Connectivity::setwifiEnabled
void setwifiEnabled(bool enabled)
Definition connectivity.cpp:330
connectivityqt::Connectivity::registerMetaTypes
static void registerMetaTypes()
Definition connectivity.cpp:198
connectivityqt::Connectivity::modemAvailable
bool modemAvailable
Definition connectivity.h:118
connectivityqt::Connectivity::hotspotSsid
QByteArray hotspotSsid
Definition connectivity.h:121
connectivityqt::Connectivity::limitedBandwidthUpdated
void limitedBandwidthUpdated(bool value)
connectivityqt::Connectivity::setHotspotEnabled
void setHotspotEnabled(bool active)
Definition connectivity.cpp:383
connectivityqt::Connectivity::modemAvailableUpdated
void modemAvailableUpdated(bool)
connectivityqt::Connectivity::Status
Status
enum for networking status
Definition connectivity.h:74
connectivityqt::Connectivity::d
std::shared_ptr< Priv > d
Definition connectivity.h:225
connectivityqt::Connectivity::setFlightMode
void setFlightMode(bool enabled)
Definition connectivity.cpp:322
connectivityqt::Connectivity::hotspotSwitchEnabled
bool hotspotSwitchEnabled
Definition connectivity.h:115
connectivityqt::Connectivity::online
bool online
Definition connectivity.h:91
connectivityqt::Connectivity::isInitialized
bool isInitialized() const
Definition connectivity.cpp:316
connectivityqt::Connectivity::limitedBandwidth
bool limitedBandwidth
Definition connectivity.h:94
connectivityqt::Connectivity::unstoppableOperationHappeningUpdated
void unstoppableOperationHappeningUpdated(bool)
connectivityqt::Connectivity::flightMode
bool flightMode
Definition connectivity.h:88
connectivityqt::Connectivity::hotspotAuth
QString hotspotAuth
Definition connectivity.h:133
connectivityqt::Connectivity::flightModeSwitchEnabled
bool flightModeSwitchEnabled
Definition connectivity.h:109
connectivityqt::Connectivity::setHotspotSsid
void setHotspotSsid(const QByteArray &ssid)
Definition connectivity.cpp:373
connectivityqt::Connectivity::unstoppableOperationHappening
bool unstoppableOperationHappening
Definition connectivity.h:106
connectivityqt::Connectivity::wifiSwitchEnabled
bool wifiSwitchEnabled
Definition connectivity.h:112
connectivityqt::Connectivity::limitations
QVector< connectivityqt::Connectivity::Limitations > limitations() const
Definition connectivity.cpp:296
connectivityqt::Connectivity::flightModeSwitchEnabledUpdated
void flightModeSwitchEnabledUpdated(bool)
connectivityqt::Connectivity::modems
QAbstractItemModel * modems
Definition connectivity.h:152
connectivityqt::Connectivity::Limitations
Limitations
enum for networking limitations
Definition connectivity.h:60
connectivityqt::Sim
Definition sim.h:32
connectivityqt
Definition connectivity.cpp:37
vpn-connections-list-model.h