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.
18 #include "vcui-app-window.h"
19 #include "vcui-view-quickpanel.h"
21 static Eina_Bool __vcui_app_win_focus_in_cb(void *data, int type, void *event);
22 static Eina_Bool __vcui_app_win_focus_out_cb(void *data, int type, void *event);
23 static void __vcui_app_win_main_win_del_cb(void *data, Evas_Object *obj, void *event);
24 static Eina_Bool __vcui_app_win_hard_key_down_cb(void *data, int type, void *event);
25 static Eina_Bool __vcui_app_win_hard_key_up_cb(void *data, int type, void *event);
26 static Eina_Bool __vcui_app_win_mouse_down_cb(void *data, int type, void *event);
27 /*static Eina_Bool __vcui_app_win_longpress_mute_timer_cb(void *data);*/
28 static Eina_Bool __vcui_app_win_volup_key_longpress_timer_cb(void *data);
29 static Eina_Bool __vcui_app_win_voldown_key_longpress_timer_cb(void *data);
31 Evas_Object *_vcui_app_win_create_main(vcui_app_call_data_t *ad, const char *name)
35 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
37 elm_win_title_set(eo, name);
38 elm_win_borderless_set(eo, EINA_TRUE);
39 evas_object_smart_callback_add(eo, "delete,request", __vcui_app_win_main_win_del_cb, NULL);
40 ecore_x_window_size_get(ecore_x_window_root_first_get(), &ad->root_w, &ad->root_h);
41 evas_object_resize(eo, ad->root_w, ad->root_h);
42 elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
48 static Eina_Bool __vcui_app_win_focus_in_cb(void *data, int type, void *event)
51 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
52 Ecore_X_Event_Window_Focus_Out *ev = (Ecore_X_Event_Window_Focus_Out *)event;
55 CALL_UI_DEBUG("ad == NULL");
56 return ECORE_CALLBACK_CANCEL;
59 if (ad->win_main!= NULL && ev->win == elm_win_xwindow_get(ad->win_main)) {
60 CALL_UI_DEBUG("Uninstall quick-panel view");
61 _vcui_view_qp_uninstall_window(ad->view_st[VIEW_QUICKPANEL_VIEW]);
64 CALL_UI_DEBUG("__win_focus_in_cb leave");
66 return ECORE_CALLBACK_PASS_ON;
69 static Eina_Bool __vcui_app_win_focus_out_cb(void *data, int type, void *event)
72 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
73 Ecore_X_Event_Window_Focus_Out *ev = (Ecore_X_Event_Window_Focus_Out *)event;
76 CALL_UI_DEBUG("ad == NULL");
77 return ECORE_CALLBACK_CANCEL;
80 if (ad->win_main != NULL && ev->win == elm_win_xwindow_get(ad->win_main)) {
81 CALL_UI_DEBUG("install quick-panel view");
82 _vcui_view_qp_install_window(ad->view_st[VIEW_QUICKPANEL_VIEW]);
85 CALL_UI_DEBUG("__win_focus_out_cb leave");
87 return ECORE_CALLBACK_PASS_ON;
90 static void __vcui_app_win_main_win_del_cb(void *data, Evas_Object *obj, void *event)
96 static Eina_Bool __vcui_app_win_hard_key_down_cb(void *data, int type, void *event)
100 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
101 Ecore_Event_Key *ev = event;
102 gboolean banswering_enabled = EINA_FALSE;
103 gboolean bpowerkey_enabled = EINA_FALSE;
105 retvm_if(ev == NULL, 0, "ERROR!!! ========= Event is NULL!!!");
107 if (ad->view_top == -1) {
108 CALL_UI_DEBUG("ad->view_top is -1.");
109 #ifdef SEND_END_TO_UG
110 if ((ad->contact_ug != NULL) && (!strcmp(ev->keyname, KEY_END))) {
111 CALL_UI_DEBUG("send end key to contact ug.");
112 ug_send_key_event(UG_KEY_EVENT_END);
118 if (!strcmp(ev->keyname, KEY_POWER)) {
119 bpowerkey_enabled = _vcui_is_powerkey_mode_on();
120 CALL_UI_DEBUG("[KEY]KEY_POWER pressed, bpowerkey_enabled(%d)", bpowerkey_enabled);
121 if (bpowerkey_enabled == EINA_TRUE) {
122 CALL_UI_DEBUG("Lock the LCD state to ON...");
123 vcall_engine_device_control_lcd_state(VC_LCD_ON_LOCK);
125 if (ad->view_st[ad->view_top]->type == VIEW_DIALLING_VIEW) {
126 if (ad->ball_view_hide) {
127 CALL_UI_DEBUG("VCUI_RQST_REDIAL_STOP !!");
128 vcall_engine_process_auto_redial(EINA_FALSE);
131 vcall_engine_cancel_call();
133 } else if (ad->view_st[ad->view_top]->type == VIEW_INCOMING_LOCK_VIEW) {
134 vcall_engine_reject_call();
135 } else if ((ad->view_st[ad->view_top]->type >= VIEW_INCALL_ONECALL_VIEW)
136 && (ad->view_st[ad->view_top]->type <= VIEW_INCALL_MULTICALL_LIST_VIEW)) {
137 vcall_engine_release_call_by_type(VCALL_ENGINE_RELEASE_ALL_CALLS);
139 CALL_UI_DEBUG("nothing...");
142 } else if (!strcmp(ev->keyname, KEY_VOLUMEUP)) {
143 CALL_UI_DEBUG("[KEY]KEY_VOLUMEUP pressed");
144 if (ad->view_st[ad->view_top]->type == VIEW_INCOMING_LOCK_VIEW) {
145 vcall_engine_mute_alert();
146 ad->bmute_ringtone = EINA_TRUE;
148 ad->vol_longpress_cnt = 0;
149 vcall_engine_device_control_lcd_state(VC_LCD_ON);
151 _vcui_set_volume(VAL_VOL_UP);
152 ad->volup_key_longpress_timer = ecore_timer_add(VOLUME_KEY_LONG_PRESS_TIMEOUT, __vcui_app_win_volup_key_longpress_timer_cb, ad);
155 } else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN)) {
156 CALL_UI_DEBUG("[KEY]KEY_VOLUMEDOWN pressed");
157 if (ad->view_st[ad->view_top]->type == VIEW_INCOMING_LOCK_VIEW) {
158 vcall_engine_mute_alert();
159 ad->bmute_ringtone = EINA_TRUE;
161 ad->vol_longpress_cnt = 0;
162 vcall_engine_device_control_lcd_state(VC_LCD_ON);
164 _vcui_set_volume(VAL_VOL_DOWN);
165 ad->voldown_key_longpress_timer = ecore_timer_add(VOLUME_KEY_LONG_PRESS_TIMEOUT, __vcui_app_win_voldown_key_longpress_timer_cb, ad);
168 } else if (!strcmp(ev->keyname, KEY_SELECT)) {
169 banswering_enabled = _vcui_is_answering_mode_on();
170 CALL_UI_DEBUG("[KEY]KEY_SELECT pressed");
171 if (banswering_enabled == EINA_TRUE) {
172 if (ad->view_st[ad->view_top]->type == VIEW_INCOMING_LOCK_VIEW) {
173 CALL_UI_DEBUG("Answering mode on and Home key pressed on MT screen");
175 if (_vcui_is_phonelock_status() == EINA_FALSE)
176 vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK);
177 vcall_engine_answer_call();
182 CALL_UI_DEBUG("End..");
186 static Eina_Bool __vcui_app_win_hard_key_up_cb(void *data, int type, void *event)
190 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
191 Ecore_Event_Key *ev = event;
193 retvm_if(ev == NULL, 0, "ERROR!!! ========= Event is NULL!!!");
195 if (0 == strcmp(ev->keyname, KEY_VOLUMEDOWN)) {
196 if (ad->ringtone_longpress_mute_timer) {
197 ecore_timer_del(ad->ringtone_longpress_mute_timer);
198 ad->ringtone_longpress_mute_timer = NULL;
202 ad->vol_longpress_cnt = 0;
204 if (ad->volup_key_longpress_timer) {
205 ecore_timer_del(ad->volup_key_longpress_timer);
206 ad->volup_key_longpress_timer = NULL;
209 if (ad->voldown_key_longpress_timer) {
210 ecore_timer_del(ad->voldown_key_longpress_timer);
211 ad->voldown_key_longpress_timer = NULL;
217 static Eina_Bool __vcui_app_win_mouse_down_cb(void *data, int type, void *event)
219 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
220 Ecore_Event_Mouse_Button *ev = event;
227 void _vcui_app_win_key_grab(vcui_app_call_data_t *ad)
230 CALL_UI_KPI("_vcui_app_win_key_grab start");
233 ad->disp = ecore_x_display_get();
234 ad->win = elm_win_xwindow_get(ad->win_main);
236 result = utilx_grab_key(ad->disp, ad->win, KEY_VOLUMEUP, EXCLUSIVE_GRAB);
238 CALL_UI_DEBUG("KEY_VOLUMEUP key grab failed");
240 result = utilx_grab_key(ad->disp, ad->win, KEY_VOLUMEDOWN, EXCLUSIVE_GRAB);
242 CALL_UI_DEBUG("KEY_VOLUMEDOWN key grab failed");
244 if (ad->downkey_handler == NULL)
245 ad->downkey_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __vcui_app_win_hard_key_down_cb, ad);
246 if (ad->upkey_handler == NULL)
247 ad->upkey_handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, __vcui_app_win_hard_key_up_cb, ad);
248 if (ad->mouse_evnt_handler == NULL)
249 ad->mouse_evnt_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, __vcui_app_win_mouse_down_cb, ad); /*for ctxpopup */
250 if (ad->focus_in == NULL)
251 ad->focus_in = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, __vcui_app_win_focus_in_cb, ad);
252 if (ad->focus_out == NULL)
253 ad->focus_out = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, __vcui_app_win_focus_out_cb, ad);
255 CALL_UI_KPI("_vcui_app_win_key_grab done");
259 static Eina_Bool __vcui_app_win_longpress_mute_timer_cb(void *data)
263 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
264 call_data_t *call_data = _vcui_doc_get_recent_mt_call_data();
266 if (call_data == NULL)
267 return ECORE_CALLBACK_CANCEL;
269 if (ad->ringtone_longpress_mute_timer) {
270 ecore_timer_del(ad->ringtone_longpress_mute_timer);
271 ad->ringtone_longpress_mute_timer = NULL;
274 ad->vol_longpress_cnt = 0;
276 if (ad->volup_key_longpress_timer) {
277 ecore_timer_del(ad->volup_key_longpress_timer);
278 ad->volup_key_longpress_timer = NULL;
281 if (ad->voldown_key_longpress_timer) {
282 ecore_timer_del(ad->voldown_key_longpress_timer);
283 ad->voldown_key_longpress_timer = NULL;
286 _vcui_view_popup_unload(ad->vol_ringtone_popup_eo);
288 vcall_engine_mute_alert();
289 ad->bmute_ringtone = EINA_TRUE;
291 return ECORE_CALLBACK_CANCEL;
295 static Eina_Bool __vcui_app_win_volup_key_longpress_timer_cb(void *data)
299 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
301 if (ad->view_st[ad->view_top]->type == VIEW_INCOMING_LOCK_VIEW) {
302 if ((ad->ringtone_val == RINGTONE_MAX) || (ad->bmute_ringtone == EINA_TRUE)) {
303 if (ad->volup_key_longpress_timer) {
304 ecore_timer_del(ad->volup_key_longpress_timer);
305 ad->volup_key_longpress_timer = NULL;
307 return ECORE_CALLBACK_CANCEL;
309 } else if (ad->headset_status == EINA_TRUE) {
310 if (ad->bt_vol_val == BT_VOL_MAX) {
311 if (ad->volup_key_longpress_timer) {
312 ecore_timer_del(ad->volup_key_longpress_timer);
313 ad->volup_key_longpress_timer = NULL;
315 return ECORE_CALLBACK_CANCEL;
318 if (ad->voice_vol_val == VOICE_VOL_MAX) {
319 if (ad->volup_key_longpress_timer) {
320 ecore_timer_del(ad->volup_key_longpress_timer);
321 ad->volup_key_longpress_timer = NULL;
323 return ECORE_CALLBACK_CANCEL;
327 ad->vol_longpress_cnt++;
329 if ((ad->vol_longpress_cnt % 3) == 0) {
330 _vcui_set_volume(VAL_VOL_UP);
333 return ECORE_CALLBACK_RENEW;
336 static Eina_Bool __vcui_app_win_voldown_key_longpress_timer_cb(void *data)
340 vcui_app_call_data_t *ad = (vcui_app_call_data_t *)data;
342 if (ad->view_st[ad->view_top]->type == VIEW_INCOMING_LOCK_VIEW) {
343 if ((ad->ringtone_val == RINGTONE_MAX) || (ad->bmute_ringtone == EINA_TRUE)) {
344 if (ad->voldown_key_longpress_timer) {
345 ecore_timer_del(ad->voldown_key_longpress_timer);
346 ad->voldown_key_longpress_timer = NULL;
348 return ECORE_CALLBACK_CANCEL;
350 } else if (ad->headset_status == EINA_TRUE) {
351 if (ad->bt_vol_val == BT_VOL_MIN) {
352 if (ad->voldown_key_longpress_timer) {
353 ecore_timer_del(ad->voldown_key_longpress_timer);
354 ad->voldown_key_longpress_timer = NULL;
356 return ECORE_CALLBACK_CANCEL;
359 if (ad->voice_vol_val == VOICE_VOL_MIN) {
360 if (ad->voldown_key_longpress_timer) {
361 ecore_timer_del(ad->voldown_key_longpress_timer);
362 ad->voldown_key_longpress_timer = NULL;
364 return ECORE_CALLBACK_CANCEL;
368 ad->vol_longpress_cnt++;
370 if ((ad->vol_longpress_cnt % 3) == 0) {
371 _vcui_set_volume(VAL_VOL_DOWN);
374 return ECORE_CALLBACK_RENEW;
377 void _vcui_app_win_set_noti_type(int bwin_noti)
380 vcui_app_call_data_t *ad = _vcui_get_app_data();
383 xwin = elm_win_xwindow_get(ad->win_main);
385 if (bwin_noti == EINA_FALSE) {
386 CALL_UI_DEBUG("window type: NORMAL");
387 /* Set Normal window */
388 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NORMAL);
390 CALL_UI_DEBUG("window type: NOTI-HIGH");
391 /* Set Notification window */
392 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
393 /* Set Notification's priority to LEVEL_HIGH */
394 utilx_set_system_notification_level(ecore_x_display_get(), xwin, UTILX_NOTIFICATION_LEVEL_HIGH);