summaryrefslogtreecommitdiff
path: root/src/dbusbind.c
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2026-05-28 10:03:05 +0200
committerMichael Albinus <michael.albinus@gmx.de>2026-05-28 10:03:05 +0200
commit833553dd9aec0072961a7f1a7797f9481855a07f (patch)
tree417960e9ac031f0c57d1d75cf388c2e1023b7b65 /src/dbusbind.c
parentde926d281a111a86b1907636c958508e1b71e198 (diff)
dbus-call-method-asynchronously supports also an ERROR-HANDLERmaster
* doc/misc/dbus.texi (Asynchronous Methods): HANDLER can also be (HANDLER . ERROR-HANDLER). * etc/NEWS: Mention ERROR-HANDLER of dbus-call-method-asynchronously. * lisp/net/dbus.el (dbus-call-method-asynchronously): Adapt docstring. (dbus-check-event, dbus-handle-event): HANDLER can also be (HANDLER . ERROR-HANDLER). * src/dbusbind.c (Fdbus_message_internal): HANDLER can also be (HANDLER . ERROR-HANDLER). (Bug#80952) * test/lisp/net/dbus-tests.el (dbus--test-method-another-handler) (dbus--test-method-error-handler): New defvars. (dbus--test-method-another-handler) (dbus--test-method-error-handler): New functions. (dbus-test04-call-method-error-handler): New test. (dbus-test10-keep-fd): Extend test.
Diffstat (limited to 'src/dbusbind.c')
-rw-r--r--src/dbusbind.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 95fedeb166b..7039eac3dbe 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -1411,7 +1411,11 @@ usage: (dbus-message-internal &rest REST) */)
XD_DBUS_VALIDATE_PATH (path);
XD_DBUS_VALIDATE_INTERFACE (interface);
XD_DBUS_VALIDATE_MEMBER (member);
- if (!NILP (handler) && !FUNCTIONP (handler))
+ if (!NILP (handler)
+ && !(FUNCTIONP (handler)
+ || (CONSP (handler)
+ && FUNCTIONP (CAR_SAFE (handler))
+ && FUNCTIONP (CDR_SAFE (handler)))))
wrong_type_argument (Qinvalid_function, handler);
}
@@ -1562,6 +1566,12 @@ usage: (dbus-message-internal &rest REST) */)
if (mtype != DBUS_MESSAGE_TYPE_METHOD_CALL)
XD_SIGNAL1
(build_string (":keep-fd is only supported on method calls"));
+ /* This is because the error handler and the keepfd path use
+ the same slot in Vdbus_registered_objects_table. */
+ if (CONSP (handler))
+ XD_SIGNAL1
+ (build_string
+ (":keep-fd cannot be used when there is an error handler"));
/* Ignore this keyword if unsupported. */
#ifdef DBUS_TYPE_UNIX_FD
@@ -1842,9 +1852,6 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
/* Remove the entry. */
Fremhash (key, Vdbus_registered_objects_table);
- /* Store the event. */
- xd_store_event (CONSP (value) ? CAR_SAFE (value) : value, args, event_args);
-
#ifdef DBUS_TYPE_UNIX_FD
/* Check, whether there is a file descriptor to be kept.
value is (handler . path)
@@ -1857,8 +1864,12 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
Fcons (Fcons (CAR_SAFE (CDR_SAFE (CAR_SAFE (args))),
CDR_SAFE (value)),
xd_registered_fds);
+ value = CAR_SAFE (value);
}
#endif
+
+ /* Store the event. */
+ xd_store_event (value, args, event_args);
}
else /* DBUS_MESSAGE_TYPE_METHOD_CALL, DBUS_MESSAGE_TYPE_SIGNAL. */
@@ -2141,8 +2152,9 @@ means a wildcard then.
OBJECT is either the handler to be called when a D-Bus message, which
matches the key criteria, arrives (TYPE `:method', `:signal' and
-`:monitor'), or a list (ACCESS EMITS-SIGNAL VALUE) for TYPE
-`:property'.
+`:monitor'), or a list (ACCESS EMITS-SIGNAL VALUE) for TYPE `:property'.
+For type `:message', the handler slot can also be a cons cell (HANDLER
+. ERROR-HANDLER) or (HANDLER . KEEP-FD-PATH).
For entries of type `:signal' or `:monitor', there is also a fifth
element RULE, which keeps the match string the signal or monitor is