diff --git a/configure.ac b/configure.ac index ebb7a7bdb2..e89a678b63 100644 --- a/configure.ac +++ b/configure.ac @@ -1752,6 +1752,31 @@ AC_ARG_ENABLE([gstreamer], ], [want_gstreamer="yes"]) +AC_ARG_ENABLE([tizen], + [AC_HELP_STRING([--enable-tizen], + [enable tizen support. @<:@default=disabled@:>@])], + [ + if test "x${enableval}" = "xyes" ; then + want_tizen="yes" + else + want_tizen="no" + fi + ], + [want_tizen="no"]) + +if test "${want_tizen}" = "yes"; then + PKG_CHECK_MODULES([TIZEN_CONFIGURATION_MANAGER], + [vconf], + [have_tizen_vconf="yes"], + [have_tizen_vconf="no"]) + PKG_CHECK_MODULES([TIZEN_CONFIGURATION_MANAGER], [vconf]) +fi + +AM_CONDITIONAL([HAVE_TIZEN_CONFIGURATION_MANAGER], [test "${have_tizen_vconf}" = "yes"]) +if test "${have_tizen_vconf}" = "yes"; then + AC_DEFINE(HAVE_TIZEN_CONFIGURATION_MANAGER, 1, [Define to 1 if you have Tizen configuration manager(vconf).]) +fi + ### Default values if test "${have_windows}" = "yes"; then @@ -3234,23 +3259,10 @@ EFL_LIB_END([Efreet]) have_libmount_new="no" have_libmount_old="no" have_eeze_mount="no" -want_tizen="no" EFL_LIB_START_OPTIONAL([Eeze], [test "${have_linux}" = "yes"]) ### Additional options to configure -AC_ARG_ENABLE([tizen], - [AC_HELP_STRING([--enable-tizen], - [enable tizen support. @<:@default=disabled@:>@])], - [ - if test "x${enableval}" = "xyes" ; then - want_tizen="yes" - else - want_tizen="no" - fi - ], - [want_tizen="no"]) - AC_ARG_WITH([mount], [AS_HELP_STRING([--with-mount], [specify mount bin @<:@default=detect@:>@])], [with_eeze_mount=$withval], [with_eeze_mount="detect"]) diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am index c1fbf6b376..89cb328de9 100644 --- a/src/Makefile_Ecore.am +++ b/src/Makefile_Ecore.am @@ -105,6 +105,25 @@ modules_ecore_system_upower_module_la_DEPENDENCIES = \ modules_ecore_system_upower_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ modules_ecore_system_upower_module_la_LIBTOOLFLAGS = --tag=disable-static +# tizen + +if HAVE_TIZEN_CONFIGURATION_MANAGER +ecoretizenpkgdir = $(libdir)/ecore/system/tizen/$(MODULE_ARCH) +ecoretizenpkg_LTLIBRARIES = modules/ecore/system/tizen/module.la +modules_ecore_system_tizen_module_la_SOURCES = \ +modules/ecore/system/tizen/ecore_system_tizen.c +modules_ecore_system_tizen_module_la_CPPFLAGS = \ +-I$(top_builddir)/src/lib/efl \ +@ECORE_CFLAGS@ \ +@TIZEN_CONFIGURATION_MANAGER_CFLAGS@ +modules_ecore_system_tizen_module_la_LIBADD = \ +@USE_ECORE_LIBS@ \ +@TIZEN_CONFIGURATION_MANAGER_LIBS@ +modules_ecore_system_tizen_module_la_DEPENDENCIES = \ +@USE_ECORE_INTERNAL_LIBS@ +modules_ecore_system_tizen_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@ +modules_ecore_system_tizen_module_la_LIBTOOLFLAGS = --tag=disable-static +endif ### Unit tests diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index efdc344ce2..bd7f077a96 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -135,6 +135,9 @@ ecore_system_modules_load(void) const char *built_modules[] = { #ifdef HAVE_SYSTEMD "systemd", +#endif +#ifdef HAVE_TIZEN_CONFIGURATION_MANAGER + "tizen", #endif NULL }; diff --git a/src/modules/ecore/system/tizen/ecore_system_tizen.c b/src/modules/ecore/system/tizen/ecore_system_tizen.c new file mode 100644 index 0000000000..69c2cf78f0 --- /dev/null +++ b/src/modules/ecore/system/tizen/ecore_system_tizen.c @@ -0,0 +1,200 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include + +static int _log_dom = -1; + +#ifdef CRITICAL +#undef CRITICAL +#endif +#define CRITICAL(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__) + +#ifdef ERR +#undef ERR +#endif +#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__) + +#ifdef WRN +#undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__) + +#ifdef DBG +#undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__) + +static void _low_mem_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED) +{ + int status; + + if (vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &status) < 0) + return; + + if (status == VCONFKEY_SYSMAN_LOW_MEMORY_NORMAL) + ecore_memory_state_set(ECORE_MEMORY_STATE_NORMAL); + else + ecore_memory_state_set(ECORE_MEMORY_STATE_LOW); +} + +static void _charge_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED) +{ + int charging, status; + + if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &charging) < 0) + return; + + if (charging) + { + ecore_power_state_set(ECORE_POWER_STATE_MAINS); + return; + } + + if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &status) < 0) + return; + + if (status == VCONFKEY_SYSMAN_BAT_NORMAL || status == VCONFKEY_SYSMAN_BAT_FULL) + ecore_power_state_set(ECORE_POWER_STATE_BATTERY); + else + ecore_power_state_set(ECORE_POWER_STATE_LOW); +} + +static void _low_batt_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED) +{ + _charge_key_changed_cb(NULL, NULL); +} + +static void _lang_key_changed_cb(keynode_t *node EINA_UNUSED, void *first) +{ + char *lang; + + lang = vconf_get_str(VCONFKEY_LANGSET); + if (!lang) + return; + + setenv("LANG", lang, 1); + setenv("LC_MESSAGES", lang, 1); + setlocale(__LC_ALL, ""); + + if (!first) + ecore_event_add(ECORE_EVENT_LOCALE_CHANGED, NULL, NULL, NULL); + free(lang); +} + +static void _region_fmt_key_changed_cb(keynode_t *node EINA_UNUSED, void *first) +{ + char *region; + + region = vconf_get_str(VCONFKEY_REGIONFORMAT); + if (!region) + return; + + setenv("LC_CTYPE", region, 1); + setenv("LC_NUMERIC", region, 1); + setenv("LC_TIME", region, 1); + setenv("LC_COLLATE", region, 1); + setenv("LC_MONETARY", region, 1); + setenv("LC_PAPER", region, 1); + setenv("LC_NAME", region, 1); + setenv("LC_ADDRESS", region, 1); + setenv("LC_TELEPHONE", region, 1); + setenv("LC_MEASUREMENT", region, 1); + setenv("LC_IDENTIFICATION", region, 1); + setlocale(__LC_ALL, ""); + + if (!first) + ecore_event_add(ECORE_EVENT_LOCALE_CHANGED, NULL, NULL, NULL); + free(region); +} + +static void _time_fmt_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED) +{ + ecore_event_add(ECORE_EVENT_LOCALE_CHANGED, NULL, NULL, NULL); +} + +static Eina_Bool +_ecore_system_tizen_init(void) +{ + _log_dom = eina_log_domain_register("ecore_system_tizen", NULL); + if (_log_dom < 0) + { + EINA_LOG_ERR("Could not register log domain: ecore_system_tizen"); + return EINA_FALSE; + } + + if (vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, _low_mem_key_changed_cb, NULL) < 0) + { + ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_SYSMAN_LOW_MEMORY); + goto err_low_memory; + } + _low_mem_key_changed_cb(NULL, NULL); + + if (vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, _charge_key_changed_cb, NULL) < 0) + { + ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW); + goto err_charge; + } + + if (vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, _low_batt_key_changed_cb, NULL) < 0) + { + ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_SYSMAN_BATTERY_STATUS_LOW); + goto err_batt_status_low; + } + _low_batt_key_changed_cb(NULL, NULL); + + if (vconf_notify_key_changed(VCONFKEY_LANGSET, _lang_key_changed_cb, NULL) < 0) + { + ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_LANGSET); + goto err_lang; + } + _lang_key_changed_cb(NULL, (void *)1); + + if (vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, _region_fmt_key_changed_cb, NULL) < 0) + { + ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_REGIONFORMAT); + goto err_region_fmt; + } + _region_fmt_key_changed_cb(NULL, (void *)1); + + if (vconf_notify_key_changed(VCONFKEY_REGIONFORMAT_TIME1224, _time_fmt_key_changed_cb, NULL) < 0) + { + ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_REGIONFORMAT_TIME1224); + goto err_time_fmt; + } + + return EINA_TRUE; + +err_time_fmt: + vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, _lang_key_changed_cb); +err_region_fmt: + vconf_ignore_key_changed(VCONFKEY_LANGSET, _lang_key_changed_cb); +err_lang: + vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, _low_batt_key_changed_cb); +err_batt_status_low: + vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, _charge_key_changed_cb); +err_charge: + vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, _low_mem_key_changed_cb); +err_low_memory: + eina_log_domain_unregister(_log_dom); + _log_dom = -1; + return EINA_FALSE; +} + +static void +_ecore_system_tizen_shutdown(void) +{ + vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, _region_fmt_key_changed_cb); + vconf_ignore_key_changed(VCONFKEY_LANGSET, _lang_key_changed_cb); + vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, _low_batt_key_changed_cb); + vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, _charge_key_changed_cb); + vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, _low_mem_key_changed_cb); + eina_log_domain_unregister(_log_dom); + _log_dom = -1; +} + +EINA_MODULE_INIT(_ecore_system_tizen_init); +EINA_MODULE_SHUTDOWN(_ecore_system_tizen_shutdown);