summaryrefslogtreecommitdiff
path: root/src/dbusbind.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbusbind.c')
-rw-r--r--src/dbusbind.c126
1 files changed, 61 insertions, 65 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 56bfd7164a4..08b7cc2ddf2 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -20,6 +20,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifdef HAVE_DBUS
#include <stdio.h>
+#include <stdlib.h>
#include <dbus/dbus.h>
#include "lisp.h"
@@ -90,7 +91,7 @@ static bool xd_in_read_queued_messages = 0;
} while (0)
/* Macros for debugging. In order to enable them, build with
- "env MYCPPFLAGS='-DDBUS_DEBUG -Wall' make". */
+ "make MYCPPFLAGS='-DDBUS_DEBUG'". */
#ifdef DBUS_DEBUG
#define XD_DEBUG_MESSAGE(...) \
do { \
@@ -168,25 +169,25 @@ static int
xd_symbol_to_dbus_type (Lisp_Object object)
{
return
- ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE
- : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN
- : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16
- : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16
- : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32
- : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32
- : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64
- : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64
- : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE
- : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING
- : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH
- : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE
+ (EQ (object, QCbyte) ? DBUS_TYPE_BYTE
+ : EQ (object, QCboolean) ? DBUS_TYPE_BOOLEAN
+ : EQ (object, QCint16) ? DBUS_TYPE_INT16
+ : EQ (object, QCuint16) ? DBUS_TYPE_UINT16
+ : EQ (object, QCint32) ? DBUS_TYPE_INT32
+ : EQ (object, QCuint32) ? DBUS_TYPE_UINT32
+ : EQ (object, QCint64) ? DBUS_TYPE_INT64
+ : EQ (object, QCuint64) ? DBUS_TYPE_UINT64
+ : EQ (object, QCdouble) ? DBUS_TYPE_DOUBLE
+ : EQ (object, QCstring) ? DBUS_TYPE_STRING
+ : EQ (object, QCobject_path) ? DBUS_TYPE_OBJECT_PATH
+ : EQ (object, QCsignature) ? DBUS_TYPE_SIGNATURE
#ifdef DBUS_TYPE_UNIX_FD
- : (EQ (object, QCdbus_type_unix_fd)) ? DBUS_TYPE_UNIX_FD
+ : EQ (object, QCunix_fd) ? DBUS_TYPE_UNIX_FD
#endif
- : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY
- : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT
- : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT
- : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY
+ : EQ (object, QCarray) ? DBUS_TYPE_ARRAY
+ : EQ (object, QCvariant) ? DBUS_TYPE_VARIANT
+ : EQ (object, QCstruct) ? DBUS_TYPE_STRUCT
+ : EQ (object, QCdict_entry) ? DBUS_TYPE_DICT_ENTRY
: DBUS_TYPE_INVALID);
}
@@ -257,16 +258,16 @@ XD_OBJECT_TO_STRING (Lisp_Object object)
if ((session_bus_address != NULL) \
&& (!NILP (Fstring_equal \
(bus, build_string (session_bus_address))))) \
- bus = QCdbus_session_bus; \
+ bus = QCsession; \
} \
\
else \
{ \
CHECK_SYMBOL (bus); \
- if (!(EQ (bus, QCdbus_system_bus) || EQ (bus, QCdbus_session_bus))) \
+ if (!(EQ (bus, QCsystem) || EQ (bus, QCsession))) \
XD_SIGNAL2 (build_string ("Wrong bus name"), bus); \
/* We do not want to have an autolaunch for the session bus. */ \
- if (EQ (bus, QCdbus_session_bus) && session_bus_address == NULL) \
+ if (EQ (bus, QCsession) && session_bus_address == NULL) \
XD_SIGNAL2 (build_string ("No connection to bus"), bus); \
} \
} while (0)
@@ -395,7 +396,7 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
CHECK_CONS (object);
/* Type symbol is optional. */
- if (EQ (QCdbus_type_array, CAR_SAFE (elt)))
+ if (EQ (QCarray, CAR_SAFE (elt)))
elt = XD_NEXT_VALUE (elt);
/* If the array is empty, DBUS_TYPE_STRING is the default
@@ -1009,8 +1010,7 @@ xd_add_watch (DBusWatch *watch, void *data)
}
/* Stop monitoring WATCH for possible I/O.
- DATA is the used bus, either a string or QCdbus_system_bus or
- QCdbus_session_bus. */
+ DATA is the used bus, either a string or QCsystem or QCsession. */
static void
xd_remove_watch (DBusWatch *watch, void *data)
{
@@ -1025,7 +1025,7 @@ xd_remove_watch (DBusWatch *watch, void *data)
/* Unset session environment. */
#if 0
/* This is buggy, since unsetenv is not thread-safe. */
- if (XSYMBOL (QCdbus_session_bus) == data)
+ if (XSYMBOL (QCsession) == data)
{
XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
unsetenv ("DBUS_SESSION_BUS_ADDRESS");
@@ -1147,14 +1147,14 @@ this connection to those buses. */)
connection = dbus_connection_open_private (SSDATA (bus), &derror);
else
- if (NILP (private))
- connection = dbus_bus_get (EQ (bus, QCdbus_system_bus)
- ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION,
- &derror);
- else
- connection = dbus_bus_get_private (EQ (bus, QCdbus_system_bus)
- ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION,
- &derror);
+ {
+ DBusBusType bustype = (EQ (bus, QCsystem)
+ ? DBUS_BUS_SYSTEM : DBUS_BUS_SESSION);
+ if (NILP (private))
+ connection = dbus_bus_get (bustype, &derror);
+ else
+ connection = dbus_bus_get_private (bustype, &derror);
+ }
if (dbus_error_is_set (&derror))
XD_ERROR (derror);
@@ -1309,7 +1309,7 @@ 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))
wrong_type_argument (Qinvalid_function, handler);
}
@@ -1405,7 +1405,7 @@ usage: (dbus-message-internal &rest REST) */)
}
/* Check for timeout parameter. */
- if ((count+2 <= nargs) && (EQ ((args[count]), QCdbus_timeout)))
+ if ((count + 2 <= nargs) && EQ (args[count], QCtimeout))
{
CHECK_NATNUM (args[count+1]);
timeout = min (XFASTINT (args[count+1]), INT_MAX);
@@ -1452,8 +1452,7 @@ usage: (dbus-message-internal &rest REST) */)
/* The result is the key in Vdbus_registered_objects_table. */
serial = dbus_message_get_serial (dmessage);
- result = list3 (QCdbus_registered_serial,
- bus, make_fixnum_or_float (serial));
+ result = list3 (QCserial, bus, make_fixnum_or_float (serial));
/* Create a hash table entry. */
Fputhash (result, handler, Vdbus_registered_objects_table);
@@ -1540,8 +1539,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
|| (mtype == DBUS_MESSAGE_TYPE_ERROR))
{
/* Search for a registered function of the message. */
- key = list3 (QCdbus_registered_serial, bus,
- make_fixnum_or_float (serial));
+ key = list3 (QCserial, bus, make_fixnum_or_float (serial));
value = Fgethash (key, Vdbus_registered_objects_table, Qnil);
/* There shall be exactly one entry. Construct an event. */
@@ -1566,9 +1564,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus)
goto cleanup;
/* Search for a registered function of the message. */
- key = list4 ((mtype == DBUS_MESSAGE_TYPE_METHOD_CALL)
- ? QCdbus_registered_method
- : QCdbus_registered_signal,
+ key = list4 (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL ? QCmethod : QCsignal,
bus, build_string (interface), build_string (member));
value = Fgethash (key, Vdbus_registered_objects_table, Qnil);
@@ -1697,37 +1693,37 @@ syms_of_dbusbind (void)
build_pure_c_string ("D-Bus error"));
/* Lisp symbols of the system and session buses. */
- DEFSYM (QCdbus_system_bus, ":system");
- DEFSYM (QCdbus_session_bus, ":session");
+ DEFSYM (QCsystem, ":system");
+ DEFSYM (QCsession, ":session");
/* Lisp symbol for method call timeout. */
- DEFSYM (QCdbus_timeout, ":timeout");
+ DEFSYM (QCtimeout, ":timeout");
/* Lisp symbols of D-Bus types. */
- DEFSYM (QCdbus_type_byte, ":byte");
- DEFSYM (QCdbus_type_boolean, ":boolean");
- DEFSYM (QCdbus_type_int16, ":int16");
- DEFSYM (QCdbus_type_uint16, ":uint16");
- DEFSYM (QCdbus_type_int32, ":int32");
- DEFSYM (QCdbus_type_uint32, ":uint32");
- DEFSYM (QCdbus_type_int64, ":int64");
- DEFSYM (QCdbus_type_uint64, ":uint64");
- DEFSYM (QCdbus_type_double, ":double");
- DEFSYM (QCdbus_type_string, ":string");
- DEFSYM (QCdbus_type_object_path, ":object-path");
- DEFSYM (QCdbus_type_signature, ":signature");
+ DEFSYM (QCbyte, ":byte");
+ DEFSYM (QCboolean, ":boolean");
+ DEFSYM (QCint16, ":int16");
+ DEFSYM (QCuint16, ":uint16");
+ DEFSYM (QCint32, ":int32");
+ DEFSYM (QCuint32, ":uint32");
+ DEFSYM (QCint64, ":int64");
+ DEFSYM (QCuint64, ":uint64");
+ DEFSYM (QCdouble, ":double");
+ DEFSYM (QCstring, ":string");
+ DEFSYM (QCobject_path, ":object-path");
+ DEFSYM (QCsignature, ":signature");
#ifdef DBUS_TYPE_UNIX_FD
- DEFSYM (QCdbus_type_unix_fd, ":unix-fd");
+ DEFSYM (QCunix_fd, ":unix-fd");
#endif
- DEFSYM (QCdbus_type_array, ":array");
- DEFSYM (QCdbus_type_variant, ":variant");
- DEFSYM (QCdbus_type_struct, ":struct");
- DEFSYM (QCdbus_type_dict_entry, ":dict-entry");
+ DEFSYM (QCarray, ":array");
+ DEFSYM (QCvariant, ":variant");
+ DEFSYM (QCstruct, ":struct");
+ DEFSYM (QCdict_entry, ":dict-entry");
/* Lisp symbols of objects in `dbus-registered-objects-table'. */
- DEFSYM (QCdbus_registered_serial, ":serial");
- DEFSYM (QCdbus_registered_method, ":method");
- DEFSYM (QCdbus_registered_signal, ":signal");
+ DEFSYM (QCserial, ":serial");
+ DEFSYM (QCmethod, ":method");
+ DEFSYM (QCsignal, ":signal");
DEFVAR_LISP ("dbus-compiled-version",
Vdbus_compiled_version,