From: Vibhav Pant vibhavp@gmail.com
--- include/Makefile.in | 1 + include/windows.networking.sockets.idl | 49 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 include/windows.networking.sockets.idl
diff --git a/include/Makefile.in b/include/Makefile.in index ab4957969d3..ca2854610ee 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -894,6 +894,7 @@ SOURCES = \ windows.media.speechrecognition.idl \ windows.media.speechsynthesis.idl \ windows.networking.connectivity.idl \ + windows.networking.sockets.idl \ windows.networking.idl \ windows.perception.spatial.idl \ windows.perception.spatial.surfaces.idl \ diff --git a/include/windows.networking.sockets.idl b/include/windows.networking.sockets.idl new file mode 100644 index 00000000000..21a26da4243 --- /dev/null +++ b/include/windows.networking.sockets.idl @@ -0,0 +1,49 @@ +/* + * Copyright 2025 Vibhav Pant + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "windowscontracts.idl"; + +namespace Windows.Networking.Sockets { + typedef enum SocketProtectionLevel SocketProtectionLevel; + + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + enum SocketProtectionLevel + { + PlainSocket = 0, + Ssl = 1, + SslAllowNullEncryption = 2, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + BluetoothEncryptionAllowNullAuthentication = 3, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + BluetoothEncryptionWithAuthentication = 4, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + Ssl3AllowWeakEncryption = 5, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + Tls10 = 6, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + Tls11 = 7, + [contract(Windows.Foundation.UniversalApiContract, 1.0)] + Tls12 = 8, + [contract(Windows.Foundation.UniversalApiContract, 5.0)] + Unspecified = 9 + }; +}
From: Vibhav Pant vibhavp@gmail.com
--- include/Makefile.in | 1 + include/windows.devices.bluetooth.rfcomm.idl | 103 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 include/windows.devices.bluetooth.rfcomm.idl
diff --git a/include/Makefile.in b/include/Makefile.in index ca2854610ee..9e048bf2d77 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -857,6 +857,7 @@ SOURCES = \ windows.applicationmodel.idl \ windows.data.json.idl \ windows.data.xml.dom.idl \ + windows.devices.bluetooth.rfcomm.idl \ windows.devices.bluetooth.idl \ windows.devices.enumeration.idl \ windows.devices.geolocation.idl \ diff --git a/include/windows.devices.bluetooth.rfcomm.idl b/include/windows.devices.bluetooth.rfcomm.idl new file mode 100644 index 00000000000..2bac68279a0 --- /dev/null +++ b/include/windows.devices.bluetooth.rfcomm.idl @@ -0,0 +1,103 @@ +/* + * Copyright 2025 Vibhav Pant + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +import "windows.devices.bluetooth.idl"; +import "windows.networking.idl"; +import "windows.networking.sockets.idl"; +import "windows.storage.streams.idl"; + +namespace Windows.Devices.Bluetooth.Rfcomm { + interface IRfcommDeviceService; + interface IRfcommDeviceService2; + interface IRfcommDeviceService3; + interface IRfcommDeviceServiceStatics; + interface IRfcommServiceId; + interface IRfcommServiceIdStatics; + + runtimeclass RfcommDeviceService; + runtimeclass RfcommServiceId; + + declare { + interface Windows.Foundation.Collections.IMapView<UINT32, Windows.Storage.Streams.IBuffer *>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Foundation.Collections.IMapView<UINT32, Windows.Storage.Streams.IBuffer *> *>; + interface Windows.Foundation.IAsyncOperation<Windows.Foundation.Collections.IMapView<UINT32, Windows.Storage.Streams.IBuffer *> *>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService *>; + interface Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService *>; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService), + uuid(ae81ff1f-c5a1-4c40-8c28-f3efd69062f3) + ] + interface IRfcommDeviceService : IInspectable + { + [propget] HRESULT ConnectionHostName([out, retval] Windows.Networking.HostName **value); + [propget] HRESULT ConnectionServiceName([out, retval] HSTRING *value); + [propget] HRESULT ServiceId([out, retval] Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId **value); + [propget] HRESULT ProtectionLevel([out, retval] Windows.Networking.Sockets.SocketProtectionLevel *value); + [propget] HRESULT MaxProtectionLevel([out, retval] Windows.Networking.Sockets.SocketProtectionLevel *value); + [overload("GetSdpRawAttributesAsync")] HRESULT GetSdpRawAttributesAsync([out, retval] Windows.Foundation.IAsyncOperation<Windows.Foundation.Collections.IMapView<UINT32, Windows.Storage.Streams.IBuffer *> *> **operation); + [overload("GetSdpRawAttributesAsync")] HRESULT GetSdpRawAttributesWithCacheModeAsync([in] Windows.Devices.Bluetooth.BluetoothCacheMode cacheMode, [out, retval] Windows.Foundation.IAsyncOperation<Windows.Foundation.Collections.IMapView<UINT32, Windows.Storage.Streams.IBuffer *> *> **operation); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService), + uuid(a4a149ef-626d-41ac-b253-87ac5c27e28a) + ] + interface IRfcommDeviceServiceStatics : IInspectable + { + HRESULT FromIdAsync([in] HSTRING id, [out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService *> **operation); + HRESULT GetDeviceSelector([in] Windows.Devices.Bluetooth.Rfcomm.RfcommServiceId *id, [out] [retval] HSTRING *selector); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Devices.Bluetooth.Rfcomm.IRfcommDeviceServiceStatics, Windows.Foundation.UniversalApiContract, 1.0), + threading(both) + ] + runtimeclass RfcommDeviceService + { + [default] interface Windows.Devices.Bluetooth.Rfcomm.IRfcommDeviceService; + interface Windows.Devices.Bluetooth.Rfcomm.IRfcommDeviceService2; + interface Windows.Foundation.IClosable; + [contract(Windows.Foundation.UniversalApiContract, 3.0)] interface Windows.Devices.Bluetooth.Rfcomm.IRfcommDeviceService3; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Devices.Bluetooth.Rfcomm.IRfcommServiceIdStatics, Windows.Foundation.UniversalApiContract, 1.0), + threading(both) + ] + runtimeclass RfcommServiceId + { + [default] interface Windows.Devices.Bluetooth.Rfcomm.IRfcommServiceId; + } +}
From: Vibhav Pant vibhavp@gmail.com
--- dlls/windows.devices.bluetooth/classes.idl | 17 ++ include/windows.devices.bluetooth.idl | 240 ++++++++++++++++++- include/windows.devices.bluetooth.rfcomm.idl | 6 + 3 files changed, 261 insertions(+), 2 deletions(-)
diff --git a/dlls/windows.devices.bluetooth/classes.idl b/dlls/windows.devices.bluetooth/classes.idl index 448b3920d4e..4ed8641d5f6 100644 --- a/dlls/windows.devices.bluetooth/classes.idl +++ b/dlls/windows.devices.bluetooth/classes.idl @@ -20,4 +20,21 @@
#pragma makedep register
+#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +import "windows.devices.enumeration.idl"; +import "windows.devices.radios.idl"; +import "windows.networking.idl"; +import "windows.networking.sockets.idl"; +import "windows.storage.streams.idl"; + +#define DO_NO_IMPORTS +#include "windows.devices.bluetooth.rfcomm.idl" #include "windows.devices.bluetooth.idl" diff --git a/include/windows.devices.bluetooth.idl b/include/windows.devices.bluetooth.idl index c3b64ce058a..0cd8b3d4918 100644 --- a/include/windows.devices.bluetooth.idl +++ b/include/windows.devices.bluetooth.idl @@ -20,31 +20,184 @@ #pragma winrt ns_prefix #endif
+#ifndef DO_NO_IMPORTS import "inspectable.idl"; import "asyncinfo.idl"; import "eventtoken.idl"; import "windowscontracts.idl"; import "windows.foundation.idl"; /* import "windows.devices.bluetooth.genericattributeprofile.idl"; */ -/* import "windows.devices.bluetooth.rfcomm.idl"; */ +import "windows.devices.bluetooth.rfcomm.idl"; import "windows.devices.enumeration.idl"; import "windows.devices.radios.idl"; -/* import "windows.networking.idl"; */ +import "windows.networking.idl"; import "windows.storage.streams.idl"; +#endif
namespace Windows.Devices.Bluetooth { + typedef enum BluetoothConnectionStatus BluetoothConnectionStatus; + typedef enum BluetoothMajorClass BluetoothMajorClass; + typedef enum BluetoothMinorClass BluetoothMinorClass; + typedef enum BluetoothServiceCapabilities BluetoothServiceCapabilities; + interface IBluetoothAdapter; interface IBluetoothAdapter2; interface IBluetoothAdapter3; interface IBluetoothAdapterStatics; + interface IBluetoothClassOfDevice; + interface IBluetoothClassOfDeviceStatics; + interface IBluetoothDevice; + interface IBluetoothDeviceStatics;
runtimeclass BluetoothAdapter; + runtimeclass BluetoothClassOfDevice; + runtimeclass BluetoothDevice; + + namespace Rfcomm { + runtimeclass RfcommDeviceService; + }
declare { interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Bluetooth.BluetoothAdapter *>; interface Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.BluetoothAdapter *>; + interface Windows.Foundation.TypedEventHandler<Windows.Devices.Bluetooth.BluetoothDevice *, IInspectable *>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Devices.Bluetooth.BluetoothDevice *>; + interface Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.BluetoothDevice *>; + interface Windows.Foundation.Collections.IVectorView<Windows.Storage.Streams.IBuffer *>; + interface Windows.Foundation.Collections.IVectorView<Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService *>; }
+ [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum BluetoothCacheMode + { + Cached = 0, + Uncached = 1 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum BluetoothConnectionStatus + { + Disconnected = 0, + Connected = 1 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum BluetoothMajorClass + { + Miscellaneous = 0, + Computer = 1, + Phone = 2, + NetworkAccessPoint = 3, + AudioVideo = 4, + Peripheral = 5, + Imaging = 6, + Wearable = 7, + Toy = 8, + Health = 9 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum BluetoothMinorClass + { + Uncategorized = 0, + ComputerDesktop = 1, + ComputerServer = 2, + ComputerLaptop = 3, + ComputerHandheld = 4, + ComputerPalmSize = 5, + ComputerWearable = 6, + ComputerTablet = 7, + PhoneCellular = 1, + PhoneCordless = 2, + PhoneSmartPhone = 3, + PhoneWired = 4, + PhoneIsdn = 5, + NetworkFullyAvailable = 0, + NetworkUsed01To17Percent = 8, + NetworkUsed17To33Percent = 16, + NetworkUsed33To50Percent = 24, + NetworkUsed50To67Percent = 32, + NetworkUsed67To83Percent = 40, + NetworkUsed83To99Percent = 48, + NetworkNoServiceAvailable = 56, + AudioVideoWearableHeadset = 1, + AudioVideoHandsFree = 2, + AudioVideoMicrophone = 4, + AudioVideoLoudspeaker = 5, + AudioVideoHeadphones = 6, + AudioVideoPortableAudio = 7, + AudioVideoCarAudio = 8, + AudioVideoSetTopBox = 9, + AudioVideoHifiAudioDevice = 10, + AudioVideoVcr = 11, + AudioVideoVideoCamera = 12, + AudioVideoCamcorder = 13, + AudioVideoVideoMonitor = 14, + AudioVideoVideoDisplayAndLoudspeaker = 15, + AudioVideoVideoConferencing = 16, + AudioVideoGamingOrToy = 18, + PeripheralJoystick = 1, + PeripheralGamepad = 2, + PeripheralRemoteControl = 3, + PeripheralSensing = 4, + PeripheralDigitizerTablet = 5, + PeripheralCardReader = 6, + PeripheralDigitalPen = 7, + PeripheralHandheldScanner = 8, + PeripheralHandheldGesture = 9, + WearableWristwatch = 1, + WearablePager = 2, + WearableJacket = 3, + WearableHelmet = 4, + WearableGlasses = 5, + ToyRobot = 1, + ToyVehicle = 2, + ToyDoll = 3, + ToyController = 4, + ToyGame = 5, + HealthBloodPressureMonitor = 1, + HealthThermometer = 2, + HealthWeighingScale = 3, + HealthGlucoseMeter = 4, + HealthPulseOximeter = 5, + HealthHeartRateMonitor = 6, + HealthHealthDataDisplay = 7, + HealthStepCounter = 8, + HealthBodyCompositionAnalyzer = 9, + HealthPeakFlowMonitor = 10, + HealthMedicationMonitor = 11, + HealthKneeProsthesis = 12, + HealthAnkleProsthesis = 13, + HealthGenericHealthManager = 14, + HealthPersonalMobilityDevice = 15 + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + flags + ] + enum BluetoothServiceCapabilities + { + None = 0x0, + LimitedDiscoverableMode = 0x1, + PositioningService = 0x8, + NetworkingService = 0x10, + RenderingService = 0x20, + CapturingService = 0x40, + ObjectTransferService = 0x80, + AudioService = 0x100, + TelephoneService = 0x200, + InformationService = 0x400 + }; + [ contract(Windows.Foundation.UniversalApiContract, 4.0), exclusiveto(Windows.Devices.Bluetooth.BluetoothAdapter), @@ -86,4 +239,87 @@ namespace Windows.Devices.Bluetooth { [contract(Windows.Foundation.UniversalApiContract, 6.0)] interface Windows.Devices.Bluetooth.IBluetoothAdapter2; [contract(Windows.Foundation.UniversalApiContract, 10.0)] interface Windows.Devices.Bluetooth.IBluetoothAdapter3; } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Devices.Bluetooth.BluetoothClassOfDevice), + uuid(d640227e-d7d7-4661-9454-65039ca17a2b) + ] + interface IBluetoothClassOfDevice : IInspectable + { + [propget] HRESULT RawValue([out, retval] UINT32 *value); + [propget] HRESULT MajorClass([out, retval] Windows.Devices.Bluetooth.BluetoothMajorClass *value); + [propget] HRESULT MinorClass([out, retval] Windows.Devices.Bluetooth.BluetoothMinorClass *value); + [propget] HRESULT ServiceCapabilities([out, retval] Windows.Devices.Bluetooth.BluetoothServiceCapabilities *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Devices.Bluetooth.BluetoothClassOfDevice), + uuid(e46135bd-0fa2-416c-91b4-c1e48ca061c1) + ] + interface IBluetoothClassOfDeviceStatics : IInspectable + { + HRESULT FromRawValue([in] UINT32 rawValue, [out, retval] Windows.Devices.Bluetooth.BluetoothClassOfDevice **cod); + HRESULT FromParts([in] Windows.Devices.Bluetooth.BluetoothMajorClass major, [in] Windows.Devices.Bluetooth.BluetoothMinorClass minor, [in] Windows.Devices.Bluetooth.BluetoothServiceCapabilities capabilities, [out, retval] Windows.Devices.Bluetooth.BluetoothClassOfDevice **cod); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Devices.Bluetooth.IBluetoothClassOfDeviceStatics, Windows.Foundation.UniversalApiContract, 1.0), + threading(both) + ] + runtimeclass BluetoothClassOfDevice + { + [default] interface Windows.Devices.Bluetooth.IBluetoothClassOfDevice; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Devices.Bluetooth.BluetoothDevice), + uuid(2335b156-90d2-4a04-aef5-0e20b9e6b707) + ] + interface IBluetoothDevice : IInspectable + { + [propget] HRESULT DeviceId([out, retval] HSTRING *value); + [propget] HRESULT HostName([out, retval] Windows.Networking.HostName **value); + [propget] HRESULT Name([out, retval] HSTRING *value); + [propget] HRESULT ClassOfDevice([out, retval] Windows.Devices.Bluetooth.BluetoothClassOfDevice **value); + [propget] HRESULT SdpRecords([out, retval] Windows.Foundation.Collections.IVectorView<Windows.Storage.Streams.IBuffer *> **value); + [propget] HRESULT RfcommServices([out, retval] Windows.Foundation.Collections.IVectorView<Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService *> **value); + [propget] HRESULT ConnectionStatus([out, retval] Windows.Devices.Bluetooth.BluetoothConnectionStatus *value); + [propget] HRESULT BluetoothAddress([out, retval] UINT64 *value); + [eventadd] HRESULT NameChanged([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Bluetooth.BluetoothDevice *, IInspectable *> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT NameChanged([in] EventRegistrationToken token); + [eventadd] HRESULT SdpRecordsChanged([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Bluetooth.BluetoothDevice*, IInspectable*> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT SdpRecordsChanged([in] EventRegistrationToken token); + [eventadd] HRESULT ConnectionStatusChanged([in] Windows.Foundation.TypedEventHandler<Windows.Devices.Bluetooth.BluetoothDevice*, IInspectable*> *handler, [out, retval] EventRegistrationToken *token); + [eventremove] HRESULT ConnectionStatusChanged([in] EventRegistrationToken token); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Devices.Bluetooth.BluetoothDevice), + uuid(0991df51-57db-4725-bbd7-84f64327ec2c) + ] + interface IBluetoothDeviceStatics : IInspectable + { + HRESULT FromIdAsync([in] HSTRING id, [out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.BluetoothDevice *> **operation); + HRESULT FromHostNameAsync([in] Windows.Networking.HostName *name, [out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.BluetoothDevice *> **operation); + HRESULT FromBluetoothAddressAsync([in] UINT64 address, [out, retval] Windows.Foundation.IAsyncOperation<Windows.Devices.Bluetooth.BluetoothDevice *> **operation); + HRESULT GetDeviceSelector([out, retval] HSTRING *selector); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Devices.Bluetooth.IBluetoothDeviceStatics, Windows.Foundation.UniversalApiContract, 1.0), + threading(both) + ] + runtimeclass BluetoothDevice + { + [default] interface Windows.Devices.Bluetooth.IBluetoothDevice; + interface Windows.Foundation.IClosable; + } } diff --git a/include/windows.devices.bluetooth.rfcomm.idl b/include/windows.devices.bluetooth.rfcomm.idl index 2bac68279a0..0b076280af8 100644 --- a/include/windows.devices.bluetooth.rfcomm.idl +++ b/include/windows.devices.bluetooth.rfcomm.idl @@ -20,6 +20,7 @@ #pragma winrt ns_prefix #endif
+#ifndef DO_NO_IMPORTS import "inspectable.idl"; import "asyncinfo.idl"; import "eventtoken.idl"; @@ -29,6 +30,11 @@ import "windows.devices.bluetooth.idl"; import "windows.networking.idl"; import "windows.networking.sockets.idl"; import "windows.storage.streams.idl"; +#endif + +namespace Windows.Devices.Bluetooth { + typedef enum BluetoothCacheMode BluetoothCacheMode; +}
namespace Windows.Devices.Bluetooth.Rfcomm { interface IRfcommDeviceService;
From: Vibhav Pant vibhavp@gmail.com
--- .../tests/bluetooth.c | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/dlls/windows.devices.bluetooth/tests/bluetooth.c b/dlls/windows.devices.bluetooth/tests/bluetooth.c index 58ce063c50a..3dbb4b77d91 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -95,6 +95,45 @@ static void test_BluetoothAdapterStatics(void) ok( ref == 1, "got ref %ld.\n", ref ); }
+static void test_BluetoothDeviceStatics( void ) +{ + static const WCHAR *class_name = RuntimeClass_Windows_Devices_Bluetooth_BluetoothDevice; + IBluetoothDeviceStatics *statics; + IActivationFactory *factory; + HSTRING str; + HRESULT hr; + + WindowsCreateString( class_name, wcslen( class_name ), &str ); + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void *)&factory ); + WindowsDeleteString( str ); + todo_wine ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); + if (hr == REGDB_E_CLASSNOTREG) + { + win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) ); + return; + } + check_interface( factory, &IID_IUnknown ); + check_interface( factory, &IID_IInspectable ); + check_interface( factory, &IID_IAgileObject ); + + hr = IActivationFactory_QueryInterface( factory, &IID_IBluetoothDeviceStatics, (void **)&statics ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + IActivationFactory_Release( factory ); + if (FAILED( hr )) + { + skip( "BluetoothAdapterStatics not available.\n" ); + return; + } + + str = NULL; + hr = IBluetoothDeviceStatics_GetDeviceSelector( statics, &str ); + todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); + todo_wine ok( !WindowsIsStringEmpty( str ), "got empty device selector string.\n" ); + WindowsDeleteString( str ); + + IBluetoothDeviceStatics_Release( statics ); +} + START_TEST(bluetooth) { HRESULT hr; @@ -103,6 +142,7 @@ START_TEST(bluetooth) ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr );
test_BluetoothAdapterStatics(); + test_BluetoothDeviceStatics();
RoUninitialize(); }
From: Vibhav Pant vibhavp@gmail.com
--- dlls/windows.devices.bluetooth/Makefile.in | 1 + .../bluetoothdevice.c | 165 ++++++++++++++++++ dlls/windows.devices.bluetooth/main.c | 2 + dlls/windows.devices.bluetooth/private.h | 3 + .../tests/bluetooth.c | 2 +- 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 dlls/windows.devices.bluetooth/bluetoothdevice.c
diff --git a/dlls/windows.devices.bluetooth/Makefile.in b/dlls/windows.devices.bluetooth/Makefile.in index 216c1f7ae9b..89f3fc78abc 100644 --- a/dlls/windows.devices.bluetooth/Makefile.in +++ b/dlls/windows.devices.bluetooth/Makefile.in @@ -3,5 +3,6 @@ IMPORTS = combase
SOURCES = \ bluetoothadapter.c \ + bluetoothdevice.c \ classes.idl \ main.c diff --git a/dlls/windows.devices.bluetooth/bluetoothdevice.c b/dlls/windows.devices.bluetooth/bluetoothdevice.c new file mode 100644 index 00000000000..6eff705c352 --- /dev/null +++ b/dlls/windows.devices.bluetooth/bluetoothdevice.c @@ -0,0 +1,165 @@ +/* BluetoothDevice Implementation + * + * Copyright 2025 Vibhav Pant + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL( bluetooth ); + +struct bluetoothdevice_statics +{ + IActivationFactory IActivationFactory_iface; + IBluetoothDeviceStatics IBluetoothDeviceStatics_iface; + LONG ref; +}; + +static inline struct bluetoothdevice_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct bluetoothdevice_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct bluetoothdevice_statics *impl = impl_from_IActivationFactory( iface ); + + TRACE( "(%p, %s, %p) %ld\n", iface, debugstr_guid( iid ), out, impl->ref ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IActivationFactory )) + { + IActivationFactory_AddRef(( *out = &impl->IActivationFactory_iface )); + return S_OK; + } + if (IsEqualGUID( iid, &IID_IBluetoothDeviceStatics)) + { + IBluetoothDeviceStatics_AddRef(( *out = &impl->IBluetoothDeviceStatics_iface )); + return S_OK; + } + *out = NULL; + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +{ + struct bluetoothdevice_statics *impl = impl_from_IActivationFactory( iface ); + TRACE( "(%p)\n", iface ); + return InterlockedIncrement( &impl->ref ); +} + +static ULONG WINAPI factory_Release( IActivationFactory *iface ) +{ + struct bluetoothdevice_statics *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "(%p)\n", iface ); + return ref; +} + +static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "(%p, %p, %p): stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +{ + FIXME( "(%p, %p): stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *level ) +{ + FIXME( "(%p, %p): stub!\n", iface, level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +{ + FIXME( "(%p, %p): stub!\n", iface, instance ); + return E_NOTIMPL; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory */ + factory_ActivateInstance +}; + +DEFINE_IINSPECTABLE( bluetoothdevice_statics, IBluetoothDeviceStatics, struct bluetoothdevice_statics, IActivationFactory_iface ); + +static HRESULT WINAPI bluetoothdevice_statics_FromIdAsync( IBluetoothDeviceStatics *iface, HSTRING id, IAsyncOperation_BluetoothDevice **async_op ) +{ + FIXME( "(%p, %s, %p): stub!\n", iface, debugstr_hstring( id ), async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothdevice_statics_FromHostNameAsync( IBluetoothDeviceStatics *iface, IHostName *name, IAsyncOperation_BluetoothDevice **async_op ) +{ + FIXME( "(%p, %p, %p): stub!\n", iface, name, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothdevice_statics_FromBluetoothAddressAsync( IBluetoothDeviceStatics *iface, + UINT64 address, + IAsyncOperation_BluetoothDevice **async_op ) +{ + FIXME( "(%p, %#I64x, %p): stub!\n", iface, address, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI bluetoothdevice_statics_GetDeviceSelector( IBluetoothDeviceStatics *iface, HSTRING *value ) +{ + FIXME( "(%p, %p): stub!\n", iface, value ); + *value = NULL; + return E_NOTIMPL; +} + +static const IBluetoothDeviceStaticsVtbl bluetoothdevice_statics_vtbl = +{ + bluetoothdevice_statics_QueryInterface, + bluetoothdevice_statics_AddRef, + bluetoothdevice_statics_Release, + /* IInspectable */ + bluetoothdevice_statics_GetIids, + bluetoothdevice_statics_GetRuntimeClassName, + bluetoothdevice_statics_GetTrustLevel, + /* IBluetoothDeviceStatics */ + bluetoothdevice_statics_FromIdAsync, + bluetoothdevice_statics_FromHostNameAsync, + bluetoothdevice_statics_FromBluetoothAddressAsync, + bluetoothdevice_statics_GetDeviceSelector, +}; + +static struct bluetoothdevice_statics bluetoothdevice_statics = +{ + {&factory_vtbl}, + {&bluetoothdevice_statics_vtbl}, + 1 +}; + +IActivationFactory *bluetoothdevice_statics_factory = &bluetoothdevice_statics.IActivationFactory_iface; diff --git a/dlls/windows.devices.bluetooth/main.c b/dlls/windows.devices.bluetooth/main.c index d4e608d2f1f..b94599103a8 100644 --- a/dlls/windows.devices.bluetooth/main.c +++ b/dlls/windows.devices.bluetooth/main.c @@ -40,6 +40,8 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **fa
if (!wcscmp( buffer, RuntimeClass_Windows_Devices_Bluetooth_BluetoothAdapter )) IActivationFactory_QueryInterface( bluetoothadapter_factory, &IID_IActivationFactory, (void **)factory ); + if (!wcscmp( buffer, RuntimeClass_Windows_Devices_Bluetooth_BluetoothDevice )) + IActivationFactory_QueryInterface( bluetoothdevice_statics_factory, &IID_IActivationFactory, (void **)factory );
if (*factory) return S_OK; return CLASS_E_CLASSNOTAVAILABLE; diff --git a/dlls/windows.devices.bluetooth/private.h b/dlls/windows.devices.bluetooth/private.h index 746aa1e66ee..3b81cb319a8 100644 --- a/dlls/windows.devices.bluetooth/private.h +++ b/dlls/windows.devices.bluetooth/private.h @@ -32,10 +32,13 @@ #define WIDL_using_Windows_Foundation #define WIDL_using_Windows_Foundation_Collections #include "windows.foundation.h" +#define WIDL_using_Windows_Networking +#include "windows.networking.h" #define WIDL_using_Windows_Devices_Bluetooth #include "windows.devices.bluetooth.h"
extern IActivationFactory *bluetoothadapter_factory; +extern IActivationFactory *bluetoothdevice_statics_factory;
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ static inline impl_type *impl_from( iface_type *iface ) \ diff --git a/dlls/windows.devices.bluetooth/tests/bluetooth.c b/dlls/windows.devices.bluetooth/tests/bluetooth.c index 3dbb4b77d91..1ded17982ff 100644 --- a/dlls/windows.devices.bluetooth/tests/bluetooth.c +++ b/dlls/windows.devices.bluetooth/tests/bluetooth.c @@ -106,7 +106,7 @@ static void test_BluetoothDeviceStatics( void ) WindowsCreateString( class_name, wcslen( class_name ), &str ); hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void *)&factory ); WindowsDeleteString( str ); - todo_wine ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); + ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr ); if (hr == REGDB_E_CLASSNOTREG) { win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) );