apply FSL(Flora Software License)
[apps/home/call.git] / ui / vcui-view-single-call.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
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
7  *
8  * http://www.tizenopensource.org/license
9  *
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.
15  */
16
17
18 #include "vcui-application.h"
19 #include "vcui-view-common.h"
20 #include "vcui-view-single-call.h"
21 #include "vcui-view-elements.h"
22  
23 static int __vc_ui_view_single_call_oncreate(voice_call_view_data_t *view_data, int param1, void *param2, void *param3);
24 static int __vc_ui_view_single_call_onupdate(voice_call_view_data_t *view_data, void *update_data1, void *update_data2);
25 static int __vc_ui_view_single_call_onhide(voice_call_view_data_t *view_data);
26 static int __vc_ui_view_single_call_onshow(voice_call_view_data_t *view_data);
27 static int __vc_ui_view_single_call_ondestroy(voice_call_view_data_t *view_data);
28
29 static voice_call_view_data_t s_view = {
30         .type = VIEW_INCALL_ONECALL_VIEW,
31         .app_data = NULL,
32         .layout = NULL,
33         .onCreate = __vc_ui_view_single_call_oncreate,
34         .onUpdate = __vc_ui_view_single_call_onupdate,
35         .onHide = __vc_ui_view_single_call_onhide,
36         .onShow = __vc_ui_view_single_call_onshow,
37         .onDestroy = __vc_ui_view_single_call_ondestroy,
38         .priv = NULL,
39 };
40
41 voice_call_view_data_t *_vc_ui_view_single_call_new(vcui_app_call_data_t *ad)
42 {
43         s_view.app_data = ad;
44         s_view.priv = calloc(1, sizeof(incall_one_view_priv_t));
45
46         if (!s_view.priv) {
47                 CALL_UI_DEBUG("ERROR!!!!!!!!!!!");
48         }
49
50         return &s_view;
51 }
52
53 static void __vc_ui_view_single_call_draw_screen(Evas_Object *eo, void *data)
54 {
55         CALL_UI_DEBUG("..");
56
57         voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
58         incall_one_view_priv_t *priv = (incall_one_view_priv_t *)vd->priv;
59         vcui_app_call_data_t *ad = vd->app_data;
60
61         if (priv->now_data == NULL) {
62                 CALL_UI_DEBUG("Now Data is NULL");
63                 return;
64         }
65
66         /* ============ Check valid Evas Object ============= */
67         int valid = 0;
68         CALL_UI_KPI("_vcui_check_valid_eo ONEVIEW start");
69         valid = _vcui_check_valid_eo(priv->contents, "ONEVIEW");
70         CALL_UI_KPI("_vcui_check_valid_eo ONEVIEW done");
71         if (valid == -1) {
72                 CALL_UI_DEBUG("[========== ONEVIEW : Invalid Evas Object, priv->contents : %p ==========]", priv->contents);
73                 return;
74         }
75         /* ============ Check valid Evas Object ============= */
76
77         /* call image */
78         if (strcmp((char *)priv->now_data->call_file_path, NOIMG_ICON) == 0) {
79                 _vcui_show_wallpaper_image(priv->contents);
80         } else {
81                 CALL_UI_DEBUG("some image case!!");
82                 _vcui_show_wallpaper_image(priv->contents);
83                 priv->ic = _vcui_show_contact_image(priv->contents, vd->app_data->win_main, priv->now_data->call_file_path);
84                 if (priv->now_data->caller_status == CALL_HOLD) {
85                         double scale_factor = 0.0;
86                         scale_factor = elm_config_scale_get();
87                         CALL_UI_DEBUG("scale_factor %f", scale_factor);
88
89                         if (scale_factor == 1.0) {
90                                 edje_object_signal_emit(_EDJ(priv->contents), "SHOW_DIM_HD", "CID_HD");
91                         } else {
92                                 edje_object_signal_emit(_EDJ(priv->contents), "SHOW_DIM_WVGA", "CID_WVGA");
93                         }
94                 } else {
95                         edje_object_signal_emit(_EDJ(priv->contents), "HIDE_DIM", "CID");
96                 }
97         }
98
99         /* call name (if nothing, call number) */
100         CALL_UI_KPI("edje_object_part_text_set start");
101         if (strlen((char *)priv->now_data->call_display) == 0) {
102                 edje_object_part_text_set(_EDJ(eo), "txt_call_name", (char *)priv->now_data->call_num);
103         } else {
104                 edje_object_part_text_set(_EDJ(eo), "txt_call_name", (char *)priv->now_data->call_display);
105                 edje_object_part_text_set(_EDJ(eo), "txt_contact_phone_type", (char *)priv->now_data->call_num);
106         }
107         CALL_UI_KPI("edje_object_part_text_set done");
108
109         CALL_UI_KPI("_vcui_view_common_set_each_time start");
110         _vcui_view_common_set_each_time(priv->now_data->start_time);
111         CALL_UI_KPI("_vcui_view_common_set_each_time done");
112
113         CALL_UI_KPI("_vcui_create_top_left_button start");
114         _vcui_create_top_left_button(vd);
115         CALL_UI_KPI("_vcui_create_top_left_button done");
116
117         CALL_UI_KPI("_vcui_create_top_right_button start");
118         _vcui_create_top_right_button(vd);
119         CALL_UI_KPI("_vcui_create_top_right_button done");
120
121         CALL_UI_KPI("_vcui_create_bottom_left_button start");
122         _vcui_create_bottom_left_button(vd);
123         CALL_UI_KPI("_vcui_create_bottom_left_button done");
124
125         CALL_UI_KPI("_vcui_create_bottom_middle_button start");
126         _vcui_create_bottom_middle_button(vd);
127         CALL_UI_KPI("_vcui_create_bottom_middle_button done");
128
129         if ((_vcui_is_phonelock_status() == EINA_TRUE)&&(_vcui_is_idle_lock() == EINA_TRUE)) {
130                 CALL_UI_KPI("_vcui_create_top_middle_button start");
131                 _vcui_create_top_middle_button_disabled(vd);
132                 CALL_UI_KPI("_vcui_create_top_middle_button done");
133
134                 CALL_UI_KPI("_vcui_create_bottom_right_button start");
135                 _vcui_create_bottom_right_button_disabled(vd);
136                 CALL_UI_KPI("_vcui_create_bottom_right_button done");
137         } else {
138                 CALL_UI_KPI("_vcui_create_top_middle_button start");
139                 _vcui_create_top_middle_button(vd);
140                 CALL_UI_KPI("_vcui_create_top_middle_button done");
141
142                 _vcui_create_bottom_right_button(vd);
143         }
144
145         CALL_UI_KPI("_vcui_create_button_bigend start");
146         _vcui_create_button_bigend(vd);
147         CALL_UI_KPI("_vcui_create_button_bigend done");
148
149         CALL_UI_KPI("edje_object_signal_emit effect start");
150         if (ad->beffect_needed == EINA_TRUE) {
151                 edje_object_signal_emit(_EDJ(priv->contents), "SHOW_EFFECT", "ALLBTN");
152                 ad->beffect_needed = EINA_FALSE;
153         } else {
154                 edje_object_signal_emit(_EDJ(priv->contents), "SHOW_NO_EFFECT", "ALLBTN");
155         }
156         CALL_UI_KPI("edje_object_signal_emit effect done");
157
158         CALL_UI_KPI("evas_object_show start");
159         evas_object_show(eo);
160         CALL_UI_KPI("evas_object_show done");
161 }
162
163 static Evas_Object *__vc_ui_view_single_call_create_contents(void *data)
164 {
165         if (data == NULL) {
166                 CALL_UI_DEBUG("ERROR");
167                 return NULL;
168         }
169         voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
170         Evas_Object *eo = NULL;
171
172         /* load edje */
173         eo = _vcui_load_edj(vd->app_data->win_main, EDJ_NAME, GRP_INCALL);
174         if (eo == NULL)
175                 return NULL;
176
177         return eo;
178 }
179
180 static Evas_Object *__vc_ui_view_single_call_create_layout_main(Evas_Object *parent)
181 {
182         if (parent == NULL) {
183                 CALL_UI_DEBUG("ERROR");
184                 return NULL;
185         }
186
187         Evas_Object *ly;
188         ly = elm_layout_add(parent);
189         retvm_if(ly == NULL, NULL, "Failed elm_layout_add.");
190
191         elm_layout_theme_set(ly, "standard", "window", "integration");
192         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
193         elm_win_resize_object_add(parent, ly);
194
195         edje_object_signal_emit(_EDJ(ly), "elm,state,show,indicator", "elm");
196         edje_object_signal_emit(_EDJ(ly), "elm,state,show,content", "elm");
197         evas_object_show(ly);
198
199         return ly;
200 }
201
202 static int __vc_ui_view_single_call_oncreate(voice_call_view_data_t *view_data, int param1, void *param2, void *param3)
203 {
204         CALL_UI_DEBUG("incall view create");
205         voice_call_view_data_t *vd = view_data;
206         incall_one_view_priv_t *priv = (incall_one_view_priv_t *)vd->priv;
207
208         priv->now_data = _vcui_doc_get_first();
209         if (priv->now_data == NULL) {
210                 CALL_UI_DEBUG("call data is null");
211                 return VC_ERROR;
212         }
213
214         if (!vd->layout) {
215
216                 CALL_UI_KPI("__vc_ui_view_single_call_create_layout_main start");
217                 vd->layout = __vc_ui_view_single_call_create_layout_main(vd->app_data->win_main);
218                 CALL_UI_KPI("__vc_ui_view_single_call_create_layout_main done");
219                 if (vd->layout == NULL) {
220                         CALL_UI_DEBUG("ERROR");
221                         return VC_ERROR;
222                 }
223
224                 CALL_UI_KPI("__vc_ui_view_single_call_create_contents start");
225                 priv->contents = __vc_ui_view_single_call_create_contents(vd);
226                 elm_object_part_content_set(vd->layout, "elm.swallow.content", priv->contents);
227                 CALL_UI_KPI("__vc_ui_view_single_call_create_contents done");
228
229                 CALL_UI_KPI("evas_object_name_set start");
230                 evas_object_name_set(priv->contents, "ONEVIEW");
231                 CALL_UI_KPI("evas_object_name_set done");
232                 CALL_UI_DEBUG("[========== ONEVIEW: priv->contents Addr : [%p] ==========]", priv->contents);
233
234         } else {
235                 CALL_UI_DEBUG("[UI]ad->layout_incall==NULL case ");
236                 evas_object_show(vd->layout);
237         }
238
239         __vc_ui_view_single_call_onshow(view_data);
240         return VC_NO_ERROR;
241 }
242
243 static int __vc_ui_view_single_call_onupdate(voice_call_view_data_t *view_data, void *update_data1, void *update_data2)
244 {
245         CALL_UI_DEBUG("incall view update");
246
247         __vc_ui_view_single_call_onshow(view_data);
248
249         return VC_NO_ERROR;
250 }
251
252 static int __vc_ui_view_single_call_onhide(voice_call_view_data_t *view_data)
253 {
254         CALL_UI_DEBUG("incall view hide");
255
256         evas_object_hide(view_data->layout);
257         return VC_NO_ERROR;
258 }
259
260 static int __vc_ui_view_single_call_onshow(voice_call_view_data_t *view_data)
261 {
262         CALL_UI_DEBUG("incall view show");
263         CALL_UI_KPI("__vc_ui_view_single_call_onshow start");
264         incall_one_view_priv_t *priv = (incall_one_view_priv_t *)view_data->priv;
265
266         priv->now_data = _vcui_doc_get_first();
267         if (priv->now_data == NULL) {
268                 CALL_UI_DEBUG("call data is null");
269                 return VC_ERROR;
270         }
271         CALL_UI_KPI("__vc_ui_view_single_call_draw_screen start");
272         __vc_ui_view_single_call_draw_screen(priv->contents, view_data);
273         CALL_UI_KPI("__vc_ui_view_single_call_draw_screen done");
274
275
276         CALL_UI_KPI("incall-one-view hide start");
277         evas_object_hide(view_data->layout);
278         CALL_UI_KPI("incall-one-view hide done");
279         CALL_UI_KPI("incall-one-view show start");
280         evas_object_show(view_data->layout);
281         CALL_UI_KPI("incall-one-view show done");
282         CALL_UI_KPI("__vc_ui_view_single_call_onshow done");
283         return VC_NO_ERROR;
284 }
285
286 static int __vc_ui_view_single_call_ondestroy(voice_call_view_data_t *view_data)
287 {
288         CALL_UI_DEBUG("incall view destroy");
289
290         vcui_app_call_data_t *ad = _vcui_get_app_data();
291
292         voice_call_view_data_t *vd = ad->view_st[VIEW_INCALL_ONECALL_VIEW];
293         incall_one_view_priv_t *priv = (incall_one_view_priv_t *)vd->priv;
294
295         if (priv != NULL) {
296                 if (priv->contents) {
297                         evas_object_del(priv->contents);
298                         priv->contents = NULL;
299                 }
300
301                 free(priv);
302                 priv = NULL;
303         }
304
305         if (vd->layout != NULL) {
306                 evas_object_hide(vd->layout);
307                 evas_object_del(vd->layout);
308                 vd->layout = NULL;
309         }
310
311         ad->view_st[VIEW_INCALL_ONECALL_VIEW] = NULL;
312
313         _vcui_cache_flush();
314         CALL_UI_DEBUG("complete destroy one view");
315         return VC_NO_ERROR;
316 }