formatting

SVN revision: 73149
This commit is contained in:
Mike Blumenkrantz 2012-07-02 10:35:16 +00:00
parent 1546ae67a8
commit ffd62128c3
1 changed files with 190 additions and 189 deletions

View File

@ -8,12 +8,12 @@
*/ */
/* local subsystem functions */ /* local subsystem functions */
static void _e_module_free(E_Module *m); 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_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_cb_dialog_disable(void *data, E_Dialog *dia);
static void _e_module_event_update_free(void *data, void *event); static void _e_module_event_update_free(void *data, void *event);
static Eina_Bool _e_module_cb_idler(void *data); static Eina_Bool _e_module_cb_idler(void *data);
static int _e_module_sort_priority(const void *d1, const void *d2); static int _e_module_sort_priority(const void *d1, const void *d2);
/* local subsystem globals */ /* local subsystem globals */
static Eina_List *_e_modules = NULL; static Eina_List *_e_modules = NULL;
@ -46,7 +46,7 @@ e_module_shutdown(void)
/* do not use EINA_LIST_FREE! e_object_del modifies list */ /* do not use EINA_LIST_FREE! e_object_del modifies list */
if (x_fatal) if (x_fatal)
e_module_save_all(); e_module_save_all();
else else
{ {
while (_e_modules) while (_e_modules)
@ -77,28 +77,28 @@ e_module_all_load(void)
EINA_LIST_FOREACH(e_config->modules, l, em) EINA_LIST_FOREACH(e_config->modules, l, em)
{ {
if (!em) continue; if (!em) continue;
if ((em->delayed) && (em->enabled)) if ((em->delayed) && (em->enabled))
{ {
if (!_e_module_idler) if (!_e_module_idler)
_e_module_idler = ecore_idler_add(_e_module_cb_idler, NULL); _e_module_idler = ecore_idler_add(_e_module_cb_idler, NULL);
_e_modules_delayed = _e_modules_delayed =
eina_list_append(_e_modules_delayed, eina_list_append(_e_modules_delayed,
eina_stringshare_add(em->name)); eina_stringshare_add(em->name));
} }
else if (em->enabled) else if (em->enabled)
{ {
E_Module *m; E_Module *m;
if (!em->name) continue; if (!em->name) continue;
e_util_env_set("E_MODULE_LOAD", em->name); e_util_env_set("E_MODULE_LOAD", em->name);
snprintf (buf, sizeof(buf), _("Loading Module: %s"), em->name); snprintf(buf, sizeof(buf), _("Loading Module: %s"), em->name);
e_init_status_set(buf); e_init_status_set(buf);
m = e_module_new(em->name); m = e_module_new(em->name);
if (m) e_module_enable(m); if (m) e_module_enable(m);
} }
} }
if (!_e_modules_delayed) if (!_e_modules_delayed)
@ -123,33 +123,33 @@ e_module_new(const char *name)
m = E_OBJECT_ALLOC(E_Module, E_MODULE_TYPE, _e_module_free); m = E_OBJECT_ALLOC(E_Module, E_MODULE_TYPE, _e_module_free);
if (name[0] != '/') if (name[0] != '/')
{ {
snprintf(buf, sizeof(buf), "%s/%s/module.so", name, MODULE_ARCH); snprintf(buf, sizeof(buf), "%s/%s/module.so", name, MODULE_ARCH);
modpath = e_path_find(path_modules, buf); modpath = e_path_find(path_modules, buf);
} }
else else
modpath = eina_stringshare_add(name); modpath = eina_stringshare_add(name);
if (!modpath) if (!modpath)
{ {
snprintf(body, sizeof(body), snprintf(body, sizeof(body),
_("There was an error loading module named: %s<br>" _("There was an error loading module named: %s<br>"
"No module named %s could be found in the<br>" "No module named %s could be found in the<br>"
"module search directories.<br>"), name, buf); "module search directories.<br>"), name, buf);
_e_module_dialog_disable_show(_("Error loading Module"), body, m); _e_module_dialog_disable_show(_("Error loading Module"), body, m);
m->error = 1; m->error = 1;
goto init_done; goto init_done;
} }
m->handle = dlopen(modpath, (RTLD_NOW | RTLD_GLOBAL)); m->handle = dlopen(modpath, (RTLD_NOW | RTLD_GLOBAL));
if (!m->handle) if (!m->handle)
{ {
snprintf(body, sizeof(body), snprintf(body, sizeof(body),
_("There was an error loading module named: %s<br>" _("There was an error loading module named: %s<br>"
"The full path to this module is:<br>" "The full path to this module is:<br>"
"%s<br>" "%s<br>"
"The error reported was:<br>" "The error reported was:<br>"
"%s<br>"), name, buf, dlerror()); "%s<br>"), name, buf, dlerror());
_e_module_dialog_disable_show(_("Error loading Module"), body, m); _e_module_dialog_disable_show(_("Error loading Module"), body, m);
m->error = 1; m->error = 1;
goto init_done; goto init_done;
} }
m->api = dlsym(m->handle, "e_modapi"); m->api = dlsym(m->handle, "e_modapi");
m->func.init = dlsym(m->handle, "e_modapi_init"); m->func.init = dlsym(m->handle, "e_modapi_init");
@ -158,44 +158,44 @@ e_module_new(const char *name)
if ((!m->func.init) || (!m->func.shutdown) || (!m->func.save) || (!m->api)) if ((!m->func.init) || (!m->func.shutdown) || (!m->func.save) || (!m->api))
{ {
snprintf(body, sizeof(body), snprintf(body, sizeof(body),
_("There was an error loading module named: %s<br>" _("There was an error loading module named: %s<br>"
"The full path to this module is:<br>" "The full path to this module is:<br>"
"%s<br>" "%s<br>"
"The error reported was:<br>" "The error reported was:<br>"
"%s<br>"), "%s<br>"),
name, buf, _("Module does not contain all needed functions")); name, buf, _("Module does not contain all needed functions"));
_e_module_dialog_disable_show(_("Error loading Module"), body, m); _e_module_dialog_disable_show(_("Error loading Module"), body, m);
m->api = NULL; m->api = NULL;
m->func.init = NULL; m->func.init = NULL;
m->func.shutdown = NULL; m->func.shutdown = NULL;
m->func.save = NULL; m->func.save = NULL;
dlclose(m->handle); dlclose(m->handle);
m->handle = NULL; m->handle = NULL;
m->error = 1; m->error = 1;
goto init_done; goto init_done;
} }
if (m->api->version < E_MODULE_API_VERSION) if (m->api->version < E_MODULE_API_VERSION)
{ {
snprintf(body, sizeof(body), snprintf(body, sizeof(body),
_("Module API Error<br>Error initializing Module: %s<br>" _("Module API Error<br>Error initializing Module: %s<br>"
"It requires a minimum module API version of: %i.<br>" "It requires a minimum module API version of: %i.<br>"
"The module API advertized by Enlightenment is: %i.<br>"), "The module API advertized by Enlightenment is: %i.<br>"),
_(m->api->name), m->api->version, E_MODULE_API_VERSION); _(m->api->name), m->api->version, E_MODULE_API_VERSION);
snprintf(title, sizeof(title), _("Enlightenment %s Module"), snprintf(title, sizeof(title), _("Enlightenment %s Module"),
_(m->api->name)); _(m->api->name));
_e_module_dialog_disable_show(title, body, m); _e_module_dialog_disable_show(title, body, m);
m->api = NULL; m->api = NULL;
m->func.init = NULL; m->func.init = NULL;
m->func.shutdown = NULL; m->func.shutdown = NULL;
m->func.save = NULL; m->func.save = NULL;
dlclose(m->handle); dlclose(m->handle);
m->handle = NULL; m->handle = NULL;
m->error = 1; m->error = 1;
goto init_done; goto init_done;
} }
init_done: init_done:
@ -204,38 +204,38 @@ init_done:
m->name = eina_stringshare_add(name); m->name = eina_stringshare_add(name);
if (modpath) if (modpath)
{ {
s = ecore_file_dir_get(modpath); s = ecore_file_dir_get(modpath);
if (s) if (s)
{ {
char *s2; char *s2;
s2 = ecore_file_dir_get(s); s2 = ecore_file_dir_get(s);
free(s); free(s);
if (s2) if (s2)
{ {
m->dir = eina_stringshare_add(s2); m->dir = eina_stringshare_add(s2);
free(s2); free(s2);
} }
} }
} }
EINA_LIST_FOREACH(e_config->modules, l, em) EINA_LIST_FOREACH(e_config->modules, l, em)
{ {
if (!em) continue; if (!em) continue;
if (!e_util_strcmp(em->name, m->name)) if (!e_util_strcmp(em->name, m->name))
{ {
in_list = 1; in_list = 1;
break; break;
} }
} }
if (!in_list) if (!in_list)
{ {
E_Config_Module *module; E_Config_Module *module;
module = E_NEW(E_Config_Module, 1); module = E_NEW(E_Config_Module, 1);
module->name = eina_stringshare_add(m->name); module->name = eina_stringshare_add(m->name);
module->enabled = 0; module->enabled = 0;
e_config->modules = eina_list_append(e_config->modules, module); e_config->modules = eina_list_append(e_config->modules, module);
e_config_save_queue(); e_config_save_queue();
} }
if (modpath) eina_stringshare_del(modpath); if (modpath) eina_stringshare_del(modpath);
return m; return m;
@ -271,24 +271,24 @@ e_module_enable(E_Module *m)
m->data = m->func.init(m); m->data = m->func.init(m);
if (m->data) if (m->data)
{ {
m->enabled = 1; m->enabled = 1;
EINA_LIST_FOREACH(e_config->modules, l, em) EINA_LIST_FOREACH(e_config->modules, l, em)
{ {
if (!em) continue; if (!em) continue;
if (!e_util_strcmp(em->name, m->name)) if (!e_util_strcmp(em->name, m->name))
{ {
em->enabled = 1; em->enabled = 1;
e_config_save_queue(); e_config_save_queue();
ev = E_NEW(E_Event_Module_Update, 1); ev = E_NEW(E_Event_Module_Update, 1);
ev->name = strdup(em->name); ev->name = strdup(em->name);
ev->enabled = 1; ev->enabled = 1;
ecore_event_add(E_EVENT_MODULE_UPDATE, ev, ecore_event_add(E_EVENT_MODULE_UPDATE, ev,
_e_module_event_update_free, NULL); _e_module_event_update_free, NULL);
break; break;
} }
} }
return 1; return 1;
} }
return 0; return 0;
} }
@ -309,19 +309,19 @@ e_module_disable(E_Module *m)
m->enabled = 0; m->enabled = 0;
EINA_LIST_FOREACH(e_config->modules, l, em) EINA_LIST_FOREACH(e_config->modules, l, em)
{ {
if (!em) continue; if (!em) continue;
if (!e_util_strcmp(em->name, m->name)) if (!e_util_strcmp(em->name, m->name))
{ {
em->enabled = 0; em->enabled = 0;
e_config_save_queue(); e_config_save_queue();
ev = E_NEW(E_Event_Module_Update, 1); ev = E_NEW(E_Event_Module_Update, 1);
ev->name = strdup(em->name); ev->name = strdup(em->name);
ev->enabled = 0; ev->enabled = 0;
ecore_event_add(E_EVENT_MODULE_UPDATE, ev, ecore_event_add(E_EVENT_MODULE_UPDATE, ev,
_e_module_event_update_free, NULL); _e_module_event_update_free, NULL);
break; break;
} }
} }
return ret; return ret;
} }
@ -380,33 +380,33 @@ e_module_dialog_show(E_Module *m, const char *title, const char *body)
const char *icon = NULL; const char *icon = NULL;
dia = e_dialog_new(e_container_current_get(e_manager_current_get()), dia = e_dialog_new(e_container_current_get(e_manager_current_get()),
"E", "_module_dialog"); "E", "_module_dialog");
if (!dia) return; if (!dia) return;
e_dialog_title_set(dia, title); e_dialog_title_set(dia, title);
if (m) if (m)
{ {
Efreet_Desktop *desktop; Efreet_Desktop *desktop;
snprintf(buf, sizeof(buf), "%s/module.desktop", e_module_dir_get(m)); snprintf(buf, sizeof(buf), "%s/module.desktop", e_module_dir_get(m));
desktop = efreet_desktop_new(buf); desktop = efreet_desktop_new(buf);
if ((desktop) && (desktop->icon)) if ((desktop) && (desktop->icon))
{ {
icon = efreet_icon_path_find(e_config->icon_theme, desktop->icon, 64); icon = efreet_icon_path_find(e_config->icon_theme, desktop->icon, 64);
if (!icon) if (!icon)
{ {
snprintf(buf, sizeof(buf), "%s/%s.edj", snprintf(buf, sizeof(buf), "%s/%s.edj",
e_module_dir_get(m), desktop->icon); e_module_dir_get(m), desktop->icon);
dia->icon_object = e_util_icon_add(buf, e_win_evas_get(dia->win)); dia->icon_object = e_util_icon_add(buf, e_win_evas_get(dia->win));
} }
else else
dia->icon_object = e_util_icon_add(icon, e_win_evas_get(dia->win)); dia->icon_object = e_util_icon_add(icon, e_win_evas_get(dia->win));
edje_extern_object_min_size_set(dia->icon_object, 64, 64); edje_extern_object_min_size_set(dia->icon_object, 64, 64);
edje_object_part_swallow(dia->bg_object, "e.swallow.icon", dia->icon_object); edje_object_part_swallow(dia->bg_object, "e.swallow.icon", dia->icon_object);
evas_object_show(dia->icon_object); evas_object_show(dia->icon_object);
} }
if (desktop) efreet_desktop_free(desktop); if (desktop) efreet_desktop_free(desktop);
} }
else else
e_dialog_icon_set(dia, "preferences-plugin", 64); e_dialog_icon_set(dia, "preferences-plugin", 64);
@ -430,16 +430,16 @@ e_module_delayed_set(E_Module *m, int delayed)
EINA_LIST_FOREACH(e_config->modules, l, em) EINA_LIST_FOREACH(e_config->modules, l, em)
{ {
if (!em) continue; if (!em) continue;
if (!e_util_strcmp(m->name, em->name)) if (!e_util_strcmp(m->name, em->name))
{ {
if (em->delayed != delayed) if (em->delayed != delayed)
{ {
em->delayed = delayed; em->delayed = delayed;
e_config_save_queue(); e_config_save_queue();
} }
break; break;
} }
} }
} }
@ -453,16 +453,16 @@ e_module_priority_set(E_Module *m, int priority)
EINA_LIST_FOREACH(e_config->modules, l, em) EINA_LIST_FOREACH(e_config->modules, l, em)
{ {
if (!em) continue; if (!em) continue;
if (!e_util_strcmp(m->name, em->name)) if (!e_util_strcmp(m->name, em->name))
{ {
if (em->priority != priority) if (em->priority != priority)
{ {
em->priority = priority; em->priority = priority;
e_config_save_queue(); e_config_save_queue();
} }
break; break;
} }
} }
} }
@ -476,20 +476,20 @@ _e_module_free(E_Module *m)
EINA_LIST_FOREACH(e_config->modules, l, em) EINA_LIST_FOREACH(e_config->modules, l, em)
{ {
if (!em) continue; if (!em) continue;
if (!e_util_strcmp(em->name, m->name)) if (!e_util_strcmp(em->name, m->name))
{ {
e_config->modules = eina_list_remove(e_config->modules, em); e_config->modules = eina_list_remove(e_config->modules, em);
if (em->name) eina_stringshare_del(em->name); if (em->name) eina_stringshare_del(em->name);
E_FREE(em); E_FREE(em);
break; break;
} }
} }
if ((m->enabled) && (!m->error)) if ((m->enabled) && (!m->error))
{ {
m->func.save(m); m->func.save(m);
m->func.shutdown(m); m->func.shutdown(m);
} }
if (m->name) eina_stringshare_del(m->name); if (m->name) eina_stringshare_del(m->name);
if (m->dir) eina_stringshare_del(m->dir); if (m->dir) eina_stringshare_del(m->dir);
@ -506,11 +506,11 @@ _e_module_dialog_disable_show(const char *title, const char *body, E_Module *m)
printf("MODULE ERR:\n%s\n", body); printf("MODULE ERR:\n%s\n", body);
dia = e_dialog_new(e_container_current_get(e_manager_current_get()), dia = e_dialog_new(e_container_current_get(e_manager_current_get()),
"E", "_module_unload_dialog"); "E", "_module_unload_dialog");
if (!dia) return; if (!dia) return;
snprintf(buf, sizeof(buf), "%s<br>%s", body, snprintf(buf, sizeof(buf), "%s<br>%s", body,
_("Would you like to unload this module?<br>")); _("Would you like to unload this module?<br>"));
e_dialog_title_set(dia, title); e_dialog_title_set(dia, title);
e_dialog_icon_set(dia, "enlightenment", 64); e_dialog_icon_set(dia, "enlightenment", 64);
@ -538,21 +538,21 @@ _e_module_cb_idler(void *data __UNUSED__)
{ {
if (_e_modules_delayed) if (_e_modules_delayed)
{ {
const char *name; const char *name;
E_Module *m; E_Module *m;
name = eina_list_data_get(_e_modules_delayed); name = eina_list_data_get(_e_modules_delayed);
_e_modules_delayed = _e_modules_delayed =
eina_list_remove_list(_e_modules_delayed, _e_modules_delayed); eina_list_remove_list(_e_modules_delayed, _e_modules_delayed);
m = NULL; m = NULL;
if (name) m = e_module_new(name); if (name) m = e_module_new(name);
if (m) e_module_enable(m); if (m) e_module_enable(m);
eina_stringshare_del(name); eina_stringshare_del(name);
} }
if (_e_modules_delayed) if (_e_modules_delayed)
{ {
e_util_wakeup(); e_util_wakeup();
return ECORE_CALLBACK_RENEW; return ECORE_CALLBACK_RENEW;
} }
ecore_event_add(E_EVENT_MODULE_INIT_END, NULL, NULL, NULL); ecore_event_add(E_EVENT_MODULE_INIT_END, NULL, NULL, NULL);
@ -568,7 +568,7 @@ _e_module_sort_priority(const void *d1, const void *d2)
m1 = d1; m1 = d1;
m2 = d2; m2 = d2;
return (m2->priority - m1->priority); return m2->priority - m1->priority;
} }
static void static void
@ -580,3 +580,4 @@ _e_module_event_update_free(void *data __UNUSED__, void *event)
E_FREE(ev->name); E_FREE(ev->name);
E_FREE(ev); E_FREE(ev);
} }