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 QDEVICEINFO_H
43 #define QDEVICEINFO_H
44 
45 #include "qsysteminfoglobal.h"
46 #include <QtCore/qobject.h>
47 
48 QT_BEGIN_NAMESPACE
49 
50 #if !defined(QT_SIMULATOR)
51 class QDeviceInfoPrivate;
52 #else
53 class QDeviceInfoSimulator;
54 #endif // QT_SIMULATOR
55 
56 class Q_SYSTEMINFO_EXPORT QDeviceInfo : public QObject
57 {
58     Q_OBJECT
59 
60     Q_ENUMS(Feature)
61     Q_ENUMS(LockType)
62     Q_ENUMS(ThermalState)
63     Q_ENUMS(Version)
64 
65     Q_FLAGS(LockType LockTypeFlags)
66 
67     Q_PROPERTY(LockTypeFlags activatedLocks READ activatedLocks NOTIFY activatedLocksChanged)
68     Q_PROPERTY(LockTypeFlags enabledLocks READ enabledLocks NOTIFY enabledLocksChanged)
69     Q_PROPERTY(ThermalState thermalState READ thermalState NOTIFY thermalStateChanged)
70     Q_PROPERTY(bool currentBluetoothPowerState READ currentBluetoothPowerState NOTIFY bluetoothStateChanged)
71 
72 public:
73     enum Feature {
74         BluetoothFeature = 0,
75         CameraFeature,
76         FmRadioFeature,
77         FmTransmitterFeature,
78         InfraredFeature,
79         LedFeature,
80         MemoryCardFeature,
81         UsbFeature,
82         VibrationFeature,
83         WlanFeature,
84         SimFeature,
85         PositioningFeature,
86         VideoOutFeature,
87         HapticsFeature,
88         NfcFeature
89     };
90 
91     enum LockType {
92         NoLock = 0,
93         PinLock = 0x0000001,
94         TouchOrKeyboardLock = 0x0000002,
95         UnknownLock = 0x0000004
96     };
97     Q_DECLARE_FLAGS(LockTypeFlags, LockType)
98 
99     enum ThermalState {
100         UnknownThermal = 0,
101         NormalThermal,
102         WarningThermal,
103         AlertThermal,
104         ErrorThermal
105     };
106 
107     enum Version {
108         Os = 0,
109         Firmware
110     };
111 
112     QDeviceInfo(QObject *parent = nullptr);
113     ~QDeviceInfo() override;
114 
115     QDeviceInfo::LockTypeFlags activatedLocks() const;
116     QDeviceInfo::LockTypeFlags enabledLocks() const;
117     QDeviceInfo::ThermalState thermalState() const;
118 
119     Q_INVOKABLE bool hasFeature(QDeviceInfo::Feature feature) const;
120     Q_INVOKABLE int imeiCount() const;
121     Q_INVOKABLE QString imei(int interfaceNumber) const;
122     Q_INVOKABLE QString manufacturer() const;
123     Q_INVOKABLE QString model() const;
124     Q_INVOKABLE QString productName() const;
125     Q_INVOKABLE QString uniqueDeviceID() const;
126     Q_INVOKABLE QString version(QDeviceInfo::Version type) const;
127     Q_INVOKABLE QString operatingSystemName() const;
128     Q_INVOKABLE QString boardName() const;
129 
130     bool currentBluetoothPowerState();
131 
132 Q_SIGNALS:
133     void activatedLocksChanged(QDeviceInfo::LockTypeFlags types);
134     void enabledLocksChanged(QDeviceInfo::LockTypeFlags types);
135     void thermalStateChanged(QDeviceInfo::ThermalState state);
136     void bluetoothStateChanged(bool on);
137 
138 protected:
139     void connectNotify(const QMetaMethod &signal) override;
140     void disconnectNotify(const QMetaMethod &signal) override;
141 
142 private:
143     Q_DISABLE_COPY(QDeviceInfo)
144 #if !defined(QT_SIMULATOR)
145     QDeviceInfoPrivate * const d_ptr;
146     Q_DECLARE_PRIVATE(QDeviceInfo)
147 #else
148     QDeviceInfoSimulator * const d_ptr;
149 #endif // QT_SIMULATOR
150 };
151 
152 QT_END_NAMESPACE
153 
154 #endif // QDEVICEINFO_H
155