3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.0 (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"
48 static struct text_part main_txt[] = {
51 static void update_ts(Evas_Object *eo, struct text_part *tp, int size)
55 if (eo == NULL || tp == NULL || size < 0)
58 for (i = 0; i < size; i++) {
59 if (tp[i].part && tp[i].msgid)
60 edje_object_part_text_set(eo,
61 tp[i].part, _(tp[i].msgid));
65 static int _lang_changed(void *data)
67 struct appdata *ad = data;
72 update_ts(elm_layout_edje_get(ad->ly),
73 main_txt, sizeof(main_txt) / sizeof(main_txt[0]));
78 int _get_vconf_idlelock(void)
81 int lock = IDLELOCK_OFF;
83 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock);
84 retvm_if(ret < 0, -1, "Failed to get vconf %s\n",
85 VCONFKEY_IDLE_LOCK_STATE);
86 _D("idlelock vconf:%d\n", lock);
88 return lock == VCONFKEY_IDLE_LOCK ? IDLELOCK_ON : IDLELOCK_OFF;
91 Eina_Bool _exit_cb(void *data)
93 int lock = IDLELOCK_ON;
94 lock = _get_vconf_idlelock();
96 _D("lock(%d)\n", lock);
97 if(lock == IDLELOCK_OFF){
102 _D("IDLELOCK is set, taskmnager doesn't exit\n");
103 return ECORE_CALLBACK_CANCEL;
105 return ECORE_CALLBACK_CANCEL;
108 void _key_grab(struct appdata *ad)
111 Ecore_X_Window xwin; /* key grab */
112 Ecore_X_Display *disp; /* key grab */
115 disp = ecore_x_display_get();
116 xwin = elm_win_xwindow_get(ad->win);
118 ret = utilx_grab_key(disp, xwin, KEY_SELECT, SHARED_GRAB);
119 retm_if(ret < 0, "Failed to grab home key\n");
122 int _set_launch_effect(Evas_Object *win)
124 Ecore_X_Window xwin = 0;
125 static Ecore_X_Atom ATOM_WM_WINDOW_ROLE = 0;
126 static Ecore_X_Atom ATOM_NET_WM_NAME = 0;
127 retvm_if(win == NULL, -1, "[Error] Invalid argument: win is NULL\n");
129 ATOM_WM_WINDOW_ROLE = ecore_x_atom_get("WM_WINDOW_ROLE");
130 if (!ATOM_WM_WINDOW_ROLE) {
132 "[App] %s(%d) XInternAtom(WM_WINDOW_ROLE) failed.\n",
136 ATOM_NET_WM_NAME = ecore_x_atom_get("_NET_WM_NAME");
137 if (!ATOM_NET_WM_NAME) {
139 "[App] %s(%d) XInternAtom(ATOM_NET_WM_NAME) failed.\n",
143 xwin = elm_win_xwindow_get(win);
144 ecore_x_window_prop_string_set(xwin, ATOM_WM_WINDOW_ROLE,
146 ecore_x_window_prop_string_set(xwin, ATOM_NET_WM_NAME, "TASK_MANAGER");
148 ecore_x_icccm_name_class_set(xwin, "TASK_MANAGER", "TASK_MANAGER");
152 int _unset_notification_level(Evas_Object *win)
156 xwin = elm_win_xwindow_get(win);
157 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NORMAL);
162 int _set_notification_level(Evas_Object *win, Utilx_Notification_Level level)
164 Ecore_X_Window xwin = 0;
166 xwin = elm_win_xwindow_get(win);
167 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
168 utilx_set_system_notification_level(ecore_x_display_get(), xwin, level);
172 int app_create(void *data)
175 struct appdata *ad = data;
178 win = _add_window(PACKAGE);
179 retv_if(win == NULL, -1);
180 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
183 _set_launch_effect(win);
184 // _set_notification_level(win, UTILX_NOTIFICATION_LEVEL_NORMAL);
186 /* init internationalization */
187 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
188 retvm_if(r < 0, -1, "Failed to set i18n\n");
192 elm_theme_extension_add(NULL, EDJ_THEME);
198 /* set dead signal listener */
199 aul_listen_app_dead_signal(_dead_cb, ad);
201 appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE,
204 ecore_idler_add(_create_idler_cb, ad);
209 static int app_terminate(void *data)
214 static int app_pause(void *data)
219 static int app_resume(void *data)
222 struct appdata *ad = data;
224 refresh_app_info(ad);
225 if (ad->killall_timer) {
226 ecore_timer_del(ad->killall_timer);
227 ad->killall_timer = NULL;
229 if (ad->exit_timer) {
230 ecore_timer_del(ad->exit_timer);
231 ad->exit_timer = NULL;
237 static int app_reset(bundle *b, void *data)
239 struct appdata *ad = data;
241 /* appcore measure time example */
242 printf("from AUL to %s(): %d msec\n", __func__,
243 appcore_measure_time_from("APP_START_TIME"));
244 printf("from create to %s(): %d msec\n", __func__,
245 appcore_measure_time());
248 elm_win_activate(ad->win);
252 int main(int argc, char *argv[])
254 sysconf_set_mempolicy(OOM_IGNORE);
257 struct appcore_ops ops = {
258 .create = app_create,
259 .terminate = app_terminate,
261 .resume = app_resume,
265 /* appcore measure time example */
266 _D("from AUL to %s(): %d msec\n", __func__,
267 appcore_measure_time_from("APP_START_TIME"));
269 memset(&ad, 0x0, sizeof(struct appdata));
272 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);