1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc 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: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 Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QNETWORKINFO_H
43 #define QNETWORKINFO_H
44 
45 #include "qsysteminfoglobal.h"
46 #include <QtCore/qobject.h>
47 #include <QtNetwork/qnetworkinterface.h>
48 
49 QT_BEGIN_NAMESPACE
50 
51 #if !defined(QT_SIMULATOR)
52 class QNetworkInfoPrivate;
53 #else
54 class QNetworkInfoSimulator;
55 #endif // QT_SIMULATOR
56 
57 class Q_SYSTEMINFO_EXPORT QNetworkInfo : public QObject
58 {
59     Q_OBJECT
60 
61 public:
62     enum CellDataTechnology {
63         UnknownDataTechnology = 0,
64         GprsDataTechnology,
65         EdgeDataTechnology,
66         UmtsDataTechnology,
67         HspaDataTechnology
68     };
69 
70     enum NetworkMode {
71         UnknownMode = 0,
72         GsmMode,
73         CdmaMode,
74         WcdmaMode,
75         WlanMode,
76         EthernetMode,
77         BluetoothMode,
78         WimaxMode,
79         LteMode,
80         TdscdmaMode
81     };
82 
83     enum NetworkStatus {
84         UnknownStatus = 0,
85         NoNetworkAvailable,
86         EmergencyOnly,
87         Searching,
88         Busy,
89         Denied,
90         HomeNetwork,
91         Roaming
92         // ,Connected //desktop
93     };
94 
95     QNetworkInfo(QObject *parent = nullptr);
96     ~QNetworkInfo() override;
97 
98     int networkInterfaceCount(QNetworkInfo::NetworkMode mode) const;
99     int networkSignalStrength(QNetworkInfo::NetworkMode mode, int interface) const;
100     QNetworkInfo::CellDataTechnology currentCellDataTechnology(int interface) const;
101     QNetworkInfo::NetworkMode currentNetworkMode() const;
102     QNetworkInfo::NetworkStatus networkStatus(QNetworkInfo::NetworkMode mode, int interface) const;
103 #ifndef QT_NO_NETWORKINTERFACE
104     QNetworkInterface interfaceForMode(QNetworkInfo::NetworkMode mode, int interface) const;
105 #endif // QT_NO_NETWORKINTERFACE
106     QString cellId(int interface) const;
107     QString currentMobileCountryCode(int interface) const;
108     QString currentMobileNetworkCode(int interface) const;
109     QString homeMobileCountryCode(int interface) const;
110     QString homeMobileNetworkCode(int interface) const;
111     QString imsi(int interface) const;
112     QString locationAreaCode(int interface) const;
113     QString macAddress(QNetworkInfo::NetworkMode mode, int interface) const;
114     QString networkName(QNetworkInfo::NetworkMode mode, int interface) const;
115 
116 Q_SIGNALS:
117     void cellIdChanged(int interface, const QString &id);
118     void currentCellDataTechnologyChanged(int interface, QNetworkInfo::CellDataTechnology tech);
119     void currentMobileCountryCodeChanged(int interface, const QString &mcc);
120     void currentMobileNetworkCodeChanged(int interface, const QString &mnc);
121     void currentNetworkModeChanged(QNetworkInfo::NetworkMode mode);
122     void locationAreaCodeChanged(int interface, const QString &lac);
123     void networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count);
124     void networkNameChanged(QNetworkInfo::NetworkMode mode, int interface, const QString &name);
125     void networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interface, int strength);
126     void networkStatusChanged(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status);
127 
128 protected:
129     void connectNotify(const QMetaMethod &signal) override;
130     void disconnectNotify(const QMetaMethod &signal) override;
131 
132 private:
133     Q_DISABLE_COPY(QNetworkInfo)
134 #if !defined(QT_SIMULATOR)
135     QNetworkInfoPrivate * const d_ptr;
136     Q_DECLARE_PRIVATE(QNetworkInfo)
137 #else
138     QNetworkInfoSimulator * const d_ptr;
139 #endif // QT_SIMULATOR
140 };
141 
142 QT_END_NAMESPACE
143 
144 #endif // QNETWORKINFO_H
145