summaryrefslogtreecommitdiff
path: root/src/modules/ecore/system/tizen/ecore_system_tizen.c
diff options
context:
space:
mode:
authorJosé Roberto de Souza <jose.souza@intel.com>2013-08-14 16:06:22 -0300
committerJosé Roberto de Souza <jose.souza@intel.com>2013-08-15 14:46:30 -0300
commit76e69f9323f5a1ef87d8f9120b4f8d03498d526b (patch)
treed967b835ed26eddb56d32f3188ba05243ac5c805 /src/modules/ecore/system/tizen/ecore_system_tizen.c
parent914e05c2ad1a7c60aa36de82267b4a3e70fcfe71 (diff)
ecore system: Add Tizen backend
Diffstat (limited to '')
-rw-r--r--src/modules/ecore/system/tizen/ecore_system_tizen.c200
1 files changed, 200 insertions, 0 deletions
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 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Ecore.h>
6#include <vconf.h>
7#include <locale.h>
8
9static int _log_dom = -1;
10
11#ifdef CRITICAL
12#undef CRITICAL
13#endif
14#define CRITICAL(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__)
15
16#ifdef ERR
17#undef ERR
18#endif
19#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
20
21#ifdef WRN
22#undef WRN
23#endif
24#define WRN(...) EINA_LOG_DOM_WARN(_log_dom, __VA_ARGS__)
25
26#ifdef DBG
27#undef DBG
28#endif
29#define DBG(...) EINA_LOG_DOM_DBG(_log_dom, __VA_ARGS__)
30
31static void _low_mem_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED)
32{
33 int status;
34
35 if (vconf_get_int(VCONFKEY_SYSMAN_LOW_MEMORY, &status) < 0)
36 return;
37
38 if (status == VCONFKEY_SYSMAN_LOW_MEMORY_NORMAL)
39 ecore_memory_state_set(ECORE_MEMORY_STATE_NORMAL);
40 else
41 ecore_memory_state_set(ECORE_MEMORY_STATE_LOW);
42}
43
44static void _charge_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED)
45{
46 int charging, status;
47
48 if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &charging) < 0)
49 return;
50
51 if (charging)
52 {
53 ecore_power_state_set(ECORE_POWER_STATE_MAINS);
54 return;
55 }
56
57 if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &status) < 0)
58 return;
59
60 if (status == VCONFKEY_SYSMAN_BAT_NORMAL || status == VCONFKEY_SYSMAN_BAT_FULL)
61 ecore_power_state_set(ECORE_POWER_STATE_BATTERY);
62 else
63 ecore_power_state_set(ECORE_POWER_STATE_LOW);
64}
65
66static void _low_batt_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED)
67{
68 _charge_key_changed_cb(NULL, NULL);
69}
70
71static void _lang_key_changed_cb(keynode_t *node EINA_UNUSED, void *first)
72{
73 char *lang;
74
75 lang = vconf_get_str(VCONFKEY_LANGSET);
76 if (!lang)
77 return;
78
79 setenv("LANG", lang, 1);
80 setenv("LC_MESSAGES", lang, 1);
81 setlocale(__LC_ALL, "");
82
83 if (!first)
84 ecore_event_add(ECORE_EVENT_LOCALE_CHANGED, NULL, NULL, NULL);
85 free(lang);
86}
87
88static void _region_fmt_key_changed_cb(keynode_t *node EINA_UNUSED, void *first)
89{
90 char *region;
91
92 region = vconf_get_str(VCONFKEY_REGIONFORMAT);
93 if (!region)
94 return;
95
96 setenv("LC_CTYPE", region, 1);
97 setenv("LC_NUMERIC", region, 1);
98 setenv("LC_TIME", region, 1);
99 setenv("LC_COLLATE", region, 1);
100 setenv("LC_MONETARY", region, 1);
101 setenv("LC_PAPER", region, 1);
102 setenv("LC_NAME", region, 1);
103 setenv("LC_ADDRESS", region, 1);
104 setenv("LC_TELEPHONE", region, 1);
105 setenv("LC_MEASUREMENT", region, 1);
106 setenv("LC_IDENTIFICATION", region, 1);
107 setlocale(__LC_ALL, "");
108
109 if (!first)
110 ecore_event_add(ECORE_EVENT_LOCALE_CHANGED, NULL, NULL, NULL);
111 free(region);
112}
113
114static void _time_fmt_key_changed_cb(keynode_t *node EINA_UNUSED, void *data EINA_UNUSED)
115{
116 ecore_event_add(ECORE_EVENT_LOCALE_CHANGED, NULL, NULL, NULL);
117}
118
119static Eina_Bool
120_ecore_system_tizen_init(void)
121{
122 _log_dom = eina_log_domain_register("ecore_system_tizen", NULL);
123 if (_log_dom < 0)
124 {
125 EINA_LOG_ERR("Could not register log domain: ecore_system_tizen");
126 return EINA_FALSE;
127 }
128
129 if (vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, _low_mem_key_changed_cb, NULL) < 0)
130 {
131 ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_SYSMAN_LOW_MEMORY);
132 goto err_low_memory;
133 }
134 _low_mem_key_changed_cb(NULL, NULL);
135
136 if (vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, _charge_key_changed_cb, NULL) < 0)
137 {
138 ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW);
139 goto err_charge;
140 }
141
142 if (vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, _low_batt_key_changed_cb, NULL) < 0)
143 {
144 ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_SYSMAN_BATTERY_STATUS_LOW);
145 goto err_batt_status_low;
146 }
147 _low_batt_key_changed_cb(NULL, NULL);
148
149 if (vconf_notify_key_changed(VCONFKEY_LANGSET, _lang_key_changed_cb, NULL) < 0)
150 {
151 ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_LANGSET);
152 goto err_lang;
153 }
154 _lang_key_changed_cb(NULL, (void *)1);
155
156 if (vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, _region_fmt_key_changed_cb, NULL) < 0)
157 {
158 ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_REGIONFORMAT);
159 goto err_region_fmt;
160 }
161 _region_fmt_key_changed_cb(NULL, (void *)1);
162
163 if (vconf_notify_key_changed(VCONFKEY_REGIONFORMAT_TIME1224, _time_fmt_key_changed_cb, NULL) < 0)
164 {
165 ERR("Unable to register a vconf changed cb to %s.", VCONFKEY_REGIONFORMAT_TIME1224);
166 goto err_time_fmt;
167 }
168
169 return EINA_TRUE;
170
171err_time_fmt:
172 vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, _lang_key_changed_cb);
173err_region_fmt:
174 vconf_ignore_key_changed(VCONFKEY_LANGSET, _lang_key_changed_cb);
175err_lang:
176 vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, _low_batt_key_changed_cb);
177err_batt_status_low:
178 vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, _charge_key_changed_cb);
179err_charge:
180 vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, _low_mem_key_changed_cb);
181err_low_memory:
182 eina_log_domain_unregister(_log_dom);
183 _log_dom = -1;
184 return EINA_FALSE;
185}
186
187static void
188_ecore_system_tizen_shutdown(void)
189{
190 vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, _region_fmt_key_changed_cb);
191 vconf_ignore_key_changed(VCONFKEY_LANGSET, _lang_key_changed_cb);
192 vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, _low_batt_key_changed_cb);
193 vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, _charge_key_changed_cb);
194 vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, _low_mem_key_changed_cb);
195 eina_log_domain_unregister(_log_dom);
196 _log_dom = -1;
197}
198
199EINA_MODULE_INIT(_ecore_system_tizen_init);
200EINA_MODULE_SHUTDOWN(_ecore_system_tizen_shutdown);