/* Elisp bindings for D-Bus.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2014 Free Software Foundation, Inc.
This file is part of GNU Emacs.
\f
/* Subroutines. */
-static Lisp_Object Qdbus_init_bus;
+static Lisp_Object Qdbus__init_bus;
static Lisp_Object Qdbus_get_unique_name;
static Lisp_Object Qdbus_message_internal;
} while (0)
#else /* !DBUS_DEBUG */
-#define XD_DEBUG_MESSAGE(...) \
+# if __STDC_VERSION__ < 199901
+# define XD_DEBUG_MESSAGE (void) /* Pre-C99 compilers cannot debug. */
+# else
+# define XD_DEBUG_MESSAGE(...) \
do { \
if (!NILP (Vdbus_debug)) \
{ \
message ("%s: %s", __func__, s); \
} \
} while (0)
-#define XD_DEBUG_VALID_LISP_OBJECT_P(object)
+# endif
+# define XD_DEBUG_VALID_LISP_OBJECT_P(object)
#endif
/* Check whether TYPE is a basic DBusType. */
#endif
{
dbus_uint32_t val;
- unsigned int pval = val;
+ unsigned int pval;
dbus_message_iter_get_basic (iter, &val);
pval = val;
XD_DEBUG_MESSAGE ("%c %u", dtype, pval);
return *refcount;
}
+/* Convert a Lisp D-Bus object to a pointer. */
+static DBusConnection*
+xd_lisp_dbus_to_dbus (Lisp_Object bus)
+{
+ return (DBusConnection *) (intptr_t) XFASTINT (bus);
+}
+
/* Return D-Bus connection address. BUS is either a Lisp symbol,
:system or :session, or a string denoting the bus address. */
static DBusConnection *
if (NILP (val))
XD_SIGNAL2 (build_string ("No connection to bus"), bus);
else
- connection = (DBusConnection *) (intptr_t) XFASTINT (val);
+ connection = xd_lisp_dbus_to_dbus (val);
if (!dbus_connection_get_is_connected (connection))
XD_SIGNAL2 (build_string ("No connection to bus"), bus);
{
DBusConnection *connection;
Lisp_Object val;
+ Lisp_Object busobj;
/* Check whether we are connected. */
val = Fassoc (bus, xd_registered_buses);
if (NILP (val))
return;
+ busobj = CDR_SAFE (val);
+ if (NILP (busobj)) {
+ xd_registered_buses = Fdelete (val, xd_registered_buses);
+ return;
+ }
+
/* Retrieve bus address. */
- connection = xd_get_connection_address (bus);
+ connection = xd_lisp_dbus_to_dbus (busobj);
if (xd_get_connection_references (connection) == 1)
{
return;
}
-DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 2, 0,
+DEFUN ("dbus--init-bus", Fdbus__init_bus, Sdbus__init_bus, 1, 2, 0,
doc: /* Establish the connection to D-Bus BUS.
+This function is dbus internal. You almost certainly want to use
+`dbus-init-bus'.
+
BUS can be either the symbol `:system' or the symbol `:session', or it
can be a string denoting the address of the corresponding bus. For
the system and session buses, this function is called when loading
xd_registered_buses = Fcons (Fcons (bus, val), xd_registered_buses);
/* We do not want to abort. */
- putenv ((char *) "DBUS_FATAL_WARNINGS=0");
+ xputenv ("DBUS_FATAL_WARNINGS=0");
/* Cleanup. */
dbus_error_free (&derror);
syms_of_dbusbind (void)
{
- DEFSYM (Qdbus_init_bus, "dbus-init-bus");
- defsubr (&Sdbus_init_bus);
+ DEFSYM (Qdbus__init_bus, "dbus--init-bus");
+ defsubr (&Sdbus__init_bus);
DEFSYM (Qdbus_get_unique_name, "dbus-get-unique-name");
defsubr (&Sdbus_get_unique_name);