summaryrefslogtreecommitdiffstats
path: root/src/networksettings/qnetworksettingsservice.cpp
blob: e910bc31e1179f4c3c156edea922b8308b66de87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Device Utilities module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qnetworksettingsservice.h"
#include "qnetworksettingsservice_p.h"

/*!
    \qmltype NetworkService
    \inqmlmodule QtDeviceUtilities.NetworkSettings
    \brief Represents a network service.

    The NetworkService QML type represents a network service.

    Instances of NetworkService cannot be created directly; instead, they can
    be retrieved via NetworkSettingsManager.

    \sa {NetworkSettingsManager::services}{NetworkSettingsManager.services}
*/

QNetworkSettingsService::QNetworkSettingsService(const QString& aServiceId, QObject* parent) :
   QObject(parent)
  ,d_ptr(new QNetworkSettingsServicePrivate(aServiceId, this))
{

}

/*!
    \qmlproperty string NetworkService::id
    \readonly
    \brief Holds a unique ID of this service.
*/
QString QNetworkSettingsService::id() const
{
    Q_D(const QNetworkSettingsService);
    return d->m_id;
}

/*!
    \qmlproperty string NetworkService::name
    \readonly
    \brief Holds the name of this service.
*/
QString QNetworkSettingsService::name() const
{
    Q_D(const QNetworkSettingsService);
    return d->m_name;
}

/*!
    \qmlmethod void NetworkService::setAutoConnect(bool auto)
*/
void QNetworkSettingsService::setAutoConnect(const bool autoconnect)
{
    Q_UNUSED(autoconnect);
}

/*!
    \qmlproperty enumeration NetworkService::state
    \readonly
    \brief Holds the state of this service.

    See \l [QML] {NetworkInterface::state}{NetworkInterface.state}
    for possible states.
*/
QNetworkSettingsState::States QNetworkSettingsService::state()
{
    Q_D(QNetworkSettingsService);
    return d->m_state.state();
}

/*!
    \qmlproperty enumeration NetworkService::type
    \readonly
    \brief Holds the type of this service.

    See \l [QML] {NetworkInterface::type}{NetworkInterface.type}
    for possible types.
*/
QNetworkSettingsType::Types QNetworkSettingsService::type()
{
    Q_D(QNetworkSettingsService);
    return d->m_type.type();
}

/*!
    \qmlproperty NetworkSettingsIPv4 NetworkService::ipv4
    \readonly
    \brief Holds the IPv4 address for this service.
*/
QNetworkSettingsIPv4* QNetworkSettingsService::ipv4()
{
    Q_D(QNetworkSettingsService);
    return &d->m_ipv4config;
}

/*!
    \qmlproperty NetworkSettingsIPv6 NetworkService::ipv6
    \readonly
    \brief Holds the IPv6 address for this service.
*/
QNetworkSettingsIPv6* QNetworkSettingsService::ipv6()
{
    Q_D(QNetworkSettingsService);
    return &d->m_ipv6config;
}

/*!
    \qmlproperty NetworkSettingsProxy NetworkService::proxy
    \readonly
    \brief Holds the proxy settings for this service.
*/
QNetworkSettingsProxy* QNetworkSettingsService::proxy()
{
    Q_D(QNetworkSettingsService);
    return &d->m_proxyConfig;
}

/*!
    \qmlproperty NetworkSettingsWireless NetworkService::wirelessConfig
    \readonly
    \brief Holds the wireless configuration for this service.
*/
QNetworkSettingsWireless* QNetworkSettingsService::wirelessConfig()
{
    Q_D(QNetworkSettingsService);
    return &d->m_wifiConfig;
}

void QNetworkSettingsService::setPlaceholderState(bool placeholderState)
{
    Q_D(QNetworkSettingsService);
    d->setPlaceholderState(placeholderState);
}

bool QNetworkSettingsService::placeholderState() const
{
    Q_D(const QNetworkSettingsService);
    return d->placeholderState();
}

/*!
    \qmlproperty object NetworkService::domains
    \readonly
    \brief The model containing the domains associated with this service.

    The \e domains property can be used as a model for a view
    that lists the domain addresses associated with this service.

    \sa domains.count, domains.append(), domains.remove(), domains.resetChanges()
*/

/*!
    \qmlproperty int NetworkService::domains.count
    \readonly
    \brief Holds the number of domain addresses in the \l domains model.
*/

/*!
   \qmlmethod void NetworkService::domains.append(string address)
   \brief Adds \a address into the \l domains model.
*/

/*!
   \qmlmethod void NetworkService::domains.remove(int index)
   \brief Removes the entry at index \a index from the \l domains model.
*/

/*!
   \qmlmethod void NetworkService::domains.resetChanges()
   \brief Clears unsaved changes from the \l domains model.
*/

QAbstractItemModel* QNetworkSettingsService::domains()
{
    Q_D(QNetworkSettingsService);
    return &d->m_domainsConfig;
}

/*!
    \qmlproperty object NetworkService::nameservers
    \readonly
    \brief The model containing the domain name servers associated with this
           service.

    The \e nameservers property can be used as a model for a view
    that lists the domain name server (DNS) addresses associated with this
    service.

    \sa nameservers.count, nameservers.append(), nameservers.remove(), nameservers.resetChanges()
*/

/*!
    \qmlproperty int NetworkService::nameservers.count
    \readonly
    \brief Holds the number of domain name server addresses in the
           \l nameservers model.
*/

/*!
   \qmlmethod void NetworkService::nameservers.append(string address)
   \brief Adds \a address into the \l nameservers model.
*/

/*!
   \qmlmethod void NetworkService::nameservers.remove(int index)
   \brief Removes the entry at index \a index from the \l nameservers model.
*/

/*!
   \qmlmethod void NetworkService::nameservers.resetChanges()
   \brief Clears unsaved changes from the \l nameservers model.
*/

QAbstractItemModel* QNetworkSettingsService::nameservers()
{
    Q_D(QNetworkSettingsService);
    return &d->m_nameserverConfig;
}

/*!
    \qmlmethod void NetworkService::setupIpv4Config()
    \brief Sets up the IPv4 configuration.

    Call this method after changing the IPv4 settings.

    \sa ipv4
*/
void QNetworkSettingsService::setupIpv4Config()
{
    Q_D(QNetworkSettingsService);
    d->setupIpv4Config();
}

/*!
    \qmlmethod void NetworkService::setupIpv6Config()
    \brief Sets up the IPv6 configuration.

    Call this method after changing the IPv6 settings.

    \sa ipv6
*/
void QNetworkSettingsService::setupIpv6Config()
{
    Q_D(QNetworkSettingsService);
    d->setupIpv6Config();
}

/*!
    \qmlmethod void NetworkService::setupNameserversConfig()
    \brief Sets up the domain name server configuration.

    Call this method after modifying the list of domain name servers.

    \sa nameservers
*/
void QNetworkSettingsService::setupNameserversConfig()
{
    Q_D(QNetworkSettingsService);
    d->setupNameserversConfig();
}

/*!
    \qmlmethod void NetworkService::setupDomainsConfig()
    \brief Sets up the domains configuration.

    Call this method after modifying the list of domain addresses.

    \sa domains
*/
void QNetworkSettingsService::setupDomainsConfig()
{
    Q_D(QNetworkSettingsService);
    d->setupDomainsConfig();
}

/*!
    \qmlmethod void NetworkService::setupNetworkSettingsProxy()
    \brief Sets up the network proxy configuration.

    Call this method after modifying the network proxy settings.

    \sa proxy
*/
void QNetworkSettingsService::setupNetworkSettingsProxy()
{
    Q_D(QNetworkSettingsService);
    d->setupQNetworkSettingsProxy();
}

/*!
    \qmlmethod void NetworkService::connectService()
    \brief Initiates the process of connecting to this network service.

    \sa disconnectService()
*/
void QNetworkSettingsService::connectService()
{
    Q_D(QNetworkSettingsService);
    d->connectService();
}

/*!
    \qmlmethod void NetworkService::disconnectService()
    \brief Disconnects this service.

    \sa connectService()
*/
void QNetworkSettingsService::disconnectService()
{
    Q_D(QNetworkSettingsService);
    d->disconnectService();
}