|
16 | 16 |
|
17 | 17 | from dbus_next import Variant |
18 | 18 | from dbus_next.aio import MessageBus |
| 19 | +from dbus_next.proxy_object import BaseProxyInterface |
19 | 20 | from dbus_next.constants import MessageType |
20 | 21 | from dbus_next.message import Message |
21 | 22 |
|
|
25 | 26 |
|
26 | 27 | APP_ID = "@APP_ID@" |
27 | 28 | DBUS_DOC_FILE = "@DBUS_DOC_FILE@" |
| 29 | +INTERFACE: Optional[BaseProxyInterface] = None |
28 | 30 |
|
29 | 31 |
|
30 | 32 | def getMessage(): |
@@ -409,8 +411,11 @@ async def get_passkey(interface, options, origin, top_origin): |
409 | 411 | return response_json |
410 | 412 |
|
411 | 413 |
|
412 | | -async def run(cmd, options, origin, top_origin): |
413 | | - logging.debug("Executing command") |
| 414 | +async def get_interface(): |
| 415 | + global INTERFACE |
| 416 | + if INTERFACE and INTERFACE.bus.connected: |
| 417 | + return INTERFACE |
| 418 | + |
414 | 419 | bus = await MessageBus().connect() |
415 | 420 | logging.debug("Connected to bus") |
416 | 421 | import os |
@@ -438,11 +443,17 @@ async def run(cmd, options, origin, top_origin): |
438 | 443 | "/org/freedesktop/portal/desktop", |
439 | 444 | introspection, |
440 | 445 | ) |
441 | | - |
442 | 446 | interface = proxy_object.get_interface( |
443 | 447 | "org.freedesktop.portal.experimental.Credential" |
444 | 448 | ) |
| 449 | + INTERFACE = interface |
445 | 450 | logging.debug(f"Connected to interface at {interface.path}") |
| 451 | + return INTERFACE |
| 452 | + |
| 453 | + |
| 454 | +async def run(cmd, options, origin, top_origin): |
| 455 | + logging.debug("Executing command") |
| 456 | + interface = await get_interface() |
446 | 457 |
|
447 | 458 | if cmd == "create": |
448 | 459 | if "publicKey" in options: |
@@ -477,6 +488,7 @@ async def run(cmd, options, origin, top_origin): |
477 | 488 |
|
478 | 489 | async def main(): |
479 | 490 | logging.info("starting credential_manager_shim") |
| 491 | + |
480 | 492 | while not quit.is_set(): |
481 | 493 | logging.debug("starting event loop message") |
482 | 494 | receivedMessage = getMessage() |
|
0 commit comments