From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/main.c | 67 +++++++++++++++++++------------- dlls/bluetoothapis/tests/radio.c | 8 ++-- 2 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index c32a6fb5a0d..c63d584e9a6 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -57,10 +57,7 @@ HBLUETOOTH_DEVICE_FIND WINAPI BluetoothFindFirstDevice(BLUETOOTH_DEVICE_SEARCH_P */ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS *params, HANDLE *radio) { - char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)]; - SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail; struct bluetooth_find_radio_handle *find; - SP_DEVICE_INTERFACE_DATA iface_data; HANDLE device_ret; BOOL found;
@@ -93,25 +90,7 @@ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS return NULL; }
- iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer; - iface_detail->cbSize = sizeof(*iface_detail); - iface_data.cbSize = sizeof(iface_data); - found = FALSE; - while (SetupDiEnumDeviceInterfaces(find->devinfo, NULL, &GUID_BTHPORT_DEVICE_INTERFACE, find->idx++, - &iface_data)) - { - - if (!SetupDiGetDeviceInterfaceDetailW(find->devinfo, &iface_data, iface_detail, sizeof(buffer), NULL, - NULL)) - continue; - device_ret = CreateFileW(iface_detail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); - if (device_ret != INVALID_HANDLE_VALUE) - { - found = TRUE; - break; - } - } + found = BluetoothFindNextRadio(find, &device_ret);
if (!found) { @@ -151,11 +130,47 @@ BOOL WINAPI BluetoothFindDeviceClose(HBLUETOOTH_DEVICE_FIND find) /********************************************************************* * BluetoothFindNextRadio */ -BOOL WINAPI BluetoothFindNextRadio(HBLUETOOTH_RADIO_FIND find, HANDLE *radio) +BOOL WINAPI BluetoothFindNextRadio(HBLUETOOTH_RADIO_FIND find_handle, HANDLE *radio) { - FIXME("(%p, %p): stub!\n", find, radio); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)]; + struct bluetooth_find_radio_handle *find = find_handle; + SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail; + SP_DEVICE_INTERFACE_DATA iface_data; + HANDLE device_ret; + BOOL found; + + TRACE("(%p, %p)\n", find_handle, radio); + + if (!find_handle) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer; + iface_detail->cbSize = sizeof(*iface_detail); + iface_data.cbSize = sizeof(iface_data); + found = FALSE; + while (SetupDiEnumDeviceInterfaces(find->devinfo, NULL, &GUID_BTHPORT_DEVICE_INTERFACE, find->idx++, + &iface_data)) + { + + if (!SetupDiGetDeviceInterfaceDetailW(find->devinfo, &iface_data, iface_detail, sizeof(buffer), NULL, + NULL)) + continue; + device_ret = CreateFileW(iface_detail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); + if (device_ret != INVALID_HANDLE_VALUE) + { + found = TRUE; + break; + } + } + + if (found) + *radio = device_ret; + + return found; }
/********************************************************************* diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index a394c0f7948..0eefecb053e 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -85,10 +85,10 @@ void test_BluetoothFindNextRadio( void ) radio = dummy; SetLastError( 0xdeadbeef ); ret = BluetoothFindNextRadio( NULL, &radio ); - todo_wine ok( !ret, "Expected BluetoothFindNextRadio to return FALSE\n" ); + ok( !ret, "Expected BluetoothFindNextRadio to return FALSE\n" ); err = GetLastError(); - todo_wine ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); - todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy ); + ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); + ok( radio == dummy, "%p != %p\n", radio, dummy );
for(;;) { @@ -97,7 +97,7 @@ void test_BluetoothFindNextRadio( void ) if (!ret) { err = GetLastError(); - todo_wine ok( err == ERROR_NO_MORE_ITEMS, "%lu != %d\n", err, ERROR_NO_MORE_ITEMS ); + ok( err == ERROR_NO_MORE_ITEMS, "%lu != %d\n", err, ERROR_NO_MORE_ITEMS ); break; } CloseHandle( radio );