parent
c5ebbe38c2
commit
8df6712483
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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<br> has been"
|
||||
" wiped and a new set of defaults initialized. "
|
||||
"This<br>will happen regularly during "
|
||||
"development, so don't report a<br>bug. "
|
||||
"This simply means Weather module needs "
|
||||
"new configuration<br>data by default for "
|
||||
"usable functionality that your old<br>"
|
||||
"configuration simply lacks. This new set of "
|
||||
"defaults will fix<br>that by adding it in. "
|
||||
"You can re-configure things now to your<br>"
|
||||
"liking. Sorry for the inconvenience.<br>"));
|
||||
}
|
||||
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<br>strange. This should not happen unless"
|
||||
" you downgraded<br>the Weather Module or "
|
||||
"copied the configuration from a place where"
|
||||
"<br>a newer version of the Weather Module "
|
||||
"was running. This is bad and<br>as a "
|
||||
"precaution your configuration has been now "
|
||||
"restored to<br>defaults. Sorry for the "
|
||||
"inconvenience.<br>"));
|
||||
weather_cfg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue