From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/tests/radio.c | 65 ++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index 5851df6cc02..157298931a3 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -119,9 +119,74 @@ void test_BluetoothFindRadioClose( void ) ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); }
+void test_for_all_radios( void (*test)( HANDLE radio ) ) +{ + DWORD err, idx = 0; + HANDLE radio; + HBLUETOOTH_RADIO_FIND find; + BLUETOOTH_FIND_RADIO_PARAMS find_params; + + find_params.dwSize = sizeof( find_params ); + find = BluetoothFindFirstRadio( &find_params, &radio ); + if (!find) + { + err = GetLastError(); + ok( err == ERROR_NO_MORE_ITEMS, "%lu != %d\n", err, ERROR_NO_MORE_ITEMS ); + skip( "No Bluetooth radios found.\n" ); + return; + } + + for(;;) + { + BOOL ret; + + winetest_push_context( "radio %lu", idx++ ); + test( radio ); + winetest_pop_context(); + + CloseHandle( radio ); + ret = BluetoothFindNextRadio( find, &radio ); + if (!ret) + { + err = GetLastError(); + ok( err == ERROR_NO_MORE_ITEMS, "%lu != %d\n", err, ERROR_NO_MORE_ITEMS ); + break; + } + } + BluetoothFindRadioClose( find ); +} + +void test_BluetoothGetRadioInfo( HANDLE radio ) +{ + DWORD err; + BLUETOOTH_RADIO_INFO info = {0}; + + err = BluetoothGetRadioInfo( NULL, NULL ); + todo_wine ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); + err = BluetoothGetRadioInfo( radio, NULL ); + todo_wine ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); + err = BluetoothGetRadioInfo( radio, &info ); + todo_wine ok( err == ERROR_REVISION_MISMATCH, "%lu != %d\n", err, ERROR_REVISION_MISMATCH ); + + info.dwSize = sizeof( info ); + err = BluetoothGetRadioInfo( radio, &info ); + todo_wine ok( !err, "BluetoothGetRadioInfo failed: %lu\n", err ); + if (err) + return; + + trace( "address: %x:%x:%x:%x:%x:%x\n", info.address.rgBytes[0], info.address.rgBytes[1], info.address.rgBytes[2], + info.address.rgBytes[3], info.address.rgBytes[4], info.address.rgBytes[5] ); + trace( "name: %s\n", debugstr_w( info.szName ) ); + trace( "class: %lx\n", info.ulClassofDevice ); + trace( "LMP subversion: %x\n", info.lmpSubversion ); + trace( "manufacturer: %x\n", info.manufacturer ); +} + START_TEST( radio ) { test_BluetoothFindFirstRadio(); test_BluetoothFindNextRadio(); test_BluetoothFindRadioClose(); + + test_for_all_radios( test_BluetoothGetRadioInfo ); }
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/main.c | 37 ++++++++++++++++++++++++++++---- dlls/bluetoothapis/tests/radio.c | 8 +++---- 2 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index 076d758eb1a..07a9908b657 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -20,18 +20,23 @@ */
#include <stdarg.h> +#include <winternl.h> #include <windef.h> #include <winbase.h> #include <winuser.h> #include <winreg.h> +#include <winnls.h>
-#include "wine/debug.h" #include "bthsdpdef.h" #include "bluetoothapis.h" #include "setupapi.h" +#include "winioctl.h"
#include "initguid.h" #include "bthdef.h" +#include "bthioctl.h" + +#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(bluetoothapis);
@@ -177,10 +182,34 @@ BOOL WINAPI BluetoothFindNextRadio( HBLUETOOTH_RADIO_FIND find_handle, HANDLE *r /********************************************************************* * BluetoothGetRadioInfo */ -DWORD WINAPI BluetoothGetRadioInfo(HANDLE radio, PBLUETOOTH_RADIO_INFO info) +DWORD WINAPI BluetoothGetRadioInfo( HANDLE radio, PBLUETOOTH_RADIO_INFO info ) { - FIXME("(%p, %p): stub!\n", radio, info); - return ERROR_CALL_NOT_IMPLEMENTED; + BOOL ret; + DWORD bytes = 0; + BTH_LOCAL_RADIO_INFO radio_info = {0}; + + TRACE( "(%p, %p)\n", radio, info ); + + if (!radio || !info) + return ERROR_INVALID_PARAMETER; + if (info->dwSize != sizeof( *info )) + return ERROR_REVISION_MISMATCH; + + ret = DeviceIoControl( radio, IOCTL_BTH_GET_LOCAL_INFO, NULL, 0, &radio_info, sizeof( radio_info ), &bytes, NULL ); + if (!ret) + return GetLastError(); + + if (radio_info.localInfo.flags & BDIF_ADDRESS) + info->address.ullLong = RtlUlonglongByteSwap( radio_info.localInfo.address ); + if (radio_info.localInfo.flags & BDIF_COD) + info->ulClassofDevice = radio_info.localInfo.classOfDevice; + if (radio_info.localInfo.flags & BDIF_NAME) + MultiByteToWideChar( CP_ACP, 0, radio_info.localInfo.name, -1, info->szName, ARRAY_SIZE( info->szName ) ); + + info->lmpSubversion = radio_info.radioInfo.lmpSubversion; + info->manufacturer = radio_info.radioInfo.mfg; + + return ERROR_SUCCESS; }
/********************************************************************* diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index 157298931a3..c880fffdcf0 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -162,15 +162,15 @@ void test_BluetoothGetRadioInfo( HANDLE radio ) BLUETOOTH_RADIO_INFO info = {0};
err = BluetoothGetRadioInfo( NULL, NULL ); - todo_wine ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); + ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); err = BluetoothGetRadioInfo( radio, NULL ); - todo_wine ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); + ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); err = BluetoothGetRadioInfo( radio, &info ); - todo_wine ok( err == ERROR_REVISION_MISMATCH, "%lu != %d\n", err, ERROR_REVISION_MISMATCH ); + ok( err == ERROR_REVISION_MISMATCH, "%lu != %d\n", err, ERROR_REVISION_MISMATCH );
info.dwSize = sizeof( info ); err = BluetoothGetRadioInfo( radio, &info ); - todo_wine ok( !err, "BluetoothGetRadioInfo failed: %lu\n", err ); + ok( !err, "BluetoothGetRadioInfo failed: %lu\n", err ); if (err) return;
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/bluetoothapis.spec | 4 ++-- dlls/bluetoothapis/main.c | 18 ++++++++++++++++++ dlls/bthprops.cpl/bthprops.cpl.spec | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dlls/bluetoothapis/bluetoothapis.spec b/dlls/bluetoothapis/bluetoothapis.spec index 939072d308c..a28a493311d 100644 --- a/dlls/bluetoothapis/bluetoothapis.spec +++ b/dlls/bluetoothapis/bluetoothapis.spec @@ -47,8 +47,8 @@ @ stub BluetoothGetLocalServiceInfo @ stdcall BluetoothGetRadioInfo(ptr ptr) @ stub BluetoothGetServicePnpInstance -@ stub BluetoothIsConnectable -@ stub BluetoothIsDiscoverable +@ stdcall BluetoothIsConnectable(ptr) +@ stdcall BluetoothIsDiscoverable(ptr) @ stub BluetoothIsVersionAvailable @ stub BluetoothRegisterForAuthentication @ stdcall BluetoothRegisterForAuthenticationEx(ptr ptr ptr ptr) diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index 07a9908b657..ccfbe07258c 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -212,6 +212,24 @@ DWORD WINAPI BluetoothGetRadioInfo( HANDLE radio, PBLUETOOTH_RADIO_INFO info ) return ERROR_SUCCESS; }
+/********************************************************************* + * BluetoothIsConnectable + */ +BOOL WINAPI BluetoothIsConnectable( HANDLE radio ) +{ + FIXME( "(%p): stub!\n", radio ); + return FALSE; +} + +/********************************************************************* + * BluetoothIsDiscoverable + */ +BOOL WINAPI BluetoothIsDiscoverable( HANDLE radio ) +{ + FIXME( "(%p): stub!\n", radio ); + return FALSE; +} + /********************************************************************* * BluetoothFindNextDevice */ diff --git a/dlls/bthprops.cpl/bthprops.cpl.spec b/dlls/bthprops.cpl/bthprops.cpl.spec index 7fe1d82ac89..751eec41e79 100644 --- a/dlls/bthprops.cpl/bthprops.cpl.spec +++ b/dlls/bthprops.cpl/bthprops.cpl.spec @@ -36,8 +36,8 @@ @ stub BluetoothFindServiceClose @ stub BluetoothGetDeviceInfo @ stdcall -import BluetoothGetRadioInfo(ptr ptr) -@ stub BluetoothIsConnectable -@ stub BluetoothIsDiscoverable +@ stdcall -import BluetoothIsConnectable(ptr) +@ stdcall -import BluetoothIsDiscoverable(ptr) @ stub BluetoothIsVersionAvailable @ stub BluetoothMapClassOfDeviceToImageIndex @ stub BluetoothMapClassOfDeviceToString
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/tests/radio.c | 47 +++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index c880fffdcf0..60e0a7f4ebc 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -119,7 +119,7 @@ void test_BluetoothFindRadioClose( void ) ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); }
-void test_for_all_radios( void (*test)( HANDLE radio ) ) +void test_for_all_radios( void (*test)( HANDLE radio, void *data ), void *data ) { DWORD err, idx = 0; HANDLE radio; @@ -141,7 +141,7 @@ void test_for_all_radios( void (*test)( HANDLE radio ) ) BOOL ret;
winetest_push_context( "radio %lu", idx++ ); - test( radio ); + test( radio, data ); winetest_pop_context();
CloseHandle( radio ); @@ -156,7 +156,7 @@ void test_for_all_radios( void (*test)( HANDLE radio ) ) BluetoothFindRadioClose( find ); }
-void test_BluetoothGetRadioInfo( HANDLE radio ) +void test_BluetoothGetRadioInfo( HANDLE radio, void *data ) { DWORD err; BLUETOOTH_RADIO_INFO info = {0}; @@ -182,11 +182,50 @@ void test_BluetoothGetRadioInfo( HANDLE radio ) trace( "manufacturer: %x\n", info.manufacturer ); }
+void test_radio_BluetoothIsConnectable( HANDLE radio, void *data ) +{ + BOOL *result = data; + + *result |= BluetoothIsConnectable( radio ); +} + +void test_BluetoothIsConnectable( void ) +{ + BOOL ret; + BOOL result = FALSE; + + ret = BluetoothIsConnectable( NULL ); + /* If ret is true, then at least one radio must be connectable. If ret returns false, then no radios are connectable. */ + test_for_all_radios( test_radio_BluetoothIsConnectable, &result ); + + ok( ret == result, "%d != %d\n", ret, result ); +} + +void test_radio_BluetoothIsDiscoverable( HANDLE radio, void *data ) +{ + BOOL *result = data; + + *result |= BluetoothIsDiscoverable( radio ); +} + +void test_BluetoothIsDiscoverable( void ) +{ + BOOL ret; + BOOL result = FALSE; + + ret = BluetoothIsDiscoverable( NULL ); + test_for_all_radios( test_radio_BluetoothIsDiscoverable, &result ); + + ok( ret == result, "%d != %d\n", ret, result ); +} + START_TEST( radio ) { test_BluetoothFindFirstRadio(); test_BluetoothFindNextRadio(); test_BluetoothFindRadioClose();
- test_for_all_radios( test_BluetoothGetRadioInfo ); + test_for_all_radios( test_BluetoothGetRadioInfo, NULL ); + test_BluetoothIsDiscoverable(); + test_BluetoothIsConnectable(); }
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/main.c | 45 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index ccfbe07258c..a9c9526f925 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -212,13 +212,54 @@ DWORD WINAPI BluetoothGetRadioInfo( HANDLE radio, PBLUETOOTH_RADIO_INFO info ) return ERROR_SUCCESS; }
+#define LOCAL_RADIO_CONNECTABLE 0x0002 + /********************************************************************* * BluetoothIsConnectable */ BOOL WINAPI BluetoothIsConnectable( HANDLE radio ) { - FIXME( "(%p): stub!\n", radio ); - return FALSE; + TRACE( "(%p)\n", radio ); + + if (!radio) + { + BLUETOOTH_FIND_RADIO_PARAMS params = {.dwSize = sizeof( params )}; + HBLUETOOTH_RADIO_FIND find = BluetoothFindFirstRadio( ¶ms, &radio ); + + if (!find) + return FALSE; + for (;;) + { + if (BluetoothIsConnectable( radio )) + { + CloseHandle( radio ); + BluetoothFindRadioClose( find ); + return TRUE; + } + + CloseHandle( radio ); + if (!BluetoothFindNextRadio( find, &radio )) + { + BluetoothFindRadioClose( find ); + return FALSE; + } + } + } + else + { + BTH_LOCAL_RADIO_INFO radio_info = {0}; + DWORD bytes; + DWORD ret; + + ret = DeviceIoControl( radio, IOCTL_BTH_GET_LOCAL_INFO, NULL, 0, &radio_info, sizeof( radio_info ), &bytes, + NULL ); + if (!ret) + { + ERR( "DeviceIoControl failed: %#lx\n", GetLastError() ); + return FALSE; + } + return !!(radio_info.flags & LOCAL_RADIO_CONNECTABLE); + } }
/*********************************************************************
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/main.c | 44 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index a9c9526f925..fd3496e3fab 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -212,6 +212,7 @@ DWORD WINAPI BluetoothGetRadioInfo( HANDLE radio, PBLUETOOTH_RADIO_INFO info ) return ERROR_SUCCESS; }
+#define LOCAL_RADIO_DISCOVERABLE 0x0001 #define LOCAL_RADIO_CONNECTABLE 0x0002
/********************************************************************* @@ -267,8 +268,47 @@ BOOL WINAPI BluetoothIsConnectable( HANDLE radio ) */ BOOL WINAPI BluetoothIsDiscoverable( HANDLE radio ) { - FIXME( "(%p): stub!\n", radio ); - return FALSE; + TRACE( "(%p)\n", radio ); + + if (!radio) + { + BLUETOOTH_FIND_RADIO_PARAMS params = {.dwSize = sizeof( params )}; + HBLUETOOTH_RADIO_FIND find = BluetoothFindFirstRadio( ¶ms, &radio ); + + if (!find) + return FALSE; + for (;;) + { + if (BluetoothIsDiscoverable( radio )) + { + CloseHandle( radio ); + BluetoothFindRadioClose( find ); + return TRUE; + } + + CloseHandle( radio ); + if (!BluetoothFindNextRadio( find, &radio )) + { + BluetoothFindRadioClose( find ); + return FALSE; + } + } + } + else + { + BTH_LOCAL_RADIO_INFO radio_info = {0}; + DWORD bytes; + DWORD ret; + + ret = DeviceIoControl( radio, IOCTL_BTH_GET_LOCAL_INFO, NULL, 0, &radio_info, sizeof( radio_info ), &bytes, + NULL ); + if (!ret) + { + ERR( "DeviceIoControl failed: %#lx\n", GetLastError() ); + return FALSE; + } + return !!(radio_info.flags & LOCAL_RADIO_DISCOVERABLE); + } }
/*********************************************************************