From 8df6712483385f0845eba04f709137afc6c5bbd0 Mon Sep 17 00:00:00 2001 From: Igor Murzov Date: Tue, 1 Jan 2013 16:05:26 +0000 Subject: [PATCH] eweather: Update versioning scheme SVN revision: 81957 --- src/module/e_mod_config.c | 12 ++---------- src/module/e_mod_config.h | 8 ++++---- src/module/e_mod_main.c | 37 ++++--------------------------------- 3 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/module/e_mod_config.c b/src/module/e_mod_config.c index 15101cc..e923283 100644 --- a/src/module/e_mod_config.c +++ b/src/module/e_mod_config.c @@ -62,17 +62,9 @@ EINTERN void _weather_config_new() { weather_cfg = E_NEW(Config, 1); - weather_cfg->version = (MOD_CONFIG_FILE_EPOCH << 16); + weather_cfg->config_version = MOD_CONFIG_FILE_VERSION; -#define IFMODCFG(v) \ - if ((weather_cfg->version & 0xffff) < v) { -#define IFMODCFGEND } - - IFMODCFG(0x008d); _weather_config_item_get(NULL, NULL); - IFMODCFGEND; - - weather_cfg->version = MOD_CONFIG_FILE_VERSION; /* set any config limits here with E_CONFIG_LIMIT */ @@ -314,7 +306,7 @@ _config_updated(Config_Item *ci) else eweather_code_set(eweather, ci->google); if(ci->celcius) - eweather_temp_type_set(eweather, EWEATHER_TEMP_CELCIUS); + eweather_temp_type_set(eweather, EWEATHER_TEMP_CELCIUS); else eweather_temp_type_set(eweather, EWEATHER_TEMP_FARENHEIT); } diff --git a/src/module/e_mod_config.h b/src/module/e_mod_config.h index 5ee6750..b55919c 100644 --- a/src/module/e_mod_config.h +++ b/src/module/e_mod_config.h @@ -2,10 +2,10 @@ # define E_MOD_CONFIG_H -#define MOD_CONFIG_FILE_EPOCH 0x0001 -#define MOD_CONFIG_FILE_GENERATION 0x008d +#define MOD_CONFIG_FILE_EPOCH 1 +#define MOD_CONFIG_FILE_GENERATION 0 #define MOD_CONFIG_FILE_VERSION \ - ((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION) + ((MOD_CONFIG_FILE_EPOCH * 1000000) + MOD_CONFIG_FILE_GENERATION) typedef struct _Config Config; typedef struct _Config_Item Config_Item; @@ -14,7 +14,7 @@ typedef struct _Config_Item Config_Item; struct _Config { - int version; + unsigned int config_version; Eina_List *instances, *items; const char *mod_dir; }; diff --git a/src/module/e_mod_main.c b/src/module/e_mod_main.c index 2c8753e..c9e017a 100644 --- a/src/module/e_mod_main.c +++ b/src/module/e_mod_main.c @@ -33,45 +33,16 @@ e_modapi_init(E_Module *m) E_CONFIG_VAL(item_edd, Config_Item, poll_time, DOUBLE); conf_edd = E_CONFIG_DD_NEW("Config", Config); + E_CONFIG_VAL(conf_edd, Config, config_version, UINT); E_CONFIG_LIST(conf_edd, Config, items, item_edd); weather_cfg = e_config_domain_load("module.eweather", conf_edd); - - if (weather_cfg) + if (weather_cfg) { - if ((weather_cfg->version >> 16) < MOD_CONFIG_FILE_EPOCH) + if (!e_util_module_config_check("EWeather", weather_cfg->config_version, MOD_CONFIG_FILE_VERSION)) { - /* config too old */ - //_weather_config_free(); - ecore_timer_add(1.0, _cb_cfg_timer, - D_("Weather 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 Weather 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 (weather_cfg->version > MOD_CONFIG_FILE_VERSION) - { - /* config too new */ _weather_config_free(); - ecore_timer_add(1.0, _cb_cfg_timer, - D_("Your Weather Module configuration is NEWER " - "than the Weather Module version. This is " - "very
strange. This should not happen unless" - " you downgraded
the Weather Module or " - "copied the configuration from a place where" - "
a newer version of the Weather Module " - "was running. This is bad and
as a " - "precaution your configuration has been now " - "restored to
defaults. Sorry for the " - "inconvenience.
")); + weather_cfg = NULL; } }