summaryrefslogtreecommitdiffstats
path: root/bus
diff options
context:
space:
mode:
Diffstat (limited to 'bus')
-rw-r--r--bus/Makefile.am9
-rw-r--r--bus/dbusimpl.c11
-rw-r--r--bus/ibus.desktop10
-rw-r--r--bus/ibusimpl.c264
-rw-r--r--bus/inputcontext.c41
-rw-r--r--bus/inputcontext.h5
-rw-r--r--bus/main.c15
-rw-r--r--bus/matchrule.c11
-rw-r--r--bus/matchrule.h5
-rw-r--r--bus/registry.c28
-rw-r--r--bus/registry.h3
-rw-r--r--bus/server.c20
12 files changed, 341 insertions, 81 deletions
diff --git a/bus/Makefile.am b/bus/Makefile.am
index 03ddfb3..526ac21 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -42,8 +42,13 @@ AM_LDFLAGS = \
TESTS = \
test-matchrule \
$(NULL)
-
-desktop_DATA = ibus.desktop
+xdgautostart_DATA = \
+ ibus.desktop \
+ $(NULL)
+xdgautostartdir = $(sysconfdir)/xdg/autostart
+desktop_DATA = \
+ ibus.desktop \
+ $(NULL)
desktopdir = $(datadir)/applications
noinst_PROGRAMS = $(TESTS)
diff --git a/bus/dbusimpl.c b/bus/dbusimpl.c
index f8b8566..3cc51dc 100644
--- a/bus/dbusimpl.c
+++ b/bus/dbusimpl.c
@@ -819,6 +819,7 @@ _connection_ibus_message_cb (BusConnection *connection,
ibus_message_set_sender (message, bus_connection_get_unique_name (connection));
switch (ibus_message_get_type (message)) {
+#if 1
case DBUS_MESSAGE_TYPE_ERROR:
g_debug ("From :%s to %s, Error: %s : %s",
ibus_message_get_sender (message),
@@ -826,6 +827,7 @@ _connection_ibus_message_cb (BusConnection *connection,
ibus_message_get_error_name (message),
ibus_message_get_error_message (message));
break;
+#endif
#if 0
case DBUS_MESSAGE_TYPE_METHOD_CALL:
g_debug("From %s to %s, Method %s on %s",
@@ -1066,11 +1068,10 @@ bus_dbus_impl_dispatch_message_by_rule (BusDBusImpl *dbus,
#endif
for (link = dbus->rules; link != NULL; link = link->next) {
- if (bus_match_rule_get_recipients (BUS_MATCH_RULE (link->data),
- message,
- &recipients)) {
+ recipients = bus_match_rule_get_recipients (BUS_MATCH_RULE (link->data),
+ message);
+ if (recipients != NULL)
break;
- }
}
for (link = recipients; link != NULL; link = link->next) {
@@ -1078,7 +1079,7 @@ bus_dbus_impl_dispatch_message_by_rule (BusDBusImpl *dbus,
if (connection != skip_connection) {
ibus_connection_send (IBUS_CONNECTION (connection), message);
}
- g_object_unref (link->data);
+ g_object_unref (connection);
}
g_list_free (recipients);
}
diff --git a/bus/ibus.desktop b/bus/ibus.desktop
index fd98021..6336dfd 100644
--- a/bus/ibus.desktop
+++ b/bus/ibus.desktop
@@ -1,11 +1,13 @@
[Desktop Entry]
Encoding=UTF-8
Name=IBus
-GenericName=Intelligent Input Bus
-Comment=Intellignent Input Bus
+GenericName=IBus input method framework
+Comment=IBus input method framework
Exec=ibus-daemon --xim
Icon=ibus
Terminal=false
Type=Application
-StartupNotify=false
-Categories=Utility;
+X-GNOME-Autostart-Phase=Panel
+X-GNOME-AutoRestart=false
+X-GNOME-Autostart-Notify=true
+X-KDE-autostart-after=panel
diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c
index 053080f..814e831 100644
--- a/bus/ibusimpl.c
+++ b/bus/ibusimpl.c
@@ -23,6 +23,8 @@
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
+#include <locale.h>
+#include <strings.h>
#include "ibusimpl.h"
#include "dbusimpl.h"
#include "server.h"
@@ -130,22 +132,18 @@ _panel_destroy_cb (BusPanelProxy *panel,
}
static void
-bus_ibus_impl_set_trigger (BusIBusImpl *ibus,
- GValue *value)
+bus_ibus_impl_set_hotkey (BusIBusImpl *ibus,
+ GQuark hotkey,
+ GValue *value)
{
g_assert (BUS_IS_IBUS_IMPL (ibus));
GValueArray *array;
gint i;
- ibus_hotkey_profile_remove_hotkey_by_event (ibus->hotkey_profile,
- g_quark_from_static_string ("trigger"));
+ ibus_hotkey_profile_remove_hotkey_by_event (ibus->hotkey_profile, hotkey);
if (value == NULL) {
- ibus_hotkey_profile_add_hotkey (ibus->hotkey_profile,
- IBUS_space,
- IBUS_CONTROL_MASK,
- g_quark_from_static_string ("trigger"));
return;
}
@@ -160,8 +158,39 @@ bus_ibus_impl_set_trigger (BusIBusImpl *ibus,
ibus_hotkey_profile_add_hotkey_from_string (ibus->hotkey_profile,
g_value_get_string (str),
- g_quark_from_static_string ("trigger"));
+ hotkey);
}
+
+}
+
+static void
+bus_ibus_impl_set_trigger (BusIBusImpl *ibus,
+ GValue *value)
+{
+ GQuark hotkey = g_quark_from_static_string ("trigger");
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value);
+ if (value == NULL) {
+ ibus_hotkey_profile_add_hotkey (ibus->hotkey_profile,
+ IBUS_space,
+ IBUS_CONTROL_MASK,
+ hotkey);
+ }
+}
+
+static void
+bus_ibus_impl_set_next_engine (BusIBusImpl *ibus,
+ GValue *value)
+{
+ GQuark hotkey = g_quark_from_static_string ("next-engine");
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value);
+}
+
+static void
+bus_ibus_impl_set_prev_engine (BusIBusImpl *ibus,
+ GValue *value)
+{
+ GQuark hotkey = g_quark_from_static_string ("prev-engine");
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value);
}
static void
@@ -198,6 +227,78 @@ bus_ibus_impl_set_preload_engines (BusIBusImpl *ibus,
g_list_foreach (engine_list, (GFunc) g_object_ref, NULL);
ibus->engine_list = engine_list;
+
+ if (ibus->engine_list) {
+ IBusComponent *component;
+
+ component = ibus_component_get_from_engine ((IBusEngineDesc *) ibus->engine_list->data);
+ if (component && !ibus_component_is_running (component)) {
+ ibus_component_start (component);
+ }
+ }
+}
+
+static gint
+_engine_desc_cmp (IBusEngineDesc *desc1,
+ IBusEngineDesc *desc2)
+{
+ return - ((gint) desc1->rank) + ((gint) desc2->rank);
+}
+
+static void
+bus_ibus_impl_set_default_preload_engines (BusIBusImpl *ibus)
+{
+ g_assert (BUS_IS_IBUS_IMPL (ibus));
+
+ static gboolean done = FALSE;
+ GValue value = { 0 };
+ GList *engines, *l;
+ gchar *lang, *p;
+ GValueArray *array;
+
+ if (done || ibus->config == NULL) {
+ return;
+ }
+
+ if (ibus_config_get_value (ibus->config, "general", "preload_engines", &value)) {
+ done = TRUE;
+ g_value_unset (&value);
+ return;
+ }
+
+ done = TRUE;
+ lang = g_strdup (setlocale (LC_ALL, NULL));
+ p = index (lang, '.');
+ if (p) {
+ *p = '\0';
+ }
+
+ engines = bus_registry_get_engines_by_language (ibus->registry, lang);
+ if (engines == NULL) {
+ p = index (lang, '_');
+ if (p) {
+ *p = '\0';
+ engines = bus_registry_get_engines_by_language (ibus->registry, lang);
+ }
+ }
+
+ engines = g_list_sort (engines, (GCompareFunc) _engine_desc_cmp);
+ g_free (lang);
+
+ g_value_init (&value, G_TYPE_VALUE_ARRAY);
+ array = g_value_array_new (5);
+ for (l = engines; l != NULL; l = l->next) {
+ IBusEngineDesc *desc;
+ GValue name = { 0 };
+ desc = (IBusEngineDesc *)l->data;
+ g_value_init (&name, G_TYPE_STRING);
+ g_value_set_string (&name, desc->name);
+ g_value_array_append (array, &name);
+ }
+ g_value_take_boxed (&value, array);
+ ibus_config_set_value (ibus->config, "general", "preload_engines", &value);
+ g_value_unset (&value);
+ g_list_free (engines);
}
static void
@@ -214,6 +315,8 @@ bus_ibus_impl_reload_config (BusIBusImpl *ibus)
void ( *func) (BusIBusImpl *, GValue *);
} entries [] = {
{ "general/hotkey", "trigger", bus_ibus_impl_set_trigger },
+ { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine },
+ { "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine },
{ "general", "preload_engines", bus_ibus_impl_set_preload_engines },
{ NULL, NULL, NULL },
};
@@ -253,8 +356,10 @@ _config_value_changed_cb (IBusConfig *config,
gchar *key;
void ( *func) (BusIBusImpl *, GValue *);
} entries [] = {
- { "general/hotkey", "trigger", bus_ibus_impl_set_trigger },
- { "general", "preload_engines", bus_ibus_impl_set_preload_engines },
+ { "general/hotkey", "trigger", bus_ibus_impl_set_trigger },
+ { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine },
+ { "general/hotkey", "prev_engine", bus_ibus_impl_set_prev_engine },
+ { "general", "preload_engines", bus_ibus_impl_set_preload_engines },
{ NULL, NULL, NULL },
};
@@ -347,6 +452,7 @@ _dbus_name_owner_changed_cb (BusDBusImpl *dbus,
G_CALLBACK (_config_destroy_cb),
ibus);
+ bus_ibus_impl_set_default_preload_engines (ibus);
bus_ibus_impl_reload_config (ibus);
}
}
@@ -406,7 +512,7 @@ bus_ibus_impl_destroy (BusIBusImpl *ibus)
break;
}
if (pid == 0) { /* no child status changed */
- usleep (1000);
+ g_usleep (1000);
timeout += 1000;
if (timeout >= G_USEC_PER_SEC) {
if (flag == FALSE) {
@@ -504,14 +610,58 @@ _ibus_get_address (BusIBusImpl *ibus,
return reply;
}
+static BusEngineProxy *
+bus_ibus_impl_create_engine (IBusEngineDesc *engine_desc)
+{
+ IBusComponent *comp;
+ BusFactoryProxy *factory;
+ BusEngineProxy *engine;
+
+ factory = bus_factory_proxy_get_from_engine (engine_desc);
+
+ if (factory == NULL) {
+ /* try to execute the engine */
+ comp = ibus_component_get_from_engine (engine_desc);
+ g_assert (comp);
+
+ if (!ibus_component_is_running (comp)) {
+ ibus_component_start (comp);
+
+ gint time = 0;
+ while (time < G_USEC_PER_SEC * 3) {
+ if (g_main_context_pending (NULL)) {
+ g_main_context_iteration (NULL, FALSE);
+ }
+ else {
+ g_usleep (50 * 1000);
+ time += 50 * 1000;
+ }
+ factory = bus_factory_proxy_get_from_engine (engine_desc);
+ if (factory != NULL) {
+ break;
+ }
+ }
+ }
+ factory = bus_factory_proxy_get_from_engine (engine_desc);
+ }
+
+ if (factory == NULL) {
+ return NULL;
+ }
+
+ g_object_ref (factory);
+ engine = bus_factory_proxy_create_engine (factory, engine_desc);
+ g_object_unref (factory);
+
+ return engine;
+}
+
static void
_context_request_engine_cb (BusInputContext *context,
gchar *engine_name,
BusIBusImpl *ibus)
{
IBusEngineDesc *engine_desc = NULL;
- IBusComponent *comp;
- BusFactoryProxy *factory;
BusEngineProxy *engine;
if (engine_name == NULL || engine_name[0] == '\0') {
@@ -553,44 +703,15 @@ _context_request_engine_cb (BusInputContext *context,
}
}
- if (engine_desc == NULL)
+ if (engine_desc == NULL) {
return;
-
- factory = bus_factory_proxy_get_from_engine (engine_desc);
-
- if (factory == NULL) {
- /* try to execute the engine */
- comp = ibus_component_get_from_engine (engine_desc);
- g_assert (comp);
-
- if (!ibus_component_is_running (comp)) {
- ibus_component_start (comp);
-
- gint time = 0;
- while (time < G_USEC_PER_SEC * 3) {
- if (g_main_context_pending (NULL)) {
- g_main_context_iteration (NULL, FALSE);
- }
- else {
- g_usleep (50 * 1000);
- time += 50 * 1000;
- }
- factory = bus_factory_proxy_get_from_engine (engine_desc);
- if (factory != NULL) {
- break;
- }
- }
- }
- factory = bus_factory_proxy_get_from_engine (engine_desc);
}
- if (factory == NULL)
- return;
+ engine = bus_ibus_impl_create_engine (engine_desc);
- engine = bus_factory_proxy_create_engine (factory, engine_desc);
-
- if (engine == NULL)
+ if (engine == NULL) {
return;
+ }
bus_input_context_set_engine (context, engine);
g_object_unref (engine);
@@ -600,7 +721,47 @@ static void
_context_request_next_engine_cb (BusInputContext *context,
BusIBusImpl *ibus)
{
+ BusEngineProxy *engine;
+ IBusEngineDesc *desc;
+ IBusEngineDesc *next_desc = NULL;
+ GList *p;
+
+ engine = bus_input_context_get_engine (context);
+ if (engine == NULL) {
+ _context_request_engine_cb (context, NULL, ibus);
+ return;
+ }
+
+ desc = bus_engine_proxy_get_desc (engine);
+
+ p = g_list_find (ibus->register_engine_list, desc);
+ if (p != NULL) {
+ p = p->next;
+ }
+ if (p == NULL) {
+ p = g_list_find (ibus->engine_list, desc);
+ if (p != NULL) {
+ p = p->next;
+ }
+ }
+ if (p != NULL) {
+ next_desc = (IBusEngineDesc*) p->data;
+ }
+ else {
+ if (ibus->register_engine_list) {
+ next_desc = (IBusEngineDesc *)ibus->register_engine_list->data;
+ }
+ else if (ibus->engine_list) {
+ next_desc = (IBusEngineDesc *)ibus->engine_list->data;
+ }
+ }
+
+ if (next_desc != NULL) {
+ engine = bus_ibus_impl_create_engine (next_desc);
+ bus_input_context_set_engine (context, engine);
+ g_object_unref (engine);
+ }
}
static void
@@ -699,8 +860,6 @@ _ibus_create_input_context (BusIBusImpl *ibus,
context = bus_input_context_new (connection, client);
ibus->contexts = g_list_append (ibus->contexts, context);
- _context_request_engine_cb (context, NULL, ibus);
-
static const struct {
gchar *name;
GCallback callback;
@@ -905,12 +1064,19 @@ _ibus_exit (BusIBusImpl *ibus,
else {
extern gchar **g_argv;
gchar *exe;
+ gint fd;
exe = g_strdup_printf ("/proc/%d/exe", getpid ());
if (!g_file_test (exe, G_FILE_TEST_EXISTS)) {
g_free (exe);
exe = g_argv[0];
}
+
+ /* close all fds except stdin, stdout, stderr */
+ for (fd = 3; fd <= sysconf (_SC_OPEN_MAX); fd ++) {
+ close (fd);
+ }
+
execv (exe, g_argv);
g_warning ("execv %s failed!", g_argv[0]);
exit (-1);
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
index 6ba7322..d857479 100644
--- a/bus/inputcontext.c
+++ b/bus/inputcontext.c
@@ -1022,7 +1022,7 @@ bus_input_context_ibus_message (BusInputContext *context,
gboolean
-bus_input_context_is_focus (BusInputContext *context)
+bus_input_context_has_focus (BusInputContext *context)
{
g_assert (BUS_IS_INPUT_CONTEXT (context));
@@ -1425,7 +1425,6 @@ bus_input_context_disable (BusInputContext *context)
BusInputContextPrivate *priv;
priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
-
if (priv->engine) {
if (priv->has_focus) {
bus_engine_proxy_focus_out (priv->engine);
@@ -1443,6 +1442,17 @@ bus_input_context_disable (BusInputContext *context)
priv->enabled = FALSE;
}
+gboolean
+bus_input_context_is_enabled (BusInputContext *context)
+{
+ g_assert (BUS_IS_INPUT_CONTEXT (context));
+
+ BusInputContextPrivate *priv;
+ priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
+
+ return priv->enabled;
+}
+
const static struct {
const gchar *name;
GCallback callback;
@@ -1492,7 +1502,6 @@ void
bus_input_context_set_engine (BusInputContext *context,
BusEngineProxy *engine)
{
-
g_assert (BUS_IS_INPUT_CONTEXT (context));
BusInputContextPrivate *priv;
@@ -1517,12 +1526,29 @@ bus_input_context_set_engine (BusInputContext *context,
context);
}
bus_engine_proxy_set_cursor_location (priv->engine, priv->x, priv->y, priv->w, priv->h);
+ if (priv->enabled) {
+ bus_engine_proxy_enable (priv->engine);
+ if (priv->has_focus) {
+ bus_engine_proxy_focus_in (priv->engine);
+ }
+ }
}
g_signal_emit (context,
context_signals[ENGINE_CHANGED],
0);
}
+BusEngineProxy *
+bus_input_context_get_engine (BusInputContext *context)
+{
+ g_assert (BUS_IS_INPUT_CONTEXT (context));
+
+ BusInputContextPrivate *priv;
+ priv = BUS_INPUT_CONTEXT_GET_PRIVATE (context);
+
+ return priv->engine;
+}
+
static gboolean
bus_input_context_filter_keyboard_shortcuts (BusInputContext *context,
guint keyval,
@@ -1549,7 +1575,6 @@ bus_input_context_filter_keyboard_shortcuts (BusInputContext *context,
keyval,
modifiers,
0);
-
if (event == trigger) {
if (priv->engine == NULL) {
g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, NULL);
@@ -1569,9 +1594,17 @@ bus_input_context_filter_keyboard_shortcuts (BusInputContext *context,
return TRUE;
}
else if (event == next_factory) {
+ g_signal_emit (context, context_signals[REQUEST_NEXT_ENGINE], 0);
+ if (priv->engine && !priv->enabled) {
+ bus_input_context_enable (context);
+ }
return TRUE;
}
else if (event == prev_factory) {
+ g_signal_emit (context, context_signals[REQUEST_PREV_ENGINE], 0);
+ if (priv->engine && !priv->enabled) {
+ bus_input_context_enable (context);
+ }
return TRUE;
}
else
diff --git a/bus/inputcontext.h b/bus/inputcontext.h
index edebdc0..537cbef 100644
--- a/bus/inputcontext.h
+++ b/bus/inputcontext.h
@@ -61,18 +61,19 @@ struct _BusInputContextClass {
GType bus_input_context_get_type (void);
BusInputContext *bus_input_context_new (BusConnection *connection,
const gchar *client);
-gboolean bus_input_context_is_focus (BusInputContext *context);
void bus_input_context_focus_in (BusInputContext *context);
void bus_input_context_focus_out (BusInputContext *context);
-void bus_input_context_enable_or_disable(BusInputContext *context);
+gboolean bus_input_context_has_focus (BusInputContext *context);
void bus_input_context_enable (BusInputContext *context);
void bus_input_context_disable (BusInputContext *context);
+gboolean bus_input_context_is_enabled (BusInputContext *context);
void bus_input_context_page_up (BusInputContext *context);
void bus_input_context_page_down (BusInputContext *context);
void bus_input_context_cursor_up (BusInputContext *context);
void bus_input_context_cursor_down (BusInputContext *context);
void bus_input_context_set_engine (BusInputContext *context,
BusEngineProxy *factory);
+BusEngineProxy *bus_input_context_get_engine (BusInputContext *context);
void bus_input_context_property_activate(BusInputContext *context,
const gchar *prop_name,
gint prop_state);
diff --git a/bus/main.c b/bus/main.c
index 8757af5..7e53144 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -19,6 +19,8 @@
*/
#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
#include <stdlib.h>
#include <locale.h>
#include "server.h"
@@ -106,6 +108,19 @@ main (gint argc, gchar **argv)
exit (-1);
}
+ /* check uid */
+ {
+ gchar *username = ibus_get_user_name ();
+ uid_t uid = getuid ();
+ struct passwd *pwd = getpwuid (uid);
+
+ if (pwd == NULL || strcmp (pwd->pw_name, username) != 0) {
+ g_printerr ("Please run ibus-daemon with login user! Do not run ibus-daemon with sudo or su.\n");
+ exit (-1);
+ }
+ }
+
+ /* daemonize process */
if (daemonize) {
if (daemon (1, 0) != 0) {
g_printerr ("Can not daemonize ibus.\n");
diff --git a/bus/matchrule.c b/bus/matchrule.c
index 6bf75c5..f40147a 100644
--- a/bus/matchrule.c
+++ b/bus/matchrule.c
@@ -649,16 +649,15 @@ bus_match_rule_remove_recipient (BusMatchRule *rule,
g_warning ("Remove recipient failed");
}
-gboolean
+GList *
bus_match_rule_get_recipients (BusMatchRule *rule,
- DBusMessage *message,
- GList **recipients)
+ DBusMessage *message)
{
g_assert (BUS_IS_MATCH_RULE (rule));
g_assert (message != NULL);
- g_assert (recipients != NULL);
GList *link;
+ GList *recipients = NULL;
if (!bus_match_rule_match (rule, message))
return FALSE;
@@ -667,9 +666,9 @@ bus_match_rule_get_recipients (BusMatchRule *rule,
BusRecipient *recipient = (BusRecipient *) link->data;
g_object_ref (recipient->connection);
- *recipients = g_list_append (*recipients, recipient->connection);
+ recipients = g_list_append (recipients, recipient->connection);
}
- return TRUE;
+ return recipients;
}
diff --git a/bus/matchrule.h b/bus/matchrule.h
index b69825d..5a965a8 100644
--- a/bus/matchrule.h
+++ b/bus/matchrule.h
@@ -114,10 +114,9 @@ void bus_match_rule_add_recipient
void bus_match_rule_remove_recipient
(BusMatchRule *rule,
BusConnection *connection);
-gboolean bus_match_rule_get_recipients
+GList *bus_match_rule_get_recipients
(BusMatchRule *rule,
- DBusMessage *message,
- GList **recipients);
+ DBusMessage *message);
G_END_DECLS
#endif
diff --git a/bus/registry.c b/bus/registry.c
index 13e1cdf..65488da 100644
--- a/bus/registry.c
+++ b/bus/registry.c
@@ -20,6 +20,7 @@
#include <glib/gstdio.h>
#include <gio/gio.h>
#include <stdlib.h>
+#include <string.h>
#include "registry.h"
enum {
@@ -403,6 +404,33 @@ bus_registry_get_engines (BusRegistry *registry)
}
+GList *
+bus_registry_get_engines_by_language (BusRegistry *registry,
+ const gchar *language)
+{
+ g_assert (BUS_IS_REGISTRY (registry));
+ g_assert (language);
+
+ gint n;
+ GList *p1, *p2, *engines;
+
+ n = strlen (language);
+
+ p1 = bus_registry_get_engines (registry);
+
+ engines = NULL;
+
+ for (p2 = p1; p2 != NULL; p2 = p2->next) {
+ IBusEngineDesc *desc = (IBusEngineDesc *) p2->data;
+ if (strncmp (desc->language, language, n) == 0) {
+ engines = g_list_append (engines, desc);
+ }
+ }
+
+ g_list_free (p1);
+ return engines;
+}
+
IBusEngineDesc *
bus_registry_find_engine_by_name (BusRegistry *registry,
const gchar *name)
diff --git a/bus/registry.h b/bus/registry.h
index 377ac45..fb4078d 100644
--- a/bus/registry.h
+++ b/bus/registry.h
@@ -67,6 +67,9 @@ GType bus_registry_get_type (void);
BusRegistry *bus_registry_new (void);
GList *bus_registry_get_components (BusRegistry *registry);
GList *bus_registry_get_engines (BusRegistry *registry);
+GList *bus_registry_get_engines_by_language
+ (BusRegistry *registry,
+ const gchar *language);
void bus_registry_stop_all_components
(BusRegistry *registry);
diff --git a/bus/server.c b/bus/server.c
index 3a957db..7245bd3 100644
--- a/bus/server.c
+++ b/bus/server.c
@@ -17,10 +17,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
-
+#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <libgen.h>
+#include <stdlib.h>
#include "server.h"
#include "connection.h"
@@ -87,13 +87,21 @@ bus_server_listen (BusServer *server)
// const gchar *address = "unix:abstract=/tmp/ibus-c"
const gchar *address;
gchar *path;
+ gboolean retval;
path = g_strdup_printf("/tmp/ibus-%s", ibus_get_user_name ());
mkdir (path, 0775);
- g_free(path);
address = ibus_get_address ();
- return ibus_server_listen (IBUS_SERVER (server), address);
+ retval = ibus_server_listen (IBUS_SERVER (server), address);
+
+ if (!retval) {
+ g_printerr ("Can not listen on %s! Please try remove directory %s and run again.", address, path);
+ exit (-1);
+ }
+
+ g_free(path);
+ return retval;
}
void
@@ -128,8 +136,8 @@ static void
bus_server_init (BusServer *server)
{
server->loop = g_main_loop_new (NULL, FALSE);
- server->dbus = bus_dbus_impl_get_default ();
- server->ibus = bus_ibus_impl_get_default ();
+ server->dbus = bus_dbus_impl_get_default ();
+ server->ibus = bus_ibus_impl_get_default ();
}
static void