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) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtSystems module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qdeviceinfo.h"
#if defined(QT_SIMULATOR)
# include "simulator/qsysteminfo_simulator_p.h"
#elif defined(Q_OS_LINUX)
# include "linux/qdeviceinfo_linux_p.h"
#elif defined(Q_OS_WIN)
# include "windows/qdeviceinfo_win_p.h"
#elif defined(Q_OS_MAC)
# include "mac/qdeviceinfo_mac_p.h"
#else
QT_BEGIN_NAMESPACE
class QDeviceInfoPrivate
{
public:
QDeviceInfoPrivate(QDeviceInfo *) {}
bool hasFeature(QDeviceInfo::Feature) { return false; }
int imeiCount() { return -1; }
QDeviceInfo::LockTypeFlags activatedLocks() { return QDeviceInfo::NoLock; }
QDeviceInfo::LockTypeFlags enabledLocks() { return QDeviceInfo::NoLock; }
QDeviceInfo::ThermalState thermalState() { return QDeviceInfo::UnknownThermal; }
QString imei(int) { return QString(); }
QString manufacturer() { return QString(); }
QString model() { return QString(); }
QString productName() { return QString(); }
QString uniqueDeviceID() { return QString(); }
QString version(QDeviceInfo::Version) { return QString(); }
QString operatingSystemName() { return QString(); }
bool currentBluetoothPowerState() { return false; }
QString boardName() { return QString(); }
};
QT_END_NAMESPACE
#endif
#include <QtCore/qmetaobject.h>
QT_BEGIN_NAMESPACE
/*!
\class QDeviceInfo
\inmodule QtSystemInfo
\brief The QDeviceInfo class provides various information of the system.
\ingroup systeminfo
*/
/*!
\enum QDeviceInfo::Feature
This enum describes the features of the device.
\value BluetoothFeature Bluetooth feature.
\value CameraFeature Camera feature.
\value FmRadioFeature Frequency modulation (FM) radio feature.
\value FmTransmitterFeature Frequency modulation (FM) radio transmitter feature.
\value InfraredFeature Infrared communication feature.
\value LedFeature Light-emitting diode (LED) feature.
\value MemoryCardFeature Memory card feature.
\value UsbFeature Universal system bus (USB) feature.
\value VibrationFeature Vibration feature.
\value WlanFeature Wireless local area network (WLAN) feature.
\value SimFeature Subscriber identity module (SIM) feature.
\value PositioningFeature Positioning feature, e.g. Global Positioning System (GPS).
\value VideoOutFeature Video out feature.
\value HapticsFeature Haptics feature, the platform can provide audio and/or visual and/or vibration feedback.
\value NfcFeature Near Field Communication (NFC) feature.
*/
/*!
\enum QDeviceInfo::LockType
This enum describes lock type on the device.
\value NoLock No lock.
\value PinLock Device can be locked by PIN code or password.
\value TouchOrKeyboardLock Device can be locked by touch or keyboard.
\value UnknownLock lock types requested but no result received yet.
*/
/*!
\enum QDeviceInfo::ThermalState
This enum describes the thermal state:
\value UnknownThermal The thermal state is unknown.
\value NormalThermal The thermal state is normal.
\value WarningThermal The thermal state is warning.
\value AlertThermal The thermal state is alert.
\value ErrorThermal The thermal state is error.
*/
/*!
\enum QDeviceInfo::Version
This enum describes the version component.
\value Os Operating system version. For Linux, it returns the version of the
distribution if any.
\value Firmware Version of (flashable) system as a whole. For Linux, it's the version
of the kernel.
*/
/*!
\fn void QDeviceInfo::activatedLocksChanged(QDeviceInfo::LockTypeFlags types)
This signal is emitted when the activated locks have changed to \a types.
*/
/*!
\fn void QDeviceInfo::enabledLocksChanged(QDeviceInfo::LockTypeFlags types)
This signal is emitted when the enabled locks have changed to \a types.
*/
/*!
\fn void QDeviceInfo::thermalStateChanged(QDeviceInfo::ThermalState state)
This signal is emitted when the thermal state has changed to \a state.
*/
/*!
Constructs a QDeviceInfo object with the given \a parent.
*/
QDeviceInfo::QDeviceInfo(QObject *parent)
: QObject(parent)
#if !defined(QT_SIMULATOR)
, d_ptr(new QDeviceInfoPrivate(this))
#else
, d_ptr(new QDeviceInfoSimulator(this))
#endif // QT_SIMULATOR
{
}
/*!
Destroys the object
*/
QDeviceInfo::~QDeviceInfo()
{
#if !defined(Q_OS_LINUX)
delete d_ptr;
#endif
}
/*!
\property QDeviceInfo::activatedLocks
\brief The activated lock types.
The current activated lock types of the device. It suggests that these lock types are also
enabled.
*/
QDeviceInfo::LockTypeFlags QDeviceInfo::activatedLocks() const
{
return d_ptr->activatedLocks();
}
/*!
\property QDeviceInfo::enabledLocks
\brief The enabled lock types.
The current lock types that are enabled on the device. Note that it doesn't mean the device is
currently locked.
*/
QDeviceInfo::LockTypeFlags QDeviceInfo::enabledLocks() const
{
return d_ptr->enabledLocks();
}
/*!
\property QDeviceInfo::thermalState
\brief The thermal state.
The current thermal state of the device. If there are more than one thermal zone devices available,
the state of the most critical one is reported.
*/
QDeviceInfo::ThermalState QDeviceInfo::thermalState() const
{
return d_ptr->thermalState();
}
/*!
Returns true if the \a feature is supported, otherwise false.
*/
bool QDeviceInfo::hasFeature(QDeviceInfo::Feature feature) const
{
return d_ptr->hasFeature(feature);
}
/*!
Returns the count of available International Mobile Equipment Identity (IMEI) of the device. In
case of error, or the information is not available, -1 is returned.
*/
int QDeviceInfo::imeiCount() const
{
return d_ptr->imeiCount();
}
/*!
Returns the International Mobile Equipment Identity (IMEI) of the given \a interfaceNumber on the device.
In case of error, or the information is not available, an empty string is returned.
*/
QString QDeviceInfo::imei(int interfaceNumber) const
{
return d_ptr->imei(interfaceNumber);
}
/*!
Returns the name of the manufacturer of this device, or the name of the vendor of the motherboard
as a fallback. In case of error, or the information is not available, an empty string is returned.
*/
QString QDeviceInfo::manufacturer() const
{
return d_ptr->manufacturer();
}
/*!
Returns the model information of the device, e.g. N8, or the CPU architect as a fallback. In case
of error, or the information is not available, an empty string is returned.
*/
QString QDeviceInfo::model() const
{
return d_ptr->model();
}
/*!
Returns the internal product name of the device, e.g. RM-774. In case of error, or the information
is not available, an empty string is returned.
For Linux, it returns the codename of the distribution if any.
*/
QString QDeviceInfo::productName() const
{
return d_ptr->productName();
}
/*!
Returns a unique identifier for the device, or an empty string if on error or not available.
*/
QString QDeviceInfo::uniqueDeviceID() const
{
return d_ptr->uniqueDeviceID();
}
/*!
Returns the version of \a type. In case of error, or the version is unknown, an empty string
is returned.
*/
QString QDeviceInfo::version(QDeviceInfo::Version type) const
{
return d_ptr->version(type);
}
/*!
Returns the current bluetooth power state.
*/
bool QDeviceInfo::currentBluetoothPowerState()
{
return d_ptr->currentBluetoothPowerState();
}
/*!
Returns the name for the operating system for the device, or an empty string if an error or not available.
*/
QString QDeviceInfo::operatingSystemName() const
{
return d_ptr->operatingSystemName();
}
/*!
Returns the board name for the device, or an empty string if an error or not available.
*/
QString QDeviceInfo::boardName() const
{
return d_ptr->boardName();
}
extern QMetaMethod proxyToSourceSignal(const QMetaMethod &, QObject *);
/*!
\internal
*/
void QDeviceInfo::connectNotify(const QMetaMethod &signalSig)
{
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) || defined(QT_SIMULATOR) || defined(Q_OS_MAC)
QMetaMethod sourceSignal = proxyToSourceSignal(signalSig, reinterpret_cast<QObject *>(d_ptr));
connect(reinterpret_cast<QObject *>(d_ptr), sourceSignal, this, signalSig, Qt::UniqueConnection);
#else
Q_UNUSED(signalSig)
#endif
}
/*!
\internal
*/
void QDeviceInfo::disconnectNotify(const QMetaMethod &signalSig)
{
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) || defined(QT_SIMULATOR) || defined(Q_OS_MAC)
// We can only disconnect with the private implementation, when there is no receivers for the signal.
if (isSignalConnected(signalSig))
return;
QMetaMethod sourceSignal = proxyToSourceSignal(signalSig, reinterpret_cast<QObject *>(d_ptr));
disconnect(reinterpret_cast<QObject *>(d_ptr), sourceSignal, this, signalSig);
#else
Q_UNUSED(signalSig)
#endif
}
QT_END_NAMESPACE
|