2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <sys/types.h>
33 #include "client_life.h"
37 #include "slave_life.h"
38 #include "critical_log.h"
44 static void lcd_state_cb(keynode_t *node, void *user_data)
49 xmonitor_handle_state_changes();
52 HAPI int setting_is_lcd_off(void)
56 if (vconf_get_int(VCONFKEY_PM_STATE, &state) != 0) {
57 ErrPrint("Idle lock state is not valid\n");
58 state = VCONFKEY_PM_STATE_NORMAL; /* UNLOCK */
61 DbgPrint("State: %d, (%d:lcdoff, %d:sleep)\n", state, VCONFKEY_PM_STATE_LCDOFF, VCONFKEY_PM_STATE_SLEEP);
62 return state == VCONFKEY_PM_STATE_LCDOFF || state == VCONFKEY_PM_STATE_SLEEP;
65 static void power_off_cb(keynode_t *node, void *user_data)
68 CRITICAL_LOG("Terminated(vconf)\n");
70 if (vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) != 0) {
71 ErrPrint("Failed to get power off status (%d)\n", val);
75 if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART) {
78 fd = creat("/tmp/.stop.provider", 0644);
79 if (fd < 0 || close(fd) < 0)
80 ErrPrint("stop.provider [%s]\n", strerror(errno));
82 vconf_set_bool(VCONFKEY_MASTER_STARTED, 0);
84 //ecore_main_loop_quit();
86 ErrPrint("Unknown power state: %d\n", val);
90 static void region_changed_cb(keynode_t *node, void *user_data)
95 region = vconf_get_str(VCONFKEY_REGIONFORMAT);
99 setenv("LC_CTYPE", region, 1);
100 setenv("LC_NUMERIC", region, 1);
101 setenv("LC_TIME", region, 1);
102 setenv("LC_COLLATE", region, 1);
103 setenv("LC_MONETARY", region, 1);
104 setenv("LC_PAPER", region, 1);
105 setenv("LC_NAME", region, 1);
106 setenv("LC_ADDRESS", region, 1);
107 setenv("LC_TELEPHONE", region, 1);
108 setenv("LC_MEASUREMENT", region, 1);
109 setenv("LC_IDENTIFICATION", region, 1);
111 r = setlocale(LC_ALL, "");
113 ErrPrint("Failed to change region\n");
118 static void lang_changed_cb(keynode_t *node, void *user_data)
123 lang = vconf_get_str(VCONFKEY_LANGSET);
127 setenv("LANG", lang, 1);
128 setenv("LC_MESSAGES", lang, 1);
130 r = setlocale(LC_ALL, "");
132 ErrPrint("Failed to change locale\n");
134 DbgPrint("Locale: %s\n", setlocale(LC_ALL, NULL));
138 HAPI int setting_init(void)
142 ret = vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_cb, NULL);
144 ErrPrint("Failed to add vconf for lock state: %d\n", ret);
146 ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb, NULL);
148 ErrPrint("Failed to add vconf for power state: %d \n", ret);
150 ret = vconf_notify_key_changed(VCONFKEY_LANGSET, lang_changed_cb, NULL);
152 ErrPrint("Failed to add vconf for lang change: %d\n", ret);
154 ret = vconf_notify_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb, NULL);
156 ErrPrint("Failed to add vconf for region change: %d\n", ret);
158 lang_changed_cb(NULL, NULL);
159 region_changed_cb(NULL, NULL);
163 HAPI int setting_fini(void)
167 ret = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb);
169 ErrPrint("Failed to ignore vconf key (%d)\n", ret);
171 ret = vconf_ignore_key_changed(VCONFKEY_LANGSET, lang_changed_cb);
173 ErrPrint("Failed to ignore vconf key (%d)\n", ret);
175 ret = vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_cb);
177 ErrPrint("Failed to ignore vconf key (%d)\n", ret);
179 ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, power_off_cb);
181 ErrPrint("Failed to ignore vconf key (%d)\n", ret);