2004-11-24 19:37:45 -08:00
|
|
|
#include "e.h"
|
2005-10-06 11:49:53 -07:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* TODO List:
|
2012-06-20 23:19:43 -07:00
|
|
|
*
|
2004-11-24 19:37:45 -08:00
|
|
|
* * add module types/classes
|
2010-09-08 16:59:07 -07:00
|
|
|
* * add list of exclusions that a module can't work withApi
|
2012-06-20 23:19:43 -07:00
|
|
|
*
|
2004-11-24 19:37:45 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
2012-07-02 03:35:16 -07:00
|
|
|
static void _e_module_free(E_Module *m);
|
|
|
|
static void _e_module_dialog_disable_show(const char *title, const char *body, E_Module *m);
|
|
|
|
static void _e_module_cb_dialog_disable(void *data, E_Dialog *dia);
|
|
|
|
static void _e_module_event_update_free(void *data, void *event);
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool _e_module_cb_idler(void *data);
|
2012-07-02 03:35:16 -07:00
|
|
|
static int _e_module_sort_priority(const void *d1, const void *d2);
|
2012-10-16 03:42:01 -07:00
|
|
|
static void _e_module_whitelist_check(void);
|
2013-01-15 07:33:39 -08:00
|
|
|
static Eina_Bool _e_module_desktop_list_cb(const Eina_Hash *hash EINA_UNUSED, const void *key, void *data, void *fdata);
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* local subsystem globals */
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *_e_modules = NULL;
|
2013-01-15 07:33:39 -08:00
|
|
|
static Eina_Hash *_e_modules_hash = NULL;
|
2012-07-26 01:38:32 -07:00
|
|
|
static Ecore_Idle_Enterer *_e_module_idler = NULL;
|
2008-10-22 04:49:33 -07:00
|
|
|
static Eina_List *_e_modules_delayed = NULL;
|
2012-10-16 03:42:01 -07:00
|
|
|
static Eina_Bool _e_modules_initting = EINA_FALSE;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2013-01-15 07:33:39 -08:00
|
|
|
static Eina_List *_e_module_path_monitors = NULL;
|
|
|
|
static Eina_List *_e_module_path_lists = NULL;
|
|
|
|
static Eina_List *handlers = NULL;
|
|
|
|
static Eina_Hash *_e_module_path_hash = NULL;
|
|
|
|
|
2007-07-15 19:15:37 -07:00
|
|
|
EAPI int E_EVENT_MODULE_UPDATE = 0;
|
2009-09-21 13:36:35 -07:00
|
|
|
EAPI int E_EVENT_MODULE_INIT_END = 0;
|
2007-07-15 19:15:37 -07:00
|
|
|
|
2013-01-15 07:33:39 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_module_filter_cb(void *d EINA_UNUSED, Eio_File *ls EINA_UNUSED, const Eina_File_Direct_Info *info)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
if (lstat(info->path, &st)) return EINA_FALSE;
|
|
|
|
return (info->path[info->name_start] != '.');
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s/module.so", info->path, MODULE_ARCH);
|
|
|
|
return ecore_file_exists(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_module_main_cb(void *d EINA_UNUSED, Eio_File *ls EINA_UNUSED, const Eina_File_Direct_Info *info)
|
|
|
|
{
|
|
|
|
Eina_Stringshare *s;
|
|
|
|
|
|
|
|
s = eina_hash_set(_e_module_path_hash, info->path + info->name_start, eina_stringshare_add(info->path));
|
|
|
|
if (!s) return;
|
|
|
|
WRN("REPLACING DUPLICATE MODULE PATH: %s -> %s", s, info->path);
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_module_done_cb(void *d EINA_UNUSED, Eio_File *ls)
|
|
|
|
{
|
|
|
|
_e_module_path_lists = eina_list_remove(_e_module_path_lists, ls);
|
|
|
|
if (_e_module_path_lists) return;
|
|
|
|
if (_e_modules_initting) e_module_all_load();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_module_error_cb(void *d EINA_UNUSED, Eio_File *ls, int error EINA_UNUSED)
|
|
|
|
{
|
|
|
|
_e_module_path_lists = eina_list_remove(_e_module_path_lists, ls);
|
|
|
|
if (_e_module_path_lists) return;
|
|
|
|
if (_e_modules_initting) e_module_all_load();
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_module_monitor_dir_create(void *d EINA_UNUSED, int type EINA_UNUSED, Eio_Monitor_Event *ev)
|
|
|
|
{
|
|
|
|
Eina_Stringshare *s;
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
path = ecore_file_file_get(ev->filename);
|
|
|
|
s = eina_hash_set(_e_module_path_hash, path, eina_stringshare_ref(ev->filename));
|
|
|
|
if (s && (s != ev->filename))
|
|
|
|
WRN("REPLACING DUPLICATE MODULE PATH: %s -> %s", s, ev->filename);
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_module_monitor_dir_del(void *d EINA_UNUSED, int type EINA_UNUSED, Eio_Monitor_Event *ev)
|
|
|
|
{
|
|
|
|
Eina_Stringshare *s;
|
|
|
|
const char *path;
|
|
|
|
|
|
|
|
path = ecore_file_file_get(ev->filename);
|
|
|
|
s = eina_hash_find(_e_module_path_hash, path);
|
|
|
|
if (s == ev->filename)
|
|
|
|
eina_hash_del_by_key(_e_module_path_hash, path);
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_module_monitor_error(void *d EINA_UNUSED, int type EINA_UNUSED, Eio_Monitor_Error *ev)
|
|
|
|
{
|
|
|
|
_e_module_path_monitors = eina_list_remove(_e_module_path_monitors, ev->monitor);
|
|
|
|
eio_monitor_del(ev->monitor);
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* externally accessible functions */
|
2010-11-22 07:21:32 -08:00
|
|
|
EINTERN int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_init(void)
|
2006-07-30 12:34:05 -07:00
|
|
|
{
|
2013-01-15 07:33:39 -08:00
|
|
|
Eina_List *module_paths;
|
|
|
|
E_Path_Dir *epd;
|
|
|
|
|
2007-07-15 19:15:37 -07:00
|
|
|
E_EVENT_MODULE_UPDATE = ecore_event_type_new();
|
2009-09-21 13:36:35 -07:00
|
|
|
E_EVENT_MODULE_INIT_END = ecore_event_type_new();
|
2013-01-15 07:33:39 -08:00
|
|
|
_e_module_path_hash = eina_hash_string_superfast_new((Eina_Free_Cb)eina_stringshare_del);
|
|
|
|
_e_modules_hash = eina_hash_string_superfast_new(NULL);
|
|
|
|
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, EIO_MONITOR_DIRECTORY_CREATED, _module_monitor_dir_create, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, EIO_MONITOR_DIRECTORY_DELETED, _module_monitor_dir_del, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, EIO_MONITOR_ERROR, _module_monitor_error, NULL);
|
|
|
|
|
|
|
|
module_paths = e_path_dir_list_get(path_modules);
|
|
|
|
EINA_LIST_FREE(module_paths, epd)
|
|
|
|
{
|
|
|
|
Eio_Monitor *mon;
|
|
|
|
Eio_File *ls;
|
|
|
|
|
|
|
|
mon = eio_monitor_stringshared_add(epd->dir);
|
|
|
|
ls = eio_file_direct_ls(epd->dir, _module_filter_cb, _module_main_cb, _module_done_cb, _module_error_cb, NULL);
|
|
|
|
_e_module_path_monitors = eina_list_append(_e_module_path_monitors, mon);
|
|
|
|
_e_module_path_lists = eina_list_append(_e_module_path_lists, ls);
|
|
|
|
eina_stringshare_del(epd->dir);
|
|
|
|
free(epd);
|
|
|
|
}
|
|
|
|
|
2006-07-30 12:34:05 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-11-22 07:21:32 -08:00
|
|
|
EINTERN int
|
2006-07-30 12:34:05 -07:00
|
|
|
e_module_shutdown(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
|
|
|
E_Module *m;
|
2012-06-20 23:19:43 -07:00
|
|
|
|
2006-07-30 12:34:05 -07:00
|
|
|
#ifdef HAVE_VALGRIND
|
|
|
|
/* do a leak check now before we dlclose() all those plugins, cause
|
|
|
|
* that means we won't get a decent backtrace to leaks in there
|
|
|
|
*/
|
|
|
|
VALGRIND_DO_LEAK_CHECK
|
|
|
|
#endif
|
2008-05-18 21:37:34 -07:00
|
|
|
|
2009-09-04 13:26:25 -07:00
|
|
|
/* do not use EINA_LIST_FREE! e_object_del modifies list */
|
2011-02-15 21:20:13 -08:00
|
|
|
if (x_fatal)
|
2012-07-02 03:35:16 -07:00
|
|
|
e_module_save_all();
|
2011-02-15 21:20:13 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
while (_e_modules)
|
|
|
|
{
|
|
|
|
m = _e_modules->data;
|
|
|
|
if ((m) && (m->enabled) && !(m->error))
|
|
|
|
{
|
2013-01-10 03:31:17 -08:00
|
|
|
if (m->func.save) m->func.save(m);
|
|
|
|
if (m->func.shutdown) m->func.shutdown(m);
|
2011-02-15 21:20:13 -08:00
|
|
|
m->enabled = 0;
|
|
|
|
}
|
|
|
|
e_object_del(E_OBJECT(m));
|
|
|
|
}
|
2008-03-04 03:48:39 -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
|
|
|
|
2013-01-15 07:33:39 -08:00
|
|
|
E_FN_DEL(eina_hash_free, _e_module_path_hash);
|
|
|
|
E_FN_DEL(eina_hash_free, _e_modules_hash);
|
|
|
|
E_FREE_LIST(handlers, ecore_event_handler_del);
|
|
|
|
E_FREE_LIST(_e_module_path_monitors, eio_monitor_del);
|
|
|
|
E_FREE_LIST(_e_module_path_lists, eio_file_cancel);
|
|
|
|
|
2006-07-30 12:34:05 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_module_all_load(void)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2013-01-10 00:28:50 -08:00
|
|
|
Eina_List *l, *ll;
|
2008-12-17 07:33:43 -08:00
|
|
|
E_Config_Module *em;
|
2010-04-26 09:31:33 -07:00
|
|
|
char buf[128];
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2012-10-16 03:42:01 -07:00
|
|
|
_e_modules_initting = EINA_TRUE;
|
2013-01-15 07:33:39 -08:00
|
|
|
if (_e_module_path_lists) return;
|
2013-01-11 02:34:29 -08:00
|
|
|
|
2012-06-20 23:19:43 -07:00
|
|
|
e_config->modules =
|
2010-04-26 14:50:53 -07:00
|
|
|
eina_list_sort(e_config->modules, 0, _e_module_sort_priority);
|
|
|
|
|
2013-01-10 00:28:50 -08:00
|
|
|
EINA_LIST_FOREACH_SAFE(e_config->modules, l, ll, em)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
if (!em) continue;
|
2013-01-10 02:03:10 -08:00
|
|
|
if (!e_util_strcasecmp(em->name, "comp"))
|
2013-01-10 00:28:50 -08:00
|
|
|
{
|
|
|
|
e_config->modules = eina_list_remove_list(e_config->modules, l);
|
|
|
|
eina_stringshare_del(em->name);
|
|
|
|
free(em);
|
|
|
|
continue;
|
|
|
|
}
|
2012-10-07 03:01:14 -07:00
|
|
|
if ((em->delayed) && (em->enabled) & (!e_config->no_module_delay))
|
2012-07-02 03:35:16 -07:00
|
|
|
{
|
|
|
|
if (!_e_module_idler)
|
2012-07-26 01:38:32 -07:00
|
|
|
_e_module_idler = ecore_idle_enterer_add(_e_module_cb_idler, NULL);
|
2012-07-02 03:35:16 -07:00
|
|
|
_e_modules_delayed =
|
|
|
|
eina_list_append(_e_modules_delayed,
|
|
|
|
eina_stringshare_add(em->name));
|
|
|
|
}
|
|
|
|
else if (em->enabled)
|
|
|
|
{
|
|
|
|
E_Module *m;
|
|
|
|
|
|
|
|
if (!em->name) continue;
|
|
|
|
|
|
|
|
e_util_env_set("E_MODULE_LOAD", em->name);
|
|
|
|
snprintf(buf, sizeof(buf), _("Loading Module: %s"), em->name);
|
|
|
|
e_init_status_set(buf);
|
|
|
|
|
|
|
|
m = e_module_new(em->name);
|
|
|
|
if (m) e_module_enable(m);
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2010-04-26 14:50:53 -07:00
|
|
|
|
2009-09-21 13:36:35 -07:00
|
|
|
if (!_e_modules_delayed)
|
2012-10-16 03:42:01 -07:00
|
|
|
{
|
|
|
|
ecore_event_add(E_EVENT_MODULE_INIT_END, NULL, NULL, NULL);
|
|
|
|
_e_modules_initting = EINA_FALSE;
|
|
|
|
_e_module_whitelist_check();
|
|
|
|
}
|
2010-04-26 14:50:53 -07:00
|
|
|
|
2010-04-26 09:31:33 -07:00
|
|
|
unsetenv("E_MODULE_LOAD");
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2012-12-11 02:30:06 -08:00
|
|
|
EAPI Eina_Bool
|
|
|
|
e_module_loading_get(void)
|
|
|
|
{
|
|
|
|
return _e_modules_initting;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_Module *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_module_new(const char *name)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
E_Module *m;
|
2010-04-26 14:50:53 -07:00
|
|
|
char buf[PATH_MAX];
|
2012-08-22 00:02:41 -07:00
|
|
|
char body[4096], title[1024];
|
2012-10-04 16:27:01 -07:00
|
|
|
const char *modpath = NULL;
|
2006-03-02 04:03:48 -08:00
|
|
|
char *s;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Config_Module *em;
|
2004-12-05 01:34:59 -08:00
|
|
|
int in_list = 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
if (!name) return NULL;
|
2013-01-10 02:03:10 -08:00
|
|
|
if (!e_util_strcasecmp(name, "comp"))
|
2013-01-10 00:14:15 -08:00
|
|
|
{
|
|
|
|
e_util_dialog_show(_("Module Error"),
|
|
|
|
_("The composite module cannot be loaded;"
|
|
|
|
"Enlightenment is already composited."));
|
|
|
|
ERR("USER TRIED TO LOAD EXTERNAL COMP MODULE! MY TEARS FLOW LIKE VICTORIA FALLS!");
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-01-21 22:58:34 -08:00
|
|
|
m = E_OBJECT_ALLOC(E_Module, E_MODULE_TYPE, _e_module_free);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (name[0] != '/')
|
|
|
|
{
|
2013-01-15 07:33:39 -08:00
|
|
|
Eina_Stringshare *path;
|
|
|
|
|
|
|
|
path = eina_hash_find(_e_module_path_hash, name);
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s/module.so", path, MODULE_ARCH);
|
|
|
|
modpath = eina_stringshare_add(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s/module.so", name, MODULE_ARCH);
|
|
|
|
modpath = e_path_find(path_modules, buf);
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2012-10-01 00:30:06 -07:00
|
|
|
else if (eina_str_has_extension(name, ".so"))
|
2008-10-15 08:12:56 -07:00
|
|
|
modpath = eina_stringshare_add(name);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (!modpath)
|
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
snprintf(body, sizeof(body),
|
2012-11-30 07:39:17 -08:00
|
|
|
_("There was an error loading the module named: %s<br>"
|
2012-07-02 03:35:16 -07:00
|
|
|
"No module named %s could be found in the<br>"
|
|
|
|
"module search directories.<br>"), name, buf);
|
|
|
|
_e_module_dialog_disable_show(_("Error loading Module"), body, m);
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2011-07-23 11:10:11 -07:00
|
|
|
m->handle = dlopen(modpath, (RTLD_NOW | RTLD_GLOBAL));
|
2004-11-24 19:37:45 -08:00
|
|
|
if (!m->handle)
|
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
snprintf(body, sizeof(body),
|
2012-11-30 07:39:17 -08:00
|
|
|
_("There was an error loading the module named: %s<br>"
|
2012-07-02 03:35:16 -07:00
|
|
|
"The full path to this module is:<br>"
|
|
|
|
"%s<br>"
|
|
|
|
"The error reported was:<br>"
|
|
|
|
"%s<br>"), name, buf, dlerror());
|
|
|
|
_e_module_dialog_disable_show(_("Error loading Module"), body, m);
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-09-24 06:42:05 -07:00
|
|
|
m->api = dlsym(m->handle, "e_modapi");
|
2005-04-11 20:34:31 -07:00
|
|
|
m->func.init = dlsym(m->handle, "e_modapi_init");
|
|
|
|
m->func.shutdown = dlsym(m->handle, "e_modapi_shutdown");
|
|
|
|
m->func.save = dlsym(m->handle, "e_modapi_save");
|
2005-12-17 03:21:54 -08:00
|
|
|
|
2013-01-10 03:31:17 -08:00
|
|
|
if ((!m->func.init) || (!m->api))
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
snprintf(body, sizeof(body),
|
2012-11-30 07:39:17 -08:00
|
|
|
_("There was an error loading the module named: %s<br>"
|
2012-07-02 03:35:16 -07:00
|
|
|
"The full path to this module is:<br>"
|
|
|
|
"%s<br>"
|
|
|
|
"The error reported was:<br>"
|
|
|
|
"%s<br>"),
|
|
|
|
name, buf, _("Module does not contain all needed functions"));
|
|
|
|
_e_module_dialog_disable_show(_("Error loading Module"), body, m);
|
|
|
|
m->api = NULL;
|
|
|
|
m->func.init = NULL;
|
|
|
|
m->func.shutdown = NULL;
|
|
|
|
m->func.save = NULL;
|
|
|
|
|
|
|
|
dlclose(m->handle);
|
|
|
|
m->handle = NULL;
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-09-23 10:13:47 -07:00
|
|
|
if (m->api->version < E_MODULE_API_VERSION)
|
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
snprintf(body, sizeof(body),
|
|
|
|
_("Module API Error<br>Error initializing Module: %s<br>"
|
|
|
|
"It requires a minimum module API version of: %i.<br>"
|
|
|
|
"The module API advertized by Enlightenment is: %i.<br>"),
|
|
|
|
_(m->api->name), m->api->version, E_MODULE_API_VERSION);
|
|
|
|
|
|
|
|
snprintf(title, sizeof(title), _("Enlightenment %s Module"),
|
|
|
|
_(m->api->name));
|
|
|
|
|
|
|
|
_e_module_dialog_disable_show(title, body, m);
|
|
|
|
m->api = NULL;
|
|
|
|
m->func.init = NULL;
|
|
|
|
m->func.shutdown = NULL;
|
|
|
|
m->func.save = NULL;
|
|
|
|
dlclose(m->handle);
|
|
|
|
m->handle = NULL;
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2005-09-23 10:13:47 -07:00
|
|
|
}
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
init_done:
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_modules = eina_list_append(_e_modules, m);
|
2013-01-15 07:33:39 -08:00
|
|
|
eina_hash_add(_e_modules_hash, name, m);
|
2008-10-15 08:12:56 -07:00
|
|
|
m->name = eina_stringshare_add(name);
|
2005-12-04 04:03:59 -08:00
|
|
|
if (modpath)
|
2005-02-07 19:51:08 -08:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
s = ecore_file_dir_get(modpath);
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
char *s2;
|
|
|
|
|
|
|
|
s2 = ecore_file_dir_get(s);
|
|
|
|
free(s);
|
|
|
|
if (s2)
|
|
|
|
{
|
|
|
|
m->dir = eina_stringshare_add(s2);
|
|
|
|
free(s2);
|
|
|
|
}
|
|
|
|
}
|
2005-02-07 19:51:08 -08:00
|
|
|
}
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(e_config->modules, l, em)
|
2004-12-05 01:34:59 -08:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
if (!em) continue;
|
2012-08-24 06:00:28 -07:00
|
|
|
if (em->name == m->name)
|
2012-07-02 03:35:16 -07:00
|
|
|
{
|
|
|
|
in_list = 1;
|
|
|
|
break;
|
|
|
|
}
|
2004-12-05 01:34:59 -08:00
|
|
|
}
|
|
|
|
if (!in_list)
|
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
E_Config_Module *module;
|
2009-04-20 19:07:06 -07:00
|
|
|
|
2012-07-02 03:35:16 -07:00
|
|
|
module = E_NEW(E_Config_Module, 1);
|
|
|
|
module->name = eina_stringshare_add(m->name);
|
|
|
|
module->enabled = 0;
|
|
|
|
e_config->modules = eina_list_append(e_config->modules, module);
|
|
|
|
e_config_save_queue();
|
2004-12-05 01:34:59 -08:00
|
|
|
}
|
2008-10-15 08:12:56 -07:00
|
|
|
if (modpath) eina_stringshare_del(modpath);
|
2004-11-24 19:37:45 -08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_save(E_Module *m)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((!m->enabled) || (m->error)) return 0;
|
2013-01-10 03:31:17 -08:00
|
|
|
return m->func.save ? m->func.save(m) : 1;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI const char *
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_dir_get(E_Module *m)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(m, NULL);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2004-11-24 19:37:45 -08:00
|
|
|
return m->dir;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_enable(E_Module *m)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2007-07-15 19:15:37 -07:00
|
|
|
E_Event_Module_Update *ev;
|
2008-12-17 07:33:43 -08:00
|
|
|
E_Config_Module *em;
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((m->enabled) || (m->error)) return 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
m->data = m->func.init(m);
|
2005-10-31 18:41:58 -08:00
|
|
|
if (m->data)
|
2004-12-05 01:34:59 -08:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
m->enabled = 1;
|
|
|
|
EINA_LIST_FOREACH(e_config->modules, l, em)
|
|
|
|
{
|
|
|
|
if (!em) continue;
|
|
|
|
if (!e_util_strcmp(em->name, m->name))
|
|
|
|
{
|
|
|
|
em->enabled = 1;
|
|
|
|
e_config_save_queue();
|
|
|
|
|
|
|
|
ev = E_NEW(E_Event_Module_Update, 1);
|
2012-11-26 02:30:00 -08:00
|
|
|
ev->name = eina_stringshare_ref(em->name);
|
2012-07-02 03:35:16 -07:00
|
|
|
ev->enabled = 1;
|
|
|
|
ecore_event_add(E_EVENT_MODULE_UPDATE, ev,
|
|
|
|
_e_module_event_update_free, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-10-16 03:42:01 -07:00
|
|
|
if (!_e_modules_initting)
|
|
|
|
_e_module_whitelist_check();
|
2012-07-02 03:35:16 -07:00
|
|
|
return 1;
|
2004-12-05 01:34:59 -08:00
|
|
|
}
|
2005-10-31 18:41:58 -08:00
|
|
|
return 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_disable(E_Module *m)
|
|
|
|
{
|
2007-07-15 19:15:37 -07:00
|
|
|
E_Event_Module_Update *ev;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2008-12-17 07:33:43 -08:00
|
|
|
E_Config_Module *em;
|
2004-11-24 19:37:45 -08:00
|
|
|
int ret;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((!m->enabled) || (m->error)) return 0;
|
2013-01-10 03:31:17 -08:00
|
|
|
ret = m->func.shutdown ? m->func.shutdown(m) : 1;
|
2004-11-24 19:37:45 -08:00
|
|
|
m->data = NULL;
|
|
|
|
m->enabled = 0;
|
2008-12-17 07:33:43 -08:00
|
|
|
EINA_LIST_FOREACH(e_config->modules, l, em)
|
2004-12-05 01:34:59 -08:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
if (!em) continue;
|
|
|
|
if (!e_util_strcmp(em->name, m->name))
|
|
|
|
{
|
|
|
|
em->enabled = 0;
|
|
|
|
e_config_save_queue();
|
|
|
|
|
|
|
|
ev = E_NEW(E_Event_Module_Update, 1);
|
2012-11-26 02:30:00 -08:00
|
|
|
ev->name = eina_stringshare_ref(em->name);
|
2012-07-02 03:35:16 -07:00
|
|
|
ev->enabled = 0;
|
|
|
|
ecore_event_add(E_EVENT_MODULE_UPDATE, ev,
|
|
|
|
_e_module_event_update_free, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2004-12-05 01:34:59 -08:00
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_enabled_get(E_Module *m)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2004-11-24 19:37:45 -08:00
|
|
|
return m->enabled;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI int
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_save_all(void)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2008-12-17 07:33:43 -08:00
|
|
|
E_Module *m;
|
2004-11-24 19:37:45 -08:00
|
|
|
int ret = 1;
|
2008-12-17 07:33:43 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_e_modules, l, m)
|
2013-01-15 07:33:39 -08:00
|
|
|
{
|
|
|
|
e_object_ref(E_OBJECT(m));
|
|
|
|
if ((m->enabled) && (!m->error))
|
|
|
|
{
|
|
|
|
if (m->func.save && (!m->func.save(m))) ret = 0;
|
|
|
|
}
|
|
|
|
e_object_unref(E_OBJECT(m));
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI E_Module *
|
2006-03-02 04:03:48 -08:00
|
|
|
e_module_find(const char *name)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2013-01-15 07:33:39 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
|
|
|
|
return eina_hash_find(_e_modules_hash, name);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
2008-10-22 04:49:33 -07:00
|
|
|
EAPI Eina_List *
|
2004-11-24 19:37:45 -08:00
|
|
|
e_module_list(void)
|
|
|
|
{
|
|
|
|
return _e_modules;
|
|
|
|
}
|
|
|
|
|
2006-01-07 02:39:46 -08:00
|
|
|
EAPI void
|
2006-07-02 11:55:33 -07:00
|
|
|
e_module_dialog_show(E_Module *m, const char *title, const char *body)
|
2005-09-24 06:42:05 -07:00
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
2006-07-02 11:55:33 -07:00
|
|
|
E_Border *bd;
|
2007-03-24 02:27:40 -07:00
|
|
|
char buf[PATH_MAX];
|
2010-11-09 12:15:55 -08:00
|
|
|
const char *icon = NULL;
|
2005-09-24 06:42:05 -07:00
|
|
|
|
2012-06-20 23:19:43 -07:00
|
|
|
dia = e_dialog_new(e_container_current_get(e_manager_current_get()),
|
2012-07-02 03:35:16 -07:00
|
|
|
"E", "_module_dialog");
|
2005-09-24 06:42:05 -07:00
|
|
|
if (!dia) return;
|
|
|
|
|
|
|
|
e_dialog_title_set(dia, title);
|
2006-09-02 02:19:19 -07:00
|
|
|
if (m)
|
2006-07-02 12:34:51 -07:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
Efreet_Desktop *desktop;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/module.desktop", e_module_dir_get(m));
|
|
|
|
|
|
|
|
desktop = efreet_desktop_new(buf);
|
|
|
|
if ((desktop) && (desktop->icon))
|
|
|
|
{
|
|
|
|
icon = efreet_icon_path_find(e_config->icon_theme, desktop->icon, 64);
|
|
|
|
if (!icon)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/%s.edj",
|
|
|
|
e_module_dir_get(m), desktop->icon);
|
2010-11-09 12:15:55 -08:00
|
|
|
dia->icon_object = e_util_icon_add(buf, e_win_evas_get(dia->win));
|
2012-07-02 03:35:16 -07:00
|
|
|
}
|
2010-11-09 12:15:55 -08:00
|
|
|
else
|
|
|
|
dia->icon_object = e_util_icon_add(icon, e_win_evas_get(dia->win));
|
2012-07-02 03:35:16 -07:00
|
|
|
edje_extern_object_min_size_set(dia->icon_object, 64, 64);
|
|
|
|
edje_object_part_swallow(dia->bg_object, "e.swallow.icon", dia->icon_object);
|
|
|
|
evas_object_show(dia->icon_object);
|
|
|
|
}
|
|
|
|
if (desktop) efreet_desktop_free(desktop);
|
2006-07-02 12:34:51 -07:00
|
|
|
}
|
2006-07-02 12:25:34 -07:00
|
|
|
else
|
2009-03-04 18:39:50 -08:00
|
|
|
e_dialog_icon_set(dia, "preferences-plugin", 64);
|
2010-04-26 14:50:53 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
e_dialog_text_set(dia, body);
|
2005-10-05 09:44:41 -07:00
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
|
|
|
|
e_dialog_button_focus_num(dia, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
2006-07-02 12:25:34 -07:00
|
|
|
if (!m) return;
|
2006-07-02 11:55:33 -07:00
|
|
|
bd = dia->win->border;
|
|
|
|
if (!bd) return;
|
2008-10-15 08:12:56 -07:00
|
|
|
bd->internal_icon = eina_stringshare_add(icon);
|
2005-09-24 06:42:05 -07:00
|
|
|
}
|
|
|
|
|
2007-07-29 03:24:56 -07:00
|
|
|
EAPI void
|
|
|
|
e_module_delayed_set(E_Module *m, int delayed)
|
|
|
|
{
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Config_Module *em;
|
2010-04-26 14:50:53 -07:00
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(e_config->modules, l, em)
|
2007-07-29 03:24:56 -07:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
if (!em) continue;
|
|
|
|
if (!e_util_strcmp(m->name, em->name))
|
|
|
|
{
|
|
|
|
if (em->delayed != delayed)
|
|
|
|
{
|
|
|
|
em->delayed = delayed;
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-07-29 03:24:56 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-18 21:37:34 -07:00
|
|
|
EAPI void
|
|
|
|
e_module_priority_set(E_Module *m, int priority)
|
|
|
|
{
|
|
|
|
/* Set the loading order for a module.
|
|
|
|
More priority means load earlier */
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2009-08-21 08:08:49 -07:00
|
|
|
E_Config_Module *em;
|
2009-04-20 19:07:06 -07:00
|
|
|
|
2009-08-21 08:08:49 -07:00
|
|
|
EINA_LIST_FOREACH(e_config->modules, l, em)
|
2008-05-18 21:37:34 -07:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
if (!em) continue;
|
|
|
|
if (!e_util_strcmp(m->name, em->name))
|
|
|
|
{
|
|
|
|
if (em->priority != priority)
|
|
|
|
{
|
|
|
|
em->priority = priority;
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-05-18 21:37:34 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-15 07:33:39 -08:00
|
|
|
EAPI Eina_List *
|
|
|
|
e_module_desktop_list(void)
|
|
|
|
{
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
|
|
|
|
eina_hash_foreach(_e_module_path_hash, _e_module_desktop_list_cb, &l);
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
e_module_desktop_free(E_Module_Desktop *md)
|
|
|
|
{
|
|
|
|
if (!md) return;
|
|
|
|
eina_stringshare_del(md->dir);
|
|
|
|
efreet_desktop_free(md->desktop);
|
|
|
|
free(md);
|
|
|
|
}
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* local subsystem functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_module_free(E_Module *m)
|
|
|
|
{
|
* 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
|
|
|
E_Config_Module *em;
|
2008-10-22 04:49:33 -07:00
|
|
|
Eina_List *l;
|
2010-04-26 14:50:53 -07: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_FOREACH(e_config->modules, l, em)
|
2004-12-05 01:34:59 -08:00
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
if (!em) continue;
|
|
|
|
if (!e_util_strcmp(em->name, m->name))
|
|
|
|
{
|
|
|
|
e_config->modules = eina_list_remove(e_config->modules, em);
|
|
|
|
if (em->name) eina_stringshare_del(em->name);
|
|
|
|
E_FREE(em);
|
|
|
|
break;
|
|
|
|
}
|
2004-12-05 01:34:59 -08:00
|
|
|
}
|
2009-04-20 19:07:06 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((m->enabled) && (!m->error))
|
2005-02-10 04:29:25 -08:00
|
|
|
{
|
2013-01-10 03:31:17 -08:00
|
|
|
if (m->func.save) m->func.save(m);
|
|
|
|
if (m->func.shutdown) m->func.shutdown(m);
|
2005-02-10 04:29:25 -08:00
|
|
|
}
|
2008-10-15 08:12:56 -07:00
|
|
|
if (m->name) eina_stringshare_del(m->name);
|
|
|
|
if (m->dir) eina_stringshare_del(m->dir);
|
2010-01-27 07:18:51 -08:00
|
|
|
// if (m->handle) dlclose(m->handle); DONT dlclose! causes problems with deferred callbacks for free etc. - when their code goes away!
|
2008-10-22 04:49:33 -07:00
|
|
|
_e_modules = eina_list_remove(_e_modules, m);
|
2004-11-24 19:37:45 -08:00
|
|
|
free(m);
|
|
|
|
}
|
|
|
|
|
2013-01-15 07:33:39 -08:00
|
|
|
static Eina_Bool
|
|
|
|
_e_module_desktop_list_cb(const Eina_Hash *hash EINA_UNUSED, const void *key EINA_UNUSED, void *data, void *fdata)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
Eina_List **l = fdata;
|
|
|
|
Efreet_Desktop *desktop;
|
|
|
|
E_Module_Desktop *md;
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/module.desktop", (char*)data);
|
|
|
|
desktop = efreet_desktop_new(buf);
|
|
|
|
if (desktop)
|
|
|
|
{
|
|
|
|
md = E_NEW(E_Module_Desktop, 1);
|
|
|
|
md->desktop = desktop;
|
|
|
|
md->dir = eina_stringshare_ref(data);
|
|
|
|
*l = eina_list_append(*l, md);
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
static void
|
2006-03-02 04:03:48 -08:00
|
|
|
_e_module_dialog_disable_show(const char *title, const char *body, E_Module *m)
|
2005-09-22 11:17:18 -07:00
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
2012-08-22 00:02:41 -07:00
|
|
|
char buf[4096];
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2008-11-26 17:50:00 -08:00
|
|
|
printf("MODULE ERR:\n%s\n", body);
|
2012-06-20 23:19:43 -07:00
|
|
|
dia = e_dialog_new(e_container_current_get(e_manager_current_get()),
|
2012-07-02 03:35:16 -07:00
|
|
|
"E", "_module_unload_dialog");
|
2005-09-22 11:17:18 -07:00
|
|
|
if (!dia) return;
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s<br>%s", body,
|
2012-07-25 23:47:12 -07:00
|
|
|
_("What action should be taken with this module?<br>"));
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
e_dialog_title_set(dia, title);
|
2009-03-15 10:41:46 -07:00
|
|
|
e_dialog_icon_set(dia, "enlightenment", 64);
|
2005-09-24 06:42:05 -07:00
|
|
|
e_dialog_text_set(dia, buf);
|
2012-06-26 16:23:11 -07:00
|
|
|
e_dialog_button_add(dia, _("Unload"), NULL, _e_module_cb_dialog_disable, m);
|
2012-07-25 23:47:12 -07:00
|
|
|
e_dialog_button_add(dia, _("Keep"), NULL, NULL, NULL);
|
2005-09-24 06:42:05 -07:00
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
static void
|
|
|
|
_e_module_cb_dialog_disable(void *data, E_Dialog *dia)
|
|
|
|
{
|
|
|
|
E_Module *m;
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
m = data;
|
|
|
|
e_module_disable(m);
|
|
|
|
e_object_del(E_OBJECT(m));
|
|
|
|
e_object_del(E_OBJECT(dia));
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2007-07-15 19:15:37 -07:00
|
|
|
|
2010-06-24 09:19:12 -07:00
|
|
|
static Eina_Bool
|
2010-11-05 11:40:31 -07:00
|
|
|
_e_module_cb_idler(void *data __UNUSED__)
|
2007-07-29 03:24:56 -07:00
|
|
|
{
|
|
|
|
if (_e_modules_delayed)
|
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
const char *name;
|
|
|
|
E_Module *m;
|
|
|
|
|
|
|
|
name = eina_list_data_get(_e_modules_delayed);
|
|
|
|
_e_modules_delayed =
|
|
|
|
eina_list_remove_list(_e_modules_delayed, _e_modules_delayed);
|
|
|
|
m = NULL;
|
|
|
|
if (name) m = e_module_new(name);
|
2012-08-24 06:34:25 -07:00
|
|
|
if (m)
|
|
|
|
{
|
2012-07-26 23:43:14 -07:00
|
|
|
#ifndef E17_RELEASE_BUILD
|
2012-08-24 06:34:25 -07:00
|
|
|
char buf[1024];
|
|
|
|
snprintf(buf, sizeof(buf), "DELAYED MODULE LOAD: %s", name);
|
|
|
|
e_main_ts(buf);
|
2012-07-26 23:43:14 -07:00
|
|
|
#endif
|
2012-08-24 06:34:25 -07:00
|
|
|
e_module_enable(m);
|
|
|
|
}
|
2012-07-02 03:35:16 -07:00
|
|
|
eina_stringshare_del(name);
|
2007-07-29 03:24:56 -07:00
|
|
|
}
|
2009-09-21 13:36:35 -07:00
|
|
|
if (_e_modules_delayed)
|
|
|
|
{
|
2012-07-02 03:35:16 -07:00
|
|
|
e_util_wakeup();
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
2009-09-21 13:36:35 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ecore_event_add(E_EVENT_MODULE_INIT_END, NULL, NULL, NULL);
|
2013-01-11 02:34:29 -08:00
|
|
|
|
2012-10-16 03:42:01 -07:00
|
|
|
_e_modules_initting = EINA_FALSE;
|
|
|
|
_e_module_whitelist_check();
|
2009-09-21 13:36:35 -07:00
|
|
|
|
2007-07-29 03:24:56 -07:00
|
|
|
_e_module_idler = NULL;
|
2010-06-24 09:19:12 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2007-07-29 03:24:56 -07:00
|
|
|
}
|
2008-05-18 21:37:34 -07:00
|
|
|
|
|
|
|
static int
|
2008-10-27 00:33:21 -07:00
|
|
|
_e_module_sort_priority(const void *d1, const void *d2)
|
2008-05-18 21:37:34 -07:00
|
|
|
{
|
2008-10-27 00:33:21 -07:00
|
|
|
const E_Config_Module *m1, *m2;
|
2008-05-18 21:37:34 -07:00
|
|
|
|
|
|
|
m1 = d1;
|
|
|
|
m2 = d2;
|
2012-07-02 03:35:16 -07:00
|
|
|
return m2->priority - m1->priority;
|
2008-05-18 21:37:34 -07:00
|
|
|
}
|
2009-09-21 13:36:35 -07:00
|
|
|
|
2012-06-20 23:19:43 -07:00
|
|
|
static void
|
|
|
|
_e_module_event_update_free(void *data __UNUSED__, void *event)
|
2009-09-21 13:36:35 -07:00
|
|
|
{
|
|
|
|
E_Event_Module_Update *ev;
|
2010-04-26 14:50:53 -07:00
|
|
|
|
2009-09-21 13:36:35 -07:00
|
|
|
if (!(ev = event)) return;
|
2012-11-26 02:30:00 -08:00
|
|
|
eina_stringshare_del(ev->name);
|
2009-09-21 13:36:35 -07:00
|
|
|
E_FREE(ev);
|
|
|
|
}
|
2012-07-02 03:35:16 -07:00
|
|
|
|
2012-10-17 23:26:57 -07:00
|
|
|
static void
|
|
|
|
_cleanup_cb(void *data, E_Dialog *dialog)
|
|
|
|
{
|
|
|
|
Eina_List *badl = data;
|
|
|
|
const char *s;
|
|
|
|
|
|
|
|
e_object_del(E_OBJECT(dialog));
|
|
|
|
EINA_LIST_FREE(badl, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ignore_cb(void *data, E_Dialog *dialog)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
|
|
|
|
e_object_del(E_OBJECT(dialog));
|
|
|
|
|
|
|
|
EINA_LIST_FREE(e_config->bad_modules, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
e_config->bad_modules = data;
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
|
|
|
|
2012-10-16 03:42:01 -07:00
|
|
|
static void
|
|
|
|
_e_module_whitelist_check(void)
|
|
|
|
{
|
|
|
|
Eina_List *l, *badl = NULL;
|
|
|
|
E_Module *m;
|
2012-10-17 23:26:57 -07:00
|
|
|
unsigned int known = 0;
|
2012-10-16 03:42:01 -07:00
|
|
|
int i;
|
|
|
|
const char *s;
|
2013-01-11 02:34:29 -08:00
|
|
|
const char *goodmods[] =
|
|
|
|
{
|
|
|
|
"access",
|
|
|
|
"backlight",
|
|
|
|
"battery",
|
|
|
|
"bluez4",
|
|
|
|
"clock",
|
|
|
|
"conf",
|
|
|
|
"conf_applications",
|
|
|
|
"conf_comp",
|
|
|
|
"conf_dialogs",
|
|
|
|
"conf_display",
|
|
|
|
"conf_edgebindings",
|
|
|
|
"conf_interaction",
|
|
|
|
"conf_intl",
|
|
|
|
"conf_keybindings",
|
|
|
|
"conf_menus",
|
|
|
|
"conf_paths",
|
|
|
|
"conf_performance",
|
|
|
|
"conf_randr",
|
|
|
|
"conf_shelves",
|
|
|
|
"conf_theme",
|
|
|
|
"conf_wallpaper2",
|
|
|
|
"conf_window_manipulation",
|
|
|
|
"conf_window_remembers",
|
|
|
|
"connman",
|
|
|
|
"cpufreq",
|
|
|
|
"everything",
|
|
|
|
"fileman",
|
|
|
|
"fileman_opinfo",
|
|
|
|
"gadman",
|
|
|
|
"ibar",
|
|
|
|
"ibox",
|
|
|
|
"illume2",
|
|
|
|
"illume-bluetooth",
|
|
|
|
"illume-home",
|
|
|
|
"illume-home-toggle",
|
|
|
|
"illume-indicator",
|
|
|
|
"illume-kbd-toggle",
|
|
|
|
"illume-keyboard",
|
|
|
|
"illume-mode-toggle",
|
|
|
|
"illume-softkey",
|
|
|
|
"layout",
|
|
|
|
"mixer",
|
|
|
|
"msgbus",
|
|
|
|
"notification",
|
|
|
|
"ofono",
|
|
|
|
"pager",
|
|
|
|
"physics",
|
|
|
|
"quickaccess",
|
|
|
|
"shot",
|
|
|
|
"start",
|
|
|
|
"syscon",
|
|
|
|
"systray",
|
|
|
|
"tasks",
|
|
|
|
"temperature",
|
|
|
|
"tiling",
|
|
|
|
"winlist",
|
|
|
|
"wizard",
|
|
|
|
"wl_drm",
|
|
|
|
"wl_screenshot",
|
|
|
|
"wl_shell",
|
|
|
|
"xkbswitch",
|
|
|
|
"echievements",
|
|
|
|
"music-control",
|
|
|
|
"conf2",
|
|
|
|
"appmenu",
|
|
|
|
NULL // end marker
|
|
|
|
};
|
2012-10-16 03:42:01 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(_e_modules, l, m)
|
|
|
|
{
|
|
|
|
Eina_Bool ok;
|
2013-01-11 02:34:29 -08:00
|
|
|
|
2012-10-16 03:42:01 -07:00
|
|
|
if (!m->name) continue;
|
|
|
|
ok = EINA_FALSE;
|
|
|
|
for (i = 0; goodmods[i]; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(m->name, goodmods[i]))
|
|
|
|
{
|
|
|
|
ok = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-10-17 23:26:57 -07:00
|
|
|
if (!ok) badl = eina_list_append(badl, eina_stringshare_add(m->name));
|
2012-10-16 03:42:01 -07:00
|
|
|
}
|
2012-10-17 23:26:57 -07:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(badl, l, s)
|
|
|
|
{
|
|
|
|
const char *tmp;
|
|
|
|
Eina_List *ll;
|
|
|
|
Eina_Bool found = EINA_FALSE;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(e_config->bad_modules, ll, tmp)
|
|
|
|
{
|
|
|
|
if (!strcmp(s, tmp))
|
|
|
|
{
|
|
|
|
found = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) break;
|
|
|
|
known++;
|
|
|
|
}
|
|
|
|
|
2012-10-31 02:00:23 -07:00
|
|
|
{
|
|
|
|
Ecore_X_Atom _x_tainted;
|
|
|
|
char *state;
|
|
|
|
unsigned int _e_tainted;
|
|
|
|
|
|
|
|
state = badl ? "YES" : "NO";
|
|
|
|
_e_tainted = badl ? 1 : 0;
|
|
|
|
|
|
|
|
_x_tainted = ecore_x_atom_get("_E_TAINTED");
|
|
|
|
ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
|
|
|
|
_x_tainted, &_e_tainted, 1);
|
|
|
|
|
|
|
|
e_env_set("E17_TAINTED", state);
|
|
|
|
}
|
2012-10-17 23:26:57 -07:00
|
|
|
|
|
|
|
if (eina_list_count(badl) != known)
|
2012-10-16 03:42:01 -07:00
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
|
|
|
Eina_Strbuf *sbuf;
|
2013-01-11 02:34:29 -08:00
|
|
|
|
2012-10-16 03:42:01 -07:00
|
|
|
dia = e_dialog_new(e_container_current_get(e_manager_current_get()),
|
|
|
|
"E", "_module_whitelist_dialog");
|
|
|
|
if (!dia)
|
|
|
|
{
|
|
|
|
eina_list_free(badl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sbuf = eina_strbuf_new();
|
|
|
|
if (!sbuf)
|
|
|
|
{
|
|
|
|
eina_list_free(badl);
|
|
|
|
e_object_del(E_OBJECT(dia));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
eina_strbuf_append
|
|
|
|
(sbuf, _("The following modules are not standard ones for<br>"
|
|
|
|
"Enlightenment and may cause bugs and crashes.<br>"
|
|
|
|
"Please remove them before reporting any bugs.<br>"
|
|
|
|
"<br>"
|
|
|
|
"The module list is as follows:<br>"
|
|
|
|
"<br>"));
|
2012-10-17 23:26:57 -07:00
|
|
|
EINA_LIST_FOREACH(badl, l, s)
|
2012-10-16 03:42:01 -07:00
|
|
|
{
|
|
|
|
eina_strbuf_append(sbuf, s);
|
|
|
|
eina_strbuf_append(sbuf, "<br>");
|
|
|
|
}
|
|
|
|
|
|
|
|
e_dialog_title_set(dia, _("Unstable module tainting"));
|
|
|
|
e_dialog_icon_set(dia, "enlightenment", 64);
|
|
|
|
e_dialog_text_set(dia, eina_strbuf_string_get(sbuf));
|
2012-10-17 23:26:57 -07:00
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, _cleanup_cb, badl);
|
|
|
|
e_dialog_button_add(dia, _("I know"), NULL, _ignore_cb, badl);
|
2012-10-16 03:42:01 -07:00
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
|
|
|
eina_strbuf_free(sbuf);
|
|
|
|
}
|
2012-10-17 23:26:57 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
EINA_LIST_FREE(badl, s)
|
|
|
|
eina_stringshare_del(s);
|
|
|
|
}
|
2012-10-16 03:42:01 -07:00
|
|
|
}
|
2013-01-11 02:34:29 -08:00
|
|
|
|