1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QCONNMANSERVICE_H
41#define QCONNMANSERVICE_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtDBus/QtDBus>
55#include <QtDBus/QDBusConnection>
56#include <QtDBus/QDBusError>
57#include <QtDBus/QDBusInterface>
58#include <QtDBus/QDBusMessage>
59#include <QtDBus/QDBusReply>
60#include <QtDBus/QDBusArgument>
61
62#include <QtDBus/QDBusPendingCallWatcher>
63#include <QtDBus/QDBusObjectPath>
64#include <QtDBus/QDBusContext>
65#include <QMap>
66
67#ifndef QT_NO_DBUS
68
69#ifndef __CONNMAN_DBUS_H
70
71#define CONNMAN_SERVICE "net.connman"
72#define CONNMAN_PATH "/net/connman"
73#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
74#define CONNMAN_MANAGER_PATH "/"
75#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
76#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
77#endif
78
79QT_BEGIN_NAMESPACE
80
81struct ConnmanMap {
82 QDBusObjectPath objectPath;
83 QVariantMap propertyMap;
84};
85Q_DECLARE_TYPEINFO(ConnmanMap, Q_MOVABLE_TYPE); // QDBusObjectPath is movable, but cannot be
86 // marked as such until Qt 6
87typedef QVector<ConnmanMap> ConnmanMapList;
88
89QT_END_NAMESPACE
90
91Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMap))
92Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMapList))
93
94QT_BEGIN_NAMESPACE
95
96QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj);
97const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj);
98
99class QConnmanTechnologyInterface;
100class QConnmanServiceInterface;
101
102class QConnmanManagerInterface : public QDBusAbstractInterface
103{
104 Q_OBJECT
105
106public:
107
108 QConnmanManagerInterface( QObject *parent = nullptr);
109 ~QConnmanManagerInterface();
110
111 QDBusObjectPath path() const;
112 QVariantMap getProperties();
113
114 QString getState();
115 bool getOfflineMode();
116 QStringList getTechnologies();
117 QStringList getServices();
118 bool requestScan(const QString &type);
119
120 QHash<QString, QConnmanTechnologyInterface *> technologiesMap;
121
122Q_SIGNALS:
123 void propertyChanged(const QString &, const QDBusVariant &value);
124 void stateChanged(const QString &);
125 void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
126 void servicesChanged(const ConnmanMapList&, const QList<QDBusObjectPath> &);
127
128 void servicesReady(const QStringList &);
129 void scanFinished(bool error);
130
131protected:
132 void connectNotify(const QMetaMethod &signal);
133 QVariant getProperty(const QString &);
134
135private:
136 QVariantMap propertiesCacheMap;
137 QStringList servicesList;
138 QStringList technologiesList;
139
140private slots:
141 void onServicesChanged(const ConnmanMapList&, const QList<QDBusObjectPath> &);
142 void changedProperty(const QString &, const QDBusVariant &value);
143
144 void propertiesReply(QDBusPendingCallWatcher *call);
145 void servicesReply(QDBusPendingCallWatcher *call);
146
147 void technologyAdded(const QDBusObjectPath &technology, const QVariantMap &properties);
148 void technologyRemoved(const QDBusObjectPath &technology);
149
150};
151
152class QConnmanServiceInterface : public QDBusAbstractInterface
153{
154 Q_OBJECT
155
156public:
157
158 explicit QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = nullptr);
159 ~QConnmanServiceInterface();
160
161 QVariantMap getProperties();
162 // clearProperty
163 void connect();
164 void disconnect();
165 void remove();
166
167// properties
168 QString state();
169 QString lastError();
170 QString name();
171 QString type();
172 QString security();
173 bool favorite();
174 bool autoConnect();
175 bool roaming();
176 QVariantMap ethernet();
177 QString serviceInterface();
178
179 bool isOfflineMode();
180 QStringList services();
181
182Q_SIGNALS:
183 void propertyChanged(const QString &, const QDBusVariant &value);
184 void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
185 void propertiesReady();
186 void stateChanged(const QString &state);
187
188protected:
189 void connectNotify(const QMetaMethod &signal);
190 QVariant getProperty(const QString &);
191private:
192 QVariantMap propertiesCacheMap;
193private slots:
194 void propertiesReply(QDBusPendingCallWatcher *call);
195 void changedProperty(const QString &, const QDBusVariant &value);
196
197};
198
199class QConnmanTechnologyInterface : public QDBusAbstractInterface
200{
201 Q_OBJECT
202
203public:
204
205 explicit QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = nullptr);
206 ~QConnmanTechnologyInterface();
207
208 QString type();
209
210 void scan();
211Q_SIGNALS:
212 void propertyChanged(const QString &, const QDBusVariant &value);
213 void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
214 void scanFinished(bool error);
215protected:
216 void connectNotify(const QMetaMethod &signal);
217 QVariant getProperty(const QString &);
218private:
219 QVariantMap properties();
220 QVariantMap propertiesMap;
221private Q_SLOTS:
222 void scanReply(QDBusPendingCallWatcher *call);
223
224};
225
226QT_END_NAMESPACE
227
228#endif // QT_NO_DBUS
229
230#endif //QCONNMANSERVICE_H
231

source code of qtbase/src/plugins/bearer/connman/qconnmanservice_linux_p.h