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.
17 #include <Elementary.h>
20 #include <sys/types.h>
35 #include "lock-daemon.h"
36 #include "lockd-debug.h"
38 #define DEFAULT_THEME "tizen"
40 #define HIB_CAPTURING "/opt/etc/.hib_capturing"
41 #define STR_STARTER_READY "/tmp/hibernation/starter_ready"
43 static void lock_menu_screen(void)
45 vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 0);
48 static void unlock_menu_screen(void)
54 r = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &show_menu);
55 if (r || !show_menu) {
56 vconf_set_int(VCONFKEY_STARTER_SEQUENCE, 1);
60 static void _set_elm_theme(void)
65 vstr = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR);
67 theme = DEFAULT_THEME;
72 _DBG("theme vconf[%s]\n set[%s]\n", vstr, theme);
73 elm_theme_set(th, theme);
79 static void hib_leave(void *data)
81 struct appdata *ad = data;
83 fprintf(stderr, "Invalid argument: appdata is NULL\n");
92 static int add_noti(struct appdata *ad)
96 _DBG("%s %d\n", __func__, __LINE__);
99 fprintf(stderr, "Invalid argument: appdata is NULL\n");
105 _ERR("Noti init error");
110 r = heynoti_subscribe(fd, "HIBERNATION_PRELEAVE", hib_leave, ad);
112 _ERR("Noti subs error");
116 r = heynoti_attach_handler(fd);
118 _ERR("Noti attach error");
122 _DBG("Waiting for hib leave");
123 _DBG("%s %d\n", __func__, __LINE__);
128 static void _signal_handler(int signum, siginfo_t *info, void *unused)
130 _DBG("_signal_handler : Terminated...");
133 static void _heynoti_event_power_off(void *data)
135 _DBG("_heynoti_event_power_off : Terminated...");
139 static int _init(struct appdata *ad)
145 struct sigaction act;
146 act.sa_sigaction = _signal_handler;
147 act.sa_flags = SA_SIGINFO;
149 int ret = sigemptyset(&act.sa_mask);
151 _ERR("Failed to sigemptyset[%s]", strerror(errno));
153 ret = sigaddset(&act.sa_mask, SIGTERM);
155 _ERR("Failed to sigaddset[%s]", strerror(errno));
157 ret = sigaction(SIGTERM, &act, NULL);
159 _ERR("Failed to sigaction[%s]", strerror(errno));
162 memset(ad, 0, sizeof(struct appdata));
165 gettimeofday(&ad->tv_start, NULL);
170 _DBG("%s %d\n", __func__, __LINE__);
172 fd = open(HIB_CAPTURING, O_RDONLY);
173 _DBG("fd = %d\n", fd);
175 _DBG("fd = %d\n", fd);
183 fd1 = open(STR_STARTER_READY, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
185 _DBG("Hibernation ready.\n");
192 static void _fini(struct appdata *ad)
194 struct timeval tv, res;
197 fprintf(stderr, "Invalid argument: appdata is NULL\n");
201 heynoti_close(ad->noti);
203 unlock_menu_screen();
205 gettimeofday(&tv, NULL);
206 timersub(&tv, &ad->tv_start, &res);
207 _DBG("Total time: %d.%06d sec\n", (int)res.tv_sec, (int)res.tv_usec);
210 int main(int argc, char *argv[])
214 int heyfd = heynoti_init();
216 _ERR("Failed to heynoti_init[%d]", heyfd);
219 int ret = heynoti_subscribe(heyfd, "power_off_start", _heynoti_event_power_off, NULL);
221 _ERR("Failed to heynoti_subscribe[%d]", ret);
223 ret = heynoti_attach_handler(heyfd);
225 _ERR("Failed to heynoti_attach_handler[%d]", ret);
228 elm_init(argc, argv);