2009-01-31 10:33:39 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2007-11-19 10:27:11 -08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-01-31 10:33:39 -08:00
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
2007-11-19 10:27:11 -08:00
|
|
|
|
2009-12-22 13:15:12 -08:00
|
|
|
#include <Ecore.h>
|
2009-03-10 15:44:36 -07:00
|
|
|
#include <ecore_private.h>
|
|
|
|
|
|
|
|
#include "Ecore_IMF.h"
|
2007-11-19 10:27:11 -08:00
|
|
|
#include "ecore_imf_private.h"
|
|
|
|
|
|
|
|
static void _ecore_imf_module_free(Ecore_IMF_Module *module);
|
|
|
|
static int _ecore_imf_modules_exists(const char *ctx_id);
|
|
|
|
|
2008-12-11 05:55:47 -08:00
|
|
|
typedef struct _Ecore_IMF_Selector
|
|
|
|
{
|
2011-04-11 04:31:55 -07:00
|
|
|
const char *toselect;
|
|
|
|
void *selected;
|
2008-12-11 05:55:47 -08:00
|
|
|
} Ecore_IMF_Selector;
|
|
|
|
|
|
|
|
static Eina_Hash *modules = NULL;
|
2010-01-26 14:22:14 -08:00
|
|
|
static Eina_Array *module_list = NULL;
|
2013-01-04 09:19:43 -08:00
|
|
|
static Eina_Prefix *pfx = NULL;
|
2007-11-19 10:27:11 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
ecore_imf_module_init(void)
|
|
|
|
{
|
2013-01-04 09:19:43 -08:00
|
|
|
char buf[PATH_MAX] = "";
|
2013-01-09 21:27:31 -08:00
|
|
|
char *path;
|
2007-11-19 10:27:11 -08:00
|
|
|
|
2013-01-04 09:19:43 -08:00
|
|
|
pfx = eina_prefix_new(NULL, ecore_imf_init,
|
|
|
|
"ECORE_IMF", "ecore_imf", "checkme",
|
|
|
|
PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
|
|
|
|
PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
|
|
|
|
|
|
|
|
if (getenv("EFL_RUN_IN_TREE"))
|
|
|
|
{
|
|
|
|
struct stat st;
|
2013-01-09 08:46:58 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/src/modules/ecore_imf",
|
2013-01-04 09:19:43 -08:00
|
|
|
PACKAGE_BUILD_DIR);
|
|
|
|
if (stat(buf, &st) == 0)
|
|
|
|
{
|
|
|
|
const char *built_modules[] = {
|
|
|
|
#ifdef ENABLE_XIM
|
|
|
|
"xim",
|
|
|
|
#endif
|
|
|
|
#ifdef BUILD_ECORE_IMF_IBUS
|
|
|
|
"ibus",
|
|
|
|
#endif
|
|
|
|
#ifdef BUILD_ECORE_IMF_SCIM
|
|
|
|
"scim",
|
|
|
|
#endif
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
const char **itr;
|
|
|
|
for (itr = built_modules; *itr != NULL; itr++)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf),
|
2013-01-09 08:46:58 -08:00
|
|
|
"%s/src/modules/ecore_imf/%s/.libs",
|
2013-01-04 09:19:43 -08:00
|
|
|
PACKAGE_BUILD_DIR, *itr);
|
|
|
|
module_list = eina_module_list_get(module_list, buf,
|
|
|
|
EINA_FALSE, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (module_list)
|
|
|
|
eina_module_list_load(module_list);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-09 21:27:31 -08:00
|
|
|
path = eina_module_environment_path_get("ECORE_IMF_MODULES_DIR",
|
|
|
|
"/ecore_imf/modules");
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
|
|
|
|
free(path);
|
|
|
|
}
|
2013-01-04 09:19:43 -08:00
|
|
|
|
2013-01-09 21:27:31 -08:00
|
|
|
path = eina_module_environment_path_get("HOME", "/.ecore_imf");
|
|
|
|
if (path)
|
2007-11-19 10:27:11 -08:00
|
|
|
{
|
2013-01-09 21:27:31 -08:00
|
|
|
module_list = eina_module_arch_list_get(module_list, path, MODULE_ARCH);
|
|
|
|
free(path);
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
2013-01-09 21:27:31 -08:00
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/ecore_imf/modules", eina_prefix_lib_get(pfx));
|
|
|
|
module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH);
|
|
|
|
|
2010-01-26 14:22:14 -08:00
|
|
|
eina_module_list_load(module_list);
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ecore_imf_module_shutdown(void)
|
|
|
|
{
|
|
|
|
if (modules)
|
|
|
|
{
|
2010-09-30 00:31:11 -07:00
|
|
|
eina_hash_free(modules);
|
|
|
|
modules = NULL;
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
2010-01-26 14:22:14 -08:00
|
|
|
if (module_list)
|
|
|
|
{
|
2010-09-30 00:31:11 -07:00
|
|
|
eina_module_list_free(module_list);
|
2011-10-23 05:01:36 -07:00
|
|
|
eina_array_free(module_list);
|
2010-09-30 00:31:11 -07:00
|
|
|
module_list = NULL;
|
2010-01-26 14:22:14 -08:00
|
|
|
}
|
2013-01-04 09:19:43 -08:00
|
|
|
|
|
|
|
eina_prefix_free(pfx);
|
|
|
|
pfx = NULL;
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
|
|
|
|
2008-12-11 05:55:47 -08:00
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_hash_module_available_get(const Eina_Hash *hash EINA_UNUSED, int *data, void *list)
|
2008-12-11 05:55:47 -08:00
|
|
|
{
|
2011-04-11 04:31:55 -07:00
|
|
|
*(Eina_List**)list = eina_list_append(*(Eina_List**)list, data);
|
|
|
|
return EINA_TRUE;
|
2008-12-11 05:55:47 -08:00
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *
|
2007-11-19 10:27:11 -08:00
|
|
|
ecore_imf_module_available_get(void)
|
|
|
|
{
|
2010-03-07 17:14:12 -08:00
|
|
|
Eina_List *values = NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
Eina_Iterator *it = NULL;
|
2007-11-19 10:27:11 -08:00
|
|
|
|
|
|
|
if (!modules) return NULL;
|
|
|
|
|
2008-12-11 05:55:47 -08:00
|
|
|
it = eina_hash_iterator_data_new(modules);
|
|
|
|
if (!it)
|
2011-04-11 04:31:55 -07:00
|
|
|
return NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
|
2010-08-11 07:32:30 -07:00
|
|
|
eina_iterator_foreach(it, EINA_EACH_CB(_hash_module_available_get), &values);
|
2008-12-11 05:55:47 -08:00
|
|
|
eina_iterator_free(it);
|
|
|
|
|
2007-11-19 10:27:11 -08:00
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ecore_IMF_Module *
|
|
|
|
ecore_imf_module_get(const char *ctx_id)
|
|
|
|
{
|
|
|
|
if (!modules) return NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
return eina_hash_find(modules, ctx_id);
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
Ecore_IMF_Context *
|
|
|
|
ecore_imf_module_context_create(const char *ctx_id)
|
|
|
|
{
|
|
|
|
Ecore_IMF_Module *module;
|
2007-11-21 14:20:16 -08:00
|
|
|
Ecore_IMF_Context *ctx = NULL;
|
2007-11-19 10:27:11 -08:00
|
|
|
|
|
|
|
if (!modules) return NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
module = eina_hash_find(modules, ctx_id);
|
2007-11-21 14:20:16 -08:00
|
|
|
if (module)
|
|
|
|
{
|
2010-09-30 00:31:11 -07:00
|
|
|
ctx = module->create();
|
|
|
|
if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
|
|
|
|
{
|
|
|
|
ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
|
|
|
|
"ecore_imf_module_context_create");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ctx->module = module;
|
2007-11-21 14:20:16 -08:00
|
|
|
}
|
|
|
|
return ctx;
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
|
|
|
|
2008-12-11 05:55:47 -08:00
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_hash_ids_get(const Eina_Hash *hash EINA_UNUSED, const char *key, void *list)
|
2008-12-11 05:55:47 -08:00
|
|
|
{
|
2011-04-11 04:31:55 -07:00
|
|
|
*(Eina_List**)list = eina_list_append(*(Eina_List**)list, key);
|
|
|
|
return EINA_TRUE;
|
2008-12-11 05:55:47 -08:00
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *
|
2007-11-19 10:27:11 -08:00
|
|
|
ecore_imf_module_context_ids_get(void)
|
|
|
|
{
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *l = NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
Eina_Iterator *it = NULL;
|
|
|
|
|
2007-11-19 10:27:11 -08:00
|
|
|
if (!modules) return NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
|
|
|
|
it = eina_hash_iterator_key_new(modules);
|
|
|
|
if (!it)
|
2011-04-11 04:31:55 -07:00
|
|
|
return NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
|
2010-08-11 07:32:30 -07:00
|
|
|
eina_iterator_foreach(it, EINA_EACH_CB(_hash_ids_get), &l);
|
2008-12-11 05:55:47 -08:00
|
|
|
eina_iterator_free(it);
|
|
|
|
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_hash_ids_by_canvas_type_get(const Eina_Hash *hash EINA_UNUSED, void *data, void *fdata)
|
2008-12-11 05:55:47 -08:00
|
|
|
{
|
|
|
|
Ecore_IMF_Module *module = data;
|
|
|
|
Ecore_IMF_Selector *selector = fdata;
|
|
|
|
|
|
|
|
if (!strcmp(module->info->canvas_type, selector->toselect))
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
selector->selected = eina_list_append(selector->selected, (void *)module->info->id);
|
2008-12-11 05:55:47 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
|
|
|
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *
|
2007-11-21 14:20:16 -08:00
|
|
|
ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type)
|
|
|
|
{
|
2008-12-11 05:55:47 -08:00
|
|
|
Ecore_IMF_Selector selector;
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
Eina_List *values = NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
Eina_Iterator *it = NULL;
|
2007-11-21 14:20:16 -08:00
|
|
|
|
|
|
|
if (!modules) return NULL;
|
|
|
|
|
|
|
|
if (!canvas_type)
|
|
|
|
return ecore_imf_module_context_ids_get();
|
|
|
|
|
2008-12-11 05:55:47 -08:00
|
|
|
it = eina_hash_iterator_data_new(modules);
|
|
|
|
if (!it)
|
2011-04-11 04:31:55 -07:00
|
|
|
return NULL;
|
2008-12-11 05:55:47 -08:00
|
|
|
|
|
|
|
selector.toselect = canvas_type;
|
|
|
|
selector.selected = values;
|
2010-08-11 07:32:30 -07:00
|
|
|
eina_iterator_foreach(it, EINA_EACH_CB(_hash_ids_by_canvas_type_get), &selector);
|
2008-12-11 05:55:47 -08:00
|
|
|
eina_iterator_free(it);
|
|
|
|
|
2007-11-21 14:20:16 -08:00
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
2010-01-26 14:22:14 -08:00
|
|
|
EAPI void
|
|
|
|
ecore_imf_module_register(const Ecore_IMF_Context_Info *info,
|
2010-09-30 00:31:11 -07:00
|
|
|
Ecore_IMF_Context *(*imf_module_create)(void),
|
|
|
|
Ecore_IMF_Context *(*imf_module_exit)(void))
|
2007-11-19 10:27:11 -08:00
|
|
|
{
|
|
|
|
Ecore_IMF_Module *module;
|
|
|
|
|
2010-01-26 14:22:14 -08:00
|
|
|
if (_ecore_imf_modules_exists(info->id)) return;
|
|
|
|
|
2007-11-19 10:27:11 -08:00
|
|
|
if (!modules)
|
* estickies,
* etk,
* PROTO/exalt,
* E-MODULES-EXTRA/diskio,
* E-MODULES-EXTRA/drawer,
* E-MODULES-EXTRA/penguins,
* E-MODULES-EXTRA/slideshow,
* E-MODULES-EXTRA/mail,
* E-MODULES-EXTRA/forecasts,
* E-MODULES-EXTRA/iiirk,
* E-MODULES-EXTRA/places,
* e,
* ewl,
* ecore,
* elitaire,
* entrance,
* e_dbus,
* efreet: Here we go, move from Ecore_List to Eina_List.
NOTE: This patch is huge, I did test it a lot, and I hope nothing is
broken. But if you think something change after this commit, please
contact me ASAP.
SVN revision: 39200
2009-02-25 03:03:47 -08:00
|
|
|
modules = eina_hash_string_superfast_new(EINA_FREE_CB(_ecore_imf_module_free));
|
2007-11-19 10:27:11 -08:00
|
|
|
|
|
|
|
module = malloc(sizeof(Ecore_IMF_Module));
|
|
|
|
module->info = info;
|
|
|
|
/* cache imf_module_create as it may be used several times */
|
|
|
|
module->create = imf_module_create;
|
2010-01-26 14:22:14 -08:00
|
|
|
module->exit = imf_module_exit;
|
2007-11-19 10:27:11 -08:00
|
|
|
|
2008-12-11 05:55:47 -08:00
|
|
|
eina_hash_add(modules, info->id, module);
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_imf_module_free(Ecore_IMF_Module *module)
|
|
|
|
{
|
2010-01-26 14:22:14 -08:00
|
|
|
if (module->exit) module->exit();
|
2007-11-19 10:27:11 -08:00
|
|
|
free(module);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_ecore_imf_modules_exists(const char *ctx_id)
|
|
|
|
{
|
|
|
|
if (!modules) return 0;
|
2008-12-11 05:55:47 -08:00
|
|
|
if (!ctx_id) return 0;
|
|
|
|
|
|
|
|
if (eina_hash_find(modules, ctx_id))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
2007-11-19 10:27:11 -08:00
|
|
|
}
|