/* Lisp symbols of the system and session buses. */
Lisp_Object QCdbus_system_bus, QCdbus_session_bus;
+/* Lisp symbol for method call timeout. */
+Lisp_Object QCdbus_timeout;
+
/* Lisp symbols of D-Bus types. */
Lisp_Object QCdbus_type_byte, QCdbus_type_boolean;
Lisp_Object QCdbus_type_int16, QCdbus_type_uint16;
object path SERVICE is registered at. INTERFACE is an interface
offered by SERVICE. It must provide METHOD.
+If the parameter `:timeout' is given, the following integer TIMEOUT
+specifies the maximun number of milliseconds the method call must
+return. The default value is 25.000. If the method call doesn't return
+in time, a D-Bus error is raised.
+
All other arguments ARGS are passed to METHOD as arguments. They are
converted into D-Bus types via the following rules:
=> "i686"
-usage: (dbus-call-method BUS SERVICE PATH INTERFACE METHOD &rest ARGS) */)
+usage: (dbus-call-method
+ BUS SERVICE PATH INTERFACE METHOD
+ &optional :timeout TIMEOUT &rest ARGS) */)
(nargs, args)
int nargs;
register Lisp_Object *args;
DBusMessageIter iter;
DBusError derror;
unsigned int dtype;
- int i;
+ int timeout = -1;
+ int i = 5;
char signature[DBUS_MAXIMUM_SIGNATURE_LENGTH];
/* Check parameters. */
SDATA (path),
SDATA (interface),
SDATA (method));
+ UNGCPRO;
if (dmessage == NULL)
+ xsignal1 (Qdbus_error, build_string ("Unable to create a new message"));
+
+ /* Check for timeout parameter. */
+ if ((i+2 <= nargs) && (EQ ((args[i]), QCdbus_timeout)))
{
- UNGCPRO;
- xsignal1 (Qdbus_error, build_string ("Unable to create a new message"));
+ CHECK_NATNUM (args[i+1]);
+ timeout = XUINT (args[i+1]);
+ i = i+2;
}
- UNGCPRO;
-
/* Initialize parameter list of message. */
dbus_message_iter_init_append (dmessage, &iter);
/* Append parameters to the message. */
- for (i = 5; i < nargs; ++i)
+ for (; i < nargs; ++i)
{
dtype = XD_OBJECT_TO_DBUS_TYPE (args[i]);
if (XD_DBUS_TYPE_P (args[i]))
dbus_error_init (&derror);
reply = dbus_connection_send_with_reply_and_block (connection,
dmessage,
- -1,
+ timeout,
&derror);
if (dbus_error_is_set (&derror))
dmessage = dbus_message_new_signal (SDATA (path),
SDATA (interface),
SDATA (signal));
- if (dmessage == NULL)
- {
- UNGCPRO;
- xsignal1 (Qdbus_error, build_string ("Unable to create a new message"));
- }
-
UNGCPRO;
+ if (dmessage == NULL)
+ xsignal1 (Qdbus_error, build_string ("Unable to create a new message"));
/* Initialize parameter list of message. */
dbus_message_iter_init_append (dmessage, &iter);
interface = dbus_message_get_interface (dmessage);
member = dbus_message_get_member (dmessage);
- /* dbus-registered-functions-table requires non nil interface and member. */
+ /* Vdbus_registered_functions_table requires non-nil interface and member. */
if ((NULL == interface) || (NULL == member))
goto cleanup;
QCdbus_session_bus = intern (":session");
staticpro (&QCdbus_session_bus);
+ QCdbus_timeout = intern (":timeout");
+ staticpro (&QCdbus_timeout);
+
QCdbus_type_byte = intern (":byte");
staticpro (&QCdbus_type_byte);