Пример #1
0
void
ibus_connection_flush (IBusConnection *connection)
{
    g_assert (IBUS_IS_CONNECTION (connection));
    g_assert (ibus_connection_is_connected (connection));

    IBusConnectionPrivate *priv;

    priv = IBUS_CONNECTION_GET_PRIVATE (connection);

    dbus_connection_flush (priv->connection);
}
Пример #2
0
gboolean
ibus_proxy_call_with_reply (IBusProxy        *proxy,
                            const gchar      *method,
                            IBusPendingCall **pending,
                            gint              timeout_milliseconds,
                            IBusError       **error,
                            GType             first_arg_type,
                            ...)
{
    g_assert (IBUS_IS_PROXY (proxy));
    g_assert (pending != NULL);
    g_assert (method != NULL);

    va_list args;
    gboolean retval;
    DBusMessage *message;

    IBusProxyPrivate *priv;
    priv = IBUS_PROXY_GET_PRIVATE (proxy);

    if (priv->connection == NULL || !ibus_connection_is_connected (priv->connection)) {
        if (error) {
            *error = ibus_error_new_from_printf (DBUS_ERROR_DISCONNECTED,
                                                 "Connection of %s was disconnected.",
                                                 G_OBJECT_TYPE_NAME (proxy));
        }
        return FALSE;
    }

    message = ibus_message_new_method_call (priv->name,
                                            priv->path,
                                            priv->interface,
                                            method);
    va_start (args, first_arg_type);
    retval = ibus_message_append_args_valist (message,
                                              first_arg_type,
                                              args);
    va_end (args);

    *pending = NULL;
    retval = ibus_connection_send_with_reply (priv->connection,
                                              message,
                                              pending,
                                              timeout_milliseconds);
    ibus_message_unref (message);

    if (!retval && error != NULL) {
        *error = ibus_error_new_from_printf (DBUS_ERROR_NO_MEMORY, "");
    }

    return retval;
}
Пример #3
0
static IBusMessage *
ibus_connection_call_with_reply_valist (IBusConnection     *connection,
                                        const gchar        *name,
                                        const gchar        *path,
                                        const gchar        *interface,
                                        const gchar        *member,
                                        IBusError          **error,
                                        GType              first_arg_type,
                                        va_list            va_args)
{
    g_assert (IBUS_IS_CONNECTION (connection));
    g_assert (name != NULL);
    g_assert (path != NULL);
    g_assert (interface != NULL);
    g_assert (member != NULL);
    g_assert (ibus_connection_is_connected (connection));

    IBusConnectionPrivate *priv;
    priv = IBUS_CONNECTION_GET_PRIVATE (connection);

    IBusMessage *message, *reply;
    IBusError *tmp_error;

    message = ibus_message_new_method_call (name, path, interface, member);

    ibus_message_append_args_valist (message, first_arg_type, va_args);

    reply = ibus_connection_send_with_reply_and_block (
                                        connection,
                                        message,
                                        -1,
                                        error);
    ibus_message_unref (message);

    if (reply == NULL) {
        return NULL;
    }

    if ((tmp_error = ibus_error_new_from_message (reply)) != NULL) {
        if (error) {
            *error = tmp_error;
        }
        else {
            ibus_error_free (tmp_error);
        }
        ibus_message_unref (reply);
        return NULL;
    }

    return reply;
}
Пример #4
0
gboolean
ibus_bus_is_connected (IBusBus *bus)
{
    g_assert (IBUS_IS_BUS (bus));

    IBusBusPrivate *priv;
    priv = IBUS_BUS_GET_PRIVATE (bus);

    if (priv->connection) {
        return ibus_connection_is_connected (priv->connection);
    }

    return FALSE;
}
Пример #5
0
gboolean
ibus_proxy_send (IBusProxy      *proxy,
                 DBusMessage    *message)
{
    g_assert (IBUS_IS_PROXY (proxy));
    g_assert (message != NULL);

    IBusProxyPrivate *priv;
    priv = IBUS_PROXY_GET_PRIVATE (proxy);

    g_return_val_if_fail (priv->connection, FALSE);
    g_return_val_if_fail (ibus_connection_is_connected (priv->connection), FALSE);

    return ibus_connection_send (priv->connection, message);
}
Пример #6
0
gboolean
ibus_proxy_call (IBusProxy      *proxy,
                 const gchar    *method,
                 GType           first_arg_type,
                 ...)
{
    g_assert (IBUS_IS_PROXY (proxy));
    g_assert (method != NULL);

    va_list args;
    gboolean retval;
    DBusMessage *message;

    IBusProxyPrivate *priv;
    priv = IBUS_PROXY_GET_PRIVATE (proxy);

    g_return_val_if_fail (priv->connection, FALSE);
    g_return_val_if_fail (ibus_connection_is_connected (priv->connection), FALSE);

    message = ibus_message_new_method_call (priv->name,
                                            priv->path,
                                            priv->interface,
                                            method);
    va_start (args, first_arg_type);
    retval = ibus_message_append_args_valist (message,
                                              first_arg_type,
                                              args);
    if (!retval) {
        ibus_message_unref (message);
        g_return_val_if_reached (FALSE);
    }

    va_end (args);

    retval = ibus_connection_send (priv->connection, message);

    ibus_message_unref (message);

    return retval;
}
Пример #7
0
gboolean
ibus_connection_call (IBusConnection     *connection,
                      const gchar        *name,
                      const gchar        *path,
                      const gchar        *interface,
                      const gchar        *member,
                      IBusError          **error,
                      GType              first_arg_type,
                      ...)
{
    g_assert (IBUS_IS_CONNECTION (connection));
    g_assert (name != NULL);
    g_assert (path != NULL);
    g_assert (interface != NULL);
    g_assert (member != NULL);
    g_return_val_if_fail (ibus_connection_is_connected (connection), FALSE);

    IBusConnectionPrivate *priv;
    priv = IBUS_CONNECTION_GET_PRIVATE (connection);

    IBusMessage *message, *reply;
    IBusError *tmp_error;
    va_list args;
    GType type;
    gboolean retval;

    message = ibus_message_new_method_call (name, path, interface, member);

    va_start (args, first_arg_type);

    ibus_message_append_args_valist (message, first_arg_type, args);

    va_end (args);

    reply = ibus_connection_send_with_reply_and_block (
                                        connection,
                                        message,
                                        -1,
                                        error);
    ibus_message_unref (message);

    if (reply == NULL) {
        return FALSE;
    }

    if ((tmp_error = ibus_error_new_from_message (reply)) != NULL) {
        if (error) {
            *error = tmp_error;
        }
        else {
            ibus_error_free (tmp_error);
        }
        ibus_message_unref (reply);
        return FALSE;
    }

    va_start (args, first_arg_type);

    type = first_arg_type;

    while (type != G_TYPE_INVALID) {
        va_arg (args, gpointer);
        type = va_arg (args, GType);
    }
    type = va_arg (args, GType);

    if (type != G_TYPE_INVALID) {
        retval = ibus_message_get_args_valist (reply, error, type, args);
    }
    else {
        retval = TRUE;
    }

    va_end (args);
    ibus_message_unref (reply);

    return retval;
}