diff options
Diffstat (limited to 'src/dbusbind.c')
| -rw-r--r-- | src/dbusbind.c | 291 |
1 files changed, 163 insertions, 128 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c index 7e5104026cd..f662d5b38a2 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -30,53 +30,53 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | /* Subroutines. */ | 32 | /* Subroutines. */ |
| 33 | Lisp_Object Qdbus_init_bus; | 33 | static Lisp_Object Qdbus_init_bus; |
| 34 | Lisp_Object Qdbus_close_bus; | 34 | static Lisp_Object Qdbus_close_bus; |
| 35 | Lisp_Object Qdbus_get_unique_name; | 35 | static Lisp_Object Qdbus_get_unique_name; |
| 36 | Lisp_Object Qdbus_call_method; | 36 | static Lisp_Object Qdbus_call_method; |
| 37 | Lisp_Object Qdbus_call_method_asynchronously; | 37 | static Lisp_Object Qdbus_call_method_asynchronously; |
| 38 | Lisp_Object Qdbus_method_return_internal; | 38 | static Lisp_Object Qdbus_method_return_internal; |
| 39 | Lisp_Object Qdbus_method_error_internal; | 39 | static Lisp_Object Qdbus_method_error_internal; |
| 40 | Lisp_Object Qdbus_send_signal; | 40 | static Lisp_Object Qdbus_send_signal; |
| 41 | Lisp_Object Qdbus_register_service; | 41 | static Lisp_Object Qdbus_register_service; |
| 42 | Lisp_Object Qdbus_register_signal; | 42 | static Lisp_Object Qdbus_register_signal; |
| 43 | Lisp_Object Qdbus_register_method; | 43 | static Lisp_Object Qdbus_register_method; |
| 44 | 44 | ||
| 45 | /* D-Bus error symbol. */ | 45 | /* D-Bus error symbol. */ |
| 46 | Lisp_Object Qdbus_error; | 46 | static Lisp_Object Qdbus_error; |
| 47 | 47 | ||
| 48 | /* Lisp symbols of the system and session buses. */ | 48 | /* Lisp symbols of the system and session buses. */ |
| 49 | Lisp_Object QCdbus_system_bus, QCdbus_session_bus; | 49 | static Lisp_Object QCdbus_system_bus, QCdbus_session_bus; |
| 50 | 50 | ||
| 51 | /* Lisp symbol for method call timeout. */ | 51 | /* Lisp symbol for method call timeout. */ |
| 52 | Lisp_Object QCdbus_timeout; | 52 | static Lisp_Object QCdbus_timeout; |
| 53 | 53 | ||
| 54 | /* Lisp symbols for name request flags. */ | 54 | /* Lisp symbols for name request flags. */ |
| 55 | Lisp_Object QCdbus_request_name_allow_replacement; | 55 | static Lisp_Object QCdbus_request_name_allow_replacement; |
| 56 | Lisp_Object QCdbus_request_name_replace_existing; | 56 | static Lisp_Object QCdbus_request_name_replace_existing; |
| 57 | Lisp_Object QCdbus_request_name_do_not_queue; | 57 | static Lisp_Object QCdbus_request_name_do_not_queue; |
| 58 | 58 | ||
| 59 | /* Lisp symbols for name request replies. */ | 59 | /* Lisp symbols for name request replies. */ |
| 60 | Lisp_Object QCdbus_request_name_reply_primary_owner; | 60 | static Lisp_Object QCdbus_request_name_reply_primary_owner; |
| 61 | Lisp_Object QCdbus_request_name_reply_in_queue; | 61 | static Lisp_Object QCdbus_request_name_reply_in_queue; |
| 62 | Lisp_Object QCdbus_request_name_reply_exists; | 62 | static Lisp_Object QCdbus_request_name_reply_exists; |
| 63 | Lisp_Object QCdbus_request_name_reply_already_owner; | 63 | static Lisp_Object QCdbus_request_name_reply_already_owner; |
| 64 | 64 | ||
| 65 | /* Lisp symbols of D-Bus types. */ | 65 | /* Lisp symbols of D-Bus types. */ |
| 66 | Lisp_Object QCdbus_type_byte, QCdbus_type_boolean; | 66 | static Lisp_Object QCdbus_type_byte, QCdbus_type_boolean; |
| 67 | Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; | 67 | static Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; |
| 68 | Lisp_Object QCdbus_type_int32, QCdbus_type_uint32; | 68 | static Lisp_Object QCdbus_type_int32, QCdbus_type_uint32; |
| 69 | Lisp_Object QCdbus_type_int64, QCdbus_type_uint64; | 69 | static Lisp_Object QCdbus_type_int64, QCdbus_type_uint64; |
| 70 | Lisp_Object QCdbus_type_double, QCdbus_type_string; | 70 | static Lisp_Object QCdbus_type_double, QCdbus_type_string; |
| 71 | Lisp_Object QCdbus_type_object_path, QCdbus_type_signature; | 71 | static Lisp_Object QCdbus_type_object_path, QCdbus_type_signature; |
| 72 | #ifdef DBUS_TYPE_UNIX_FD | 72 | #ifdef DBUS_TYPE_UNIX_FD |
| 73 | Lisp_Object QCdbus_type_unix_fd; | 73 | static Lisp_Object QCdbus_type_unix_fd; |
| 74 | #endif | 74 | #endif |
| 75 | Lisp_Object QCdbus_type_array, QCdbus_type_variant; | 75 | static Lisp_Object QCdbus_type_array, QCdbus_type_variant; |
| 76 | Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; | 76 | static Lisp_Object QCdbus_type_struct, QCdbus_type_dict_entry; |
| 77 | 77 | ||
| 78 | /* Whether we are reading a D-Bus event. */ | 78 | /* Whether we are reading a D-Bus event. */ |
| 79 | int xd_in_read_queued_messages = 0; | 79 | static int xd_in_read_queued_messages = 0; |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | /* We use "xd_" and "XD_" as prefix for all internal symbols, because | 82 | /* We use "xd_" and "XD_" as prefix for all internal symbols, because |
| @@ -242,6 +242,24 @@ xd_symbol_to_dbus_type (Lisp_Object object) | |||
| 242 | #define XD_NEXT_VALUE(object) \ | 242 | #define XD_NEXT_VALUE(object) \ |
| 243 | ((XD_DBUS_TYPE_P (CAR_SAFE (object))) ? CDR_SAFE (object) : object) | 243 | ((XD_DBUS_TYPE_P (CAR_SAFE (object))) ? CDR_SAFE (object) : object) |
| 244 | 244 | ||
| 245 | /* Check whether X is a valid dbus serial number. If valid, set | ||
| 246 | SERIAL to its value. Otherwise, signal an error. */ | ||
| 247 | #define CHECK_DBUS_SERIAL_GET_SERIAL(x, serial) \ | ||
| 248 | do \ | ||
| 249 | { \ | ||
| 250 | dbus_uint32_t DBUS_SERIAL_MAX = -1; \ | ||
| 251 | if (NATNUMP (x) && XINT (x) <= DBUS_SERIAL_MAX) \ | ||
| 252 | serial = XINT (x); \ | ||
| 253 | else if (MOST_POSITIVE_FIXNUM < DBUS_SERIAL_MAX \ | ||
| 254 | && FLOATP (x) \ | ||
| 255 | && 0 <= XFLOAT_DATA (x) \ | ||
| 256 | && XFLOAT_DATA (x) <= DBUS_SERIAL_MAX) \ | ||
| 257 | serial = XFLOAT_DATA (x); \ | ||
| 258 | else \ | ||
| 259 | XD_SIGNAL2 (build_string ("Invalid dbus serial"), x); \ | ||
| 260 | } \ | ||
| 261 | while (0) | ||
| 262 | |||
| 245 | /* Compute SIGNATURE of OBJECT. It must have a form that it can be | 263 | /* Compute SIGNATURE of OBJECT. It must have a form that it can be |
| 246 | used in dbus_message_iter_open_container. DTYPE is the DBusType | 264 | used in dbus_message_iter_open_container. DTYPE is the DBusType |
| 247 | the object is related to. It is passed as argument, because it | 265 | the object is related to. It is passed as argument, because it |
| @@ -325,7 +343,7 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 325 | if ((subtype == DBUS_TYPE_SIGNATURE) | 343 | if ((subtype == DBUS_TYPE_SIGNATURE) |
| 326 | && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt))) | 344 | && STRINGP (CAR_SAFE (XD_NEXT_VALUE (elt))) |
| 327 | && NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) | 345 | && NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) |
| 328 | strcpy (x, SDATA (CAR_SAFE (XD_NEXT_VALUE (elt)))); | 346 | strcpy (x, SSDATA (CAR_SAFE (XD_NEXT_VALUE (elt)))); |
| 329 | 347 | ||
| 330 | while (!NILP (elt)) | 348 | while (!NILP (elt)) |
| 331 | { | 349 | { |
| @@ -431,9 +449,9 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 431 | switch (dtype) | 449 | switch (dtype) |
| 432 | { | 450 | { |
| 433 | case DBUS_TYPE_BYTE: | 451 | case DBUS_TYPE_BYTE: |
| 434 | CHECK_NUMBER (object); | 452 | CHECK_NATNUM (object); |
| 435 | { | 453 | { |
| 436 | unsigned char val = XUINT (object) & 0xFF; | 454 | unsigned char val = XFASTINT (object) & 0xFF; |
| 437 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); | 455 | XD_DEBUG_MESSAGE ("%c %d", dtype, val); |
| 438 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 456 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 439 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 457 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -460,9 +478,9 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 460 | } | 478 | } |
| 461 | 479 | ||
| 462 | case DBUS_TYPE_UINT16: | 480 | case DBUS_TYPE_UINT16: |
| 463 | CHECK_NUMBER (object); | 481 | CHECK_NATNUM (object); |
| 464 | { | 482 | { |
| 465 | dbus_uint16_t val = XUINT (object); | 483 | dbus_uint16_t val = XFASTINT (object); |
| 466 | XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); | 484 | XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); |
| 467 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 485 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 468 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 486 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -483,9 +501,9 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 483 | #ifdef DBUS_TYPE_UNIX_FD | 501 | #ifdef DBUS_TYPE_UNIX_FD |
| 484 | case DBUS_TYPE_UNIX_FD: | 502 | case DBUS_TYPE_UNIX_FD: |
| 485 | #endif | 503 | #endif |
| 486 | CHECK_NUMBER (object); | 504 | CHECK_NATNUM (object); |
| 487 | { | 505 | { |
| 488 | dbus_uint32_t val = XUINT (object); | 506 | dbus_uint32_t val = XFASTINT (object); |
| 489 | XD_DEBUG_MESSAGE ("%c %u", dtype, val); | 507 | XD_DEBUG_MESSAGE ("%c %u", dtype, val); |
| 490 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 508 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 491 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 509 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -503,10 +521,10 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 503 | } | 521 | } |
| 504 | 522 | ||
| 505 | case DBUS_TYPE_UINT64: | 523 | case DBUS_TYPE_UINT64: |
| 506 | CHECK_NUMBER (object); | 524 | CHECK_NATNUM (object); |
| 507 | { | 525 | { |
| 508 | dbus_uint64_t val = XUINT (object); | 526 | dbus_uint64_t val = XFASTINT (object); |
| 509 | XD_DEBUG_MESSAGE ("%c %u", dtype, (unsigned int) val); | 527 | XD_DEBUG_MESSAGE ("%c %"pI"d", dtype, XFASTINT (object)); |
| 510 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 528 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 511 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 529 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| 512 | return; | 530 | return; |
| @@ -531,7 +549,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 531 | but by not encoding it, we guarantee it's valid utf-8, even if | 549 | but by not encoding it, we guarantee it's valid utf-8, even if |
| 532 | it contains eight-bit-bytes. Of course, you can still send | 550 | it contains eight-bit-bytes. Of course, you can still send |
| 533 | manually-crafted junk by passing a unibyte string. */ | 551 | manually-crafted junk by passing a unibyte string. */ |
| 534 | char *val = SDATA (object); | 552 | char *val = SSDATA (object); |
| 535 | XD_DEBUG_MESSAGE ("%c %s", dtype, val); | 553 | XD_DEBUG_MESSAGE ("%c %s", dtype, val); |
| 536 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) | 554 | if (!dbus_message_iter_append_basic (iter, dtype, &val)) |
| 537 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); | 555 | XD_SIGNAL2 (build_string ("Unable to append argument"), object); |
| @@ -569,7 +587,7 @@ xd_append_arg (unsigned int dtype, Lisp_Object object, DBusMessageIter *iter) | |||
| 569 | && STRINGP (CAR_SAFE (XD_NEXT_VALUE (object))) | 587 | && STRINGP (CAR_SAFE (XD_NEXT_VALUE (object))) |
| 570 | && NILP (CDR_SAFE (XD_NEXT_VALUE (object)))) | 588 | && NILP (CDR_SAFE (XD_NEXT_VALUE (object)))) |
| 571 | { | 589 | { |
| 572 | strcpy (signature, SDATA (CAR_SAFE (XD_NEXT_VALUE (object)))); | 590 | strcpy (signature, SSDATA (CAR_SAFE (XD_NEXT_VALUE (object)))); |
| 573 | object = CDR_SAFE (XD_NEXT_VALUE (object)); | 591 | object = CDR_SAFE (XD_NEXT_VALUE (object)); |
| 574 | } | 592 | } |
| 575 | 593 | ||
| @@ -789,7 +807,7 @@ xd_initialize (Lisp_Object bus, int raise_error) | |||
| 789 | dbus_error_init (&derror); | 807 | dbus_error_init (&derror); |
| 790 | 808 | ||
| 791 | if (STRINGP (bus)) | 809 | if (STRINGP (bus)) |
| 792 | connection = dbus_connection_open (SDATA (bus), &derror); | 810 | connection = dbus_connection_open (SSDATA (bus), &derror); |
| 793 | else | 811 | else |
| 794 | if (EQ (bus, QCdbus_system_bus)) | 812 | if (EQ (bus, QCdbus_system_bus)) |
| 795 | connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); | 813 | connection = dbus_bus_get (DBUS_BUS_SYSTEM, &derror); |
| @@ -892,7 +910,7 @@ xd_remove_watch (DBusWatch *watch, void *data) | |||
| 892 | return; | 910 | return; |
| 893 | 911 | ||
| 894 | /* Unset session environment. */ | 912 | /* Unset session environment. */ |
| 895 | if (data != NULL && data == (void*) XHASH (QCdbus_session_bus)) | 913 | if (XSYMBOL (QCdbus_session_bus) == data) |
| 896 | { | 914 | { |
| 897 | XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); | 915 | XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); |
| 898 | unsetenv ("DBUS_SESSION_BUS_ADDRESS"); | 916 | unsetenv ("DBUS_SESSION_BUS_ADDRESS"); |
| @@ -919,6 +937,15 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, | |||
| 919 | (Lisp_Object bus) | 937 | (Lisp_Object bus) |
| 920 | { | 938 | { |
| 921 | DBusConnection *connection; | 939 | DBusConnection *connection; |
| 940 | void *busp; | ||
| 941 | |||
| 942 | /* Check parameter. */ | ||
| 943 | if (SYMBOLP (bus)) | ||
| 944 | busp = XSYMBOL (bus); | ||
| 945 | else if (STRINGP (bus)) | ||
| 946 | busp = XSTRING (bus); | ||
| 947 | else | ||
| 948 | wrong_type_argument (intern ("D-Bus"), bus); | ||
| 922 | 949 | ||
| 923 | /* Open a connection to the bus. */ | 950 | /* Open a connection to the bus. */ |
| 924 | connection = xd_initialize (bus, TRUE); | 951 | connection = xd_initialize (bus, TRUE); |
| @@ -929,14 +956,14 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0, | |||
| 929 | xd_add_watch, | 956 | xd_add_watch, |
| 930 | xd_remove_watch, | 957 | xd_remove_watch, |
| 931 | xd_toggle_watch, | 958 | xd_toggle_watch, |
| 932 | (void*) XHASH (bus), NULL)) | 959 | busp, NULL)) |
| 933 | XD_SIGNAL1 (build_string ("Cannot add watch functions")); | 960 | XD_SIGNAL1 (build_string ("Cannot add watch functions")); |
| 934 | 961 | ||
| 935 | /* Add bus to list of registered buses. */ | 962 | /* Add bus to list of registered buses. */ |
| 936 | Vdbus_registered_buses = Fcons (bus, Vdbus_registered_buses); | 963 | Vdbus_registered_buses = Fcons (bus, Vdbus_registered_buses); |
| 937 | 964 | ||
| 938 | /* We do not want to abort. */ | 965 | /* We do not want to abort. */ |
| 939 | putenv ("DBUS_FATAL_WARNINGS=0"); | 966 | putenv ((char *) "DBUS_FATAL_WARNINGS=0"); |
| 940 | 967 | ||
| 941 | /* Return. */ | 968 | /* Return. */ |
| 942 | return Qnil; | 969 | return Qnil; |
| @@ -1051,7 +1078,7 @@ object is returned instead of a list containing this single Lisp object. | |||
| 1051 | => "i686" | 1078 | => "i686" |
| 1052 | 1079 | ||
| 1053 | usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TIMEOUT &rest ARGS) */) | 1080 | usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TIMEOUT &rest ARGS) */) |
| 1054 | (int nargs, register Lisp_Object *args) | 1081 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1055 | { | 1082 | { |
| 1056 | Lisp_Object bus, service, path, interface, method; | 1083 | Lisp_Object bus, service, path, interface, method; |
| 1057 | Lisp_Object result; | 1084 | Lisp_Object result; |
| @@ -1063,7 +1090,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1063 | DBusError derror; | 1090 | DBusError derror; |
| 1064 | unsigned int dtype; | 1091 | unsigned int dtype; |
| 1065 | int timeout = -1; | 1092 | int timeout = -1; |
| 1066 | int i = 5; | 1093 | ptrdiff_t i = 5; |
| 1067 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 1094 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 1068 | 1095 | ||
| 1069 | /* Check parameters. */ | 1096 | /* Check parameters. */ |
| @@ -1089,10 +1116,10 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1089 | connection = xd_initialize (bus, TRUE); | 1116 | connection = xd_initialize (bus, TRUE); |
| 1090 | 1117 | ||
| 1091 | /* Create the message. */ | 1118 | /* Create the message. */ |
| 1092 | dmessage = dbus_message_new_method_call (SDATA (service), | 1119 | dmessage = dbus_message_new_method_call (SSDATA (service), |
| 1093 | SDATA (path), | 1120 | SSDATA (path), |
| 1094 | SDATA (interface), | 1121 | SSDATA (interface), |
| 1095 | SDATA (method)); | 1122 | SSDATA (method)); |
| 1096 | UNGCPRO; | 1123 | UNGCPRO; |
| 1097 | if (dmessage == NULL) | 1124 | if (dmessage == NULL) |
| 1098 | XD_SIGNAL1 (build_string ("Unable to create a new message")); | 1125 | XD_SIGNAL1 (build_string ("Unable to create a new message")); |
| @@ -1101,7 +1128,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1101 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) | 1128 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) |
| 1102 | { | 1129 | { |
| 1103 | CHECK_NATNUM (args[i+1]); | 1130 | CHECK_NATNUM (args[i+1]); |
| 1104 | timeout = XUINT (args[i+1]); | 1131 | timeout = XFASTINT (args[i+1]); |
| 1105 | i = i+2; | 1132 | i = i+2; |
| 1106 | } | 1133 | } |
| 1107 | 1134 | ||
| @@ -1116,7 +1143,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1116 | { | 1143 | { |
| 1117 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1144 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1118 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | 1145 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); |
| 1119 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4, | 1146 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, |
| 1120 | SDATA (format2 ("%s", args[i], Qnil)), | 1147 | SDATA (format2 ("%s", args[i], Qnil)), |
| 1121 | SDATA (format2 ("%s", args[i+1], Qnil))); | 1148 | SDATA (format2 ("%s", args[i+1], Qnil))); |
| 1122 | ++i; | 1149 | ++i; |
| @@ -1124,7 +1151,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1124 | else | 1151 | else |
| 1125 | { | 1152 | { |
| 1126 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1153 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1127 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-4, | 1154 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, |
| 1128 | SDATA (format2 ("%s", args[i], Qnil))); | 1155 | SDATA (format2 ("%s", args[i], Qnil))); |
| 1129 | } | 1156 | } |
| 1130 | 1157 | ||
| @@ -1177,7 +1204,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &optional :timeout TI | |||
| 1177 | 1204 | ||
| 1178 | /* Return the result. If there is only one single Lisp object, | 1205 | /* Return the result. If there is only one single Lisp object, |
| 1179 | return it as-it-is, otherwise return the reversed list. */ | 1206 | return it as-it-is, otherwise return the reversed list. */ |
| 1180 | if (XUINT (Flength (result)) == 1) | 1207 | if (XFASTINT (Flength (result)) == 1) |
| 1181 | RETURN_UNGCPRO (CAR_SAFE (result)); | 1208 | RETURN_UNGCPRO (CAR_SAFE (result)); |
| 1182 | else | 1209 | else |
| 1183 | RETURN_UNGCPRO (Fnreverse (result)); | 1210 | RETURN_UNGCPRO (Fnreverse (result)); |
| @@ -1233,7 +1260,7 @@ Example: | |||
| 1233 | -| i686 | 1260 | -| i686 |
| 1234 | 1261 | ||
| 1235 | usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLER &optional :timeout TIMEOUT &rest ARGS) */) | 1262 | usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLER &optional :timeout TIMEOUT &rest ARGS) */) |
| 1236 | (int nargs, register Lisp_Object *args) | 1263 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1237 | { | 1264 | { |
| 1238 | Lisp_Object bus, service, path, interface, method, handler; | 1265 | Lisp_Object bus, service, path, interface, method, handler; |
| 1239 | Lisp_Object result; | 1266 | Lisp_Object result; |
| @@ -1242,8 +1269,9 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1242 | DBusMessage *dmessage; | 1269 | DBusMessage *dmessage; |
| 1243 | DBusMessageIter iter; | 1270 | DBusMessageIter iter; |
| 1244 | unsigned int dtype; | 1271 | unsigned int dtype; |
| 1272 | dbus_uint32_t serial; | ||
| 1245 | int timeout = -1; | 1273 | int timeout = -1; |
| 1246 | int i = 6; | 1274 | ptrdiff_t i = 6; |
| 1247 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 1275 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 1248 | 1276 | ||
| 1249 | /* Check parameters. */ | 1277 | /* Check parameters. */ |
| @@ -1259,7 +1287,7 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1259 | CHECK_STRING (interface); | 1287 | CHECK_STRING (interface); |
| 1260 | CHECK_STRING (method); | 1288 | CHECK_STRING (method); |
| 1261 | if (!NILP (handler) && !FUNCTIONP (handler)) | 1289 | if (!NILP (handler) && !FUNCTIONP (handler)) |
| 1262 | wrong_type_argument (intern ("functionp"), handler); | 1290 | wrong_type_argument (Qinvalid_function, handler); |
| 1263 | GCPRO6 (bus, service, path, interface, method, handler); | 1291 | GCPRO6 (bus, service, path, interface, method, handler); |
| 1264 | 1292 | ||
| 1265 | XD_DEBUG_MESSAGE ("%s %s %s %s", | 1293 | XD_DEBUG_MESSAGE ("%s %s %s %s", |
| @@ -1272,10 +1300,10 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1272 | connection = xd_initialize (bus, TRUE); | 1300 | connection = xd_initialize (bus, TRUE); |
| 1273 | 1301 | ||
| 1274 | /* Create the message. */ | 1302 | /* Create the message. */ |
| 1275 | dmessage = dbus_message_new_method_call (SDATA (service), | 1303 | dmessage = dbus_message_new_method_call (SSDATA (service), |
| 1276 | SDATA (path), | 1304 | SSDATA (path), |
| 1277 | SDATA (interface), | 1305 | SSDATA (interface), |
| 1278 | SDATA (method)); | 1306 | SSDATA (method)); |
| 1279 | if (dmessage == NULL) | 1307 | if (dmessage == NULL) |
| 1280 | XD_SIGNAL1 (build_string ("Unable to create a new message")); | 1308 | XD_SIGNAL1 (build_string ("Unable to create a new message")); |
| 1281 | 1309 | ||
| @@ -1283,7 +1311,7 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1283 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) | 1311 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) |
| 1284 | { | 1312 | { |
| 1285 | CHECK_NATNUM (args[i+1]); | 1313 | CHECK_NATNUM (args[i+1]); |
| 1286 | timeout = XUINT (args[i+1]); | 1314 | timeout = XFASTINT (args[i+1]); |
| 1287 | i = i+2; | 1315 | i = i+2; |
| 1288 | } | 1316 | } |
| 1289 | 1317 | ||
| @@ -1298,7 +1326,7 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1298 | { | 1326 | { |
| 1299 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1327 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1300 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | 1328 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); |
| 1301 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4, | 1329 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, |
| 1302 | SDATA (format2 ("%s", args[i], Qnil)), | 1330 | SDATA (format2 ("%s", args[i], Qnil)), |
| 1303 | SDATA (format2 ("%s", args[i+1], Qnil))); | 1331 | SDATA (format2 ("%s", args[i+1], Qnil))); |
| 1304 | ++i; | 1332 | ++i; |
| @@ -1306,7 +1334,7 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1306 | else | 1334 | else |
| 1307 | { | 1335 | { |
| 1308 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1336 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1309 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-4, | 1337 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, |
| 1310 | SDATA (format2 ("%s", args[i], Qnil))); | 1338 | SDATA (format2 ("%s", args[i], Qnil))); |
| 1311 | } | 1339 | } |
| 1312 | 1340 | ||
| @@ -1326,7 +1354,8 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE | |||
| 1326 | XD_SIGNAL1 (build_string ("Cannot send message")); | 1354 | XD_SIGNAL1 (build_string ("Cannot send message")); |
| 1327 | 1355 | ||
| 1328 | /* The result is the key in Vdbus_registered_objects_table. */ | 1356 | /* The result is the key in Vdbus_registered_objects_table. */ |
| 1329 | result = (list2 (bus, make_number (dbus_message_get_serial (dmessage)))); | 1357 | serial = dbus_message_get_serial (dmessage); |
| 1358 | result = list2 (bus, make_fixnum_or_float (serial)); | ||
| 1330 | 1359 | ||
| 1331 | /* Create a hash table entry. */ | 1360 | /* Create a hash table entry. */ |
| 1332 | Fputhash (result, handler, Vdbus_registered_objects_table); | 1361 | Fputhash (result, handler, Vdbus_registered_objects_table); |
| @@ -1357,27 +1386,28 @@ DEFUN ("dbus-method-return-internal", Fdbus_method_return_internal, | |||
| 1357 | This is an internal function, it shall not be used outside dbus.el. | 1386 | This is an internal function, it shall not be used outside dbus.el. |
| 1358 | 1387 | ||
| 1359 | usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) | 1388 | usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) |
| 1360 | (int nargs, register Lisp_Object *args) | 1389 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1361 | { | 1390 | { |
| 1362 | Lisp_Object bus, serial, service; | 1391 | Lisp_Object bus, service; |
| 1363 | struct gcpro gcpro1, gcpro2, gcpro3; | 1392 | struct gcpro gcpro1, gcpro2; |
| 1364 | DBusConnection *connection; | 1393 | DBusConnection *connection; |
| 1365 | DBusMessage *dmessage; | 1394 | DBusMessage *dmessage; |
| 1366 | DBusMessageIter iter; | 1395 | DBusMessageIter iter; |
| 1367 | unsigned int dtype; | 1396 | dbus_uint32_t serial; |
| 1368 | int i; | 1397 | unsigned int ui_serial, dtype; |
| 1398 | ptrdiff_t i; | ||
| 1369 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 1399 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 1370 | 1400 | ||
| 1371 | /* Check parameters. */ | 1401 | /* Check parameters. */ |
| 1372 | bus = args[0]; | 1402 | bus = args[0]; |
| 1373 | serial = args[1]; | ||
| 1374 | service = args[2]; | 1403 | service = args[2]; |
| 1375 | 1404 | ||
| 1376 | CHECK_NUMBER (serial); | 1405 | CHECK_DBUS_SERIAL_GET_SERIAL (args[1], serial); |
| 1377 | CHECK_STRING (service); | 1406 | CHECK_STRING (service); |
| 1378 | GCPRO3 (bus, serial, service); | 1407 | GCPRO2 (bus, service); |
| 1379 | 1408 | ||
| 1380 | XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA (service)); | 1409 | ui_serial = serial; |
| 1410 | XD_DEBUG_MESSAGE ("%u %s ", ui_serial, SSDATA (service)); | ||
| 1381 | 1411 | ||
| 1382 | /* Open a connection to the bus. */ | 1412 | /* Open a connection to the bus. */ |
| 1383 | connection = xd_initialize (bus, TRUE); | 1413 | connection = xd_initialize (bus, TRUE); |
| @@ -1385,8 +1415,8 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1385 | /* Create the message. */ | 1415 | /* Create the message. */ |
| 1386 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); | 1416 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); |
| 1387 | if ((dmessage == NULL) | 1417 | if ((dmessage == NULL) |
| 1388 | || (!dbus_message_set_reply_serial (dmessage, XUINT (serial))) | 1418 | || (!dbus_message_set_reply_serial (dmessage, serial)) |
| 1389 | || (!dbus_message_set_destination (dmessage, SDATA (service)))) | 1419 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) |
| 1390 | { | 1420 | { |
| 1391 | UNGCPRO; | 1421 | UNGCPRO; |
| 1392 | XD_SIGNAL1 (build_string ("Unable to create a return message")); | 1422 | XD_SIGNAL1 (build_string ("Unable to create a return message")); |
| @@ -1405,7 +1435,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1405 | { | 1435 | { |
| 1406 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1436 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1407 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | 1437 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); |
| 1408 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-2, | 1438 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 2, |
| 1409 | SDATA (format2 ("%s", args[i], Qnil)), | 1439 | SDATA (format2 ("%s", args[i], Qnil)), |
| 1410 | SDATA (format2 ("%s", args[i+1], Qnil))); | 1440 | SDATA (format2 ("%s", args[i+1], Qnil))); |
| 1411 | ++i; | 1441 | ++i; |
| @@ -1413,7 +1443,7 @@ usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1413 | else | 1443 | else |
| 1414 | { | 1444 | { |
| 1415 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1445 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1416 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-2, | 1446 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 2, |
| 1417 | SDATA (format2 ("%s", args[i], Qnil))); | 1447 | SDATA (format2 ("%s", args[i], Qnil))); |
| 1418 | } | 1448 | } |
| 1419 | 1449 | ||
| @@ -1445,27 +1475,28 @@ DEFUN ("dbus-method-error-internal", Fdbus_method_error_internal, | |||
| 1445 | This is an internal function, it shall not be used outside dbus.el. | 1475 | This is an internal function, it shall not be used outside dbus.el. |
| 1446 | 1476 | ||
| 1447 | usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) | 1477 | usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) |
| 1448 | (int nargs, register Lisp_Object *args) | 1478 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1449 | { | 1479 | { |
| 1450 | Lisp_Object bus, serial, service; | 1480 | Lisp_Object bus, service; |
| 1451 | struct gcpro gcpro1, gcpro2, gcpro3; | 1481 | struct gcpro gcpro1, gcpro2; |
| 1452 | DBusConnection *connection; | 1482 | DBusConnection *connection; |
| 1453 | DBusMessage *dmessage; | 1483 | DBusMessage *dmessage; |
| 1454 | DBusMessageIter iter; | 1484 | DBusMessageIter iter; |
| 1455 | unsigned int dtype; | 1485 | dbus_uint32_t serial; |
| 1456 | int i; | 1486 | unsigned int ui_serial, dtype; |
| 1487 | ptrdiff_t i; | ||
| 1457 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 1488 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 1458 | 1489 | ||
| 1459 | /* Check parameters. */ | 1490 | /* Check parameters. */ |
| 1460 | bus = args[0]; | 1491 | bus = args[0]; |
| 1461 | serial = args[1]; | ||
| 1462 | service = args[2]; | 1492 | service = args[2]; |
| 1463 | 1493 | ||
| 1464 | CHECK_NUMBER (serial); | 1494 | CHECK_DBUS_SERIAL_GET_SERIAL (args[1], serial); |
| 1465 | CHECK_STRING (service); | 1495 | CHECK_STRING (service); |
| 1466 | GCPRO3 (bus, serial, service); | 1496 | GCPRO2 (bus, service); |
| 1467 | 1497 | ||
| 1468 | XD_DEBUG_MESSAGE ("%lu %s ", (unsigned long) XUINT (serial), SDATA (service)); | 1498 | ui_serial = serial; |
| 1499 | XD_DEBUG_MESSAGE ("%u %s ", ui_serial, SSDATA (service)); | ||
| 1469 | 1500 | ||
| 1470 | /* Open a connection to the bus. */ | 1501 | /* Open a connection to the bus. */ |
| 1471 | connection = xd_initialize (bus, TRUE); | 1502 | connection = xd_initialize (bus, TRUE); |
| @@ -1474,8 +1505,8 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1474 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); | 1505 | dmessage = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); |
| 1475 | if ((dmessage == NULL) | 1506 | if ((dmessage == NULL) |
| 1476 | || (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED)) | 1507 | || (!dbus_message_set_error_name (dmessage, DBUS_ERROR_FAILED)) |
| 1477 | || (!dbus_message_set_reply_serial (dmessage, XUINT (serial))) | 1508 | || (!dbus_message_set_reply_serial (dmessage, serial)) |
| 1478 | || (!dbus_message_set_destination (dmessage, SDATA (service)))) | 1509 | || (!dbus_message_set_destination (dmessage, SSDATA (service)))) |
| 1479 | { | 1510 | { |
| 1480 | UNGCPRO; | 1511 | UNGCPRO; |
| 1481 | XD_SIGNAL1 (build_string ("Unable to create a error message")); | 1512 | XD_SIGNAL1 (build_string ("Unable to create a error message")); |
| @@ -1494,7 +1525,7 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1494 | { | 1525 | { |
| 1495 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1526 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1496 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | 1527 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); |
| 1497 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-2, | 1528 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 2, |
| 1498 | SDATA (format2 ("%s", args[i], Qnil)), | 1529 | SDATA (format2 ("%s", args[i], Qnil)), |
| 1499 | SDATA (format2 ("%s", args[i+1], Qnil))); | 1530 | SDATA (format2 ("%s", args[i+1], Qnil))); |
| 1500 | ++i; | 1531 | ++i; |
| @@ -1502,7 +1533,7 @@ usage: (dbus-method-error-internal BUS SERIAL SERVICE &rest ARGS) */) | |||
| 1502 | else | 1533 | else |
| 1503 | { | 1534 | { |
| 1504 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1535 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1505 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-2, | 1536 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 2, |
| 1506 | SDATA (format2 ("%s", args[i], Qnil))); | 1537 | SDATA (format2 ("%s", args[i], Qnil))); |
| 1507 | } | 1538 | } |
| 1508 | 1539 | ||
| @@ -1557,7 +1588,7 @@ Example: | |||
| 1557 | "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs") | 1588 | "org.gnu.Emacs.FileManager" "FileModified" "/home/albinus/.emacs") |
| 1558 | 1589 | ||
| 1559 | usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | 1590 | usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) |
| 1560 | (int nargs, register Lisp_Object *args) | 1591 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1561 | { | 1592 | { |
| 1562 | Lisp_Object bus, service, path, interface, signal; | 1593 | Lisp_Object bus, service, path, interface, signal; |
| 1563 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 1594 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| @@ -1565,7 +1596,7 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | |||
| 1565 | DBusMessage *dmessage; | 1596 | DBusMessage *dmessage; |
| 1566 | DBusMessageIter iter; | 1597 | DBusMessageIter iter; |
| 1567 | unsigned int dtype; | 1598 | unsigned int dtype; |
| 1568 | int i; | 1599 | ptrdiff_t i; |
| 1569 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 1600 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 1570 | 1601 | ||
| 1571 | /* Check parameters. */ | 1602 | /* Check parameters. */ |
| @@ -1591,9 +1622,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | |||
| 1591 | connection = xd_initialize (bus, TRUE); | 1622 | connection = xd_initialize (bus, TRUE); |
| 1592 | 1623 | ||
| 1593 | /* Create the message. */ | 1624 | /* Create the message. */ |
| 1594 | dmessage = dbus_message_new_signal (SDATA (path), | 1625 | dmessage = dbus_message_new_signal (SSDATA (path), |
| 1595 | SDATA (interface), | 1626 | SSDATA (interface), |
| 1596 | SDATA (signal)); | 1627 | SSDATA (signal)); |
| 1597 | UNGCPRO; | 1628 | UNGCPRO; |
| 1598 | if (dmessage == NULL) | 1629 | if (dmessage == NULL) |
| 1599 | XD_SIGNAL1 (build_string ("Unable to create a new message")); | 1630 | XD_SIGNAL1 (build_string ("Unable to create a new message")); |
| @@ -1609,7 +1640,7 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | |||
| 1609 | { | 1640 | { |
| 1610 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1641 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1611 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | 1642 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); |
| 1612 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4, | 1643 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s %s", i - 4, |
| 1613 | SDATA (format2 ("%s", args[i], Qnil)), | 1644 | SDATA (format2 ("%s", args[i], Qnil)), |
| 1614 | SDATA (format2 ("%s", args[i+1], Qnil))); | 1645 | SDATA (format2 ("%s", args[i+1], Qnil))); |
| 1615 | ++i; | 1646 | ++i; |
| @@ -1617,7 +1648,7 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | |||
| 1617 | else | 1648 | else |
| 1618 | { | 1649 | { |
| 1619 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | 1650 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); |
| 1620 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-4, | 1651 | XD_DEBUG_MESSAGE ("Parameter%"pD"d %s", i - 4, |
| 1621 | SDATA (format2 ("%s", args[i], Qnil))); | 1652 | SDATA (format2 ("%s", args[i], Qnil))); |
| 1622 | } | 1653 | } |
| 1623 | 1654 | ||
| @@ -1654,7 +1685,9 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1654 | DBusMessage *dmessage; | 1685 | DBusMessage *dmessage; |
| 1655 | DBusMessageIter iter; | 1686 | DBusMessageIter iter; |
| 1656 | unsigned int dtype; | 1687 | unsigned int dtype; |
| 1657 | int mtype, serial; | 1688 | int mtype; |
| 1689 | dbus_uint32_t serial; | ||
| 1690 | unsigned int ui_serial; | ||
| 1658 | const char *uname, *path, *interface, *member; | 1691 | const char *uname, *path, *interface, *member; |
| 1659 | 1692 | ||
| 1660 | dmessage = dbus_connection_pop_message (connection); | 1693 | dmessage = dbus_connection_pop_message (connection); |
| @@ -1683,7 +1716,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1683 | /* Read message type, message serial, unique name, object path, | 1716 | /* Read message type, message serial, unique name, object path, |
| 1684 | interface and member from the message. */ | 1717 | interface and member from the message. */ |
| 1685 | mtype = dbus_message_get_type (dmessage); | 1718 | mtype = dbus_message_get_type (dmessage); |
| 1686 | serial = | 1719 | ui_serial = serial = |
| 1687 | ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) | 1720 | ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) |
| 1688 | || (mtype == DBUS_MESSAGE_TYPE_ERROR)) | 1721 | || (mtype == DBUS_MESSAGE_TYPE_ERROR)) |
| 1689 | ? dbus_message_get_reply_serial (dmessage) | 1722 | ? dbus_message_get_reply_serial (dmessage) |
| @@ -1693,7 +1726,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1693 | interface = dbus_message_get_interface (dmessage); | 1726 | interface = dbus_message_get_interface (dmessage); |
| 1694 | member = dbus_message_get_member (dmessage); | 1727 | member = dbus_message_get_member (dmessage); |
| 1695 | 1728 | ||
| 1696 | XD_DEBUG_MESSAGE ("Event received: %s %d %s %s %s %s %s", | 1729 | XD_DEBUG_MESSAGE ("Event received: %s %u %s %s %s %s %s", |
| 1697 | (mtype == DBUS_MESSAGE_TYPE_INVALID) | 1730 | (mtype == DBUS_MESSAGE_TYPE_INVALID) |
| 1698 | ? "DBUS_MESSAGE_TYPE_INVALID" | 1731 | ? "DBUS_MESSAGE_TYPE_INVALID" |
| 1699 | : (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) | 1732 | : (mtype == DBUS_MESSAGE_TYPE_METHOD_CALL) |
| @@ -1703,14 +1736,14 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1703 | : (mtype == DBUS_MESSAGE_TYPE_ERROR) | 1736 | : (mtype == DBUS_MESSAGE_TYPE_ERROR) |
| 1704 | ? "DBUS_MESSAGE_TYPE_ERROR" | 1737 | ? "DBUS_MESSAGE_TYPE_ERROR" |
| 1705 | : "DBUS_MESSAGE_TYPE_SIGNAL", | 1738 | : "DBUS_MESSAGE_TYPE_SIGNAL", |
| 1706 | serial, uname, path, interface, member, | 1739 | ui_serial, uname, path, interface, member, |
| 1707 | SDATA (format2 ("%s", args, Qnil))); | 1740 | SDATA (format2 ("%s", args, Qnil))); |
| 1708 | 1741 | ||
| 1709 | if ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) | 1742 | if ((mtype == DBUS_MESSAGE_TYPE_METHOD_RETURN) |
| 1710 | || (mtype == DBUS_MESSAGE_TYPE_ERROR)) | 1743 | || (mtype == DBUS_MESSAGE_TYPE_ERROR)) |
| 1711 | { | 1744 | { |
| 1712 | /* Search for a registered function of the message. */ | 1745 | /* Search for a registered function of the message. */ |
| 1713 | key = list2 (bus, make_number (serial)); | 1746 | key = list2 (bus, make_fixnum_or_float (serial)); |
| 1714 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); | 1747 | value = Fgethash (key, Vdbus_registered_objects_table, Qnil); |
| 1715 | 1748 | ||
| 1716 | /* There shall be exactly one entry. Construct an event. */ | 1749 | /* There shall be exactly one entry. Construct an event. */ |
| @@ -1745,19 +1778,19 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1745 | /* key has the structure (UNAME SERVICE PATH HANDLER). */ | 1778 | /* key has the structure (UNAME SERVICE PATH HANDLER). */ |
| 1746 | if (((uname == NULL) | 1779 | if (((uname == NULL) |
| 1747 | || (NILP (CAR_SAFE (key))) | 1780 | || (NILP (CAR_SAFE (key))) |
| 1748 | || (strcmp (uname, SDATA (CAR_SAFE (key))) == 0)) | 1781 | || (strcmp (uname, SSDATA (CAR_SAFE (key))) == 0)) |
| 1749 | && ((path == NULL) | 1782 | && ((path == NULL) |
| 1750 | || (NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) | 1783 | || (NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) |
| 1751 | || (strcmp (path, | 1784 | || (strcmp (path, |
| 1752 | SDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) | 1785 | SSDATA (CAR_SAFE (CDR_SAFE (CDR_SAFE (key))))) |
| 1753 | == 0)) | 1786 | == 0)) |
| 1754 | && (!NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key))))))) | 1787 | && (!NILP (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key))))))) |
| 1755 | { | 1788 | { |
| 1756 | EVENT_INIT (event); | 1789 | EVENT_INIT (event); |
| 1757 | event.kind = DBUS_EVENT; | 1790 | event.kind = DBUS_EVENT; |
| 1758 | event.frame_or_window = Qnil; | 1791 | event.frame_or_window = Qnil; |
| 1759 | event.arg = Fcons (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))), | 1792 | event.arg |
| 1760 | args); | 1793 | = Fcons (CAR_SAFE (CDR_SAFE (CDR_SAFE (CDR_SAFE (key)))), args); |
| 1761 | break; | 1794 | break; |
| 1762 | } | 1795 | } |
| 1763 | value = CDR_SAFE (value); | 1796 | value = CDR_SAFE (value); |
| @@ -1776,7 +1809,7 @@ xd_read_message_1 (DBusConnection *connection, Lisp_Object bus) | |||
| 1776 | event.arg); | 1809 | event.arg); |
| 1777 | event.arg = Fcons ((uname == NULL ? Qnil : build_string (uname)), | 1810 | event.arg = Fcons ((uname == NULL ? Qnil : build_string (uname)), |
| 1778 | event.arg); | 1811 | event.arg); |
| 1779 | event.arg = Fcons (make_number (serial), event.arg); | 1812 | event.arg = Fcons (make_fixnum_or_float (serial), event.arg); |
| 1780 | event.arg = Fcons (make_number (mtype), event.arg); | 1813 | event.arg = Fcons (make_number (mtype), event.arg); |
| 1781 | 1814 | ||
| 1782 | /* Add the bus symbol to the event. */ | 1815 | /* Add the bus symbol to the event. */ |
| @@ -1824,7 +1857,8 @@ xd_read_queued_messages (int fd, void *data, int for_read) | |||
| 1824 | if (data != NULL) | 1857 | if (data != NULL) |
| 1825 | while (!NILP (busp)) | 1858 | while (!NILP (busp)) |
| 1826 | { | 1859 | { |
| 1827 | if (data == (void*) XHASH (CAR_SAFE (busp))) | 1860 | if ((SYMBOLP (CAR_SAFE (busp)) && XSYMBOL (CAR_SAFE (busp)) == data) |
| 1861 | || (STRINGP (CAR_SAFE (busp)) && XSTRING (CAR_SAFE (busp)) == data)) | ||
| 1828 | bus = CAR_SAFE (busp); | 1862 | bus = CAR_SAFE (busp); |
| 1829 | busp = CDR_SAFE (busp); | 1863 | busp = CDR_SAFE (busp); |
| 1830 | } | 1864 | } |
| @@ -1885,12 +1919,11 @@ Example: | |||
| 1885 | => :already-owner. | 1919 | => :already-owner. |
| 1886 | 1920 | ||
| 1887 | usage: (dbus-register-service BUS SERVICE &rest FLAGS) */) | 1921 | usage: (dbus-register-service BUS SERVICE &rest FLAGS) */) |
| 1888 | (int nargs, register Lisp_Object *args) | 1922 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1889 | { | 1923 | { |
| 1890 | Lisp_Object bus, service; | 1924 | Lisp_Object bus, service; |
| 1891 | struct gcpro gcpro1, gcpro2; | ||
| 1892 | DBusConnection *connection; | 1925 | DBusConnection *connection; |
| 1893 | unsigned int i; | 1926 | ptrdiff_t i; |
| 1894 | unsigned int value; | 1927 | unsigned int value; |
| 1895 | unsigned int flags = 0; | 1928 | unsigned int flags = 0; |
| 1896 | int result; | 1929 | int result; |
| @@ -1921,7 +1954,7 @@ usage: (dbus-register-service BUS SERVICE &rest FLAGS) */) | |||
| 1921 | 1954 | ||
| 1922 | /* Request the known name from the bus. */ | 1955 | /* Request the known name from the bus. */ |
| 1923 | dbus_error_init (&derror); | 1956 | dbus_error_init (&derror); |
| 1924 | result = dbus_bus_request_name (connection, SDATA (service), flags, | 1957 | result = dbus_bus_request_name (connection, SSDATA (service), flags, |
| 1925 | &derror); | 1958 | &derror); |
| 1926 | if (dbus_error_is_set (&derror)) | 1959 | if (dbus_error_is_set (&derror)) |
| 1927 | XD_ERROR (derror); | 1960 | XD_ERROR (derror); |
| @@ -1986,13 +2019,13 @@ INTERFACE, SIGNAL and HANDLER must not be nil. Example: | |||
| 1986 | `dbus-unregister-object' for removing the registration. | 2019 | `dbus-unregister-object' for removing the registration. |
| 1987 | 2020 | ||
| 1988 | usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARGS) */) | 2021 | usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARGS) */) |
| 1989 | (int nargs, register Lisp_Object *args) | 2022 | (ptrdiff_t nargs, Lisp_Object *args) |
| 1990 | { | 2023 | { |
| 1991 | Lisp_Object bus, service, path, interface, signal, handler; | 2024 | Lisp_Object bus, service, path, interface, signal, handler; |
| 1992 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; | 2025 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; |
| 1993 | Lisp_Object uname, key, key1, value; | 2026 | Lisp_Object uname, key, key1, value; |
| 1994 | DBusConnection *connection; | 2027 | DBusConnection *connection; |
| 1995 | int i; | 2028 | ptrdiff_t i; |
| 1996 | char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; | 2029 | char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; |
| 1997 | char x[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; | 2030 | char x[DBUS_MAXIMUM_MATCH_RULE_LENGTH]; |
| 1998 | DBusError derror; | 2031 | DBusError derror; |
| @@ -2010,7 +2043,7 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG | |||
| 2010 | CHECK_STRING (interface); | 2043 | CHECK_STRING (interface); |
| 2011 | CHECK_STRING (signal); | 2044 | CHECK_STRING (signal); |
| 2012 | if (!FUNCTIONP (handler)) | 2045 | if (!FUNCTIONP (handler)) |
| 2013 | wrong_type_argument (intern ("functionp"), handler); | 2046 | wrong_type_argument (Qinvalid_function, handler); |
| 2014 | GCPRO6 (bus, service, path, interface, signal, handler); | 2047 | GCPRO6 (bus, service, path, interface, signal, handler); |
| 2015 | 2048 | ||
| 2016 | /* Retrieve unique name of service. If service is a known name, we | 2049 | /* Retrieve unique name of service. If service is a known name, we |
| @@ -2019,8 +2052,8 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG | |||
| 2019 | name of "org.freedesktop.DBus" is that string itself. */ | 2052 | name of "org.freedesktop.DBus" is that string itself. */ |
| 2020 | if ((STRINGP (service)) | 2053 | if ((STRINGP (service)) |
| 2021 | && (SBYTES (service) > 0) | 2054 | && (SBYTES (service) > 0) |
| 2022 | && (strcmp (SDATA (service), DBUS_SERVICE_DBUS) != 0) | 2055 | && (strcmp (SSDATA (service), DBUS_SERVICE_DBUS) != 0) |
| 2023 | && (strncmp (SDATA (service), ":", 1) != 0)) | 2056 | && (strncmp (SSDATA (service), ":", 1) != 0)) |
| 2024 | { | 2057 | { |
| 2025 | uname = call2 (intern ("dbus-get-name-owner"), bus, service); | 2058 | uname = call2 (intern ("dbus-get-name-owner"), bus, service); |
| 2026 | /* When there is no unique name, we mark it with an empty | 2059 | /* When there is no unique name, we mark it with an empty |
| @@ -2062,7 +2095,8 @@ usage: (dbus-register-signal BUS SERVICE PATH INTERFACE SIGNAL HANDLER &rest ARG | |||
| 2062 | if (!NILP (args[i])) | 2095 | if (!NILP (args[i])) |
| 2063 | { | 2096 | { |
| 2064 | CHECK_STRING (args[i]); | 2097 | CHECK_STRING (args[i]); |
| 2065 | sprintf (x, ",arg%d='%s'", i-6, SDATA (args[i])); | 2098 | sprintf (x, ",arg%"pD"d='%s'", i - 6, |
| 2099 | SDATA (args[i])); | ||
| 2066 | strcat (rule, x); | 2100 | strcat (rule, x); |
| 2067 | } | 2101 | } |
| 2068 | 2102 | ||
| @@ -2122,7 +2156,6 @@ discovering the still incomplete interface.*/) | |||
| 2122 | Lisp_Object dont_register_service) | 2156 | Lisp_Object dont_register_service) |
| 2123 | { | 2157 | { |
| 2124 | Lisp_Object key, key1, value; | 2158 | Lisp_Object key, key1, value; |
| 2125 | DBusError derror; | ||
| 2126 | Lisp_Object args[2] = { bus, service }; | 2159 | Lisp_Object args[2] = { bus, service }; |
| 2127 | 2160 | ||
| 2128 | /* Check parameters. */ | 2161 | /* Check parameters. */ |
| @@ -2131,7 +2164,7 @@ discovering the still incomplete interface.*/) | |||
| 2131 | CHECK_STRING (interface); | 2164 | CHECK_STRING (interface); |
| 2132 | CHECK_STRING (method); | 2165 | CHECK_STRING (method); |
| 2133 | if (!FUNCTIONP (handler)) | 2166 | if (!FUNCTIONP (handler)) |
| 2134 | wrong_type_argument (intern ("functionp"), handler); | 2167 | wrong_type_argument (Qinvalid_function, handler); |
| 2135 | /* TODO: We must check for a valid service name, otherwise there is | 2168 | /* TODO: We must check for a valid service name, otherwise there is |
| 2136 | a segmentation fault. */ | 2169 | a segmentation fault. */ |
| 2137 | 2170 | ||
| @@ -2173,11 +2206,13 @@ syms_of_dbusbind (void) | |||
| 2173 | staticpro (&Qdbus_call_method); | 2206 | staticpro (&Qdbus_call_method); |
| 2174 | defsubr (&Sdbus_call_method); | 2207 | defsubr (&Sdbus_call_method); |
| 2175 | 2208 | ||
| 2176 | Qdbus_call_method_asynchronously = intern_c_string ("dbus-call-method-asynchronously"); | 2209 | Qdbus_call_method_asynchronously |
| 2210 | = intern_c_string ("dbus-call-method-asynchronously"); | ||
| 2177 | staticpro (&Qdbus_call_method_asynchronously); | 2211 | staticpro (&Qdbus_call_method_asynchronously); |
| 2178 | defsubr (&Sdbus_call_method_asynchronously); | 2212 | defsubr (&Sdbus_call_method_asynchronously); |
| 2179 | 2213 | ||
| 2180 | Qdbus_method_return_internal = intern_c_string ("dbus-method-return-internal"); | 2214 | Qdbus_method_return_internal |
| 2215 | = intern_c_string ("dbus-method-return-internal"); | ||
| 2181 | staticpro (&Qdbus_method_return_internal); | 2216 | staticpro (&Qdbus_method_return_internal); |
| 2182 | defsubr (&Sdbus_method_return_internal); | 2217 | defsubr (&Sdbus_method_return_internal); |
| 2183 | 2218 | ||
| @@ -2214,7 +2249,8 @@ syms_of_dbusbind (void) | |||
| 2214 | QCdbus_session_bus = intern_c_string (":session"); | 2249 | QCdbus_session_bus = intern_c_string (":session"); |
| 2215 | staticpro (&QCdbus_session_bus); | 2250 | staticpro (&QCdbus_session_bus); |
| 2216 | 2251 | ||
| 2217 | QCdbus_request_name_allow_replacement = intern_c_string (":allow-replacement"); | 2252 | QCdbus_request_name_allow_replacement |
| 2253 | = intern_c_string (":allow-replacement"); | ||
| 2218 | staticpro (&QCdbus_request_name_allow_replacement); | 2254 | staticpro (&QCdbus_request_name_allow_replacement); |
| 2219 | 2255 | ||
| 2220 | QCdbus_request_name_replace_existing = intern_c_string (":replace-existing"); | 2256 | QCdbus_request_name_replace_existing = intern_c_string (":replace-existing"); |
| @@ -2350,4 +2386,3 @@ be called when the D-Bus reply message arrives. */); | |||
| 2350 | } | 2386 | } |
| 2351 | 2387 | ||
| 2352 | #endif /* HAVE_DBUS */ | 2388 | #endif /* HAVE_DBUS */ |
| 2353 | |||