aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbusbind.c
diff options
context:
space:
mode:
authorMichael Albinus2008-01-03 21:27:25 +0000
committerMichael Albinus2008-01-03 21:27:25 +0000
commit5125905efd436e023d09290dad500e4e0eaed3d5 (patch)
tree5588595394c94cc9e83f145cf9a824aa44443055 /src/dbusbind.c
parent7d1112ae98dc7d8eb1664b6867fe9c980f6fe896 (diff)
downloademacs-5125905efd436e023d09290dad500e4e0eaed3d5.tar.gz
emacs-5125905efd436e023d09290dad500e4e0eaed3d5.zip
* dbusbind.c (all): Replace XCAR by CAR_SAFE and XCDR by CDR_SAFE.
(xd_signature, xd_append_arg): Handle element type detection for empty arrays. (Fdbus_call_method, Fdbus_send_signal): Undo type casting for SDATA () calls; this must be solved more general. (Fdbus_register_signal): Use SBYTES instead of strlen.
Diffstat (limited to 'src/dbusbind.c')
-rw-r--r--src/dbusbind.c191
1 files changed, 126 insertions, 65 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c
index a0c928d0eea..9afa62ae790 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -159,14 +159,14 @@ Lisp_Object Vdbus_debug;
159 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ 159 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \
160 : (STRINGP (object)) ? DBUS_TYPE_STRING \ 160 : (STRINGP (object)) ? DBUS_TYPE_STRING \
161 : (XD_DBUS_TYPE_P (object)) ? XD_SYMBOL_TO_DBUS_TYPE (object) \ 161 : (XD_DBUS_TYPE_P (object)) ? XD_SYMBOL_TO_DBUS_TYPE (object) \
162 : (CONSP (object)) ? ((XD_DBUS_TYPE_P (XCAR (object))) \ 162 : (CONSP (object)) ? ((XD_DBUS_TYPE_P (CAR_SAFE (object))) \
163 ? XD_SYMBOL_TO_DBUS_TYPE (XCAR (object)) \ 163 ? XD_SYMBOL_TO_DBUS_TYPE (CAR_SAFE (object)) \
164 : DBUS_TYPE_ARRAY) \ 164 : DBUS_TYPE_ARRAY) \
165 : DBUS_TYPE_INVALID) 165 : DBUS_TYPE_INVALID)
166 166
167/* Return a list pointer which does not have a Lisp symbol as car. */ 167/* Return a list pointer which does not have a Lisp symbol as car. */
168#define XD_NEXT_VALUE(object) \ 168#define XD_NEXT_VALUE(object) \
169 ((XD_DBUS_TYPE_P (XCAR (object))) ? XCDR (object) : object) 169 ((XD_DBUS_TYPE_P (CAR_SAFE (object))) ? CDR_SAFE (object) : object)
170 170
171/* Compute SIGNATURE of OBJECT. It must have a form that it can be 171/* Compute SIGNATURE of OBJECT. It must have a form that it can be
172 used in dbus_message_iter_open_container. DTYPE is the DBusType 172 used in dbus_message_iter_open_container. DTYPE is the DBusType
@@ -228,16 +228,36 @@ xd_signature(signature, dtype, parent_type, object)
228 the whole element's signature. */ 228 the whole element's signature. */
229 CHECK_CONS (object); 229 CHECK_CONS (object);
230 230
231 if (EQ (QCdbus_type_array, XCAR (elt))) /* Type symbol is optional. */ 231 /* Type symbol is optional. */
232 if (EQ (QCdbus_type_array, CAR_SAFE (elt)))
232 elt = XD_NEXT_VALUE (elt); 233 elt = XD_NEXT_VALUE (elt);
233 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); 234
234 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); 235 /* If the array is empty, DBUS_TYPE_STRING is the default
236 element type. */
237 if (NILP (elt))
238 {
239 subtype = DBUS_TYPE_STRING;
240 strcpy (x, DBUS_TYPE_STRING_AS_STRING);
241 }
242 else
243 {
244 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
245 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
246 }
247
248 /* If the element type is DBUS_TYPE_SIGNATURE, and this is the
249 only element, the value of this element is used as he array's
250 element signature. */
251 if ((subtype == DBUS_TYPE_SIGNATURE)
252 && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt)))
253 && NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
254 strcpy (x, SDATA (CAR_SAFE (XD_NEXT_VALUE (elt))));
235 255
236 while (!NILP (elt)) 256 while (!NILP (elt))
237 { 257 {
238 if (subtype != XD_OBJECT_TO_DBUS_TYPE (XCAR (elt))) 258 if (subtype != XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)))
239 wrong_type_argument (intern ("D-Bus"), XCAR (elt)); 259 wrong_type_argument (intern ("D-Bus"), CAR_SAFE (elt));
240 elt = XCDR (XD_NEXT_VALUE (elt)); 260 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
241 } 261 }
242 262
243 sprintf (signature, "%c%s", dtype, x); 263 sprintf (signature, "%c%s", dtype, x);
@@ -248,12 +268,12 @@ xd_signature(signature, dtype, parent_type, object)
248 CHECK_CONS (object); 268 CHECK_CONS (object);
249 269
250 elt = XD_NEXT_VALUE (elt); 270 elt = XD_NEXT_VALUE (elt);
251 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); 271 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
252 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); 272 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
253 273
254 if (!NILP (XCDR (XD_NEXT_VALUE (elt)))) 274 if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
255 wrong_type_argument (intern ("D-Bus"), 275 wrong_type_argument (intern ("D-Bus"),
256 XCAR (XCDR (XD_NEXT_VALUE (elt)))); 276 CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt))));
257 277
258 sprintf (signature, "%c", dtype); 278 sprintf (signature, "%c", dtype);
259 break; 279 break;
@@ -270,10 +290,10 @@ xd_signature(signature, dtype, parent_type, object)
270 sprintf (signature, "%c", DBUS_STRUCT_BEGIN_CHAR ); 290 sprintf (signature, "%c", DBUS_STRUCT_BEGIN_CHAR );
271 while (!NILP (elt)) 291 while (!NILP (elt))
272 { 292 {
273 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); 293 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
274 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); 294 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
275 strcat (signature, x); 295 strcat (signature, x);
276 elt = XCDR (XD_NEXT_VALUE (elt)); 296 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
277 } 297 }
278 sprintf (signature, "%s%c", signature, DBUS_STRUCT_END_CHAR); 298 sprintf (signature, "%s%c", signature, DBUS_STRUCT_END_CHAR);
279 break; 299 break;
@@ -294,22 +314,22 @@ xd_signature(signature, dtype, parent_type, object)
294 314
295 /* First element. */ 315 /* First element. */
296 elt = XD_NEXT_VALUE (elt); 316 elt = XD_NEXT_VALUE (elt);
297 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); 317 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
298 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); 318 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
299 strcat (signature, x); 319 strcat (signature, x);
300 320
301 if (!XD_BASIC_DBUS_TYPE (subtype)) 321 if (!XD_BASIC_DBUS_TYPE (subtype))
302 wrong_type_argument (intern ("D-Bus"), XCAR (XD_NEXT_VALUE (elt))); 322 wrong_type_argument (intern ("D-Bus"), CAR_SAFE (XD_NEXT_VALUE (elt)));
303 323
304 /* Second element. */ 324 /* Second element. */
305 elt = XCDR (XD_NEXT_VALUE (elt)); 325 elt = CDR_SAFE (XD_NEXT_VALUE (elt));
306 subtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (elt)); 326 subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt));
307 xd_signature (x, subtype, dtype, XCAR (XD_NEXT_VALUE (elt))); 327 xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt)));
308 strcat (signature, x); 328 strcat (signature, x);
309 329
310 if (!NILP (XCDR (XD_NEXT_VALUE (elt)))) 330 if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt))))
311 wrong_type_argument (intern ("D-Bus"), 331 wrong_type_argument (intern ("D-Bus"),
312 XCAR (XCDR (XD_NEXT_VALUE (elt)))); 332 CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt))));
313 333
314 /* Closing signature. */ 334 /* Closing signature. */
315 sprintf (signature, "%s%c", signature, DBUS_DICT_ENTRY_END_CHAR); 335 sprintf (signature, "%s%c", signature, DBUS_DICT_ENTRY_END_CHAR);
@@ -445,20 +465,54 @@ xd_append_arg (dtype, object, iter)
445 465
446 /* All compound types except array have a type symbol. For 466 /* All compound types except array have a type symbol. For
447 array, it is optional. Skip it. */ 467 array, it is optional. Skip it. */
448 if (!XD_BASIC_DBUS_TYPE (XD_OBJECT_TO_DBUS_TYPE (XCAR (object)))) 468 if (!XD_BASIC_DBUS_TYPE (XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object))))
449 object = XD_NEXT_VALUE (object); 469 object = XD_NEXT_VALUE (object);
450 470
451 /* Open new subiteration. */ 471 /* Open new subiteration. */
452 switch (dtype) 472 switch (dtype)
453 { 473 {
454 case DBUS_TYPE_ARRAY: 474 case DBUS_TYPE_ARRAY:
475 /* An array has only elements of the same type. So it is
476 sufficient to check the first element's signature
477 only. */
478
479 if (NILP (object))
480 /* If the array is empty, DBUS_TYPE_STRING is the default
481 element type. */
482 strcpy (signature, DBUS_TYPE_STRING_AS_STRING);
483
484 else
485 /* If the element type is DBUS_TYPE_SIGNATURE, and this is
486 the only element, the value of this element is used as
487 the array's element signature. */
488 if ((XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object))
489 == DBUS_TYPE_SIGNATURE)
490 && STRINGP (CAR_SAFE (XD_NEXT_VALUE (object)))
491 && NILP (CDR_SAFE (XD_NEXT_VALUE (object))))
492 {
493 strcpy (signature, SDATA (CAR_SAFE (XD_NEXT_VALUE (object))));
494 object = CDR_SAFE (XD_NEXT_VALUE (object));
495 }
496
497 else
498 xd_signature (signature,
499 XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object)),
500 dtype, CAR_SAFE (XD_NEXT_VALUE (object)));
501
502 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature,
503 SDATA (format2 ("%s", object, Qnil)));
504 if (!dbus_message_iter_open_container (iter, dtype,
505 signature, &subiter))
506 xsignal3 (Qdbus_error,
507 build_string ("Cannot open container"),
508 make_number (dtype), build_string (signature));
509 break;
510
455 case DBUS_TYPE_VARIANT: 511 case DBUS_TYPE_VARIANT:
456 /* A variant has just one element. An array has elements of 512 /* A variant has just one element. */
457 the same type. Both have been checked already for 513 xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object)),
458 correct types, it is sufficient to retrieve just the 514 dtype, CAR_SAFE (XD_NEXT_VALUE (object)));
459 signature of the first element. */ 515
460 xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (XCAR (object)),
461 dtype, XCAR (XD_NEXT_VALUE (object)));
462 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, 516 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature,
463 SDATA (format2 ("%s", object, Qnil))); 517 SDATA (format2 ("%s", object, Qnil)));
464 if (!dbus_message_iter_open_container (iter, dtype, 518 if (!dbus_message_iter_open_container (iter, dtype,
@@ -483,12 +537,12 @@ xd_append_arg (dtype, object, iter)
483 /* Loop over list elements. */ 537 /* Loop over list elements. */
484 while (!NILP (object)) 538 while (!NILP (object))
485 { 539 {
486 dtype = XD_OBJECT_TO_DBUS_TYPE (XCAR (object)); 540 dtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (object));
487 object = XD_NEXT_VALUE (object); 541 object = XD_NEXT_VALUE (object);
488 542
489 xd_append_arg (dtype, XCAR (object), &subiter); 543 xd_append_arg (dtype, CAR_SAFE (object), &subiter);
490 544
491 object = XCDR (object); 545 object = CDR_SAFE (object);
492 } 546 }
493 547
494 /* Close the subiteration. */ 548 /* Close the subiteration. */
@@ -591,6 +645,7 @@ xd_retrieve_arg (dtype, iter)
591 result = Fcons (xd_retrieve_arg (subtype, &subiter), result); 645 result = Fcons (xd_retrieve_arg (subtype, &subiter), result);
592 dbus_message_iter_next (&subiter); 646 dbus_message_iter_next (&subiter);
593 } 647 }
648 XD_DEBUG_MESSAGE ("%c %s", dtype, SDATA (format2 ("%s", result, Qnil)));
594 RETURN_UNGCPRO (Fnreverse (result)); 649 RETURN_UNGCPRO (Fnreverse (result));
595 } 650 }
596 651
@@ -600,7 +655,6 @@ xd_retrieve_arg (dtype, iter)
600 } 655 }
601} 656}
602 657
603
604/* Initialize D-Bus connection. BUS is a Lisp symbol, either :system 658/* Initialize D-Bus connection. BUS is a Lisp symbol, either :system
605 or :session. It tells which D-Bus to be initialized. */ 659 or :session. It tells which D-Bus to be initialized. */
606DBusConnection * 660DBusConnection *
@@ -635,7 +689,7 @@ xd_initialize (bus)
635 689
636DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name, 690DEFUN ("dbus-get-unique-name", Fdbus_get_unique_name, Sdbus_get_unique_name,
637 1, 1, 0, 691 1, 1, 0,
638 doc: /* Return the unique name of Emacs registered at D-Bus BUS as string. */) 692 doc: /* Return the unique name of Emacs registered at D-Bus BUS. */)
639 (bus) 693 (bus)
640 Lisp_Object bus; 694 Lisp_Object bus;
641{ 695{
@@ -760,10 +814,10 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
760 connection = xd_initialize (bus); 814 connection = xd_initialize (bus);
761 815
762 /* Create the message. */ 816 /* Create the message. */
763 dmessage = dbus_message_new_method_call ((char *) SDATA (service), 817 dmessage = dbus_message_new_method_call (SDATA (service),
764 (char *) SDATA (path), 818 SDATA (path),
765 (char *) SDATA (interface), 819 SDATA (interface),
766 (char *) SDATA (method)); 820 SDATA (method));
767 if (dmessage == NULL) 821 if (dmessage == NULL)
768 { 822 {
769 UNGCPRO; 823 UNGCPRO;
@@ -835,7 +889,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
835 /* Return the result. If there is only one single Lisp object, 889 /* Return the result. If there is only one single Lisp object,
836 return it as-it-is, otherwise return the reversed list. */ 890 return it as-it-is, otherwise return the reversed list. */
837 if (XUINT (Flength (result)) == 1) 891 if (XUINT (Flength (result)) == 1)
838 RETURN_UNGCPRO (XCAR (result)); 892 RETURN_UNGCPRO (CAR_SAFE (result));
839 else 893 else
840 RETURN_UNGCPRO (Fnreverse (result)); 894 RETURN_UNGCPRO (Fnreverse (result));
841} 895}
@@ -906,9 +960,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */)
906 connection = xd_initialize (bus); 960 connection = xd_initialize (bus);
907 961
908 /* Create the message. */ 962 /* Create the message. */
909 dmessage = dbus_message_new_signal ((char *) SDATA (path), 963 dmessage = dbus_message_new_signal (SDATA (path),
910 (char *) SDATA (interface), 964 SDATA (interface),
911 (char *) SDATA (signal)); 965 SDATA (signal));
912 if (dmessage == NULL) 966 if (dmessage == NULL)
913 { 967 {
914 UNGCPRO; 968 UNGCPRO;
@@ -1021,20 +1075,22 @@ xd_read_message (bus)
1021 /* Loop over the registered functions. Construct an event. */ 1075 /* Loop over the registered functions. Construct an event. */
1022 while (!NILP (value)) 1076 while (!NILP (value))
1023 { 1077 {
1024 key = XCAR (value); 1078 key = CAR_SAFE (value);
1025 /* key has the structure (UNAME SERVICE PATH HANDLER). */ 1079 /* key has the structure (UNAME SERVICE PATH HANDLER). */
1026 if (((uname == NULL) 1080 if (((uname == NULL)
1027 || (NILP (XCAR (key))) 1081 || (NILP (CAR_SAFE (key)))
1028 || (strcmp (uname, SDATA (XCAR (key))) == 0)) 1082 || (strcmp (uname, SDATA (CAR_SAFE (key))) == 0))
1029 && ((path == NULL) 1083 && ((path == NULL)
1030 || (NILP (XCAR (XCDR (XCDR (key))))) 1084 || (NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (key)))))
1031 || (strcmp (path, SDATA (XCAR (XCDR (XCDR (key))))) == 0)) 1085 || (strcmp (path, SDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key)))))
1032 && (!NILP (XCAR (XCDR (XCDR (XCDR (key))))))) 1086 == 0))
1087 && (!NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))))))
1033 { 1088 {
1034 EVENT_INIT (event); 1089 EVENT_INIT (event);
1035 event.kind = DBUS_EVENT; 1090 event.kind = DBUS_EVENT;
1036 event.frame_or_window = Qnil; 1091 event.frame_or_window = Qnil;
1037 event.arg = Fcons (XCAR (XCDR (XCDR (XCDR (key)))), args); 1092 event.arg = Fcons (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))),
1093 args);
1038 1094
1039 /* Add uname, path, interface and member to the event. */ 1095 /* Add uname, path, interface and member to the event. */
1040 event.arg = Fcons ((member == NULL ? Qnil : build_string (member)), 1096 event.arg = Fcons ((member == NULL ? Qnil : build_string (member)),
@@ -1053,7 +1109,7 @@ xd_read_message (bus)
1053 /* Store it into the input event queue. */ 1109 /* Store it into the input event queue. */
1054 kbd_buffer_store_event (&event); 1110 kbd_buffer_store_event (&event);
1055 } 1111 }
1056 value = XCDR (value); 1112 value = CDR_SAFE (value);
1057 } 1113 }
1058 1114
1059 /* Cleanup. */ 1115 /* Cleanup. */
@@ -1131,8 +1187,8 @@ SIGNAL and HANDLER must not be nil. Example:
1131 will register for the corresponding unique name, if any. Signals 1187 will register for the corresponding unique name, if any. Signals
1132 are sent always with the unique name as sender. Note: the unique 1188 are sent always with the unique name as sender. Note: the unique
1133 name of "org.freedesktop.DBus" is that string itself. */ 1189 name of "org.freedesktop.DBus" is that string itself. */
1134 if ((!NILP (service)) 1190 if ((STRINGP (service))
1135 && (strlen (SDATA (service)) > 0) 1191 && (SBYTES (service) > 0)
1136 && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0) 1192 && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0)
1137 && (strncmp (SDATA (service), ":", 1) != 0)) 1193 && (strncmp (SDATA (service), ":", 1) != 0))
1138 { 1194 {
@@ -1147,7 +1203,7 @@ SIGNAL and HANDLER must not be nil. Example:
1147 1203
1148 /* Create a matching rule if the unique name exists (when no 1204 /* Create a matching rule if the unique name exists (when no
1149 wildcard). */ 1205 wildcard). */
1150 if (NILP (uname) || (strlen (SDATA (uname)) > 0)) 1206 if (NILP (uname) || (SBYTES (uname) > 0))
1151 { 1207 {
1152 /* Open a connection to the bus. */ 1208 /* Open a connection to the bus. */
1153 connection = xd_initialize (bus); 1209 connection = xd_initialize (bus);
@@ -1248,7 +1304,8 @@ The function is not fully implemented and documented. Don't use it. */)
1248 return list2 (key, list3 (service, path, handler)); 1304 return list2 (key, list3 (service, path, handler));
1249} 1305}
1250 1306
1251DEFUN ("dbus-unregister-object", Fdbus_unregister_object, Sdbus_unregister_object, 1307DEFUN ("dbus-unregister-object", Fdbus_unregister_object,
1308 Sdbus_unregister_object,
1252 1, 1, 0, 1309 1, 1, 0,
1253 doc: /* Unregister OBJECT from the D-Bus. 1310 doc: /* Unregister OBJECT from the D-Bus.
1254OBJECT must be the result of a preceding `dbus-register-signal' or 1311OBJECT must be the result of a preceding `dbus-register-signal' or
@@ -1261,11 +1318,12 @@ unregistered, nil otherwise. */)
1261 struct gcpro gcpro1; 1318 struct gcpro gcpro1;
1262 1319
1263 /* Check parameter. */ 1320 /* Check parameter. */
1264 if (!(CONSP (object) && (!NILP (XCAR (object))) && CONSP (XCDR (object)))) 1321 if (!(CONSP (object) && (!NILP (CAR_SAFE (object)))
1322 && CONSP (CDR_SAFE (object))))
1265 wrong_type_argument (intern ("D-Bus"), object); 1323 wrong_type_argument (intern ("D-Bus"), object);
1266 1324
1267 /* Find the corresponding entry in the hash table. */ 1325 /* Find the corresponding entry in the hash table. */
1268 value = Fgethash (XCAR (object), Vdbus_registered_functions_table, Qnil); 1326 value = Fgethash (CAR_SAFE (object), Vdbus_registered_functions_table, Qnil);
1269 1327
1270 /* Loop over the registered functions. */ 1328 /* Loop over the registered functions. */
1271 while (!NILP (value)) 1329 while (!NILP (value))
@@ -1274,20 +1332,22 @@ unregistered, nil otherwise. */)
1274 1332
1275 /* (car value) has the structure (UNAME SERVICE PATH HANDLER). 1333 /* (car value) has the structure (UNAME SERVICE PATH HANDLER).
1276 (cdr object) has the structure ((SERVICE PATH HANDLER) ...). */ 1334 (cdr object) has the structure ((SERVICE PATH HANDLER) ...). */
1277 if (!NILP (Fequal (XCDR (XCAR (value)), XCAR (XCDR (object))))) 1335 if (!NILP (Fequal (CDR_SAFE (CAR_SAFE (value)),
1336 CAR_SAFE (CDR_SAFE (object)))))
1278 { 1337 {
1279 /* Compute new hash value. */ 1338 /* Compute new hash value. */
1280 value = Fdelete (XCAR (value), 1339 value = Fdelete (CAR_SAFE (value),
1281 Fgethash (XCAR (object), 1340 Fgethash (CAR_SAFE (object),
1282 Vdbus_registered_functions_table, Qnil)); 1341 Vdbus_registered_functions_table, Qnil));
1283 if (NILP (value)) 1342 if (NILP (value))
1284 Fremhash (XCAR (object), Vdbus_registered_functions_table); 1343 Fremhash (CAR_SAFE (object), Vdbus_registered_functions_table);
1285 else 1344 else
1286 Fputhash (XCAR (object), value, Vdbus_registered_functions_table); 1345 Fputhash (CAR_SAFE (object), value,
1346 Vdbus_registered_functions_table);
1287 RETURN_UNGCPRO (Qt); 1347 RETURN_UNGCPRO (Qt);
1288 } 1348 }
1289 UNGCPRO; 1349 UNGCPRO;
1290 value = XCDR (value); 1350 value = CDR_SAFE (value);
1291 } 1351 }
1292 1352
1293 /* Return. */ 1353 /* Return. */
@@ -1384,7 +1444,8 @@ syms_of_dbusbind ()
1384 QCdbus_type_dict_entry = intern (":dict-entry"); 1444 QCdbus_type_dict_entry = intern (":dict-entry");
1385 staticpro (&QCdbus_type_dict_entry); 1445 staticpro (&QCdbus_type_dict_entry);
1386 1446
1387 DEFVAR_LISP ("dbus-registered-functions-table", &Vdbus_registered_functions_table, 1447 DEFVAR_LISP ("dbus-registered-functions-table",
1448 &Vdbus_registered_functions_table,
1388 doc: /* Hash table of registered functions for D-Bus. 1449 doc: /* Hash table of registered functions for D-Bus.
1389The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is 1450The key in the hash table is the list (BUS INTERFACE MEMBER). BUS is
1390either the symbol `:system' or the symbol `:session'. INTERFACE is a 1451either the symbol `:system' or the symbol `:session'. INTERFACE is a