3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.1 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
23 #include <appcore-efl.h>
24 #include <Elementary.h>
31 #include "taskmanager.h"
32 #include "_util_log.h"
33 #include "_util_efl.h"
54 static struct text_part main_txt[] = {
57 static void update_ts(Evas_Object *eo, struct text_part *tp, int size)
61 if (eo == NULL || tp == NULL || size < 0)
64 for (i = 0; i < size; i++) {
65 if (tp[i].part && tp[i].msgid)
66 edje_object_part_text_set(eo,
67 tp[i].part, _(tp[i].msgid));
71 static int _lang_changed(void *data)
73 struct appdata *ad = data;
78 update_ts(elm_layout_edje_get(ad->ly),
79 main_txt, sizeof(main_txt) / sizeof(main_txt[0]));
84 int _get_vconf_idlelock(void)
87 int lock = IDLELOCK_OFF;
89 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock);
90 retvm_if(ret < 0, -1, "Failed to get vconf\n");
91 _D("idlelock vconf:%d\n", lock);
93 return lock == VCONFKEY_IDLE_LOCK ? IDLELOCK_ON : IDLELOCK_OFF;
96 int _get_vconf_lcdstate(void)
101 ret = vconf_get_int(VCONFKEY_PM_STATE, &lcd);
102 retvm_if(ret < 0, -1, "Failed to get vconf\n");
103 _D("lcd vconf:%d\n", lcd);
105 return lcd == VCONFKEY_PM_STATE_LCDOFF ? LCD_OFF : LCD_ON;
108 Eina_Bool _exit_cb(void *data)
110 int lock = IDLELOCK_ON;
111 lock = _get_vconf_idlelock();
113 _D("lock(%d)\n", lock);
114 if(lock == IDLELOCK_OFF){
119 _D("IDLELOCK is set, taskmnager doesn't exit\n");
120 return ECORE_CALLBACK_CANCEL;
122 return ECORE_CALLBACK_CANCEL;
125 void _key_grab(struct appdata *ad)
128 Ecore_X_Window xwin; /* key grab */
129 Ecore_X_Display *disp; /* key grab */
132 disp = ecore_x_display_get();
133 xwin = elm_win_xwindow_get(ad->win);
135 ret = utilx_grab_key(disp, xwin, KEY_SELECT, SHARED_GRAB);
136 retm_if(ret < 0, "Failed to grab home key\n");
139 int _set_launch_effect(Evas_Object *win)
141 Ecore_X_Window xwin = 0;
142 static Ecore_X_Atom ATOM_WM_WINDOW_ROLE = 0;
143 static Ecore_X_Atom ATOM_NET_WM_NAME = 0;
144 retvm_if(win == NULL, -1, "[Error] Invalid argument: win is NULL\n");
146 ATOM_WM_WINDOW_ROLE = ecore_x_atom_get("WM_WINDOW_ROLE");
147 if (!ATOM_WM_WINDOW_ROLE) {
149 "[App] %s(%d) XInternAtom(WM_WINDOW_ROLE) failed.\n",
153 ATOM_NET_WM_NAME = ecore_x_atom_get("_NET_WM_NAME");
154 if (!ATOM_NET_WM_NAME) {
156 "[App] %s(%d) XInternAtom(ATOM_NET_WM_NAME) failed.\n",
160 xwin = elm_win_xwindow_get(win);
161 ecore_x_window_prop_string_set(xwin, ATOM_WM_WINDOW_ROLE,
163 ecore_x_window_prop_string_set(xwin, ATOM_NET_WM_NAME, "TASK_MANAGER");
165 ecore_x_icccm_name_class_set(xwin, "TASK_MANAGER", "TASK_MANAGER");
169 int _unset_notification_level(Evas_Object *win)
173 xwin = elm_win_xwindow_get(win);
174 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NORMAL);
179 int _set_notification_level(Evas_Object *win, Utilx_Notification_Level level)
181 Ecore_X_Window xwin = 0;
183 xwin = elm_win_xwindow_get(win);
184 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
185 utilx_set_system_notification_level(ecore_x_display_get(), xwin, level);
189 void _check_show_state(void)
191 int lcd = LCD_OFF, idlelock = IDLELOCK_OFF;
192 lcd = _get_vconf_lcdstate();
193 idlelock = _get_vconf_idlelock();
194 if(lcd == LCD_OFF || idlelock == IDLELOCK_ON)
200 int app_create(void *data)
203 struct appdata *ad = data;
206 win = _add_window(PACKAGE);
207 retv_if(win == NULL, -1);
208 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
211 _set_launch_effect(win);
212 // _set_notification_level(win, UTILX_NOTIFICATION_LEVEL_NORMAL);
214 /* init internationalization */
215 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
216 retvm_if(r < 0, -1, "Failed to set i18n\n");
220 elm_theme_extension_add(NULL, EDJ_THEME);
226 /* set dead signal listener */
227 aul_listen_app_dead_signal(_dead_cb, ad);
229 appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE,
232 ecore_idler_add(_create_idler_cb, ad);
237 static int app_terminate(void *data)
242 static int app_pause(void *data)
247 static int app_resume(void *data)
250 struct appdata *ad = data;
252 refresh_app_info(ad);
253 if (ad->killall_timer) {
254 ecore_timer_del(ad->killall_timer);
255 ad->killall_timer = NULL;
257 if (ad->exit_timer) {
258 ecore_timer_del(ad->exit_timer);
259 ad->exit_timer = NULL;
265 static int app_reset(bundle *b, void *data)
267 struct appdata *ad = data;
269 /* appcore measure time example */
270 printf("from AUL to %s(): %d msec\n", __func__,
271 appcore_measure_time_from("APP_START_TIME"));
272 printf("from create to %s(): %d msec\n", __func__,
273 appcore_measure_time());
276 elm_win_activate(ad->win);
280 int main(int argc, char *argv[])
282 sysconf_set_mempolicy(OOM_IGNORE);
285 struct appcore_ops ops = {
286 .create = app_create,
287 .terminate = app_terminate,
289 .resume = app_resume,
293 /* appcore measure time example */
294 _D("from AUL to %s(): %d msec\n", __func__,
295 appcore_measure_time_from("APP_START_TIME"));
297 memset(&ad, 0x0, sizeof(struct appdata));
300 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);