<commit_before>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

/* TODO List:
 * 
 * * add module types/classes
 * * add list of exclusions that a module cant work withApi
 * 
 */

/* local subsystem functions */
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);
static int _e_module_cb_idler(void *data);
static int _e_module_sort_priority(const void *d1, const void *d2);

/* local subsystem globals */
static Eina_List *_e_modules = NULL;
static Ecore_Idler *_e_module_idler = NULL;
static Eina_List *_e_modules_delayed = NULL;

EAPI int E_EVENT_MODULE_UPDATE = 0;

/* externally accessible functions */
EAPI int
e_module_init(void)
{
   E_EVENT_MODULE_UPDATE = ecore_event_type_new();
   return 1;
}

EAPI int
e_module_shutdown(void)
{
   E_Module *m;

#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

   _e_modules = eina_list_reverse(_e_modules);

   EINA_LIST_FREE(_e_modules, m)
     {
	if (m && m->enabled && !m->error)
	  {
	     m->func.save(m);
	     m->func.shutdown(m);
	     m->enabled = 0;
	  }
	e_object_del(E_OBJECT(m));
     }

   return 1;
}

EAPI void
e_module_all_load(void)
{
   Eina_List *l;
   E_Config_Module *em;

   e_config->modules = eina_list_sort(e_config->modules,
                                      eina_list_count(e_config->modules),
                                      _e_module_sort_priority);
   EINA_LIST_FOREACH(e_config->modules, l, em)
     {
	E_Module *m;

	if (!em) continue;
	if ((em->delayed) && (em->enabled))
	  {
	     if (!_e_module_idler)
	       _e_module_idler = ecore_idler_add(_e_module_cb_idler, NULL);
	     _e_modules_delayed = 
	       eina_list_append(_e_modules_delayed,
				eina_stringshare_add(em->name));
	  }
	else if (em->enabled)
	  {
	     m = NULL;<commit_msg>e17:shutdown all modules<commit_after>/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#include "e.h"

/* TODO List:
 * 
 * * add module types/classes
 * * add list of exclusions that a module cant work withApi
 * 
 */

/* local subsystem functions */
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);
static int _e_module_cb_idler(void *data);
static int _e_module_sort_priority(const void *d1, const void *d2);

/* local subsystem globals */
static Eina_List *_e_modules = NULL;
static Ecore_Idler *_e_module_idler = NULL;
static Eina_List *_e_modules_delayed = NULL;

EAPI int E_EVENT_MODULE_UPDATE = 0;

/* externally accessible functions */
EAPI int
e_module_init(void)
{
   E_EVENT_MODULE_UPDATE = ecore_event_type_new();
   return 1;
}

EAPI int
e_module_shutdown(void)
{
   E_Module *m;
   Eina_List *l;
   
#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

   // whats was this for? modules should not depend on each others load order
   // _e_modules = eina_list_reverse(_e_modules); 
   
   /* FIXME there seems to be a module that modifies _e_modules here
    * dont use EINA_LIST_FREE until solved! */
   EINA_LIST_FOREACH(_e_modules, l, m)
     {
	printf("shutdown module: %s\n", m->name);
	
	if (m && m->enabled && !m->error)
	  {
	     m->func.save(m);
	     m->func.shutdown(m);
	     m->enabled = 0;
	  }
	e_object_del(E_OBJECT(m));
     }

   if (_e_modules)
     eina_list_free(_e_modules);
   _e_modules = NULL;
     
   return 1;
}

EAPI void
e_module_all_load(void)
{
   Eina_List *l;
   E_Config_Module *em;

   e_config->modules = eina_list_sort(e_config->modules,
                                      eina_list_count(e_config->modules),
                                      _e_module_sort_priority);
   EINA_LIST_FOREACH(e_config->modules, l, em)
     {
	E_Module *m;

	if (!em) continue;
	if ((em->delayed) && (em->enabled))
	  {
	     if (!_e_module_idler)
	       _e_module_idler = ecore_idler_add(_e_module_cb_idler, NULL);
	     _e_modules_delayed = 
	       eina_list_append(_e_modules_delayed,
				eina_stringshare_add(em->name));
	  }
	else if (em->enabled)
	  {
	     m = NULL;
{'fraction_non_alphanumeric': 0.10966904607397794, 'fraction_numerical': 0.006489292667099286, 'mean_word_length': 3.345864661654135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4357991', 'n_tokens_mistral': 1783, 'n_tokens_neox': 1697, 'n_words': 386}