From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/main.c | 43 ++++++++++++++++++++++++++++++-- dlls/bluetoothapis/tests/radio.c | 6 ++--- 2 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index 8a3acc781bd..6cdc84f6b6f 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -363,8 +363,47 @@ BOOL WINAPI BluetoothIsDiscoverable( HANDLE radio ) */ BOOL WINAPI BluetoothEnableDiscovery( HANDLE radio, BOOL enabled ) { - FIXME("(%p %d): stub!\n", radio, enabled); - return FALSE; + TRACE( "(%p, %d)\n", radio, enabled ); + if (!radio) + { + BLUETOOTH_FIND_RADIO_PARAMS params = {.dwSize = sizeof( params )}; + HBLUETOOTH_RADIO_FIND find = BluetoothFindFirstRadio( ¶ms, &radio ); + + if (!find) + return FALSE; + for (;;) + { + if (BluetoothEnableDiscovery( radio, enabled )) + { + CloseHandle( radio ); + BluetoothFindRadioClose( find ); + return TRUE; + } + + CloseHandle(radio ); + if (!BluetoothFindNextRadio( find, &radio )) + { + BluetoothFindRadioClose( find ); + return FALSE; + } + } + } + else if (enabled && !BluetoothIsConnectable( radio )) + /* The local radio can only be made discoverable if it is connectable. */ + return FALSE; + else + { + struct winebth_radio_set_flag_params params = {0}; + BOOL ret; + DWORD bytes; + + params.flag = LOCAL_RADIO_DISCOVERABLE; + params.enable = !!enabled; + ret = DeviceIoControl( radio, IOCTL_WINEBTH_RADIO_SET_FLAG, ¶ms, sizeof( params ), NULL, 0, &bytes, NULL ); + if (!ret) + ERR("DeviceIoControl failed: %#lx\n", GetLastError()); + return ret; + } }
/********************************************************************* diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index 903f6010edc..798c5ddce20 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -255,7 +255,7 @@ void test_radio_BluetoothEnableDiscovery( HANDLE radio, void *data ) if (BluetoothIsDiscoverable( radio )) { ret = BluetoothEnableDiscovery( radio, FALSE ); - todo_wine ok( ret, "%d != 1\n", ret ); + ok( ret, "%d != 1\n", ret ); }
/* Enabling discovery requires incoming connections to be enabled as well, so this should result in an error. */ @@ -265,9 +265,9 @@ void test_radio_BluetoothEnableDiscovery( HANDLE radio, void *data )
BluetoothEnableIncomingConnections( radio, TRUE ); ret = BluetoothEnableDiscovery( radio, TRUE ); - todo_wine ok( ret, "%d != 1\n", ret ); + ok( ret, "%d != 1\n", ret ); ret = BluetoothIsDiscoverable( radio ); - todo_wine ok ( ret, "%d != 1\n", ret ); + ok ( ret, "%d != 1\n", ret ); }
void test_BluetoothEnableDiscovery( void )