Debian Codegraph @

src/imports/SystemInfo/lomirideviceinfo.cpp

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2018 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: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 The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://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 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39
40 #include "lomirideviceinfo_p.h"
41
42 QT_BEGIN_NAMESPACE
43
44 /*!
45 \qmltype DeviceInfo
46 \instantiates LomiriDeclarativeDeviceInfo
47 \inqmlmodule QtSystemInfo
48 \ingroup qml-systeminfo
49 \brief The DeviceInfo element provides various information about the device.
50 */
51
52 /*!
53 \internal
54 */
55 LomiriDeclarativeDeviceInfo::LomiriDeclarativeDeviceInfo(QObject *parent)
56 : QObject(parent)
57 , deviceInfo(new LomiriDeviceInfo(this))
58 , isMonitorThermalState(false)
59 {
60 }
61
62 /*!
63 \internal
64 */
65 LomiriDeclarativeDeviceInfo::~LomiriDeclarativeDeviceInfo()
66 {
67 }
68
69 /*!
70 \qmlproperty flag DeviceInfo::activatedLocks
71
72 This property holds the activated locks. Available locks include:
73 \list
74 \li DeviceInfo.NoLock - No lock.
75 \li DeviceInfo.PinLock - Device can be locked by PIN code or password.
76 \li DeviceInfo.TouchOrKeyboardLock - Device can be locked by touch or keyboard.
77 \li DeviceInfo.UnknownLock - Lock types requested but no result received yet.
78 \endlist
79 */
80 LomiriDeclarativeDeviceInfo::LockTypeFlags LomiriDeclarativeDeviceInfo::activatedLocks() const
81 {
82 connect(deviceInfo, SIGNAL(activatedLocksChanged(LomiriDeviceInfo::LockTypeFlags)),
83 this, SIGNAL(activatedLocksChanged()), Qt::UniqueConnection);
84
85 LomiriDeviceInfo::LockTypeFlags locks(deviceInfo->activatedLocks());
86 if (locks.testFlag(LomiriDeviceInfo::UnknownLock))
87 return LomiriDeclarativeDeviceInfo::UnknownLock;
88 LockTypeFlags declarativeLocks(NoLock);
89 if (locks.testFlag(LomiriDeviceInfo::PinLock))
90 declarativeLocks |= PinLock;
91 if (locks.testFlag(LomiriDeviceInfo::TouchOrKeyboardLock))
92 declarativeLocks |= TouchOrKeyboardLock;
93 return declarativeLocks;
94 }
95
96 /*!
97 \qmlproperty flag DeviceInfo::enabledLocks
98
99 This property holds the enabled locks. Available locks include:
100 \list
101 \li DeviceInfo.NoLock - No lock.
102 \li DeviceInfo.PinLock - Device can be locked by PIN code or password.
103 \li DeviceInfo.TouchOrKeyboardLock - Device can be locked by touch or keyboard.
104 \li DeviceInfo.UnknownLock - Lock types requested but no result received yet.
105 \endlist
106 */
107 LomiriDeclarativeDeviceInfo::LockTypeFlags LomiriDeclarativeDeviceInfo::enabledLocks() const
108 {
109 connect(deviceInfo, SIGNAL(enabledLocksChanged(LomiriDeviceInfo::LockTypeFlags)),
110 this, SIGNAL(enabledLocksChanged()), Qt::UniqueConnection);
111
112 LomiriDeviceInfo::LockTypeFlags locks(deviceInfo->enabledLocks());
113 if (locks.testFlag(LomiriDeviceInfo::UnknownLock))
114 return LomiriDeclarativeDeviceInfo::UnknownLock;
115 LockTypeFlags declarativeLocks(NoLock);
116 if (locks.testFlag(LomiriDeviceInfo::PinLock))
117 declarativeLocks |= PinLock;
118 if (locks.testFlag(LomiriDeviceInfo::TouchOrKeyboardLock))
119 declarativeLocks |= TouchOrKeyboardLock;
120 return declarativeLocks;
121 }
122
123 /*!
124 \qmlproperty bool DeviceInfo::monitorThermalState
125
126 This property holds whether or not monitor the change of thermal state.
127 */
128 bool LomiriDeclarativeDeviceInfo::monitorThermalState() const
129 {
130 return isMonitorThermalState;
131 }
132
133 void LomiriDeclarativeDeviceInfo::setMonitorThermalState(bool monitor)
134 {
135 if (monitor != isMonitorThermalState) {
136 isMonitorThermalState = monitor;
137 if (monitor) {
138 connect(deviceInfo, SIGNAL(thermalStateChanged(LomiriDeviceInfo::ThermalState)),
139 this, SIGNAL(thermalStateChanged()));
140 } else {
141 disconnect(deviceInfo, SIGNAL(thermalStateChanged(LomiriDeviceInfo::ThermalState)),
142 this, SIGNAL(thermalStateChanged()));
143 }
144 Q_EMIT monitorThermalStateChanged();
145 }
146 }
147
148 /*!
149 \qmlproperty enumeration DeviceInfo::thermalState
150
151 This property holds the thermal state. Possible values are:
152 \list
153 \li DeviceInfo.UnknownThermal - The thermal state is unknown.
154 \li DeviceInfo.NormalThermal - The thermal state is normal.
155 \li DeviceInfo.WarningThermal - The thermal state is warning.
156 \li DeviceInfo.AlertThermal - The thermal state is alert.
157 \li DeviceInfo.ErrorThermal - The thermal state is error.
158 \endlist
159 */
160 LomiriDeclarativeDeviceInfo::ThermalState LomiriDeclarativeDeviceInfo::thermalState() const
161 {
162 return static_cast<ThermalState>(deviceInfo->thermalState());
163 }
164
165 /*!
166 \qmlmethod bool DeviceInfo::hasFeature(Feature feature)
167
168 Returns true if the \a feature is supported, otherwise false. The following features can be
169 queried:
170 \list
171 \li DeviceInfo.BluetoothFeature - Bluetooth feature.
172 \li DeviceInfo.CameraFeature - Camera feature.
173 \li DeviceInfo.FmRadioFeature - Frequency modulation (FM) radio feature.
174 \li DeviceInfo.FmTransmitterFeature - Frequency modulation (FM) radio transmitter feature.
175 \li DeviceInfo.InfraredFeature - Infrared communication feature.
176 \li DeviceInfo.LedFeature - Light-emitting diode (LED) feature.
177 \li DeviceInfo.MemoryCardFeature - Memory card feature.
178 \li DeviceInfo.UsbFeature - Universal system bus (USB) feature.
179 \li DeviceInfo.VibrationFeature - Vibration feature.
180 \li DeviceInfo.WlanFeature - Wireless local area network (WLAN) feature.
181 \li DeviceInfo.SimFeature - Subscriber identity module (SIM) feature.
182 \li DeviceInfo.PositioningFeature - Positioning feature, e.g. Global Positioning System (GPS).
183 \li DeviceInfo.VideoOutFeature - Video out feature.
184 \li DeviceInfo.HapticsFeature - Haptics feature, the platform can provide audio and/or visual and/or vibration feedback.
185 \li DeviceInfo.NfcFeature - Near Field Communication (NFC) feature
186 \endlist
187 */
188 bool LomiriDeclarativeDeviceInfo::hasFeature(LomiriDeclarativeDeviceInfo::Feature feature) const
189 {
190 return deviceInfo->hasFeature(static_cast<LomiriDeviceInfo::Feature>(feature));
191 }
192
193 /*!
194 \qmlmethod int DeviceInfo::imeiCount()
195
196 Returns the count of available International Mobile Equipment Identity (IMEI) of the device. In
197 case of error, or the information is not available, -1 is returned.
198 */
199 int LomiriDeclarativeDeviceInfo::imeiCount() const
200 {
201 return deviceInfo->imeiCount();
202 }
203
204 /*!
205 \qmlmethod string DeviceInfo::imei(int interface)
206
207 Returns the International Mobile Equipment Identity (IMEI) of the given \a interface on the device.
208 In case of error, or the information is not available, an empty string is returned.
209 */
210 QString LomiriDeclarativeDeviceInfo::imei(int interface) const
211 {
212 return deviceInfo->imei(interface);
213 }
214
215 /*!
216 \qmlmethod string DeviceInfo::manufacturer()
217
218 Returns the name of the manufacturer of this device, or the name of the vendor of the motherboard
219 as a fallback. In case of error, or the information is not available, an empty string is returned.
220 */
221 QString LomiriDeclarativeDeviceInfo::manufacturer() const
222 {
223 return deviceInfo->manufacturer();
224 }
225
226 /*!
227 \qmlmethod string DeviceInfo::model()
228
229 Returns the model information of the device, e.g. N8, or the CPU architect as a fallback. In case
230 of error, or the information is not available, an empty string is returned.
231 */
232 QString LomiriDeclarativeDeviceInfo::model() const
233 {
234 return deviceInfo->model();
235 }
236
237 /*!
238 \qmlmethod string DeviceInfo::productName()
239
240 Returns the internal product name of the device, e.g. RM-774. In case of error, or the information
241 is not available, an empty string is returned.
242
243 For Linux, it returns the codename of the distribution if any.
244 */
245 QString LomiriDeclarativeDeviceInfo::productName() const
246 {
247 return deviceInfo->productName();
248 }
249
250 /*!
251 \qmlmethod string DeviceInfo::uniqueDeviceID()
252
253 Returns a unique identifier for the device, or an empty string if on error or not available.
254 */
255 QString LomiriDeclarativeDeviceInfo::uniqueDeviceID() const
256 {
257 return deviceInfo->uniqueDeviceID();
258 }
259
260 /*!
261 \qmlmethod string DeviceInfo::version(Version type)
262
263 Returns the version of \a type. In case of error, or the version is unknown, an empty string
264 is returned. The following versions can be queried:
265 \list
266 \li DeviceInfo.Os - Operating system version. For Linux, it returns the version of the
267 distribution if any.
268 \li DeviceInfo.Firmware - Version of (flashable) system as a whole. For Linux, it's the version
269 of the kernel.
270 \endlist
271 */
272 QString LomiriDeclarativeDeviceInfo::version(LomiriDeclarativeDeviceInfo::Version type) const
273 {
274 return deviceInfo->version(static_cast<LomiriDeviceInfo::Version>(type));
275 }
276
277 QT_END_NAMESPACE