death / dbus Goto Github PK
View Code? Open in Web Editor NEWA D-BUS client library for Common Lisp
License: BSD 2-Clause "Simplified" License
A D-BUS client library for Common Lisp
License: BSD 2-Clause "Simplified" License
Since define-dbus-object
defines something akin to methods, it would be nice to attach a documentation string to it. What do you think?
I try to communicate with wpa_supplicant via dbus. I can set and get properties as long as they are not arrays of dicts of values. I noticed that dbus-send is not able to do this either.
When I try setting a value which is to be in a dict the call hangs. Perhaps I am missing something?
The dbus api for wpa_supplicant is documented here: https://w1.fi/wpa_supplicant/devel/dbus.html#dbus_p2pdevice
Of the following defuns the first three work, the last one hangs:
(defun wpa-get-go-intent ()
(let ((path (first (wpa-get-interfaces))))
(dbus:with-open-bus (bus (dbus:system-server-addresses))
(dbus:with-introspected-object (dev
bus
path
"fi.w1.wpa_supplicant1")
(dev "org.freedesktop.DBus.Properties" "Get"
"fi.w1.wpa_supplicant1.Interface"
"P2pGoIntent")))))
(defun wpa-set-go-intent (level)
(let ((path (first (wpa-get-interfaces))))
(dbus:with-open-bus (bus (dbus:system-server-addresses))
(dbus:with-introspected-object (dev
bus
path
"fi.w1.wpa_supplicant1")
(dev "org.freedesktop.DBus.Properties" "Set"
"fi.w1.wpa_supplicant1.Interface"
"P2pGoIntent" `((:string) ,(write-to-string level)))))))
(defun wpa-get-p2p-device-config ()
(let ((path (first (wpa-get-interfaces))))
(dbus:with-open-bus (bus (dbus:system-server-addresses))
(dbus:with-introspected-object (dev
bus
path
"fi.w1.wpa_supplicant1")
(dev "org.freedesktop.DBus.Properties" "Get"
"fi.w1.wpa_supplicant1.Interface.P2PDevice"
"P2PDeviceConfig")))))
(defun wpa-set-p2p-go-intent (level)
(let ((path (first (wpa-get-interfaces))))
(dbus:with-open-bus (bus (dbus:system-server-addresses))
(dbus:with-introspected-object (dev
bus
path
"fi.w1.wpa_supplicant1")
(dev "org.freedesktop.DBus.Properties" "Set"
"fi.w1.wpa_supplicant1.Interface.P2PDevice"
"P2PDeviceConfig" `((:string :uint32) "GOIntent" ,level))))))
I want to publish an object and invoke a method on it. I started example/publish.lisp, and I was able to publish an object, "my-service" since I saw a new bus name with d-feet. Then, I invoked "my-method", but an error
end of file on #<active local stream socket connected to ""/run/user/1000/bus"" {100507A4E3}>
happened.
After loading "dbus' package with quicklisp and example/publish.lisp, I did
(in-package #:publish-example)
(publish-example)
(with-open-bus (bus (session-server-addresses))
(invoke-method (bus-connection bus) "my-method"
:path "/org/adeht/Myservice"
:interface "org.adeht.MyService"
:destination "org.adeht.Myservice"
:arguments (list "aaa" "bbb")
:signature "ss"))
"my-service" is not introspectable, so how do I invoke a method on such a object?
When connecting the following is assumed:
(defun session-server-addresses ()
"Return a list of server addresses for the current session."
(when-let (string (getenv "DBUS_SESSION_BUS_ADDRESS"))
(parse-server-addresses-string string)))
on macOS however, particularly D-Bus installed via MacPorts, that information is obtained in the following way:
export DBUS_SESSION_BUS_ADDRESS "unix:path=$DBUS_LAUNCHD_SESSION_BUS_SOCKET"
I therefore suggest to also check the DBUS_LAUNCHD_SESSION_BUS_SOCKET
. Do you think this makes sense, or should be handled by the user?
When recompiling publish.lisp
, the variable *ALL-DBUS-OBJECTS*
gets reset because it's declared using DEFPARAMETER
rather than DEFVAR
. This leads to a strange state where an object is registered, but the dispatch fails because this list is empty.
Using DEFVAR
instead fixes this problem.
I’m writing a signal handler for signal-cli
’s D-Bus service; the MessageReceived
signal has two arrays in its type signature ("x" "s" "ay" "s" "as")
. How should I specify a signal handler for that signal? Here’s what I’ve got so far:
(dbus:define-dbus-object signal-service (:path "/org/asamk/Signal"))
(dbus:define-dbus-signal-handler (signal-service message-received) ((timestamp :int64) (source :string) (group-id (:array :byte)) (message :string) (attachments (:array :string)))
(:interface "org.asamk.Signal")
(with-open-file (log #P"/tmp/messages" :if-exists :append :direction :output :if-does-not-exist :create)
(format log "~&~a ~a ~a ~a ~a~%" timestamp source group-id message attachments)))
I did read the source and noticed that DEFINE-DBUS-SIGNAL-HANDLER
uses SECOND
on the parameters, so it looks like I oughtn’t use e.g (group-id :array :byte)
. I also looked through all the previous issues & in the examples
directory for hints.
The example above has no effect, not even a SLIME debugger. I’ve also tried the name on-message-received
.
This succeeds:
(with-open-bus (bus (system-server-addresses))
(with-introspected-object (logind bus "/org/freedesktop/login1" "org.freedesktop.login1")
(logind "org.freedesktop.login1.Manager" "ListInhibitors")))
but this hangs, apparently forever:
(with-open-bus (bus (system-server-addresses))
(with-introspected-object (logind bus "/org/freedesktop/login1" "org.freedesktop.login1")
(logind "org.freedesktop.login1.Manager" "Inhibit" "sleep" "test" "testing" "delay")))
I think it's because Inhibit returns a file descriptor. I've not been able to come up with a fix; can you please take a look and see if you can reproduce it?
cl-xmlspam does not have any license and this dbus library depends on it, which means that it cannot be distributed as free software :(
I've opened a issue on defunkydrummer/cl-xmlspam#1 and I've contacted the original author, Rog Peppe, still waiting for an answer :)
Should this remain unresolve, @death do you have a plan to work around the licensing issue?
hi,
I am interested in contributing some code to your project, but it seems that there is no license file or license referenced in the asd file. Can you please either add a licence file or reference the license in the asd file.
thanks,
russell
I was thinking I should like the variant type to be inferred if not given as the first element of a two item list. But this would fail in case such a list is passed as a value, expecting the type to be inferred. Ideas?
Debian squeeze, dbus 1.2.24-4
Example:
(dbus:with-open-bus (bus (dbus:system-server-addresses))
(dbus:with-introspected-object (wicd-wireless bus "/org/wicd/daemon/wireless" "org.wicd.daemon")))
Error: No more mechanisms to try.
Seems to be related to cookie sha1 auth
Python and scheme bindings via libdbus are working
Working example in scheme:
(define wicd-wireless-context (dbus:make-context
bus: dbus:system-bus
service: 'org.wicd.daemon
interface: 'org.wicd.daemon.wireless
path: '/org/wicd/daemon/wireless))
(dbus:call wicd-wireless-context "GetWirelessProperty" 0 "bssid")
("88:43:E1:13:FC:B2")
I don't yet know enough to attempt a fix unfortunately.
The array unpacker (messages.lisp) expects the array end at
(= end (stream-read-position stream)), instead of
(<= end (stream-read-position stream)).
As the specs says: The array length is from the end of the alignment padding to the end of the last element, i.e. it does not include the padding after the length, or any padding after the last element.
This causes problems for some arrays like the ones returned by "GetMetadata" method from MPRIS.
According to the specs: The direction element on may be omitted, in which case it defaults to "in" for method calls and "out" for signals. Signals only allow "out" so while direction may be specified, it's pointless.
This seems to fix the problem:
(defun parse-introspection-document (input)
(with-xspam-source (make-xspam-source input :entity-resolver #'dont-resolve-entities)
(element :node
(let (interfaces)
(one-or-more
(element :interface
(let (interface-name)
(attribute :name (setf interface-name _))
(let (methods)
(zero-or-more
(element :method
(let (method-name)
(attribute :name (setf method-name _))
(let ((signature (make-string-output-stream)))
(zero-or-more
(element :arg
(attribute :type
(let ((sig _))
(handler-case (attribute :direction
(when (equal _ "in")
(write-string sig signature)))
(simple-error () (write-string sig signature)))))))
(push (make-method method-name (get-output-stream-string signature)) methods)))))
(push (make-interface interface-name (nreverse methods)) interfaces)))))
(nreverse interfaces)))))
Update:
Here is a standalone test case:
(loop
(with-open-bus (bus (session-server-addresses))
(with-introspected-object (notify bus "/org/freedesktop/Notifications" "org.freedesktop.Notifications")
(notify "org.freedesktop.DBus.Introspectable" "Introspect")
(notify "org.freedesktop.Notifications" "GetCapabilities")
(notify "org.freedesktop.Notifications" "GetServerInformation"))
(format t "."))
(iolib.syscalls:usleep 500000))
This hung after about 10 minutes on my machine.
The thread hangs after an event-dispatch waiting for the reply to an "Introspect" call generated from with-introspected-object. Also, as you might expect, pending-messages for the connection does not contain a method-return-message, only a signal-message. The complete data for the method-return message is present in the socket's input buffer.
When I run D-Feet to introspect the object, it appears in the object list on the session. When I click on it however, I get the following error message:
Missing method-call handler at path / interface
org.freedesktop.DBus.Introspectable name Introspect (36)
Do I need to do something special to enable introspection or is it simply lacking in this library?
(let ((path (format nil "/org/freedesktop/login1/session/~a" (sb-ext:posix-getenv "XDG_SESSION_ID")))) (with-open-bus (bus (system-server-addresses)) (with-introspected-object (session bus path "org.freedesktop.login1"))))
Results in an error from XSPAM: expected one of {:|arg| }, got :end-document nil nil nil
. This is caused by the fact that Lock and Unlock do not have any dbus arguments, but PARSE-INTROSPECTION-DOCUMENT requires them.
How do I make signal handler for signals where I don't know the object path?
Like for example when ofono notifies about a new phone connected.
With D-Bus methods may have no return values (which means in particular that the caller won't be waiting).
I'm wondering how to this with this library. It seems that setting the return-types to ()
in dbus:define-dbus-method
does not work, a condition is raised:
Method handler (NEXT::CORE-OBJECT NEXT::request-resource) returned bad results; expected-signature=NIL, results=(nil).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.