diff options
| author | Michael Albinus | 2009-08-16 17:35:44 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-08-16 17:35:44 +0000 |
| commit | ca4f31ea158896bcca9020b15489340df6ccba38 (patch) | |
| tree | 7d353d49e2b09c45b6dd9e774dc7ac660245fb3b /src/dbusbind.c | |
| parent | 556594956bdd178569ea6e1fe0b5c3034be0f3a1 (diff) | |
| download | emacs-ca4f31ea158896bcca9020b15489340df6ccba38.tar.gz emacs-ca4f31ea158896bcca9020b15489340df6ccba38.zip | |
* dbusbind.c (Fdbus_call_method_asynchronously): Allow nil HANDLER.
Diffstat (limited to 'src/dbusbind.c')
| -rw-r--r-- | src/dbusbind.c | 41 |
1 files changed, 29 insertions, 12 deletions
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 | |||
| 967 | offered by SERVICE. It must provide METHOD. | 967 | offered by SERVICE. It must provide METHOD. |
| 968 | 968 | ||
| 969 | HANDLER is a Lisp function, which is called when the corresponding | 969 | HANDLER is a Lisp function, which is called when the corresponding |
| 970 | return message has arrived. | 970 | return message has arrived. If HANDLER is nil, no return message will |
| 971 | be expected. | ||
| 971 | 972 | ||
| 972 | If the parameter `:timeout' is given, the following integer TIMEOUT | 973 | If the parameter `:timeout' is given, the following integer TIMEOUT |
| 973 | specifies the maximun number of milliseconds the method call must | 974 | specifies the maximun number of milliseconds the method call must |
| @@ -987,7 +988,7 @@ converted into D-Bus types via the following rules: | |||
| 987 | All arguments can be preceded by a type symbol. For details about | 988 | All arguments can be preceded by a type symbol. For details about |
| 988 | type symbols, see Info node `(dbus)Type Conversion'. | 989 | type symbols, see Info node `(dbus)Type Conversion'. |
| 989 | 990 | ||
| 990 | The function returns a key into the hash table | 991 | Unless 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 |
| 992 | hash table is removed, when the return message has been arrived, and | 993 | hash table is removed, when the return message has been arrived, and |
| 993 | HANDLER is called. | 994 | HANDLER 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); |