- commit
- 7175cabd964a680ef6f8ad7d9ad941c6128c5cf0
- parent
- 16d0005ef362b5ff8e257f03d4a46f636c39f94d
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2026-02-16 08:57
add portal call
Diffstat
| M | xibus/client.py | 25 | +++++++++++++++++++++++++ |
1 files changed, 25 insertions, 0 deletions
diff --git a/xibus/client.py b/xibus/client.py
@@ -1,5 +1,7 @@ 1 1 import contextlib -1 2 import random 2 3 -1 4 from .connection import DBusError 3 5 from .schema import Schema 4 6 5 7 @@ -58,6 +60,9 @@ class Proxy: 58 60 async for value in self.client.watch_property(*self.defaults, prop): 59 61 yield value 60 62 -1 63 async def portal_call(self, method, params=()): -1 64 return await self.client.portal_call(*self.defaults, method, params) -1 65 61 66 62 67 class Client: 63 68 def __init__(self, con): @@ -131,6 +136,26 @@ class Client: 131 136 elif prop in invalidated: 132 137 yield None 133 138 -1 139 async def portal_call(self, name, path, iface, method, params=()): -1 140 sender = self.con.unique_name.replace('.', '_')[1:] -1 141 token = str(random.randint(1_000_000_000, 10_000_000_000)) -1 142 params[-1]['handle_token'] = ('s', token) -1 143 request_path = f'/org/freedesktop/portal/desktop/request/{sender}/{token}' -1 144 -1 145 async with self.subscribe_signal( -1 146 name, -1 147 request_path, -1 148 'org.freedesktop.portal.Request', -1 149 'Response', -1 150 ) as queue: -1 151 await self.call(name, path, iface, method, params) -1 152 async for status, value in queue: -1 153 if status != 0: -1 154 # I don't think there is any way to get a -1 155 # human-readable error message in this case -1 156 raise DBusError(status) -1 157 return value -1 158 134 159 135 160 class MagicClient(Client): 136 161 async def _iter_paths(self, name, path=''):