コード例 #1
0
ファイル: engineproxy.c プロジェクト: hychen/ibus
static void
bus_engine_proxy_process_key_event_reply_cb (IBusPendingCall *pending,
                                             CallData        *call_data)
{
    IBusMessage *reply_message;
    IBusError *error;
    gboolean retval = FALSE;

    reply_message = dbus_pending_call_steal_reply (pending);

    if (reply_message == NULL) {
        /* reply timeout */
        IBusObject *connection;
        connection = (IBusObject *) ibus_proxy_get_connection ((IBusProxy *)call_data->engine);
        ibus_object_destroy (connection);
        goto _out;
    }
    else if ((error = ibus_error_new_from_message (reply_message)) != NULL) {
        if (g_strcmp0 (error->name, DBUS_ERROR_NO_REPLY) == 0) {
            /* reply timeout */
            IBusObject *connection;
            connection = (IBusObject *) ibus_proxy_get_connection ((IBusProxy *)call_data->engine);
            if (connection) {
                ibus_object_destroy (connection);
            }
        }
        g_warning ("%s: %s", error->name, error->message);
        ibus_error_free (error);
        goto _out;
    }

    if (!ibus_message_get_args (reply_message,
                                &error,
                                G_TYPE_BOOLEAN, &retval,
                                G_TYPE_INVALID)) {
        g_warning ("%s: %s", error->name, error->message);
        ibus_error_free (error);
        goto _out;
    }

_out:
    if (reply_message) {
        ibus_message_unref (reply_message);
    }
    g_object_unref (call_data->engine);
    call_data->func (GINT_TO_POINTER (retval), call_data->user_data);
    g_slice_free (CallData, call_data);
}
コード例 #2
0
ファイル: engineproxy.c プロジェクト: XueWei/ibus
static void
bus_engine_proxy_real_destroy (BusEngineProxy *engine)
{
    if (engine->prop_list) {
        g_object_unref (engine->prop_list);
        engine->prop_list = NULL;
    }

    if (ibus_proxy_get_connection ((IBusProxy *) engine)) {
        ibus_proxy_call ((IBusProxy *) engine,
                         "Destroy",
                         G_TYPE_INVALID);
    }

    if (engine->desc) {
        g_object_unref (engine->desc);
        engine->desc = NULL;
    }

    if (engine->keymap) {
        g_object_unref (engine->keymap);
        engine->keymap = NULL;
    }

    IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (engine));
}
コード例 #3
0
ファイル: ibusconfig.c プロジェクト: colorant/ibus
static void
ibus_config_real_destroy (IBusConfig *config)
{
    if (ibus_proxy_get_connection ((IBusProxy *) config) != NULL) {
        ibus_proxy_call ((IBusProxy *) config,
                         "Destroy",
                         G_TYPE_INVALID);
    }

    IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (config));
}
コード例 #4
0
ファイル: panelproxy.c プロジェクト: hychen/ibus
void
bus_panel_proxy_register_properties (BusPanelProxy  *panel,
                                     IBusPropList   *prop_list)
{
    g_assert (BUS_IS_PANEL_PROXY (panel));
    g_assert (prop_list != NULL);

    ibus_proxy_call ((IBusProxy *) panel,
                     "RegisterProperties",
                     IBUS_TYPE_PROP_LIST, &prop_list,
                     G_TYPE_INVALID);
    ibus_connection_flush (ibus_proxy_get_connection((IBusProxy *)panel));
}
コード例 #5
0
ファイル: ibusinputcontext.c プロジェクト: BBIO/ibus
static void
ibus_input_context_real_destroy (IBusInputContext *context)
{
    IBusInputContextPrivate *priv;
    priv = IBUS_INPUT_CONTEXT_GET_PRIVATE (context);

    if (priv->own && ibus_proxy_get_connection ((IBusProxy *) context) != NULL) {
        ibus_proxy_call (IBUS_PROXY (context),
                         "Destroy",
                         G_TYPE_INVALID);
    }

    IBUS_OBJECT_CLASS(ibus_input_context_parent_class)->destroy (IBUS_OBJECT (context));
}
コード例 #6
0
ファイル: panelproxy.c プロジェクト: hychen/ibus
static void
bus_panel_proxy_real_destroy (BusPanelProxy *panel)
{
    if (ibus_proxy_get_connection ((IBusProxy *)panel) != NULL) {
        ibus_proxy_call ((IBusProxy *) panel,
                         "Destroy",
                         G_TYPE_INVALID);
    }

    if (panel->focused_context) {
        bus_panel_proxy_focus_out (panel, panel->focused_context);
        panel->focused_context = NULL;
    }

    IBUS_OBJECT_CLASS(bus_panel_proxy_parent_class)->destroy (IBUS_OBJECT (panel));
}
コード例 #7
0
ファイル: panelproxy.c プロジェクト: iwaim/ibus
static void
bus_panel_proxy_real_destroy (BusPanelProxy *panel)
{
    BusPanelProxyPrivate *priv;
    priv = BUS_PANEL_PROXY_GET_PRIVATE (panel);

    if (ibus_proxy_get_connection ((IBusProxy *)panel) != NULL) {
        ibus_proxy_call ((IBusProxy *) panel,
                         "Destroy",
                         G_TYPE_INVALID);
    }

    if (priv->focused_context) {
        bus_panel_proxy_focus_out (panel, priv->focused_context);
        priv->focused_context = NULL;
    }

    IBUS_OBJECT_CLASS(parent_class)->destroy (IBUS_OBJECT (panel));
}
コード例 #8
0
ファイル: ibusproxy.c プロジェクト: BBIO/ibus
static void
ibus_proxy_get_property (IBusProxy      *proxy,
                         guint           prop_id,
                         GValue         *value,
                         GParamSpec     *pspec)
{
    switch (prop_id) {
    case PROP_NAME:
        g_value_set_string (value, ibus_proxy_get_name (proxy));
        break;
    case PROP_PATH:
        g_value_set_string (value, ibus_proxy_get_path (proxy));
        break;
    case PROP_INTERFACE:
        g_value_set_string (value, ibus_proxy_get_interface (proxy));
        break;
    case PROP_CONNECTION:
        g_value_set_object (value, ibus_proxy_get_connection (proxy));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (proxy, prop_id, pspec);
    }
}
コード例 #9
0
ファイル: factoryproxy.c プロジェクト: luoxsbupt/ibus
BusEngineProxy *
bus_factory_proxy_create_engine (BusFactoryProxy *factory,
                                 IBusEngineDesc  *desc)
{
    g_assert (BUS_IS_FACTORY_PROXY (factory));
    g_assert (IBUS_IS_ENGINE_DESC (desc));

    IBusPendingCall *pending = NULL;
    IBusMessage *reply_message;
    IBusError *error;
    BusEngineProxy *engine;
    gchar *object_path;
    gboolean retval;

    if (g_list_find (factory->component->engines, desc) == NULL) {
        return NULL;
    }

    retval = ibus_proxy_call_with_reply ((IBusProxy *) factory,
                                         "CreateEngine",
                                         &pending,
                                         g_dbus_timeout,
                                         &error,
                                         G_TYPE_STRING, &(desc->name),
                                         G_TYPE_INVALID);

    if (!retval) {
        g_warning ("%s: %s", error->name, error->message);
        ibus_error_free (error);
        return NULL;
    }

    ibus_pending_call_wait (pending);
    reply_message = ibus_pending_call_steal_reply (pending);
    ibus_pending_call_unref (pending);

    if (reply_message == NULL) {
        IBusObject *connection;
        connection = (IBusObject *) ibus_proxy_get_connection ((IBusProxy *)factory);
        ibus_object_destroy (connection);
        g_warning ("%s: %s", error->name, error->message);
        ibus_error_free (error);
        return NULL;
    }

    if ((error = ibus_error_new_from_message (reply_message)) != NULL) {
        if (g_strcmp0 (error->name, DBUS_ERROR_NO_REPLY) == 0) {
            IBusObject *connection;
            connection = (IBusObject *) ibus_proxy_get_connection ((IBusProxy *)factory);
            ibus_object_destroy (connection);
        }
        g_warning ("%s: %s", error->name, error->message);
        ibus_error_free (error);
        ibus_message_unref (reply_message);
        return NULL;
    }

    if (!ibus_message_get_args (reply_message,
                                &error,
                                IBUS_TYPE_OBJECT_PATH, &object_path,
                                G_TYPE_INVALID)) {
        g_warning ("%s: %s", error->name, error->message);
        ibus_error_free (error);
        ibus_message_unref (reply_message);

        return NULL;
    }

    IBusConnection *connection = ibus_proxy_get_connection ((IBusProxy *) factory);
    engine = bus_engine_proxy_new (object_path, desc, (BusConnection *) connection);
    ibus_message_unref (reply_message);

    return engine;
}
コード例 #10
0
ファイル: ibusinputcontext.c プロジェクト: BBIO/ibus
gboolean
ibus_input_context_process_key_event (IBusInputContext *context,
                                      guint32           keyval,
                                      guint32           keycode,
                                      guint32           state)
{
    g_assert (IBUS_IS_INPUT_CONTEXT (context));

    IBusMessage *reply_message;
    IBusPendingCall *pending = NULL;
    IBusError *error = NULL;
    gboolean retval;

    if (state & IBUS_HANDLED_MASK)
        return TRUE;

    if (state & IBUS_IGNORED_MASK)
        return FALSE;

    retval = ibus_proxy_call_with_reply ((IBusProxy *) context,
                                         "ProcessKeyEvent",
                                         &pending,
                                         -1,
                                         &error,
                                         G_TYPE_UINT, &keyval,
                                         G_TYPE_UINT, &keycode,
                                         G_TYPE_UINT, &state,
                                         G_TYPE_INVALID);
    if (!retval) {
        g_debug ("%s: %s", error->name, error->message);
        ibus_error_free (error);
        return FALSE;
    }

    /* wait reply or timeout */
    IBusConnection *connection = ibus_proxy_get_connection ((IBusProxy *) context);
    while (!ibus_pending_call_get_completed (pending)) {
        ibus_connection_read_write_dispatch (connection, -1);
    }

    reply_message = ibus_pending_call_steal_reply (pending);
    ibus_pending_call_unref (pending);

    if (reply_message == NULL) {
        g_debug ("%s: Do not recevie reply of ProcessKeyEvent", DBUS_ERROR_NO_REPLY);
        retval = FALSE;
    }
    else if ((error = ibus_error_new_from_message (reply_message)) != NULL) {
        g_debug ("%s: %s", error->name, error->message);
        ibus_message_unref (reply_message);
        ibus_error_free (error);
        retval = FALSE;
    }
    else {
        if (!ibus_message_get_args (reply_message,
                                    &error,
                                    G_TYPE_BOOLEAN, &retval,
                                    G_TYPE_INVALID)) {
            g_debug ("%s: %s", error->name, error->message);
            ibus_error_free (error);
            retval = FALSE;
        }
        ibus_message_unref (reply_message);
    }
    return retval;
}