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
94 Q_PROPERTY(bool limitedBandwidth READ limitedBandwidth NOTIFY limitedBandwidthUpdated)
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
100 Q_PROPERTY(connectivityqt::Connectivity::Status status READ status NOTIFY statusUpdated)
102
103 Q_PROPERTY(bool wifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
104 bool wifiEnabled() const;
105
106 Q_PROPERTY(bool unstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated)
107 bool unstoppableOperationHappening() const;
108
109 Q_PROPERTY(bool flightModeSwitchEnabled READ flightModeSwitchEnabled NOTIFY flightModeSwitchEnabledUpdated)
110 bool flightModeSwitchEnabled() const;
111
112 Q_PROPERTY(bool wifiSwitchEnabled READ wifiSwitchEnabled NOTIFY wifiSwitchEnabledUpdated)
113 bool wifiSwitchEnabled() const;
114
115 Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
116 bool hotspotSwitchEnabled() const;
117
118 Q_PROPERTY(bool modemAvailable READ modemAvailable NOTIFY modemAvailableUpdated)
119 bool modemAvailable() const;
120
121 Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)
122 QByteArray hotspotSsid() const;
123
124 Q_PROPERTY(QString hotspotPassword READ hotspotPassword WRITE setHotspotPassword NOTIFY hotspotPasswordUpdated)
125 QString hotspotPassword() const;
126
127 Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledUpdated)
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
136 Q_PROPERTY(bool hotspotStored READ hotspotStored NOTIFY hotspotStoredUpdated)
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
146 READ mobileDataEnabled
147 WRITE setMobileDataEnabled
148 NOTIFY mobileDataEnabledUpdated)
149 bool mobileDataEnabled() const;
150
151 Q_PROPERTY(Sim* simForMobileData
152 READ simForMobileData
153 WRITE setSimForMobileData
154 NOTIFY simForMobileDataUpdated)
155 Sim* simForMobileData() const;
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);
179
180 void setHotspotAuth(const QString& auth);
181
182 void setMobileDataEnabled(bool enabled);
183
184 void setSimForMobileData(Sim *sim);
185
186Q_SIGNALS:
188
189 void onlineUpdated(bool value);
190
191 void limitedBandwidthUpdated(bool value);
192
193 void limitationsUpdated(const QVector<connectivityqt::Connectivity::Limitations>&);
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
224
225 void vpnConnectionsUpdated(QAbstractItemModel*);
226
228
230
231protected:
232 class Priv;
233 std::shared_ptr<Priv> d;
234};
235
236}
237
239Q_DECLARE_METATYPE(QVector<connectivityqt::Connectivity::Limitations>)
240Q_DECLARE_METATYPE(connectivityqt::Connectivity::Status)
Definition connectivity.h:41
LOMIRI_DEFINES_PTRS(Connectivity)
void hotspotModeUpdated(const QString &mode)
void limitationsUpdated(const QVector< connectivityqt::Connectivity::Limitations > &)
void vpnConnectionsUpdated(QAbstractItemModel *)
void reportError(int reason)
void simForMobileDataUpdated(Sim *sim)
void hotspotPasswordUpdated(const QString &password)
void hotspotSwitchEnabledUpdated(bool)
void statusUpdated(connectivityqt::Connectivity::Status value)
void onlineUpdated(bool value)
void hotspotAuthUpdated(const QString &auth)
void hotspotSsidUpdated(const QByteArray &name)
void limitedBandwidthUpdated(bool value)
Status
enum for networking status
Definition connectivity.h:74
std::shared_ptr< Priv > d
Definition connectivity.h:233
void unstoppableOperationHappeningUpdated(bool)
void flightModeSwitchEnabledUpdated(bool)
Limitations
enum for networking limitations
Definition connectivity.h:60
Definition sim.h:32
Definition connectivity.cpp:37