connectivity-api: connectivityqt/connectivity.h Source File

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 <unity/util/DefinesPtrs.h>
30
31 #include <connectivityqt/vpn-connections-list-model.h>
32
33 #include <QDBusObjectPath>
34
35 namespace connectivityqt
36 {
37
38 class Sim;
39
40 class Q_DECL_EXPORT Connectivity: public QObject
41 {
42 Q_OBJECT
43
44 public:
45 UNITY_DEFINES_PTRS(Connectivity);
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 Bandwith
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
86 ~Connectivity();
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 limitedBandwith READ limitedBandwith NOTIFY limitedBandwithUpdated)
95 bool limitedBandwith() const;
96
97 Q_PROPERTY(QVector<Limitations> Limitations READ limitations NOTIFY limitationsUpdated)
98 QVector<Limitations> limitations() const;
99
100 Q_PROPERTY(connectivityqt::Connectivity::Status status READ status NOTIFY statusUpdated)
101 connectivityqt::Connectivity::Status status() const;
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
167 public 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
186 Q_SIGNALS:
187 void flightModeUpdated(bool);
188
189 void onlineUpdated(bool value);
190
191 void limitedBandwithUpdated(bool value);
192
193 void limitationsUpdated(const QVector<connectivityqt::Connectivity::Limitations>&);
194
195 void statusUpdated(connectivityqt::Connectivity::Status value);
196
197 void wifiEnabledUpdated(bool);
198
199 void unstoppableOperationHappeningUpdated(bool);
200
201 void flightModeSwitchEnabledUpdated(bool);
202
203 void wifiSwitchEnabledUpdated(bool);
204
205 void hotspotSwitchEnabledUpdated(bool);
206
207 void hotspotSsidUpdated(const QByteArray& name);
208
209 void hotspotPasswordUpdated(const QString& password);
210
211 void modemAvailableUpdated(bool);
212
213 void hotspotEnabledUpdated(bool);
214
215 void hotspotModeUpdated(const QString& mode);
216
217 void hotspotAuthUpdated(const QString& auth);
218
219 void hotspotStoredUpdated(bool);
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
231 protected:
232 class Priv;
233 std::shared_ptr<Priv> d;
234 };
235
236 }
237
238 Q_DECLARE_METATYPE(connectivityqt::Connectivity::Limitations)
239 Q_DECLARE_METATYPE(QVector<connectivityqt::Connectivity::Limitations>)
240 Q_DECLARE_METATYPE(connectivityqt::Connectivity::Status)
241
connectivityqt::Connectivity::Limitations
Limitations
enum for networking limitations
Definition: connectivity.h:60
connectivityqt::Connectivity
Definition: connectivity.h:41
connectivityqt
Definition: connectivity.cpp:37
connectivityqt::Connectivity::UNITY_DEFINES_PTRS
UNITY_DEFINES_PTRS(Connectivity)
connectivityqt::Connectivity::Status
Status
enum for networking status
Definition: connectivity.h:74
connectivityqt::Sim
Definition: sim.h:32
vpn-connections-list-model.h