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 | // |
35 | // W A R N I N G |
36 | // ------------- |
37 | // |
38 | // This file is not part of the Qt API. It exists purely as an |
39 | // implementation detail. This header file may change from version to |
40 | // version without notice, or even be removed. |
41 | // |
42 | // We mean it. |
43 | // |
44 | |
45 | #ifndef QDECLARATIVENETWORKINFO_P_H |
46 | #define QDECLARATIVENETWORKINFO_P_H |
47 | |
48 | #include <qnetworkinfo.h> |
49 | |
50 | QT_BEGIN_NAMESPACE |
51 | |
52 | class QDeclarativeNetworkInfo : public QObject |
53 | { |
54 | Q_OBJECT |
55 | |
56 | Q_ENUMS(CellDataTechnology) |
57 | Q_ENUMS(NetworkMode) |
58 | Q_ENUMS(NetworkStatus) |
59 | |
60 | Q_PROPERTY(bool monitorNetworkSignalStrength READ monitorNetworkSignalStrength WRITE setMonitorNetworkSignalStrength NOTIFY monitorNetworkSignalStrengthChanged) |
61 | Q_PROPERTY(bool monitorNetworkStatus READ monitorNetworkStatus WRITE setMonitorNetworkStatus NOTIFY monitorNetworkStatusChanged) |
62 | Q_PROPERTY(bool monitorNetworkName READ monitorNetworkName WRITE setMonitorNetworkName NOTIFY monitorNetworkNameChanged) |
63 | Q_PROPERTY(bool monitorCurrentNetworkMode READ monitorCurrentNetworkMode WRITE setMonitorCurrentNetworkMode NOTIFY monitorCurrentNetworkModeChanged) |
64 | |
65 | Q_PROPERTY(NetworkMode currentNetworkMode READ currentNetworkMode NOTIFY currentNetworkModeChanged) |
66 | |
67 | // obsoleted |
68 | Q_PROPERTY(bool monitorNetworkInterfaceCount READ monitorNetworkInterfaceCount WRITE setMonitorNetworkInterfaceCount NOTIFY monitorNetworkInterfaceCountChanged) |
69 | Q_PROPERTY(bool monitorCurrentCellDataTechnology READ monitorCurrentCellDataTechnology WRITE setMonitorCurrentCellDataTechnology NOTIFY monitorCurrentCellDataTechnologyChanged) |
70 | Q_PROPERTY(bool monitorCellId READ monitorCellId WRITE setMonitorCellId NOTIFY monitorCellIdChanged) |
71 | Q_PROPERTY(bool monitorCurrentMobileCountryCode READ monitorCurrentMobileCountryCode WRITE setMonitorCurrentMobileCountryCode NOTIFY monitorCurrentMobileCountryCodeChanged) |
72 | Q_PROPERTY(bool monitorCurrentMobileNetworkCode READ monitorCurrentMobileNetworkCode WRITE setMonitorCurrentMobileNetworkCode NOTIFY monitorCurrentMobileNetworkCodeChanged) |
73 | Q_PROPERTY(bool monitorLocationAreaCode READ monitorLocationAreaCode WRITE setMonitorLocationAreaCode NOTIFY monitorLocationAreaCodeChanged) |
74 | |
75 | public: |
76 | enum CellDataTechnology { |
77 | UnknownDataTechnology = QNetworkInfo::UnknownDataTechnology, |
78 | GprsDataTechnology = QNetworkInfo::GprsDataTechnology, |
79 | EdgeDataTechnology = QNetworkInfo::EdgeDataTechnology, |
80 | UmtsDataTechnology = QNetworkInfo::UmtsDataTechnology, |
81 | HspaDataTechnology = QNetworkInfo::HspaDataTechnology |
82 | }; |
83 | |
84 | enum NetworkMode { |
85 | UnknownMode = QNetworkInfo::UnknownMode, |
86 | GsmMode = QNetworkInfo::GsmMode, |
87 | CdmaMode = QNetworkInfo::CdmaMode, |
88 | WcdmaMode = QNetworkInfo::WcdmaMode, |
89 | WlanMode = QNetworkInfo::WlanMode, |
90 | EthernetMode = QNetworkInfo::EthernetMode, |
91 | BluetoothMode = QNetworkInfo::BluetoothMode, |
92 | WimaxMode = QNetworkInfo::WimaxMode, |
93 | LteMode = QNetworkInfo::LteMode, |
94 | TdscdmaMode = QNetworkInfo::TdscdmaMode |
95 | }; |
96 | |
97 | enum NetworkStatus { |
98 | UnknownStatus = QNetworkInfo::UnknownStatus, |
99 | NoNetworkAvailable = QNetworkInfo::NoNetworkAvailable, |
100 | EmergencyOnly = QNetworkInfo::EmergencyOnly, |
101 | Searching = QNetworkInfo::Searching, |
102 | Busy = QNetworkInfo::Busy, |
103 | Denied = QNetworkInfo::Denied, |
104 | HomeNetwork = QNetworkInfo::HomeNetwork, |
105 | Roaming = QNetworkInfo::Roaming |
106 | }; |
107 | |
108 | QDeclarativeNetworkInfo(QObject *parent = 0); |
109 | virtual ~QDeclarativeNetworkInfo(); |
110 | |
111 | bool monitorCurrentNetworkMode() const; |
112 | void setMonitorCurrentNetworkMode(bool monitor); |
113 | NetworkMode currentNetworkMode() const; |
114 | |
115 | bool monitorNetworkSignalStrength() const; |
116 | void setMonitorNetworkSignalStrength(bool monitor); |
117 | Q_INVOKABLE int networkSignalStrength(NetworkMode mode, int interface) const; |
118 | |
119 | bool monitorNetworkInterfaceCount() const; |
120 | void setMonitorNetworkInterfaceCount(bool monitor); |
121 | Q_INVOKABLE int networkInterfaceCount(NetworkMode mode) const; |
122 | |
123 | bool monitorCurrentCellDataTechnology() const; |
124 | void setMonitorCurrentCellDataTechnology(bool monitor); |
125 | Q_INVOKABLE int currentCellDataTechnology(int interface) const; |
126 | |
127 | bool monitorNetworkStatus() const; |
128 | void setMonitorNetworkStatus(bool monitor); |
129 | Q_INVOKABLE int networkStatus(NetworkMode mode, int interface) const; |
130 | |
131 | bool monitorCellId() const; |
132 | void setMonitorCellId(bool monitor); |
133 | Q_INVOKABLE QString cellId(int interface) const; |
134 | |
135 | bool monitorCurrentMobileCountryCode() const; |
136 | void setMonitorCurrentMobileCountryCode(bool monitor); |
137 | Q_INVOKABLE QString currentMobileCountryCode(int interface) const; |
138 | |
139 | bool monitorCurrentMobileNetworkCode() const; |
140 | void setMonitorCurrentMobileNetworkCode(bool monitor); |
141 | Q_INVOKABLE QString currentMobileNetworkCode(int interface) const; |
142 | |
143 | bool monitorLocationAreaCode() const; |
144 | void setMonitorLocationAreaCode(bool monitor); |
145 | Q_INVOKABLE QString locationAreaCode(int interface) const; |
146 | |
147 | bool monitorNetworkName() const; |
148 | void setMonitorNetworkName(bool monitor); |
149 | Q_INVOKABLE QString networkName(NetworkMode mode, int interface) const; |
150 | |
151 | Q_INVOKABLE QString homeMobileCountryCode(int interface) const; |
152 | Q_INVOKABLE QString homeMobileNetworkCode(int interface) const; |
153 | Q_INVOKABLE QString imsi(int interface) const; |
154 | Q_INVOKABLE QString macAddress(NetworkMode mode, int interface) const; |
155 | |
156 | Q_SIGNALS: |
157 | void monitorCurrentCellDataTechnologyChanged(); |
158 | void monitorCurrentNetworkModeChanged(); |
159 | void monitorNetworkSignalStrengthChanged(); |
160 | void monitorNetworkInterfaceCountChanged(); |
161 | void monitorNetworkStatusChanged(); |
162 | void monitorCellIdChanged(); |
163 | void monitorCurrentMobileCountryCodeChanged(); |
164 | void monitorCurrentMobileNetworkCodeChanged(); |
165 | void monitorLocationAreaCodeChanged(); |
166 | void monitorNetworkNameChanged(); |
167 | |
168 | void cellIdChanged(int interfaceIndex, const QString &id); |
169 | void currentCellDataTechnologyChanged(int interfaceIndex, int tech); |
170 | void currentMobileCountryCodeChanged(int interfaceIndex, const QString &mcc); |
171 | void currentMobileNetworkCodeChanged(int interfaceIndex, const QString &mnc); |
172 | void currentNetworkModeChanged(); |
173 | void locationAreaCodeChanged(int interfaceIndex, const QString &lac); |
174 | void networkInterfaceCountChanged(int mode, int count); |
175 | void networkNameChanged(int mode, int interfaceIndex, const QString &name); |
176 | void networkSignalStrengthChanged(int mode, int interfaceIndex, int strength); |
177 | void networkStatusChanged(int mode, int interfaceIndex, int status); |
178 | |
179 | private Q_SLOTS: |
180 | void _q_currentCellDataTechnologyChanged(int interface, QNetworkInfo::CellDataTechnology tech); |
181 | void _q_networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count); |
182 | void _q_networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interface, int strength); |
183 | void _q_networkStatusChanged(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status); |
184 | void _q_networkNameChanged(QNetworkInfo::NetworkMode mode, int interface, const QString &name); |
185 | |
186 | private: |
187 | QNetworkInfo *networkInfo; |
188 | |
189 | bool isMonitorCurrentNetworkMode; |
190 | bool isMonitorNetworkSignalStrength; |
191 | bool isMonitorNetworkInterfaceCount; |
192 | bool isMonitorCurrentCellDataTechnology; |
193 | bool isMonitorNetworkStatus; |
194 | bool isMonitorCellId; |
195 | bool isMonitorCurrentMobileCountryCode; |
196 | bool isMonitorCurrentMobileNetworkCode; |
197 | bool isMonitorLocationAreaCode; |
198 | bool isMonitorNetworkName; |
199 | }; |
200 | |
201 | QT_END_NAMESPACE |
202 | |
203 | #endif // QDECLARATIVENETWORKINFO_P_H |
204 | |