summaryrefslogtreecommitdiffstats
path: root/src/systeminfo/linux/qsysteminfo_linux_common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/systeminfo/linux/qsysteminfo_linux_common.cpp')
-rw-r--r--src/systeminfo/linux/qsysteminfo_linux_common.cpp738
1 files changed, 370 insertions, 368 deletions
diff --git a/src/systeminfo/linux/qsysteminfo_linux_common.cpp b/src/systeminfo/linux/qsysteminfo_linux_common.cpp
index c09a32ac66..5301582e4a 100644
--- a/src/systeminfo/linux/qsysteminfo_linux_common.cpp
+++ b/src/systeminfo/linux/qsysteminfo_linux_common.cpp
@@ -48,7 +48,6 @@
#include <QCryptographicHash>
#include <QVariantMap>
#include <QProcess>
-
#if !defined(QT_NO_DBUS)
#include "qhalservice_linux_p.h"
#include <QtDBus/QtDBus>
@@ -62,6 +61,7 @@
#include <QtDBus/QDBusPendingCall>
#endif
+#include <QApplication>
#include <QDesktopWidget>
#include <locale.h>
@@ -175,42 +175,56 @@ static struct fb_var_screeninfo* allocFrameBufferInfo(int screen)
QTM_BEGIN_NAMESPACE
-QSystemInfoLinuxCommonPrivate::QSystemInfoLinuxCommonPrivate(QObject *parent) : QObject(parent)
+QSystemInfoLinuxCommonPrivate::QSystemInfoLinuxCommonPrivate(QObject *parent)
+ : QObject(parent)
+ , langTimer(0)
{
- halIsAvailable = halAvailable();
- langCached = currentLanguage();
}
QSystemInfoLinuxCommonPrivate::~QSystemInfoLinuxCommonPrivate()
{
}
-void QSystemInfoLinuxCommonPrivate::startLanguagePolling()
+void QSystemInfoLinuxCommonPrivate::connectNotify(const char *signal)
{
- QString checkLang = QString::fromLocal8Bit(qgetenv("LANG"));
- if (langCached.isEmpty()) {
- currentLanguage();
+ if (QLatin1String(signal) == SIGNAL(currentLanguageChanged(QString))) {
+ if (!langTimer) {
+ currentLang = currentLanguage();
+ langTimer = new QTimer(this);
+ connect(langTimer, SIGNAL(timeout()), this, SLOT(pollCurrentLanguage()));
+ langTimer->start(5000);
+ }
}
- checkLang = checkLang.left(2);
- if (checkLang != langCached) {
- emit currentLanguageChanged(checkLang);
- langCached = checkLang;
+}
+
+void QSystemInfoLinuxCommonPrivate::disconnectNotify(const char *signal)
+{
+ if (QLatin1String(signal) == SIGNAL(currentLanguageChanged(QString))) {
+ currentLang.clear();
+ langTimer->stop();
}
- langTimer = new QTimer(this);
- QTimer::singleShot(5000, this, SLOT(startLanguagePolling()));
+}
+
+void QSystemInfoLinuxCommonPrivate::pollCurrentLanguage()
+{
+ QString oldLang = currentLang;
+ currentLang = currentLanguage();
+ if (oldLang != currentLang)
+ Q_EMIT currentLanguageChanged(currentLang);
}
QString QSystemInfoLinuxCommonPrivate::currentLanguage() const
{
QString lang;
- if (langCached.isEmpty()) {
- lang = QLocale::system().name().left(2);
- if (lang.isEmpty() || lang == QLatin1String("C")) {
+
+ if (currentLang.isEmpty()) {
+ lang = QLocale::system().name().left(2);
+ if (lang.isEmpty() || lang == QLatin1String("C"))
lang = QLatin1String("en");
- }
} else {
- lang = langCached;
+ lang = currentLang;
}
+
return lang;
}
@@ -228,323 +242,304 @@ bool QSystemInfoLinuxCommonPrivate::fmTransmitterAvailable()
memset(&capability, 0, sizeof(struct v4l2_capability));
if (-1 != (fd = open(device, O_RDWR)) && (-1 != ioctl(fd, VIDIOC_QUERYCAP, &capability))) {
- if ((capability.capabilities & (V4L2_CAP_RADIO | V4L2_CAP_MODULATOR)) ==
- (V4L2_CAP_RADIO | V4L2_CAP_MODULATOR)) {
+ if ((capability.capabilities & (V4L2_CAP_RADIO | V4L2_CAP_MODULATOR))
+ == (V4L2_CAP_RADIO | V4L2_CAP_MODULATOR)) {
available = true;
}
}
if (fd != -1) {
- close(fd), fd = -1;
+ close(fd);
+ fd = -1;
}
}
-#endif
+#endif // __LINUX_VIDEODEV2_H
return available;
}
bool QSystemInfoLinuxCommonPrivate::hasFeatureSupported(QSystemInfo::Feature feature)
{
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- QUdevService udevService;
+ QUdevService udevService;
#endif
- bool featureSupported = false;
- switch (feature) {
- case QSystemInfo::BluetoothFeature :
- {
+
+ bool featureSupported = false;
+ switch (feature) {
+ case QSystemInfo::BluetoothFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_BLUETOOTH);
-#endif
- const QString sysPath = "/sys/class/bluetooth/";
- const QDir sysDir(sysPath);
- QStringList filters;
- filters << "*";
- const QStringList sysList = sysDir.entryList( filters ,QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
- foreach (const QString &dir, sysList) {
- const QFileInfo btFile(sysPath + dir+"/address");
- if (btFile.exists()) {
- return true;
- }
- }
- }
- break;
- case QSystemInfo::CameraFeature :
- {
+ return udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_BLUETOOTH);
+#endif
+ const QString sysPath("/sys/class/bluetooth/");
+ const QDir sysDir(sysPath);
+ QStringList filters;
+ filters << "*";
+ const QStringList sysList = sysDir.entryList(filters, QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
+ foreach (const QString &dir, sysList) {
+ const QFileInfo btFile(sysPath + dir + "/address");
+ if (btFile.exists())
+ return true;
+ }
+ break;
+ }
+
+ case QSystemInfo::CameraFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isPropertyAvailable(UDEV_PROPERTY_V4L_CAP, "*:capture:*");
+ return udevService.isPropertyAvailable(UDEV_PROPERTY_V4L_CAP, "*:capture:*");
#endif
#if !defined(QT_NO_DBUS)
- featureSupported = hasHalUsbFeature(0x06); // image
- if (featureSupported)
- return featureSupported;
- #endif
- featureSupported = hasSysFeature("video");
- }
- break;
- case QSystemInfo::FmradioFeature :
- {
+ featureSupported = hasHalUsbFeature(0x06); // image
+ if (featureSupported)
+ return featureSupported;
+ #endif // QT_NO_DBUS
+ featureSupported = hasSysFeature("video");
+ break;
+ }
+
+ case QSystemInfo::FmradioFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isPropertyAvailable(UDEV_PROPERTY_V4L_CAP, "*:radio:*");
-#endif
- const QString sysPath = "/sys/class/video4linux/";
- const QDir sysDir(sysPath);
- QStringList filters;
- filters << "*";
- QStringList sysList = sysDir.entryList( filters ,QDir::Dirs, QDir::Name);
- foreach (const QString &dir, sysList) {
- if (dir.contains("radio")) {
- featureSupported = true;
- }
- }
- }
- break;
- case QSystemInfo::IrFeature :
- {
+ return udevService.isPropertyAvailable(UDEV_PROPERTY_V4L_CAP, "*:radio:*");
+#endif
+ const QString sysPath("/sys/class/video4linux/");
+ const QDir sysDir(sysPath);
+ QStringList filters;
+ filters << "*";
+ QStringList sysList = sysDir.entryList(filters, QDir::Dirs, QDir::Name);
+ foreach (const QString &dir, sysList) {
+ if (dir.contains("radio"))
+ featureSupported = true;
+ }
+ break;
+ }
+
+ case QSystemInfo::IrFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, "*irda*");
+ return udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, "*irda*");
#endif
- #if !defined(QT_NO_DBUS)
- featureSupported = hasHalUsbFeature(0xFE);
- if (featureSupported)
- return featureSupported;
- #endif
- featureSupported = hasSysFeature("irda"); //?
- }
- break;
- case QSystemInfo::LedFeature :
- {
+#if !defined(QT_NO_DBUS)
+ featureSupported = hasHalUsbFeature(0xFE);
+ if (featureSupported)
+ return featureSupported;
+#endif
+ featureSupported = hasSysFeature("irda"); //?
+ break;
+ }
+
+ case QSystemInfo::LedFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_LEDS);
+ return udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_LEDS);
#endif
- featureSupported = hasSysFeature("led"); //?
- }
- break;
- case QSystemInfo::MemcardFeature :
- {
+ featureSupported = hasSysFeature("led"); //?
+ break;
+ }
+
+ case QSystemInfo::MemcardFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- bool ok = udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_MEMCARD);
- if (!ok) {
+ bool ok = udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_MEMCARD);
+ if (!ok) {
#if !defined(QT_NO_DBUS)
#if !defined(QT_NO_UDISKS)
- // try harder
- //this only works when a drive is in
- if (udisksAvailable()) {
- QUDisksInterface udisksIface;
- foreach (const QDBusObjectPath &device,udisksIface.enumerateDevices() ) {
- QUDisksDeviceInterface devIface(device.path());
- if (devIface.deviceIsDrive()) {
- if (devIface.driveMedia().contains("flash")) {
- return true;
- }
- // just guess
- if (devIface.driveCanDetach() &&
- devIface.deviceIsRemovable()
- && !devIface.driveIsMediaEjectable()) {
- return true;
- }
- }
- }
- }
-#endif
+ // try harder
+ //this only works when a drive is in
+ if (udisksAvailable()) {
+ QUDisksInterface udisksIface;
+ foreach (const QDBusObjectPath &device, udisksIface.enumerateDevices() ) {
+ QUDisksDeviceInterface devIface(device.path());
+ if (devIface.deviceIsDrive()) {
+ if (devIface.driveMedia().contains("flash"))
+ return true;
+
+ // just guess
+ if (devIface.driveCanDetach() && devIface.deviceIsRemovable() && !devIface.driveIsMediaEjectable())
+ return true;
+ }
+ }
+ }
+#endif // QT_NO_UDISKS
+#endif // QT_NO_DBUS
+ }
+ return ok;
#endif
- }
- return ok;
+#if !defined(QT_NO_DBUS)
+ QHalInterface iface;
+ if (iface.isValid()) {
+ QHalInterface halIface;
+ const QStringList halDevices = halIface.findDeviceByCapability("mmc_host");
+ foreach (const QString &device, halDevices) {
+ QHalDeviceInterface ifaceDevice(device);
+ if (ifaceDevice.isValid()) {
+ if (ifaceDevice.getPropertyString("info.subsystem") == "mmc_host")
+ return true;
+ if (ifaceDevice.getPropertyBool("storage.removable"))
+ return true;
+ }
+ }
+ }
#endif
- #if !defined(QT_NO_DBUS)
- QHalInterface iface;
- if (iface.isValid()) {
- QHalInterface halIface;
- const QStringList halDevices = halIface.findDeviceByCapability("mmc_host");
- foreach (const QString &device, halDevices) {
- QHalDeviceInterface ifaceDevice(device);
- if (ifaceDevice.isValid()) {
- if (ifaceDevice.getPropertyString("info.subsystem") == "mmc_host") {
- return true;
- }
- if (ifaceDevice.getPropertyBool("storage.removable")) {
- return true;
- }
- }
- }
- }
- #endif
- }
- break;
- case QSystemInfo::UsbFeature :
- {
+ break;
+ }
+
+ case QSystemInfo::UsbFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- if (udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, UDEV_DRIVER_MUSB))
- return true;
- if(udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, UDEV_DRIVER_USB))
- return true;
- if(udevService.isPropertyAvailable(UDEV_PROPERTY_INTERFACE, "usb*"))
- return true;
+ if (udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, UDEV_DRIVER_MUSB))
+ return true;
+ if(udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, UDEV_DRIVER_USB))
+ return true;
+ if(udevService.isPropertyAvailable(UDEV_PROPERTY_INTERFACE, "usb*"))
+ return true;
#endif
- #if !defined(QT_NO_DBUS)
- featureSupported = hasHalDeviceFeature("usb");
- if (featureSupported)
- return featureSupported;
- #endif
- featureSupported = hasSysFeature("usb_host");
- }
- break;
- case QSystemInfo::VibFeature :
+#if !defined(QT_NO_DBUS)
+ featureSupported = hasHalDeviceFeature("usb");
+ if (featureSupported)
+ return featureSupported;
+#endif // QT_NO_DBUS
+ featureSupported = hasSysFeature("usb_host");
+ break;
+ }
+
+ case QSystemInfo::VibFeature:
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- if (udevService.isPropertyAvailable(UDEV_PROPERTY_NAME, "*vibra*"))
+ if (udevService.isPropertyAvailable(UDEV_PROPERTY_NAME, "*vibra*"))
+ return true;
+ if(udevService.isPropertyAvailable(UDEV_PROPERTY_NAME, "*Vibra*"))
return true;
- if(udevService.isPropertyAvailable(UDEV_PROPERTY_NAME, "*Vibra*"))
- return true;
-#endif
- #if !defined(QT_NO_DBUS)
- if (hasHalDeviceFeature("vibrator") || hasHalDeviceFeature("vib")) {
- return true;
- }
#endif
- break;
- case QSystemInfo::WlanFeature :
- {
+#if !defined(QT_NO_DBUS)
+ if (hasHalDeviceFeature("vibrator") || hasHalDeviceFeature("vib"))
+ return true;
+#endif // QT_NO_DBUS
+ break;
+
+ case QSystemInfo::WlanFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_WLAN);
+ return udevService.isSubsystemAvailable(UDEV_SUBSYSTEM_WLAN);
#endif
- #if !defined(QT_NO_DBUS)
- QHalInterface iface;
- if (iface.isValid()) {
- const QStringList list = iface.findDeviceByCapability("net.80211");
- if (!list.isEmpty()) {
- featureSupported = true;
- break;
- }
- }
- #endif
- featureSupported = hasSysFeature("80211");
- }
- break;
- case QSystemInfo::SimFeature :
- {
-#if !defined(QT_NO_CONNMAN)
- if (ofonoAvailable()) {
- QOfonoManagerInterface ofonoManager(this);
- QString modempath = ofonoManager.currentModem().path();
- if (!modempath.isEmpty()) {
- QOfonoSimInterface simInterface(modempath,this);
- return simInterface.isValid();
- }
- }
+#if !defined(QT_NO_DBUS)
+ QHalInterface iface;
+ if (iface.isValid()) {
+ const QStringList list = iface.findDeviceByCapability("net.80211");
+ if (!list.isEmpty()) {
+ featureSupported = true;
+ break;
+ }
+ }
#endif
+ featureSupported = hasSysFeature("80211");
+ break;
+ }
- }
- break;
- case QSystemInfo::LocationFeature :
+ case QSystemInfo::SimFeature: {
+#if !defined(QT_NO_CONNMAN)
+ if (ofonoAvailable()) {
+ QOfonoManagerInterface ofonoManager(this);
+ QString modempath = ofonoManager.currentModem().path();
+ if (!modempath.isEmpty()) {
+ QOfonoSimInterface simInterface(modempath, this);
+ return simInterface.isValid();
+ }
+ }
+#endif // QT_NO_CONNMAN
+ break;
+ }
+
+ case QSystemInfo::LocationFeature:
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, "*gps*");
+ return udevService.isPropertyAvailable(UDEV_PROPERTY_DRIVER, "*gps*");
#endif
- #if !defined(QT_NO_DBUS)
- featureSupported = hasHalDeviceFeature("gps"); //might not always be true
- if (featureSupported)
- return featureSupported;
+#if !defined(QT_NO_DBUS)
+ featureSupported = hasHalDeviceFeature("gps"); //might not always be true
+ if (featureSupported)
+ return featureSupported;
- #endif
- break;
- case QSystemInfo::VideoOutFeature :
- {
+#endif // QT_NO_DBUS
+ break;
+
+ case QSystemInfo::VideoOutFeature: {
#if !defined(Q_WS_MAEMO_6) && !defined(Q_WS_MAEMO_5) && defined(UDEV_SUPPORTED)
- return udevService.isPropertyAvailable(UDEV_PROPERTY_V4L_CAP, "*:video_output:*");
-#endif
- const QString sysPath = "/sys/class/video4linux/";
- const QDir sysDir(sysPath);
- QStringList filters;
- filters << "*";
- const QStringList sysList = sysDir.entryList( filters ,QDir::Dirs, QDir::Name);
- if (sysList.contains("video")) {
- featureSupported = true;
- }
- }
- break;
- case QSystemInfo::HapticsFeature:
-
- break;
- case QSystemInfo::FmTransmitterFeature:
- featureSupported = fmTransmitterAvailable();
- break;
- default:
- featureSupported = false;
- break;
- };
- return featureSupported;
- }
+ return udevService.isPropertyAvailable(UDEV_PROPERTY_V4L_CAP, "*:video_output:*");
+#endif
+ const QString sysPath("/sys/class/video4linux/");
+ const QDir sysDir(sysPath);
+ QStringList filters;
+ filters << "*";
+ const QStringList sysList = sysDir.entryList(filters, QDir::Dirs, QDir::Name);
+ if (sysList.contains("video"))
+ featureSupported = true;
+ break;
+ }
- #if !defined(QT_NO_DBUS)
- bool QSystemInfoLinuxCommonPrivate::hasHalDeviceFeature(const QString &param)
- {
- QHalInterface halIface;
- const QStringList halDevices = halIface.getAllDevices();
- foreach (const QString &device, halDevices) {
- if (device.contains(param)) {
- return true;
- }
- }
- return false;
- }
+ case QSystemInfo::HapticsFeature:
+ break;
- bool QSystemInfoLinuxCommonPrivate::hasHalUsbFeature(qint32 usbClass)
- {
- QHalInterface halIface;
- const QStringList halDevices = halIface.findDeviceByCapability("usb_device");
- foreach (const QString &device, halDevices) {
- QHalDeviceInterface ifaceDevice(device);
- if (ifaceDevice.isValid()) {
- if (ifaceDevice.getPropertyString("info.subsystem") == "usb_device") {
- if (ifaceDevice.getPropertyInt("usb.interface.class") == usbClass) {
- return true;
- }
- }
- }
- }
- return false;
+ case QSystemInfo::FmTransmitterFeature:
+ featureSupported = fmTransmitterAvailable();
+ break;
+
+ default:
+ featureSupported = false;
+ break;
+ };
+
+ return featureSupported;
}
- #endif
- QString QSystemInfoLinuxCommonPrivate::version(QSystemInfo::Version type,
- const QString &parameter)
- {
- QString errorStr = QLatin1String("Not Available");
+#if !defined(QT_NO_DBUS)
+bool QSystemInfoLinuxCommonPrivate::hasHalDeviceFeature(const QString &param)
+{
+ QHalInterface halIface;
+ const QStringList halDevices = halIface.getAllDevices();
+ foreach (const QString &device, halDevices) {
+ if (device.contains(param))
+ return true;
+ }
+ return false;
+}
- bool useDate = false;
- if (parameter == QLatin1String("versionDate")) {
- useDate = true;
- }
+bool QSystemInfoLinuxCommonPrivate::hasHalUsbFeature(qint32 usbClass)
+{
+ QHalInterface halIface;
+ const QStringList halDevices = halIface.findDeviceByCapability("usb_device");
+ foreach (const QString &device, halDevices) {
+ QHalDeviceInterface ifaceDevice(device);
+ if (ifaceDevice.isValid()) {
+ if (ifaceDevice.getPropertyString("info.subsystem") == "usb_device") {
+ if (ifaceDevice.getPropertyInt("usb.interface.class") == usbClass)
+ return true;
+ }
+ }
+ }
+ return false;
+}
+#endif // QT_NO_DBUS
- switch(type) {
- case QSystemInfo::Firmware :
- {
+QString QSystemInfoLinuxCommonPrivate::version(QSystemInfo::Version type, const QString &parameter)
+{
+ switch(type) {
+ case QSystemInfo::Firmware: {
#if !defined(QT_NO_DBUS)
- QHalDeviceInterface iface(QLatin1String("/org/freedesktop/Hal/devices/computer"));
- QString str;
- if (iface.isValid()) {
- str = iface.getPropertyString(QLatin1String("system.kernel.version"));
- if (!str.isEmpty()) {
- return str;
- }
- if (useDate) {
- str = iface.getPropertyString(QLatin1String("system.firmware.release_date"));
- if (!str.isEmpty()) {
- return str;
- }
- } else {
- str = iface.getPropertyString(QLatin1String("system.firmware.version"));
- if (str.isEmpty()) {
- if (!str.isEmpty()) {
- return str;
- }
- }
- }
- }
- break;
+ QHalDeviceInterface iface(QLatin1String("/org/freedesktop/Hal/devices/computer"));
+ QString str;
+ if (iface.isValid()) {
+ str = iface.getPropertyString(QLatin1String("system.kernel.version"));
+ if (!str.isEmpty())
+ return str;
+ if (parameter == "versionDate") {
+ str = iface.getPropertyString(QLatin1String("system.firmware.release_date"));
+ if (!str.isEmpty())
+ return str;
+ } else {
+ str = iface.getPropertyString(QLatin1String("system.firmware.version"));
+ if (str.isEmpty()) {
+ if (!str.isEmpty())
+ return str;
+ }
+ }
+ }
+ break;
#endif
- }
- case QSystemInfo::Os :
- {
+ }
- if(QFileInfo("/usr/bin/lsb_release").exists()) {
+ case QSystemInfo::Os: {
+ if (QFile::exists("/usr/bin/lsb_release")) {
QProcess syscall;
QString program = "/usr/bin/lsb_release";
QStringList arguments;
@@ -556,8 +551,8 @@ bool QSystemInfoLinuxCommonPrivate::hasFeatureSupported(QSystemInfo::Feature fea
return desc.simplified();
}
- QFile versionFile2(QLatin1String("/etc/issue"));
- if(!versionFile2.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QFile versionFile2("/etc/issue");
+ if (!versionFile2.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "File not opened";
} else {
QString line;
@@ -571,13 +566,12 @@ bool QSystemInfoLinuxCommonPrivate::hasFeatureSupported(QSystemInfo::Feature fea
break;
} while (!line.isNull());
versionFile2.close();
- if(!strvalue.isEmpty()) {
+ if(!strvalue.isEmpty())
return strvalue;
- }
}
QFile versionFile3(QLatin1String("/proc/version"));
- if(!versionFile3.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ if (!versionFile3.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "File not opened";
} else {
QString strvalue;
@@ -585,15 +579,18 @@ bool QSystemInfoLinuxCommonPrivate::hasFeatureSupported(QSystemInfo::Feature fea
versionFile3.close();
return strvalue;
}
+
break;
}
+
case QSystemInfo::QtCore :
- return QLatin1String(qVersion());
- break;
- default:
- break;
+ return QString(qVersion());
+
+ default:
+ break;
};
- return errorStr;
+
+ return QString("Not Available");
}
QString QSystemInfoLinuxCommonPrivate::currentCountryCode() const
@@ -603,18 +600,17 @@ QString QSystemInfoLinuxCommonPrivate::currentCountryCode() const
bool QSystemInfoLinuxCommonPrivate::hasSysFeature(const QString &featureStr)
{
- const QString sysPath = QLatin1String("/sys/class/");
+ const QString sysPath("/sys/class/");
const QDir sysDir(sysPath);
QStringList filters;
filters << QLatin1String("*");
- const QStringList sysList = sysDir.entryList( filters ,QDir::Dirs, QDir::Name);
+ const QStringList sysList = sysDir.entryList(filters, QDir::Dirs, QDir::Name);
foreach (const QString &dir, sysList) {
const QDir sysDir2(sysPath + dir);
if (dir.contains(featureStr)) {
- const QStringList sysList2 = sysDir2.entryList( filters ,QDir::Dirs, QDir::Name);
- if (!sysList2.isEmpty()) {
+ const QStringList sysList2 = sysDir2.entryList(filters, QDir::Dirs, QDir::Name);
+ if (!sysList2.isEmpty())
return true;
- }
}
}
return false;
@@ -1621,7 +1617,7 @@ bool q_XEventFilter(void *message)
XRRScreenChangeNotifyEvent *rrev = (XRRScreenChangeNotifyEvent *)(xev);
if (rrev->rotation != rot) {
- rot = rrev->rotation;
+ rot = rrev->rotation;
QTM_NAMESPACE::QSystemDisplayInfoLinuxCommonPrivate::instance()->emitOrientationChanged(rot);
QTM_NAMESPACE::QSystemDisplayInfoLinuxCommonPrivate::instance()->lastRotation = rot;
}
@@ -1629,14 +1625,14 @@ bool q_XEventFilter(void *message)
}
return false;
}
-#endif
+#endif // Q_WS_X11
+
QSystemDisplayInfoLinuxCommonPrivate::QSystemDisplayInfoLinuxCommonPrivate(QObject *parent)
- : QObject(parent), wid(0)
+ : QObject(parent)
{
- halIsAvailable = halAvailable();
- wid = new QDesktopWidget();
- if(!self)
+ if (!self)
self = this;
+
#if defined(Q_WS_X11)
QAbstractEventDispatcher::instance()->setEventFilter(q_XEventFilter);
Display *display = QX11Info::display();
@@ -1655,7 +1651,7 @@ QSystemDisplayInfoLinuxCommonPrivate::QSystemDisplayInfoLinuxCommonPrivate(QObje
lastRotation = cur_rotation;
}
}
-#endif
+#endif // Q_WS_X11
}
QSystemDisplayInfoLinuxCommonPrivate::~QSystemDisplayInfoLinuxCommonPrivate()
@@ -1680,46 +1676,45 @@ void QSystemDisplayInfoLinuxCommonPrivate::emitOrientationChanged(int curRotatio
break;
};
}
-#endif
-
+#endif // Q_WS_X11
bool QSystemDisplayInfoLinuxCommonPrivate::isScreenValid(int screen)
{
- if (screen > wid->screenCount() || screen < 0) {
+ if (screen > QApplication::desktop()->screenCount() || screen < 0)
return false;
- }
+
return true;
}
int QSystemDisplayInfoLinuxCommonPrivate::colorDepth(int screen)
{
- if (!isScreenValid(screen)) {
+ if (!isScreenValid(screen))
return -1;
- }
+
#if defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO)
struct fb_var_screeninfo *screenInfo = allocFrameBufferInfo(screen);
if (screenInfo) {
- int colorDepth = screenInfo->bits_per_pixel;
- free(screenInfo), screenInfo = 0;
- return colorDepth;
+ int colorDepth = screenInfo->bits_per_pixel;
+ free(screenInfo), screenInfo = 0;
+ return colorDepth;
}
#endif
#ifdef Q_WS_X11
- return wid->screen(screen)->x11Info().depth();
-#endif
+ return QApplication::desktop()->screen(screen)->x11Info().depth();
+#endif // Q_WS_X11
- /* as a last resort, use the default depth */
+ // as a last resort, use the default depth
return QPixmap::defaultDepth();
}
int QSystemDisplayInfoLinuxCommonPrivate::displayBrightness(int screen)
{
- if (!isScreenValid(screen)) {
+ if (!isScreenValid(screen))
return -1;
- }
#if !defined(QT_NO_DBUS)
+ halIsAvailable = halAvailable();
if (halIsAvailable) {
QHalInterface iface;
if (iface.isValid()) {
@@ -1735,24 +1730,23 @@ int QSystemDisplayInfoLinuxCommonPrivate::displayBrightness(int screen)
}
}
}
-#endif
- const QString backlightPath = "/proc/acpi/video/";
+#endif // QT_NO_DBUS
+
+ const QString backlightPath("/proc/acpi/video/");
const QDir videoDir(backlightPath);
QStringList filters;
filters << "*";
const QStringList brightnessList = videoDir.entryList(filters,
- QDir::Dirs
- | QDir::NoDotAndDotDot,
+ QDir::Dirs | QDir::NoDotAndDotDot,
QDir::Name);
foreach (const QString &brightnessFileName, brightnessList) {
float numLevels = 0.0;
float curLevel = 0.0;
- const QDir videoSubDir(backlightPath+"/"+brightnessFileName);
+ const QDir videoSubDir(backlightPath + "/" + brightnessFileName);
const QStringList vidDirList = videoSubDir.entryList(filters,
- QDir::Dirs
- | QDir::NoDotAndDotDot,
+ QDir::Dirs | QDir::NoDotAndDotDot,
QDir::Name);
foreach (const QString &vidFileName, vidDirList) {
QFile curBrightnessFile(backlightPath+brightnessFileName+"/"+vidFileName+"/brightness");
@@ -1761,10 +1755,10 @@ int QSystemDisplayInfoLinuxCommonPrivate::displayBrightness(int screen)
} else {
QTextStream bri(&curBrightnessFile);
QString line = bri.readLine();
- while(!line.isNull()) {
+ while (!line.isNull()) {
if (!line.contains("not supported")) {
if (line.contains("levels")) {
- QString level = line.section(" ",-1);
+ QString level = line.section(" ", -1);
bool ok;
numLevels = level.toFloat(&ok);
if (!ok)
@@ -1780,27 +1774,33 @@ int QSystemDisplayInfoLinuxCommonPrivate::displayBrightness(int screen)
line = bri.readLine();
}
curBrightnessFile.close();
- if (curLevel > -1 && numLevels > 0) {
+ if (curLevel > -1 && numLevels > 0)
return curLevel / numLevels * 100;
- }
-
}
}
}
+
return -1;
}
-QSystemDisplayInfo::BacklightState QSystemDisplayInfoLinuxCommonPrivate::backlightStatus(int screen)
+float QSystemDisplayInfoLinuxCommonPrivate::contrast(int screen)
{
- if (!isScreenValid(screen)) {
- return QSystemDisplayInfo::BacklightStateUnknown;
- }
+ Q_UNUSED(screen);
+
+ return -1;
+}
+
+QSystemDisplayInfo::BacklightState QSystemDisplayInfoLinuxCommonPrivate::backlightStatus(int screen)
+{
+ Q_UNUSED(screen);
+
return QSystemDisplayInfo::BacklightStateUnknown;
}
QSystemDisplayInfo::DisplayOrientation QSystemDisplayInfoLinuxCommonPrivate::orientation(int screen)
{
QSystemDisplayInfo::DisplayOrientation orientation = QSystemDisplayInfo::Unknown;
+
#if defined(Q_WS_X11)
XRRScreenConfiguration *sc;
Rotation cur_rotation;
@@ -1809,7 +1809,7 @@ QSystemDisplayInfo::DisplayOrientation QSystemDisplayInfoLinuxCommonPrivate::ori
if (display && (sc = XRRGetScreenInfo(display, RootWindow(display, screen)))) {
XRRConfigRotations(sc, &cur_rotation);
- if(screen < 16 && screen > -1) {
+ if (screen < 16 && screen > -1) {
switch(cur_rotation) {
case RR_Rotate_0:
orientation = QSystemDisplayInfo::Landscape;
@@ -1824,103 +1824,105 @@ QSystemDisplayInfo::DisplayOrientation QSystemDisplayInfoLinuxCommonPrivate::ori
orientation = QSystemDisplayInfo::InvertedPortrait;
break;
};
+ return orientation;
}
}
#endif
- if (wid->width() > wid->height()) {//landscape
- if (orientation == QSystemDisplayInfo::Unknown || orientation == QSystemDisplayInfo::Portrait) {
+ if (QApplication::desktop()->width() > QApplication::desktop()->height()) {//landscape
+ if (orientation == QSystemDisplayInfo::Unknown || orientation == QSystemDisplayInfo::Portrait)
orientation = QSystemDisplayInfo::Landscape;
- }
} else { //portrait
- if (orientation == QSystemDisplayInfo::Unknown || orientation == QSystemDisplayInfo::Landscape) {
+ if (orientation == QSystemDisplayInfo::Unknown || orientation == QSystemDisplayInfo::Landscape)
orientation = QSystemDisplayInfo::Portrait;
- }
}
+
return orientation;
}
int QSystemDisplayInfoLinuxCommonPrivate::physicalHeight(int screen)
{
- if (!isScreenValid(screen)) {
+ if (!isScreenValid(screen))
return -1;
- }
- int height = 0;
+
+ int height = -1;
+
#if defined(Q_WS_X11)
XRRScreenResources *sr;
sr = XRRGetScreenResources(QX11Info::display(), RootWindow(QX11Info::display(), screen));
for (int i = 0; i < sr->noutput; ++i) {
XRROutputInfo *output = XRRGetOutputInfo(QX11Info::display(),sr,sr->outputs[i]);
- if (output->crtc) {
+ if (output->crtc)
height = output->mm_height;
- }
XRRFreeOutputInfo(output);
}
XRRFreeScreenResources(sr);
-#endif
- if(height == 0) {
- struct fb_var_screeninfo *screenInfo = allocFrameBufferInfo(screen);
+#endif // Q_WS_X11
+ if (height == 0) {
+ struct fb_var_screeninfo *screenInfo = allocFrameBufferInfo(screen);
if (screenInfo) {
height = screenInfo->height;
- free(screenInfo), screenInfo = 0;
+ free(screenInfo);
}
}
+
return height;
}
int QSystemDisplayInfoLinuxCommonPrivate::physicalWidth(int screen)
{
- if (!isScreenValid(screen)) {
+ if (!isScreenValid(screen))
return -1;
- }
- int width = 0;
+
+ int width = -1;
+
#if defined(Q_WS_X11)
XRRScreenResources *sr;
sr = XRRGetScreenResources(QX11Info::display(), RootWindow(QX11Info::display(), screen));
for (int i = 0; i < sr->noutput; ++i) {
XRROutputInfo *output = XRRGetOutputInfo(QX11Info::display(),sr,sr->outputs[i]);
- if (output->crtc) {
+ if (output->crtc)
width = output->mm_width;
- }
XRRFreeOutputInfo(output);
}
XRRFreeScreenResources(sr);
-#endif
- if(width == 0) {
- struct fb_var_screeninfo *screenInfo = allocFrameBufferInfo(screen);
+#endif // Q_WS_X11
+ if (width == 0) {
+ struct fb_var_screeninfo *screenInfo = allocFrameBufferInfo(screen);
if (screenInfo) {
width = screenInfo->width;
- free(screenInfo), screenInfo = 0;
+ free(screenInfo);
}
}
+
return width;
}
int QSystemDisplayInfoLinuxCommonPrivate::getDPIWidth(int screen)
{
- if (!isScreenValid(screen)) {
+ if (!isScreenValid(screen))
return -1;
- }
+
#if defined(Q_WS_X11)
return QX11Info::appDpiY(screen);
#else
- return 0;
+ return -1;
#endif
}
int QSystemDisplayInfoLinuxCommonPrivate::getDPIHeight(int screen)
{
- if (!isScreenValid(screen)) {
+ if (!isScreenValid(screen))
return -1;
- }
+
#if defined(Q_WS_X11)
return QX11Info::appDpiX(screen);
#else
- return 0;
+ return -1;
#endif
}