diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2012-10-12 14:35:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-16 19:45:37 +0200 |
commit | 966825806db0bc96418a41b13728f262de5e3237 (patch) | |
tree | c18f13106c84f8f6fae2b5b5d5c5af79d693bd8f | |
parent | e8c937f74a42368bfaaae3145970d7de2d68cc90 (diff) |
QtSystems: Fix MinGW compilation.
- Q_UNIMPLEMENT functionality that is only present in
the Windows SDK or TDM MinGW.
- Remove linkage to Dxva2, which is not used and not
present in stock MinGW.
- Remove linkage to WLanAPI which does not exist
in stock MinGW. QNetworkDeviceInfo already contains
functionality to dynamically resolve the
WLanAPI-functions. Use those in the feature
detection code, too, thus decoupling the library.
Task-number: QTBUG-27560
Change-Id: I611070edc3db96e34e14ed28a95846a678463574
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Alexey Pavlov <alexpux@gmail.com>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
-rw-r--r-- | src/systeminfo/qbatteryinfo_win.cpp | 13 | ||||
-rw-r--r-- | src/systeminfo/qdeviceinfo_win.cpp | 44 | ||||
-rw-r--r-- | src/systeminfo/qnetworkinfo_win.cpp | 26 | ||||
-rw-r--r-- | src/systeminfo/qnetworkinfo_win_p.h | 5 | ||||
-rw-r--r-- | src/systeminfo/qstorageinfo_win.cpp | 2 | ||||
-rw-r--r-- | src/systeminfo/systeminfo.pro | 5 | ||||
-rw-r--r-- | src/systeminfo/windows/qwmihelper_win.cpp | 4 | ||||
-rw-r--r-- | src/systeminfo/windows/qwmihelper_win_p.h | 4 |
8 files changed, 67 insertions, 36 deletions
diff --git a/src/systeminfo/qbatteryinfo_win.cpp b/src/systeminfo/qbatteryinfo_win.cpp index 7e09ce92..552b4318 100644 --- a/src/systeminfo/qbatteryinfo_win.cpp +++ b/src/systeminfo/qbatteryinfo_win.cpp @@ -46,13 +46,17 @@ #include <PowrProf.h> #include <Setupapi.h> -#include <BatClass.h> +#if !defined (Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) +# include <BatClass.h> +#endif #include <QtCore/qmetaobject.h> #include <QtCore/QTimer> #include <QtCore/QUuid> -#pragma comment (lib, "Setupapi.lib") +#ifdef Q_CC_MSVC +# pragma comment (lib, "Setupapi.lib") +#endif QT_BEGIN_NAMESPACE @@ -134,6 +138,7 @@ QBatteryInfo::BatteryStatus QBatteryInfoPrivate::batteryStatus(int battery) void QBatteryInfoPrivate::getBatteryStatus() { +#if !defined (Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) SYSTEM_BATTERY_STATE systemBatteryState; CallNtPowerInformation(SystemBatteryState,NULL,0,&systemBatteryState,sizeof(systemBatteryState)); @@ -270,6 +275,10 @@ void QBatteryInfoPrivate::getBatteryStatus() SetupDiDestroyDeviceInfoList(hdevInfo); } numberOfBatteries = batteryNumber; +#else // !defined (Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) + numberOfBatteries = 0; + Q_UNIMPLEMENTED(); +#endif } QT_END_NAMESPACE diff --git a/src/systeminfo/qdeviceinfo_win.cpp b/src/systeminfo/qdeviceinfo_win.cpp index 37120234..64833066 100644 --- a/src/systeminfo/qdeviceinfo_win.cpp +++ b/src/systeminfo/qdeviceinfo_win.cpp @@ -40,17 +40,19 @@ ****************************************************************************/ #include "qdeviceinfo_win_p.h" +#include "qnetworkinfo_win_p.h" #include "qscreensaver_win_p.h" #include <QtCore/qsettings.h> #include <Winsock2.h> -#include <windows.h> +#include <qt_windows.h> #include <Vfw.h> -#include <Ws2bth.h> -#include <Bthsdpdef.h> -#include <BluetoothAPIs.h> -#include <Wlanapi.h> +#if !defined(Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) +# include <Ws2bth.h> +# include <Bthsdpdef.h> +# include <BluetoothAPIs.h> +#endif QT_BEGIN_NAMESPACE @@ -68,6 +70,7 @@ QDeviceInfoPrivate::QDeviceInfoPrivate(QDeviceInfo *parent) bool QDeviceInfoPrivate::hasFeature(QDeviceInfo::Feature feature) { switch (feature) { +#if !defined(Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) case QDeviceInfo::BluetoothFeature: { BLUETOOTH_DEVICE_SEARCH_PARAMS searchParameter; searchParameter.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS); @@ -89,25 +92,6 @@ bool QDeviceInfoPrivate::hasFeature(QDeviceInfo::Feature feature) } } - case QDeviceInfo::WlanFeature: { - bool supportsWlan(false); - DWORD negotiatedVersion; - HANDLE handle; - if (ERROR_SUCCESS == WlanOpenHandle(1, NULL, &negotiatedVersion, &handle)) { - PWLAN_INTERFACE_INFO_LIST list; - if (ERROR_SUCCESS == WlanEnumInterfaces(handle, NULL, &list)) { - if (list->dwNumberOfItems > 0) - supportsWlan = true; - WlanFreeMemory(list); - } - WlanCloseHandle(handle, NULL); - } - return supportsWlan; - } - - case QDeviceInfo::VideoOutFeature: - return (GetSystemMetrics(SM_CMONITORS) > 0); - case QDeviceInfo::InfraredFeature: { WSADATA wsaData; if (0 == WSAStartup(MAKEWORD(1,1), &wsaData)) { @@ -129,6 +113,18 @@ bool QDeviceInfoPrivate::hasFeature(QDeviceInfo::Feature feature) } return false; } +#else // !defined(Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) + case QDeviceInfo::BluetoothFeature: + case QDeviceInfo::InfraredFeature: + case QDeviceInfo::CameraFeature: + Q_UNIMPLEMENTED(); + return false; +#endif + case QDeviceInfo::WlanFeature: + return QNetworkInfoPrivate::wifiInterfaceCount() > 0; + + case QDeviceInfo::VideoOutFeature: + return (GetSystemMetrics(SM_CMONITORS) > 0); // not sure if we can use WDK, thus not implemented as of now // case QDeviceInfo::MemoryCard: diff --git a/src/systeminfo/qnetworkinfo_win.cpp b/src/systeminfo/qnetworkinfo_win.cpp index 5bc9c479..8a6a714d 100644 --- a/src/systeminfo/qnetworkinfo_win.cpp +++ b/src/systeminfo/qnetworkinfo_win.cpp @@ -47,6 +47,8 @@ #include <QtCore/QTimer> #include <QtCore/QTimerEvent> #include <QtCore/QSettings> +#include <QtCore/QStringList> +#include <QtCore/qt_windows.h> #include <QtCore/qmetaobject.h> @@ -488,6 +490,30 @@ QNetworkInfoPrivate *QNetworkInfoPrivate::instance() return self; } +// Called by the feature detection code. +unsigned QNetworkInfoPrivate::wifiInterfaceCount() +{ +#if !defined( Q_CC_MINGW) && !defined( Q_OS_WINCE) + resolveLibrary(); + if (!local_WlanOpenHandle) + return 0; + DWORD negotiatedVersion; + HANDLE handle; + if (ERROR_SUCCESS != local_WlanOpenHandle(1, NULL, &negotiatedVersion, &handle)) + return 0; + WLAN_INTERFACE_INFO_LIST *list; + unsigned result = 0; + if (ERROR_SUCCESS == local_WlanEnumInterfaces(handle, NULL, &list)) { + result = list->dwNumberOfItems; + local_WlanFreeMemory(list); + } + local_WlanCloseHandle(handle, NULL); + return result; +#else // !defined( Q_CC_MINGW) && !defined( Q_OS_WINCE) + return 0; +#endif +} + void QNetworkInfoPrivate::startWifiCallback() { #if !defined( Q_CC_MINGW) && !defined( Q_OS_WINCE) diff --git a/src/systeminfo/qnetworkinfo_win_p.h b/src/systeminfo/qnetworkinfo_win_p.h index db62827d..8a704a28 100644 --- a/src/systeminfo/qnetworkinfo_win_p.h +++ b/src/systeminfo/qnetworkinfo_win_p.h @@ -57,9 +57,6 @@ #include "qnetworkinfo.h" - -#include <qt_windows.h> - QT_BEGIN_NAMESPACE class QNetworkInfoPrivate : public QObject @@ -92,6 +89,8 @@ public: void emitNetworkSignalStrengthChanged(QNetworkInfo::NetworkMode,int); static QNetworkInfoPrivate *instance(); + static unsigned wifiInterfaceCount(); + Q_SIGNALS: void cellIdChanged(int netInterface, const QString &id); void currentCellDataTechnologyChanged(int netInterface, QNetworkInfo::CellDataTechnology tech); diff --git a/src/systeminfo/qstorageinfo_win.cpp b/src/systeminfo/qstorageinfo_win.cpp index cb69c13e..8974bf00 100644 --- a/src/systeminfo/qstorageinfo_win.cpp +++ b/src/systeminfo/qstorageinfo_win.cpp @@ -50,7 +50,7 @@ #include <QtCore/qdir.h> #include <QtCore/qmetaobject.h> -#include <windows.h> +#include <qt_windows.h> QT_BEGIN_NAMESPACE diff --git a/src/systeminfo/systeminfo.pro b/src/systeminfo/systeminfo.pro index d1c7a1df..1bcf8e83 100644 --- a/src/systeminfo/systeminfo.pro +++ b/src/systeminfo/systeminfo.pro @@ -30,11 +30,11 @@ win32: !simulator: { } win32-msvc*: { - LIBS += -lUser32 -lGdi32 -lPowrProf -lBthprops -lWlanapi -lWs2_32 -lVfw32 -lSetupapi -lIphlpapi -lOle32 -lWbemuuid + LIBS += -lUser32 -lGdi32 -lPowrProf -lBthprops -lWs2_32 -lVfw32 -lSetupapi -lIphlpapi -lOle32 -lWbemuuid } win32-g++*: { - LIBS += -luser32 -lgdi32 -lpowrprof -lbthprops -lwlanapi -lws2_32 -lmsvfw32 -lavicap32 + LIBS += -luser32 -lgdi32 -lpowrprof -lbthprops -lws2_32 -lmsvfw32 -lavicap32 -luuid } PRIVATE_HEADERS += qscreensaver_win_p.h \ @@ -58,7 +58,6 @@ win32: !simulator: { -lGdi32 \ -lIphlpapi \ -lOleaut32 \ - -lDxva2 \ -lPowrProf \ -lSetupapi diff --git a/src/systeminfo/windows/qwmihelper_win.cpp b/src/systeminfo/windows/qwmihelper_win.cpp index 03fb332b..0c89afd7 100644 --- a/src/systeminfo/windows/qwmihelper_win.cpp +++ b/src/systeminfo/windows/qwmihelper_win.cpp @@ -38,7 +38,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef Q_CC_MINGW + +#include <QtCore/QtGlobal> // for Q_CC_MINGW +#if !defined (Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) #define _WIN32_DCOM #include "qwmihelper_win_p.h" diff --git a/src/systeminfo/windows/qwmihelper_win_p.h b/src/systeminfo/windows/qwmihelper_win_p.h index d993a035..b8891500 100644 --- a/src/systeminfo/windows/qwmihelper_win_p.h +++ b/src/systeminfo/windows/qwmihelper_win_p.h @@ -55,7 +55,7 @@ #include "../qsysteminfoglobal_p.h" -#ifndef Q_CC_MINGW +#if !defined (Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) #include <QObject> #include <QVariant> #include <QString> @@ -133,5 +133,5 @@ public: QT_END_NAMESPACE QT_END_HEADER -#endif +#endif // !defined (Q_CC_MINGW) || defined(__MINGW64_VERSION_MAJOR) #endif // WMIHELPER_H |