Skip to content

Commit

Permalink
Add bindings for the IOBluetoothUI framework.
Browse files Browse the repository at this point in the history
Issue #381
  • Loading branch information
ronaldoussoren committed Jan 14, 2023
1 parent 494cd6f commit 5d6cf76
Show file tree
Hide file tree
Showing 23 changed files with 4,125 additions and 4 deletions.
15 changes: 15 additions & 0 deletions docs/apinotes/IOBluetoothUI.rst
@@ -0,0 +1,15 @@
API Notes: IOBluetoothUI framework
===================================

The full API is described in `Apple's documentation`__, both
the C and Objective-C APIs are available (but see the `API Notes`_ below).

.. __: https://developer.apple.com/documentation/iobluetoothui/?preferredLanguage=occ

These bindings are accessed through the ``IOBluetoothUI`` package (that is, ``import IOBluetoothUI``).


API Notes
---------

The full API is available from Python.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Expand Up @@ -336,7 +336,7 @@ improvements as described below).
``objc.NSDecimal(0)`` was interpreted as true-ish in boolean contexts, it now
is interpreted as false-ish just like other number types.

* Add bindings for the IOBluetooth framework
* :issue:`381`: Add bindings for the IOBluetooth and IOBluetoothUI frameworks

Version 9.0.1
-------------
Expand Down
3 changes: 2 additions & 1 deletion docs/notes/framework-wrappers.rst
Expand Up @@ -337,7 +337,7 @@ The framework name links to API notes for that framework, the python packages li
+--------------------------------------------------------------------------------------+------------------------------------------------------+-----------------------------------------+
| :doc:`IOBluetooth </apinotes/IOBluetooth>` | `pyobjc-framework-IOBluetooth`_ | |
+--------------------------------------------------------------------------------------+------------------------------------------------------+-----------------------------------------+
| IOBluetoothUI | - | Will not be wrapped. |
| :doc:`IOBluetoothUI </apinotes/IOBluetoothUI>` | `pyobjc-framework-IOBluetoothUI`_ | |
+--------------------------------------------------------------------------------------+------------------------------------------------------+-----------------------------------------+
| IOKit | - | Will not be wrapped. |
+--------------------------------------------------------------------------------------+------------------------------------------------------+-----------------------------------------+
Expand Down Expand Up @@ -788,3 +788,4 @@ prioritizing work.
.. _`pyobjc-framework-SafetyKit`: https://pypi.org/project/pyobjc-framework-SafetyKit/
.. _`pyobjc-framework-ThreadNetwork`: https://pypi.org/project/pyobjc-framework-ThreadNetwork/
.. _`pyobjc-framework-IOBluetooth`: https://pypi.org/project/pyobjc-framework-IOBluetooth/
.. _`pyobjc-framework-IOBluetoothUI`: https://pypi.org/project/pyobjc-framework-IOBluetoothUI/
2 changes: 1 addition & 1 deletion pyobjc-framework-IOBluetooth/Lib/IOBluetooth/__init__.py
Expand Up @@ -15,7 +15,7 @@

sys.modules["IOBluetooth"] = mod = objc.ObjCLazyModule(
"IOBluetooth",
"com.apple.IOBluetooth",
"com.apple.Bluetooth",
objc.pathForFramework("/System/Library/Frameworks/IOBluetooth.framework"),
_metadata.__dict__,
None,
Expand Down
1 change: 0 additions & 1 deletion pyobjc-framework-IOBluetooth/setup.py
Expand Up @@ -16,7 +16,6 @@
setup(
name="pyobjc-framework-IOBluetooth",
description="Wrappers for the framework IOBluetooth on macOS",
min_os_level="10.2",
packages=["IOBluetooth"],
ext_modules=[
Extension(
Expand Down
30 changes: 30 additions & 0 deletions pyobjc-framework-IOBluetoothUI/Lib/IOBluetoothUI/__init__.py
@@ -0,0 +1,30 @@
"""
Python mapping for the IOBluetoothUI framework.
This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
"""

import sys

import IOBluetooth
import objc
from . import _metadata


sys.modules["IOBluetoothUI"] = mod = objc.ObjCLazyModule(
"IOBluetoothUI",
"com.apple.BluetoothUI",
objc.pathForFramework("/System/Library/Frameworks/IOBluetoothUI.framework"),
_metadata.__dict__,
None,
{
"__doc__": __doc__,
"objc": objc,
"__path__": __path__,
"__loader__": globals().get("__loader__", None),
},
(IOBluetooth,),
)

del sys.modules["IOBluetoothUI._metadata"]
123 changes: 123 additions & 0 deletions pyobjc-framework-IOBluetoothUI/Lib/IOBluetoothUI/_metadata.py
@@ -0,0 +1,123 @@
# This file is generated by objective.metadata
#
# Last update: Sat Jan 14 21:30:00 2023
#
# flake8: noqa

import objc, sys
from typing import NewType

if sys.maxsize > 2**32:

def sel32or64(a, b):
return b

else:

def sel32or64(a, b):
return a


if objc.arch == "arm64":

def selAorI(a, b):
return a

else:

def selAorI(a, b):
return b


misc = {}
constants = """$$"""
enums = """$kBluetoothKeyboardANSIReturn@0$kBluetoothKeyboardISOReturn@1$kBluetoothKeyboardJISReturn@2$kBluetoothKeyboardNoReturn@3$kIOBluetoothServiceBrowserControllerOptionsAutoStartInquiry@1$kIOBluetoothServiceBrowserControllerOptionsDisconnectWhenDone@2$kIOBluetoothServiceBrowserControllerOptionsNone@0$kIOBluetoothUISuccess@-1000$kIOBluetoothUIUserCanceledErr@-1001$"""
misc.update(
{
"BluetoothKeyboardReturnType": NewType("BluetoothKeyboardReturnType", int),
"IOBluetoothServiceBrowserControllerOptions": NewType(
"IOBluetoothServiceBrowserControllerOptions", int
),
}
)
misc.update({})
misc.update({})
functions = {
"IOBluetoothGetDeviceSelectorController": (b"^{OpaqueIOBluetoothObjectRef=}",),
"IOBluetoothValidateHardwareWithDescription": (b"i^{__CFString=}^{__CFString=}",),
"IOBluetoothGetPairingController": (b"^{OpaqueIOBluetoothObjectRef=}",),
}
aliases = {
"IOBluetoothServiceBrowserControllerRef": "IOBluetoothObjectRef",
"IOBluetoothDeviceSelectorControllerRef": "IOBluetoothObjectRef",
"IOBluetoothPairingControllerRef": "IOBluetoothObjectRef",
}
r = objc.registerMetaDataForSelector
objc._updatingMetadata(True)
try:
r(
b"IOBluetoothDeviceSelectorController",
b"setSearchAttributes:",
{"arguments": {2: {"type_modifier": b"n"}}},
)
r(
b"IOBluetoothObjectPushUIController",
b"isTransferInProgress",
{"retval": {"type": b"Z"}},
)
r(
b"IOBluetoothPairingController",
b"setSearchAttributes:",
{"arguments": {2: {"type_modifier": b"n"}}},
)
r(b"IOBluetoothPasskeyDisplay", b"isIncomingRequest", {"retval": {"type": b"Z"}})
r(
b"IOBluetoothPasskeyDisplay",
b"setIsIncomingRequest:",
{"arguments": {2: {"type": b"Z"}}},
)
r(
b"IOBluetoothPasskeyDisplay",
b"setPasskey:forDevice:usingSSP:",
{"arguments": {4: {"type": b"Z"}}},
)
r(
b"IOBluetoothPasskeyDisplay",
b"setPasskeyIndicatorEnabled:",
{"arguments": {2: {"type": b"Z"}}},
)
r(
b"IOBluetoothPasskeyDisplay",
b"setUsePasskeyNotificaitons:",
{"arguments": {2: {"type": b"Z"}}},
)
r(
b"IOBluetoothPasskeyDisplay",
b"usePasskeyNotificaitons",
{"retval": {"type": b"Z"}},
)
r(
b"IOBluetoothServiceBrowserController",
b"discover:",
{"arguments": {2: {"type_modifier": b"o"}}},
)
r(
b"IOBluetoothServiceBrowserController",
b"discoverAsSheetForWindow:withRecord:",
{"arguments": {3: {"type_modifier": b"o"}}},
)
r(
b"IOBluetoothServiceBrowserController",
b"discoverWithDeviceAttributes:serviceList:serviceRecord:",
{"arguments": {2: {"type_modifier": b"n"}, 4: {"type_modifier": b"o"}}},
)
r(
b"IOBluetoothServiceBrowserController",
b"setSearchAttributes:",
{"arguments": {2: {"type_modifier": b"n"}}},
)
finally:
objc._updatingMetadata(False)
expressions = {}

# END OF FILE
10 changes: 10 additions & 0 deletions pyobjc-framework-IOBluetoothUI/License.txt
@@ -0,0 +1,10 @@
(This is the MIT license, note that libffi-src is a separate product with its own license)

Copyright 2002, 2003 - Bill Bumgarner, Ronald Oussoren, Steve Majewski, Lele Gaifax, et.al.
Copyright 2003-2022 - Ronald Oussoren

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 changes: 14 additions & 0 deletions pyobjc-framework-IOBluetoothUI/MANIFEST.in
@@ -0,0 +1,14 @@
include *.txt MANIFEST.in *.py
graft Doc
graft Examples
graft Lib
graft Modules
graft source-deps
graft PyObjCTest
graft metadata
global-exclude .DS_Store
global-exclude *.pyc
global-exclude *.pyo
global-exclude *.so
prune Lib/*/*.dSYM
prune PyObjCTest/*.dSYM
1 change: 1 addition & 0 deletions pyobjc-framework-IOBluetoothUI/PyObjCTest/__init__.py
@@ -0,0 +1 @@
""" test suite """
@@ -0,0 +1,10 @@
from PyObjCTools.TestSupport import TestCase

import IOBluetoothUI


class TestIOBluetoothObjectPushUIController(TestCase):
def test_methods(self):
self.assertResultIsBOOL(
IOBluetoothUI.IOBluetoothObjectPushUIController.isTransferInProgress
)
@@ -0,0 +1,10 @@
from PyObjCTools.TestSupport import TestCase

import IOBluetoothUI


class TestIOBluetoothPairingController(TestCase):
def test_methods(self):
self.assertArgIsIn(
IOBluetoothUI.IOBluetoothPairingController.setSearchAttributes_, 0
)
@@ -0,0 +1,17 @@
from PyObjCTools.TestSupport import TestCase

import IOBluetoothUI


class TestIOBluetoothPasskeyDisplay(TestCase):
def test_constants(self):
self.assertIsEnumType(IOBluetoothUI.BluetoothKeyboardReturnType)
self.assertEqual(IOBluetoothUI.kBluetoothKeyboardANSIReturn, 0)
self.assertEqual(IOBluetoothUI.kBluetoothKeyboardISOReturn, 1)
self.assertEqual(IOBluetoothUI.kBluetoothKeyboardJISReturn, 2)
self.assertEqual(IOBluetoothUI.kBluetoothKeyboardNoReturn, 3)

def test_methods(self):
self.assertArgIsBOOL(
IOBluetoothUI.IOBluetoothPasskeyDisplay.setPasskey_forDevice_usingSSP_, 2
)
@@ -0,0 +1,22 @@
from PyObjCTools.TestSupport import TestCase

import IOBluetoothUI


class TestIOBluetoothServiceBrowserController(TestCase):
def test_methods(self):
self.assertArgIsOut(
IOBluetoothUI.IOBluetoothServiceBrowserController.discover_, 0
)
self.assertArgIsOut(
IOBluetoothUI.IOBluetoothServiceBrowserController.discoverAsSheetForWindow_withRecord_,
1,
)
self.assertArgIsOut(
IOBluetoothUI.IOBluetoothServiceBrowserController.discoverWithDeviceAttributes_serviceList_serviceRecord_,
2,
)

self.assertArgIsIn(
IOBluetoothUI.IOBluetoothServiceBrowserController.setSearchAttributes_, 0
)
28 changes: 28 additions & 0 deletions pyobjc-framework-IOBluetoothUI/PyObjCTest/test_iobluetoothui.py
@@ -0,0 +1,28 @@
from PyObjCTools.TestSupport import TestCase

import IOBluetoothUI


class TestCallableMetadata(TestCase):
def test_callable_metadata_is_sane(self):
self.assertCallableMetadataIsSane(
IOBluetoothUI,
exclude_attrs={
(
"NSObject",
"isKeyExcludedFromWebScript_",
),
(
"NSObject",
"utf8ValueSafe_",
),
(
"NSObject",
"utf8ValueSafe",
),
(
"NSObject",
"newTaggedNSStringWithASCIIBytes__length__",
),
},
)
@@ -0,0 +1,41 @@
from PyObjCTools.TestSupport import TestCase

import IOBluetoothUI


class TestIOBluetoothUIUserLib(TestCase):
def test_types(self):
self.assertIs(
IOBluetoothUI.IOBluetoothDeviceSelectorControllerRef,
IOBluetoothUI.IOBluetoothObjectRef,
)
self.assertIs(
IOBluetoothUI.IOBluetoothPairingControllerRef,
IOBluetoothUI.IOBluetoothObjectRef,
)
self.assertIs(
IOBluetoothUI.IOBluetoothServiceBrowserControllerRef,
IOBluetoothUI.IOBluetoothObjectRef,
)

def test_constants(self):
self.assertIsEnumType(IOBluetoothUI.IOBluetoothServiceBrowserControllerOptions)
self.assertEqual(
IOBluetoothUI.kIOBluetoothServiceBrowserControllerOptionsNone, 0
)
self.assertEqual(
IOBluetoothUI.kIOBluetoothServiceBrowserControllerOptionsAutoStartInquiry,
1 << 0,
)
self.assertEqual(
IOBluetoothUI.kIOBluetoothServiceBrowserControllerOptionsDisconnectWhenDone,
1 << 1,
)

self.assertEqual(IOBluetoothUI.kIOBluetoothUISuccess, -1000)
self.assertEqual(IOBluetoothUI.kIOBluetoothUIUserCanceledErr, -1001)

def test_functions(self):
IOBluetoothUI.IOBluetoothValidateHardwareWithDescription
IOBluetoothUI.IOBluetoothGetPairingController
IOBluetoothUI.IOBluetoothGetDeviceSelectorController

0 comments on commit 5d6cf76

Please sign in to comment.