From b7b129290c3363b58a19ea269e2ce12ffe901c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Fri, 26 May 2023 21:48:23 +0200 Subject: [PATCH] DBusConnection: Add a 'Start()' method that starts a DBus service by name, and waits until it is available. [GB.DBUS] * NEW: DBusConnection: Add a 'Start()' method that starts a DBus service by name, and waits until it is available. * BUG: DBusConnection: 'Exist()' acts on the current bus as expected. --- gb.dbus/src/gb.dbus/.src/DBusConnection.class | 15 ++++++++++++++- gb.dbus/src/gb.dbus/.src/MMain.module | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gb.dbus/src/gb.dbus/.src/DBusConnection.class b/gb.dbus/src/gb.dbus/.src/DBusConnection.class index ae42af036..a0fcb67d8 100644 --- a/gb.dbus/src/gb.dbus/.src/DBusConnection.class +++ b/gb.dbus/src/gb.dbus/.src/DBusConnection.class @@ -62,6 +62,19 @@ End Public Sub Exist((Application) As String) As Boolean - Try Return DBus["org.freedesktop.DBus"]["/", "org.freedesktop.DBus"].NameHasOwner(Application) + Try Return Me["org.freedesktop.DBus"]["/", "org.freedesktop.DBus"].NameHasOwner(Application) + +End + +Public Sub Start((Application) As String) + + Dim fTime As Float + + Me["org.freedesktop.DBus"]["/", "org.freedesktop.DBus"].StartServiceByName(Application, 0) + fTime = Timer + While Not {Exist}(Application) + Sleep 0.05 + If (Timer - fTime) > 1 Then Error.Raise("Cannot start service") + Wend End diff --git a/gb.dbus/src/gb.dbus/.src/MMain.module b/gb.dbus/src/gb.dbus/.src/MMain.module index da69c9ccc..489de51e0 100644 --- a/gb.dbus/src/gb.dbus/.src/MMain.module +++ b/gb.dbus/src/gb.dbus/.src/MMain.module @@ -177,6 +177,8 @@ Public Sub Main() Dim hFile As File hFile = Open "~/03.FDR_OAPP_2023_12.05_bois_harpe et piano.pdf" + Print DBus.Session.Exist("org.freedesktop.portal.Desktop") + Print DBus["org.freedesktop.portal.Desktop"]["/org/freedesktop/portal/desktop", "org.freedesktop.portal.OpenURI"].OpenFile("", DBusFile(hFile), ["handle_token": "Gambas1972", "interactive": True]) End