From: Janne Anttila Date: Thu, 8 Mar 2012 12:43:11 +0000 (+0200) Subject: Initial bearer plugin for WinCE and WEC7. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e9c9e8bfa93b467a06a6cd872712845cacc465c8;p=profile%2Fivi%2Fqtbase.git Initial bearer plugin for WinCE and WEC7. In WinCE and WEC7 the IOCTL_NDISUIO_QUERY_OID_VALUE DeviceIoControl calls need to be used instead of OCTL_NDIS_QUERY_GLOBAL_STATS which is not supported in WinCE / WEC7. Task-number: QTBUG-24525 Change-Id: Ic091b5c38db95ffc657968b232ae0965ae6a4e81 Reviewed-by: Andreas Holzammer Reviewed-by: Joerg Bornemann --- diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 5682d11..9561597 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -56,6 +56,11 @@ #include "../platformdefs_win.h" #endif +#ifdef Q_OS_WINCE +typedef ULONG NDIS_OID, *PNDIS_OID; +#include +#endif + #ifdef Q_OS_LINUX #include #include @@ -71,31 +76,60 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_NETWORKINTERFACE static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface) { -#ifdef Q_OS_WIN32 - unsigned long oid; +#if defined(Q_OS_WIN) DWORD bytesWritten; - NDIS_MEDIUM medium; NDIS_PHYSICAL_MEDIUM physicalMedium; +#ifdef Q_OS_WINCE + NDISUIO_QUERY_OID nicGetOid; + HANDLE handle = CreateFile((PTCHAR)NDISUIO_DEVICE_NAME, 0, + FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); +#else + unsigned long oid; HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); +#endif if (handle == INVALID_HANDLE_VALUE) return QNetworkConfiguration::BearerUnknown; - oid = OID_GEN_MEDIA_SUPPORTED; bytesWritten = 0; + +#ifdef Q_OS_WINCE + ZeroMemory(&nicGetOid, sizeof(NDISUIO_QUERY_OID)); + nicGetOid.Oid = OID_GEN_MEDIA_SUPPORTED; + nicGetOid.ptcDeviceName = (PTCHAR)interface.utf16(); + bool result = DeviceIoControl(handle, IOCTL_NDISUIO_QUERY_OID_VALUE, &nicGetOid, sizeof(nicGetOid), + &nicGetOid, sizeof(nicGetOid), &bytesWritten, 0); +#else + oid = OID_GEN_MEDIA_SUPPORTED; bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), &medium, sizeof(medium), &bytesWritten, 0); +#endif if (!result) { CloseHandle(handle); return QNetworkConfiguration::BearerUnknown; } - oid = OID_GEN_PHYSICAL_MEDIUM; bytesWritten = 0; + +#ifdef Q_OS_WINCE + medium = NDIS_MEDIUM( *(LPDWORD)nicGetOid.Data ); + + ZeroMemory(&nicGetOid, sizeof(NDISUIO_QUERY_OID)); + nicGetOid.Oid = OID_GEN_PHYSICAL_MEDIUM; + nicGetOid.ptcDeviceName = (PTCHAR)interface.utf16(); + + result = DeviceIoControl(handle, IOCTL_NDISUIO_QUERY_OID_VALUE, &nicGetOid, sizeof(nicGetOid), + &nicGetOid, sizeof(nicGetOid), &bytesWritten, 0); + + physicalMedium = NDIS_PHYSICAL_MEDIUM( *(LPDWORD)nicGetOid.Data ); +#else + oid = OID_GEN_PHYSICAL_MEDIUM; result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0); +#endif + if (!result) { CloseHandle(handle);