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#ifndef QNETWORKINFO_H
35#define QNETWORKINFO_H
36
37#include <QtSystemInfo/qsysteminfoglobal.h>
38#include <QtCore/qobject.h>
39#include <QtNetwork/qnetworkinterface.h>
40
41QT_BEGIN_NAMESPACE
42
43#if !defined(QT_SIMULATOR)
44class QNetworkInfoPrivate;
45#else
46class QNetworkInfoSimulator;
47#endif // QT_SIMULATOR
48
49class Q_SYSTEMINFO_EXPORT QNetworkInfo : public QObject
50{
51 Q_OBJECT
52
53public:
54 enum CellDataTechnology {
55 UnknownDataTechnology = 0,
56 GprsDataTechnology,
57 EdgeDataTechnology,
58 UmtsDataTechnology,
59 HspaDataTechnology
60 };
61
62 enum NetworkMode {
63 UnknownMode = 0,
64 GsmMode,
65 CdmaMode,
66 WcdmaMode,
67 WlanMode,
68 EthernetMode,
69 BluetoothMode,
70 WimaxMode,
71 LteMode,
72 TdscdmaMode
73 };
74
75 enum NetworkStatus {
76 UnknownStatus = 0,
77 NoNetworkAvailable,
78 EmergencyOnly,
79 Searching,
80 Busy,
81 Denied,
82 HomeNetwork,
83 Roaming
84 // ,Connected //desktop
85 };
86
87 explicit QNetworkInfo(QObject *parent = Q_NULLPTR);
88 virtual ~QNetworkInfo();
89
90 int networkInterfaceCount(QNetworkInfo::NetworkMode mode) const;
91 int networkSignalStrength(QNetworkInfo::NetworkMode mode, int interfaceDevice) const;
92 QNetworkInfo::CellDataTechnology currentCellDataTechnology(int interfaceDevice) const;
93 QNetworkInfo::NetworkMode currentNetworkMode() const;
94 QNetworkInfo::NetworkStatus networkStatus(QNetworkInfo::NetworkMode mode, int interfaceDevice) const;
95#ifndef QT_NO_NETWORKINTERFACE
96 QNetworkInterface interfaceForMode(QNetworkInfo::NetworkMode mode, int interfaceDevice) const;
97#endif // QT_NO_NETWORKINTERFACE
98 QString cellId(int interfaceDevice) const;
99 QString currentMobileCountryCode(int interfaceDevice) const;
100 QString currentMobileNetworkCode(int interfaceDevice) const;
101 QString homeMobileCountryCode(int interfaceDevice) const;
102 QString homeMobileNetworkCode(int interfaceDevice) const;
103 QString imsi(int interfaceDevice) const;
104 QString locationAreaCode(int interfaceDevice) const;
105 QString macAddress(QNetworkInfo::NetworkMode mode, int interfaceDevice) const;
106 QString networkName(QNetworkInfo::NetworkMode mode, int interfaceDevice) const;
107
108Q_SIGNALS:
109 void cellIdChanged(int interfaceDevice, const QString &id);
110 void currentCellDataTechnologyChanged(int interfaceDevice, QNetworkInfo::CellDataTechnology tech);
111 void currentMobileCountryCodeChanged(int interfaceDevice, const QString &mcc);
112 void currentMobileNetworkCodeChanged(int interfaceDevice, const QString &mnc);
113 void currentNetworkModeChanged(QNetworkInfo::NetworkMode mode);
114 void locationAreaCodeChanged(int interfaceDevice, const QString &lac);
115 void networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count);
116 void networkNameChanged(QNetworkInfo::NetworkMode mode, int interfaceDevice, const QString &name);
117 void networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interfaceDevice, int strength);
118 void networkStatusChanged(QNetworkInfo::NetworkMode mode, int interfaceDevice, QNetworkInfo::NetworkStatus status);
119
120protected:
121 void connectNotify(const QMetaMethod &signal);
122 void disconnectNotify(const QMetaMethod &signal);
123
124private:
125 Q_DISABLE_COPY(QNetworkInfo)
126#if !defined(QT_SIMULATOR)
127 QNetworkInfoPrivate * const d_ptr;
128 Q_DECLARE_PRIVATE(QNetworkInfo)
129#else
130 QNetworkInfoSimulator * const d_ptr;
131#endif // QT_SIMULATOR
132};
133
134QT_END_NAMESPACE
135
136#endif // QNETWORKINFO_H
137

source code of qtsystems/src/systeminfo/qnetworkinfo.h