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://floralicense.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.
17 #ifdef _CALL_SET_AUTO_AREA_CODE_SUPPORT
19 #include <Elementary.h>
21 #include "cst-common.h"
22 #include "cst-common-string.h"
23 #include "cst-widget.h"
24 #include "cst-call-setting.h"
26 #include "cst-prefix-dial.h"
27 #include "cst-prefix-dial-ime.h"
28 #include "cst-delete-list.h"
31 static gboolean keypad_enabled = EINA_FALSE;
32 static Evas_Object *ec_item[3];
33 static Evas_Object *prefixdialling_gl = NULL;
35 static void __cst_on_click_sound_eq_back_button(void *data, Evas_Object *obj, void *event_info);
37 static void __cst_on_click_sound_eq_back_button(void *data, Evas_Object *obj, void *event_info)
39 ENTER(__cst_on_click_sound_eq_back_button);
41 _cst_destroy_prefix_dialling();
44 void _cst_set_prefix_dialling_list(int index, char *number)
46 ENTER(_cst_set_prefix_dialling_list);
48 ret_if(number == NULL);
51 _cst_vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR,
55 _cst_vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR,
59 _cst_vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR,
63 _cst_vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR,
67 _cst_vconf_set_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR,
71 DBG("Error set prefix dialling list");
76 char *_cst_get_prefix_dialling_list(int index)
78 ENTER(_cst_get_prefix_dialling_list);
83 number = _cst_vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR);
86 number = _cst_vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR);
89 number = _cst_vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR);
92 number = _cst_vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR);
95 number = _cst_vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR);
98 retv_if(NULL == number, NULL);
102 static void __cst_click_prefix_dial_save(void *data,
106 ENTER(__cst_click_prefix_dial_save);
109 CstUgData_t *ugd = (CstUgData_t *)data;
110 const char *number = elm_entry_entry_get(ugd->dg_entry);
111 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ugd->dg_entry);
114 ecore_imf_context_input_panel_event_callback_del(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _cst_prefix_dialling_input_panel_event_callback);
115 ecore_imf_context_input_panel_enabled_set(imf_context, EINA_FALSE);
118 DBG("number : %s ", number);
119 if (0 == strlen(number)) {
120 if (0 == strlen(_cst_get_prefix_dialling_list(CST_ITEM_1))) {
121 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, EINA_FALSE);
123 /*Evas_Object *error;
125 DBG("No new number");
126 error = _cst_create_error_popup(ugd->nf,
127 CST_ERROR_ENTER_NUMBER);
129 evas_object_show(error);
132 _cst_set_prefix_dialling_list(CST_ITEM_1, (char *)number);
135 keypad_enabled = EINA_FALSE;
137 evas_object_smart_callback_del(obj, "clicked",
138 __cst_click_prefix_dial_save);
140 evas_object_smart_callback_del(ugd->dg_entry, "changed", _cst_call_prefix_dialling_entry_changed_cb);
141 evas_object_smart_callback_del(ugd->dg_entry, "preedit,changed", _cst_call_prefix_dialling_entry_changed_cb);
143 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, EINA_TRUE);
145 /* ecore_timer_add(CST_NAVIFRAME_ITEM_POP_TIMER, _cst_naviframe_item_pop_cb, ugd);
147 _cst_naviframe_item_pop_cb(ugd);
150 static void __cst_click_prefix_dial_cancel(void *data,
154 ENTER(__cst_click_prefix_dial_cancel);
157 CstUgData_t *ugd = (CstUgData_t *)data;
158 Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ugd->dg_entry);
161 ecore_imf_context_input_panel_event_callback_del(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _cst_prefix_dialling_input_panel_event_callback);
162 ecore_imf_context_input_panel_enabled_set(imf_context, EINA_FALSE);
165 keypad_enabled = EINA_FALSE;
167 evas_object_smart_callback_del(obj, "clicked",
168 __cst_click_prefix_dial_cancel);
170 evas_object_smart_callback_del(ugd->dg_entry, "changed", _cst_call_prefix_dialling_entry_changed_cb);
171 evas_object_smart_callback_del(ugd->dg_entry, "preedit,changed", _cst_call_prefix_dialling_entry_changed_cb);
173 /* ecore_timer_add(CST_NAVIFRAME_ITEM_POP_TIMER, _cst_naviframe_item_pop_cb, ugd);
175 _cst_naviframe_item_pop_cb(ugd);
178 static void __cst_create_prefix_dialling_ime(Evas_Object *parent, void *data)
180 ENTER(__cst_create_prefix_dialling_ime);
182 CstUgData_t *ugd = (CstUgData_t *)data;
183 Evas_Object *back_btn = NULL;
184 Elm_Object_Item *navi_it;
187 prefixdialling_gl = _cst_create_prefix_dialling_ime(ugd->nf, NULL, ugd);
188 evas_object_show(prefixdialling_gl);
190 _cst_remove_naviframe(ugd->nf);
192 navi_it = elm_naviframe_item_push(ugd->nf, T_(CST_STR_AUTO_AREA_CODE),
193 NULL, NULL, prefixdialling_gl, NULL);
195 back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
196 evas_object_smart_callback_add(back_btn, "clicked", __cst_on_click_sound_eq_back_button, ugd);
201 void _cst_on_click_prefix_dialling(void *data, Evas *evas, Evas_Object *obj, void *event_info)
203 ENTER(_cst_on_click_prefix_dialling);
204 ret_if(NULL == data);
205 CstUgData_t *ugd = (CstUgData_t *)data;
206 __cst_create_prefix_dialling_ime(ugd->nf, ugd);
209 void _cst_prefix_dialling_input_panel_event_callback(void *data, Ecore_IMF_Context *imf_context, int value)
211 ENTER(_cst_prefix_dialling_input_panel_event_callback);
213 CstUgData_t *ugd = (CstUgData_t *)data;
215 const char *entry_input = NULL;
217 Elm_Object_Item *top_it = elm_naviframe_top_item_get(ugd->nf);
219 if (value == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW) {
223 if (EINA_FALSE == keypad_enabled) {
224 DBG("keypad_enabled = %d", keypad_enabled);
225 keypad_enabled = EINA_TRUE;
227 if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
232 entry_input = elm_entry_entry_get(ugd->dg_entry);
233 if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
235 DBG("ECORE_IMF_INPUT_PANEL_STATE_SHOW");
237 elm_object_item_part_content_set(top_it, "toolbar_button1", NULL);
238 elm_object_item_part_content_set(top_it, "toolbar_button2", NULL);
240 btn = _cst_create_title_btn(ugd->nf, (char *)T_(CST_STR_CANCEL),
241 __cst_click_prefix_dial_cancel, (void *)ugd);
242 elm_object_item_part_content_set(top_it, "title_right_btn", btn);
244 btn = _cst_create_title_btn(ugd->nf, (char *)T_(CST_STR_SAVE),
245 __cst_click_prefix_dial_save, (void *)ugd);
246 elm_object_item_part_content_set(top_it, "title_left_btn", btn);
248 if (entry_input && strlen(entry_input) > 0) {
249 elm_object_disabled_set(btn, EINA_FALSE);
251 elm_object_disabled_set(btn, EINA_TRUE);
253 } else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
254 DBG("ECORE_IMF_INPUT_PANEL_STATE_HIDE");
255 elm_object_item_part_content_set(top_it, "title_right_btn", NULL);
256 elm_object_item_part_content_set(top_it, "title_left_btn", NULL);
257 _cst_create_navi_control_bar(ugd->nf,
258 (char *)T_(CST_STR_SAVE), NULL,
259 __cst_click_prefix_dial_save,
260 (char *)T_(CST_STR_CANCEL), NULL,
261 __cst_click_prefix_dial_cancel,
265 if (entry_input && strlen(entry_input) > 0) {
266 elm_object_disabled_set(ec_item[0], EINA_FALSE);
268 elm_object_disabled_set(ec_item[0], EINA_TRUE);
273 void _cst_call_prefix_dialling_entry_changed_cb(void *data, Evas_Object *obj, void *event_info)
275 ENTER(_cst_call_prefix_dialling_entry_changed_cb);
277 CstUgData_t *ugd = (CstUgData_t *)data;
278 Evas_Object *btn = NULL;
279 const char *entry_input = NULL;
281 Elm_Object_Item *top_it = elm_naviframe_top_item_get(ugd->nf);
284 entry_input = elm_entry_entry_get(ugd->dg_entry);
285 if ((btn = elm_object_item_part_content_get(top_it, "title_left_btn")) != NULL) {
286 if (entry_input && strlen(entry_input) > 0) {
287 elm_object_disabled_set(btn, EINA_FALSE);
289 elm_object_disabled_set(btn, EINA_TRUE);
292 if (entry_input && strlen(entry_input) > 0) {
293 elm_object_disabled_set(ec_item[0], EINA_FALSE);
295 elm_object_disabled_set(ec_item[0], EINA_TRUE);
300 void _cst_destroy_prefix_dialling(void)
302 ENTER(_cst_destroy_prefix_dialling);
304 if (prefixdialling_gl != NULL) {
305 elm_genlist_clear(prefixdialling_gl);
306 evas_object_del(prefixdialling_gl);
307 prefixdialling_gl = NULL;
311 #endif /* _CALL_SET_AUTO_AREA_CODE_SUPPORT */