lomiri-connectivity-api
connectivity.h
Go to the documentation of this file.
1/*
2 * Copyright © 2014 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 * Authors:
17 * Pete Woods <pete.woods@canonical.com>
18 */
19
20#pragma once
21
22#include <QAbstractListModel>
23#include <QDBusConnection>
24#include <QObject>
25#include <QStringList>
26#include <functional>
27#include <memory>
28
29#include <lomiri/util/DefinesPtrs.h>
30
32
33#include <QDBusObjectPath>
34
35namespace connectivityqt
36{
37
38class Sim;
39
40class Q_DECL_EXPORT Connectivity: public QObject
41{
42 Q_OBJECT
43
44public:
46
47 Q_DISABLE_COPY(Connectivity)
48
49 Q_ENUMS(Limitations)
50 Q_ENUMS(Status)
51
52 static void registerMetaTypes();
53
59 enum class Limitations
60 {
65 Bandwidth
66 };
67
73 enum class Status
74 {
75 Offline,
76 Connecting,
77 Online
78 };
79
80 Connectivity(const QDBusConnection& sessionConnection = QDBusConnection::sessionBus(), QObject* parent = 0);
81
82 Connectivity(const std::function<void(QObject*)>& objectOwner,
83 const QDBusConnection& sessionConnection = QDBusConnection::sessionBus(),
84 QObject* parent = 0);
85
87
88 Q_PROPERTY(bool flightMode READ flightMode WRITE setFlightMode NOTIFY flightModeUpdated)
89 bool flightMode() const;
90
91 Q_PROPERTY(bool online READ online NOTIFY onlineUpdated)
92 bool online() const;
93
95 bool limitedBandwidth() const;
96
97 Q_PROPERTY(QVector<connectivityqt::Connectivity::Limitations> Limitations READ limitations NOTIFY limitationsUpdated)
98 QVector<connectivityqt::Connectivity::Limitations> limitations() const;
99
102
103 Q_PROPERTY(bool wifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
104 bool wifiEnabled() const;
105
108
110 bool flightModeSwitchEnabled() const;
111
113 bool wifiSwitchEnabled() const;
114
116 bool hotspotSwitchEnabled() const;
117
119 bool modemAvailable() const;
120
121 Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)
122 QByteArray hotspotSsid() const;
123
125 QString hotspotPassword() const;
126
128 bool hotspotEnabled() const;
129
130 Q_PROPERTY(QString hotspotMode READ hotspotMode WRITE setHotspotMode NOTIFY hotspotModeUpdated)
131 QString hotspotMode() const;
132
133 Q_PROPERTY(QString hotspotAuth READ hotspotAuth WRITE setHotspotAuth NOTIFY hotspotAuthUpdated)
134 QString hotspotAuth() const;
135
137 bool hotspotStored() const;
138
139 Q_PROPERTY(bool initialized READ isInitialized NOTIFY initialized)
140 bool isInitialized() const;
141
142 Q_PROPERTY(QAbstractItemModel* vpnConnections READ vpnConnections NOTIFY vpnConnectionsUpdated)
143 QAbstractItemModel* vpnConnections() const;
144
145 Q_PROPERTY(bool mobileDataEnabled
149 bool mobileDataEnabled() const;
150
156
157 Q_PROPERTY(QAbstractItemModel* modems
158 READ modems
159 CONSTANT)
160 QAbstractItemModel* modems() const;
161
162 Q_PROPERTY(QAbstractItemModel* sims
163 READ sims
164 CONSTANT)
165 QAbstractItemModel* sims() const;
166
167public Q_SLOTS:
168 void setFlightMode(bool enabled);
169
170 void setwifiEnabled(bool enabled);
171
172 void setHotspotEnabled(bool active);
173
174 void setHotspotSsid(const QByteArray& ssid);
175
176 void setHotspotPassword(const QString& password);
177
178 void setHotspotMode(const QString& mode);
180 void setHotspotAuth(const QString& auth);
182 void setMobileDataEnabled(bool enabled);
184 void setSimForMobileData(Sim *sim);
186Q_SIGNALS:
188
189 void onlineUpdated(bool value);
190
191 void limitedBandwidthUpdated(bool value);
192
194
196
198
200
202
204
206
207 void hotspotSsidUpdated(const QByteArray& name);
208
209 void hotspotPasswordUpdated(const QString& password);
210
212
214
215 void hotspotModeUpdated(const QString& mode);
216
217 void hotspotAuthUpdated(const QString& auth);
218
220
221 void reportError(int reason);
222
223 void initialized();
224
225 void vpnConnectionsUpdated(QAbstractItemModel*);
226
227 void mobileDataEnabledUpdated(bool);
228
229 void simForMobileDataUpdated(Sim* sim);
230
231protected:
232 class Priv;
233 std::shared_ptr<Priv> d;
234
235private:
236 void onReportError(int reason);
237};
238
239}
240
241Q_DECLARE_METATYPE(connectivityqt::Connectivity::Limitations)
242Q_DECLARE_METATYPE(QVector<connectivityqt::Connectivity::Limitations>)
243Q_DECLARE_METATYPE(connectivityqt::Connectivity::Status)
Definition connectivity.h:41
void setMobileDataEnabled(bool enabled)
Definition connectivity.cpp:421
bool hotspotEnabled
Definition connectivity.h:127
bool initialized
Definition connectivity.h:139
LOMIRI_DEFINES_PTRS(Connectivity)
void setHotspotPassword(const QString &password)
Definition connectivity.cpp:378
void hotspotModeUpdated(const QString &mode)
connectivityqt::Connectivity::Status status
Definition connectivity.h:100
void limitationsUpdated(const QVector< connectivityqt::Connectivity::Limitations > &)
void vpnConnectionsUpdated(QAbstractItemModel *)
void reportError(int reason)
void simForMobileDataUpdated(Sim *sim)
Connectivity(const QDBusConnection &sessionConnection=QDBusConnection::sessionBus(), QObject *parent=0)
Definition connectivity.cpp:212
bool wifiEnabled
Definition connectivity.h:103
QAbstractItemModel * sims
Definition connectivity.h:156
void hotspotPasswordUpdated(const QString &password)
void setSimForMobileData(Sim *sim)
Definition connectivity.cpp:432
void hotspotSwitchEnabledUpdated(bool)
QAbstractItemModel * vpnConnections
Definition connectivity.h:142
QString hotspotPassword
Definition connectivity.h:124
void statusUpdated(connectivityqt::Connectivity::Status value)
void setHotspotAuth(const QString &auth)
Definition connectivity.cpp:396
Sim * simForMobileData
Definition connectivity.h:148
void setHotspotMode(const QString &mode)
Definition connectivity.cpp:391
void onlineUpdated(bool value)
void hotspotAuthUpdated(const QString &auth)
bool hotspotStored
Definition connectivity.h:136
QString hotspotMode
Definition connectivity.h:130
bool mobileDataEnabled
Definition connectivity.h:145
void hotspotSsidUpdated(const QByteArray &name)
void setwifiEnabled(bool enabled)
Definition connectivity.cpp:330
static void registerMetaTypes()
Definition connectivity.cpp:198
bool modemAvailable
Definition connectivity.h:118
QByteArray hotspotSsid
Definition connectivity.h:121
void limitedBandwidthUpdated(bool value)
void setHotspotEnabled(bool active)
Definition connectivity.cpp:383
Status
enum for networking status
Definition connectivity.h:74
std::shared_ptr< Priv > d
Definition connectivity.h:225
void setFlightMode(bool enabled)
Definition connectivity.cpp:322
bool hotspotSwitchEnabled
Definition connectivity.h:115
bool online
Definition connectivity.h:91
bool isInitialized() const
Definition connectivity.cpp:316
bool limitedBandwidth
Definition connectivity.h:94
void unstoppableOperationHappeningUpdated(bool)
bool flightMode
Definition connectivity.h:88
QString hotspotAuth
Definition connectivity.h:133
bool flightModeSwitchEnabled
Definition connectivity.h:109
void setHotspotSsid(const QByteArray &ssid)
Definition connectivity.cpp:373
bool unstoppableOperationHappening
Definition connectivity.h:106
bool wifiSwitchEnabled
Definition connectivity.h:112
QVector< connectivityqt::Connectivity::Limitations > limitations() const
Definition connectivity.cpp:296
void flightModeSwitchEnabledUpdated(bool)
QAbstractItemModel * modems
Definition connectivity.h:152
Limitations
enum for networking limitations
Definition connectivity.h:60
Definition sim.h:32
Definition connectivity.cpp:37