diff options
author | Eduardo Lima (Etrunko) <eduardo.lima@intel.com> | 2013-10-09 16:33:09 -0300 |
---|---|---|
committer | Eduardo Lima (Etrunko) <eduardo.lima@intel.com> | 2013-10-09 18:26:36 -0300 |
commit | abb645fc09405557eadb28d09912dc96510095a1 (patch) | |
tree | 256b8896fd1979d67bf84e3cc8b31063883ee891 | |
parent | f4fde198d49529b6380e55a6aa554a0a390088e9 (diff) | |
download | weekeyboard-abb645fc09405557eadb28d09912dc96510095a1.tar.gz weekeyboard-abb645fc09405557eadb28d09912dc96510095a1.tar.bz2 weekeyboard-abb645fc09405557eadb28d09912dc96510095a1.zip |
Fix query for IBus address
Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
-rw-r--r-- | src/wkb-ibus.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/wkb-ibus.c b/src/wkb-ibus.c index f4513c9..0573265 100644 --- a/src/wkb-ibus.c +++ b/src/wkb-ibus.c @@ -212,7 +212,7 @@ _wkb_ibus_query_address_cb(void *data, int type, void *event) if (strncmp(exe_data->data, "(null)", exe_data->size) == 0) { - INF("IBus daemon is not running."); + WRN("IBus daemon is not running."); _wkb_ibus_launch_daemon(); goto end; } @@ -224,30 +224,20 @@ _wkb_ibus_query_address_cb(void *data, int type, void *event) free(ctx->address); ctx->address = strndup(exe_data->data, exe_data->size); + DBG("Got IBus address: '%s'", ctx->address); end: - ecore_idler_add(ecore_exe_free, exe_data->exe); ctx->address_pending = EINA_FALSE; + ecore_idler_add((Ecore_Task_Cb) ecore_exe_free, exe_data->exe); return ECORE_CALLBACK_DONE; } - static void _wkb_ibus_query_address(void) { - const char *ibus_addr; Ecore_Exe *ibus_exec = NULL; - /* Check for IBUS_ADDRESS environment variable */ - if ((ibus_addr = getenv("IBUS_ADDRESS")) != NULL) - { - DBG("Got IBus address from IBUS_ADDRESS environment variable %s", ibus_addr); - ctx->address = strdup(ibus_addr); - return; - } - - /* Get IBus address by invoking 'ibus address' from command line */ - DBG("Querying IBus address from using 'ibus address' command"); + INF("Querying IBus address from 'ibus address' command"); ibus_exec = ecore_exe_pipe_run("ibus address", ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_READ_LINE_BUFFERED, @@ -266,16 +256,29 @@ Eina_Bool wkb_ibus_connect(void) { if (ctx->conn) - return EINA_TRUE; - - if (!ctx->address) { - INF("IBus address is not set."); - if (!ctx->address_pending) - _wkb_ibus_query_address(); + INF("Already connected to IBus"); + return EINA_TRUE; + } + if (ctx->address_pending) + { + INF("IBus address query in progress"); return EINA_FALSE; - } + } + + if (!ctx->address) + { + char *env_addr = getenv("IBUS_ADDRESS"); + if (!env_addr) + { + _wkb_ibus_query_address(); + return EINA_FALSE; + } + + DBG("Got IBus address from environment variable: '%s'", env_addr); + ctx->address = strdup(env_addr); + } INF("Connecting to IBus at address '%s'", ctx->address); ctx->conn = eldbus_address_connection_get(ctx->address); @@ -361,7 +364,6 @@ wkb_ibus_init(void) WKB_IBUS_CONNECTED = ecore_event_type_new(); WKB_IBUS_DISCONNECTED = ecore_event_type_new(); - _wkb_ibus_query_address(); end: return ++ctx->refcount; |