From: Enlightenment S. <no-...@en...> - 2010-05-10 23:45:00
|
Log: added utility function to check module config version and show dialog when required. works with the common VERSION macros. Author: jeffdameth Date: 2010-05-10 16:44:53 -0700 (Mon, 10 May 2010) New Revision: 48742 Modified: trunk/e/src/bin/e_utils.c trunk/e/src/bin/e_utils.h Modified: trunk/e/src/bin/e_utils.c =================================================================== --- trunk/e/src/bin/e_utils.c 2010-05-10 22:35:42 UTC (rev 48741) +++ trunk/e/src/bin/e_utils.c 2010-05-10 23:44:53 UTC (rev 48742) @@ -1475,3 +1475,69 @@ 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; +} Modified: trunk/e/src/bin/e_utils.h =================================================================== --- trunk/e/src/bin/e_utils.h 2010-05-10 22:35:42 UTC (rev 48741) +++ trunk/e/src/bin/e_utils.h 2010-05-10 23:44:53 UTC (rev 48742) @@ -71,6 +71,7 @@ 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); |