From f6914dfb6e65136d74d7a3cc3303f49aaefadaa9 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 30 Aug 2012 08:04:35 +0000 Subject: [PATCH] use module version check util function instead of copying the same code everywhere SVN revision: 75849 --- src/modules/conf/e_mod_main.c | 44 ++-------------------------- src/modules/fileman/e_mod_main.c | 34 ++------------------- src/modules/physics/e_mod_main.c | 30 +------------------ src/modules/quickaccess/e_mod_main.c | 30 +------------------ 4 files changed, 6 insertions(+), 132 deletions(-) diff --git a/src/modules/conf/e_mod_main.c b/src/modules/conf/e_mod_main.c index b738f733b..a0af6efbf 100644 --- a/src/modules/conf/e_mod_main.c +++ b/src/modules/conf/e_mod_main.c @@ -27,7 +27,6 @@ static void _cb_action_conf(void *data, Evas_Object *obj, const char static void _conf_new(void); static void _conf_free(void); -static Eina_Bool _conf_timer(void *data); static E_Module *conf_module = NULL; static E_Action *act = NULL; @@ -295,38 +294,8 @@ e_modapi_init(E_Module *m) conf = e_config_domain_load("module.conf", conf_edd); if (conf) { - if ((conf->version >> 16) < MOD_CONFIG_FILE_EPOCH) - { - _conf_free(); - ecore_timer_add(1.0, _conf_timer, - _("Configuration Panel Module Configuration data needed " - "upgrading. Your old configuration
has been" - " wiped and a new set of defaults initialized. " - "This
will happen regularly during " - "development, so don't report a
bug. " - "This simply means the module needs " - "new configuration
data by default for " - "usable functionality that your old
" - "configuration simply lacks. This new set of " - "defaults will fix
that by adding it in. " - "You can re-configure things now to your
" - "liking. Sorry for the inconvenience.
")); - } - else if (conf->version > MOD_CONFIG_FILE_VERSION) - { - _conf_free(); - ecore_timer_add(1.0, _conf_timer, - _("Your Configuration Panel Module configuration is NEWER " - "than the module version. This is " - "very
strange. This should not happen unless" - " you downgraded
the module or " - "copied the configuration from a place where" - "
a newer version of the module " - "was running. This is bad and
as a " - "precaution your configuration has been now " - "restored to
defaults. Sorry for the " - "inconvenience.
")); - } + if (!e_util_module_config_check("Configuration Panel", conf->version, MOD_CONFIG_FILE_VERSION)) + _conf_free(); } if (!conf) _conf_new(); @@ -510,12 +479,3 @@ _conf_free(void) { E_FREE(conf); } - -static Eina_Bool -_conf_timer(__UNUSED__ void *data) -{ - e_util_dialog_show(_("Configuration Panel Configuration Updated"), - "%s", (char *)data); - return ECORE_CALLBACK_CANCEL; -} - diff --git a/src/modules/fileman/e_mod_main.c b/src/modules/fileman/e_mod_main.c index 3fe174d31..de7ae54a5 100644 --- a/src/modules/fileman/e_mod_main.c +++ b/src/modules/fileman/e_mod_main.c @@ -24,7 +24,6 @@ static void _e_mod_menu_add(void *data, E_Menu *m); static void _e_mod_fileman_config_load(void); static void _e_mod_fileman_config_free(void); -static Eina_Bool _e_mod_cb_config_timer(void *data); static Eina_Bool _e_mod_zone_add(void *data, int type, void *event); @@ -703,30 +702,8 @@ _e_mod_fileman_config_load(void) fileman_config = e_config_domain_load("module.fileman", conf_edd); if (fileman_config) { - if ((fileman_config->config_version >> 16) < MOD_CONFIG_FILE_EPOCH) - { - _e_mod_fileman_config_free(); - ecore_timer_add(1.0, _e_mod_cb_config_timer, - _("Fileman Module Settings data needed upgrading. Your old configuration
" - "has been wiped and a new set of defaults initialized. This
" - "will happen regularly during development, so don't report a
" - "bug. This simply means Fileman module needs new configuration
" - "data by default for usable functionality that your old
" - "configuration simply lacks. This new set of defaults will fix
" - "that by adding it in. You can re-configure things now to your
" - "liking. Sorry for the hiccup in your configuration.
")); - } - else if (fileman_config->config_version > MOD_CONFIG_FILE_VERSION) - { - _e_mod_fileman_config_free(); - ecore_timer_add(1.0, _e_mod_cb_config_timer, - _("Your Fileman Module configuration is NEWER than Fileman Module version. This is very
" - "strange. This should not happen unless you downgraded
" - "the Fileman Module or copied the configuration from a place where
" - "a newer version of the Fileman Module was running. This is bad and
" - "as a precaution your configuration has been now restored to
" - "defaults. Sorry for the inconvenience.
")); - } + if (!e_util_module_config_check("Fileman", fileman_config->config_version, MOD_CONFIG_FILE_VERSION)) + _e_mod_fileman_config_free(); } if (!fileman_config) @@ -819,13 +796,6 @@ _e_mod_fileman_config_free(void) E_FREE(fileman_config); } -static Eina_Bool -_e_mod_cb_config_timer(void *data) -{ - e_util_dialog_show(_("Fileman Settings Updated"), "%s", (char *)data); - return ECORE_CALLBACK_CANCEL; -} - static Eina_Bool _e_mod_zone_add(__UNUSED__ void *data, int type, diff --git a/src/modules/physics/e_mod_main.c b/src/modules/physics/e_mod_main.c index 48edcb630..23070e6b9 100644 --- a/src/modules/physics/e_mod_main.c +++ b/src/modules/physics/e_mod_main.c @@ -14,13 +14,6 @@ EAPI E_Module_Api e_modapi = "Physics" }; -static Eina_Bool -_e_mod_cb_config_timer(void *data) -{ - e_util_dialog_show(_("Physics Settings Updated"), "%s", (char *)data); - return ECORE_CALLBACK_CANCEL; -} - EAPI void * e_modapi_init(E_Module *m) { @@ -59,30 +52,9 @@ e_modapi_init(E_Module *m) mod->conf = e_config_domain_load("module.physics", mod->conf_edd); if (mod->conf) { - if ((mod->conf->config_version >> 16) < MOD_CONFIG_FILE_EPOCH) + if (!e_util_module_config_check("Physics", mod->conf->config_version, MOD_CONFIG_FILE_VERSION)) { e_mod_cfdata_config_free(mod->conf); - ecore_timer_add(1.0, _e_mod_cb_config_timer, - _("Physics module settings data needed upgrading. Your old configuration
" - "has been wiped and a new set of defaults initialized. This
" - "will happen regularly during development, so don't report a
" - "bug. This simply means Physics module needs new configuration
" - "data by default for usable functionality that your old
" - "configuration simply lacks. This new set of defaults will fix
" - "that by adding it in. You can re-configure things now to your
" - "liking. Sorry for the hiccup in your configuration.
")); - mod->conf = NULL; - } - else if (mod->conf->config_version > MOD_CONFIG_FILE_VERSION) - { - e_mod_cfdata_config_free(mod->conf); - ecore_timer_add(1.0, _e_mod_cb_config_timer, - _("Your Physics module configuration is NEWER than Fileman Module version. This is very
" - "strange. This should not happen unless you downgraded
" - "the Physics Module or copied the configuration from a place where
" - "a newer version of the Physics module was running. This is bad and
" - "as a precaution your configuration has been now restored to
" - "defaults. Sorry for the inconvenience.
")); mod->conf = NULL; } } diff --git a/src/modules/quickaccess/e_mod_main.c b/src/modules/quickaccess/e_mod_main.c index 6cdcd8a2e..8af1ae5df 100644 --- a/src/modules/quickaccess/e_mod_main.c +++ b/src/modules/quickaccess/e_mod_main.c @@ -25,13 +25,6 @@ Config *qa_config = NULL; EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Quickaccess"}; -static Eina_Bool -_e_mod_cb_config_timer(void *data) -{ - e_util_dialog_show(_("Quickaccess Settings Updated"), "%s", (char *)data); - return ECORE_CALLBACK_CANCEL; -} - ////////////////////////////// EAPI void * e_modapi_init(E_Module *m) @@ -51,31 +44,10 @@ e_modapi_init(E_Module *m) qa_config = e_config_domain_load("module.quickaccess", conf_edd); if (qa_config) { - if ((qa_config->config_version >> 16) < MOD_CONFIG_FILE_EPOCH) + if (!e_util_module_config_check("Quickaccess", qa_config->config_version, MOD_CONFIG_FILE_VERSION)) { e_qa_config_free(qa_config); qa_config = NULL; - ecore_timer_add(1.0, _e_mod_cb_config_timer, - _("Quickaccess module settings data needed upgrading. Your old configuration
" - "has been wiped and a new set of defaults initialized. This
" - "will happen regularly during development, so don't report a
" - "bug. This means Quickaccess module needs new configuration
" - "data by default for usable functionality that your old
" - "configuration lacked. This new set of defaults will fix
" - "that by adding it in. You can re-configure things now to your
" - "liking. Sorry for the hiccup in your configuration.
")); - } - else if (qa_config->config_version > MOD_CONFIG_FILE_VERSION) - { - e_qa_config_free(qa_config); - qa_config = NULL; - ecore_timer_add(1.0, _e_mod_cb_config_timer, - _("Your Quickaccess module configuration is NEWER than Quickaccess module version. This is very
" - "strange. This should not happen unless you downgraded
" - "the Quickaccess Module or copied the configuration from a place where
" - "a newer version of the Quickaccess Module was running. This is bad and
" - "as a precaution your configuration has been now restored to
" - "defaults. Sorry for the inconvenience.
")); } }