cleanup every hour

SVN revision: 48531
This commit is contained in:
Hannes Janetzek 2010-05-01 23:24:14 +00:00
parent cba6bba260
commit 2cf7cf080f
2 changed files with 24 additions and 1 deletions

View File

@ -21,6 +21,7 @@ static void _e_mod_run_cb(void *data, E_Menu *m, E_Menu_Item *mi);
static void _e_mod_menu_add(void *data, E_Menu *m);
static void _config_init(void);
static void _config_free(void);
static int _cleanup_history(void *data);
static E_Int_Menu_Augmentation *maug = NULL;
static E_Action *act = NULL;
@ -30,6 +31,8 @@ static E_Config_DD *conf_edd = NULL;
static E_Config_DD *plugin_conf_edd = NULL;
static E_Config_DD *plugin_setting_edd = NULL;
static Ecore_Timer *cleanup_timer;
EAPI int _e_module_evry_log_dom = -1;
@ -57,6 +60,7 @@ EAPI E_Module_Api e_modapi =
static Eina_List *_evry_types = NULL;
EAPI Evry_Type
evry_type_register(const char *type)
{
@ -158,6 +162,9 @@ e_modapi_init(E_Module *m)
e_datastore_set("everything_loaded", "");
/* cleanup every hour :) */
cleanup_timer = ecore_timer_add(3600, _cleanup_history, NULL);
return m;
}
@ -205,6 +212,10 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
E_CONFIG_DD_FREE(plugin_conf_edd);
E_CONFIG_DD_FREE(plugin_setting_edd);
e_datastore_del("everything_loaded");
if (cleanup_timer)
ecore_timer_del(cleanup_timer);
return 1;
}
@ -215,6 +226,16 @@ e_modapi_save(E_Module *m __UNUSED__)
return 1;
}
static int
_cleanup_history(void *data)
{
/* cleanup old entries */
evry_history_free();
evry_history_init();
return 1;
}
static void
_config_init()
{

View File

@ -211,6 +211,8 @@ evry_history_free(void)
EAPI void
evry_history_load(void)
{
if (evry_hist) return;
evry_hist = e_config_domain_load("module.everything.history", hist_edd);
if (evry_hist && evry_hist->version != HISTORY_VERSION)
@ -298,7 +300,7 @@ evry_history_add(Eina_Hash *hist, Evry_Item *it, const char *ctxt, const char *i
hi->usage /= 4.0;
hi->usage += TIME_FACTOR(hi->last_used);
hi->transient = it->plugin->transient;
hi->count += (hi->transient ? 2:1);
/* hi->count += (hi->transient ? 2:1); */
if (ctxt && !hi->context)
hi->context = eina_stringshare_ref(ctxt);