summarylogtreecommitdiffstats
path: root/dbus-fixes.patch
blob: 045bdce212674a42813f19aca0cfb272ec3c4a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
From 945b8ca24ed6646ce798d19b4a92d1b414a76599 Mon Sep 17 00:00:00 2001
From: Boris Yumankulov <boria138@altlinux.org>
Date: Fri, 17 Apr 2026 14:52:06 +0500
Subject: [PATCH] fix: drop dbus-fast annotations from bluetooth agent

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
---
 portprotonqt/system_manager/bluetooth.py | 66 +++++++++++++++++++-----
 1 file changed, 54 insertions(+), 12 deletions(-)

diff --git a/portprotonqt/system_manager/bluetooth.py b/portprotonqt/system_manager/bluetooth.py
index 23f070b..c7a21da 100644
--- a/portprotonqt/system_manager/bluetooth.py
+++ b/portprotonqt/system_manager/bluetooth.py
@@ -3,11 +3,39 @@
 import re
 import threading
 import time
+from collections.abc import Callable
+from typing import Any, cast
 
 from PySide6.QtCore import QThread, Signal
-from dbus_fast import DBusError
-from dbus_fast.annotations import DBusObjectPath, DBusStr, DBusUInt16, DBusUInt32
-from dbus_fast.service import ServiceInterface, method
+
+try:
+    from dbus_fast import DBusError as _DBusError
+    from dbus_fast.service import ServiceInterface as _ServiceInterface
+    from dbus_fast.service import method as _method
+except ModuleNotFoundError:
+    class DBusError(Exception):
+        """Fallback D-Bus error when dbus-fast is unavailable."""
+
+    class ServiceInterface:
+        """Fallback service interface for environments without dbus-fast."""
+
+        def __init__(self, _name: str) -> None:
+            return None
+
+    def method(
+        name: str | None = None,
+        disabled: bool = False,
+    ) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
+        del name, disabled
+
+        def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
+            return func
+
+        return decorator
+else:
+    DBusError = cast(Any, _DBusError)
+    ServiceInterface = cast(Any, _ServiceInterface)
+    method = cast(Any, _method)
 
 from portprotonqt.localization import _
 from portprotonqt.logger import get_logger
@@ -42,7 +70,7 @@ class BluezPairingAgent(ServiceInterface):
         self._service = service
 
     @method()
-    def RequestPinCode(self, device: DBusObjectPath) -> DBusStr:
+    def RequestPinCode(self, device: str) -> str:
         response = self._service._request_pairing_input(
             _("Bluetooth PIN code"),
             _("Enter the Bluetooth PIN code shown on the device"),
@@ -53,11 +81,11 @@ class BluezPairingAgent(ServiceInterface):
         return response
 
     @method()
-    def DisplayPinCode(self, _device: DBusObjectPath, _pincode: DBusStr) -> None:
+    def DisplayPinCode(self, _device: str, _pincode: str) -> None:
         return None
 
     @method()
-    def RequestPasskey(self, device: DBusObjectPath) -> DBusUInt32:
+    def RequestPasskey(self, device: str) -> int:
         response = self._service._request_pairing_input(
             _("Bluetooth passkey"),
             _("Enter the Bluetooth passkey shown on the device"),
@@ -70,25 +98,25 @@ class BluezPairingAgent(ServiceInterface):
     @method()
     def DisplayPasskey(
         self,
-        _device: DBusObjectPath,
-        _passkey: DBusUInt32,
-        _entered: DBusUInt16,
+        _device: str,
+        _passkey: int,
+        _entered: int,
     ) -> None:
         return None
 
     @method()
-    def RequestConfirmation(self, device: DBusObjectPath, passkey: DBusUInt32) -> None:
+    def RequestConfirmation(self, device: str, passkey: int) -> None:
         message = _("Confirm the passkey on devices: {0}").format(f"{int(passkey):06d}")
         approved = self._service._request_pairing_confirm(message, str(device))
         if not approved:
             raise DBusError("org.bluez.Error.Rejected", "Bluetooth pairing confirmation rejected")
 
     @method()
-    def RequestAuthorization(self, _device: DBusObjectPath) -> None:
+    def RequestAuthorization(self, _device: str) -> None:
         return None
 
     @method()
-    def AuthorizeService(self, _device: DBusObjectPath, _uuid: DBusStr) -> None:
+    def AuthorizeService(self, _device: str, _uuid: str) -> None:
         return None
 
     @method()
@@ -96,6 +124,20 @@ class BluezPairingAgent(ServiceInterface):
         return None
 
 
+BluezPairingAgent.RequestPinCode.__annotations__ = {"device": "o", "return": "s"}
+BluezPairingAgent.DisplayPinCode.__annotations__ = {"_device": "o", "_pincode": "s"}
+BluezPairingAgent.RequestPasskey.__annotations__ = {"device": "o", "return": "u"}
+BluezPairingAgent.DisplayPasskey.__annotations__ = {
+    "_device": "o",
+    "_passkey": "u",
+    "_entered": "q",
+}
+BluezPairingAgent.RequestConfirmation.__annotations__ = {"device": "o", "passkey": "u"}
+BluezPairingAgent.RequestAuthorization.__annotations__ = {"_device": "o"}
+BluezPairingAgent.AuthorizeService.__annotations__ = {"_device": "o", "_uuid": "s"}
+BluezPairingAgent.Cancel.__annotations__ = {}
+
+
 class BluetoothManagerWorker(QThread):
     """Run Bluetooth actions outside the UI thread."""
 
From d76f06d0b65cb26326bc881707fd49dd32f572a2 Mon Sep 17 00:00:00 2001
From: Boris Yumankulov <boria138@altlinux.org>
Date: Fri, 17 Apr 2026 15:36:08 +0500
Subject: [PATCH] fix: use Annotated DBus signatures in bluetooth agent

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
---
 portprotonqt/system_manager/bluetooth.py | 46 ++++++++++++++++++------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/portprotonqt/system_manager/bluetooth.py b/portprotonqt/system_manager/bluetooth.py
index c7a21da..eba3a83 100644
--- a/portprotonqt/system_manager/bluetooth.py
+++ b/portprotonqt/system_manager/bluetooth.py
@@ -4,12 +4,13 @@ import re
 import threading
 import time
 from collections.abc import Callable
-from typing import Any, cast
+from typing import Annotated, Any, cast
 
 from PySide6.QtCore import QThread, Signal
 
 try:
     from dbus_fast import DBusError as _DBusError
+    from dbus_fast.annotations import DBusSignature as _DBusSignature
     from dbus_fast.service import ServiceInterface as _ServiceInterface
     from dbus_fast.service import method as _method
 except ModuleNotFoundError:
@@ -32,8 +33,15 @@ except ModuleNotFoundError:
             return func
 
         return decorator
+
+    class DBusSignature:
+        """Fallback D-Bus signature holder when dbus-fast is unavailable."""
+
+        def __init__(self, signature: str) -> None:
+            self.signature = signature
 else:
     DBusError = cast(Any, _DBusError)
+    DBusSignature = cast(Any, _DBusSignature)
     ServiceInterface = cast(Any, _ServiceInterface)
     method = cast(Any, _method)
 
@@ -70,7 +78,10 @@ class BluezPairingAgent(ServiceInterface):
         self._service = service
 
     @method()
-    def RequestPinCode(self, device: str) -> str:
+    def RequestPinCode(
+        self,
+        device: Annotated[str, DBusSignature("o")],
+    ) -> Annotated[str, DBusSignature("s")]:
         response = self._service._request_pairing_input(
             _("Bluetooth PIN code"),
             _("Enter the Bluetooth PIN code shown on the device"),
@@ -81,11 +92,18 @@ class BluezPairingAgent(ServiceInterface):
         return response
 
     @method()
-    def DisplayPinCode(self, _device: str, _pincode: str) -> None:
+    def DisplayPinCode(
+        self,
+        _device: Annotated[str, DBusSignature("o")],
+        _pincode: Annotated[str, DBusSignature("s")],
+    ) -> None:
         return None
 
     @method()
-    def RequestPasskey(self, device: str) -> int:
+    def RequestPasskey(
+        self,
+        device: Annotated[str, DBusSignature("o")],
+    ) -> Annotated[int, DBusSignature("u")]:
         response = self._service._request_pairing_input(
             _("Bluetooth passkey"),
             _("Enter the Bluetooth passkey shown on the device"),
@@ -98,25 +116,33 @@ class BluezPairingAgent(ServiceInterface):
     @method()
     def DisplayPasskey(
         self,
-        _device: str,
-        _passkey: int,
-        _entered: int,
+        _device: Annotated[str, DBusSignature("o")],
+        _passkey: Annotated[int, DBusSignature("u")],
+        _entered: Annotated[int, DBusSignature("q")],
     ) -> None:
         return None
 
     @method()
-    def RequestConfirmation(self, device: str, passkey: int) -> None:
+    def RequestConfirmation(
+        self,
+        device: Annotated[str, DBusSignature("o")],
+        passkey: Annotated[int, DBusSignature("u")],
+    ) -> None:
         message = _("Confirm the passkey on devices: {0}").format(f"{int(passkey):06d}")
         approved = self._service._request_pairing_confirm(message, str(device))
         if not approved:
             raise DBusError("org.bluez.Error.Rejected", "Bluetooth pairing confirmation rejected")
 
     @method()
-    def RequestAuthorization(self, _device: str) -> None:
+    def RequestAuthorization(self, _device: Annotated[str, DBusSignature("o")]) -> None:
         return None
 
     @method()
-    def AuthorizeService(self, _device: str, _uuid: str) -> None:
+    def AuthorizeService(
+        self,
+        _device: Annotated[str, DBusSignature("o")],
+        _uuid: Annotated[str, DBusSignature("s")],
+    ) -> None:
         return None
 
     @method()