forked from enlightenment/efl
Remove Ecore Data
This requires ecore_imf_modules to change. Substitute imf_module_init in modules with EINA_MODULE_INIT(imf_module_init) and init Ecore_IMF_Context_Info here and then register with ecore_imf with ecore_imf_module_register Since it seems that there is no ecore_imf_modules in svn it is hard to test this change. SVN revision: 45604
This commit is contained in:
parent
03d9fb7b94
commit
52e7b442cb
|
@ -5,8 +5,6 @@
|
|||
#ifndef _ECORE_IMF_H
|
||||
#define _ECORE_IMF_H
|
||||
|
||||
#include <Ecore_Data.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
@ -294,6 +292,8 @@ extern "C" {
|
|||
EAPI int ecore_imf_init(void);
|
||||
EAPI int ecore_imf_shutdown(void);
|
||||
|
||||
EAPI void ecore_imf_module_register(const Ecore_IMF_Context_Info *info, Ecore_IMF_Context *(*imf_module_create)(void), Ecore_IMF_Context *(*imf_module_exit)(void));
|
||||
|
||||
EAPI Eina_List *ecore_imf_context_available_ids_get(void);
|
||||
EAPI Eina_List *ecore_imf_context_available_ids_by_canvas_type_get(const char *canvas_type);
|
||||
EAPI const char *ecore_imf_context_default_id_get(void);
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "Ecore_IMF.h"
|
||||
#include "ecore_imf_private.h"
|
||||
|
||||
static void _ecore_imf_module_load_all(void);
|
||||
static void _ecore_imf_module_append(Ecore_Plugin *plugin, const Ecore_IMF_Context_Info *info, Ecore_IMF_Context *(*imf_module_create)(void));
|
||||
static void _ecore_imf_module_free(Ecore_IMF_Module *module);
|
||||
static int _ecore_imf_modules_exists(const char *ctx_id);
|
||||
|
||||
|
@ -28,30 +26,22 @@ typedef struct _Ecore_IMF_Selector
|
|||
void *selected;
|
||||
} Ecore_IMF_Selector;
|
||||
|
||||
static Ecore_Path_Group *ecore_imf_modules_path = NULL;
|
||||
static Eina_Hash *modules = NULL;
|
||||
static Eina_Array *module_list = NULL;
|
||||
|
||||
void
|
||||
ecore_imf_module_init(void)
|
||||
{
|
||||
char pathname[PATH_MAX];
|
||||
const char *homedir;
|
||||
char *homedir;
|
||||
|
||||
ecore_imf_modules_path = ecore_path_group_new();
|
||||
snprintf(pathname, sizeof(pathname), "%s/ecore/immodules/",
|
||||
PACKAGE_LIB_DIR);
|
||||
ecore_path_group_add(ecore_imf_modules_path, pathname);
|
||||
|
||||
homedir = getenv("HOME");
|
||||
module_list = eina_module_list_get(NULL, PACKAGE_LIB_DIR "/ecore/immodules", 0, NULL, NULL);
|
||||
homedir = eina_module_environment_path_get("HOME", "/.ecore/immodules");
|
||||
if (homedir)
|
||||
{
|
||||
snprintf(pathname, sizeof(pathname), "%s/.ecore/immodules/",
|
||||
homedir);
|
||||
ecore_path_group_add(ecore_imf_modules_path, pathname);
|
||||
module_list = eina_module_list_get(module_list, homedir, 0, NULL, NULL);
|
||||
free(homedir);
|
||||
}
|
||||
|
||||
modules = NULL;
|
||||
_ecore_imf_module_load_all();
|
||||
eina_module_list_load(module_list);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -62,9 +52,11 @@ ecore_imf_module_shutdown(void)
|
|||
eina_hash_free(modules);
|
||||
modules = NULL;
|
||||
}
|
||||
|
||||
ecore_path_group_del(ecore_imf_modules_path);
|
||||
ecore_imf_modules_path = NULL;
|
||||
if (module_list)
|
||||
{
|
||||
eina_module_list_free(module_list);
|
||||
modules = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -77,7 +69,7 @@ _hash_module_available_get(const Eina_Hash *hash, int *data, void *list)
|
|||
Eina_List *
|
||||
ecore_imf_module_available_get(void)
|
||||
{
|
||||
Eina_List *values = NULL;
|
||||
Eina_List *values;
|
||||
Eina_Iterator *it = NULL;
|
||||
|
||||
if (!modules) return NULL;
|
||||
|
@ -182,77 +174,23 @@ ecore_imf_module_context_ids_by_canvas_type_get(const char *canvas_type)
|
|||
return values;
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_imf_module_load_all(void)
|
||||
{
|
||||
Eina_List *avail;
|
||||
char *filename;
|
||||
Ecore_Plugin *plugin;
|
||||
const Ecore_IMF_Context_Info *info = NULL;
|
||||
int (*imf_module_init)(const Ecore_IMF_Context_Info **info);
|
||||
Ecore_IMF_Context *(*imf_module_create)(void);
|
||||
|
||||
avail = ecore_plugin_available_get(ecore_imf_modules_path);
|
||||
if (!avail) return;
|
||||
|
||||
EINA_LIST_FREE(avail, filename)
|
||||
{
|
||||
plugin = ecore_plugin_load(ecore_imf_modules_path, filename, NULL);
|
||||
if (!plugin)
|
||||
{
|
||||
ERR("** Error loading input method plugin %s!",
|
||||
filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
imf_module_init = ecore_plugin_symbol_get(plugin, "imf_module_init");
|
||||
if (!imf_module_init || !imf_module_init(&info) || !info)
|
||||
{
|
||||
ERR("** Error initializing input method plugin %s! "
|
||||
"'imf_module_init' is missing or failed to run!",
|
||||
filename);
|
||||
ecore_plugin_unload(plugin);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_ecore_imf_modules_exists(info->id))
|
||||
{
|
||||
ERR("** ecore_imf: Error loading input method plugin %s! "
|
||||
"Plugin with id='%s' already exists!",
|
||||
filename, info->id);
|
||||
ecore_plugin_unload(plugin);
|
||||
continue;
|
||||
}
|
||||
|
||||
imf_module_create = ecore_plugin_symbol_get(plugin, "imf_module_create");
|
||||
if (!imf_module_create)
|
||||
{
|
||||
ERR("** ecore_imf: Error setting up input method plugin %s! "
|
||||
"'imf_module_create' is missing!",
|
||||
filename);
|
||||
ecore_plugin_unload(plugin);
|
||||
continue;
|
||||
}
|
||||
|
||||
_ecore_imf_module_append(plugin, info, imf_module_create);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_imf_module_append(Ecore_Plugin *plugin,
|
||||
const Ecore_IMF_Context_Info *info,
|
||||
Ecore_IMF_Context *(*imf_module_create)(void))
|
||||
EAPI void
|
||||
ecore_imf_module_register(const Ecore_IMF_Context_Info *info,
|
||||
Ecore_IMF_Context *(*imf_module_create)(void),
|
||||
Ecore_IMF_Context *(*imf_module_exit)(void))
|
||||
{
|
||||
Ecore_IMF_Module *module;
|
||||
|
||||
if (_ecore_imf_modules_exists(info->id)) return;
|
||||
|
||||
if (!modules)
|
||||
modules = eina_hash_string_superfast_new(EINA_FREE_CB(_ecore_imf_module_free));
|
||||
|
||||
module = malloc(sizeof(Ecore_IMF_Module));
|
||||
module->plugin = plugin;
|
||||
module->info = info;
|
||||
/* cache imf_module_create as it may be used several times */
|
||||
module->create = imf_module_create;
|
||||
module->exit = imf_module_exit;
|
||||
|
||||
eina_hash_add(modules, info->id, module);
|
||||
}
|
||||
|
@ -260,11 +198,7 @@ _ecore_imf_module_append(Ecore_Plugin *plugin,
|
|||
static void
|
||||
_ecore_imf_module_free(Ecore_IMF_Module *module)
|
||||
{
|
||||
int (*imf_module_exit)(void);
|
||||
|
||||
imf_module_exit = ecore_plugin_symbol_get(module->plugin, "imf_module_exit");
|
||||
if (imf_module_exit) imf_module_exit();
|
||||
ecore_plugin_unload(module->plugin);
|
||||
if (module->exit) module->exit();
|
||||
free(module);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ struct _Ecore_IMF_Context
|
|||
|
||||
struct _Ecore_IMF_Module
|
||||
{
|
||||
Ecore_Plugin *plugin;
|
||||
const Ecore_IMF_Context_Info *info;
|
||||
Ecore_IMF_Context *(*create)(void);
|
||||
Ecore_IMF_Context *(*exit)(void);
|
||||
};
|
||||
|
||||
void ecore_imf_module_init(void);
|
||||
|
|
Loading…
Reference in New Issue