BusEngineProxy * bus_engine_proxy_new (const gchar *path, IBusEngineDesc *desc, BusConnection *connection) { g_assert (path); g_assert (IBUS_IS_ENGINE_DESC (desc)); g_assert (BUS_IS_CONNECTION (connection)); BusEngineProxy *engine; engine = (BusEngineProxy *) g_object_new (BUS_TYPE_ENGINE_PROXY, "name", NULL, "path", path, "connection", connection, NULL); engine->desc = desc; g_object_ref_sink (desc); if (desc->layout != NULL && desc->layout[0] != '\0') { engine->keymap = ibus_keymap_get (desc->layout); } if (engine->keymap == NULL) { engine->keymap = ibus_keymap_get ("us"); } return engine; }
BusFactoryProxy * bus_factory_proxy_get_from_engine (IBusEngineDesc *desc) { IBUS_IS_ENGINE_DESC (desc); BusFactoryProxy *factory; factory = (BusFactoryProxy *) g_object_get_data ((GObject *)desc, "factory"); return factory; }
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; }