diff options
| author | Michael Albinus | 2008-03-30 12:38:49 +0000 |
|---|---|---|
| committer | Michael Albinus | 2008-03-30 12:38:49 +0000 |
| commit | 90b3fc84155c58879c5193d10f92575692544572 (patch) | |
| tree | bab394edb60c7c781a5c2459a13cc56d9e1a3c60 /src | |
| parent | 990e2c2fbce776825ce853151707136cebaff03d (diff) | |
| download | emacs-90b3fc84155c58879c5193d10f92575692544572.tar.gz emacs-90b3fc84155c58879c5193d10f92575692544572.zip | |
* dbusbind.c (QCdbus_timeout): New D-Bus internal symbol.
(Fdbus_call_method): New parameter TIMEOUT.
(dbus-send-signal): Optimize UNGCPRO call.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/dbusbind.c | 44 |
2 files changed, 35 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9061ffc2359..8a9337a66d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-03-30 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * dbusbind.c (QCdbus_timeout): New D-Bus internal symbol. | ||
| 4 | (Fdbus_call_method): New parameter TIMEOUT. | ||
| 5 | (dbus-send-signal): Optimize UNGCPRO call. | ||
| 6 | |||
| 1 | 2008-03-29 Juri Linkov <juri@jurta.org> | 7 | 2008-03-29 Juri Linkov <juri@jurta.org> |
| 2 | 8 | ||
| 3 | * window.c (Fdisplay_buffer): Move call to | 9 | * window.c (Fdisplay_buffer): Move call to |
diff --git a/src/dbusbind.c b/src/dbusbind.c index 029c53640de..07711053560 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -44,6 +44,9 @@ Lisp_Object Qdbus_error; | |||
| 44 | /* Lisp symbols of the system and session buses. */ | 44 | /* Lisp symbols of the system and session buses. */ |
| 45 | Lisp_Object QCdbus_system_bus, QCdbus_session_bus; | 45 | Lisp_Object QCdbus_system_bus, QCdbus_session_bus; |
| 46 | 46 | ||
| 47 | /* Lisp symbol for method call timeout. */ | ||
| 48 | Lisp_Object QCdbus_timeout; | ||
| 49 | |||
| 47 | /* Lisp symbols of D-Bus types. */ | 50 | /* Lisp symbols of D-Bus types. */ |
| 48 | Lisp_Object QCdbus_type_byte, QCdbus_type_boolean; | 51 | Lisp_Object QCdbus_type_byte, QCdbus_type_boolean; |
| 49 | Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; | 52 | Lisp_Object QCdbus_type_int16, QCdbus_type_uint16; |
| @@ -724,6 +727,11 @@ SERVICE is the D-Bus service name to be used. PATH is the D-Bus | |||
| 724 | object path SERVICE is registered at. INTERFACE is an interface | 727 | object path SERVICE is registered at. INTERFACE is an interface |
| 725 | offered by SERVICE. It must provide METHOD. | 728 | offered by SERVICE. It must provide METHOD. |
| 726 | 729 | ||
| 730 | If the parameter `:timeout' is given, the following integer TIMEOUT | ||
| 731 | specifies the maximun number of milliseconds the method call must | ||
| 732 | return. The default value is 25.000. If the method call doesn't return | ||
| 733 | in time, a D-Bus error is raised. | ||
| 734 | |||
| 727 | All other arguments ARGS are passed to METHOD as arguments. They are | 735 | All other arguments ARGS are passed to METHOD as arguments. They are |
| 728 | converted into D-Bus types via the following rules: | 736 | converted into D-Bus types via the following rules: |
| 729 | 737 | ||
| @@ -777,7 +785,9 @@ object is returned instead of a list containing this single Lisp object. | |||
| 777 | 785 | ||
| 778 | => "i686" | 786 | => "i686" |
| 779 | 787 | ||
| 780 | usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | 788 | usage: (dbus-call-method |
| 789 | BUS SERVICE PATH INTERFACE METHOD | ||
| 790 | &optional :timeout TIMEOUT &rest ARGS) */) | ||
| 781 | (nargs, args) | 791 | (nargs, args) |
| 782 | int nargs; | 792 | int nargs; |
| 783 | register Lisp_Object *args; | 793 | register Lisp_Object *args; |
| @@ -791,7 +801,8 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | |||
| 791 | DBusMessageIter iter; | 801 | DBusMessageIter iter; |
| 792 | DBusError derror; | 802 | DBusError derror; |
| 793 | unsigned int dtype; | 803 | unsigned int dtype; |
| 794 | int i; | 804 | int timeout = -1; |
| 805 | int i = 5; | ||
| 795 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; | 806 | char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH]; |
| 796 | 807 | ||
| 797 | /* Check parameters. */ | 808 | /* Check parameters. */ |
| @@ -822,19 +833,23 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | |||
| 822 | SDATA (path), | 833 | SDATA (path), |
| 823 | SDATA (interface), | 834 | SDATA (interface), |
| 824 | SDATA (method)); | 835 | SDATA (method)); |
| 836 | UNGCPRO; | ||
| 825 | if (dmessage == NULL) | 837 | if (dmessage == NULL) |
| 838 | xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); | ||
| 839 | |||
| 840 | /* Check for timeout parameter. */ | ||
| 841 | if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout))) | ||
| 826 | { | 842 | { |
| 827 | UNGCPRO; | 843 | CHECK_NATNUM (args[i+1]); |
| 828 | xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); | 844 | timeout = XUINT (args[i+1]); |
| 845 | i = i+2; | ||
| 829 | } | 846 | } |
| 830 | 847 | ||
| 831 | UNGCPRO; | ||
| 832 | |||
| 833 | /* Initialize parameter list of message. */ | 848 | /* Initialize parameter list of message. */ |
| 834 | dbus_message_iter_init_append (dmessage, &iter); | 849 | dbus_message_iter_init_append (dmessage, &iter); |
| 835 | 850 | ||
| 836 | /* Append parameters to the message. */ | 851 | /* Append parameters to the message. */ |
| 837 | for (i = 5; i < nargs; ++i) | 852 | for (; i < nargs; ++i) |
| 838 | { | 853 | { |
| 839 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); | 854 | dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]); |
| 840 | if (XD_DBUS_TYPE_P (args[i])) | 855 | if (XD_DBUS_TYPE_P (args[i])) |
| @@ -864,7 +879,7 @@ usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */) | |||
| 864 | dbus_error_init (&derror); | 879 | dbus_error_init (&derror); |
| 865 | reply = dbus_connection_send_with_reply_and_block (connection, | 880 | reply = dbus_connection_send_with_reply_and_block (connection, |
| 866 | dmessage, | 881 | dmessage, |
| 867 | -1, | 882 | timeout, |
| 868 | &derror); | 883 | &derror); |
| 869 | 884 | ||
| 870 | if (dbus_error_is_set (&derror)) | 885 | if (dbus_error_is_set (&derror)) |
| @@ -1071,13 +1086,9 @@ usage: (dbus-send-signal BUS SERVICE PATH INTERFACE SIGNAL &rest ARGS) */) | |||
| 1071 | dmessage = dbus_message_new_signal (SDATA (path), | 1086 | dmessage = dbus_message_new_signal (SDATA (path), |
| 1072 | SDATA (interface), | 1087 | SDATA (interface), |
| 1073 | SDATA (signal)); | 1088 | SDATA (signal)); |
| 1074 | if (dmessage == NULL) | ||
| 1075 | { | ||
| 1076 | UNGCPRO; | ||
| 1077 | xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); | ||
| 1078 | } | ||
| 1079 | |||
| 1080 | UNGCPRO; | 1089 | UNGCPRO; |
| 1090 | if (dmessage == NULL) | ||
| 1091 | xsignal1 (Qdbus_error, build_string ("Unable to create a new message")); | ||
| 1081 | 1092 | ||
| 1082 | /* Initialize parameter list of message. */ | 1093 | /* Initialize parameter list of message. */ |
| 1083 | dbus_message_iter_init_append (dmessage, &iter); | 1094 | dbus_message_iter_init_append (dmessage, &iter); |
| @@ -1178,7 +1189,7 @@ xd_read_message (bus) | |||
| 1178 | interface = dbus_message_get_interface (dmessage); | 1189 | interface = dbus_message_get_interface (dmessage); |
| 1179 | member = dbus_message_get_member (dmessage); | 1190 | member = dbus_message_get_member (dmessage); |
| 1180 | 1191 | ||
| 1181 | /* dbus-registered-functions-table requires non nil interface and member. */ | 1192 | /* Vdbus_registered_functions_table requires non-nil interface and member. */ |
| 1182 | if ((NULL == interface) || (NULL == member)) | 1193 | if ((NULL == interface) || (NULL == member)) |
| 1183 | goto cleanup; | 1194 | goto cleanup; |
| 1184 | 1195 | ||
| @@ -1462,6 +1473,9 @@ syms_of_dbusbind () | |||
| 1462 | QCdbus_session_bus = intern (":session"); | 1473 | QCdbus_session_bus = intern (":session"); |
| 1463 | staticpro (&QCdbus_session_bus); | 1474 | staticpro (&QCdbus_session_bus); |
| 1464 | 1475 | ||
| 1476 | QCdbus_timeout = intern (":timeout"); | ||
| 1477 | staticpro (&QCdbus_timeout); | ||
| 1478 | |||
| 1465 | QCdbus_type_byte = intern (":byte"); | 1479 | QCdbus_type_byte = intern (":byte"); |
| 1466 | staticpro (&QCdbus_type_byte); | 1480 | staticpro (&QCdbus_type_byte); |
| 1467 | 1481 | ||