diff options
| author | Michael Albinus | 2008-01-21 20:19:16 +0000 |
|---|---|---|
| committer | Michael Albinus | 2008-01-21 20:19:16 +0000 |
| commit | 8c7a4ac525e888da28f53a984c555e077e51935e (patch) | |
| tree | 1ed3ff01a28ac3896dc9c75174abc87a4e5b9350 /src | |
| parent | 22b04708edb530bf64b7f0d88488cc0d067e2c98 (diff) | |
| download | emacs-8c7a4ac525e888da28f53a984c555e077e51935e.tar.gz emacs-8c7a4ac525e888da28f53a984c555e077e51935e.zip | |
* dbusbind.el (Fdbus_method_return_internal): Renamed from
Fdbus_method_return.
(Fdbus_unregister_object): Moved to dbus.el.
(Fdbus_call_method, Fdbus_method_return_internal)
(Fdbus_send_signal): Debug messages improved.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/dbusbind.c | 134 |
2 files changed, 61 insertions, 81 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 73a1164915e..0a798a670a0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2008-01-21 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * dbusbind.el (Fdbus_method_return_internal): Renamed from | ||
| 4 | Fdbus_method_return. | ||
| 5 | (Fdbus_unregister_object): Moved to dbus.el. | ||
| 6 | (Fdbus_call_method, Fdbus_method_return_internal) | ||
| 7 | (Fdbus_send_signal): Debug messages improved. | ||
| 8 | |||
| 1 | 2008-01-20 Martin Rudalics <rudalics@gmx.at> | 9 | 2008-01-20 Martin Rudalics <rudalics@gmx.at> |
| 2 | 10 | ||
| 3 | * undo.c (undo_inhibit_record_point): New variable. | 11 | * undo.c (undo_inhibit_record_point): New variable. |
diff --git a/src/dbusbind.c b/src/dbusbind.c index 136cea9adb4..badcf1f14d7 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -33,11 +33,10 @@ Boston, MA 02110-1301, USA. */ | |||
| 33 | /* Subroutines. */ | 33 | /* Subroutines. */ |
| 34 | Lisp_Object Qdbus_get_unique_name; | 34 | Lisp_Object Qdbus_get_unique_name; |
| 35 | Lisp_Object Qdbus_call_method; | 35 | Lisp_Object Qdbus_call_method; |
| 36 | Lisp_Object Qdbus_method_return; | 36 | Lisp_Object Qdbus_method_return_internal; |
| 37 | Lisp_Object Qdbus_send_signal; | 37 | Lisp_Object Qdbus_send_signal; |
| 38 | Lisp_Object Qdbus_register_signal; | 38 | Lisp_Object Qdbus_register_signal; |
| 39 | Lisp_Object Qdbus_register_method; | 39 | Lisp_Object Qdbus_register_method; |
| 40 | Lisp_Object Qdbus_unregister_object; | ||
| 41 | 40 | ||
| 42 | /* D-Bus error symbol. */ | 41 | /* D-Bus error symbol. */ |
| 43 | Lisp_Object Qdbus_error; | 42 | Lisp_Object Qdbus_error; |
| @@ -833,14 +832,22 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | |||
| 833 | /* Append parameters to the message. */ | 832 | /* Append parameters to the message. */ |
| 834 | for (i = 5; i < nargs; ++i) | 833 | for (i = 5; i < nargs; ++i) |
| 835 | { | 834 | { |
| 836 | |||
| 837 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 838 | XD_DEBUG_MESSAGE ("Parameter%d %s", | ||
| 839 | i-4, SDATA (format2 ("%s", args[i], Qnil))); | ||
| 840 | |||
| 841 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | 835 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); |
| 842 | if (XD_DBUS_TYPE_P (args[i])) | 836 | if (XD_DBUS_TYPE_P (args[i])) |
| 843 | ++i; | 837 | { |
| 838 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 839 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | ||
| 840 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4, | ||
| 841 | SDATA (format2 ("%s", args[i], Qnil)), | ||
| 842 | SDATA (format2 ("%s", args[i+1], Qnil))); | ||
| 843 | ++i; | ||
| 844 | } | ||
| 845 | else | ||
| 846 | { | ||
| 847 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 848 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-4, | ||
| 849 | SDATA (format2 ("%s", args[i], Qnil))); | ||
| 850 | } | ||
| 844 | 851 | ||
| 845 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | 852 | /* Check for valid signature. We use DBUS_TYPE_INVALID as |
| 846 | indication that there is no parent type. */ | 853 | indication that there is no parent type. */ |
| @@ -872,7 +879,8 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | |||
| 872 | { | 879 | { |
| 873 | /* Loop over the parameters of the D-Bus reply message. Construct a | 880 | /* Loop over the parameters of the D-Bus reply message. Construct a |
| 874 | Lisp list, which is returned by `dbus-call-method'. */ | 881 | Lisp list, which is returned by `dbus-call-method'. */ |
| 875 | while ((dtype = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) | 882 | while ((dtype = dbus_message_iter_get_arg_type (&iter)) |
| 883 | != DBUS_TYPE_INVALID) | ||
| 876 | { | 884 | { |
| 877 | result = Fcons (xd_retrieve_arg (dtype, &iter), result); | 885 | result = Fcons (xd_retrieve_arg (dtype, &iter), result); |
| 878 | dbus_message_iter_next (&iter); | 886 | dbus_message_iter_next (&iter); |
| @@ -880,7 +888,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | |||
| 880 | } | 888 | } |
| 881 | else | 889 | else |
| 882 | { | 890 | { |
| 883 | /* No arguments: just return nil. */ | 891 | /* No arguments: just return nil. */ |
| 884 | } | 892 | } |
| 885 | 893 | ||
| 886 | /* Cleanup. */ | 894 | /* Cleanup. */ |
| @@ -895,12 +903,13 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | |||
| 895 | RETURN_UNGCPRO (Fnreverse (result)); | 903 | RETURN_UNGCPRO (Fnreverse (result)); |
| 896 | } | 904 | } |
| 897 | 905 | ||
| 898 | DEFUN ("dbus-method-return", Fdbus_method_return, Sdbus_method_return, | 906 | DEFUN ("dbus-method-return-internal", Fdbus_method_return_internal, |
| 907 | Sdbus_method_return_internal, | ||
| 899 | 3, MANY, 0, | 908 | 3, MANY, 0, |
| 900 | doc: /* Return to method SERIAL on the D-Bus BUS. | 909 | doc: /* Return for message SERIAL on the D-Bus BUS. |
| 901 | This is an internal function, it shall not be used outside dbus.el. | 910 | This is an internal function, it shall not be used outside dbus.el. |
| 902 | 911 | ||
| 903 | usage: (dbus-method-return BUS SERIAL SERVICE &rest ARGS) */) | 912 | usage: (dbus-method-return-internal BUS SERIAL SERVICE &rest ARGS) */) |
| 904 | (nargs, args) | 913 | (nargs, args) |
| 905 | int nargs; | 914 | int nargs; |
| 906 | register Lisp_Object *args; | 915 | register Lisp_Object *args; |
| @@ -948,14 +957,22 @@ usage: (dbus-method-return BUS SERIAL SERVICE &rest ARGS) */) | |||
| 948 | /* Append parameters to the message. */ | 957 | /* Append parameters to the message. */ |
| 949 | for (i = 3; i < nargs; ++i) | 958 | for (i = 3; i < nargs; ++i) |
| 950 | { | 959 | { |
| 951 | |||
| 952 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 953 | XD_DEBUG_MESSAGE ("Parameter%d %s", | ||
| 954 | i-2, SDATA (format2 ("%s", args[i], Qnil))); | ||
| 955 | |||
| 956 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | 960 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); |
| 957 | if (XD_DBUS_TYPE_P (args[i])) | 961 | if (XD_DBUS_TYPE_P (args[i])) |
| 958 | ++i; | 962 | { |
| 963 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 964 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | ||
| 965 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-2, | ||
| 966 | SDATA (format2 ("%s", args[i], Qnil)), | ||
| 967 | SDATA (format2 ("%s", args[i+1], Qnil))); | ||
| 968 | ++i; | ||
| 969 | } | ||
| 970 | else | ||
| 971 | { | ||
| 972 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 973 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-2, | ||
| 974 | SDATA (format2 ("%s", args[i], Qnil))); | ||
| 975 | } | ||
| 959 | 976 | ||
| 960 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | 977 | /* Check for valid signature. We use DBUS_TYPE_INVALID as |
| 961 | indication that there is no parent type. */ | 978 | indication that there is no parent type. */ |
| @@ -1064,13 +1081,22 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | |||
| 1064 | /* Append parameters to the message. */ | 1081 | /* Append parameters to the message. */ |
| 1065 | for (i = 5; i < nargs; ++i) | 1082 | for (i = 5; i < nargs; ++i) |
| 1066 | { | 1083 | { |
| 1067 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1068 | XD_DEBUG_MESSAGE ("Parameter%d %s", | ||
| 1069 | i-4, SDATA (format2 ("%s", args[i], Qnil))); | ||
| 1070 | |||
| 1071 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | 1084 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); |
| 1072 | if (XD_DBUS_TYPE_P (args[i])) | 1085 | if (XD_DBUS_TYPE_P (args[i])) |
| 1073 | ++i; | 1086 | { |
| 1087 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1088 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i+1]); | ||
| 1089 | XD_DEBUG_MESSAGE ("Parameter%d %s %s", i-4, | ||
| 1090 | SDATA (format2 ("%s", args[i], Qnil)), | ||
| 1091 | SDATA (format2 ("%s", args[i+1], Qnil))); | ||
| 1092 | ++i; | ||
| 1093 | } | ||
| 1094 | else | ||
| 1095 | { | ||
| 1096 | XD_DEBUG_VALID_LISP_OBJECT_P (args[i]); | ||
| 1097 | XD_DEBUG_MESSAGE ("Parameter%d %s", i-4, | ||
| 1098 | SDATA (format2 ("%s", args[i], Qnil))); | ||
| 1099 | } | ||
| 1074 | 1100 | ||
| 1075 | /* Check for valid signature. We use DBUS_TYPE_INVALID as | 1101 | /* Check for valid signature. We use DBUS_TYPE_INVALID as |
| 1076 | indication that there is no parent type. */ | 1102 | indication that there is no parent type. */ |
| @@ -1392,56 +1418,6 @@ used for composing the returning D-Bus message. */) | |||
| 1392 | return list2 (key, list3 (service, path, handler)); | 1418 | return list2 (key, list3 (service, path, handler)); |
| 1393 | } | 1419 | } |
| 1394 | 1420 | ||
| 1395 | DEFUN ("dbus-unregister-object", Fdbus_unregister_object, | ||
| 1396 | Sdbus_unregister_object, | ||
| 1397 | 1, 1, 0, | ||
| 1398 | doc: /* Unregister OBJECT from the D-Bus. | ||
| 1399 | OBJECT must be the result of a preceding `dbus-register-signal' or | ||
| 1400 | `dbus-register-method' call. It returns t if OBJECT has been | ||
| 1401 | unregistered, nil otherwise. */) | ||
| 1402 | (object) | ||
| 1403 | Lisp_Object object; | ||
| 1404 | { | ||
| 1405 | Lisp_Object value; | ||
| 1406 | struct gcpro gcpro1; | ||
| 1407 | |||
| 1408 | /* Check parameter. */ | ||
| 1409 | if (!(CONSP (object) && (!NILP (CAR_SAFE (object))) | ||
| 1410 | && CONSP (CDR_SAFE (object)))) | ||
| 1411 | wrong_type_argument (intern ("D-Bus"), object); | ||
| 1412 | |||
| 1413 | /* Find the corresponding entry in the hash table. */ | ||
| 1414 | value = Fgethash (CAR_SAFE (object), Vdbus_registered_functions_table, Qnil); | ||
| 1415 | |||
| 1416 | /* Loop over the registered functions. */ | ||
| 1417 | while (!NILP (value)) | ||
| 1418 | { | ||
| 1419 | GCPRO1 (value); | ||
| 1420 | |||
| 1421 | /* (car value) has the structure (UNAME SERVICE PATH HANDLER). | ||
| 1422 | (cdr object) has the structure ((SERVICE PATH HANDLER) ...). */ | ||
| 1423 | if (!NILP (Fequal (CDR_SAFE (CAR_SAFE (value)), | ||
| 1424 | CAR_SAFE (CDR_SAFE (object))))) | ||
| 1425 | { | ||
| 1426 | /* Compute new hash value. */ | ||
| 1427 | value = Fdelete (CAR_SAFE (value), | ||
| 1428 | Fgethash (CAR_SAFE (object), | ||
| 1429 | Vdbus_registered_functions_table, Qnil)); | ||
| 1430 | if (NILP (value)) | ||
| 1431 | Fremhash (CAR_SAFE (object), Vdbus_registered_functions_table); | ||
| 1432 | else | ||
| 1433 | Fputhash (CAR_SAFE (object), value, | ||
| 1434 | Vdbus_registered_functions_table); | ||
| 1435 | RETURN_UNGCPRO (Qt); | ||
| 1436 | } | ||
| 1437 | UNGCPRO; | ||
| 1438 | value = CDR_SAFE (value); | ||
| 1439 | } | ||
| 1440 | |||
| 1441 | /* Return. */ | ||
| 1442 | return Qnil; | ||
| 1443 | } | ||
| 1444 | |||
| 1445 | 1421 | ||
| 1446 | void | 1422 | void |
| 1447 | syms_of_dbusbind () | 1423 | syms_of_dbusbind () |
| @@ -1455,9 +1431,9 @@ syms_of_dbusbind () | |||
| 1455 | staticpro (&Qdbus_call_method); | 1431 | staticpro (&Qdbus_call_method); |
| 1456 | defsubr (&Sdbus_call_method); | 1432 | defsubr (&Sdbus_call_method); |
| 1457 | 1433 | ||
| 1458 | Qdbus_method_return = intern ("dbus-method-return"); | 1434 | Qdbus_method_return_internal = intern ("dbus-method-return-internal"); |
| 1459 | staticpro (&Qdbus_method_return); | 1435 | staticpro (&Qdbus_method_return_internal); |
| 1460 | defsubr (&Sdbus_method_return); | 1436 | defsubr (&Sdbus_method_return_internal); |
| 1461 | 1437 | ||
| 1462 | Qdbus_send_signal = intern ("dbus-send-signal"); | 1438 | Qdbus_send_signal = intern ("dbus-send-signal"); |
| 1463 | staticpro (&Qdbus_send_signal); | 1439 | staticpro (&Qdbus_send_signal); |
| @@ -1471,10 +1447,6 @@ syms_of_dbusbind () | |||
| 1471 | staticpro (&Qdbus_register_method); | 1447 | staticpro (&Qdbus_register_method); |
| 1472 | defsubr (&Sdbus_register_method); | 1448 | defsubr (&Sdbus_register_method); |
| 1473 | 1449 | ||
| 1474 | Qdbus_unregister_object = intern ("dbus-unregister-object"); | ||
| 1475 | staticpro (&Qdbus_unregister_object); | ||
| 1476 | defsubr (&Sdbus_unregister_object); | ||
| 1477 | |||
| 1478 | Qdbus_error = intern ("dbus-error"); | 1450 | Qdbus_error = intern ("dbus-error"); |
| 1479 | staticpro (&Qdbus_error); | 1451 | staticpro (&Qdbus_error); |
| 1480 | Fput (Qdbus_error, Qerror_conditions, | 1452 | Fput (Qdbus_error, Qerror_conditions, |