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.
This commit is contained in:
Benoît Minisini 2023-05-26 21:48:23 +02:00
parent d5910b6141
commit b7b129290c
2 changed files with 16 additions and 1 deletions

View file

@ -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

View file

@ -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