+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
/* vim:set et sts=4: */
/* ibus - The Input Bus
- * Copyright (C) 2008-2009 Huang Peng <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
+ * Copyright (C) 2008-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
#include "ibusfactory.h"
#include "ibusengine.h"
+#include "ibusmarshalers.h"
#include "ibusshare.h"
#include "ibusinternal.h"
(G_TYPE_INSTANCE_GET_PRIVATE ((o), IBUS_TYPE_FACTORY, IBusFactoryPrivate))
enum {
+ CREATE_ENGINE,
LAST_SIGNAL,
};
+enum {
+ PROP_0,
+};
+
/* IBusFactoryPriv */
struct _IBusFactoryPrivate {
guint id;
- IBusConnection *connection;
GList *engine_list;
GHashTable *engine_table;
};
-typedef struct _IBusFactoryPrivate IBusFactoryPrivate;
+
+static guint factory_signals[LAST_SIGNAL] = { 0 };
/* functions prototype */
-static void ibus_factory_class_init (IBusFactoryClass *klass);
-static void ibus_factory_init (IBusFactory *factory);
-static void ibus_factory_destroy (IBusFactory *factory);
-static gboolean ibus_factory_ibus_message (IBusFactory *factory,
- IBusConnection *connection,
- IBusMessage *message);
-
-static void _engine_destroy_cb (IBusEngine *engine,
- IBusFactory *factory);
-static void ibus_factory_info_class_init(IBusFactoryInfoClass *klass);
-static void ibus_factory_info_init (IBusFactoryInfo *info);
-static void ibus_factory_info_destroy (IBusFactoryInfo *info);
-static gboolean ibus_factory_info_serialize (IBusFactoryInfo *info,
- IBusMessageIter *iter);
-static gboolean ibus_factory_info_deserialize
- (IBusFactoryInfo *info,
- IBusMessageIter *iter);
-static gboolean ibus_factory_info_copy (IBusFactoryInfo *dest,
- const IBusFactoryInfo *src);
-
-static IBusServiceClass *factory_parent_class = NULL;
-static IBusSerializableClass *factory_info_parent_class = NULL;
-
-GType
-ibus_factory_get_type (void)
+static void ibus_factory_destroy (IBusFactory *factory);
+static void ibus_factory_set_property (IBusFactory *engine,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void ibus_factory_get_property (IBusFactory *factory,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void ibus_factory_service_method_call
+ (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation
+ *invocation);
+static GVariant *ibus_factory_service_get_property
+ (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error);
+static gboolean ibus_factory_service_set_property
+ (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GVariant *value,
+ GError **error);
+static void ibus_factory_engine_destroy_cb
+ (IBusEngine *engine,
+ IBusFactory *factory);
+
+G_DEFINE_TYPE (IBusFactory, ibus_factory, IBUS_TYPE_SERVICE)
+
+static const gchar introspection_xml[] =
+ "<node>"
+ " <interface name='org.freedesktop.IBus.Factory'>"
+ " <method name='CreateEngine'>"
+ " <arg direction='in' type='s' name='name' />"
+ " <arg direction='out' type='o' />"
+ " </method>"
+ " </interface>"
+ "</node>";
+
+static IBusEngine *
+ibus_factory_real_create_engine (IBusFactory *factory,
+ const gchar *engine_name)
{
- static GType type = 0;
-
- static const GTypeInfo type_info = {
- sizeof (IBusFactoryClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) ibus_factory_class_init,
- NULL, /* class finalize */
- NULL, /* class data */
- sizeof (IBusFactory),
- 0,
- (GInstanceInitFunc) ibus_factory_init,
- };
-
- if (type == 0) {
- type = g_type_register_static (IBUS_TYPE_SERVICE,
- "IBusFactory",
- &type_info,
- (GTypeFlags) 0);
- }
- return type;
-}
+ GType engine_type;
+ gchar *object_path = NULL;
+ IBusEngine *engine = NULL;
-IBusFactory *
-ibus_factory_new (IBusConnection *connection)
-{
- g_assert (IBUS_IS_CONNECTION (connection));
+ engine_type = (GType) g_hash_table_lookup (factory->priv->engine_table,
+ engine_name);
- IBusFactory *factory;
- IBusFactoryPrivate *priv;
+ g_return_val_if_fail (engine_type != G_TYPE_INVALID, NULL);
- factory = (IBusFactory *) g_object_new (IBUS_TYPE_FACTORY,
- "path", IBUS_PATH_FACTORY,
- NULL);
- priv = IBUS_FACTORY_GET_PRIVATE (factory);
+ object_path = g_strdup_printf ("/org/freedesktop/IBus/Engine/%d",
+ ++factory->priv->id);
+ engine = ibus_engine_new_with_type (engine_type,
+ engine_name,
+ object_path,
+ ibus_service_get_connection ((IBusService *)factory));
+ g_free (object_path);
- priv->connection = g_object_ref (connection);
- ibus_service_add_to_connection ((IBusService *)factory, connection);
+ return engine;
+}
- return factory;
+static gboolean
+_ibus_factory_create_engine_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer dummy)
+{
+ gboolean retval = TRUE;
+ GObject *object = g_value_get_object (handler_return);
+
+ if (object != NULL) {
+ g_value_copy (handler_return, return_accu);
+ retval = FALSE;
+ }
+
+ return retval;
}
static void
-ibus_factory_class_init (IBusFactoryClass *klass)
+ibus_factory_class_init (IBusFactoryClass *class)
{
- // GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (klass);
-
- factory_parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass);
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ IBusObjectClass *ibus_object_class = IBUS_OBJECT_CLASS (class);
- g_type_class_add_private (klass, sizeof (IBusFactoryPrivate));
+ gobject_class->set_property = (GObjectSetPropertyFunc) ibus_factory_set_property;
+ gobject_class->get_property = (GObjectGetPropertyFunc) ibus_factory_get_property;
ibus_object_class->destroy = (IBusObjectDestroyFunc) ibus_factory_destroy;
- IBUS_SERVICE_CLASS (klass)->ibus_message = (ServiceIBusMessageFunc) ibus_factory_ibus_message;
-
+ IBUS_SERVICE_CLASS (class)->service_method_call = ibus_factory_service_method_call;
+ IBUS_SERVICE_CLASS (class)->service_get_property = ibus_factory_service_get_property;
+ IBUS_SERVICE_CLASS (class)->service_set_property = ibus_factory_service_set_property;
+ class->create_engine = ibus_factory_real_create_engine;
+
+ ibus_service_class_add_interfaces (IBUS_SERVICE_CLASS (class), introspection_xml);
+
+ g_type_class_add_private (class, sizeof (IBusFactoryPrivate));
+
+ /**
+ * IBusFactory::create-engine:
+ * @factory: the factory which received the signal
+ * @engine_name: the engine_name which received the signal
+ * @returns: (transfer full): An IBusEngine
+ *
+ * The ::create-engine signal is a signal to create IBusEngine
+ * with @engine_name, which gets emitted when IBusFactory
+ * received CreateEngine dbus method. The callback functions
+ * will be called until a callback returns a non-null object
+ * of IBusEngine.
+ */
+ factory_signals[CREATE_ENGINE] =
+ g_signal_new (I_("create-engine"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (IBusFactoryClass, create_engine),
+ _ibus_factory_create_engine_accumulator,
+ NULL,
+ _ibus_marshal_OBJECT__STRING,
+ IBUS_TYPE_ENGINE,
+ 1,
+ G_TYPE_STRING);
}
static void
ibus_factory_init (IBusFactory *factory)
{
- IBusFactoryPrivate *priv;
- priv = IBUS_FACTORY_GET_PRIVATE (factory);
-
- priv->id = 0;
- priv->connection = NULL;
- priv->engine_table = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- NULL);
- priv->engine_list = NULL;
+ factory->priv = IBUS_FACTORY_GET_PRIVATE (factory);
+ factory->priv->engine_table =
+ g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ NULL);
}
static void
ibus_factory_destroy (IBusFactory *factory)
{
GList *list;
- IBusFactoryPrivate *priv;
- priv = IBUS_FACTORY_GET_PRIVATE (factory);
- list = g_list_copy (priv->engine_list);
- g_list_foreach (list, (GFunc) ibus_object_destroy, NULL);
- g_list_free (priv->engine_list);
- g_list_free (list);
- priv->engine_list = NULL;
+ list = g_list_copy (factory->priv->engine_list);
+ g_list_free_full (list, (GDestroyNotify)ibus_object_destroy);
+ g_list_free(factory->priv->engine_list);
+ factory->priv->engine_list = NULL;
- if (priv->engine_table) {
- g_hash_table_destroy (priv->engine_table);
+ if (factory->priv->engine_table) {
+ g_hash_table_destroy (factory->priv->engine_table);
}
- if (priv->connection) {
- ibus_service_remove_from_connection ((IBusService *)factory,
- priv->connection);
- g_object_unref (priv->connection);
- }
-
- IBUS_OBJECT_CLASS(factory_parent_class)->destroy (IBUS_OBJECT (factory));
+ IBUS_OBJECT_CLASS(ibus_factory_parent_class)->destroy (IBUS_OBJECT (factory));
}
static void
-_engine_destroy_cb (IBusEngine *engine,
- IBusFactory *factory)
+ibus_factory_set_property (IBusFactory *factory,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- IBusFactoryPrivate *priv;
- priv = IBUS_FACTORY_GET_PRIVATE (factory);
-
- priv->engine_list = g_list_remove (priv->engine_list, engine);
- g_object_unref (engine);
-}
-
-static gboolean
-ibus_factory_ibus_message (IBusFactory *factory,
- IBusConnection *connection,
- IBusMessage *message)
-{
- g_assert (IBUS_IS_FACTORY (factory));
- g_assert (IBUS_IS_CONNECTION (connection));
- g_assert (message != NULL);
-
- IBusMessage *reply_message;
- IBusFactoryPrivate *priv;
- priv = IBUS_FACTORY_GET_PRIVATE (factory);
-
- g_assert (priv->connection == connection);
-
- if (ibus_message_is_method_call (message,
- IBUS_INTERFACE_FACTORY,
- "CreateEngine")) {
- gchar *engine_name;
- gchar *path;
- IBusError *error;
- IBusEngine *engine;
- gboolean retval;
- GType engine_type;
-
- retval = ibus_message_get_args (message,
- &error,
- G_TYPE_STRING, &engine_name,
- G_TYPE_INVALID);
-
- if (!retval) {
- reply_message = ibus_message_new_error_printf (message,
- DBUS_ERROR_INVALID_ARGS,
- "The 1st arg should be engine name");
- ibus_connection_send (connection, reply_message);
- ibus_message_unref (reply_message);
- return TRUE;
- }
-
- engine_type = (GType )g_hash_table_lookup (priv->engine_table, engine_name);
-
- if (engine_type == G_TYPE_INVALID) {
- reply_message = ibus_message_new_error_printf (message,
- DBUS_ERROR_FAILED,
- "Can not create engine %s", engine_name);
- ibus_connection_send (connection, reply_message);
- ibus_message_unref (reply_message);
- return TRUE;
-
- }
-
- path = g_strdup_printf ("/org/freedesktop/IBus/Engine/%d", ++priv->id);
-
- engine = g_object_new (engine_type,
- "name", engine_name,
- "path", path,
- "connection", priv->connection,
- NULL);
-
- priv->engine_list = g_list_append (priv->engine_list, engine);
- g_signal_connect (engine,
- "destroy",
- G_CALLBACK (_engine_destroy_cb),
- factory);
-
- reply_message = ibus_message_new_method_return (message);
- ibus_message_append_args (reply_message,
- IBUS_TYPE_OBJECT_PATH, &path,
- G_TYPE_INVALID);
- g_free (path);
- ibus_connection_send (connection, reply_message);
- ibus_message_unref (reply_message);
- return TRUE;
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (factory, prop_id, pspec);
}
-
- return factory_parent_class->ibus_message ((IBusService *)factory,
- connection,
- message);
-}
-
-void
-ibus_factory_add_engine (IBusFactory *factory,
- const gchar *engine_name,
- GType engine_type)
-{
- g_assert (IBUS_IS_FACTORY (factory));
- g_assert (engine_name);
- g_assert (g_type_is_a (engine_type, IBUS_TYPE_ENGINE));
-
- IBusFactoryPrivate *priv;
- priv = IBUS_FACTORY_GET_PRIVATE (factory);
-
- g_hash_table_insert (priv->engine_table, g_strdup (engine_name), (gpointer) engine_type);
}
-#if 0
-IBusFactoryInfo *
-ibus_factory_get_info (IBusFactory *factory)
-{
- IBusFactoryPrivate *priv;
- priv = IBUS_FACTORY_GET_PRIVATE (factory);
-
- return priv->info;
-}
-#endif
-
-GType
-ibus_factory_info_get_type (void)
+static void
+ibus_factory_get_property (IBusFactory *factory,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- static GType type = 0;
-
- static const GTypeInfo type_info = {
- sizeof (IBusFactoryInfoClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) ibus_factory_info_class_init,
- NULL, /* class finialize */
- NULL, /* class data */
- sizeof (IBusFactoryInfo),
- 0,
- (GInstanceInitFunc) ibus_factory_info_init,
- };
-
- if (type == 0) {
- type = g_type_register_static (IBUS_TYPE_SERIALIZABLE,
- "IBusFactoryInfo",
- &type_info,
- 0);
+ switch (prop_id) {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (factory, prop_id, pspec);
}
-
- return type;
}
static void
-ibus_factory_info_class_init (IBusFactoryInfoClass *klass)
+ibus_factory_engine_destroy_cb (IBusEngine *engine,
+ IBusFactory *factory)
{
- IBusObjectClass *object_class = IBUS_OBJECT_CLASS (klass);
- IBusSerializableClass *serializable_class = IBUS_SERIALIZABLE_CLASS (klass);
-
- factory_info_parent_class = (IBusSerializableClass *) g_type_class_peek_parent (klass);
-
- object_class->destroy = (IBusObjectDestroyFunc) ibus_factory_info_destroy;
-
- serializable_class->serialize = (IBusSerializableSerializeFunc) ibus_factory_info_serialize;
- serializable_class->deserialize = (IBusSerializableDeserializeFunc) ibus_factory_info_deserialize;
- serializable_class->copy = (IBusSerializableCopyFunc) ibus_factory_info_copy;
-
- g_string_append (serializable_class->signature, "osssss");
+ factory->priv->engine_list = g_list_remove (factory->priv->engine_list, engine);
+ g_object_unref (engine);
}
static void
-ibus_factory_info_init (IBusFactoryInfo *info)
+ibus_factory_service_method_call (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
- info->path = NULL;
- info->name = NULL;
- info->lang = NULL;
- info->icon = NULL;
- info->authors = NULL;
- info->credits = NULL;
-}
+ IBusFactory *factory = IBUS_FACTORY (service);
+
+ if (g_strcmp0 (method_name, "CreateEngine") == 0) {
+ gchar *engine_name = NULL;
+ IBusEngine *engine = NULL;
+
+ g_variant_get (parameters, "(&s)", &engine_name);
+ g_signal_emit (factory, factory_signals[CREATE_ENGINE],
+ 0, engine_name, &engine);
+
+ if (engine != NULL) {
+ gchar *object_path = NULL;
+ GValue value = { 0, };
+
+ g_value_init (&value, G_TYPE_STRING);
+ g_object_get_property (G_OBJECT (engine), "object-path", &value);
+ object_path = g_value_dup_string (&value);
+ g_value_unset (&value);
+
+ g_assert (engine != NULL);
+ g_assert (object_path != NULL);
+ g_object_ref_sink (engine);
+ factory->priv->engine_list = g_list_append (factory->priv->engine_list, engine);
+ g_signal_connect (engine,
+ "destroy",
+ G_CALLBACK (ibus_factory_engine_destroy_cb),
+ factory);
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(o)", object_path));
+ g_free (object_path);
+ }
+ else {
+ gchar *error_message = g_strdup_printf ("Can not fond engine %s", engine_name);
+ g_dbus_method_invocation_return_error (invocation,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ error_message);
+ g_free (error_message);
+ }
+ return;
+ }
-static void
-ibus_factory_info_destroy (IBusFactoryInfo *info)
-{
- g_free (info->path);
- g_free (info->name);
- g_free (info->lang);
- g_free (info->icon);
- g_free (info->authors);
- g_free (info->credits);
-
- info->path = NULL;
- info->lang = NULL;
- info->name = NULL;
- info->icon = NULL;
- info->authors = NULL;
- info->credits = NULL;
-
- IBUS_OBJECT_CLASS (factory_info_parent_class)->destroy ((IBusObject *)info);
+ IBUS_SERVICE_CLASS (ibus_factory_parent_class)->
+ service_method_call (service,
+ connection,
+ sender,
+ object_path,
+ interface_name,
+ method_name,
+ parameters,
+ invocation);
}
-static gboolean
-ibus_factory_info_serialize (IBusFactoryInfo *info,
- IBusMessageIter *iter)
+static GVariant *
+ibus_factory_service_get_property (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error)
{
- gboolean retval;
-
- retval = factory_info_parent_class->serialize ((IBusSerializable *)info, iter);
- g_return_val_if_fail (retval, FALSE);
-
- retval = ibus_message_iter_append (iter, IBUS_TYPE_OBJECT_PATH, &info->path);
- g_return_val_if_fail (retval, FALSE);
-
- retval = ibus_message_iter_append (iter, G_TYPE_STRING, &info->name);
- g_return_val_if_fail (retval, FALSE);
-
- retval = ibus_message_iter_append (iter, G_TYPE_STRING, &info->lang);
- g_return_val_if_fail (retval, FALSE);
-
- retval = ibus_message_iter_append (iter, G_TYPE_STRING, &info->icon);
- g_return_val_if_fail (retval, FALSE);
-
- retval = ibus_message_iter_append (iter, G_TYPE_STRING, &info->authors);
- g_return_val_if_fail (retval, FALSE);
-
- retval = ibus_message_iter_append (iter, G_TYPE_STRING, &info->credits);
- g_return_val_if_fail (retval, FALSE);
-
- return TRUE;
+ return IBUS_SERVICE_CLASS (ibus_factory_parent_class)->
+ service_get_property (service,
+ connection,
+ sender,
+ object_path,
+ interface_name,
+ property_name,
+ error);
}
static gboolean
-ibus_factory_info_deserialize (IBusFactoryInfo *info,
- IBusMessageIter *iter)
+ibus_factory_service_set_property (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GVariant *value,
+ GError **error)
{
- gboolean retval;
-
- retval = factory_info_parent_class->deserialize ((IBusSerializable *)info, iter);
- g_return_val_if_fail (retval, FALSE);
-
- retval = ibus_message_iter_get (iter, IBUS_TYPE_OBJECT_PATH, &info->path);
- g_return_val_if_fail (retval, FALSE);
- ibus_message_iter_next (iter);
- info->path = g_strdup (info->path);
-
- retval = ibus_message_iter_get (iter, G_TYPE_STRING, &info->name);
- g_return_val_if_fail (retval, FALSE);
- ibus_message_iter_next (iter);
- info->name = g_strdup (info->name);
-
- retval = ibus_message_iter_get (iter, G_TYPE_STRING, &info->lang);
- g_return_val_if_fail (retval, FALSE);
- ibus_message_iter_next (iter);
- info->lang = g_strdup (info->lang);
-
- retval = ibus_message_iter_get (iter, G_TYPE_STRING, &info->icon);
- g_return_val_if_fail (retval, FALSE);
- ibus_message_iter_next (iter);
- info->icon = g_strdup (info->icon);
-
- retval = ibus_message_iter_get (iter, G_TYPE_STRING, &info->authors);
- g_return_val_if_fail (retval, FALSE);
- ibus_message_iter_next (iter);
- info->authors = g_strdup (info->authors);
-
- retval = ibus_message_iter_get (iter, G_TYPE_STRING, &info->credits);
- g_return_val_if_fail (retval, FALSE);
- ibus_message_iter_next (iter);
- info->credits = g_strdup (info->credits);
-
- return TRUE;
+ return IBUS_SERVICE_CLASS (ibus_factory_parent_class)->
+ service_set_property (service,
+ connection,
+ sender,
+ object_path,
+ interface_name,
+ property_name,
+ value,
+ error);
}
-static gboolean
-ibus_factory_info_copy (IBusFactoryInfo *dest,
- const IBusFactoryInfo *src)
+IBusFactory *
+ibus_factory_new (GDBusConnection *connection)
{
- gboolean retval;
+ g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
- retval = factory_info_parent_class->copy ((IBusSerializable *)dest,
- (IBusSerializable *)src);
- g_return_val_if_fail (retval, FALSE);
+ IBusFactory *object = g_object_new (IBUS_TYPE_FACTORY,
+ "object-path", IBUS_PATH_FACTORY,
+ "connection", connection,
+ NULL);
- g_return_val_if_fail (IBUS_IS_FACTORY_INFO (dest), FALSE);
- g_return_val_if_fail (IBUS_IS_FACTORY_INFO (src), FALSE);
+ return IBUS_FACTORY (object);
+}
- dest->path = g_strdup (src->path);
- dest->name = g_strdup (src->name);
- dest->lang = g_strdup (src->lang);
- dest->icon = g_strdup (src->icon);
- dest->authors = g_strdup (src->authors);
- dest->credits = g_strdup (src->credits);
+void
+ibus_factory_add_engine (IBusFactory *factory,
+ const gchar *engine_name,
+ GType engine_type)
+{
+ g_return_if_fail (IBUS_IS_FACTORY (factory));
+ g_return_if_fail (engine_name != NULL);
+ g_return_if_fail (g_type_is_a (engine_type, IBUS_TYPE_ENGINE));
- return TRUE;
+ g_hash_table_insert (factory->priv->engine_table, g_strdup (engine_name), (gpointer) engine_type);
}
-IBusFactoryInfo *
-ibus_factory_info_new (const gchar *path,
- const gchar *name,
- const gchar *lang,
- const gchar *icon,
- const gchar *authors,
- const gchar *credits)
+IBusEngine *
+ibus_factory_create_engine (IBusFactory *factory,
+ const gchar *engine_name)
{
- g_assert (path);
- g_assert (name);
- g_assert (lang);
- g_assert (icon);
- g_assert (authors);
- g_assert (credits);
-
- IBusFactoryInfo *info;
+ IBusEngine *engine = NULL;
- info = (IBusFactoryInfo *) g_object_new (IBUS_TYPE_FACTORY_INFO, NULL);
+ g_assert (engine_name != NULL);
- info->path = g_strdup (path);
- info->name = g_strdup (name);
- info->lang = g_strdup (lang);
- info->icon = g_strdup (icon);
- info->authors = g_strdup (authors);
- info->credits = g_strdup (credits);
+ g_signal_emit (factory, factory_signals[CREATE_ENGINE],
+ 0, engine_name, &engine);
- return info;
+ return engine;
}
-
-