aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Albinus2009-08-16 17:35:44 +0000
committerMichael Albinus2009-08-16 17:35:44 +0000
commitca4f31ea158896bcca9020b15489340df6ccba38 (patch)
tree7d353d49e2b09c45b6dd9e774dc7ac660245fb3b /src
parent556594956bdd178569ea6e1fe0b5c3034be0f3a1 (diff)
downloademacs-ca4f31ea158896bcca9020b15489340df6ccba38.tar.gz
emacs-ca4f31ea158896bcca9020b15489340df6ccba38.zip
* dbusbind.c (Fdbus_call_method_asynchronously): Allow nil HANDLER.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog1
-rw-r--r--src/dbusbind.c41
2 files changed, 30 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d3d85a8502b..123e7a845cd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,7 @@
3 * dbusbind.c (xd_initialize): Add connection file descriptor to 3 * dbusbind.c (xd_initialize): Add connection file descriptor to
4 input_wait_mask, in order to let select() detect, whether a new 4 input_wait_mask, in order to let select() detect, whether a new
5 message has been arrived. 5 message has been arrived.
6 (Fdbus_call_method_asynchronously): Allow nil HANDLER.
6 7
72009-08-15 Michael Albinus <michael.albinus@gmx.de> 82009-08-15 Michael Albinus <michael.albinus@gmx.de>
8 9
diff --git a/src/dbusbind.c b/src/dbusbind.c
index cde4dba3a23..a38a9944005 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -967,7 +967,8 @@ object path SERVICE is registered at. INTERFACE is an interface
967offered by SERVICE. It must provide METHOD. 967offered by SERVICE. It must provide METHOD.
968 968
969HANDLER is a Lisp function, which is called when the corresponding 969HANDLER is a Lisp function, which is called when the corresponding
970return message has arrived. 970return message has arrived. If HANDLER is nil, no return message will
971be expected.
971 972
972If the parameter `:timeout' is given, the following integer TIMEOUT 973If the parameter `:timeout' is given, the following integer TIMEOUT
973specifies the maximun number of milliseconds the method call must 974specifies the maximun number of milliseconds the method call must
@@ -987,7 +988,7 @@ converted into D-Bus types via the following rules:
987All arguments can be preceded by a type symbol. For details about 988All arguments can be preceded by a type symbol. For details about
988type symbols, see Info node `(dbus)Type Conversion'. 989type symbols, see Info node `(dbus)Type Conversion'.
989 990
990The function returns a key into the hash table 991Unless HANDLER is nil, the function returns a key into the hash table
991`dbus-registered-functions-table'. The corresponding entry in the 992`dbus-registered-functions-table'. The corresponding entry in the
992hash table is removed, when the return message has been arrived, and 993hash table is removed, when the return message has been arrived, and
993HANDLER is called. 994HANDLER is called.
@@ -1032,7 +1033,7 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE
1032 CHECK_STRING (path); 1033 CHECK_STRING (path);
1033 CHECK_STRING (interface); 1034 CHECK_STRING (interface);
1034 CHECK_STRING (method); 1035 CHECK_STRING (method);
1035 if (!FUNCTIONP (handler)) 1036 if (!NILP (handler) && !FUNCTIONP (handler))
1036 wrong_type_argument (intern ("functionp"), handler); 1037 wrong_type_argument (intern ("functionp"), handler);
1037 GCPRO6 (bus, service, path, interface, method, handler); 1038 GCPRO6 (bus, service, path, interface, method, handler);
1038 1039
@@ -1091,18 +1092,34 @@ usage: (dbus-call-method-asynchronously BUS SERVICE PATH INTERFACE METHOD HANDLE
1091 xd_append_arg (dtype, args[i], &iter); 1092 xd_append_arg (dtype, args[i], &iter);
1092 } 1093 }
1093 1094
1094 /* Send the message. The message is just added to the outgoing 1095 if (!NILP (handler))
1095 message queue. */ 1096 {
1096 if (!dbus_connection_send_with_reply (connection, dmessage, NULL, timeout)) 1097 /* Send the message. The message is just added to the outgoing
1097 XD_SIGNAL1 (build_string ("Cannot send message")); 1098 message queue. */
1099 if (!dbus_connection_send_with_reply (connection, dmessage,
1100 NULL, timeout))
1101 XD_SIGNAL1 (build_string ("Cannot send message"));
1098 1102
1099 XD_DEBUG_MESSAGE ("Message sent"); 1103 /* The result is the key in Vdbus_registered_functions_table. */
1104 result = (list2 (bus, make_number (dbus_message_get_serial (dmessage))));
1105
1106 /* Create a hash table entry. */
1107 Fputhash (result, handler, Vdbus_registered_functions_table);
1108 }
1109 else
1110 {
1111 /* Send the message. The message is just added to the outgoing
1112 message queue. */
1113 if (!dbus_connection_send (connection, dmessage, NULL))
1114 XD_SIGNAL1 (build_string ("Cannot send message"));
1100 1115
1101 /* The result is the key in Vdbus_registered_functions_table. */ 1116 result = Qnil;
1102 result = (list2 (bus, make_number (dbus_message_get_serial (dmessage)))); 1117 }
1103 1118
1104 /* Create a hash table entry. */ 1119 /* Flush connection to ensure the message is handled. */
1105 Fputhash (result, handler, Vdbus_registered_functions_table); 1120 dbus_connection_flush (connection);
1121
1122 XD_DEBUG_MESSAGE ("Message sent");
1106 1123
1107 /* Cleanup. */ 1124 /* Cleanup. */
1108 dbus_message_unref (dmessage); 1125 dbus_message_unref (dmessage);