Tizen 2.1 base
[apps/home/call-setting.git] / src / cst-barring.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://floralicense.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 #ifdef _CALL_SET_BARRING_SUPPORT
18
19 #include <Elementary.h>
20
21 #include "cst-common-string.h"
22 #include "cst-call-setting.h"
23
24 #include "cst-barring.h"
25 #include "cst-barring-ime.h"
26 #include "cst-widget.h"
27 #include "cst-common.h"
28 #include "cst-tapi-request.h"
29 #include "cst-util.h"
30
31 static void __cst_destroy_genlist_item_styles(void);
32 static void __cst_on_click_cb_onoff(void *data, Evas *evas, Evas_Object *obj, void *event_info);
33 static void __cst_on_click_voice_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
34 static void __cst_on_click_cf_voice_video_back_button(void *data, Evas_Object *obj, void *event_info);
35
36 static Elm_Genlist_Item_Class *itc_1text_1icon = NULL;
37 static Elm_Genlist_Item_Class *itc_1text = NULL;
38 Evas_Object *ec_item[3];
39
40 static Evas_Object *barring_gl = NULL;
41
42 static gboolean keypad_enabled = EINA_FALSE;
43
44 static CstGlItemDisplayInfo_t list_call_type[] = {
45         {1, CST_STR_VOICECALL, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_TEXT, __cst_on_click_voice_cb},
46         {1, -1, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_NONE, NULL},
47 };
48
49 static CstGlItemDisplayInfo_t list_call_barring[] = {
50         {1, CST_STR_CALL_ALL_OUTGOING_CALLS, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF_PROGRESS, __cst_on_click_cb_onoff},
51         {1, CST_STR_INTL_CALLS, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF_PROGRESS, __cst_on_click_cb_onoff},
52         {1, CST_STR_CALL_INTL_EXCEPT_HOME, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF_PROGRESS, __cst_on_click_cb_onoff},
53         {1, CST_STR_ALL_INCOMING_CALLS, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF_PROGRESS, __cst_on_click_cb_onoff},
54         {1, CST_STR_CALL_INCOMING_WHEN_ROAMING, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF_PROGRESS, __cst_on_click_cb_onoff},
55
56         {1, -1, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_NONE, NULL},
57 };
58
59 static void __cst_destroy_genlist_item_styles(void)
60 {
61         ENTER(__cst_destroy_genlist_item_styles);
62
63         if (itc_1text_1icon) {
64                 elm_genlist_item_class_free(itc_1text_1icon);
65                 itc_1text_1icon = NULL;
66         }
67         if (itc_1text) {
68                 elm_genlist_item_class_free(itc_1text);
69                 itc_1text = NULL;
70         }
71 }
72
73 void _cst_call_barring_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
74 {
75         ENTER(_cst_call_barring_entry_changed_cb);
76         ret_if(!data);
77         CstUgData_t *ugd = (CstUgData_t *)data;
78         Evas_Object *btn = NULL;
79         const char *entry_input = NULL;
80
81         Elm_Object_Item *top_it = elm_naviframe_top_item_get(ugd->nf);
82         ret_if(!top_it);
83
84         entry_input = elm_entry_entry_get(ugd->dg_entry);
85         if ((btn = elm_object_item_part_content_get(top_it, "title_left_btn")) != NULL) {
86                 if (entry_input && strlen(entry_input) > 0) {
87                         elm_object_disabled_set(btn, EINA_FALSE);
88                 } else {
89                         elm_object_disabled_set(btn, EINA_TRUE);
90                 }
91         } else {
92                 if (entry_input && strlen(entry_input) > 0) {
93                         elm_object_disabled_set(ec_item[0], EINA_FALSE);
94                 } else {
95                         elm_object_disabled_set(ec_item[0], EINA_TRUE);
96                 }
97         }
98 }
99
100 static void __cst_on_click_cf_voice_video_back_button(void *data, Evas_Object *obj, void *event_info)
101 {
102         ENTER(__cst_on_click_cf_voice_video_back_button);
103
104         retm_if(data == NULL, "NULL UgData");
105
106         CstUgData_t *ugd = (CstUgData_t *)data;
107
108         ugd->back_button = _cst_get_navifr_prev_btn(ugd->nf);
109         _cst_cancel_all_ss_request(ugd);
110 }
111
112 static void __cst_on_click_cb_back_button(void *data, Evas_Object *obj, void *event_info)
113 {
114         ENTER(__cst_on_click_cb_back_button);
115
116         __cst_on_click_cf_voice_video_back_button(data, obj, event_info);
117
118         _cst_destroy_call_barring();
119 }
120
121 static void __cst_disable_cb_glitem(CstGlItemData_t *item_data)
122 {
123         ENTER(__cst_disable_cb_glitem);
124         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
125         ugd->cb_state[item_data->index] = CST_SS_STATE_OFF;
126         elm_genlist_item_update(item_data->gl_item);
127 #ifdef  _CALL_SET_TBD
128         elm_object_item_disabled_set(item_data->gl_item, EINA_TRUE);
129 #endif  /* _CALL_SET_TBD */
130 }
131
132 static int __cst_update_cb_state(int call_type, int cb_flavour,
133                                                                  Eina_Bool cb_state, char *number,
134                                                                  int error, int req_action, void *data)
135 {
136         retv_if(NULL == data, -1);
137         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
138         CstUgData_t *ugd = item_data->ugd;
139         DBG("call_type=%d (0:voice 1:video)", call_type);
140         DBG("cb_flavour=%d (6:BAOC 7:BAOIC 8:BAOIC exc home 9:BAIC 10:BAIC roaming)", cb_flavour);
141         DBG("cb_state=%d (1:on 0:off), error=%d", cb_state, error);
142         DBG("req_action=%d(0: Activate, 1:Deactivate, 2:Query)", req_action);
143         retv_if((call_type != ugd->call_type && call_type != CST_CALLTYPE_ALL), -1);
144
145         if (error == CST_ERROR_NONE) {
146                 if (cb_state == EINA_TRUE) {
147                         ugd->cb_state[item_data->index] = CST_SS_STATE_ON;
148                 } else {
149                         ugd->cb_state[item_data->index] = CST_SS_STATE_OFF;
150                 }
151                 elm_genlist_item_update(item_data->gl_item);
152         } else {
153                 if (req_action != CST_ACTION_QUERY) {
154                         if (error != CST_ERROR_SERVICE_UNAVAILABLE &&
155                                         error != CST_ERROR_REJECTED_BY_NETWORK &&
156                                         error != CST_ERROR_UNKNOWN) {
157                                 if (req_action == CST_ACTION_DEACTIVATE) {
158                                         ugd->cb_state[item_data->index] = CST_SS_STATE_ON;
159                                 } else {
160                                         ugd->cb_state[item_data->index] = CST_SS_STATE_OFF;
161                                 }
162                         } else {
163                                 ugd->cb_state[item_data->index] = CST_SS_STATE_OFF;
164                         }
165
166                         elm_genlist_item_update(item_data->gl_item);
167                         ugd->popup = (Evas_Object *)_cst_create_error_popup(ugd->nf, error);
168                         evas_object_show(ugd->popup);
169                 } else {
170                         __cst_disable_cb_glitem(item_data);
171                 }
172         }
173         return 0;
174 }
175
176 static void __cst_query_cb_status(CstGlItemData_t *item_data)
177 {
178         ENTER(__cst_query_cb_status);
179         ret_if(NULL == item_data);
180         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
181         int cb_flavour = -1;
182
183         ugd->original_state = EINA_FALSE;
184         switch (item_data->index) {
185         case 0:
186                 cb_flavour = CST_SSTYPE_CB_OC;
187                 DBG("CST_SSTYPE_CB_OC");
188                 break;
189         case 1:
190                 cb_flavour = CST_SSTYPE_CB_OIC;
191                 DBG("CST_SSTYPE_CB_OIC");
192                 break;
193         case 2:
194                 cb_flavour = CST_SSTYPE_CB_OICEH;
195                 DBG("CST_SSTYPE_CB_OICEH");
196                 break;
197         case 3:
198                 cb_flavour = CST_SSTYPE_CB_IC;
199                 DBG("CST_SSTYPE_CB_IC");
200                 break;
201         case 4:
202                 cb_flavour = CST_SSTYPE_CB_ICR;
203                 DBG("CST_SSTYPE_CB_ICR");
204                 break;
205         default:
206                 DBG("Error type");
207                 break;
208         }
209
210         _cst_add_ss_request(&ugd->req_queue,
211                                                 CST_ACTION_QUERY, ugd->call_type, cb_flavour,
212                                                 NULL, __cst_update_cb_state, item_data, -1, ugd);
213 }
214
215 static void __cst_on_click_cb_ime_done_btn(void *data, Evas_Object *obj, void *event_info)
216 {
217         ENTER(__cst_on_click_cb_ime_done_btn);
218         ret_if(!data);
219
220         CallSettingSSReq_t *req = (CallSettingSSReq_t *)data;
221
222         CstGlItemData_t *item_data = (CstGlItemData_t *)req->data;
223         CstUgData_t *ugd = item_data->ugd;
224
225         Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ugd->dg_entry);
226
227         char buffer[CST_MAX_PHONE_NUMBER_LEN];
228
229         if (_cst_get_cb_input_password(buffer, ugd) > 0) {
230                 ugd->cb_state[item_data->index] = CST_SS_STATE_PROGRESS;
231                 elm_genlist_item_update(item_data->gl_item);
232
233                 DBG("activate CB pwd=%s", buffer);
234                 snprintf(req->number, CST_MAX_PHONE_NUMBER_LEN, "%s", buffer);
235                 _cst_add_ss_request(&ugd->req_queue,
236                                                         req->action, req->call_type, req->flavour,
237                                                         req->number, __cst_update_cb_state, item_data, -1, ugd);
238
239                 if (imf_context) {
240                         ecore_imf_context_input_panel_event_callback_del(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _cst_call_barring_input_panel_event_callback);
241                         ecore_imf_context_input_panel_enabled_set(imf_context, EINA_FALSE);
242                 }
243                 evas_object_smart_callback_del(ugd->dg_entry, "changed", _cst_call_barring_entry_changed_cb);
244                 evas_object_smart_callback_del(ugd->dg_entry, "preedit,changed", _cst_call_barring_entry_changed_cb);
245
246                 keypad_enabled = EINA_FALSE;
247
248                 memset(ugd->c_item, 0, sizeof(ugd->c_item));
249 /*              ecore_timer_add(CST_NAVIFRAME_ITEM_POP_TIMER, _cst_naviframe_item_pop_cb, ugd);
250 */
251                 _cst_naviframe_item_pop_cb(ugd);
252         }
253 }
254
255 static void __cst_on_click_cb_ime_cancel_btn(void *data, Evas_Object *obj, void *event_info)
256 {
257         ENTER(__cst_on_click_cb_ime_cancel_btn);
258         ret_if(!data);
259
260         CallSettingSSReq_t *req = (CallSettingSSReq_t *)data;
261         CstGlItemData_t *item_data = (CstGlItemData_t *)req->data;
262         CstUgData_t *ugd = item_data->ugd;
263
264         Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ugd->dg_entry);
265
266         DBG("original state : %d", req->original_state);
267         if (req->original_state == CST_SS_STATE_ON) {
268                 ugd->cb_state[item_data->index] = CST_SS_STATE_ON;
269         } else {
270                 ugd->cb_state[item_data->index] = CST_SS_STATE_OFF;
271         }
272         elm_genlist_item_update(item_data->gl_item);
273
274         if (imf_context) {
275                 ecore_imf_context_input_panel_event_callback_del(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _cst_call_barring_input_panel_event_callback);
276                 ecore_imf_context_input_panel_enabled_set(imf_context, EINA_FALSE);
277         }
278         evas_object_smart_callback_del(ugd->dg_entry, "changed", _cst_call_barring_entry_changed_cb);
279         evas_object_smart_callback_del(ugd->dg_entry, "preedit,changed", _cst_call_barring_entry_changed_cb);
280
281         keypad_enabled = EINA_FALSE;
282
283         memset(ugd->c_item, 0, sizeof(ugd->c_item));
284 /*      ecore_timer_add(CST_NAVIFRAME_ITEM_POP_TIMER, _cst_naviframe_item_pop_cb, ugd);
285 */
286         _cst_naviframe_item_pop_cb(ugd);
287         if (req) {
288                 free(req);
289         }
290 }
291
292 static char *__cst_gl_label_get_cb(void *data, Evas_Object *obj, const char *part)
293 {
294         retv_if(NULL == data, NULL);
295         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
296
297         if (strcmp(part, "elm.text") == 0) {
298                 if (list_call_barring[item_data->index].str_id != -1) {
299                         return strdup(T_(list_call_barring[item_data->index].str_id));
300                 }
301         }
302         return NULL;
303 }
304
305 static void __cst_gl_del_cb(void *data, Evas_Object *obj)
306 {
307         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
308         if (item_data) {
309                 free(item_data);
310         }
311         return;
312 }
313
314 static void __cst_update_change_cb_req(CstGlItemData_t *item_data, Eina_Bool req_state)
315 {
316         ret_if(item_data == NULL);
317
318         Evas_Object *eo;
319         CallSettingSSReq_t *req = NULL;
320         CstUgData_t *ugd = item_data->ugd;
321         Elm_Object_Item *navi_it;
322
323         req = (CallSettingSSReq_t *)calloc(1, sizeof(CallSettingSSReq_t));
324         ret_if(req == NULL);
325
326         ugd->popup = NULL;
327         req->data = item_data;
328         req->call_type = ugd->call_type;
329         req->flavour = -1;
330
331         DBG("req_state = %d", req_state);
332         switch (item_data->index) {
333         case 0:
334                 req->flavour = CST_SSTYPE_CB_OC;
335                 DBG("CST_SSTYPE_CB_OC");
336                 break;
337         case 1:
338                 req->flavour = CST_SSTYPE_CB_OIC;
339                 DBG("CST_SSTYPE_CB_OIC");
340                 break;
341         case 2:
342                 req->flavour = CST_SSTYPE_CB_OICEH;
343                 DBG("CST_SSTYPE_CB_OICEH");
344                 break;
345         case 3:
346                 req->flavour = CST_SSTYPE_CB_IC;
347                 DBG("CST_SSTYPE_CB_IC");
348                 break;
349         case 4:
350                 req->flavour = CST_SSTYPE_CB_ICR;
351                 DBG("CST_SSTYPE_CB_ICR");
352                 break;
353         default:
354                 DBG("Error type");
355                 break;
356         }
357
358         ugd->original_state = !req_state;
359         if (req_state == EINA_TRUE) {
360                 req->original_state = CST_SS_STATE_OFF;
361                 req->action = CST_ACTION_ACTIVATE;
362         } else {
363                 req->original_state = CST_SS_STATE_ON;
364                 req->action = CST_ACTION_DEACTIVATE;
365         }
366
367         eo = _cst_create_cb_ime(ugd->nf, NULL, ugd);
368
369         _cst_remove_naviframe(ugd->nf);
370         navi_it = elm_naviframe_item_push(ugd->nf,
371                                                                           T_(CST_STR_PASSWORD), NULL, NULL, eo, NULL);
372         elm_object_item_data_set(navi_it, req);
373 }
374
375 static void __cst_on_click_cb_onoff(void *data, Evas *evas, Evas_Object *obj, void *event_info)
376 {
377         ret_if(NULL == data);
378         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
379         CstUgData_t *ugd = item_data->ugd;
380         if (ugd->cb_state[item_data->index] == CST_SS_STATE_PROGRESS) {
381                 return;
382         }
383
384         Eina_Bool check_state = elm_check_state_get(item_data->eo_check);
385
386         __cst_update_change_cb_req(item_data, !check_state);
387         elm_genlist_item_update(item_data->gl_item);
388 }
389
390 static void __cst_gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
391 {
392         ret_if(data == NULL);
393         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
394         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
395         if (list_call_barring[item_data->index].func) {
396                 list_call_barring[item_data->index].func((void *)item_data, NULL, obj, event_info);
397         }
398         return;
399 }
400
401 static void __cst_on_changed_cb_check(void *data, Evas_Object *obj, void *event_info)
402 {
403         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
404         Eina_Bool check_state = elm_check_state_get(obj);
405
406         if (elm_object_item_disabled_get(item_data->gl_item) == EINA_TRUE) {
407                 elm_check_state_set(obj, EINA_FALSE);
408                 return;
409         }
410
411         __cst_update_change_cb_req(item_data, check_state);
412 }
413
414 static Evas_Object *__cst_gl_icon_get_cb(void *data, Evas_Object *obj, const char *part)
415 {
416         retv_if(NULL == data, NULL);
417         Evas_Object *icon = NULL;
418         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
419         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
420         Eina_Bool check_state = EINA_FALSE;
421
422         if (!strcmp(part, "elm.icon")) {
423                 switch (ugd->cb_state[item_data->index]) {
424                 case CST_SS_STATE_ON:
425                 case CST_SS_STATE_OFF:
426                         DBG("ugd->cb_state : %d(%d)",
427                                 ugd->cb_state[item_data->index], item_data->index);
428                         if (ugd->cb_state[item_data->index] == CST_SS_STATE_ON) {
429                                 check_state = EINA_TRUE;
430                         }
431                         item_data->eo_check = icon = _cst_create_onoff_button(obj, check_state,
432                                                                                  __cst_on_changed_cb_check, item_data);
433                         break;
434                 case CST_SS_STATE_PROGRESS:
435                         icon = _cst_create_progressbar(obj);
436                         break;
437                 default:
438                         return NULL;
439                 }
440         }
441         return icon;
442 }
443
444 static Evas_Object *__cst_create_genlist_cb(void *data)
445 {
446         ENTER(__cst_create_genlist_cb);
447         retv_if(NULL == data, NULL);
448         CstUgData_t *ugd = (CstUgData_t *)data;
449         int index = 0;
450         Evas_Object *genlist;
451         CstGlItemData_t *item_data;
452
453         itc_1text_1icon->item_style = "dialogue/1text.1icon";
454         itc_1text_1icon->func.text_get = __cst_gl_label_get_cb;
455         itc_1text_1icon->func.content_get = __cst_gl_icon_get_cb;
456         itc_1text_1icon->func.state_get = NULL;
457         itc_1text_1icon->func.del = __cst_gl_del_cb;
458
459         genlist = elm_genlist_add(ugd->nf);
460
461         _cst_create_genlist_separator(genlist, EINA_FALSE);
462         for (index = 0; list_call_barring[index].style != CST_GL_ITEM_NONE; ++index) {
463                 item_data = (CstGlItemData_t *)calloc(1, sizeof(CstGlItemData_t));
464                 retv_if(item_data == NULL, NULL);
465                 item_data->index = index;
466                 item_data->ugd = ugd;
467                 if (list_call_barring[index].style == CST_GL_ITEM_1TEXT_ONOFF_PROGRESS) {
468                         ugd->cb_state[index] = CST_SS_STATE_PROGRESS;
469                         item_data->gl_item = elm_genlist_item_append(genlist, itc_1text_1icon,
470                                                                  (void *)item_data, NULL, list_call_barring[index].flags,
471                                                                  __cst_gl_sel_cb, item_data);
472                         __cst_query_cb_status(item_data);
473                 } else {
474                         DBG("No style");
475                         free(item_data);
476                         item_data = NULL;
477                         return NULL;
478                 }
479         }
480         _cst_create_genlist_separator_no_line(genlist);
481
482         return genlist;
483 }
484
485 static void __cst_on_click_voice_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
486 {
487         ENTER(__cst_on_click_voice_cb);
488         ret_if(NULL == data);
489         CstUgData_t *ugd = (CstUgData_t *)data;
490         Evas_Object *back_btn = NULL;
491         Evas_Object *layout;
492         Elm_Object_Item *navi_it;
493
494         ugd->call_type = CST_CALLTYPE_VOICE;
495         ugd->popup = NULL;
496
497         Evas_Object *genlist = __cst_create_genlist_cb(ugd);
498
499         layout = elm_layout_add(ugd->nf);
500         elm_layout_file_set(layout, EDJ_NAME, "toolbar");
501         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
502         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
503         elm_object_part_content_set(layout, "elm.swallow.contents", genlist);
504         navi_it = elm_naviframe_item_push(ugd->nf, T_(CST_STR_VOICE_CALL_BARRING),
505                                                                           NULL, NULL, layout, NULL);
506         back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
507         evas_object_smart_callback_add(back_btn, "clicked",
508                                                                    __cst_on_click_cf_voice_video_back_button, ugd);
509 }
510
511 static void __cst_gl_sel_call_type(void *data, Evas_Object *obj, void *event_info)
512 {
513         ret_if(data == NULL);
514         CstUgData_t *ugd = (CstUgData_t *)data;
515         Elm_Object_Item *item= (Elm_Object_Item *)event_info;
516         int index = (int)elm_object_item_data_get(item);
517         elm_genlist_item_selected_set(item, EINA_FALSE);
518
519         if (list_call_type[index].func) {
520                 list_call_type[index].func((void *)ugd, NULL, obj, event_info);
521         }
522         return;
523 }
524
525 static char *__cst_gl_label_get_call_type(void *data, Evas_Object *obj, const char *part)
526 {
527         int index = (int)data;
528
529         if (strcmp(part, "elm.text") == 0) {
530                 if (list_call_type[index].str_id != -1) {
531                         return strdup(T_(list_call_type[index].str_id));
532                 }
533         }
534         return NULL;
535 }
536
537 static Evas_Object *__cst_create_genlist_call_type(void *data)
538 {
539         ENTER(__cst_create_genlist_call_type);
540         retv_if(NULL == data, NULL);
541         CstUgData_t *ugd = (CstUgData_t *)data;
542         Evas_Object *genlist;
543         int index = 0;
544
545         if (!itc_1text_1icon) {
546                 itc_1text_1icon = elm_genlist_item_class_new();
547         }
548
549         if (!itc_1text) {
550                 itc_1text = elm_genlist_item_class_new();
551         }
552
553         itc_1text->item_style = "dialogue/1text";
554         itc_1text->func.text_get = __cst_gl_label_get_call_type;
555         itc_1text->func.content_get = NULL;
556         itc_1text->func.state_get = NULL;
557         itc_1text->func.del = NULL;
558
559         genlist = elm_genlist_add(ugd->nf);
560
561         _cst_create_genlist_separator(genlist, EINA_FALSE);
562         for (index = 0; list_call_type[index].style != CST_GL_ITEM_NONE; index++) {
563                 elm_genlist_item_append(genlist, itc_1text,
564                                                                   (void *)index, NULL, ELM_GENLIST_ITEM_NONE,
565                                                                   __cst_gl_sel_call_type, (void *)ugd);
566         }
567         _cst_create_genlist_separator_no_line(genlist);
568
569         return genlist;
570 }
571
572 void _cst_call_barring_input_panel_event_callback(void *data, Ecore_IMF_Context *imf_context, int value)
573 {
574         ENTER(_cst_call_barring_input_panel_event_callback);
575         ret_if(!data);
576         CstUgData_t *ugd = (CstUgData_t *)data;
577         Evas_Object *btn = NULL;
578         CallSettingSSReq_t *req = NULL;
579         const char *entry_input = NULL;
580
581         Elm_Object_Item *top_it = elm_naviframe_top_item_get(ugd->nf);
582         ret_if(!top_it);
583         req = (CallSettingSSReq_t *)elm_object_item_data_get(top_it);
584         ret_if(!req);
585
586         if (EINA_FALSE == keypad_enabled) {
587                 DBG("keypad_enabled = %d", keypad_enabled);
588                 keypad_enabled = EINA_TRUE;
589                 return;
590         }
591
592         if (value == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW) {
593                 return;
594         }
595
596         entry_input = elm_entry_entry_get(ugd->dg_entry);
597         if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
598                 DBG("ECORE_IMF_INPUT_PANEL_STATE_SHOW");
599
600                 elm_object_item_part_content_set(top_it, "toolbar_button1", NULL);
601                 elm_object_item_part_content_set(top_it, "toolbar_button2", NULL);
602
603                 btn = _cst_create_title_btn(ugd->nf, (char *)T_(CST_STR_CANCEL),
604                                                                         __cst_on_click_cb_ime_cancel_btn, (void *)req);
605                 elm_object_item_part_content_set(top_it, "title_right_btn", btn);
606
607                 btn = _cst_create_title_btn(ugd->nf, (char *)T_(CST_STR_DONE),
608                                                                         __cst_on_click_cb_ime_done_btn, (void *)req);
609                 elm_object_item_part_content_set(top_it, "title_left_btn", btn);
610                 if (entry_input && strlen(entry_input) > 0) {
611                         elm_object_disabled_set(btn, EINA_FALSE);
612                 } else {
613                         elm_object_disabled_set(btn, EINA_TRUE);
614                 }
615         } else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
616                 DBG("ECORE_IMF_INPUT_PANEL_STATE_HIDE");
617                 elm_object_item_part_content_set(top_it, "title_right_btn", NULL);
618                 elm_object_item_part_content_set(top_it, "title_left_btn", NULL);
619                 _cst_create_navi_control_bar(ugd->nf,
620                                                                                         (char *)T_(CST_STR_DONE), NULL,
621                                                                                         __cst_on_click_cb_ime_done_btn,
622                                                                                         (char *)T_(CST_STR_CANCEL), NULL,
623                                                                                         __cst_on_click_cb_ime_cancel_btn,
624                                                                                         (void *)req, top_it,
625                                                                                         ec_item);
626                 if (entry_input && strlen(entry_input) > 0) {
627                         elm_object_disabled_set(ec_item[0], EINA_FALSE);
628                 } else {
629                         elm_object_disabled_set(ec_item[0], EINA_TRUE);
630                 }
631         }
632 }
633
634 void _cst_on_click_call_barring(void *data, Evas *evas, Evas_Object *obj, void *event_info)
635 {
636         ENTER(_cst_on_click_call_barring);
637         ret_if(NULL == data);
638         CstUgData_t *ugd = (CstUgData_t *)data;
639         Evas_Object *back_btn = NULL;
640         Elm_Object_Item *navi_it;
641
642         if (_cst_check_flight_mode()) {
643                 ugd->popup = _cst_create_error_popup(ugd->nf,
644                                                                                          CST_ERROR_CHANGE_FLIGHT_MODE);
645                 evas_object_show(ugd->popup);
646                 return;
647         }
648
649         if (!_cst_check_sim_status()) {
650                 ugd->popup = _cst_create_error_popup(ugd->nf,
651                                                                                          CST_ERROR_INSERT_SIM_CARD);
652                 evas_object_show(ugd->popup);
653                 return;
654         }
655
656         barring_gl = __cst_create_genlist_call_type(ugd);
657         navi_it = elm_naviframe_item_push(ugd->nf, T_(CST_STR_CALL_BARRING),
658                                                                           back_btn, NULL, barring_gl, NULL);
659         back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
660         evas_object_smart_callback_add(back_btn, "clicked",
661                                                                    __cst_on_click_cb_back_button, ugd);
662 }
663
664 void _cst_destroy_call_barring(void)
665 {
666         ENTER(_cst_destroy_call_barring);
667
668         __cst_destroy_genlist_item_styles();
669
670         if (barring_gl != NULL) {
671                 elm_genlist_clear(barring_gl);
672                 evas_object_del(barring_gl);
673                 barring_gl = NULL;
674         }
675 }
676 #endif  /* _CALL_SET_BARRING_SUPPORT */
677