Lisp_Object bus;
{
DBusConnection *connection;
- char name[1024];
+ char name[DBUS_MAXIMUM_NAME_LENGTH];
/* Check parameters. */
CHECK_SYMBOL (bus);
elements of the D-Bus container. Example:
\(dbus-call-method
- :session "GetKeyField" "org.gnome.seahorse"
- "/org/gnome/seahorse/keys/openpgp" "org.gnome.seahorse.Keys"
+ :session "org.gnome.seahorse" "/org/gnome/seahorse/keys/openpgp"
+ "org.gnome.seahorse.Keys" "GetKeyField"
"openpgp:657984B8C7A966DD" "simple-name")
=> (t ("Philip R. Zimmermann"))
object is returned instead of a list containing this single Lisp object.
\(dbus-call-method
- :system "GetPropertyString" "org.freedesktop.Hal"
- "/org/freedesktop/Hal/devices/computer" "org.freedesktop.Hal.Device"
+ :system "org.freedesktop.Hal" "/org/freedesktop/Hal/devices/computer"
+ "org.freedesktop.Hal.Device" "GetPropertyString"
"system.kernel.machine")
=> "i686"
-usage: (dbus-call-method BUS METHOD SERVICE PATH INTERFACE &rest ARGS) */)
+usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
(nargs, args)
int nargs;
register Lisp_Object *args;
{
- Lisp_Object bus, method, service, path, interface;
+ Lisp_Object bus, service, path, interface, method;
Lisp_Object result;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
DBusConnection *connection;
/* Check parameters. */
bus = args[0];
- method = args[1];
- service = args[2];
- path = args[3];
- interface = args[4];
+ service = args[1];
+ path = args[2];
+ interface = args[3];
+ method = args[4];
CHECK_SYMBOL (bus);
- CHECK_STRING (method);
CHECK_STRING (service);
CHECK_STRING (path);
CHECK_STRING (interface);
- GCPRO5 (bus, method, service, path, interface);
+ CHECK_STRING (method);
+ GCPRO5 (bus, service, path, interface, method);
XD_DEBUG_MESSAGE ("%s %s %s %s",
- SDATA (method),
SDATA (service),
SDATA (path),
- SDATA (interface));
+ SDATA (interface),
+ SDATA (method));
/* Open a connection to the bus. */
connection = xd_initialize (bus);
Example:
\(dbus-send-signal
- :session "Started" "org.gnu.emacs" "/org/gnu/emacs" "org.gnu.emacs")))
+ :session "org.gnu.Emacs" "/org/gnu/Emacs"
+ "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs")
-usage: (dbus-send-signal BUS SIGNAL SERVICE PATH INTERFACE &rest ARGS) */)
+usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
(nargs, args)
int nargs;
register Lisp_Object *args;
{
- Lisp_Object bus, signal, service, path, interface;
+ Lisp_Object bus, service, path, interface, signal;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
DBusConnection *connection;
DBusMessage *dmessage;
/* Check parameters. */
bus = args[0];
- signal = args[1];
- service = args[2];
- path = args[3];
- interface = args[4];
+ service = args[1];
+ path = args[2];
+ interface = args[3];
+ signal = args[4];
CHECK_SYMBOL (bus);
- CHECK_STRING (signal);
CHECK_STRING (service);
CHECK_STRING (path);
CHECK_STRING (interface);
- GCPRO5 (bus, signal, service, path, interface);
+ CHECK_STRING (signal);
+ GCPRO5 (bus, service, path, interface, signal);
XD_DEBUG_MESSAGE ("%s %s %s %s",
- SDATA (signal),
SDATA (service),
SDATA (path),
- SDATA (interface));
+ SDATA (interface),
+ SDATA (signal));
/* Open a connection to the bus. */
connection = xd_initialize (bus);
DBusMessage *dmessage;
DBusMessageIter iter;
uint dtype;
- char service[1024], path[1024], interface[1024], member[1024];
+ char service[DBUS_MAXIMUM_NAME_LENGTH];
+ char path[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; /* Unlimited in D-Bus spec. */
+ char interface[DBUS_MAXIMUM_NAME_LENGTH];
+ char member[DBUS_MAXIMUM_NAME_LENGTH];
/* Open a connection to the bus. */
connection = xd_initialize (bus);
/* The arguments are stored in reverse order. Reorder them. */
event.arg = Fnreverse (event.arg);
- /* Read service, object path interface and member from the
- message. */
+ /* Read service, object path, interface and member from the message.
+ The service is always the unique name of the sending object. */
strcpy (service, dbus_message_get_sender (dmessage));
strcpy (path, dbus_message_get_path (dmessage));
strcpy (interface, dbus_message_get_interface (dmessage));
strcpy (member, dbus_message_get_member (dmessage));
- /* Add them to the event. */
+ /* Add the registered function of the message. */
+ key = list5 (bus,
+ (service == NULL ? Qnil : build_string (service)),
+ (path == NULL ? Qnil : build_string (path)),
+ (interface == NULL ? Qnil : build_string (interface)),
+ (member == NULL ? Qnil : build_string (member)));
+ event.arg = Fcons (Fgethash (key, Vdbus_registered_functions_table, Qnil),
+ event.arg);
+
+ /* Add service, path, interface and member to the event. */
event.arg = Fcons ((member == NULL ? Qnil : build_string (member)),
event.arg);
event.arg = Fcons ((interface == NULL ? Qnil : build_string (interface)),
/* Add the bus symbol to the event. */
event.arg = Fcons (bus, event.arg);
- /* Add the registered function of the message. */
- key = list3 (bus,
- (interface == NULL ? Qnil : build_string (interface)),
- (member == NULL ? Qnil : build_string (member)));
- event.arg = Fcons (Fgethash (key, Vdbus_registered_functions_table, Qnil),
- event.arg);
-
/* Store it into the input event queue. */
kbd_buffer_store_event (&event);
(message "Device %s added" device))
\(dbus-register-signal
- :system "DeviceAdded"
- (dbus-get-name-owner :system "org.freedesktop.Hal")
- "/org/freedesktop/Hal/Manager" "org.freedesktop.Hal.Manager"
- 'my-signal-handler)
+ :system "org.freedesktop.Hal" "/org/freedesktop/Hal/Manager"
+ "org.freedesktop.Hal.Manager" "DeviceAdded" 'my-signal-handler)
- => (:system "org.freedesktop.Hal.Manager" "DeviceAdded")
+ => (:system ":1.3" "/org/freedesktop/Hal/Manager"
+ "org.freedesktop.Hal.Manager" "DeviceAdded")
`dbus-register-signal' returns an object, which can be used in
`dbus-unregister-signal' for removing the registration. */)
- (bus, signal, service, path, interface, handler)
- Lisp_Object bus, signal, service, path, interface, handler;
+ (bus, service, path, interface, signal, handler)
+ Lisp_Object bus, service, path, interface, signal, handler;
{
- Lisp_Object key;
+ Lisp_Object unique_name, key;
DBusConnection *connection;
- char rule[1024];
+ char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
DBusError derror;
/* Check parameters. */
CHECK_SYMBOL (bus);
- CHECK_STRING (signal);
if (!NILP (service)) CHECK_STRING (service);
if (!NILP (path)) CHECK_STRING (path);
CHECK_STRING (interface);
+ CHECK_STRING (signal);
CHECK_SYMBOL (handler);
+ /* Retrieve unique name of service. If service is a known name, we
+ will register for the corresponding unique name, if any. Signals
+ are sent always with the unique name as sender. Note: the unique
+ name of "org.freedesktop.DBus" is that string itself. */
+ if ((!NILP (service)) &&
+ (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0) &&
+ (strncmp (SDATA (service), ":", 1) != 0))
+ unique_name = call2 (intern ("dbus-get-name-owner"), bus, service);
+ else
+ unique_name = service;
+
/* Open a connection to the bus. */
connection = xd_initialize (bus);
SDATA (interface),
SDATA (signal));
- /* Add service and path to the rule if they are non-nil. */
- if (!NILP (service))
- sprintf (rule, "%s,sender='%s'%", rule, SDATA (service));
+ /* Add unique name and path to the rule if they are non-nil. */
+ if (!NILP (unique_name))
+ sprintf (rule, "%s,sender='%s'%", rule, SDATA (unique_name));
if (!NILP (path))
sprintf (rule, "%s,path='%s'", rule, SDATA (path));
XD_DEBUG_MESSAGE ("Matching rule \"%s\" created", rule);
/* Create a hash table entry. */
- key = list3 (bus, interface, signal);
+ key = list5 (bus, unique_name, path, interface, signal);
Fputhash (key, handler, Vdbus_registered_functions_table);
XD_DEBUG_MESSAGE ("\"%s\" registered with handler \"%s\"",
SDATA (format2 ("%s", key, Qnil)),
Lisp_Object object;
{
- /* Check parameters. */
- CHECK_SYMBOL (object);
-
- XD_DEBUG_MESSAGE ("\"%s\" unregistered with handler \"%s\"",
- SDATA (format2 ("%s", object, Qnil)),
- SDATA (format2 ("%s", Fsymbol_function (object), Qnil)));
-
/* Unintern the signal symbol. */
Fremhash (object, Vdbus_registered_functions_table);
DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table,
doc: /* Hash table of registered functions for D-Bus.
-The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is
-either the symbol `:system' or the symbol `:session'. INTERFACE is a
-string which denotes a D-Bus interface, and MEMBER, also a string, is
-either a method or a signal INTERFACE is offering.
+The key in the hash table is the list (BUS SERVICE PATH MEMBER INTERFACE).
+BUS is either the symbol `:system' or the symbol `:session'. SERVICE
+and PATH are the unique name and the object path of the sending object.
+INTERFACE is a string which denotes a D-Bus interface, and MEMBER,
+also a string, is either a method or a signal INTERFACE is offering.
+All arguments but BUS can be nil, which means a wild card then.
The value in the hash table a the function to be called when a D-Bus
message, which matches the key criteria, arrives. */);