apply FSL(Flora Software License)
[apps/home/call.git] / ui / vcui-view-callend.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-callend.h"
21 #include "vcui-view-elements.h"
22
23 static call_data_t *call_data = NULL;
24
25 static int __vcui_view_callend_oncreate(voice_call_view_data_t *view_data, int param1, void *param2, void *param3);
26 static int __vcui_view_callend_onupdate(voice_call_view_data_t *view_data, void *update_data1, void *update_data2);
27 static int __vcui_view_callend_onhide(voice_call_view_data_t *view_data);
28 static int __vcui_view_callend_onshow(voice_call_view_data_t *view_data);
29 static int __vcui_view_callend_ondestroy(voice_call_view_data_t *view_data);
30
31 static voice_call_view_data_t s_view = {
32         .type = VIEW_ENDCALL_VIEW,
33         .app_data = NULL,
34         .layout = NULL,
35         .onCreate = __vcui_view_callend_oncreate,
36         .onUpdate = __vcui_view_callend_onupdate,
37         .onHide = __vcui_view_callend_onhide,
38         .onShow = __vcui_view_callend_onshow,
39         .onDestroy = __vcui_view_callend_ondestroy,
40         .priv = NULL,
41 };
42
43 voice_call_view_data_t *_vcui_view_callend_new(vcui_app_call_data_t *ad)
44 {
45         s_view.app_data = ad;
46         s_view.priv = calloc(1, sizeof(endcall_view_priv_t));
47
48         if (!s_view.priv) {
49                 CALL_UI_DEBUG("ERROR!!!!!!!!!!!");
50         }
51
52         return &s_view;
53 }
54
55 static void __vcui_view_callend_draw_screen(Evas_Object *eo, void *data)
56 {
57         CALL_UI_DEBUG("..");
58
59         voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
60         endcall_view_priv_t *priv = (endcall_view_priv_t *)vd->priv;
61         vcui_app_call_data_t *ad = vd->app_data;
62
63         /* ============ Check valid Evas Object ============= */
64         int valid = 0;
65         valid = _vcui_check_valid_eo(priv->contents, "ENDCALLVIEW");
66         if (valid == -1) {
67                 CALL_UI_DEBUG("[========== ENDCALLVIEW : Invalid Evas Object, priv->contents : %p ==========]", priv->contents);
68                 return;
69         }
70         /* ============ Check valid Evas Object ============= */
71
72         if (ad->call_end_type == CALL_END_TYPE_SINGLE_CALL) {
73                 CALL_UI_DEBUG("CALL_END_TYPE_SINGLE_CALL type end screen");
74
75                 /* call image */
76                 _vcui_delete_contact_image(priv->contents);
77                 if (strcmp((char *)call_data->call_file_path, NOIMG_ICON) == 0 && strcmp((char *)call_data->call_full_file_path, NOIMG_ICON) == 0) {
78                         _vcui_show_wallpaper_image(priv->contents);
79                 } else {
80                         if (strcmp((char *)call_data->call_full_file_path, NOIMG_ICON) == 0) {  /* normal size */
81                                 _vcui_show_wallpaper_image(priv->contents);
82                                 priv->ic = _vcui_show_contact_image(priv->contents, vd->app_data->win_main, call_data->call_file_path);
83                         } else {                /* full size */
84                                 _vcui_set_full_image(priv->contents, vd->app_data->win_main, call_data->call_full_file_path);
85                         }
86                 }
87
88                 /* call name (if nothing, call number) */
89                 if (strlen((char *)call_data->call_display) == 0) {
90                         edje_object_part_text_set(_EDJ(eo), "txt_call_name", (char *)call_data->call_num);
91                         edje_object_signal_emit(_EDJ(eo), "show-all-buttons", "end-screen");
92                 } else {
93                         edje_object_part_text_set(_EDJ(eo), "txt_call_name", (char *)call_data->call_display);
94                         edje_object_part_text_set(_EDJ(eo), "txt_contact_phone_type", (char *)call_data->call_num);
95                         edje_object_signal_emit(_EDJ(eo), "show-some-buttons", "end-screen");
96                 }
97
98                 _vcui_view_common_set_each_time(call_data->start_time);
99         } else if (ad->call_end_type == CALL_END_TYPE_CONF_CALL) {
100                 CALL_UI_DEBUG("CALL_END_TYPE_CONF_CALL type end screen");
101                 char buf[DEF_BUF_LEN] = { 0, };
102
103                 /* Conference image */
104                 _vcui_show_wallpaper_image(priv->contents);
105                 priv->ic = _vcui_show_default_image(priv->contents, vd->app_data->win_main, CONF_ICON);
106                 if (priv->call_status == CALL_HOLD) {
107                         double scale_factor = 0.0;
108                         scale_factor = elm_config_scale_get();
109                         CALL_UI_DEBUG("scale_factor %f", scale_factor);
110
111                         if (scale_factor == 1.0) {
112                                 edje_object_signal_emit(_EDJ(priv->contents), "SHOW_DIM_HD", "CID_HD");
113                         } else {
114                                 edje_object_signal_emit(_EDJ(priv->contents), "SHOW_DIM_WVGA", "CID_WVGA");
115                         }
116                 } else {
117                         edje_object_signal_emit(_EDJ(priv->contents), "HIDE_DIM", "CID");
118                 }
119
120                 edje_object_part_text_set(_EDJ(eo), "txt_call_name", _("IDS_CALL_OPT_CONFERENCE_CALL"));
121                 snprintf(buf, DEF_BUF_LEN, "%d %s", (_vcui_doc_get_count_hold() + _vcui_doc_get_count_unhold()), _("IDS_CALL_BODY_PEOPLE"));
122                 edje_object_part_text_set(_EDJ(eo), "txt_contact_phone_type", buf);             /* in case of multicallconf, it is num of people */
123
124                 _vcui_create_top_left_button_disabled(vd);
125                 _vcui_create_top_middle_button_disabled(vd);
126                 _vcui_create_top_right_button_disabled(vd);
127                 _vcui_create_bottom_left_button_disabled(vd);
128                 _vcui_create_bottom_middle_button_disabled(vd);
129                 _vcui_create_bottom_right_button_disabled(vd);
130
131                 _vcui_create_button_bigend_disabled(vd);
132
133         } else {
134                 CALL_UI_DEBUG("invalid type... return");
135                 return;
136         }
137
138         evas_object_show(eo);
139 }
140
141 static Evas_Object *__vcui_view_callend_create_contents(void *data)
142 {
143         if (data == NULL) {
144                 CALL_UI_DEBUG("ERROR");
145                 return NULL;
146         }
147         voice_call_view_data_t *vd = (voice_call_view_data_t *)data;
148         vcui_app_call_data_t *ad = vd->app_data;
149         Evas_Object *eo = NULL;
150
151         /* load edje */
152         if (ad->call_end_type == CALL_END_TYPE_SINGLE_CALL)
153                 eo = _vcui_load_edj(vd->app_data->win_main, EDJ_NAME, GRP_END_SINGLECALL);
154         else if (ad->call_end_type == CALL_END_TYPE_CONF_CALL)
155                 eo = _vcui_load_edj(vd->app_data->win_main, EDJ_NAME, GRP_END_CONFCALL);
156
157         if (eo == NULL)
158                 return NULL;
159
160         return eo;
161 }
162
163 static Evas_Object *__vcui_view_callend_create_layout_main(Evas_Object *parent)
164 {
165         if (parent == NULL) {
166                 CALL_UI_DEBUG("ERROR");
167                 return NULL;
168         }
169
170         Evas_Object *ly;
171         ly = elm_layout_add(parent);
172         retvm_if(ly == NULL, NULL, "Failed elm_layout_add.");
173
174         elm_layout_theme_set(ly, "standard", "window", "integration");
175         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
176         elm_win_resize_object_add(parent, ly);
177
178         edje_object_signal_emit(_EDJ(ly), "elm,state,show,indicator", "elm");
179         edje_object_signal_emit(_EDJ(ly), "elm,state,show,content", "elm");
180         evas_object_show(ly);
181
182         return ly;
183 }
184
185 static int __vcui_view_callend_oncreate(voice_call_view_data_t *view_data, int param1, void *param2, void *param3)
186 {
187         CALL_UI_DEBUG("endcall view create");
188         voice_call_view_data_t *vd = view_data;
189         vcui_app_call_data_t *ad = vd->app_data;
190         endcall_view_priv_t *priv = (endcall_view_priv_t *)vd->priv;
191
192         CALL_UI_DEBUG("call_end_type[%d]", ad->call_end_type);
193         if (ad->call_end_type == CALL_END_TYPE_SINGLE_CALL) {
194                 call_data = (call_data_t *)param2;
195         } else if (ad->call_end_type == CALL_END_TYPE_CONF_CALL) {
196                 priv->call_status = _vcui_doc_get_show_callstatus();
197                 call_data = _vcui_doc_get_last_status(priv->call_status);
198         }
199
200         if (call_data == NULL) {
201                 CALL_UI_DEBUG("call Data is NULL");
202                 return;
203         }
204
205         if (!vd->layout) {
206
207                 /* Create Main Layout */
208                 vd->layout = __vcui_view_callend_create_layout_main(vd->app_data->win_main);
209                 if (vd->layout == NULL) {
210                         CALL_UI_DEBUG("ERROR");
211                         return VC_ERROR;
212                 }
213                 /* Create Contents */
214                 priv->contents = __vcui_view_callend_create_contents(vd);
215                 elm_object_part_content_set(vd->layout, "elm.swallow.content", priv->contents);
216
217                 evas_object_name_set(priv->contents, "ENDCALLVIEW");
218                 CALL_UI_DEBUG("[========== ENDCALLVIEW: priv->contents Addr : [%p] ==========]", priv->contents);
219
220         } else {
221                 CALL_UI_DEBUG("[UI]ad->layout_end call==NULL case ");
222                 evas_object_show(vd->layout);
223         }
224
225         __vcui_view_callend_onshow(view_data);
226         return VC_NO_ERROR;
227 }
228
229 static int __vcui_view_callend_onupdate(voice_call_view_data_t *view_data, void *update_data1, void *update_data2)
230 {
231         CALL_UI_DEBUG("end call view update");
232
233         __vcui_view_callend_onshow(view_data);
234
235         return VC_NO_ERROR;
236 }
237
238 static int __vcui_view_callend_onhide(voice_call_view_data_t *view_data)
239 {
240         CALL_UI_DEBUG("end call view hide");
241
242         evas_object_hide(view_data->layout);
243         return VC_NO_ERROR;
244 }
245
246 static int __vcui_view_callend_onshow(voice_call_view_data_t *view_data)
247 {
248         CALL_UI_DEBUG("end call view show");
249         CALL_UI_KPI("__vcui_view_callend_onshow start");
250         endcall_view_priv_t *priv = (endcall_view_priv_t *)view_data->priv;
251
252         __vcui_view_callend_draw_screen(priv->contents, view_data);
253
254         evas_object_hide(view_data->layout);
255         evas_object_show(view_data->layout);
256         return VC_NO_ERROR;
257 }
258
259 static int __vcui_view_callend_ondestroy(voice_call_view_data_t *view_data)
260 {
261         CALL_UI_DEBUG("endcall view destroy");
262
263         vcui_app_call_data_t *ad = _vcui_get_app_data();
264
265         voice_call_view_data_t *vd = ad->view_st[VIEW_ENDCALL_VIEW];
266         endcall_view_priv_t *priv = (endcall_view_priv_t *)vd->priv;
267
268         if (priv != NULL) {
269                 if (priv->contents) {
270                         evas_object_del(priv->contents);
271                         priv->contents = NULL;
272                 }
273
274                 free(priv);
275                 priv = NULL;
276         }
277
278         if (vd->layout != NULL) {
279                 evas_object_hide(vd->layout);
280                 evas_object_del(vd->layout);
281                 vd->layout = NULL;
282         }
283
284         ad->view_st[VIEW_ENDCALL_VIEW] = NULL;
285         call_data = NULL;
286         ad->call_end_type = CALL_END_TYPE_NONE;
287
288         _vcui_cache_flush();
289         CALL_UI_DEBUG("complete destroy one view");
290         return VC_NO_ERROR;
291 }