/* Elisp bindings for D-Bus.
- Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GNU Emacs.
NULL, (void*) XHASH (bus), NULL))
XD_SIGNAL1 (build_string ("Cannot add watch functions"));
+ /* We do not want to abort. */
+ putenv ("DBUS_FATAL_WARNINGS=0");
+
/* Return. */
return Qnil;
}
SDATA (interface),
SDATA (method));
+ /* Check dbus-registered-objects-table. */
+ if (!HASH_TABLE_P (Vdbus_registered_objects_table))
+ XD_SIGNAL1 (build_string ("dbus.el is not loaded"));
+
/* Open a connection to the bus. */
connection = xd_initialize (bus);
/* Check, whether there is pending input in the message queue of the
D-Bus BUS. BUS is a Lisp symbol, either :system or :session. */
-int
+static Lisp_Object
xd_get_dispatch_status (bus)
Lisp_Object bus;
{
return
(dbus_connection_get_dispatch_status (connection)
== DBUS_DISPATCH_DATA_REMAINS)
- ? TRUE : FALSE;
+ ? Qt : Qnil;
}
/* Check for queued incoming messages from the system and session buses. */
int
xd_pending_messages ()
{
+ int ret = FALSE;
+ xd_in_read_queued_messages = 1;
/* Vdbus_registered_objects_table will be initialized as hash table
in dbus.el. When this package isn't loaded yet, it doesn't make
sense to handle D-Bus messages. */
- return (HASH_TABLE_P (Vdbus_registered_objects_table)
- ? (xd_get_dispatch_status (QCdbus_system_bus)
- || ((getenv ("DBUS_SESSION_BUS_ADDRESS") != NULL)
- ? xd_get_dispatch_status (QCdbus_session_bus)
- : FALSE))
- : FALSE);
+ if (HASH_TABLE_P (Vdbus_registered_objects_table))
+ {
+ ret = (!NILP (internal_catch (Qdbus_error, xd_get_dispatch_status,
+ QCdbus_system_bus)));
+ if (ret) goto theend;
+
+ ret = ((getenv ("DBUS_SESSION_BUS_ADDRESS") != NULL) &&
+ (!NILP (internal_catch (Qdbus_error, xd_get_dispatch_status,
+ QCdbus_session_bus))));
+ }
+
+ /* Return. */
+ theend:
+ xd_in_read_queued_messages = 0;
+ return ret;
}
/* Read queued incoming message of the D-Bus BUS. BUS is a Lisp
wrong_type_argument (intern ("functionp"), handler);
GCPRO6 (bus, service, path, interface, signal, handler);
+ /* Check dbus-registered-objects-table. */
+ if (!HASH_TABLE_P (Vdbus_registered_objects_table))
+ XD_SIGNAL1 (build_string ("dbus.el is not loaded"));
+
/* 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
/* TODO: We must check for a valid service name, otherwise there is
a segmentation fault. */
+ /* Check dbus-registered-objects-table. */
+ if (!HASH_TABLE_P (Vdbus_registered_objects_table))
+ XD_SIGNAL1 (build_string ("dbus.el is not loaded"));
+
/* Open a connection to the bus. */
connection = xd_initialize (bus);
doc: /* If non-nil, debug messages of D-Bus bindings are raised. */);
#ifdef DBUS_DEBUG
Vdbus_debug = Qt;
- /* We can also set environment DBUS_VERBOSE=1 in order to see more
- traces. */
+ /* We can also set environment variable DBUS_VERBOSE=1 in order to
+ see more traces. This requires libdbus-1 to be configured with
+ --enable-verbose-mode. */
#else
Vdbus_debug = Qnil;
- /* We do not want to abort. */
- setenv ("DBUS_FATAL_WARNINGS", 0, 1);
#endif
Fprovide (intern_c_string ("dbusbind"), Qnil);