void bus_engine_proxy_process_key_event (BusEngineProxy *engine, guint keyval, guint keycode, guint state, GFunc return_cb, gpointer user_data) { g_assert (BUS_IS_ENGINE_PROXY (engine)); g_assert (return_cb); IBusPendingCall *pending = NULL; CallData *call_data; IBusError *error; gboolean retval; if (keycode != 0 && !BUS_DEFAULT_IBUS->use_sys_layout && engine->keymap != NULL) { guint t = ibus_keymap_lookup_keysym (engine->keymap, keycode, state); if (t != IBUS_VoidSymbol) { keyval = t; } } retval = ibus_proxy_call_with_reply ((IBusProxy *) engine, "ProcessKeyEvent", &pending, g_dbus_timeout, &error, G_TYPE_UINT, &keyval, G_TYPE_UINT, &keycode, G_TYPE_UINT, &state, G_TYPE_INVALID); if (!retval) { g_warning ("%s: %s", error->name, error->message); ibus_error_free (error); return_cb (GINT_TO_POINTER (FALSE), user_data); return; } call_data = g_slice_new0 (CallData); call_data->func = return_cb; call_data->user_data = user_data; g_object_ref (engine); call_data->engine = engine; retval = ibus_pending_call_set_notify (pending, (IBusPendingCallNotifyFunction) bus_engine_proxy_process_key_event_reply_cb, call_data, NULL); ibus_pending_call_unref (pending); if (!retval) { g_object_unref (call_data->engine); g_slice_free (CallData, call_data); g_warning ("%s : ProcessKeyEvent", DBUS_ERROR_NO_MEMORY); return_cb (GINT_TO_POINTER (FALSE), user_data); return; } }
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; }
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; }