2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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>
32 #include "client_life.h"
36 #include "slave_life.h"
37 #include "critical_log.h"
49 static void lcd_state_cb(keynode_t *node, void *user_data)
54 xmonitor_handle_state_changes();
57 HAPI int setting_is_lcd_off(void)
61 if (vconf_get_int(VCONFKEY_PM_STATE, &state) != 0) {
62 ErrPrint("Idle lock state is not valid\n");
63 state = VCONFKEY_PM_STATE_NORMAL; /* UNLOCK */
66 DbgPrint("State: %d, (%d:lcdoff, %d:sleep)\n", state, VCONFKEY_PM_STATE_LCDOFF, VCONFKEY_PM_STATE_SLEEP);
67 return state == VCONFKEY_PM_STATE_LCDOFF || state == VCONFKEY_PM_STATE_SLEEP;
70 static void power_off_cb(void *data)
72 CRITICAL_LOG("Terminated(heynoti)\n");
74 if (creat("/tmp/.stop.provider", 0644) < 0)
75 ErrPrint("Failed to create .stop.provider [%s]\n", strerror(errno));
80 HAPI int setting_init(void)
84 ret = vconf_notify_key_changed(VCONFKEY_PM_STATE, lcd_state_cb, NULL);
86 ErrPrint("Failed to add vconf for lock state\n");
88 s_info.heyfd = heynoti_init();
89 if (s_info.heyfd < 0) {
90 CRITICAL_LOG("Failed to set poweroff heynoti [%d]\n", s_info.heyfd);
94 ret = heynoti_subscribe(s_info.heyfd, "power_off_start", power_off_cb, NULL);
96 CRITICAL_LOG("Failed to subscribe heynoti for power off [%d]\n", ret);
98 ret = heynoti_attach_handler(s_info.heyfd);
100 CRITICAL_LOG("Failed to attach heynoti handler [%d]\n", ret);
105 HAPI int setting_fini(void)
108 ret = vconf_ignore_key_changed(VCONFKEY_PM_STATE, lcd_state_cb);