listener_dbus_remove_ref_entry (GSListener     *listener,
                                int             entry_type,
                                DBusConnection *connection,
                                DBusMessage    *message)
{
        DBusMessage        *reply;
        DBusError           error;
        const char         *sender;
        guint32             cookie;

        dbus_error_init (&error);
        if (! dbus_message_get_args (message, &error,
                                     DBUS_TYPE_UINT32, &cookie,
                                     DBUS_TYPE_INVALID)) {
                if (entry_type == REF_ENTRY_TYPE_INHIBIT) {
                        raise_syntax (connection, message, "UnInhibit");
                } else if (entry_type == REF_ENTRY_TYPE_THROTTLE) {
                        raise_syntax (connection, message, "UnThrottle");
                } else {
                        g_assert_not_reached ();
                }

                return DBUS_HANDLER_RESULT_HANDLED;
        }

        reply = dbus_message_new_method_return (message);
        if (reply == NULL)
                g_error ("No memory");

        /* FIXME: check sender is from same connection as entry */
        sender = dbus_message_get_sender (message);

        listener_remove_ref_entry (listener, entry_type, cookie);

        /* FIXME:  Pointless? */
        if (! dbus_connection_send (connection, reply, NULL)) {
                g_error ("No memory");
        }

        dbus_message_unref (reply);

        return DBUS_HANDLER_RESULT_HANDLED;
}
listener_dbus_remove_ref_entry (GSListener     *listener,
                                int             entry_type,
                                DBusConnection *connection,
                                DBusMessage    *message)
{
        DBusMessage        *reply;
        DBusError           error;
        const char         *sender;
        guint32             cookie;

        dbus_error_init (&error);
        if (! dbus_message_get_args (message, &error,
                                     DBUS_TYPE_UINT32, &cookie,
                                     DBUS_TYPE_INVALID)) {
                if (entry_type == REF_ENTRY_TYPE_INHIBIT) {
                        raise_syntax (connection, message, "UnInhibit");
                } else if (entry_type == REF_ENTRY_TYPE_THROTTLE) {
                        raise_syntax (connection, message, "UnThrottle");
                } else {
                        g_assert_not_reached ();
                }

                return DBUS_HANDLER_RESULT_HANDLED;
        }

        reply = dbus_message_new_method_return (message);
        if (reply == NULL)
                g_error ("No memory");

         
        sender = dbus_message_get_sender (message);

        listener_remove_ref_entry (listener, entry_type, cookie);

         
        if (! dbus_connection_send (connection, reply, NULL)) {
                g_error ("No memory");
        }

        dbus_message_unref (reply);

        return DBUS_HANDLER_RESULT_HANDLED;
}