get_events_reply (DBusPendingCall *pending, void *user_data)
{
  DBusMessage *reply = dbus_pending_call_steal_reply (pending);
  DBusMessageIter iter, iter_array, iter_struct;

  if (!reply)
    goto done;

  if (strcmp (dbus_message_get_signature (reply), "a(ss)") != 0)
    {
      g_warning ("atk-bridge: GetRegisteredEvents returned message with unknown signature");
      goto done;
    }

  dbus_message_iter_init (reply, &iter);
  dbus_message_iter_recurse (&iter, &iter_array);
  while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
    {
      char *bus_name, *event;
      dbus_message_iter_recurse (&iter_array, &iter_struct);
      dbus_message_iter_get_basic (&iter_struct, &bus_name);
      dbus_message_iter_next (&iter_struct);
      dbus_message_iter_get_basic (&iter_struct, &event);
      add_event (bus_name, event);
      dbus_message_iter_next (&iter_array);
    }

done:
  if (reply)
    dbus_message_unref (reply);
  if (pending)
    dbus_pending_call_unref (pending);

  tally_event_reply ();
}
get_events_reply (DBusPendingCall *pending, void *user_data)
{
  DBusMessage *reply = dbus_pending_call_steal_reply (pending);
  DBusMessageIter iter, iter_array, iter_struct;

  if (!reply)
    goto done;

  if (strcmp (dbus_message_get_signature (reply), "a(ss)") != 0)
    {
      g_warning ("atk-bridge: GetRegisteredEvents returned message with unknown signature");
      goto done;
    }

  dbus_message_iter_init (reply, &iter);
  dbus_message_iter_recurse (&iter, &iter_array);
  while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
    {
      char *bus_name, *event;
      dbus_message_iter_recurse (&iter_array, &iter_struct);
      dbus_message_iter_get_basic (&iter_struct, &bus_name);
      dbus_message_iter_next (&iter_struct);
      dbus_message_iter_get_basic (&iter_struct, &event);
      add_event (bus_name, event);
      dbus_message_iter_next (&iter_array);
    }

done:
  if (reply)
    dbus_message_unref (reply);
  if (pending)
    dbus_pending_call_unref (pending);

  tally_event_reply ();
}