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-application.h"
19 #include "vcui-view-common.h"
20 #include "vcui-view-layout-hd.h"
22 #include "vcui-view-dialing.h"
23 #include "vcui-view-incoming-lock.h"
24 #include "vcui-view-single-call.h"
25 #include "vcui-view-multi-call-split.h"
26 #include "vcui-view-multi-call-conf.h"
27 #include "vcui-view-multi-call-list.h"
28 #include "vcui-view-keypad.h"
29 #include "vcui-view-callend.h"
30 #include "vcui-view-quickpanel.h"
32 static vcui_view_common_t gincall_common_data;
34 void _vcui_view_common_init()
36 memset(&gincall_common_data, 0, sizeof(vcui_view_common_t));
39 static vcui_view_common_t *__vcui_view_common_get_common_data()
41 return &gincall_common_data;
44 static Eina_Bool __vcui_view_common_timer_cb(void *data)
46 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
47 char dur[TIME_BUF_LEN];
48 static int end_count = 0;
50 if (common_data->timer_flag == 1) {
51 if (common_data->time_end_flag == TIME_END_START) {
54 } else if (common_data->time_end_flag == TIME_END_NO) {
61 common_data->current_call_time = time(NULL);
63 if (common_data->timer_flag == 1) {
64 if (common_data->current_call_time > common_data->start_call_time) {
65 time_t call_time = common_data->current_call_time - common_data->start_call_time;
68 gmtime_r((const time_t *)&call_time, &loctime);
69 snprintf(dur, TIME_BUF_LEN, "%02d:%02d:%02d", loctime.tm_hour, loctime.tm_min, loctime.tm_sec);
71 _vcui_view_common_set_text_time(dur);
78 static Eina_Bool __vcui_view_common_timer_end_cb(void *data)
80 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
81 int end_type = common_data->end_type;
82 char dur[TIME_BUF_LEN];
84 if ((common_data->timer_flag == 1) && (common_data->time_end_flag == TIME_END_START)) {
85 snprintf(dur, TIME_BUF_LEN, "%02d:%02d:%02d", common_data->hour, common_data->min, common_data->sec);
86 if (common_data->time_count == 0) {
87 _vcui_view_common_set_text_time(dur);
88 } else if (common_data->time_count == 1) {
89 _vcui_view_common_set_text_time(_(" "));
90 } else if (common_data->time_count == 2) {
91 _vcui_view_common_set_text_time(dur);
92 } else if (common_data->time_count == 3) {
93 _vcui_view_common_set_text_time(_(" "));
94 } else if (common_data->time_count == 4) {
95 char data_txt[VC_DATA_LENGTH_MAX] = { 0, };
96 _vcui_view_common_set_text_time(_vcui_get_endcause_string(end_type, data_txt));
99 common_data->time_count++;
100 if (common_data->time_count == TIME_END_MAX_SHOW) {
101 common_data->time_end_flag = TIME_END_NO;
102 common_data->time_count = 0;
104 if (common_data->tm_end) {
105 ecore_timer_del(common_data->tm_end);
106 common_data->tm_end = NULL;
109 _vcui_view_common_call_terminate_or_view_change();
115 static Eina_Bool __vcui_view_common_timer_end_dialing_cb(void *data)
118 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
120 if (common_data->tm_end_dialing) {
121 ecore_timer_del(common_data->tm_end_dialing);
122 common_data->tm_end_dialing = NULL;
125 if (common_data->bredial == EINA_TRUE) {
126 vcall_engine_process_auto_redial(EINA_TRUE);
127 _vcui_view_popup_load_redial();
129 _vcui_view_common_call_terminate_or_view_change();
135 static Eina_Bool __vcui_view_common_timer_end_force_cb(void *data)
138 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
140 if (common_data->tm_end_force) {
141 ecore_timer_del(common_data->tm_end_force);
142 common_data->tm_end_force = NULL;
145 _vcui_view_common_call_terminate_or_view_change();
150 void _vcui_view_common_set_text_time(char *time_dur)
152 vcui_app_call_data_t *ad = _vcui_get_app_data();
153 voice_call_view_data_t *data = ad->view_st[ad->view_top];
156 if (data->type == VIEW_INCALL_ONECALL_VIEW) {
157 _vc_ui_view_single_call_set_call_timer(data, time_dur);
158 } else if (data->type == VIEW_INCALL_MULTICALL_SPLIT_VIEW) {
159 _vcui_view_multi_call_split_set_call_timer(data, time_dur);
160 } else if (data->type == VIEW_INCALL_MULTICALL_CONF_VIEW) {
161 _vcui_view_multi_call_conf_set_call_timer(data, time_dur);
162 } else if (data->type == VIEW_INCALL_MULTICALL_LIST_VIEW) {
163 _vcui_view_multi_call_list_set_call_timer(data, time_dur);
164 } else if (data->type == VIEW_ENDCALL_VIEW) {
165 _vc_ui_view_callend_set_call_timer(data, time_dur);
167 /*to do nothing in case of other view. */
171 if (ad->win_quickpanel && ad->quickpanel_layout) {
172 _vc_ui_view_qp_set_call_timer(ad->quickpanel_layout, time_dur);
176 void _vcui_view_common_set_each_time(time_t starttime)
179 unsigned long call_duration_in_sec = 0;
180 unsigned long sec = 0;
181 unsigned long min = 0;
182 unsigned long hr = 0;
184 curr_time = time(&curr_time);
185 call_duration_in_sec = curr_time - starttime;
186 sec = call_duration_in_sec % 60;
187 min = (call_duration_in_sec / 60) % 60;
188 hr = call_duration_in_sec / 3600;
190 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
192 /*set the start time for every call */
193 common_data->start_call_time = starttime;
194 CALL_UI_DEBUG(" common_data->start_call_time %lu", (unsigned long)common_data->start_call_time);
196 CALL_UI_DEBUG(" _vcui_view_common_set_each_time curr_time %d starttime %d", (int)curr_time, (int)starttime);
198 common_data->sec = sec;
199 common_data->min = min;
200 common_data->hour = hr;
202 char dur[TIME_BUF_LEN];
203 snprintf(dur, TIME_BUF_LEN, "%02d:%02d:%02d", common_data->hour, common_data->min, common_data->sec);
204 if (common_data->timer_flag == 1)
205 _vcui_view_common_set_text_time(dur);
207 CALL_UI_DEBUG(" complete input time");
211 void _vcui_view_common_timer_text_init()
213 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
215 if (!common_data->tm) {
216 if (common_data->timer_flag == 0) {
217 common_data->sec = 0;
218 common_data->min = 0;
219 common_data->hour = 0;
220 common_data->timer_flag = 1;
222 common_data->tm = ecore_timer_add(TIMER_TIMEOUT_1_SEC, __vcui_view_common_timer_cb, NULL);
226 void _vcui_view_common_timer_destroy()
228 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
229 if (common_data->tm) {
230 ecore_timer_del(common_data->tm);
231 common_data->tm = NULL;
235 void _vcui_view_common_timer_end_destroy()
237 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
238 if (common_data->tm_end) {
239 ecore_timer_del(common_data->tm_end);
240 common_data->tm_end = NULL;
244 void _vcui_view_common_timer_end_dialing_destroy()
246 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
247 if (common_data->tm_end_dialing) {
248 ecore_timer_del(common_data->tm_end_dialing);
249 common_data->tm_end_dialing = NULL;
253 void _vcui_view_common_timer_redial_reset()
256 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
258 _vcui_view_common_timer_end_destroy();
259 _vcui_view_common_timer_end_dialing_destroy();
260 common_data->time_end_flag = TIME_END_NO;
263 void _vcui_view_common_call_end_show_dialing(int end_type, int bredial)
265 CALL_UI_DEBUG("end_type:[%d]", end_type);
266 vcui_app_call_data_t *ad = _vcui_get_app_data();
267 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
268 char data[VC_DATA_LENGTH_MAX] = { 0, };
270 if (ad->call_end_type == CALL_END_TYPE_NONE) {
271 _vcui_view_dialing_draw_txt_ended(ad->view_st[ad->view_top], end_type);
272 } else if (ad->call_end_type == CALL_END_TYPE_SINGLE_CALL) {
273 common_data->time_end_flag = TIME_END_START; /*to stop timer from updating the call end screen */
274 _vcui_view_common_set_text_time(_vcui_get_endcause_string(end_type, data));
277 if (common_data->tm_end_dialing) {
278 ecore_timer_del(common_data->tm_end_dialing);
279 common_data->tm_end_dialing = NULL;
281 common_data->bredial = bredial;
282 common_data->tm_end_dialing = ecore_timer_add(TIMER_TIMEOUT_2_SEC, __vcui_view_common_timer_end_dialing_cb, NULL);
286 void _vcui_view_common_call_end_show(time_t start_time, int end_type)
288 CALL_UI_DEBUG("end_type:[%d]", end_type);
289 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
291 if (common_data->tm_end) {
292 ecore_timer_del(common_data->tm_end);
293 common_data->tm_end = NULL;
295 common_data->time_end_flag = TIME_END_START;
296 _vcui_view_common_set_each_time(start_time);
298 common_data->end_type = end_type;
299 common_data->tm_end = ecore_timer_add(TIMER_TIMEOUT_0_3_SEC, __vcui_view_common_timer_end_cb, NULL);
302 void _vcui_view_common_call_end_timer_reset(void)
305 vcui_view_common_t *common_data = __vcui_view_common_get_common_data();
306 if (common_data->tm_end) {
307 ecore_timer_del(common_data->tm_end);
308 common_data->tm_end = NULL;
311 if (common_data->tm_end_dialing) {
312 ecore_timer_del(common_data->tm_end_dialing);
313 common_data->tm_end_dialing = NULL;
316 common_data->tm_end_force = ecore_timer_add(TIMER_TIMEOUT_2_SEC, __vcui_view_common_timer_end_force_cb, NULL);
319 int _vcui_view_common_call_terminate_or_view_change(void)
322 vcui_app_call_data_t *ad = _vcui_get_app_data();
324 if (_vcui_doc_get_all_call_data_count() == 0) {
325 if (ad->contact_ug == NULL) {
326 CALL_UI_DEBUG("EXIT - contact ug is closed");
329 CALL_UI_DEBUG("show contact ug");
330 CALL_UI_DEBUG("hide & destory [%d]", ad->view_top);
331 if (ad->view_top != -1) {
332 ad->view_st[ad->view_top]->onHide(ad->view_st[ad->view_top]);
333 ad->view_st[ad->view_top]->onDestroy(ad->view_st[ad->view_top]);
336 evas_object_show((Evas_Object *)ug_get_layout(ad->contact_ug));
339 _vcui_view_auto_change();
344 void _vcui_view_common_show_noid_image(Evas_Object *layout)
347 vcui_app_call_data_t *ad = _vcui_get_app_data();
348 Evas_Object *noid_icon = NULL;
350 noid_icon = edje_object_part_swallow_get(_EDJ(layout), "swl-cid-noid");
352 edje_object_part_unswallow(_EDJ(layout), noid_icon);
353 evas_object_del(noid_icon);
356 noid_icon = elm_image_add(ad->win_main);
357 elm_object_part_content_set(layout, "swl-cid-noid", noid_icon);
358 elm_image_file_set(noid_icon, MO_NOCALLER_ID_ICON, NULL);
360 edje_object_signal_emit(_EDJ(layout), "show-noid-image", "show-noid");
363 void _vcui_view_common_update_mute_btn()
365 vcui_app_call_data_t *ad = _vcui_get_app_data();
366 vcui_app_call_view_id_t view_id = ad->view_top;
367 voice_call_view_data_t *vd = ad->view_st[view_id];
368 VCUI_RETURN_IF_FAIL(vd);
373 if (view_id == VIEW_DIALLING_VIEW) {
374 valid = _vc_ui_view_dialing_check_valid_eo(vd);
375 } else if (view_id == VIEW_INCALL_ONECALL_VIEW) {
376 valid = _vc_ui_view_single_call_check_valid_eo(vd);
377 } else if (view_id == VIEW_INCALL_MULTICALL_SPLIT_VIEW) {
378 valid = _vcui_view_multi_call_split_check_valid_eo(vd);
379 } else if (view_id == VIEW_INCALL_MULTICALL_CONF_VIEW) {
380 valid = _vcui_view_multi_call_conf_check_valid_eo(vd);
381 } else if (view_id == VIEW_INCALL_MULTICALL_LIST_VIEW) {
382 valid = _vcui_view_multi_call_list_check_valid_eo(vd);
384 CALL_UI_DEBUG("[============ BAD INPUT!!!! Check Input Layout!!!!! %d============]", view_id);
387 CALL_UI_DEBUG("[========== WARNING!! Invalid Evas Object ==========]");
392 _vcui_create_bottom_middle_button(vd);