Open GaikwadPratik opened 2 years ago
@amenzhinsky,
Hope you had nice weekend...
any thoughts on PR?
Hi @GaikwadPratik, sorry for the late response.
Thanks I really did :)
I don't quite understand the need of the feature, can you give an example?
Hi @amenzhinsky,
I believe you are familiar with dbus-inspect.
In the attached video, first half is WITHOUT the PR while the second is WITH the PR.
https://user-images.githubusercontent.com/5595263/164250552-3509e6ee-8b10-4057-b976-e163209242c1.mp4
Basically, I'm writing a dbus-service(server instance) in Golang. When another developer wants to interact with the service, they WILL NOT know the interface(s) definition unless
As shown in the above video, introspection returns nothing without the changes in PR.
@amenzhinsky ,
I hope above video and explanation was sufficient. Basic answer is that you won't be able to introspect and by extension call dbus server unless you know the api correctly from somewhere. I can't explain or provide any example simple than this.
P.S. I apologize for high resolution of the video. It would be better if you download it and then view it.
So, to generate server-side code you already have an introspection xml file, you can export org.freedesktop.DBus.Introspectable.Introspect
that has only one method Introspect() string
which can return its content.
@amenzhinsky ,
That didn't help. Please see attached video.
https://user-images.githubusercontent.com/5595263/165413843-6ab70576-b9a6-4443-8684-1c54471b732f.mp4
The example in above video is from clien_server. Perhaps you can directly update that.
P.S. please point out if I am doing any mistake in the above video
You need to do something like this:
conn.ExportMethodTable(map[string]interface{}{
"Introspect": func() string {
return "your-xml-goes-here"
},
}, "/org/example/Demo", "org.freedesktop.DBus.Introspectable.Introspect")
that's what this PR does. Just automatically instead of asking consumers to do it manually. Or am I missing something?
would be great to see this PR merged.... @GaikwadPratik have you also considered in your PR the Unexport function?
@GaikwadPratik adding
err := conn.Export(nil, path, "org.freedesktop.DBus.Introspectable") if err != nil { return err }
to the unexport method seems to work
By trying to access the properties, I get following error: string "Object does not implement the interface 'org.freedesktop.DBus.Properties'"
@maltegrosse ,
err := conn.Export(nil, path, "org.freedesktop.DBus.Introspectable") if err != nil { return err }
to the unexport method seems to work
Though I am not sure why would we want to UnExport
these, I'll try to work on it.
By trying to access the properties, I get following error: string "Object does not implement the interface 'org.freedesktop.DBus.Properties'"
Last time I tried this, it worked. How are you trying to access it?
This extends @knightpp's idea and actually exposes interfaces for introspection when server is running.
Related to #8 and #9