[Gambas-user] D-Bus - Change property

Benoît Minisini g4mba5 at gmail.com
Sat Mar 10 15:57:17 CET 2018


Le 09/03/2018 à 17:59, Hans Lehmann a écrit :
> Hello,
> 
> after the notes in the documentation 
> (http://gambaswiki.org/wiki/doc/dbus) I tested a (D-Bus-)Server, which 
> only has a property' Trigger', whose value should read and change a 
> (D-Bus-)Client:
> 
> FMain.class:
> 
> ' Gambas class file
> 
> Public Sub _new()
>     DBus.Unique = True
>     DBus.Session.Register(Export1, "/export1")
> End
> 
> Public Sub Form_Open()
>    FMain.Resizable = False
>    FMain.Caption = ("The data server is activated")
> End
> 
> Public Sub Form_Close()
>    FMain.Close()
> End
> 
> export1.class:
> 
> ' Gambas class file
> 
> Inherits DBusObject
> Create Static
> 
> Property Trigger1 As Float
> Private $fTrigger1 As Float = Pi(4)
> 
> Private Sub Trigger1_Read() As Float
>    Return $fTrigger1
> End
> 
> Private Sub Trigger1_Write(Value As Float)
>    $fTrigger1 = Value
> End
> 
> ' dbus-send --session --print-reply --dest=org.gambas.dbusserver 
> /export1 org.freedesktop.DBus.Introspectable.Introspect
> ' Extract from the XML introspection file:
> ' ...
> '   <interface name="org.gambas.dbusserver.export1">
> '     <property name="Trigger1" type="d" access="readwrite"/>
> '     ...
> '   </interface>
> 
> ----
> 
> The client is simple:
> 
> FMain.class:
> 
> ' Gambas class file
> 
> Public hDBusProxy As DBusProxy
> 
> Public Sub Form_Open()
>    hDBusProxy = DBus["org.gambas.server"]["/export1"]
> End
> 
> Public Sub btnDataRefresh_Click()
>    Print hDBusProxy.Trigger1
> End
> 
> Public Sub btnSetData_Click()
>    hDBusProxy.Trigger1 = 44  ----->> ERROR
> End
> 
> As a result, I can read the value of the property from the exported 
> object from the client via the D-Bus without any problems. However, I do 
> not succeed in setting the value for the property Trigger. Only the 
> error message "No function" is displayed. Where is my mental error? I 
> have oriented myself to the following:
> 
> To get the value of a property, do: DBus[Application][ObjectPath].Property
> And to set the value of a property, do: 
> DBus[Application][ObjectPath].Property = Value
> 
> Regards
> 
> Hans
> 

Fixed in commit 
https://gitlab.com/gambas/gambas/commit/be3375e0d29022f3e43adcfc38dafee9684060ba

-- 
Benoît Minisini


More information about the User mailing list