const char *destination = dbus_message_get_destination (message);
struct timeval tv;
DBusMessage *ret;
+ static gboolean in_dispatch = FALSE;
if (unique_name && destination &&
strcmp (destination, unique_name) != 0)
- return dbus_connection_send_with_reply_and_block (bus, message, dbind_timeout, error);
+ {
+ ret = dbus_connection_send_with_reply_and_block (bus, message,
+ dbind_timeout, error);
+ if (g_main_depth () == 0 && !in_dispatch)
+ {
+ in_dispatch = TRUE;
+ while (dbus_connection_dispatch (bus) == DBUS_DISPATCH_DATA_REMAINS);
+ in_dispatch = FALSE;
+ }
+ return ret;
+ }
closure = g_new0 (SpiReentrantCallClosure, 1);
closure->reply = NULL;
- atspi_dbus_connection_setup_with_g_main(bus, NULL);
- if (!dbus_connection_send_with_reply (bus, message, &pending, dbind_timeout))
+ if (!dbus_connection_send_with_reply (bus, message, &pending, dbind_timeout)
+ || !pending)
+ {
+ g_free (closure);
return NULL;
- if (!pending)
- return NULL;
+ }
dbus_pending_call_set_notify (pending, set_reply, (void *) closure, g_free);
closure->reply = NULL;
{
if (!dbus_connection_read_write_dispatch (bus, dbind_timeout))
{
+ //dbus_pending_call_set_notify (pending, NULL, NULL, NULL);
+ dbus_pending_call_cancel (pending);
dbus_pending_call_unref (pending);
return NULL;
}
if (time_elapsed (&tv) > dbind_timeout)
{
+ //dbus_pending_call_set_notify (pending, NULL, NULL, NULL);
+ dbus_pending_call_cancel (pending);
dbus_pending_call_unref (pending);
dbus_set_error_const (error, "org.freedesktop.DBus.Error.NoReply",
"timeout from dbind");
const char *p;
va_list args_demarshal;
+ dbus_error_init (&real_err);
+
va_copy (args_demarshal, args);
if (opt_error)
err = opt_error;
else {
- dbus_error_init (&real_err);
err = &real_err;
}
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
{
- const char *name = dbus_message_get_error_name (reply);
goto out;
}
/* demarshal */
{
DBusMessageIter iter;
dbus_message_iter_init (reply, &iter);
+ if (strcmp (p + 2, dbus_message_get_signature (reply)) != 0)
+ {
+ g_warning ("dbind: Call to \"%s\" returned signature %s; expected %s",
+ method, dbus_message_get_signature (reply), p + 2);
+ if (opt_error)
+ dbus_set_error (opt_error, DBUS_ERROR_INVALID_ARGS,
+ "Call to \"%s\" returned signature %s; expected %s",
+ method, dbus_message_get_signature (reply),
+ p + 2);
+ goto out;
+ }
p = arg_types;
dbind_any_demarshal_va (&iter, &p, args_demarshal);
}
if (reply)
dbus_message_unref (reply);
- if (err == &real_err)
- dbus_error_free (err);
+ if (dbus_error_is_set (&real_err))
+ dbus_error_free (&real_err);
va_end (args_demarshal);
return success;
/*---------------------------------------------------------------------------*/
+/* TODO: opt_error is unused; should be removed */
dbus_bool_t
dbind_emit_signal_va (DBusConnection *cnx,
const char *path,
dbus_bool_t success = FALSE;
DBusMessage *msg = NULL;
DBusMessageIter iter;
- DBusError *err, real_err;
const char *p;
- if (opt_error)
- err = opt_error;
- else {
- dbus_error_init (&real_err);
- err = &real_err;
- }
-
msg = dbus_message_new_signal (path, interface, signal);
if (!msg)
goto out;
if (msg)
dbus_message_unref (msg);
- if (err == &real_err)
- dbus_error_free (err);
-
return success;
}