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  bool flightMode() const;
78 
79  Q_PROPERTY(bool online READ online NOTIFY onlineUpdated)
80  bool online() const;
81 
82  Q_PROPERTY(bool limitedBandwith READ limitedBandwith NOTIFY limitedBandwithUpdated)
83  bool limitedBandwith() const;
84 
85  Q_PROPERTY(QVector<Limitations> Limitations READ limitations NOTIFY limitationsUpdated)
86  QVector<Limitations> limitations() const;
87 
88  Q_PROPERTY(connectivityqt::Connectivity::Status Status READ status NOTIFY statusUpdated)
89  Status status() const;
90 
91  Q_PROPERTY(bool WifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
92  bool wifiEnabled() const;
93 
94  Q_PROPERTY(bool UnstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated)
95  bool unstoppableOperationHappening() const;
96 
97  Q_PROPERTY(QByteArray hotspotSsid READ hotspotSsid WRITE setHotspotSsid NOTIFY hotspotSsidUpdated)
98  QByteArray hotspotSsid() const;
99 
100  Q_PROPERTY(QString hotspotPassword READ hotspotPassword WRITE setHotspotPassword NOTIFY hotspotPasswordUpdated)
101  QString hotspotPassword() const;
102 
103  Q_PROPERTY(bool hotspotEnabled READ hotspotEnabled WRITE setHotspotEnabled NOTIFY hotspotEnabledUpdated)
104  bool hotspotEnabled() const;
105 
106  Q_PROPERTY(QString hotspotMode READ hotspotMode WRITE setHotspotMode NOTIFY hotspotModeUpdated)
107  QString hotspotMode() const;
108 
109  Q_PROPERTY(bool hotspotStored READ hotspotStored NOTIFY hotspotStoredUpdated)
110  bool hotspotStored() const;
111 
112  Q_PROPERTY(bool Initialized READ isInitialized NOTIFY initialized)
113  bool isInitialized() const;
114 
115 public Q_SLOTS:
116  void setFlightMode(bool enabled);
117 
118  void setwifiEnabled(bool enabled);
119 
120  void setHotspotEnabled(bool active);
121 
122  void setHotspotSsid(const QByteArray& ssid);
123 
124  void setHotspotPassword(const QString& password);
125 
126  void setHotspotMode(const QString& mode);
127 
128 Q_SIGNALS:
129  void flightModeUpdated(bool);
130 
131  void onlineUpdated(bool value);
132 
133  void limitedBandwithUpdated(bool value);
134 
135  void limitationsUpdated(const QVector<Limitations>&);
136 
137  void statusUpdated(connectivityqt::Connectivity::Status value);
138 
139  void wifiEnabledUpdated(bool);
140 
141  void unstoppableOperationHappeningUpdated(bool);
142 
143  void hotspotSsidUpdated(const QByteArray& name);
144 
145  void hotspotPasswordUpdated(const QString& password);
146 
147  void hotspotEnabledUpdated(bool);
148 
149  void hotspotModeUpdated(const QString& mode);
150 
151  void hotspotStoredUpdated(bool);
152 
153  void reportError(int reason);
154 
155  void initialized();
156 
157 protected:
158  class Priv;
159  std::shared_ptr<Priv> d;
160 };
161 
162 }
163 
165 Q_DECLARE_METATYPE(QVector<connectivityqt::Connectivity::Limitations>)
166 Q_DECLARE_METATYPE(connectivityqt::Connectivity::Status)
167 
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
std::shared_ptr< Priv > d
Definition: connectivity.h:158