connectivity-api
connectivity.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Canonical, Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3, as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranties of
10  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11  * PURPOSE. See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * 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 <QDBusConnection>
23 #include <QObject>
24 #include <QStringList>
25 #include <memory>
26 
27 #include <unity/util/DefinesPtrs.h>
28 
29 namespace connectivityqt
30 {
31 
32 class Q_DECL_EXPORT Connectivity: public QObject
33 {
34  Q_OBJECT
35 
36 public:
37  UNITY_DEFINES_PTRS(Connectivity);
38 
39  Q_DISABLE_COPY(Connectivity)
40 
41  Q_ENUMS(Limitations)
42  Q_ENUMS(Status)
43 
44  static void registerMetaTypes();
45 
51  enum class Limitations
52  {
57  Bandwith
58  };
59 
65  enum class Status
66  {
67  Offline,
68  Connecting,
69  Online
70  };
71 
72  Connectivity(const QDBusConnection& sessionConnection = QDBusConnection::sessionBus(), QObject* parent = 0);
73 
74  ~Connectivity();
75 
76  Q_PROPERTY(bool flightMode READ flightMode WRITE setFlightMode NOTIFY flightModeUpdated)
77  Q_PROPERTY(bool FlightMode READ flightMode WRITE setFlightMode NOTIFY flightModeUpdated)
78  bool flightMode() const;
79 
80  Q_PROPERTY(bool online READ online NOTIFY onlineUpdated)
81  bool online() const;
82 
83  Q_PROPERTY(bool limitedBandwith READ limitedBandwith NOTIFY limitedBandwithUpdated)
84  bool limitedBandwith() const;
85 
86  Q_PROPERTY(QVector<Limitations> Limitations READ limitations NOTIFY limitationsUpdated)
87  QVector<Limitations> limitations() const;
88 
89  Q_PROPERTY(connectivityqt::Connectivity::Status Status READ status NOTIFY statusUpdated)
90  Status status() const;
91 
92  Q_PROPERTY(bool wifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
93  Q_PROPERTY(bool WifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
94  bool wifiEnabled() const;
95 
96  Q_PROPERTY(bool UnstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated)
97  bool unstoppableOperationHappening() const;
98 
99  Q_PROPERTY(bool FlightModeSwitchEnabled READ flightModeSwitchEnabled NOTIFY flightModeSwitchEnabledUpdated)
100  Q_PROPERTY(bool flightModeSwitchEnabled READ flightModeSwitchEnabled NOTIFY flightModeSwitchEnabledUpdated)
101  bool flightModeSwitchEnabled() const;
102 
103  Q_PROPERTY(bool WifiSwitchEnabled READ wifiSwitchEnabled NOTIFY wifiSwitchEnabledUpdated)
104  Q_PROPERTY(bool wifiSwitchEnabled READ wifiSwitchEnabled NOTIFY wifiSwitchEnabledUpdated)
105  bool wifiSwitchEnabled() const;
106 
107  Q_PROPERTY(bool HotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
108  Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
109  bool hotspotSwitchEnabled() const;
110 
111  Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)
112  QByteArray hotspotSsid() const;
113 
114  Q_PROPERTY(QString hotspotPassword READ hotspotPassword WRITE setHotspotPassword NOTIFY hotspotPasswordUpdated)
115  QString hotspotPassword() const;
116 
117  Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledUpdated)
118  bool hotspotEnabled() const;
119 
120  Q_PROPERTY(QString hotspotMode READ hotspotMode WRITE setHotspotMode NOTIFY hotspotModeUpdated)
121  QString hotspotMode() const;
122 
123  Q_PROPERTY(QString hotspotAuth READ hotspotAuth WRITE setHotspotAuth NOTIFY hotspotAuthUpdated)
124  QString hotspotAuth() const;
125 
126  Q_PROPERTY(bool hotspotStored READ hotspotStored NOTIFY hotspotStoredUpdated)
127  bool hotspotStored() const;
128 
129  Q_PROPERTY(bool Initialized READ isInitialized NOTIFY initialized)
130  bool isInitialized() const;
131 
132 public Q_SLOTS:
133  void setFlightMode(bool enabled);
134 
135  void setwifiEnabled(bool enabled);
136 
137  void setHotspotEnabled(bool active);
138 
139  void setHotspotSsid(const QByteArray& ssid);
140 
141  void setHotspotPassword(const QString& password);
142 
143  void setHotspotMode(const QString& mode);
144 
145  void setHotspotAuth(const QString& auth);
146 
147 Q_SIGNALS:
148  void flightModeUpdated(bool);
149 
150  void onlineUpdated(bool value);
151 
152  void limitedBandwithUpdated(bool value);
153 
154  void limitationsUpdated(const QVector<Limitations>&);
155 
156  void statusUpdated(connectivityqt::Connectivity::Status value);
157 
158  void wifiEnabledUpdated(bool);
159 
160  void unstoppableOperationHappeningUpdated(bool);
161 
162  void flightModeSwitchEnabledUpdated(bool);
163 
164  void wifiSwitchEnabledUpdated(bool);
165 
166  void hotspotSwitchEnabledUpdated(bool);
167 
168  void hotspotSsidUpdated(const QByteArray& name);
169 
170  void hotspotPasswordUpdated(const QString& password);
171 
172  void hotspotEnabledUpdated(bool);
173 
174  void hotspotModeUpdated(const QString& mode);
175 
176  void hotspotAuthUpdated(const QString& auth);
177 
178  void hotspotStoredUpdated(bool);
179 
180  void reportError(int reason);
181 
182  void initialized();
183 
184 protected:
185  class Priv;
186  std::shared_ptr<Priv> d;
187 };
188 
189 }
190 
191 Q_DECLARE_METATYPE(connectivityqt::Connectivity::Limitations)
192 Q_DECLARE_METATYPE(QVector<connectivityqt::Connectivity::Limitations>)
193 Q_DECLARE_METATYPE(connectivityqt::Connectivity::Status)
194 
STL namespace.
Definition: connectivity.cpp:30
Definition: connectivity.h:32
Limitations
enum for networking limitations
Definition: connectivity.h:51
Status
enum for networking status
Definition: connectivity.h:65