added utility function to check module config version and show dialog when required. works with the common VERSION macros.

SVN revision: 48742
This commit is contained in:
Hannes Janetzek 2010-05-10 23:44:53 +00:00
parent 74317f724a
commit d62eb96fb4
2 changed files with 67 additions and 0 deletions

View File

@ -1475,3 +1475,69 @@ _e_util_image_import_handle_free(E_Util_Image_Import_Handle *handle)
E_FREE(handle);
}
static int
_e_util_conf_timer_old(void *data)
{
char *module_name = data;
char buf[4096];
char *msg =
_("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 the 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>");
snprintf(buf, sizeof(buf),N_("%s Configuration Updated"), module_name);
e_util_dialog_internal(buf, msg);
E_FREE(module_name);
return 0;
}
static int
_e_util_conf_timer_new(void *data)
{
char *module_name = data;
char buf[4096];
char *msg =
_("Your module configuration is NEWER "
"than the module version. This is "
"very<br>strange. This should not happen unless"
" you downgraded<br>the module or "
"copied the configuration from a place where"
"<br>a newer version of the 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>");
snprintf(buf, sizeof(buf),N_("%s Configuration Updated"), module_name);
e_util_dialog_internal(buf, msg);
E_FREE(module_name);
return 0;
}
EAPI Eina_Bool
e_util_module_config_check(const char *module_name, int conf, int epoch, int version)
{
if ((conf >> 16) < epoch)
{
ecore_timer_add(1.0, _e_util_conf_timer_old, strdup(module_name));
return EINA_FALSE;
}
else if (conf > version)
{
ecore_timer_add(1.0, _e_util_conf_timer_new, strdup(module_name));
return EINA_FALSE;
}
return EINA_TRUE;
}

View File

@ -71,6 +71,7 @@ EAPI int e_util_dir_check(const char *dir);
EAPI void e_util_defer_object_del(E_Object *obj);
EAPI const char *e_util_winid_str_get(Ecore_X_Window win);
EAPI void e_util_win_auto_resize_fill(E_Win *win);
EAPI Eina_Bool e_util_module_config_check(const char *module_name, int conf, int epoch, int version);
EAPI E_Dialog *e_util_image_import_settings_new(const char *path, void (*cb)(void *data, const char *path, Eina_Bool ok, Eina_Bool external, int quality, E_Image_Import_Mode mode), const void *data);
EAPI E_Util_Image_Import_Handle *e_util_image_import(const char *image_path, const char *edje_path, const char *edje_group, Eina_Bool external, int quality, E_Image_Import_Mode mode, void (*cb)(void *data, Eina_Bool ok, const char *image_path, const char *edje_path), const void *data);