|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qsysteminfo.h" |
|
43 |
|
44 #ifdef Q_OS_LINUX |
|
45 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) |
|
46 #include "qsysteminfo_maemo_p.h" |
|
47 #else |
|
48 #include "qsysteminfo_linux_p.h" |
|
49 #endif //Q_WS_MAEMO_5 & Q_WS_MAEMO_6 |
|
50 #endif //Q_OS_LINUX |
|
51 |
|
52 #ifdef Q_OS_WIN |
|
53 #include "qsysteminfo_win_p.h" |
|
54 #endif |
|
55 #ifdef Q_OS_MAC |
|
56 #include "qsysteminfo_mac_p.h" |
|
57 #endif |
|
58 #ifdef Q_OS_SYMBIAN |
|
59 #include "qsysteminfo_s60_p.h" |
|
60 #endif |
|
61 |
|
62 #include <QStringList> |
|
63 #include <QSize> |
|
64 #include <QFile> |
|
65 #include <QTextStream> |
|
66 #include <QLocale> |
|
67 #include <QLibraryInfo> |
|
68 #include <QApplication> |
|
69 #include <QDesktopWidget> |
|
70 #include <QDebug> |
|
71 |
|
72 |
|
73 #include <locale.h> |
|
74 |
|
75 QTM_BEGIN_NAMESPACE |
|
76 |
|
77 /*! |
|
78 \class QSystemInfo |
|
79 |
|
80 \ingroup systeminfo |
|
81 |
|
82 \brief The QSystemInfo class provides access to various general information from the system. |
|
83 |
|
84 In the future, parts of the QtSystemInfo API may be moved and renamed into an existing Qt class that provides similiar functionality. |
|
85 |
|
86 \table |
|
87 \header |
|
88 \o Class |
|
89 \row |
|
90 \o QSystemInfo::currentLanguage |
|
91 \row |
|
92 \o QSystemInfo::availableLanguages |
|
93 \row |
|
94 \o QSystemInfo::currentCountryCode |
|
95 \row |
|
96 \o QSystemDisplayInfo::displayBrightness |
|
97 \row |
|
98 \o QSystemDisplayInfo::colorDepth |
|
99 \row |
|
100 \o QSystemScreenSaver::screenSaverInhibited |
|
101 \row |
|
102 \o QSystemScreenSaver::setScreenSaverInhibit |
|
103 \endtable |
|
104 |
|
105 Platform notes |
|
106 Some functionality may or may not be supported on various platforms. Depending on if there |
|
107 is a reliable way to gather such information. |
|
108 */ |
|
109 |
|
110 /*! |
|
111 \enum QSystemInfo::Version |
|
112 This enum describes the version component. |
|
113 |
|
114 \value Os Operating system version / platform ID. |
|
115 \value QtCore Qt libs version. |
|
116 \value Firmware Version of (flashable) system as a whole. |
|
117 |
|
118 */ |
|
119 /*! |
|
120 \enum QSystemInfo::Feature |
|
121 This enum describes the features of the device or computer. |
|
122 |
|
123 \value BluetoothFeature Bluetooth feature available. |
|
124 \value CameraFeature Camera feature available. |
|
125 \value FmradioFeature FM Radio feature available. |
|
126 \value IrFeature Infrared feature available. |
|
127 \value LedFeature LED's feature available. |
|
128 \value MemcardFeature Memory card feature available. |
|
129 \value UsbFeature Universal System Bus (USB) feature available. |
|
130 \value VibFeature Vibration feature available. |
|
131 \value WlanFeature Wireless Local Area Network (WLAN) feature available. |
|
132 \value SimFeature Subscriber Identity Module (SIM) available. |
|
133 \value LocationFeature Global Positioning System (GPS) and/or other location feature available. |
|
134 \value VideoOutFeature Video out feature available. |
|
135 \value HapticsFeature Haptics feature available. |
|
136 */ |
|
137 |
|
138 /*! |
|
139 \class QSystemNetworkInfo |
|
140 |
|
141 \ingroup systeminfo |
|
142 |
|
143 \brief The QSystemNetworkInfo class provides access to network information from the system. |
|
144 |
|
145 */ |
|
146 /*! |
|
147 \enum QSystemNetworkInfo::NetworkStatus |
|
148 This enum describes the status of the network connection: |
|
149 |
|
150 \value UndefinedStatus There is no network device, or error. |
|
151 \value NoNetworkAvailable There is no network available. |
|
152 \value EmergencyOnly Emergency calls only. |
|
153 \value Searching Searching for or connecting with the network. |
|
154 \value Busy Network is busy. |
|
155 \value Connected Connected to network. |
|
156 \value HomeNetwork On Home Network. |
|
157 \value Denied Network access denied. |
|
158 \value Roaming On Roaming network. |
|
159 |
|
160 */ |
|
161 /*! |
|
162 \enum QSystemNetworkInfo::NetworkMode |
|
163 This enum describes the type of network: |
|
164 |
|
165 \value UnknownMode Unknown network, or network error. |
|
166 \value GsmMode Global System for Mobile (GSM) network. |
|
167 \value CdmaMode Code division multiple access (CDMA) network. |
|
168 \value WcdmaMode Wideband Code Division Multiple Access (W-CDMA) network. |
|
169 \value WlanMode Wireless Local Area Network (WLAN) network. |
|
170 \value EthernetMode Wired Local Area network. |
|
171 \value BluetoothMode Bluetooth network. |
|
172 \value WimaxMode Wimax network. |
|
173 |
|
174 */ |
|
175 |
|
176 /*! |
|
177 \class QSystemDisplayInfo |
|
178 |
|
179 \ingroup systeminfo |
|
180 |
|
181 \brief The QSystemDisplayInfo class provides access to display information from the system. |
|
182 |
|
183 */ |
|
184 |
|
185 /*! |
|
186 \class QSystemStorageInfo |
|
187 |
|
188 \ingroup systeminfo |
|
189 |
|
190 \brief The QSystemStorageInfo class provides access to memory and disk information from the system. |
|
191 |
|
192 */ |
|
193 |
|
194 /*! |
|
195 \enum QSystemStorageInfo::DriveType |
|
196 This enum describes the type of drive or volume |
|
197 |
|
198 \value NoDrive Drive type undetermined. |
|
199 \value InternalDrive Is internal drive. |
|
200 \value RemovableDrive Is removable. |
|
201 \value RemoteDrive Is a network drive. |
|
202 \value CdromDrive Is a cd rom drive. |
|
203 */ |
|
204 |
|
205 |
|
206 /*! |
|
207 \class QSystemDeviceInfo |
|
208 |
|
209 \ingroup systeminfo |
|
210 |
|
211 \brief The QSystemDeviceInfo class provides access to device |
|
212 information from the system. |
|
213 |
|
214 */ |
|
215 /*! |
|
216 \fn void QSystemDeviceInfo::batteryLevelChanged(int level) |
|
217 |
|
218 This signal is emitted when battery level has changed. |
|
219 \a level is the new level. |
|
220 */ |
|
221 |
|
222 /*! |
|
223 \fn void QSystemDeviceInfo::batteryStatusChanged(QSystemDeviceInfo::BatteryStatus status) |
|
224 |
|
225 This signal is emitted when battery status has changed. |
|
226 \a status is the new status. |
|
227 */ |
|
228 |
|
229 /*! |
|
230 \fn void QSystemDeviceInfo::powerStateChanged(QSystemDeviceInfo::PowerState state) |
|
231 |
|
232 This signal is emitted when the power state has changed, such as when a phone gets plugged in to the wall. |
|
233 \a state is the new power state. |
|
234 */ |
|
235 |
|
236 /*! |
|
237 \fn void QSystemDeviceInfo::currentProfileChanged(QSystemDeviceInfo::Profile profile) |
|
238 |
|
239 This signal is emitted whenever the users active profile changes, specified by \a profile. |
|
240 */ |
|
241 |
|
242 |
|
243 /*! |
|
244 \enum QSystemDeviceInfo::BatteryStatus |
|
245 This enum describes the status of the main battery. |
|
246 |
|
247 \value NoBatteryLevel Battery level undetermined. |
|
248 \value BatteryCritical Battery level is critical 3% or less. |
|
249 \value BatteryVeryLow Battery level is very low, 10% or less. |
|
250 \value BatteryLow Battery level is low 40% or less. |
|
251 \value BatteryNormal Battery level is above 40%. |
|
252 |
|
253 */ |
|
254 /*! |
|
255 \enum QSystemDeviceInfo::PowerState |
|
256 This enum describes the power state: |
|
257 |
|
258 \value UnknownPower Power error. |
|
259 \value BatteryPower On battery power. |
|
260 \value WallPower On wall power. |
|
261 \value WallPowerChargingBattery On wall power and charging main battery. |
|
262 |
|
263 */ |
|
264 /*! |
|
265 \enum QSystemDeviceInfo::Profile |
|
266 This enum describes the current operating profile of the device or computer. |
|
267 |
|
268 \value UnknownProfile Profile unknown or error. |
|
269 \value SilentProfile Silent profile. |
|
270 \value NormalProfile Normal profile. |
|
271 \value LoudProfile Loud profile. |
|
272 \value VibProfile Vibrate profile. |
|
273 \value OfflineProfile Offline profile. |
|
274 \value PowersaveProfile Powersave profile. |
|
275 \value CustomProfile Custom profile. |
|
276 |
|
277 */ |
|
278 |
|
279 /*! |
|
280 \enum QSystemDeviceInfo::SimStatus |
|
281 This enum describes the status is the sim card or cards. |
|
282 |
|
283 \value SimNotAvailable SIM is not available on this device. |
|
284 \value SingleSimAvailable One SIM card is available on this. |
|
285 \value DualSimAvailable Two SIM cards are available on this device. |
|
286 \value SimLocked Device has SIM lock enabled. |
|
287 */ |
|
288 |
|
289 /*! |
|
290 \enum QSystemDeviceInfo::InputMethod |
|
291 This enum describes the device method of user input. |
|
292 |
|
293 \value Keys Device has key/buttons. |
|
294 \value Keypad Device has keypad (1,2,3, etc). |
|
295 \value Keyboard Device has qwerty keyboard. |
|
296 \value SingleTouch Device has single touch screen. |
|
297 \value MultiTouch Device has muti touch screen. |
|
298 \value Mouse Device has a mouse. |
|
299 */ |
|
300 |
|
301 /*! |
|
302 \class QSystemScreenSaver |
|
303 |
|
304 \ingroup systeminfo |
|
305 |
|
306 \brief The QSystemScreenSaver class provides access to screen saver and blanking. |
|
307 |
|
308 */ |
|
309 |
|
310 /*! |
|
311 \fn void QSystemInfo::currentLanguageChanged(const QString &lang) |
|
312 |
|
313 This signal is emitted whenever the current language changes, specified by \a lang, |
|
314 which is in 2 letter, ISO 639-1 specification form. |
|
315 */ |
|
316 |
|
317 /*! |
|
318 \fn void QSystemNetworkInfo::networkStatusChanged(QSystemNetworkInfo::NetworkMode mode, QSystemNetworkInfo::NetworkStatus status) |
|
319 |
|
320 This signal is emitted whenever the network status of \a mode changes, specified by \a status. |
|
321 */ |
|
322 |
|
323 /*! |
|
324 \fn void QSystemNetworkInfo::networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode mode,int strength) |
|
325 |
|
326 This signal is emitted whenever the network \a mode signal strength changes, specified by \a strength. |
|
327 */ |
|
328 |
|
329 /*! |
|
330 \fn void QSystemNetworkInfo::currentMobileCountryCodeChanged(const QString &mcc) |
|
331 |
|
332 This signal is emitted whenever the Mobile Country Code changes, specified by \a mcc. |
|
333 */ |
|
334 |
|
335 /*! |
|
336 \fn void QSystemNetworkInfo::currentMobileNetworkCodeChanged(const QString &mnc) |
|
337 |
|
338 This signal is emitted whenever the network Mobile Network Code changes, specified by \a mnc. |
|
339 */ |
|
340 |
|
341 /*! |
|
342 \fn void QSystemNetworkInfo::networkNameChanged(QSystemNetworkInfo::NetworkMode mode,const QString & netName) |
|
343 |
|
344 This signal is emitted whenever the network \a mode name changes, specified by \a netName. |
|
345 |
|
346 */ |
|
347 |
|
348 /*! |
|
349 \fn void QSystemNetworkInfo::networkModeChanged(QSystemNetworkInfo::NetworkMode mode) |
|
350 |
|
351 This signal is emitted whenever the network mode changes, specified by \a mode. |
|
352 */ |
|
353 |
|
354 /*! |
|
355 \fn void QSystemDeviceInfo::bluetoothStateChanged(bool on) |
|
356 |
|
357 This signal is emitted whenever bluetooth state changes, specified by \a on. |
|
358 */ |
|
359 |
|
360 Q_GLOBAL_STATIC(QSystemInfoPrivate, sysinfoPrivate) |
|
361 Q_GLOBAL_STATIC(QSystemNetworkInfoPrivate, netInfoPrivate) |
|
362 Q_GLOBAL_STATIC(QSystemDisplayInfoPrivate, displayInfoPrivate) |
|
363 Q_GLOBAL_STATIC(QSystemStorageInfoPrivate, storageInfoPrivate) |
|
364 Q_GLOBAL_STATIC(QSystemDeviceInfoPrivate, deviceInfoPrivate) |
|
365 |
|
366 /*! |
|
367 \fn QSystemInfo::QSystemInfo(QObject *parent) |
|
368 Constructs a QSystemInfo object with the given \a parent. |
|
369 */ |
|
370 |
|
371 QSystemInfo::QSystemInfo(QObject *parent) |
|
372 : QObject(parent), d(sysinfoPrivate()) |
|
373 { |
|
374 } |
|
375 |
|
376 /*! |
|
377 Destroys the QSystemInfo object |
|
378 */ |
|
379 QSystemInfo::~QSystemInfo() |
|
380 { |
|
381 } |
|
382 |
|
383 /*! |
|
384 \internal |
|
385 |
|
386 This function is called when the client connects to signals. |
|
387 |
|
388 \sa connectNotify() |
|
389 */ |
|
390 |
|
391 void QSystemInfo::connectNotify(const char *signal) |
|
392 { |
|
393 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
394 currentLanguageChanged(QString))))) { |
|
395 connect(d,SIGNAL(currentLanguageChanged(QString)), |
|
396 this,SIGNAL(currentLanguageChanged(QString))); |
|
397 } |
|
398 } |
|
399 |
|
400 /*! |
|
401 \internal |
|
402 |
|
403 This function is called when the client disconnects from the signals. |
|
404 |
|
405 \sa connectNotify() |
|
406 */ |
|
407 void QSystemInfo::disconnectNotify(const char *signal) |
|
408 { |
|
409 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
410 currentLanguageChanged(QString))))) { |
|
411 disconnect(d,SIGNAL(currentLanguageChanged(QString)), |
|
412 this,SIGNAL(currentLanguageChanged(QString))); |
|
413 } |
|
414 } |
|
415 /*! |
|
416 \property QSystemInfo::currentLanguage |
|
417 \brief The current Language |
|
418 Returns the current language in 2 letter ISO 639-1 format. |
|
419 */ |
|
420 QString QSystemInfo::currentLanguage() |
|
421 { |
|
422 return sysinfoPrivate()->currentLanguage(); |
|
423 } |
|
424 /*! |
|
425 \property QSystemInfo::availableLanguages |
|
426 \brief List of available languages. |
|
427 |
|
428 Returns a QStringList of available Qt language translations in 2 letter ISO 639-1 format. |
|
429 If the Qt translations cannot be found, returns the current system language. |
|
430 */ |
|
431 QStringList QSystemInfo::availableLanguages() |
|
432 { |
|
433 return sysinfoPrivate()->availableLanguages(); |
|
434 } |
|
435 |
|
436 /*! |
|
437 Returns the version of QSystemInfo::Version \a type, |
|
438 with optional platform dependent \a parameter as a string. |
|
439 |
|
440 Version will be returned in "major.minor.build" form. |
|
441 |
|
442 In case a particular version does not use the "build" part, it is set to 0. |
|
443 If a particular element is not available at all, an error "Not Installed" will be returned by |
|
444 the API. |
|
445 */ |
|
446 QString QSystemInfo::version(QSystemInfo::Version type, const QString ¶meter) |
|
447 { |
|
448 return sysinfoPrivate()->version(type, parameter); |
|
449 } |
|
450 |
|
451 /*! |
|
452 \property QSystemInfo::currentCountryCode |
|
453 \brief The current locale country code. |
|
454 |
|
455 Returns the 2 letter ISO 3166-1 for the current country code. |
|
456 */ |
|
457 QString QSystemInfo::currentCountryCode() |
|
458 { |
|
459 return sysinfoPrivate()->currentCountryCode(); |
|
460 } |
|
461 |
|
462 /*! |
|
463 Returns true if the QSystemInfo::Feature \a feature is supported, otherwise false. |
|
464 */ |
|
465 |
|
466 bool QSystemInfo::hasFeatureSupported(QSystemInfo::Feature feature) |
|
467 { |
|
468 return sysinfoPrivate()->hasFeatureSupported(feature); |
|
469 } |
|
470 |
|
471 /*! |
|
472 \fn QSystemNetworkInfo::QSystemNetworkInfo(QObject *parent) |
|
473 Constructs a QSystemNetworkInfo object with the given \a parent. |
|
474 */ |
|
475 |
|
476 QSystemNetworkInfo::QSystemNetworkInfo(QObject *parent) |
|
477 : QObject(parent), d(netInfoPrivate()) |
|
478 { |
|
479 } |
|
480 |
|
481 /*! |
|
482 Destroys the QSystemNetworkInfo object. |
|
483 */ |
|
484 QSystemNetworkInfo::~QSystemNetworkInfo() |
|
485 { |
|
486 } |
|
487 |
|
488 /*! |
|
489 Returns the status of the network \a mode. |
|
490 */ |
|
491 QSystemNetworkInfo::NetworkStatus QSystemNetworkInfo::networkStatus(QSystemNetworkInfo::NetworkMode mode) |
|
492 { |
|
493 return netInfoPrivate()->networkStatus(mode); |
|
494 } |
|
495 |
|
496 /*! |
|
497 Returns the strength of the network signal, per network \a mode , 0 - 100 linear scaling, |
|
498 or -1 in the case of unknown network mode or error. |
|
499 |
|
500 In the case of QSystemNetworkInfo::EthMode, it will either be 100 for carrier active, or 0 for when |
|
501 there is no carrier or cable connected. |
|
502 */ |
|
503 int QSystemNetworkInfo::networkSignalStrength(QSystemNetworkInfo::NetworkMode mode) |
|
504 { |
|
505 return netInfoPrivate()->networkSignalStrength(mode); |
|
506 } |
|
507 |
|
508 /*! |
|
509 \property QSystemNetworkInfo::cellId |
|
510 \brief The devices Cell ID |
|
511 Returns the Cell ID of the connected tower or based station, or 0 if not connected. |
|
512 */ |
|
513 int QSystemNetworkInfo::cellId() |
|
514 { |
|
515 return netInfoPrivate()->cellId(); |
|
516 } |
|
517 |
|
518 /*! |
|
519 \property QSystemNetworkInfo::locationAreaCode |
|
520 \brief The LAC. |
|
521 |
|
522 Returns the Location Area Code. In the case of a Desktop computer, 0 is returned. |
|
523 */ |
|
524 int QSystemNetworkInfo::locationAreaCode() |
|
525 { |
|
526 return netInfoPrivate()->locationAreaCode(); |
|
527 } |
|
528 |
|
529 /*! |
|
530 \property QSystemNetworkInfo::currentMobileCountryCode |
|
531 \brief The current MCC. |
|
532 |
|
533 Returns the current Mobile Country Code. In the case of a Desktop computer, an empty string is returned. |
|
534 */ |
|
535 QString QSystemNetworkInfo::currentMobileCountryCode() |
|
536 { |
|
537 return netInfoPrivate()->currentMobileCountryCode(); |
|
538 } |
|
539 |
|
540 /*! |
|
541 \property QSystemNetworkInfo::currentMobileNetworkCode |
|
542 \brief The current MNC. |
|
543 |
|
544 Returns the current Mobile Network Code. In the case of a Desktop computer, an empty string is returned. |
|
545 */ |
|
546 QString QSystemNetworkInfo::currentMobileNetworkCode() |
|
547 { |
|
548 return netInfoPrivate()->currentMobileNetworkCode(); |
|
549 } |
|
550 |
|
551 /*! |
|
552 \property QSystemNetworkInfo::homeMobileCountryCode |
|
553 \brief The home MNC. |
|
554 |
|
555 Returns the home Mobile Country Code. In the case of a Desktop computer, an empty string is returned. |
|
556 */ |
|
557 QString QSystemNetworkInfo::homeMobileCountryCode() |
|
558 { |
|
559 return netInfoPrivate()->homeMobileCountryCode(); |
|
560 } |
|
561 |
|
562 /*! |
|
563 \property QSystemNetworkInfo::homeMobileNetworkCode |
|
564 \brief The home MCC. |
|
565 |
|
566 Returns the home Mobile Network Code. In the case of a Desktop computer, an empty string is returned. |
|
567 Note: Some platforms don't support retrieving this info. In this case the Network Code is |
|
568 returned only when the device is registered on home network. |
|
569 */ |
|
570 QString QSystemNetworkInfo::homeMobileNetworkCode() |
|
571 { |
|
572 return netInfoPrivate()->homeMobileNetworkCode(); |
|
573 } |
|
574 |
|
575 /*! |
|
576 Returns the name of the operator for the network \a mode. For wlan this returns the network's current SSID. |
|
577 In the case of no network such as a desktop, an empty string. |
|
578 */ |
|
579 QString QSystemNetworkInfo::networkName(QSystemNetworkInfo::NetworkMode mode) |
|
580 { |
|
581 return netInfoPrivate()->networkName(mode); |
|
582 } |
|
583 |
|
584 /*! |
|
585 Returns the MAC address for the interface servicing the network \a mode. |
|
586 */ |
|
587 QString QSystemNetworkInfo::macAddress(QSystemNetworkInfo::NetworkMode mode) |
|
588 { |
|
589 return netInfoPrivate()->macAddress(mode); |
|
590 } |
|
591 |
|
592 /*! |
|
593 Returns the first found QNetworkInterface for type \a mode, or an invalid QNetworkInterface, if none is found. |
|
594 */ |
|
595 QNetworkInterface QSystemNetworkInfo::interfaceForMode(QSystemNetworkInfo::NetworkMode mode) |
|
596 { |
|
597 return netInfoPrivate()->interfaceForMode(mode); |
|
598 } |
|
599 /*! |
|
600 Returns the current active mode. If more than one mode is active, returns the |
|
601 default or preferred mode. If no modes are active, returns UnknownMode. |
|
602 */ |
|
603 QSystemNetworkInfo::NetworkMode QSystemNetworkInfo::currentMode() |
|
604 { |
|
605 return netInfoPrivate()->currentMode(); |
|
606 } |
|
607 |
|
608 /*! |
|
609 \internal |
|
610 |
|
611 This function is called when the client connects to the networkSignalStrengthChanged() |
|
612 signal. |
|
613 */ |
|
614 void QSystemNetworkInfo::connectNotify(const char *signal) |
|
615 { |
|
616 //check for networkSignalStrengthChanged() signal connect notification |
|
617 //This is not required on all platforms |
|
618 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) |
|
619 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
620 networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode, int))))) { |
|
621 netInfoPrivate()->setWlanSignalStrengthCheckEnabled(true); |
|
622 } |
|
623 #endif |
|
624 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
625 currentMobileCountryCodeChanged(QString))))) { |
|
626 connect(d,SIGNAL(currentMobileCountryCodeChanged(QString)), |
|
627 this,SIGNAL(currentMobileCountryCodeChanged(QString))); |
|
628 } |
|
629 |
|
630 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
631 currentMobileNetworkCodeChanged(QString))))) { |
|
632 connect(d,SIGNAL(currentMobileNetworkCodeChanged(QString)), |
|
633 this,SIGNAL(currentMobileNetworkCodeChanged(QString))); |
|
634 } |
|
635 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
636 networkModeChanged(QSystemNetworkInfo::NetworkMode))))) { |
|
637 connect(d,SIGNAL(networkModeChanged(QSystemNetworkInfo::NetworkMode)), |
|
638 this,SIGNAL(networkModeChanged(QSystemNetworkInfo::NetworkMode))); |
|
639 } |
|
640 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
641 networkNameChanged(QSystemNetworkInfo::NetworkMode,QString))))) { |
|
642 connect(d,SIGNAL(networkNameChanged(QSystemNetworkInfo::NetworkMode,QString)), |
|
643 this,SIGNAL(networkNameChanged(QSystemNetworkInfo::NetworkMode,QString))); |
|
644 } |
|
645 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
646 networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode,int))))) { |
|
647 connect(d,SIGNAL(networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode,int)), |
|
648 this,SIGNAL(networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode,int))); |
|
649 } |
|
650 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
651 networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus))))) { |
|
652 connect(d,SIGNAL(networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus)), |
|
653 this,SIGNAL(networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus))); |
|
654 } |
|
655 } |
|
656 |
|
657 /*! |
|
658 \internal |
|
659 |
|
660 This function is called when the client disconnects from the networkSignalStrengthChanged() |
|
661 signal. |
|
662 |
|
663 \sa connectNotify() |
|
664 */ |
|
665 void QSystemNetworkInfo::disconnectNotify(const char *signal) |
|
666 { |
|
667 //check for networkSignalStrengthChanged() signal disconnect notification |
|
668 //This is not required on all platforms |
|
669 #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) |
|
670 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
671 networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode, int))))) { |
|
672 netInfoPrivate()->setWlanSignalStrengthCheckEnabled(false); |
|
673 } |
|
674 #endif |
|
675 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
676 currentMobileCountryCodeChanged(QString))))) { |
|
677 disconnect(d,SIGNAL(currentMobileCountryCodeChanged(QString)), |
|
678 this,SIGNAL(currentMobileCountryCodeChanged(QString))); |
|
679 } |
|
680 |
|
681 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
682 currentMobileNetworkCodeChanged(QString))))) { |
|
683 disconnect(d,SIGNAL(currentMobileNetworkCodeChanged(QString)), |
|
684 this,SIGNAL(currentMobileNetworkCodeChanged(QString))); |
|
685 } |
|
686 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
687 networkModeChanged(QSystemNetworkInfo::NetworkMode))))) { |
|
688 disconnect(d,SIGNAL(networkModeChanged(QSystemNetworkInfo::NetworkMode)), |
|
689 this,SIGNAL(networkModeChanged(QSystemNetworkInfo::NetworkMode))); |
|
690 } |
|
691 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
692 networkNameChanged(QSystemNetworkInfo::NetworkMode,QString))))) { |
|
693 disconnect(d,SIGNAL(networkNameChanged(QSystemNetworkInfo::NetworkMode,QString)), |
|
694 this,SIGNAL(networkNameChanged(QSystemNetworkInfo::NetworkMode,QString))); |
|
695 } |
|
696 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
697 networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode,int))))) { |
|
698 disconnect(d,SIGNAL(networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode,int)), |
|
699 this,SIGNAL(networkSignalStrengthChanged(QSystemNetworkInfo::NetworkMode,int))); |
|
700 } |
|
701 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
702 networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus))))) { |
|
703 disconnect(d,SIGNAL(networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus)), |
|
704 this,SIGNAL(networkStatusChanged(QSystemNetworkInfo::NetworkMode,QSystemNetworkInfo::NetworkStatus))); |
|
705 } |
|
706 } |
|
707 |
|
708 // display |
|
709 /*! |
|
710 \fn QSystemDisplayInfo::QSystemDisplayInfo(QObject *parent) |
|
711 Constructs a QSystemDisplayInfo object with the given \a parent. |
|
712 */ |
|
713 |
|
714 QSystemDisplayInfo::QSystemDisplayInfo(QObject *parent) |
|
715 : QObject(parent) |
|
716 { |
|
717 } |
|
718 |
|
719 /*! |
|
720 Destroys the QSystemDisplayInfo object. |
|
721 */ |
|
722 QSystemDisplayInfo::~QSystemDisplayInfo() |
|
723 { |
|
724 } |
|
725 |
|
726 /*! |
|
727 Returns the display brightness of the screen with index \a screenNumber in %, 1 - 100 scale. |
|
728 |
|
729 Depending on platform, displayBrightness may not be available due to |
|
730 differing hardware, software or driver implementation. In which case this |
|
731 will return 0. |
|
732 |
|
733 \sa QDesktopWidget::screenCount() |
|
734 */ |
|
735 int QSystemDisplayInfo::displayBrightness(int screenNumber) |
|
736 { |
|
737 return displayInfoPrivate()->displayBrightness(screenNumber); |
|
738 } |
|
739 |
|
740 /*! |
|
741 Returns the color depth of the screen with the index \a screenNumber, in bits per pixel, or 0 if the screen is not found. |
|
742 |
|
743 \sa QDesktopWidget::screenCount() |
|
744 */ |
|
745 int QSystemDisplayInfo::colorDepth(int screenNumber) |
|
746 { |
|
747 return displayInfoPrivate()->colorDepth(screenNumber); |
|
748 } |
|
749 |
|
750 /*! |
|
751 \fn QSystemStorageInfo::QSystemStorageInfo(QObject *parent) |
|
752 Constructs a QSystemStorageInfo object with the given \a parent. |
|
753 */ |
|
754 |
|
755 QSystemStorageInfo::QSystemStorageInfo(QObject *parent) |
|
756 : QObject(parent) |
|
757 { |
|
758 } |
|
759 |
|
760 /*! |
|
761 Destroys the QSystemStorageInfo object. |
|
762 */ |
|
763 QSystemStorageInfo::~QSystemStorageInfo() |
|
764 { |
|
765 } |
|
766 |
|
767 /*! |
|
768 Returns the amount of total space on the \a volumeDrive, |
|
769 in bytes. |
|
770 */ |
|
771 qlonglong QSystemStorageInfo::totalDiskSpace(const QString &volumeDrive) |
|
772 { |
|
773 return storageInfoPrivate()->totalDiskSpace(volumeDrive); |
|
774 } |
|
775 |
|
776 /*! |
|
777 Returns the amount of available free space on the \a volumeDrive, |
|
778 in bytes. |
|
779 */ |
|
780 qlonglong QSystemStorageInfo::availableDiskSpace(const QString &volumeDrive) |
|
781 { |
|
782 return storageInfoPrivate()->availableDiskSpace(volumeDrive); |
|
783 } |
|
784 |
|
785 /*! |
|
786 \property QSystemStorageInfo::logicalDrives |
|
787 \brief The logical drives. |
|
788 |
|
789 Returns a QStringList of volumes or partitions, or an empty list if no drives are found. |
|
790 */ |
|
791 QStringList QSystemStorageInfo::logicalDrives() |
|
792 { |
|
793 return storageInfoPrivate()->logicalDrives(); |
|
794 } |
|
795 |
|
796 /*! |
|
797 Returns the type of volume \a driveVolume |
|
798 */ |
|
799 QSystemStorageInfo::DriveType QSystemStorageInfo::typeForDrive(const QString &driveVolume) |
|
800 { |
|
801 return storageInfoPrivate()->typeForDrive(driveVolume); |
|
802 } |
|
803 |
|
804 // device |
|
805 /*! |
|
806 \fn QSystemDeviceInfo::QSystemDeviceInfo(QObject *parent) |
|
807 Constructs a QSystemDeviceInfo with the given \a parent. |
|
808 */ |
|
809 |
|
810 QSystemDeviceInfo::QSystemDeviceInfo(QObject *parent) |
|
811 : QObject(parent), d(deviceInfoPrivate()) |
|
812 { |
|
813 |
|
814 } |
|
815 |
|
816 /*! |
|
817 Destroys the QSystemDeviceInfo object. |
|
818 */ |
|
819 QSystemDeviceInfo::~QSystemDeviceInfo() |
|
820 { |
|
821 } |
|
822 |
|
823 /*! |
|
824 \internal |
|
825 |
|
826 This function is called when the client connects to signals. |
|
827 |
|
828 \sa connectNotify() |
|
829 */ |
|
830 |
|
831 void QSystemDeviceInfo::connectNotify(const char *signal) |
|
832 { |
|
833 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
834 batteryLevelChanged(int))))) { |
|
835 connect(d,SIGNAL(batteryLevelChanged(int)), |
|
836 this,SIGNAL(batteryLevelChanged(int))); |
|
837 } |
|
838 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
839 batteryStatusChanged(QSystemDeviceInfo::BatteryStatus))))) { |
|
840 connect(d,SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)), |
|
841 this,SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus))); |
|
842 } |
|
843 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
844 bluetoothStateChanged(bool))))) { |
|
845 connect(d,SIGNAL(bluetoothStateChanged(bool)), |
|
846 this,SIGNAL(bluetoothStateChanged(bool))); |
|
847 } |
|
848 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
849 currentProfileChanged(QSystemDeviceInfo::Profile))))) { |
|
850 connect(d,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)), |
|
851 this,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile))); |
|
852 } |
|
853 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
854 powerStateChanged(QSystemDeviceInfo::PowerState))))) { |
|
855 connect(d,SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)), |
|
856 this,SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState))); |
|
857 } |
|
858 } |
|
859 |
|
860 /*! |
|
861 \internal |
|
862 |
|
863 This function is called when the client disconnects from the signals. |
|
864 |
|
865 \sa connectNotify() |
|
866 */ |
|
867 void QSystemDeviceInfo::disconnectNotify(const char *signal) |
|
868 { |
|
869 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
870 batteryLevelChanged(int))))) { |
|
871 disconnect(d,SIGNAL(batteryLevelChanged(int)), |
|
872 this,SIGNAL(batteryLevelChanged(int))); |
|
873 } |
|
874 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
875 batteryStatusChanged(QSystemDeviceInfo::BatteryStatus))))) { |
|
876 disconnect(d,SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus)), |
|
877 this,SIGNAL(batteryStatusChanged(QSystemDeviceInfo::BatteryStatus))); |
|
878 } |
|
879 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
880 bluetoothStateChanged(bool))))) { |
|
881 disconnect(d,SIGNAL(bluetoothStateChanged(bool)), |
|
882 this,SIGNAL(bluetoothStateChanged(bool))); |
|
883 } |
|
884 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
885 currentProfileChanged(QSystemDeviceInfo::Profile))))) { |
|
886 disconnect(d,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)), |
|
887 this,SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile))); |
|
888 } |
|
889 if (QLatin1String(signal) == QLatin1String(QMetaObject::normalizedSignature(SIGNAL( |
|
890 powerStateChanged(QSystemDeviceInfo::PowerState))))) { |
|
891 disconnect(d,SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState)), |
|
892 this,SIGNAL(powerStateChanged(QSystemDeviceInfo::PowerState))); |
|
893 } |
|
894 } |
|
895 |
|
896 /*! |
|
897 \property QSystemDeviceInfo::inputMethodType |
|
898 \brief The supported inputmethods. |
|
899 |
|
900 Returns the QSystemDeviceInfo::InputMethodFlags InputMethodType that the system uses. |
|
901 */ |
|
902 QSystemDeviceInfo::InputMethodFlags QSystemDeviceInfo::inputMethodType() |
|
903 { |
|
904 return deviceInfoPrivate()->inputMethodType(); |
|
905 } |
|
906 |
|
907 /*! |
|
908 \property QSystemDeviceInfo::imei |
|
909 \brief The IMEI. |
|
910 |
|
911 Returns the International Mobile Equipment Identity (IMEI), or a null QString in the case of none. |
|
912 */ |
|
913 QString QSystemDeviceInfo::imei() |
|
914 { |
|
915 return deviceInfoPrivate()->imei(); |
|
916 } |
|
917 |
|
918 /*! |
|
919 \property QSystemDeviceInfo::imsi |
|
920 \brief The IMSI. |
|
921 |
|
922 Returns the International Mobile Subscriber Identity (IMSI), or a null QString in the case of none. |
|
923 */ |
|
924 QString QSystemDeviceInfo::imsi() |
|
925 { |
|
926 return deviceInfoPrivate()->imsi(); |
|
927 } |
|
928 |
|
929 /*! |
|
930 \property QSystemDeviceInfo::manufacturer |
|
931 \brief The manufacture's name. |
|
932 |
|
933 Returns the name of the manufacturer of this device. In the case of desktops, the name of the vendor |
|
934 of the motherboard. |
|
935 */ |
|
936 QString QSystemDeviceInfo::manufacturer() |
|
937 { |
|
938 return deviceInfoPrivate()->manufacturer(); |
|
939 } |
|
940 |
|
941 /*! |
|
942 \property QSystemDeviceInfo::model |
|
943 \brief The model name. |
|
944 |
|
945 Returns the model information of the device. In the case of desktops where no |
|
946 model information is present, the CPU architect, such as i686, and machine type, such as Server, |
|
947 Desktop or Laptop. |
|
948 */ |
|
949 QString QSystemDeviceInfo::model() |
|
950 { |
|
951 return deviceInfoPrivate()->model(); |
|
952 } |
|
953 |
|
954 /*! |
|
955 \property QSystemDeviceInfo::productName |
|
956 \brief The product name. |
|
957 |
|
958 Returns the product name of the device. In the case where no product information is available, an empty string will be returned. |
|
959 |
|
960 */ |
|
961 QString QSystemDeviceInfo::productName() |
|
962 { |
|
963 return deviceInfoPrivate()->productName(); |
|
964 } |
|
965 /*! |
|
966 \property QSystemDeviceInfo::batteryLevel |
|
967 \brief The battery level. |
|
968 |
|
969 Returns the battery charge level as percentage 1 - 100 scale. |
|
970 */ |
|
971 int QSystemDeviceInfo::batteryLevel() const |
|
972 { |
|
973 return deviceInfoPrivate()->batteryLevel(); |
|
974 } |
|
975 |
|
976 /*! |
|
977 \property QSystemDeviceInfo::batteryStatus |
|
978 \brief The battery status. |
|
979 |
|
980 Returns the battery charge status. |
|
981 */ |
|
982 QSystemDeviceInfo::BatteryStatus QSystemDeviceInfo::batteryStatus() |
|
983 { |
|
984 int level = batteryLevel(); |
|
985 if(level < 4) { |
|
986 return QSystemDeviceInfo::BatteryCritical; |
|
987 } else if(level < 11) { |
|
988 return QSystemDeviceInfo::BatteryVeryLow; |
|
989 } else if(level < 41) { |
|
990 return QSystemDeviceInfo::BatteryLow; |
|
991 } else if(level > 40) { |
|
992 return QSystemDeviceInfo::BatteryNormal; |
|
993 } |
|
994 |
|
995 return QSystemDeviceInfo::NoBatteryLevel; |
|
996 } |
|
997 |
|
998 /*! |
|
999 \property QSystemDeviceInfo::simStatus |
|
1000 \brief the status of the sim card. |
|
1001 Returns the QSystemDeviceInfo::simStatus status of SIM card. |
|
1002 */ |
|
1003 QSystemDeviceInfo::SimStatus QSystemDeviceInfo::simStatus() |
|
1004 { |
|
1005 return deviceInfoPrivate()->simStatus(); |
|
1006 } |
|
1007 /*! |
|
1008 \property QSystemDeviceInfo::isDeviceLocked |
|
1009 \brief Device lock. |
|
1010 |
|
1011 Returns true if the device is locked, otherwise false. |
|
1012 */ |
|
1013 bool QSystemDeviceInfo::isDeviceLocked() |
|
1014 { |
|
1015 return deviceInfoPrivate()->isDeviceLocked(); |
|
1016 } |
|
1017 |
|
1018 /*! |
|
1019 \property QSystemDeviceInfo::currentProfile |
|
1020 \brief the device profile |
|
1021 Gets the current QSystemDeviceInfo::currentProfile device profile. |
|
1022 */ |
|
1023 QSystemDeviceInfo::Profile QSystemDeviceInfo::currentProfile() |
|
1024 { |
|
1025 return deviceInfoPrivate()->currentProfile(); |
|
1026 } |
|
1027 |
|
1028 /*! |
|
1029 \property QSystemDeviceInfo::currentPowerState |
|
1030 \brief the power state. |
|
1031 |
|
1032 Gets the current QSystemDeviceInfo::currentPowerState state. |
|
1033 */ |
|
1034 QSystemDeviceInfo::PowerState QSystemDeviceInfo::currentPowerState() |
|
1035 { |
|
1036 return deviceInfoPrivate()->currentPowerState(); |
|
1037 } |
|
1038 |
|
1039 |
|
1040 ///// |
|
1041 /*! |
|
1042 Constructs a QSystemScreenSaver object with the given \a parent. |
|
1043 |
|
1044 On platforms where there is no default screensaver mechanism, such as Linux, this class |
|
1045 may not be available. |
|
1046 */ |
|
1047 |
|
1048 QSystemScreenSaver::QSystemScreenSaver(QObject *parent) |
|
1049 : QObject(parent) |
|
1050 { |
|
1051 #ifdef Q_OS_LINUX |
|
1052 d = new QSystemScreenSaverPrivate(static_cast<QSystemScreenSaverLinuxCommonPrivate*>(parent)); |
|
1053 #else |
|
1054 d = new QSystemScreenSaverPrivate(parent); |
|
1055 #endif |
|
1056 screenSaverIsInhibited = screenSaverInhibited(); |
|
1057 } |
|
1058 |
|
1059 /*! |
|
1060 Destroys the QSystemScreenSaver object. |
|
1061 */ |
|
1062 QSystemScreenSaver::~QSystemScreenSaver() |
|
1063 { |
|
1064 delete d; |
|
1065 } |
|
1066 |
|
1067 /*! |
|
1068 Temporarily inhibits the screensaver. |
|
1069 |
|
1070 The screensaver will be set to a non inhibited state only when this QSystemScreenSaver object gets destroyed. |
|
1071 |
|
1072 This is a non blocking function that will return true if the inhibit procedure was successful, otherwise false. |
|
1073 |
|
1074 On platforms that support it, if screensaver is secure by policy, the policy will be honored |
|
1075 and this will fail. |
|
1076 */ |
|
1077 bool QSystemScreenSaver::setScreenSaverInhibit() |
|
1078 { |
|
1079 return d->setScreenSaverInhibit(); |
|
1080 } |
|
1081 |
|
1082 /*! |
|
1083 \property QSystemScreenSaver::screenSaverInhibited |
|
1084 \brief Screensaver inhibited. |
|
1085 |
|
1086 Returns true if the screensaver is inhibited, otherwise false. |
|
1087 */ |
|
1088 bool QSystemScreenSaver::screenSaverInhibited() |
|
1089 { |
|
1090 return d->screenSaverInhibited(); |
|
1091 } |
|
1092 |
|
1093 |
|
1094 #include "moc_qsysteminfo.cpp" |
|
1095 |
|
1096 QTM_END_NAMESPACE |