1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
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 http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://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 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qdeclarativenetworkinfo_p.h"
35
36QT_BEGIN_NAMESPACE
37
38/*!
39 \qmltype NetworkInfo
40 \instantiates QDeclarativeNetworkInfo
41 \inqmlmodule QtSystemInfo
42 \ingroup qml-systeminfo
43 \brief The NetworkInfo element provides various information about the network status.
44 */
45
46/*!
47 \internal
48 */
49QDeclarativeNetworkInfo::QDeclarativeNetworkInfo(QObject *parent)
50 : QObject(parent)
51 , networkInfo(new QNetworkInfo(this))
52 , isMonitorCurrentNetworkMode(false)
53 , isMonitorNetworkSignalStrength(false)
54 , isMonitorNetworkInterfaceCount(false)
55 , isMonitorCurrentCellDataTechnology(false)
56 , isMonitorNetworkStatus(false)
57 , isMonitorCellId(false)
58 , isMonitorCurrentMobileCountryCode(false)
59 , isMonitorCurrentMobileNetworkCode(false)
60 , isMonitorLocationAreaCode(false)
61 , isMonitorNetworkName(false)
62{
63 connect(sender: networkInfo, SIGNAL(networkInterfaceCountChanged(QNetworkInfo::NetworkMode,int)),
64 receiver: this, SLOT(_q_networkInterfaceCountChanged(QNetworkInfo::NetworkMode,int)));
65 connect(sender: networkInfo, SIGNAL(currentCellDataTechnologyChanged(int,QNetworkInfo::CellDataTechnology)),
66 receiver: this, SLOT(_q_currentCellDataTechnologyChanged(int,QNetworkInfo::CellDataTechnology)));
67 connect(sender: networkInfo, SIGNAL(cellIdChanged(int,QString)), receiver: this, SIGNAL(cellIdChanged(int,QString)));
68 connect(sender: networkInfo, SIGNAL(currentMobileCountryCodeChanged(int,QString)),
69 receiver: this, SIGNAL(currentMobileCountryCodeChanged(int,QString)));
70 connect(sender: networkInfo, SIGNAL(currentMobileNetworkCodeChanged(int,QString)),
71 receiver: this, SIGNAL(currentMobileNetworkCodeChanged(int,QString)));
72 connect(sender: networkInfo, SIGNAL(locationAreaCodeChanged(int,QString)),
73 receiver: this, SIGNAL(locationAreaCodeChanged(int,QString)));
74}
75
76/*!
77 \internal
78 */
79QDeclarativeNetworkInfo::~QDeclarativeNetworkInfo()
80{
81}
82
83/*!
84 \qmlproperty bool NetworkInfo::monitorCurrentNetworkMode
85
86 This property holds whether or not monitor the change of current network mode.
87 */
88bool QDeclarativeNetworkInfo::monitorCurrentNetworkMode() const
89{
90 return isMonitorCurrentNetworkMode;
91}
92
93void QDeclarativeNetworkInfo::setMonitorCurrentNetworkMode(bool monitor)
94{
95 if (monitor != isMonitorCurrentNetworkMode) {
96 isMonitorCurrentNetworkMode = monitor;
97 if (monitor) {
98 connect(sender: networkInfo, SIGNAL(currentNetworkModeChanged(QNetworkInfo::NetworkMode)),
99 receiver: this, SIGNAL(currentNetworkModeChanged()));
100 } else {
101 disconnect(sender: networkInfo, SIGNAL(currentNetworkModeChanged(QNetworkInfo::NetworkMode)),
102 receiver: this, SIGNAL(currentNetworkModeChanged()));
103 }
104 emit monitorCurrentNetworkModeChanged();
105 }
106}
107
108/*!
109 \qmlproperty enumeration NetworkInfo::currentNetworkMode
110
111 This property holds the current network mode. Possible values are:
112 \list
113 \li NetworkInfo.UnknownMode - The network is unknown or an error occured.
114 \li NetworkInfo.GsmMode - Global System for Mobile (GSM) network.
115 \li NetworkInfo.CdmaMode - Code Division Multiple Access (CDMA) network.
116 \li NetworkInfo.WcdmaMode - Wideband Code Division Multiple Access (WCDMA) network.
117 \li NetworkInfo.WlanMode - Wireless local area network (WLAN) network.
118 \li NetworkInfo.EthernetMode - Local area network (LAN), or Ethernet network.
119 \li NetworkInfo.BluetoothMode - Bluetooth network.
120 \li NetworkInfo.WimaxMode - Worldwide Interoperability for Microwave Access (WiMAX) network.
121 \li NetworkInfo.LteMode - 3GPP Long Term Evolution (LTE) network.
122 \li NetworkInfo.TdscdmaMode - Time Division Synchronous Code Division Multiple Access (TD-SCDMA) network.
123 \endlist
124 */
125QDeclarativeNetworkInfo::NetworkMode QDeclarativeNetworkInfo::currentNetworkMode() const
126{
127 return static_cast<QDeclarativeNetworkInfo::NetworkMode>(networkInfo->currentNetworkMode());
128}
129
130/*!
131 \qmlproperty bool NetworkInfo::monitorNetworkSignalStrength
132
133 This property holds whether or not monitor the change of network signal strength.
134 */
135bool QDeclarativeNetworkInfo::monitorNetworkSignalStrength() const
136{
137 return isMonitorNetworkSignalStrength;
138}
139
140void QDeclarativeNetworkInfo::setMonitorNetworkSignalStrength(bool monitor)
141{
142 if (monitor != isMonitorNetworkSignalStrength) {
143 isMonitorNetworkSignalStrength = monitor;
144 if (monitor) {
145 connect(sender: networkInfo, SIGNAL(networkSignalStrengthChanged(QNetworkInfo::NetworkMode,int,int)),
146 receiver: this, SLOT(_q_networkSignalStrengthChanged(QNetworkInfo::NetworkMode,int,int)));
147 } else {
148 disconnect(sender: networkInfo, SIGNAL(networkSignalStrengthChanged(QNetworkInfo::NetworkMode,int,int)),
149 receiver: this, SLOT(_q_networkSignalStrengthChanged(QNetworkInfo::NetworkMode,int,int)));
150 }
151 emit monitorNetworkSignalStrengthChanged();
152 }
153}
154
155/*!
156 \qmlmethod int NetworkInfo::networkSignalStrength(NetworkMode mode, int interface)
157
158 Returns the signal strength of the given \a mode and \a interface. If the information
159 is not available, or error occurs, -1 is returned.
160 */
161int QDeclarativeNetworkInfo::networkSignalStrength(NetworkMode mode, int interface) const
162{
163 return networkInfo->networkSignalStrength(mode: static_cast<QNetworkInfo::NetworkMode>(mode), interfaceDevice: interface);
164}
165
166/*!
167 \qmlsignal NetworkInfo::onNetworkSignalStrengthChanged(NetworkMode mode, int interfaceIndex, int strength)
168
169 This handler is called whenever the signal strength for the \a interfaceIndex of \a mode has changed
170 to \a strength. Note that it won't be called until monitorNetworkSignalStrength is set true.
171
172 \sa networkSignalStrength, monitorNetworkSignalStrength
173 */
174void QDeclarativeNetworkInfo::_q_networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interface, int strength)
175{
176 emit networkSignalStrengthChanged(mode: static_cast<NetworkMode>(mode), interfaceIndex: interface, strength);
177}
178
179/*!
180 \qmlproperty bool NetworkInfo::monitorNetworkInterfaceCount
181
182 This property is obsoleted, and will be removed soon. You don't need to use it at all.
183 */
184bool QDeclarativeNetworkInfo::monitorNetworkInterfaceCount() const
185{
186 return isMonitorNetworkInterfaceCount;
187}
188
189void QDeclarativeNetworkInfo::setMonitorNetworkInterfaceCount(bool monitor)
190{
191 if (monitor != isMonitorNetworkInterfaceCount) {
192 isMonitorNetworkInterfaceCount = monitor;
193 if (monitor) {
194 connect(sender: networkInfo, SIGNAL(networkInterfaceCountChanged(QNetworkInfo::NetworkMode,int)),
195 receiver: this, SLOT(_q_networkInterfaceCountChanged(QNetworkInfo::NetworkMode,int)));
196 } else {
197 disconnect(sender: networkInfo, SIGNAL(networkInterfaceCountChanged(QNetworkInfo::NetworkMode,int)),
198 receiver: this, SLOT(_q_networkInterfaceCountChanged(QNetworkInfo::NetworkMode,int)));
199 }
200 emit monitorNetworkInterfaceCountChanged();
201 }
202}
203
204/*!
205 \qmlmethod int NetworkInfo::networkInterfaceCount(NetworkMode mode)
206
207 Returns the interface count of the given \a mode.
208 */
209int QDeclarativeNetworkInfo::networkInterfaceCount(NetworkMode mode) const
210{
211 return networkInfo->networkInterfaceCount(mode: static_cast<QNetworkInfo::NetworkMode>(mode));
212}
213
214/*!
215 \qmlsignal NetworkInfo::onNetworkInterfaceCountChanged(NetworkMode mode, int count)
216
217 This handler is called whenever the number of interfaces of \a mode has changed to \a count.
218 Note that it won't called until monitorNetworkInterfaceCount is set true.
219
220 \sa networkInterfaceCount, monitorNetworkInterfaceCount
221 */
222void QDeclarativeNetworkInfo::_q_networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count)
223{
224 emit networkInterfaceCountChanged(mode: static_cast<NetworkMode>(mode), count);
225}
226
227/*!
228 \qmlproperty bool NetworkInfo::monitorCurrentCellDataTechnology
229
230 This property is obsoleted, and will be removed soon. You don't need to use it at all.
231 */
232bool QDeclarativeNetworkInfo::monitorCurrentCellDataTechnology() const
233{
234 return isMonitorCurrentCellDataTechnology;
235}
236
237void QDeclarativeNetworkInfo::setMonitorCurrentCellDataTechnology(bool monitor)
238{
239 if (monitor != isMonitorCurrentCellDataTechnology) {
240 isMonitorCurrentCellDataTechnology = monitor;
241 if (monitor) {
242 connect(sender: networkInfo, SIGNAL(currentCellDataTechnologyChanged(int,QNetworkInfo::CellDataTechnology)),
243 receiver: this, SLOT(_q_currentCellDataTechnologyChanged(int,QNetworkInfo::CellDataTechnology)));
244 } else {
245 disconnect(sender: networkInfo, SIGNAL(currentCellDataTechnologyChanged(int,QNetworkInfo::CellDataTechnology)),
246 receiver: this, SLOT(_q_currentCellDataTechnologyChanged(int,QNetworkInfo::CellDataTechnology)));
247 }
248 emit monitorCurrentCellDataTechnologyChanged();
249 }
250}
251
252/*!
253 \qmlmethod CellDataTechnology NetworkInfo::currentCellDataTechnology(int interface)
254
255 Returns the current cell data technology of the given \a interface. Possible values are:
256 \list
257 \li NetworkInfo.UnknownDataTechnology - The cellular technology is unknown or an error occured.
258 \li NetworkInfo.GprsDataTechnology - General Packet Radio Service (GPRS) data service.
259 \li NetworkInfo.EdgeDataTechnology - Enhanced Data Rates for GSM Evolution (EDGE) data service.
260 \li NetworkInfo.UmtsDataTechnology - Universal Mobile Telecommunications System (UMTS) data service.
261 \li NetworkInfo.HspaDataTechnology - High Speed Packet Access (HSPA) data service.
262 \endlist
263 */
264int QDeclarativeNetworkInfo::currentCellDataTechnology(int interface) const
265{
266 return networkInfo->currentCellDataTechnology(interfaceDevice: interface);
267}
268
269/*!
270 \qmlsignal NetworkInfo::onCurrentCellDataTechnologyChanged(int interfaceIndex, CellDataTechnology tech)
271
272 This handler is called whenever the cell data technology of \a interfaceIndex has been changed to \a tech.
273 Note that the signal won't emit until monitorCurrentCellDataTechnology is set true.
274
275 \sa currentCellDataTechnology, monitorCurrentCellDataTechnology
276 */
277void QDeclarativeNetworkInfo::_q_currentCellDataTechnologyChanged(int interface, QNetworkInfo::CellDataTechnology tech)
278{
279 emit currentCellDataTechnologyChanged(interfaceIndex: interface, tech: static_cast<CellDataTechnology>(tech));
280}
281
282/*!
283 \qmlproperty bool NetworkInfo::monitorNetworkStatus
284
285 This property holds whether or not monitor the network status.
286 */
287bool QDeclarativeNetworkInfo::monitorNetworkStatus() const
288{
289 return isMonitorNetworkStatus;
290}
291
292void QDeclarativeNetworkInfo::setMonitorNetworkStatus(bool monitor)
293{
294 if (monitor != isMonitorNetworkStatus) {
295 isMonitorNetworkStatus = monitor;
296 if (monitor) {
297 connect(sender: networkInfo, SIGNAL(networkStatusChanged(QNetworkInfo::NetworkMode,int,QNetworkInfo::NetworkStatus)),
298 receiver: this, SLOT(_q_networkStatusChanged(QNetworkInfo::NetworkMode,int,QNetworkInfo::NetworkStatus)));
299 } else {
300 disconnect(sender: networkInfo, SIGNAL(networkStatusChanged(QNetworkInfo::NetworkMode,int,QNetworkInfo::NetworkStatus)),
301 receiver: this, SLOT(_q_networkStatusChanged(QNetworkInfo::NetworkMode,int,QNetworkInfo::NetworkStatus)));
302 }
303 emit monitorNetworkStatusChanged();
304 }
305}
306
307/*!
308 \qmlmethod NetworkStatus NetworkInfo::networkStatus(NetworkMode mode, int interface)
309
310 Returns the status of the given \a mode and \a interface. Possible values are:
311 \list
312 \li NetworkInfo.UnknownStatus - The status is unknown or an error occured.
313 \li NetworkInfo.NoNetworkAvailable - There is no network available.
314 \li NetworkInfo.EmergencyOnly - The network only allows emergency calls.
315 \li NetworkInfo.Searching - The device is searching or connecting to the network.
316 \li NetworkInfo.Busy - The network is too busy to be connected.
317 \li NetworkInfo.Denied - The connection to the network has been denied.
318 \li NetworkInfo.HomeNetwork - The device is connected to the home network.
319 \li NetworkInfo.Roaming - The device is connected to some roaming network.
320 \endlist
321 */
322int QDeclarativeNetworkInfo::networkStatus(QDeclarativeNetworkInfo::NetworkMode mode, int interface) const
323{
324 return networkInfo->networkStatus(mode: static_cast<QNetworkInfo::NetworkMode>(mode), interfaceDevice: interface);
325}
326
327/*!
328 \qmlsignal NetworkInfo::onNetworkStatusChanged(NetworkMode mode, int interfaceIndex, NetworkStatus status)
329
330 This handler is called whenever the status of \a mode and \a interfaceIndex has been changed to \a status.
331 Note that it won't be called until monitorNetworkStatus is set true.
332
333 \sa networkStatus, monitorNetworkStatus
334 */
335void QDeclarativeNetworkInfo::_q_networkStatusChanged(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status)
336{
337 emit networkStatusChanged(mode: static_cast<NetworkMode>(mode), interfaceIndex: interface, status: static_cast<NetworkStatus>(status));
338}
339
340/*!
341 \qmlproperty bool NetworkInfo::monitorCellId
342
343 This property is obsoleted, and will be removed soon. You don't need to use it at all.
344 */
345bool QDeclarativeNetworkInfo::monitorCellId() const
346{
347 return isMonitorCellId;
348}
349
350void QDeclarativeNetworkInfo::setMonitorCellId(bool monitor)
351{
352 if (monitor != isMonitorCellId) {
353 isMonitorCellId = monitor;
354 if (monitor) {
355 connect(sender: networkInfo, SIGNAL(cellIdChanged(int,QString)),
356 receiver: this, SIGNAL(cellIdChanged(int,QString)));
357 } else {
358 disconnect(sender: networkInfo, SIGNAL(cellIdChanged(int,QString)),
359 receiver: this, SIGNAL(cellIdChanged(int,QString)));
360 }
361 emit monitorCellIdChanged();
362 }
363}
364
365/*!
366 \qmlmethod string NetworkInfo::cellId(int interface)
367
368 Returns the cell ID of the given \a interface. If this information
369 is not available or error occurs, an empty string is returned.
370
371 \sa onCellIdChanged
372 */
373QString QDeclarativeNetworkInfo::cellId(int interface) const
374{
375 return networkInfo->cellId(interfaceDevice: interface);
376}
377
378/*!
379 \qmlsignal NetworkInfo::onCellIdChanged(int interfaceIndex, string id)
380
381 This handler is called whenever the cell ID of \a interfaceIndex has been changed to \a id.
382 Note that it won't be called unless monitorCellId is set true.
383
384 \sa cellId, monitorCellId
385 */
386
387/*!
388 \qmlproperty bool NetworkInfo::monitorCurrentMobileCountryCode
389
390 This property is obsoleted, and will be removed soon. You don't need to use it at all.
391 */
392bool QDeclarativeNetworkInfo::monitorCurrentMobileCountryCode() const
393{
394 return isMonitorCurrentMobileCountryCode;
395}
396
397void QDeclarativeNetworkInfo::setMonitorCurrentMobileCountryCode(bool monitor)
398{
399 if (monitor != isMonitorCurrentMobileCountryCode) {
400 isMonitorCurrentMobileCountryCode = monitor;
401 if (monitor) {
402 connect(sender: networkInfo, SIGNAL(currentMobileCountryCodeChanged(int,QString)),
403 receiver: this, SIGNAL(currentMobileCountryCodeChanged(int,QString)));
404 } else {
405 disconnect(sender: networkInfo, SIGNAL(currentMobileCountryCodeChanged(int,QString)),
406 receiver: this, SIGNAL(currentMobileCountryCodeChanged(int,QString)));
407 }
408 emit monitorCurrentMobileCountryCodeChanged();
409 }
410}
411
412/*!
413 \qmlmethod string NetworkInfo::currentMobileCountryCode(int interface)
414
415 Returns the current mobile country code of the given \a interface. If this information
416 is not available or error occurs, an empty string is returned.
417 */
418QString QDeclarativeNetworkInfo::currentMobileCountryCode(int interface) const
419{
420 return networkInfo->currentMobileCountryCode(interfaceDevice: interface);
421}
422
423/*!
424 \qmlsignal NetworkInfo::onCurrentMobileCountryCodeChanged(int interfaceIndex, string mcc)
425
426 This handler is called whenever the current mobile country code of \a interfaceIndex has been changed
427 to \a mcc. Note that it won't be called unless monitorCurrentMobileCountryCode is set true.
428
429 \sa currentMobileCountryCode, monitorCurrentMobileCountryCode
430 */
431
432/*!
433 \qmlproperty bool NetworkInfo::monitorCurrentMobileNetworkCode
434
435 This property is obsoleted, and will be removed soon. You don't need to use it at all.
436 */
437bool QDeclarativeNetworkInfo::monitorCurrentMobileNetworkCode() const
438{
439 return isMonitorCurrentMobileNetworkCode;
440}
441
442void QDeclarativeNetworkInfo::setMonitorCurrentMobileNetworkCode(bool monitor)
443{
444 if (monitor != isMonitorCurrentMobileNetworkCode) {
445 isMonitorCurrentMobileNetworkCode = monitor;
446 if (monitor) {
447 connect(sender: networkInfo, SIGNAL(currentMobileNetworkCodeChanged(int,QString)),
448 receiver: this, SIGNAL(currentMobileNetworkCodeChanged(int,QString)));
449 } else {
450 disconnect(sender: networkInfo, SIGNAL(currentMobileNetworkCodeChanged(int,QString)),
451 receiver: this, SIGNAL(currentMobileNetworkCodeChanged(int,QString)));
452 }
453 emit monitorCurrentMobileNetworkCodeChanged();
454 }
455}
456
457/*!
458 \qmlmethod string NetworkInfo::currentMobileNetworkCode(int interface)
459
460 Returns the current mobile network code of the given \a interface. If this information
461 is not available or error occurs, an empty string is returned.
462 */
463QString QDeclarativeNetworkInfo::currentMobileNetworkCode(int interface) const
464{
465 return networkInfo->currentMobileNetworkCode(interfaceDevice: interface);
466}
467
468/*!
469 \qmlsignal NetworkInfo::onCurrentMobileNetworkCodeChanged(int interfaceIndex, string mnc)
470
471 This handler is called whenever the current mobile network code of \a interfaceIndex has been changed
472 to \a mnc. Note that it won't be called unless monitorCurrentMobileNetworkCode is set true.
473
474 \sa currentMobileNetworkCode, monitorCurrentMobileNetworkCode
475 */
476
477/*!
478 \qmlproperty bool NetworkInfo::monitorLocationAreaCode
479
480 This property is obsoleted, and will be removed soon. You don't need to use it at all.
481 */
482bool QDeclarativeNetworkInfo::monitorLocationAreaCode() const
483{
484 return isMonitorLocationAreaCode;
485}
486
487void QDeclarativeNetworkInfo::setMonitorLocationAreaCode(bool monitor)
488{
489 if (monitor != isMonitorLocationAreaCode) {
490 isMonitorLocationAreaCode = monitor;
491 if (monitor) {
492 connect(sender: networkInfo, SIGNAL(locationAreaCodeChanged(int,QString)),
493 receiver: this, SIGNAL(locationAreaCodeChanged(int,QString)));
494 } else {
495 disconnect(sender: networkInfo, SIGNAL(locationAreaCodeChanged(int,QString)),
496 receiver: this, SIGNAL(locationAreaCodeChanged(int,QString)));
497 }
498 emit monitorLocationAreaCodeChanged();
499 }
500}
501
502/*!
503 \qmlmethod string NetworkInfo::locationAreaCode(int interface)
504
505 Returns the location area code of the given \a interface. If this information
506 is not available or error occurs, an empty string is returned.
507 */
508QString QDeclarativeNetworkInfo::locationAreaCode(int interface) const
509{
510 return networkInfo->locationAreaCode(interfaceDevice: interface);
511}
512
513/*!
514 \qmlsignal NetworkInfo::onLocationAreaCodeChanged(int interfaceIndex, string lac)
515
516 This handler is called whenever the location area code of \a interfaceIndex has been changed to \a lac.
517 Note that it won't be called unless monitorLocationAreaCode is set true.
518
519 \sa locationAreaCode, monitorLocationAreaCode
520 */
521
522/*!
523 \qmlproperty bool NetworkInfo::monitorNetworkName
524
525 This property holds whether or not monitor the change of network names.
526 */
527bool QDeclarativeNetworkInfo::monitorNetworkName() const
528{
529 return isMonitorNetworkName;
530}
531
532void QDeclarativeNetworkInfo::setMonitorNetworkName(bool monitor)
533{
534 if (monitor != isMonitorNetworkName) {
535 isMonitorNetworkName = monitor;
536 if (monitor) {
537 connect(sender: networkInfo, SIGNAL(networkNameChanged(QNetworkInfo::NetworkMode,int,QString)),
538 receiver: this, SLOT(_q_networkNameChanged(QNetworkInfo::NetworkMode,int,QString)));
539 } else {
540 disconnect(sender: networkInfo, SIGNAL(networkNameChanged(QNetworkInfo::NetworkMode,int,QString)),
541 receiver: this, SLOT(_q_networkNameChanged(QNetworkInfo::NetworkMode,int,QString)));
542 }
543 emit monitorNetworkNameChanged();
544 }
545}
546
547/*!
548 \qmlmethod string NetworkInfo::networkName(NetworkMode mode, int interface)
549
550 Returns the name of the given \a mode and \a interface. If the information is not available,
551 or an error occurs, an empty string is returned.
552
553 In case of WLAN, the SSID is returned; for Ethernet, the domain name is returned if available.
554 */
555QString QDeclarativeNetworkInfo::networkName(NetworkMode mode, int interface) const
556{
557 return networkInfo->networkName(mode: static_cast<QNetworkInfo::NetworkMode>(mode), interfaceDevice: interface);
558}
559
560/*!
561 \qmlsignal NetworkInfo::onNetworkNameChanged(NetworkMode mode, int interfaceIndex, string name)
562
563 This handler is called whenever the network name of \a mode and \a interfaceIndex has been changed
564 to \a name. Note that it won't called until monitorNetworkName is set true.
565
566 \sa networkName, monitorNetworkName
567 */
568void QDeclarativeNetworkInfo::_q_networkNameChanged(QNetworkInfo::NetworkMode mode, int interface, const QString &name)
569{
570 emit networkNameChanged(mode: static_cast<NetworkMode>(mode), interfaceIndex: interface, name);
571}
572
573/*!
574 \qmlmethod string NetworkInfo::macAddress(NetworkMode mode, int interface)
575
576 Returns the MAC address for \a interface of \a mode. If the MAC address is not available or error
577 occurs, an empty string is returned.
578*/
579QString QDeclarativeNetworkInfo::macAddress(QDeclarativeNetworkInfo::NetworkMode mode, int interface) const
580{
581 return networkInfo->macAddress(mode: static_cast<QNetworkInfo::NetworkMode>(mode), interfaceDevice: interface);
582}
583
584/*!
585 \qmlmethod string NetworkInfo::homeMobileCountryCode(int interface)
586
587 Returns the home Mobile Country Code (MCC) for \a interface. An empty string is returned if the
588 information is not available or on error.
589*/
590QString QDeclarativeNetworkInfo::homeMobileCountryCode(int interface) const
591{
592 return networkInfo->homeMobileCountryCode(interfaceDevice: interface);
593}
594
595/*!
596 \qmlmethod string NetworkInfo::homeMobileNetworkCode(int interface)
597
598 Returns the home Mobile Network Code (MNC) for \a interface. An empty string is returned if the
599 information is not available or on error.
600*/
601QString QDeclarativeNetworkInfo::homeMobileNetworkCode(int interface) const
602{
603 return networkInfo->homeMobileNetworkCode(interfaceDevice: interface);
604}
605
606/*!
607 \qmlmethod string NetworkInfo::imsi(int interface)
608
609 Returns the International Mobile Subscriber Identity (IMSI) for \a interface. If this information is
610 not available, or error occurs, an empty string is returned.
611*/
612QString QDeclarativeNetworkInfo::imsi(int interface) const
613{
614 return networkInfo->imsi(interfaceDevice: interface);
615}
616
617QT_END_NAMESPACE
618

source code of qtsystems/src/imports/systeminfo/qdeclarativenetworkinfo.cpp