-- v2: bluetoothapis/tests: Add tests for BluetoothGetDeviceInfo.
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/bluetoothapis.spec | 2 +- dlls/bluetoothapis/main.c | 41 +++++++++++++++++++++++++++ dlls/bthprops.cpl/bthprops.cpl.spec | 2 +- dlls/irprops.cpl/irprops.cpl.spec | 2 +- 4 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/dlls/bluetoothapis/bluetoothapis.spec b/dlls/bluetoothapis/bluetoothapis.spec index 77a3a931a55..2a2a657fabe 100644 --- a/dlls/bluetoothapis/bluetoothapis.spec +++ b/dlls/bluetoothapis/bluetoothapis.spec @@ -43,7 +43,7 @@ @ stub BluetoothGATTSetCharacteristicValue @ stub BluetoothGATTSetDescriptorValue @ stub BluetoothGATTUnregisterEvent -@ stub BluetoothGetDeviceInfo +@ stdcall BluetoothGetDeviceInfo(ptr long) @ stub BluetoothGetLocalServiceInfo @ stdcall BluetoothGetRadioInfo(ptr ptr) @ stub BluetoothGetServicePnpInstance diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index 4f82381acc9..7cf89b23fc9 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -391,6 +391,47 @@ DWORD WINAPI BluetoothGetRadioInfo( HANDLE radio, PBLUETOOTH_RADIO_INFO info ) return ERROR_SUCCESS; }
+/********************************************************************* + * BluetoothGetDeviceInfo + */ +DWORD WINAPI BluetoothGetDeviceInfo( HANDLE radio, BLUETOOTH_DEVICE_INFO *info ) +{ + const static BYTE addr_zero[6]; + BTH_DEVICE_INFO_LIST *devices; + DWORD i, ret = ERROR_NOT_FOUND; + + TRACE( "(%p, %p)\n", radio, info ); + + if (!radio) + return E_HANDLE; + if (!info) + return ERROR_INVALID_PARAMETER; + if (info->dwSize != sizeof( *info )) + return ERROR_REVISION_MISMATCH; + if (!memcmp( info->Address.rgBytes, addr_zero, sizeof( addr_zero ) )) + return ERROR_NOT_FOUND; + + devices = radio_get_devices( radio ); + if (!devices) + return GetLastError(); + for (i = 0; i < devices->numOfDevices; i++) + { + if (devices->deviceList[i].address == info->Address.ullLong) + { + device_info_from_bth_info( info, &devices->deviceList[i] ); + if (info->fConnected) + GetSystemTime( &info->stLastSeen ); + else + FIXME( "semi-stub!\n" ); + ret = ERROR_SUCCESS; + break; + } + } + + free( devices ); + return ret; +} + /********************************************************************* * BluetoothIsConnectable */ diff --git a/dlls/bthprops.cpl/bthprops.cpl.spec b/dlls/bthprops.cpl/bthprops.cpl.spec index dee5544baaf..2b263c7627e 100644 --- a/dlls/bthprops.cpl/bthprops.cpl.spec +++ b/dlls/bthprops.cpl/bthprops.cpl.spec @@ -34,7 +34,7 @@ @ stub BluetoothFindProtocolEntryClose @ stdcall -import BluetoothFindRadioClose(ptr) @ stub BluetoothFindServiceClose -@ stub BluetoothGetDeviceInfo +@ stdcall BluetoothGetDeviceInfo(ptr long) @ stdcall -import BluetoothGetRadioInfo(ptr ptr) @ stdcall -import BluetoothIsConnectable(ptr) @ stdcall -import BluetoothIsDiscoverable(ptr) diff --git a/dlls/irprops.cpl/irprops.cpl.spec b/dlls/irprops.cpl/irprops.cpl.spec index 1f6116addc5..483ae4e288e 100644 --- a/dlls/irprops.cpl/irprops.cpl.spec +++ b/dlls/irprops.cpl/irprops.cpl.spec @@ -30,7 +30,7 @@ @ stub BluetoothFindProtocolEntryClose @ stdcall -import BluetoothFindRadioClose(ptr) @ stub BluetoothFindServiceClose -@ stub BluetoothGetDeviceInfo +@ stdcall BluetoothGetDeviceInfo(ptr long) @ stdcall -import BluetoothGetRadioInfo(ptr ptr) @ stdcall BluetoothIsConnectable(ptr) bthprops.cpl.BluetoothIsConnectable @ stdcall BluetoothIsDiscoverable(ptr) bthprops.cpl.BluetoothIsDiscoverable
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/tests/device.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/dlls/bluetoothapis/tests/device.c b/dlls/bluetoothapis/tests/device.c index b9331b7488d..4ce5d65a9d2 100644 --- a/dlls/bluetoothapis/tests/device.c +++ b/dlls/bluetoothapis/tests/device.c @@ -31,6 +31,11 @@
extern void test_for_all_radios( void (*test)( HANDLE radio, void *data ), void *data );
+static const char *debugstr_bluetooth_address( const BYTE *addr ) +{ + return wine_dbg_sprintf( "%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] ); +} + void test_radio_BluetoothFindFirstDevice( HANDLE radio, void *data ) { BLUETOOTH_DEVICE_SEARCH_PARAMS search_params; @@ -117,7 +122,7 @@ void test_radio_BluetoothFindNextDevice( HANDLE radio, void *data )
for (;;) { - const BYTE *addr = info.Address.rgBytes; + BLUETOOTH_DEVICE_INFO info2 = {0}; WCHAR buf[256]; BOOL matches;
@@ -126,7 +131,7 @@ void test_radio_BluetoothFindNextDevice( HANDLE radio, void *data ) || (info.fRemembered && search_params.fReturnRemembered) || (!info.fRemembered && search_params.fReturnUnknown); ok( matches, "Device does not match filter constraints\n" ); - trace( "device %lu: %02x:%02x:%02x:%02x:%02x:%02x\n", i, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5] ); + trace( "device %lu: %s\n", i, debugstr_bluetooth_address( info.Address.rgBytes) ); trace( " name: %s\n", debugstr_w( info.szName ) ); trace( " class: %#lx\n", info.ulClassofDevice ); trace( " connected: %d, authenticated: %d, remembered: %d\n", info.fConnected, info.fAuthenticated, @@ -134,6 +139,17 @@ void test_radio_BluetoothFindNextDevice( HANDLE radio, void *data ) if (GetTimeFormatEx( NULL, TIME_FORCE24HOURFORMAT, &info.stLastSeen, NULL, buf, ARRAY_SIZE( buf ) )) trace( " last seen: %s UTC\n", debugstr_w( buf ) );
+ info2.dwSize = sizeof( info2 ); + info2.Address = info.Address; + err = BluetoothGetDeviceInfo( radio, &info2 ); + ok( !err, "BluetoothGetDeviceInfo failed: %lu\n", err ); + ok( !memcmp( info2.Address.rgBytes, info.Address.rgBytes, sizeof( info.Address.rgBytes ) ), "%s != %s\n", + debugstr_bluetooth_address( info2.Address.rgBytes ), debugstr_bluetooth_address( info.Address.rgBytes ) ); + ok( !wcscmp( info2.szName, info.szName ), "%s != %s\n", debugstr_w( info2.szName ), debugstr_w( info.szName ) ); + ok( info2.fAuthenticated == info.fAuthenticated, "%d != %d\n", info.fAuthenticated, info.fAuthenticated ); + ok( info2.fRemembered == info.fRemembered, "%d != %d\n", info.fRemembered, info.fRemembered ); + ok( info2.fAuthenticated == info.fAuthenticated, "%d != %d\n", info.fAuthenticated, info.fAuthenticated ); + memset( &info, 0, sizeof( info )); info.dwSize = sizeof( info ); SetLastError( 0xdeadbeef );