3 E_API E_Config *e_config = NULL;
5 /* local subsystem functions */
6 static void _e_config_save_cb(void *data);
7 static void _e_config_free(E_Config *cfg);
8 static Eina_Bool _e_config_cb_timer(void *data);
9 static int _e_config_eet_close_handle(Eet_File *ef, char *file);
11 /* local subsystem globals */
12 static int _e_config_save_block = 0;
13 static const char *_e_config_profile = NULL;
14 static int _e_config_save_queued = 0;
15 static Ecore_Idle_Enterer *_idle_enter = NULL;
17 static E_Config_DD *_e_config_edd = NULL;
18 static E_Config_DD *_e_config_module_edd = NULL;
19 static E_Config_DD *_e_config_theme_edd = NULL;
20 static E_Config_DD *_e_config_desktop_bg_edd = NULL;
21 static E_Config_DD *_e_config_desklock_bg_edd = NULL;
22 static E_Config_DD *_e_config_desktop_name_edd = NULL;
23 static E_Config_DD *_e_config_desktop_window_profile_edd = NULL;
24 static E_Config_DD *_e_config_env_var_edd = NULL;
25 static E_Config_DD *_e_config_client_type_edd = NULL;
26 static E_Config_DD *_e_config_policy_desk_edd = NULL;
27 static E_Config_DD *_e_config_socket_access_edd = NULL;
28 static E_Config_DD *_e_config_aux_hint_supported_edd = NULL;
30 E_API int E_EVENT_CONFIG_MODE_CHANGED = 0;
33 static E_Dialog *_e_config_error_dialog = NULL;
36 _e_config_error_dialog_cb_delete(void *dia)
38 if (dia == _e_config_error_dialog)
39 _e_config_error_dialog = NULL;
44 _e_config_edd_shutdown(void)
46 E_CONFIG_DD_FREE(_e_config_edd);
47 E_CONFIG_DD_FREE(_e_config_module_edd);
48 E_CONFIG_DD_FREE(_e_config_theme_edd);
49 E_CONFIG_DD_FREE(_e_config_desktop_bg_edd);
50 E_CONFIG_DD_FREE(_e_config_desklock_bg_edd);
51 E_CONFIG_DD_FREE(_e_config_desktop_name_edd);
52 E_CONFIG_DD_FREE(_e_config_desktop_window_profile_edd);
53 E_CONFIG_DD_FREE(_e_config_env_var_edd);
54 E_CONFIG_DD_FREE(_e_config_client_type_edd);
55 E_CONFIG_DD_FREE(_e_config_policy_desk_edd);
56 E_CONFIG_DD_FREE(_e_config_socket_access_edd);
57 E_CONFIG_DD_FREE(_e_config_aux_hint_supported_edd);
61 _e_config_edd_init(Eina_Bool old)
63 _e_config_desktop_bg_edd = E_CONFIG_DD_NEW("E_Config_Desktop_Background", E_Config_Desktop_Background);
66 #define T E_Config_Desktop_Background
67 #define D _e_config_desktop_bg_edd
68 E_CONFIG_VAL(D, T, zone, INT);
69 E_CONFIG_VAL(D, T, desk_x, INT);
70 E_CONFIG_VAL(D, T, desk_y, INT);
71 E_CONFIG_VAL(D, T, file, STR);
73 _e_config_desktop_name_edd = E_CONFIG_DD_NEW("E_Config_Desktop_Name", E_Config_Desktop_Name);
76 #define T E_Config_Desktop_Name
77 #define D _e_config_desktop_name_edd
78 E_CONFIG_VAL(D, T, zone, INT);
79 E_CONFIG_VAL(D, T, desk_x, INT);
80 E_CONFIG_VAL(D, T, desk_y, INT);
81 E_CONFIG_VAL(D, T, name, STR);
83 _e_config_desktop_window_profile_edd = E_CONFIG_DD_NEW("E_Config_Desktop_Window_Profile", E_Config_Desktop_Window_Profile);
86 #define T E_Config_Desktop_Window_Profile
87 #define D _e_config_desktop_window_profile_edd
88 E_CONFIG_VAL(D, T, zone, INT);
89 E_CONFIG_VAL(D, T, desk_x, INT);
90 E_CONFIG_VAL(D, T, desk_y, INT);
91 E_CONFIG_VAL(D, T, profile, STR);
93 _e_config_module_edd = E_CONFIG_DD_NEW("E_Config_Module", E_Config_Module);
96 #define T E_Config_Module
97 #define D _e_config_module_edd
98 E_CONFIG_VAL(D, T, name, STR);
99 E_CONFIG_VAL(D, T, enabled, UCHAR);
100 E_CONFIG_VAL(D, T, delayed, UCHAR);
101 E_CONFIG_VAL(D, T, priority, INT);
103 _e_config_env_var_edd = E_CONFIG_DD_NEW("E_Config_Env_Var", E_Config_Env_Var);
106 #define T E_Config_Env_Var
107 #define D _e_config_env_var_edd
108 E_CONFIG_VAL(D, T, var, STR);
109 E_CONFIG_VAL(D, T, val, STR);
110 E_CONFIG_VAL(D, T, unset, UCHAR);
112 _e_config_client_type_edd = E_CONFIG_DD_NEW("E_Config_Client_Type", E_Config_Client_Type);
115 #define T E_Config_Client_Type
116 #define D _e_config_client_type_edd
117 E_CONFIG_VAL(D, T, name, STR);
118 E_CONFIG_VAL(D, T, clas, STR);
119 E_CONFIG_VAL(D, T, window_type, INT);
120 E_CONFIG_VAL(D, T, client_type, INT);
122 _e_config_policy_desk_edd = E_CONFIG_DD_NEW("E_Config_Policy_Desk", E_Config_Policy_Desk);
125 #define T E_Config_Policy_Desk
126 #define D _e_config_policy_desk_edd
127 E_CONFIG_VAL(D, T, zone_num, UINT);
128 E_CONFIG_VAL(D, T, x, INT);
129 E_CONFIG_VAL(D, T, y, INT);
130 E_CONFIG_VAL(D, T, enable, INT);
132 _e_config_socket_access_edd = E_CONFIG_DD_NEW("E_Config_Socket_Access", E_Config_Socket_Access);
135 #define T E_Config_Socket_Access
136 #define D _e_config_socket_access_edd
137 E_CONFIG_VAL(D, T, sock_access.use, UCHAR);
138 E_CONFIG_VAL(D, T, sock_access.name, STR);
139 E_CONFIG_VAL(D, T, sock_access.owner, STR);
140 E_CONFIG_VAL(D, T, sock_access.group, STR);
141 E_CONFIG_VAL(D, T, sock_access.permissions, INT);
142 E_CONFIG_VAL(D, T, sock_access.smack.use, UCHAR);
143 E_CONFIG_VAL(D, T, sock_access.smack.name, STR);
144 E_CONFIG_VAL(D, T, sock_access.smack.value, STR);
145 E_CONFIG_VAL(D, T, sock_access.smack.flags, INT);
146 E_CONFIG_VAL(D, T, sock_symlink_access.use, UCHAR);
147 E_CONFIG_VAL(D, T, sock_symlink_access.link_name, STR);
148 E_CONFIG_VAL(D, T, sock_symlink_access.owner, STR);
149 E_CONFIG_VAL(D, T, sock_symlink_access.group, STR);
150 E_CONFIG_VAL(D, T, sock_symlink_access.smack.name, STR);
151 E_CONFIG_VAL(D, T, sock_symlink_access.smack.value, STR);
152 E_CONFIG_VAL(D, T, sock_symlink_access.smack.flags, INT);
154 _e_config_aux_hint_supported_edd = E_CONFIG_DD_NEW("E_Config_Aux_Hint_Supported", E_Config_Aux_Hint_Supported);
157 #define T E_Config_Aux_Hint_Supported
158 #define D _e_config_aux_hint_supported_edd
159 E_CONFIG_VAL(D, T, name, STR);
161 _e_config_edd = E_CONFIG_DD_NEW("E_Config", E_Config);
165 #define D _e_config_edd
166 /**/ /* == already configurable via ipc */
167 E_CONFIG_VAL(D, T, config_version, INT);
168 E_CONFIG_VAL(D, T, desktop_default_background, STR);
169 E_CONFIG_VAL(D, T, desktop_default_name, STR);
170 E_CONFIG_VAL(D, T, desktop_default_window_profile, STR);
171 E_CONFIG_LIST(D, T, desktop_backgrounds, _e_config_desktop_bg_edd);
172 E_CONFIG_LIST(D, T, desktop_names, _e_config_desktop_name_edd);
173 E_CONFIG_LIST(D, T, desktop_window_profiles, _e_config_desktop_window_profile_edd);
174 E_CONFIG_VAL(D, T, framerate, DOUBLE);
175 E_CONFIG_VAL(D, T, priority, INT);
176 E_CONFIG_VAL(D, T, zone_desks_x_count, INT);
177 E_CONFIG_VAL(D, T, zone_desks_y_count, INT);
178 E_CONFIG_LIST(D, T, modules, _e_config_module_edd);
179 E_CONFIG_VAL(D, T, window_placement_policy, INT);
180 E_CONFIG_VAL(D, T, use_e_policy, INT);
181 E_CONFIG_VAL(D, T, launcher.title, STR);
182 E_CONFIG_VAL(D, T, launcher.clas, STR);
183 E_CONFIG_VAL(D, T, launcher.type, UINT);
184 E_CONFIG_LIST(D, T, policy_desks, _e_config_policy_desk_edd);
185 E_CONFIG_VAL(D, T, use_softkey_service, INT);
186 E_CONFIG_VAL(D, T, use_softkey, INT);
187 E_CONFIG_VAL(D, T, softkey_size, INT);
188 E_CONFIG_VAL(D, T, focus_policy, INT);
189 E_CONFIG_VAL(D, T, focus_policy_ext, INT);
190 E_CONFIG_VAL(D, T, focus_setting, INT);
191 E_CONFIG_VAL(D, T, always_click_to_raise, INT);
192 E_CONFIG_VAL(D, T, always_click_to_focus, INT);
193 E_CONFIG_VAL(D, T, use_auto_raise, INT);
194 E_CONFIG_VAL(D, T, maximize_policy, INT);
195 E_CONFIG_VAL(D, T, allow_manip, INT);
196 E_CONFIG_VAL(D, T, kill_if_close_not_possible, INT);
197 E_CONFIG_VAL(D, T, kill_process, INT);
198 E_CONFIG_VAL(D, T, kill_timer_wait, DOUBLE);
199 E_CONFIG_VAL(D, T, ping_clients, INT);
200 E_CONFIG_VAL(D, T, use_e_cursor, INT);
201 E_CONFIG_VAL(D, T, cursor_size, INT);
202 E_CONFIG_VAL(D, T, transient.move, INT);
203 E_CONFIG_VAL(D, T, transient.resize, INT);
204 E_CONFIG_VAL(D, T, transient.raise, INT);
205 E_CONFIG_VAL(D, T, transient.lower, INT);
206 E_CONFIG_VAL(D, T, transient.layer, INT);
207 E_CONFIG_VAL(D, T, transient.desktop, INT);
208 E_CONFIG_VAL(D, T, transient.iconify, INT);
209 E_CONFIG_VAL(D, T, fullscreen_policy, INT);
210 E_CONFIG_VAL(D, T, dpms_enable, INT);
211 E_CONFIG_VAL(D, T, dpms_standby_enable, INT);
212 E_CONFIG_VAL(D, T, dpms_suspend_enable, INT);
213 E_CONFIG_VAL(D, T, dpms_off_enable, INT);
214 E_CONFIG_VAL(D, T, dpms_standby_timeout, INT);
215 E_CONFIG_VAL(D, T, dpms_suspend_timeout, INT);
216 E_CONFIG_VAL(D, T, dpms_off_timeout, INT);
217 E_CONFIG_VAL(D, T, no_dpms_on_fullscreen, UCHAR);
218 E_CONFIG_VAL(D, T, mouse_hand, INT);
219 E_CONFIG_VAL(D, T, border_raise_on_mouse_action, INT);
220 E_CONFIG_VAL(D, T, border_raise_on_focus, INT);
221 E_CONFIG_VAL(D, T, raise_on_revert_focus, INT);
222 E_CONFIG_VAL(D, T, theme_default_border_style, STR);
223 E_CONFIG_VAL(D, T, screen_limits, INT);
224 E_CONFIG_VAL(D, T, ping_clients_interval, INT);
225 E_CONFIG_VAL(D, T, border_keyboard.timeout, DOUBLE);
226 E_CONFIG_VAL(D, T, border_keyboard.move.dx, UCHAR);
227 E_CONFIG_VAL(D, T, border_keyboard.move.dy, UCHAR);
228 E_CONFIG_VAL(D, T, border_keyboard.resize.dx, UCHAR);
229 E_CONFIG_VAL(D, T, border_keyboard.resize.dy, UCHAR);
230 E_CONFIG_VAL(D, T, scale.min, DOUBLE);
231 E_CONFIG_VAL(D, T, scale.max, DOUBLE);
232 E_CONFIG_VAL(D, T, scale.factor, DOUBLE);
233 E_CONFIG_VAL(D, T, scale.profile_factor, DOUBLE);
234 E_CONFIG_VAL(D, T, scale.inch_correction, DOUBLE);
235 E_CONFIG_VAL(D, T, scale.inch_correction_bound, DOUBLE);
236 E_CONFIG_VAL(D, T, scale.base_dpi, INT);
237 E_CONFIG_VAL(D, T, scale.use_dpi, UCHAR);
238 E_CONFIG_VAL(D, T, scale.use_custom, UCHAR);
239 E_CONFIG_VAL(D, T, scale.for_tdm, UCHAR);
240 E_CONFIG_VAL(D, T, show_cursor, UCHAR);
241 E_CONFIG_VAL(D, T, idle_cursor, UCHAR);
242 E_CONFIG_LIST(D, T, env_vars, _e_config_env_var_edd);
243 E_CONFIG_VAL(D, T, xkb.only_label, INT);
244 E_CONFIG_VAL(D, T, xkb.default_model, STR);
245 E_CONFIG_VAL(D, T, xkb.dont_touch_my_damn_keyboard, UCHAR);
246 E_CONFIG_VAL(D, T, xkb.use_cache, UCHAR);
247 E_CONFIG_VAL(D, T, xkb.delay_held_key_input_to_focus, UINT);
248 E_CONFIG_VAL(D, T, xkb.default_rmlvo.rules, STR);
249 E_CONFIG_VAL(D, T, xkb.default_rmlvo.model, STR);
250 E_CONFIG_VAL(D, T, xkb.default_rmlvo.layout, STR);
251 E_CONFIG_VAL(D, T, xkb.default_rmlvo.variant, STR);
252 E_CONFIG_VAL(D, T, xkb.default_rmlvo.options, STR);
253 E_CONFIG_VAL(D, T, keyboard.repeat_delay, INT);
254 E_CONFIG_VAL(D, T, keyboard.repeat_rate, INT);
255 E_CONFIG_VAL(D, T, use_desktop_window_profile, INT);
256 #ifdef _F_ZONE_WINDOW_ROTATION_
257 E_CONFIG_VAL(D, T, wm_win_rotation, UCHAR);
259 E_CONFIG_VAL(D, T, screen_rotation_pre, UINT);
260 E_CONFIG_VAL(D, T, screen_rotation_setting, UINT);
261 E_CONFIG_VAL(D, T, screen_rotation_client_ignore, UCHAR);
262 E_CONFIG_VAL(D, T, eom_enable, UCHAR);
263 E_CONFIG_VAL(D, T, use_cursor_timer, INT);
264 E_CONFIG_VAL(D, T, cursor_timer_interval, INT);
265 E_CONFIG_LIST(D, T, client_types, _e_config_client_type_edd);
266 E_CONFIG_VAL(D, T, comp_shadow_file, STR);
267 E_CONFIG_VAL(D, T, sleep_for_dri, INT);
268 E_CONFIG_VAL(D, T, create_wm_ready, INT);
269 E_CONFIG_VAL(D, T, create_wm_start, INT);
270 E_CONFIG_VAL(D, T, comp_canvas_bg.r, UCHAR);
271 E_CONFIG_VAL(D, T, comp_canvas_bg.g, UCHAR);
272 E_CONFIG_VAL(D, T, comp_canvas_bg.b, UCHAR);
273 E_CONFIG_VAL(D, T, comp_canvas_bg.a, UCHAR);
274 E_CONFIG_VAL(D, T, comp_canvas_bg.opmode, INT);
275 E_CONFIG_VAL(D, T, delayed_load_idle_count, INT);
276 E_CONFIG_VAL(D, T, use_buffer_flush, UCHAR);
277 E_CONFIG_VAL(D, T, use_desk_smart_obj, UCHAR);
278 E_CONFIG_LIST(D, T, sock_accesses, _e_config_socket_access_edd);
279 E_CONFIG_LIST(D, T, aux_hint_supported, _e_config_aux_hint_supported_edd);
280 E_CONFIG_VAL(D, T, use_module_srv.qp, UCHAR);
281 E_CONFIG_VAL(D, T, launchscreen_timeout, DOUBLE);
282 E_CONFIG_VAL(D, T, enable_conformant_ack, UCHAR);
283 E_CONFIG_VAL(D, T, conformant_ack_timeout, DOUBLE);
284 E_CONFIG_VAL(D, T, calc_vis_without_effect, UCHAR);
285 E_CONFIG_VAL(D, T, save_win_buffer, UCHAR);
286 E_CONFIG_VAL(D, T, hold_prev_win_img, UCHAR);
287 E_CONFIG_VAL(D, T, indicator_plug_name, STR);
288 E_CONFIG_VAL(D, T, launchscreen_without_timer, UCHAR);
289 E_CONFIG_VAL(D, T, log_type, INT);
290 E_CONFIG_VAL(D, T, rsm_buffer_release_mode, INT);
291 E_CONFIG_VAL(D, T, deiconify_approve, UCHAR);
292 E_CONFIG_VAL(D, T, use_pp_zoom, UCHAR);
293 E_CONFIG_VAL(D, T, priority_control, UCHAR);
294 E_CONFIG_VAL(D, T, comp_canvas_norender.use, UCHAR);
295 E_CONFIG_VAL(D, T, qp_handler.use_alpha, UCHAR);
296 E_CONFIG_VAL(D, T, qp_handler.alpha, INT);
300 _e_config_idle_cb(void *data)
302 if (_e_config_save_queued)
304 _e_config_save_cb(NULL);
305 _e_config_save_queued = 0;
308 return ECORE_CALLBACK_RENEW;
311 /* externally accessible functions */
315 E_EVENT_CONFIG_MODE_CHANGED = ecore_event_type_new();
317 /* TIZEN_ONLY: We don't save e.cfg file.
318 * Sometimes e.cfg file was broken after writing.
320 if (getenv("E_CONF_RO")) e_config_save_block_set(1);
322 /* if environment var set - use this profile name */
323 char *s = e_util_env_get("E_CONF_PROFILE");
326 _e_config_profile = eina_stringshare_add(s);
330 _e_config_edd_init(EINA_FALSE);
333 EINA_SAFETY_ON_NULL_RETURN_VAL(e_config, 0);
335 e_config_save_queue();
337 _idle_enter = ecore_idle_enterer_add(_e_config_idle_cb, NULL);
342 e_config_shutdown(void)
344 if (_idle_enter) ecore_idle_enterer_del(_idle_enter);
347 eina_stringshare_del(_e_config_profile);
349 _e_config_edd_shutdown();
359 e_config = e_config_domain_load("e", _e_config_edd);
362 /* major version change - that means wipe and restart */
363 if ((e_config->config_version) < E_CONFIG_FILE_EPOCH * 1000000)
365 /* your config is too old - need new defaults */
366 _e_config_free(e_config);
369 ecore_timer_add(1.0, _e_config_cb_timer,
370 _("Settings data needed upgrading. Your old settings have<br>"
371 "been wiped and a new set of defaults initialized. This<br>"
372 "will happen regularly during development, so don't report a<br>"
373 "bug. This simply means Enlightenment needs new settings<br>"
374 "data by default for usable functionality that your old<br>"
375 "settings simply lack. This new set of defaults will fix<br>"
376 "that by adding it in. You can re-configure things now to your<br>"
377 "liking. Sorry for the hiccup in your settings.<br>"));
379 /* config is too new? odd! suspect corruption? */
380 else if (e_config->config_version > E_CONFIG_FILE_VERSION)
382 /* your config is too new - what the fuck??? */
383 _e_config_free(e_config);
386 ecore_timer_add(1.0, _e_config_cb_timer,
387 _("Your settings are NEWER than Enlightenment. This is very<br>"
388 "strange. This should not happen unless you downgraded<br>"
389 "Enlightenment or copied the settings from a place where<br>"
390 "a newer version of Enlightenment was running. This is bad and<br>"
391 "as a precaution your settings have been now restored to<br>"
392 "defaults. Sorry for the inconvenience.<br>"));
396 e_config_profile_del(e_config_profile_get());
397 e_config_profile_set("default");
398 e_config = e_config_domain_load("e", _e_config_edd);
403 _e_config_edd_shutdown();
404 _e_config_edd_init(EINA_TRUE);
405 e_config = e_config_domain_load("e", _e_config_edd);
406 /* I made a c&p error here and fucked the world, so this ugliness
407 * will be my public mark of shame until E :/
412 /* this is essentially CONFIG_VERSION_CHECK(7) */
413 INF("Performing config upgrade to %d.%d", 1, 7);
414 _e_config_edd_shutdown();
415 _e_config_edd_init(EINA_FALSE);
420 e_config_profile_set("default");
421 if (!reload) e_config_profile_del(e_config_profile_get());
422 if (getenv("E_CONF_RO")) e_config_save_block_set(1);
423 e_error_message_show(_("Could not load e.cfg"));
427 #define CONFIG_VERSION_CHECK(VERSION) \
428 if (e_config->config_version - (E_CONFIG_FILE_EPOCH * 1000000) < (VERSION))
430 #define CONFIG_VERSION_UPDATE_INFO(VERSION) \
431 INF("Performing config upgrade for %d.%d", E_CONFIG_FILE_EPOCH, VERSION);
433 if (e_config->config_version < E_CONFIG_FILE_VERSION)
435 CONFIG_VERSION_CHECK(18)
439 CONFIG_VERSION_CHECK(19)
441 CONFIG_VERSION_UPDATE_INFO(19);
443 /* set (400, 25) as the default values of repeat delay, rate */
444 e_config->keyboard.repeat_delay = 400;
445 e_config->keyboard.repeat_rate = 25;
449 e_config->config_version = E_CONFIG_FILE_VERSION;
451 /* limit values so they are sane */
452 E_CONFIG_LIMIT(e_config->framerate, 1.0, 200.0);
453 E_CONFIG_LIMIT(e_config->priority, 0, 19);
454 E_CONFIG_LIMIT(e_config->zone_desks_x_count, 1, 64);
455 E_CONFIG_LIMIT(e_config->zone_desks_y_count, 1, 64);
456 E_CONFIG_LIMIT(e_config->use_e_policy, 0, 1);
457 E_CONFIG_LIMIT(e_config->use_softkey_service, 0, 1);
458 E_CONFIG_LIMIT(e_config->use_softkey, 0, 1);
459 E_CONFIG_LIMIT(e_config->softkey_size, 0, 42);
460 E_CONFIG_LIMIT(e_config->window_placement_policy, E_WINDOW_PLACEMENT_SMART, E_WINDOW_PLACEMENT_MANUAL);
461 E_CONFIG_LIMIT(e_config->focus_policy, 0, 2);
462 E_CONFIG_LIMIT(e_config->focus_policy_ext, 0, 1);
463 E_CONFIG_LIMIT(e_config->focus_setting, 0, 3);
464 E_CONFIG_LIMIT(e_config->always_click_to_raise, 0, 1);
465 E_CONFIG_LIMIT(e_config->always_click_to_focus, 0, 1);
466 E_CONFIG_LIMIT(e_config->use_auto_raise, 0, 1);
467 E_CONFIG_LIMIT(e_config->maximize_policy, E_MAXIMIZE_FULLSCREEN, E_MAXIMIZE_DIRECTION);
468 E_CONFIG_LIMIT(e_config->allow_manip, 0, 1);
469 E_CONFIG_LIMIT(e_config->kill_if_close_not_possible, 0, 1);
470 E_CONFIG_LIMIT(e_config->kill_process, 0, 1);
471 E_CONFIG_LIMIT(e_config->kill_timer_wait, 0.0, 120.0);
472 E_CONFIG_LIMIT(e_config->ping_clients, 0, 1);
473 E_CONFIG_LIMIT(e_config->use_e_cursor, 0, 1);
474 E_CONFIG_LIMIT(e_config->cursor_size, 0, 1024);
475 E_CONFIG_LIMIT(e_config->dpms_enable, 0, 1);
476 E_CONFIG_LIMIT(e_config->dpms_standby_enable, 0, 1);
477 E_CONFIG_LIMIT(e_config->dpms_suspend_enable, 0, 1);
478 E_CONFIG_LIMIT(e_config->dpms_off_enable, 0, 1);
479 E_CONFIG_LIMIT(e_config->dpms_standby_timeout, 30, 5400);
480 E_CONFIG_LIMIT(e_config->dpms_suspend_timeout, 30, 5400);
481 E_CONFIG_LIMIT(e_config->dpms_off_timeout, 30, 5400);
482 E_CONFIG_LIMIT(e_config->mouse_hand, 0, 1);
483 E_CONFIG_LIMIT(e_config->border_raise_on_mouse_action, 0, 1);
484 E_CONFIG_LIMIT(e_config->border_raise_on_focus, 0, 1);
485 E_CONFIG_LIMIT(e_config->raise_on_revert_focus, 0, 1);
486 E_CONFIG_LIMIT(e_config->screen_limits, 0, 2);
487 E_CONFIG_LIMIT(e_config->ping_clients_interval, 16, 1024);
488 E_CONFIG_LIMIT(e_config->border_keyboard.move.dx, 1, 255);
489 E_CONFIG_LIMIT(e_config->border_keyboard.move.dy, 1, 255);
490 E_CONFIG_LIMIT(e_config->border_keyboard.resize.dx, 1, 255);
491 E_CONFIG_LIMIT(e_config->border_keyboard.resize.dy, 1, 255);
492 E_CONFIG_LIMIT(e_config->show_cursor, 0, 1);
493 E_CONFIG_LIMIT(e_config->xkb.delay_held_key_input_to_focus, 0,5000); // 5000(ms) == 5(s)
494 E_CONFIG_LIMIT(e_config->keyboard.repeat_delay, -1, 1000); // 1 second
495 E_CONFIG_LIMIT(e_config->keyboard.repeat_rate, -1, 1000); // 1 second
496 E_CONFIG_LIMIT(e_config->screen_rotation_pre, 0, 270);
497 E_CONFIG_LIMIT(e_config->screen_rotation_setting, 0, 270);
498 E_CONFIG_LIMIT(e_config->screen_rotation_client_ignore, 0, 1);
499 E_CONFIG_LIMIT(e_config->eom_enable, 0, 1);
500 E_CONFIG_LIMIT(e_config->use_cursor_timer, 0, 1);
501 E_CONFIG_LIMIT(e_config->sleep_for_dri, 0, 1);
502 E_CONFIG_LIMIT(e_config->create_wm_ready, 0, 1);
503 E_CONFIG_LIMIT(e_config->create_wm_start, 0, 1);
504 E_CONFIG_LIMIT(e_config->comp_canvas_bg.r, 0, 255);
505 E_CONFIG_LIMIT(e_config->comp_canvas_bg.g, 0, 255);
506 E_CONFIG_LIMIT(e_config->comp_canvas_bg.b, 0, 255);
507 E_CONFIG_LIMIT(e_config->comp_canvas_bg.a, 0, 255);
508 E_CONFIG_LIMIT(e_config->comp_canvas_bg.opmode, 0, 11);
509 E_CONFIG_LIMIT(e_config->delayed_load_idle_count, 0, 100);
510 E_CONFIG_LIMIT(e_config->use_buffer_flush, 0, 1);
511 E_CONFIG_LIMIT(e_config->use_desk_smart_obj, 0, 1);
512 E_CONFIG_LIMIT(e_config->use_module_srv.qp, 0, 1);
513 E_CONFIG_LIMIT(e_config->launchscreen_timeout, 7.0, 100.0);
514 E_CONFIG_LIMIT(e_config->enable_conformant_ack, 0, 1);
515 E_CONFIG_LIMIT(e_config->conformant_ack_timeout, 3.0, 100.0);
516 E_CONFIG_LIMIT(e_config->calc_vis_without_effect, 0, 1);
517 E_CONFIG_LIMIT(e_config->save_win_buffer, 0, 1);
518 E_CONFIG_LIMIT(e_config->hold_prev_win_img, 0, 1);
519 E_CONFIG_LIMIT(e_config->launchscreen_without_timer, 0, 1);
520 E_CONFIG_LIMIT(e_config->log_type, 0, 255);
521 E_CONFIG_LIMIT(e_config->rsm_buffer_release_mode, 0, 2);
522 E_CONFIG_LIMIT(e_config->deiconify_approve, 0, 1);
523 E_CONFIG_LIMIT(e_config->use_pp_zoom, 0, 1);
524 E_CONFIG_LIMIT(e_config->priority_control, 0, 1);
525 E_CONFIG_LIMIT(e_config->comp_canvas_norender.use, 0, 1);
526 E_CONFIG_LIMIT(e_config->qp_handler.use_alpha, 0, 1);
527 E_CONFIG_LIMIT(e_config->qp_handler.alpha, 0, 255);
533 _e_config_save_cb(NULL);
534 return e_config_domain_save("e", _e_config_edd, e_config);
538 e_config_save_queue(void)
540 // TODO: add ecore_timer_add and call _e_config_save_cb
541 //_e_config_save_cb(NULL) moved to be called in idle time
542 _e_config_save_queued = 1;
546 e_config_profile_get(void)
548 return _e_config_profile;
552 e_config_profile_set(const char *prof)
554 eina_stringshare_replace(&_e_config_profile, prof);
555 e_util_env_set("E_CONF_PROFILE", _e_config_profile);
559 e_config_profile_dir_get(const char *prof)
563 e_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
564 if (ecore_file_is_dir(buf)) return strdup(buf);
565 e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s", prof);
566 if (ecore_file_is_dir(buf)) return strdup(buf);
571 _cb_sort_files(char *f1, char *f2)
573 return strcmp(f1, f2);
577 e_config_profile_list(void)
580 char buf[PATH_MAX], *p;
581 Eina_List *flist = NULL;
584 len = e_user_dir_concat_static(buf, "config");
585 if (len + 1 >= (int)sizeof(buf))
588 files = ecore_file_ls(buf);
594 len = sizeof(buf) - len;
599 files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
600 EINA_LIST_FREE(files, file)
602 if (eina_strlcpy(p, file, len) >= len)
607 if (ecore_file_is_dir(buf))
608 flist = eina_list_append(flist, file);
613 len = e_prefix_data_concat_static(buf, "data/config");
614 if (len + 1 >= sizeof(buf))
617 files = ecore_file_ls(buf);
623 len = sizeof(buf) - len;
627 files = eina_list_sort(files, 0, (Eina_Compare_Cb)_cb_sort_files);
628 EINA_LIST_FREE(files, file)
630 if (eina_strlcpy(p, file, len) >= len)
635 if (ecore_file_is_dir(buf))
639 EINA_LIST_FOREACH(flist, l, tmp)
640 if (!strcmp(file, tmp)) break;
642 if (!l) flist = eina_list_append(flist, file);
653 e_config_profile_add(const char *prof)
656 if (e_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof) >= sizeof(buf))
658 ecore_file_mkdir(buf);
662 e_config_profile_del(const char *prof)
665 if (e_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof) >= sizeof(buf))
667 ecore_file_recursive_rm(buf);
671 e_config_save_block_set(int block)
673 _e_config_save_block = block;
677 e_config_save_block_get(void)
679 return _e_config_save_block;
683 _e_config_domain_user_load(const char *domain, E_Config_DD *edd)
689 e_user_dir_snprintf(buf, sizeof(buf), "config/%s/%s.cfg",
690 _e_config_profile, domain);
691 ef = eet_open(buf, EET_FILE_MODE_READ);
694 data = eet_data_read(ef, edd, "config");
695 _e_config_eet_close_handle(ef, buf);
698 ELOGF("CFG", "Loaded %s", NULL, buf);
703 ELOGF("CFG", "Could not load %s", NULL, buf);
709 * Loads configurations from file located in the working profile
710 * The configurations are stored in a struct declated by the
711 * macros E_CONFIG_DD_NEW and E_CONFIG_<b>TYPE</b>
713 * @param domain of the configuration file.
714 * @param edd to struct definition
715 * @return returns allocated struct on success, if unable to find config returns null
718 e_config_domain_load(const char *domain, E_Config_DD *edd)
720 if (getenv("E_CONF_RO"))
722 return e_config_domain_system_load(domain, edd);
726 void *data = _e_config_domain_user_load(domain, edd);
730 // load data from system and save it for next loading
731 void *sys_data = e_config_domain_system_load(domain, edd);
732 e_config_domain_save(domain, edd, sys_data);
733 data = _e_config_domain_user_load(domain, edd);
735 if (data) return data;
737 ELOGF("CFG", "Enlightenment has an error again while loading domain %s", NULL, domain);
740 return e_config_domain_system_load(domain, edd);
744 e_config_domain_system_load(const char *domain, E_Config_DD *edd)
750 e_prefix_data_snprintf(buf, sizeof(buf), "data/config/%s/%s.cfg",
751 _e_config_profile, domain);
752 ef = eet_open(buf, EET_FILE_MODE_READ);
755 data = eet_data_read(ef, edd, "config");
756 _e_config_eet_close_handle(ef, buf);
759 ELOGF("CFG", "Loaded %s", NULL, buf);
763 ELOGF("CFG", "Could not read data %s", NULL, buf);
766 ELOGF("CFG", "Could not load %s", NULL, buf);
773 _e_config_mv_error(const char *from, const char *to)
778 if (_e_config_error_dialog) return;
780 dia = e_dialog_new(NULL, "E", "_sys_error_logout_slow");
781 EINA_SAFETY_ON_NULL_RETURN(dia);
783 e_dialog_title_set(dia, _("Enlightenment Settings Write Problems"));
784 e_dialog_icon_set(dia, "dialog-error", 64);
785 snprintf(buf, sizeof(buf),
786 _("Enlightenment has had an error while moving config files<br>"
793 "The rest of the write has been aborted for safety.<br>"),
795 e_dialog_text_set(dia, buf);
796 e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
797 e_dialog_button_focus_num(dia, 0);
798 //elm_win_center(dia->win, 1, 1);
799 e_object_del_attach_func_set(E_OBJECT(dia),
800 _e_config_error_dialog_cb_delete);
802 _e_config_error_dialog = dia;
807 e_config_profile_save(void)
811 char buf[4096], buf2[4096];
814 /* FIXME: check for other sessions fo E running */
815 e_user_dir_concat_static(buf, "config/profile.cfg");
816 e_user_dir_concat_static(buf2, "config/profile.cfg.tmp");
818 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
821 ok = eet_write(ef, "config", _e_config_profile,
822 strlen(_e_config_profile), 0);
823 if (_e_config_eet_close_handle(ef, buf2))
825 Eina_Bool ret = EINA_TRUE;
827 if (_e_config_revisions > 0)
830 char bsrc[4096], bdst[4096];
832 for (i = _e_config_revisions; i > 1; i--)
834 e_user_dir_snprintf(bsrc, sizeof(bsrc), "config/profile.%i.cfg", i - 1);
835 e_user_dir_snprintf(bdst, sizeof(bdst), "config/profile.%i.cfg", i);
836 if ((ecore_file_exists(bsrc)) &&
837 (ecore_file_size(bsrc)))
839 ret = ecore_file_mv(bsrc, bdst);
842 _e_config_mv_error(bsrc, bdst);
849 e_user_dir_snprintf(bsrc, sizeof(bsrc), "config/profile.cfg");
850 e_user_dir_snprintf(bdst, sizeof(bdst), "config/profile.1.cfg");
851 ret = ecore_file_mv(bsrc, bdst);
853 // _e_config_mv_error(bsrc, bdst);
856 ret = ecore_file_mv(buf2, buf);
857 if (!ret) _e_config_mv_error(buf2, buf);
859 ecore_file_unlink(buf2);
868 * Saves configurations to file located in the working profile
869 * The configurations are read from a struct declated by the
870 * macros E_CONFIG_DD_NEW and E_CONFIG_<b>TYPE</b>
872 * @param domain name of the configuration file.
873 * @param edd pointer to struct definition
874 * @param data struct to save as configuration file
875 * @return 1 if save success, 0 on failure
878 e_config_domain_save(const char *domain, E_Config_DD *edd, const void *data)
881 char buf[4096], buf2[4096];
885 if (_e_config_save_block) return 0;
886 /* FIXME: check for other sessions fo E running */
887 len = e_user_dir_snprintf(buf, sizeof(buf), "config/%s", _e_config_profile);
888 if (len + 1 >= sizeof(buf)) return 0;
890 ecore_file_mkdir(buf);
895 len2 = eina_strlcpy(buf + len, domain, sizeof(buf) - len);
896 if (len2 + sizeof(".cfg") >= sizeof(buf) - len) return 0;
900 memcpy(buf + len, ".cfg", sizeof(".cfg"));
901 len += sizeof(".cfg") - 1;
903 if (len + sizeof(".tmp") >= sizeof(buf)) return 0;
904 memcpy(buf2, buf, len);
905 memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
907 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
910 ok = eet_data_write(ef, edd, "config", data, 1);
911 if (_e_config_eet_close_handle(ef, buf2))
913 ret = ecore_file_mv(buf2, buf);
915 ERR("*** Error saving config. ***");
917 ecore_file_unlink(buf2);
923 e_config_mode_changed(void)
925 ecore_event_add(E_EVENT_CONFIG_MODE_CHANGED, NULL, NULL, NULL);
928 /* local subsystem functions */
930 _e_config_save_cb(void *data EINA_UNUSED)
932 e_config_profile_save();
934 e_config_domain_save("e", _e_config_edd, e_config);
938 _e_config_free(E_Config *ecf)
941 E_Config_Env_Var *evr;
942 E_Config_Desktop_Window_Profile *wp;
943 E_Config_Policy_Desk *pd;
944 E_Config_Socket_Access *sa;
945 E_Config_Aux_Hint_Supported *auxhint;
949 EINA_LIST_FREE(ecf->desktop_window_profiles, wp)
951 eina_stringshare_del(wp->profile);
955 eina_stringshare_del(ecf->xkb.default_model);
956 eina_stringshare_del(ecf->xkb.default_rmlvo.rules);
957 eina_stringshare_del(ecf->xkb.default_rmlvo.model);
958 eina_stringshare_del(ecf->xkb.default_rmlvo.layout);
959 eina_stringshare_del(ecf->xkb.default_rmlvo.variant);
960 eina_stringshare_del(ecf->xkb.default_rmlvo.options);
962 EINA_LIST_FREE(ecf->modules, em)
964 if (em->name) eina_stringshare_del(em->name);
967 if (ecf->comp_shadow_file) eina_stringshare_del(ecf->comp_shadow_file);
968 if (ecf->desktop_default_background) eina_stringshare_del(ecf->desktop_default_background);
969 if (ecf->desktop_default_name) eina_stringshare_del(ecf->desktop_default_name);
970 if (ecf->desktop_default_window_profile) eina_stringshare_del(ecf->desktop_default_window_profile);
971 if (ecf->theme_default_border_style) eina_stringshare_del(ecf->theme_default_border_style);
972 EINA_LIST_FREE(ecf->env_vars, evr)
974 if (evr->var) eina_stringshare_del(evr->var);
975 if (evr->val) eina_stringshare_del(evr->val);
979 EINA_LIST_FREE(ecf->policy_desks, pd)
982 eina_stringshare_del(ecf->launcher.title);
983 eina_stringshare_del(ecf->launcher.clas);
985 EINA_LIST_FREE(ecf->sock_accesses, sa)
987 eina_stringshare_del(sa->sock_access.name);
988 eina_stringshare_del(sa->sock_access.owner);
989 eina_stringshare_del(sa->sock_access.group);
990 eina_stringshare_del(sa->sock_access.smack.name);
991 eina_stringshare_del(sa->sock_access.smack.value);
992 eina_stringshare_del(sa->sock_symlink_access.link_name);
993 eina_stringshare_del(sa->sock_symlink_access.owner);
994 eina_stringshare_del(sa->sock_symlink_access.group);
995 eina_stringshare_del(sa->sock_symlink_access.smack.name);
996 eina_stringshare_del(sa->sock_symlink_access.smack.value);
1000 EINA_LIST_FREE(ecf->aux_hint_supported, auxhint)
1002 eina_stringshare_del(auxhint->name);
1010 _e_config_cb_timer(void *data)
1012 e_util_dialog_show(_("Settings Upgraded"), "%s", (char *)data);
1017 _e_config_eet_close_handle(Eet_File *ef, char *file)
1022 err = eet_close(ef);
1025 case EET_ERROR_NONE:
1026 /* all good - no error */
1029 case EET_ERROR_BAD_OBJECT:
1030 erstr = _("The EET file handle is bad.");
1033 case EET_ERROR_EMPTY:
1034 erstr = _("The file data is empty.");
1037 case EET_ERROR_NOT_WRITABLE:
1038 erstr = _("The file is not writable. Perhaps the disk is read-only<br>or you lost permissions to your files.");
1041 case EET_ERROR_OUT_OF_MEMORY:
1042 erstr = _("Memory ran out while preparing the write.<br>Please free up memory.");
1045 case EET_ERROR_WRITE_ERROR:
1046 erstr = _("This is a generic error.");
1049 case EET_ERROR_WRITE_ERROR_FILE_TOO_BIG:
1050 erstr = _("The settings file is too large.<br>It should be very small (a few hundred KB at most).");
1053 case EET_ERROR_WRITE_ERROR_IO_ERROR:
1054 erstr = _("You have I/O errors on the disk.<br>Maybe it needs replacing?");
1057 case EET_ERROR_WRITE_ERROR_OUT_OF_SPACE:
1058 erstr = _("You ran out of space while writing the file.");
1061 case EET_ERROR_WRITE_ERROR_FILE_CLOSED:
1062 erstr = _("The file was closed while writing.");
1065 case EET_ERROR_MMAP_FAILED:
1066 erstr = _("Memory-mapping (mmap) of the file failed.");
1069 case EET_ERROR_X509_ENCODING_FAILED:
1070 erstr = _("X509 Encoding failed.");
1073 case EET_ERROR_SIGNATURE_FAILED:
1074 erstr = _("Signature failed.");
1077 case EET_ERROR_INVALID_SIGNATURE:
1078 erstr = _("The signature was invalid.");
1081 case EET_ERROR_NOT_SIGNED:
1082 erstr = _("Not signed.");
1085 case EET_ERROR_NOT_IMPLEMENTED:
1086 erstr = _("Feature not implemented.");
1089 case EET_ERROR_PRNG_NOT_SEEDED:
1090 erstr = _("PRNG was not seeded.");
1093 case EET_ERROR_ENCRYPT_FAILED:
1094 erstr = _("Encryption failed.");
1097 case EET_ERROR_DECRYPT_FAILED:
1098 erstr = _("Decryption failed.");
1101 default: /* if we get here eet added errors we don't know */
1102 erstr = _("The error is unknown to Enlightenment.");
1109 /* delete any partially-written file */
1110 ecore_file_unlink(file);
1111 /* only show dialog for first error - further ones are likely */
1112 /* more of the same error */
1113 if (!_e_config_error_dialog)
1117 dia = e_dialog_new(NULL, "E", "_sys_error_logout_slow");
1122 e_dialog_title_set(dia, _("Enlightenment Settings Write Problems"));
1123 e_dialog_icon_set(dia, "dialog-error", 64);
1124 snprintf(buf, sizeof(buf),
1125 _("Enlightenment has had an error while writing<br>"
1126 "its config file.<br>"
1129 "The file where the error occurred was:<br>"
1132 "This file has been deleted to avoid corrupt data.<br>"),
1134 e_dialog_text_set(dia, buf);
1135 e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
1136 e_dialog_button_focus_num(dia, 0);
1137 //elm_win_center(dia->win, 1, 1);
1138 e_object_del_attach_func_set(E_OBJECT(dia),
1139 _e_config_error_dialog_cb_delete);
1141 _e_config_error_dialog = dia;
1146 ELOGF("CFG", "EET ERROR %s", NULL, erstr);