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(bool Initialized READ isInitialized NOTIFY initialized)
98  bool isInitialized() const;
99 
100 public Q_SLOTS:
101  void setFlightMode(bool enabled);
102 
103  void setwifiEnabled(bool enabled);
104 
105 Q_SIGNALS:
106  void flightModeUpdated(bool);
107 
108  void onlineUpdated(bool value);
109 
110  void limitedBandwithUpdated(bool value);
111 
112  void limitationsUpdated(const QVector<Limitations>&);
113 
114  void statusUpdated(connectivityqt::Connectivity::Status value);
115 
116  void wifiEnabledUpdated(bool);
117 
118  void unstoppableOperationHappeningUpdated(bool);
119 
120  void initialized();
121 
122 protected:
123  class Priv;
124  std::shared_ptr<Priv> d;
125 };
126 
127 }
128 
130 Q_DECLARE_METATYPE(QVector<connectivityqt::Connectivity::Limitations>)
131 Q_DECLARE_METATYPE(connectivityqt::Connectivity::Status)
132 
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:123