4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <Elementary.h>
25 #include <sys/types.h>
38 #include "lock-daemon.h"
39 #include "lockd-debug.h"
42 #define PACKAGE_NAME "org.tizen.starter"
45 #define PWLOCK_PKG "org.tizen.pwlock"
46 #define VCONFKEY_START "memory/startapps/sequence"
47 #define PWLOCK_FIRST_BOOT "db/setting/pwlock_boot"
48 #define DEFAULT_THEME "tizen"
49 #define PWLOCK_PATH "/opt/apps/org.tizen.pwlock/bin/pwlock"
50 #define HIB_CAPTURING "/opt/etc/.hib_capturing"
52 static void lock_menu_screen(void)
54 vconf_set_int(VCONFKEY_START, 0);
57 static void unlock_menu_screen(void)
63 r = vconf_get_int(VCONFKEY_START, &show_menu);
64 if (r || !show_menu) {
65 vconf_set_int(VCONFKEY_START, 1);
69 static void _set_elm_theme(void)
73 vstr = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR);
75 theme = DEFAULT_THEME;
79 _DBG("theme vconf[%s]\n set[%s]\n", vstr, theme);
80 elm_theme_all_set(theme);
86 static void _set_elm_entry(void)
91 r = vconf_get_bool(VCONFKEY_SETAPPL_AUTOCAPITAL_ALLOW_BOOL, &v);
93 prop_int_set("ENLIGHTENMENT_AUTOCAPITAL_ALLOW", v);
94 _DBG("vconf autocatipal[%d]", v);
97 r = vconf_get_bool(VCONFKEY_SETAPPL_AUTOPERIOD_ALLOW_BOOL, &v);
99 prop_int_set("ENLIGHTENMENT_AUTOPERIOD_ALLOW", v);
100 _DBG("vconf autoperiod[%d]", v);
104 static int _launch_pwlock(void)
108 _DBG("%s", __func__);
110 r = aul_launch_app(PWLOCK_PKG, NULL);
112 _ERR("PWLock launch error: error(%d)", r);
113 if (r == AUL_R_ETIMEOUT) {
114 _DBG("Launch pwlock is failed for AUL_R_ETIMEOUT, again launch pwlock");
115 r = aul_launch_app(PWLOCK_PKG, NULL);
117 _ERR("2'nd PWLock launch error: error(%d)", r);
120 _DBG("Launch pwlock");
127 _DBG("Launch pwlock");
132 static void hib_leave(void *data)
134 struct appdata *ad = data;
136 fprintf(stderr, "Invalid argument: appdata is NULL\n");
140 _DBG("%s", __func__);
143 if (_launch_pwlock() < 0) {
144 _ERR("launch pwlock error");
148 static int add_noti(struct appdata *ad)
152 _DBG("%s %d\n", __func__, __LINE__);
155 fprintf(stderr, "Invalid argument: appdata is NULL\n");
161 _ERR("Noti init error");
166 r = heynoti_subscribe(fd, "HIBERNATION_PRELEAVE", hib_leave, ad);
168 _ERR("Noti subs error");
172 r = heynoti_attach_handler(fd);
174 _ERR("Noti attach error");
178 _DBG("Waiting for hib leave");
179 _DBG("%s %d\n", __func__, __LINE__);
184 static int _init(struct appdata *ad)
189 memset(ad, 0, sizeof(struct appdata));
192 gettimeofday(&ad->tv_start, NULL);
198 _DBG("%s %d\n", __func__, __LINE__);
199 fd = open(HIB_CAPTURING, O_RDONLY);
200 _DBG("fd = %d\n", fd);
202 _DBG("fd = %d\n", fd);
204 if (_launch_pwlock() < 0) {
205 _ERR("launch pwlock error");
213 if (vconf_set_int("memory/hibernation/starter_ready", 1))
214 _ERR("vconf_set_int FAIL");
216 _ERR("vconf_set_int OK\n");
221 static void _fini(struct appdata *ad)
223 struct timeval tv, res;
226 fprintf(stderr, "Invalid argument: appdata is NULL\n");
230 heynoti_close(ad->noti);
232 unlock_menu_screen();
234 gettimeofday(&tv, NULL);
235 timersub(&tv, &ad->tv_start, &res);
236 _DBG("Total time: %d.%06d sec\n", (int)res.tv_sec, (int)res.tv_usec);
239 int main(int argc, char *argv[])
245 elm_init(argc, argv);