Mercurial > emacs
comparison src/dbusbind.c @ 104305:52ea0b8b565e
* dbusbind.c (Fdbus_call_method_asynchronously): Allow nil HANDLER.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Sun, 16 Aug 2009 17:34:47 +0000 |
parents | a98c5e3801f8 |
children | 73f76307d49b |
comparison
equal
deleted
inserted
replaced
104304:35fbb27750a7 | 104305:52ea0b8b565e |
---|---|
965 SERVICE is the D-Bus service name to be used. PATH is the D-Bus | 965 SERVICE is the D-Bus service name to be used. PATH is the D-Bus |
966 object path SERVICE is registered at. INTERFACE is an interface | 966 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 |
974 return. The default value is 25.000. If the method call doesn't | 975 return. The default value is 25.000. If the method call doesn't |
975 return in time, a D-Bus error is raised. | 976 return in time, a D-Bus error is raised. |
985 list => DBUS_TYPE_ARRAY | 986 list => DBUS_TYPE_ARRAY |
986 | 987 |
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. |
994 | 995 |
995 Example: | 996 Example: |
1030 CHECK_SYMBOL (bus); | 1031 CHECK_SYMBOL (bus); |
1031 CHECK_STRING (service); | 1032 CHECK_STRING (service); |
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 |
1039 XD_DEBUG_MESSAGE ("%s %s %s %s", | 1040 XD_DEBUG_MESSAGE ("%s %s %s %s", |
1040 SDATA (service), | 1041 SDATA (service), |
1089 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); | 1090 xd_signature (signature, dtype, DBUS_TYPE_INVALID, args[i]); |
1090 | 1091 |
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")); | |
1102 | |
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")); | |
1115 | |
1116 result = Qnil; | |
1117 } | |
1118 | |
1119 /* Flush connection to ensure the message is handled. */ | |
1120 dbus_connection_flush (connection); | |
1098 | 1121 |
1099 XD_DEBUG_MESSAGE ("Message sent"); | 1122 XD_DEBUG_MESSAGE ("Message sent"); |
1100 | |
1101 /* The result is the key in Vdbus_registered_functions_table. */ | |
1102 result = (list2 (bus, make_number (dbus_message_get_serial (dmessage)))); | |
1103 | |
1104 /* Create a hash table entry. */ | |
1105 Fputhash (result, handler, Vdbus_registered_functions_table); | |
1106 | 1123 |
1107 /* Cleanup. */ | 1124 /* Cleanup. */ |
1108 dbus_message_unref (dmessage); | 1125 dbus_message_unref (dmessage); |
1109 | 1126 |
1110 /* Return the result. */ | 1127 /* Return the result. */ |