2012/08/21: tizen 2.0 beta
[apps/home/call-setting.git] / src / cst-widget.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 #include <stdio.h>
18 #include <appcore-efl.h>
19 #include <Elementary.h>
20 #include <Evas.h>
21 #include <vconf.h>
22
23 #include "cst-common.h"
24 #include "cst-widget.h"
25 #include "cst-common-string.h"
26 #include "cst-debug.h"
27 #include "cst-reject-msg.h"
28 #include "cst-autoreject.h"
29 #include "cst-prefix-dial.h"
30 #include "cst-forwarding.h"
31 #include "cst-util.h"
32 #include "cst-widget.h"
33
34 static Elm_Genlist_Item_Class *itc_seperator = NULL;
35 static Elm_Genlist_Item_Class *itc_seperator_no_line = NULL;
36 static Elm_Genlist_Item_Class *itc_underline = NULL;
37
38 /* This callback is for showing(hiding) X marked button. */
39 static void _changed_cb(void *data, Evas_Object *obj, void *event_info)
40 {
41         if (elm_object_focus_get(data)) {
42                 if (elm_entry_is_empty(obj))
43                         elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
44                 else
45                         elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
46         }
47 }
48
49 /* Focused callback will show X marked button and hide guidetext. */
50 static void _focused_cb(void *data, Evas_Object *obj, void *event_info)
51 {
52         if (!elm_entry_is_empty(obj))
53                 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
54         elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
55 }
56
57 /* Unfocused callback will show guidetext and hide X marked button. */
58 static void _unfocused_cb(void *data, Evas_Object *obj, void *event_info)
59 {
60         if (elm_entry_is_empty(obj))
61                 elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
62         elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
63 }
64
65 /* When X marked button clicked, make string as empty. */
66 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
67 {
68         elm_entry_entry_set(data, "");
69 }
70
71 Evas_Object *_cst_create_progressbar(Evas_Object *parent)
72 {
73         ENTER(_cst_create_progressbar);
74         retv_if(NULL == parent, NULL);
75         Evas_Object *progressbar;
76         progressbar = elm_progressbar_add(parent);
77         elm_object_style_set(progressbar, "list_process");
78         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
79         evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
80         evas_object_show(progressbar);
81         elm_progressbar_pulse(progressbar, EINA_TRUE);
82
83         return progressbar;
84 }
85
86 static void __cst_get_error_string(int error, char *msg)
87 {
88         switch (error) {
89         case CST_ERROR_INCORRECT_OPERATION:
90                 snprintf(msg, 100, "%s", T_(CST_STR_INCORRECT_OPERATION));
91                 break;
92         case CST_ERROR_INVALID_PASSWORD:
93                 snprintf(msg, 100, "%s", T_(CST_STR_INVALID_PASSWORD));
94                 break;
95         case CST_ERROR_PASSWORD_BLOCKED:
96                 snprintf(msg, 100, "%s", T_(CST_STR_PASSWORD_BLOCKED));
97                 break;
98         case CST_ERROR_SERVICE_UNAVAILABLE:
99                 snprintf(msg, 100, "%s", T_(CST_STR_SERVICE_UNAVAILABLE));
100                 break;
101         case CST_ERROR_UNKNOWN:
102                 snprintf(msg, 100, "%s", T_(CST_STR_REJECTED_BY_NETWORK));
103                 break;
104         case CST_ERROR_ENTER_NUMBER:
105                 snprintf(msg, 100, "%s", T_(CST_STR_ENTER_NUMBER));
106                 break;
107         case CST_ERROR_ENTER_MESSAGE:
108                 snprintf(msg, 100, "%s", T_(CST_STR_ENTER_MESSAGE));
109                 break;
110         case CST_ERROR_SELECT_VALID_ENTRY:
111                 snprintf(msg, 100, "%s", T_(CST_STR_SELECT_VALID_ENTRY));
112                 break;
113         case CST_ERROR_REJECTED_BY_NETWORK:
114                 snprintf(msg, 100, "%s", T_(CST_STR_REJECTED_BY_NETWORK));
115                 break;
116         case CST_ERROR_DUPLICATE_MESSAGE:
117                 snprintf(msg, 100, "%s", T_(CST_STR_ENTER_DUPLICATE_MESSAGE));
118                 break;
119         case CST_ERROR_INSERT_SIM_CARD:
120                 snprintf(msg, 100, "%s", T_(CST_STR_INSERT_SIM_CARD));
121                 break;
122         case CST_ERROR_CHANGE_FLIGHT_MODE:
123                 snprintf(msg, 100, "%s", T_(CST_STR_CHNAGE_FLIGHT_MODE_MESSAGE));
124                 break;
125         case CST_ERROR_AUL_LAUNCH_ERROR:
126                 snprintf(msg, 100, "%s", T_(CST_STR_APP_NOT_INSTALLED));
127                 break;
128         default:
129                 snprintf(msg, 100, "%s", T_(CST_STR_UNKNOWN_OPERATION));
130                 break;
131         }
132 }
133
134 Evas_Object *_cst_create_error_popup(Evas_Object *parent, int error)
135 {
136         retv_if(error < 0, NULL);
137
138         char error_msg[100];
139         __cst_get_error_string(error, error_msg);
140         DBG("Error message=%s", error_msg);
141
142         Evas_Object *popup;
143         popup = elm_popup_add(parent);
144         elm_popup_timeout_set(popup, 1.5);
145         elm_object_text_set(popup, error_msg);
146         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
147
148         return popup;
149 }
150
151 static void __cst_2btn_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
152 {
153         ret_if(data == NULL);
154         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
155         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
156
157         switch (item_data->str_id) {
158         case CST_STR_UNABLE_TO_TURN_OFF_PROXIMITY:
159                 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_PROXIMITY_SENSOR_BOOL, EINA_FALSE);
160                 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_POWER_KEY_ENDS_CALL_BOOL, EINA_FALSE);
161                 break;
162         case CST_STR_UNABLE_TO_SET_POWER_KEY_END_CALL:
163                 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_POWER_KEY_ENDS_CALL_BOOL, EINA_TRUE);
164                 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_PROXIMITY_SENSOR_BOOL, EINA_TRUE);
165                 break;
166         default:
167                 DBG("__cst_2btn_popup_response_cb() error");
168                 break;
169         }
170         elm_genlist_item_update(item_data->gl_item);
171         evas_object_del(ugd->popup);
172         ugd->popup = NULL;
173 }
174
175 static void __cst_2btn_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
176 {
177         ret_if(data == NULL);
178         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
179         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
180
181         evas_object_del(ugd->popup);
182         ugd->popup = NULL;
183 }
184
185 Evas_Object *_cst_create_2btn_popup(Evas_Object *parent, CstGlItemData_t *item_data)
186 {
187         retv_if((parent == NULL) || (item_data == NULL), NULL);
188
189         Evas_Object *popup, *btn1, *btn2;
190         popup = elm_popup_add(parent);
191         elm_object_text_set(popup, T_(item_data->str_id));
192         evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
193
194         btn1 = elm_button_add(popup);
195         elm_object_text_set(btn1, T_(CST_STR_OK));
196         elm_object_part_content_set(popup, "button1", btn1);
197         evas_object_smart_callback_add(btn1, "clicked", __cst_2btn_popup_ok_cb, (void *)item_data);
198
199         btn2 = elm_button_add(popup);
200         elm_object_text_set(btn2, T_(CST_STR_POP_CANCEL));
201         elm_object_part_content_set(popup, "button2", btn2);
202         evas_object_smart_callback_add(btn2, "clicked", __cst_2btn_popup_cancel_cb, (void *)item_data);
203
204         return popup;
205 }
206
207 Evas_Object *_cst_get_navifr_prev_btn(Evas_Object *nf)
208 {
209         ENTER(_cst_get_navifr_prev_btn);
210         Elm_Object_Item *top_it = elm_naviframe_top_item_get(nf);
211         retv_if(top_it == NULL, NULL);
212         Evas_Object *btn = elm_object_item_part_content_get(top_it, "prev_btn");
213         retv_if(btn == NULL, NULL);
214
215         return btn;
216 }
217
218 Evas_Object *_cst_create_navi_control_bar(Evas_Object *parent,
219                         char *label1, const char *icon1, Evas_Smart_Cb cb1,
220                         char *label2, const char *icon2, Evas_Smart_Cb cb2,
221                         void *data, Elm_Object_Item *navi_it,
222                         Elm_Object_Item ** c_item)
223 {
224         ENTER(_cst_create_navi_control_bar);
225         retv_if(NULL == parent, NULL);
226         Elm_Object_Item *item;
227         Evas_Object *cbar = elm_toolbar_add(parent);
228         elm_toolbar_shrink_mode_set(cbar, ELM_TOOLBAR_SHRINK_EXPAND);
229         int i = 0;
230
231         retv_if(cbar == NULL, NULL);
232         retv_if(label1 == NULL, NULL);
233
234         if (label1) {
235                 c_item[0] = elm_toolbar_item_append(cbar,
236                         icon1, label1, cb1, data);
237         }
238
239         item = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
240         elm_object_item_part_content_set(item, "object", NULL);
241         elm_object_item_disabled_set(item, EINA_TRUE);
242
243         Evas_Object *btn = elm_object_item_part_content_get(navi_it,
244                 "prev_btn");
245
246         if (btn) {
247                 if (label2) {
248                         c_item[1] = elm_toolbar_item_append(cbar,
249                                 icon2, label2, cb2, data);
250                         item = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
251                         elm_object_item_part_content_set(item, "object", NULL);
252                         elm_object_item_disabled_set(item, EINA_TRUE); 
253                 } else {
254                         for (;i < 2; i++) {
255                                 item = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
256                                 elm_object_item_part_content_set(item, "object", NULL);
257                                 elm_object_item_disabled_set(item, EINA_TRUE); 
258                         }                               
259                 }
260         } else {
261                 if (label2) {
262                         for (;i < 2; i++) {
263                                 item = elm_toolbar_item_append(cbar, NULL, NULL, NULL, NULL);
264                                 elm_object_item_part_content_set(item, "object", NULL);
265                                 elm_object_item_disabled_set(item, EINA_TRUE); 
266                         }       
267                         c_item[1] = elm_toolbar_item_append(cbar,
268                                 icon2, label2, cb2, data);
269                 }
270         }
271
272         elm_object_item_part_content_set(navi_it, "controlbar", cbar);
273         return cbar;
274 }
275
276 static void __cst_gl_del_seperator(void *data, Evas_Object *obj)
277 {
278         ret_if(data == NULL);
279         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
280         if (item_data)
281                 free(item_data);
282         return;
283 }
284
285 void _cst_create_genlist_separator(Evas_Object *genlist, Eina_Bool need_item_data)
286 {
287         Elm_Object_Item *item = NULL;
288
289         if (!itc_seperator)
290                 itc_seperator = elm_genlist_item_class_new();
291
292         itc_seperator->item_style = "dialogue/separator/21/with_line";
293         itc_seperator->func.text_get = NULL;
294         itc_seperator->func.content_get = NULL;
295         itc_seperator->func.state_get = NULL;
296
297         if (need_item_data) {
298                 CstGlItemData_t *item_data;
299                 itc_seperator->func.del = __cst_gl_del_seperator;
300                 item_data = calloc(1, sizeof(CstGlItemData_t));
301                 ret_if(NULL == item_data);
302                 item_data->index = -1;
303                 item = elm_genlist_item_append(genlist, itc_seperator, item_data, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
304                 item_data->gl_item = item;
305         } else {
306                 itc_seperator->func.del = NULL;
307                 item = elm_genlist_item_append(genlist, itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
308         }
309         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
310 }
311
312 void _cst_create_genlist_separator_no_line(Evas_Object *genlist)
313 {
314         ret_if(NULL == genlist);
315         Elm_Object_Item *item = NULL;
316
317         if (!itc_seperator_no_line)
318                 itc_seperator_no_line = elm_genlist_item_class_new();
319
320         itc_seperator_no_line->item_style = "dialogue/separator/20";
321         itc_seperator_no_line->func.text_get = NULL;
322         itc_seperator_no_line->func.content_get = NULL;
323         itc_seperator_no_line->func.state_get = NULL;
324
325         itc_seperator_no_line->func.del = NULL;
326         item = elm_genlist_item_append(genlist, itc_seperator_no_line, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
327         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
328 }
329
330 void _cst_create_genlist_underline(Evas_Object *genlist)
331 {
332         ret_if(NULL == genlist);
333         Elm_Object_Item *item = NULL;
334
335         if (!itc_underline)
336                 itc_underline = elm_genlist_item_class_new();
337
338         itc_underline->item_style = "dialogue/separator/1/with_line";
339         itc_underline->func.text_get = NULL;
340         itc_underline->func.content_get = NULL;
341         itc_underline->func.state_get = NULL;
342         itc_underline->func.del = NULL;
343
344         item = elm_genlist_item_append(genlist, itc_underline, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
345         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
346 }
347
348 Elm_Object_Item *_cst_create_genlist_update_underline(Evas_Object *genlist)
349 {
350         retv_if(NULL == genlist, NULL);
351         Elm_Object_Item *item = NULL;
352
353         if (!itc_underline)
354                 itc_underline = elm_genlist_item_class_new();
355
356         itc_underline->item_style = "dialogue/separator/1/with_line";
357         itc_underline->func.text_get = NULL;
358         itc_underline->func.content_get = NULL;
359         itc_underline->func.state_get = NULL;
360         itc_underline->func.del = NULL;
361
362         item = elm_genlist_item_append(genlist, itc_underline, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
363         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
364         return item;
365 }
366
367 static void __cst_hide_selectinfo_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
368 {
369         ENTER(__cst_hide_selectinfo_cb);
370         ret_if(data == NULL || obj == NULL);
371
372         CstUgData_t *ugd = (CstUgData_t *)data;
373         ret_if(obj != ugd->selectinfo);
374
375         if (ugd->selectinfo && ugd->select_backup)
376                 edje_object_signal_emit(_EDJ(ugd->select_backup),
377                         DEFAULT_CONTENT_SIGNAL, BOTTOM_PADDING_CONTENT_SOURCE);
378         ugd->select_backup = NULL;
379         ugd->selectinfo = NULL;
380 }
381
382 void _cst_create_selectinfo(CstUgData_t *ugd, Evas_Object *layout, const char *label)
383 {
384         ENTER(_cst_create_selectinfo);
385         ret_if(ugd == NULL);
386         if (!ugd->selectinfo) {
387                 ugd->select_backup = layout;
388                 ugd->selectinfo = elm_notify_add(ugd->select_backup);
389                 elm_notify_orient_set(ugd->selectinfo, ELM_NOTIFY_ORIENT_BOTTOM);
390
391                 evas_object_event_callback_add(ugd->selectinfo,
392                         EVAS_CALLBACK_HIDE, __cst_hide_selectinfo_cb, ugd);
393
394                 ugd->selectinfo_layout = elm_layout_add(ugd->select_backup);
395
396                 elm_layout_theme_set(ugd->selectinfo_layout,
397                         "standard", "selectioninfo", "vertical/bottom_12");
398
399                 elm_object_content_set(ugd->selectinfo, ugd->selectinfo_layout);
400         }
401
402         if (label == NULL) {
403                 evas_object_hide(ugd->selectinfo);
404                 return;
405         }
406
407         DBG("Input label : %s", label);
408         edje_object_part_text_set(_EDJ(ugd->selectinfo_layout), "elm.text", label);
409         elm_notify_timeout_set(ugd->selectinfo, 2);
410         evas_object_show(ugd->selectinfo);
411 }
412
413 void _cst_del_selectinfo(CstUgData_t *ugd)
414 {
415         ret_if(ugd == NULL);
416
417         if (ugd->selectinfo_layout)
418                 evas_object_del(ugd->selectinfo_layout);
419         if (ugd->selectinfo)
420                 evas_object_del(ugd->selectinfo);
421
422         ugd->selectinfo_layout = NULL;
423         ugd->selectinfo = NULL;
424 }
425
426 Evas_Object *_cst_create_onoff_button(Evas_Object *obj,
427         int state_value, Evas_Smart_Cb cb_func, void *cb_data)
428 {
429         retv_if(NULL == obj, NULL);
430
431         Evas_Object *icon = elm_check_add(obj);
432         elm_object_style_set(icon, "on&off");
433         elm_check_state_set(icon, state_value);
434         if (cb_func) {
435                 evas_object_smart_callback_add(icon, "changed",
436                         cb_func, cb_data);
437         }
438         evas_object_propagate_events_set(icon, EINA_FALSE);
439
440         return icon;
441 }
442
443 Evas_Object *_cst_create_radio_icon(Evas_Object *obj,
444         Evas_Object *rdg, int value, int offset, const char *vconf_key)
445 {
446         retv_if(NULL == obj, NULL);
447
448         int rd_value = 0;
449         Evas_Object *radio = elm_radio_add(obj);
450         elm_radio_state_value_set(radio, value);
451         elm_radio_group_add(radio, rdg);
452         if (vconf_key == NULL) {
453                 elm_radio_value_set(rdg, offset);
454         }
455         else {
456                 _cst_vconf_get_int(vconf_key, &rd_value);
457                 elm_radio_value_set(rdg, (rd_value + offset));
458         }
459
460         return radio;
461 }
462
463 Evas_Object *_cst_create_title_btn(Evas_Object *parent,
464                 const char *text, Evas_Smart_Cb func, void *data)
465 {
466         retv_if(NULL == parent, NULL);
467
468         Evas_Object *btn = elm_button_add(parent);
469         if (!btn) return NULL;
470         elm_object_style_set(btn, "naviframe/title/default");
471         elm_object_text_set(btn, text);
472         evas_object_smart_callback_add(btn, "clicked", func, data);
473         return btn;
474 }
475
476 static void __cst_trans_finished(void *data, Evas_Object *obj, void *event_info)
477 {
478         ret_if(NULL == obj);
479         elm_naviframe_prev_btn_auto_pushed_set(obj, EINA_TRUE);
480         evas_object_smart_callback_del(obj, "transition,finished", __cst_trans_finished);
481 }
482
483 void _cst_remove_naviframe(Evas_Object *nf)
484 {
485         ret_if(NULL == nf);
486         elm_naviframe_prev_btn_auto_pushed_set(nf, EINA_FALSE);
487         evas_object_smart_callback_add(nf, "transition,finished",
488                 __cst_trans_finished, NULL);
489 }
490
491 static void __cst_changed_editfield_cb(void *data, Evas_Object *obj, void *event_info)
492 {
493         ret_if(NULL == data);
494         CstUgData_t *ugd = (CstUgData_t *)data;
495         const char *entry_str = elm_entry_entry_get(obj);
496
497         Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ugd->nf);
498         ret_if(!navi_it);
499         Evas_Object *btn = elm_object_item_part_content_get(navi_it,
500                 "title_left_btn");
501
502         if (btn != NULL) {
503                 if (NULL == entry_str || '\0' == entry_str[0])
504                         elm_object_disabled_set(btn, EINA_TRUE);
505                 else
506                         elm_object_disabled_set(btn, EINA_FALSE);
507         }
508 }
509
510 Evas_Object *_cst_create_ime_editfield(CstUgData_t *ugd,
511         Evas_Object *parent, CstImeType_t ime_type, char *input_string)
512 {
513         retv_if((NULL == ugd || NULL == parent), NULL);
514
515         Ecore_IMF_Input_Panel_Layout panel_layout;
516         Evas_Object *layout = elm_layout_add(parent);
517         elm_layout_theme_set(layout, "layout", "editfield", "title");
518         Elm_Entry_Filter_Limit_Size limit_filter_data;
519         Elm_Entry_Filter_Accept_Set digits_filter_data;
520         Ecore_IMF_Context *imf_context;
521         void (*input_panel_cb)() = NULL;
522         int value = 0;
523
524         ugd->dg_entry = elm_entry_add(parent);
525         elm_object_part_content_set(layout, "elm.swallow.content", ugd->dg_entry);
526
527         evas_object_smart_callback_add(ugd->dg_entry, "changed", _changed_cb, layout);
528         evas_object_smart_callback_add(ugd->dg_entry, "focused", _focused_cb, layout);
529         evas_object_smart_callback_add(ugd->dg_entry, "unfocused", _unfocused_cb, layout);
530         elm_object_signal_callback_add(layout, "elm,eraser,clicked", "elm", _eraser_clicked_cb, ugd->dg_entry);
531
532         switch (ime_type) {
533         case CST_IME_AUTO_REJECT:
534                 elm_entry_single_line_set(ugd->dg_entry, EINA_TRUE);
535                 elm_entry_scrollable_set(ugd->dg_entry, EINA_TRUE);
536                 elm_object_part_text_set(layout, "elm.text", T_(CST_STR_ENTER_NUMBER));
537                 panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
538                 elm_entry_input_panel_layout_set(ugd->dg_entry, panel_layout);
539                 limit_filter_data.max_char_count = 0;
540                 limit_filter_data.max_byte_count = CST_MAX_PHONE_NUMBER_LEN;
541                 digits_filter_data.accepted = "0123456789+*#";
542                 digits_filter_data.rejected = NULL;
543                 elm_entry_markup_filter_append(ugd->dg_entry,
544                         elm_entry_filter_accept_set, &digits_filter_data);
545                 input_panel_cb = _cst_auto_reject_input_panel_event_callback;
546                 break;
547         case CST_IME_PREFIX_DIAL:
548                 elm_entry_single_line_set(ugd->dg_entry, EINA_TRUE);
549                 elm_entry_scrollable_set(ugd->dg_entry, EINA_TRUE);
550                 elm_object_part_text_set(layout, "elm.text", T_(CST_STR_ENTER_NUMBER));
551                 panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
552                 elm_entry_input_panel_layout_set(ugd->dg_entry, panel_layout);
553                 limit_filter_data.max_char_count = 0;
554                 limit_filter_data.max_byte_count = CST_MAX_PREFIX_NUMBER_LEN;
555                 digits_filter_data.accepted = "0123456789+*#";
556                 digits_filter_data.rejected = NULL;
557                 elm_entry_markup_filter_append(ugd->dg_entry,
558                         elm_entry_filter_accept_set, &digits_filter_data);
559                 _cst_vconf_get_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, &value);
560                 input_panel_cb = _cst_prefix_dialling_input_panel_event_callback;
561                 break;
562         case CST_IME_REJECT_MSG:
563                 panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL;
564                 elm_entry_input_panel_layout_set(ugd->dg_entry, panel_layout);
565                 limit_filter_data.max_char_count = 0;
566                 limit_filter_data.max_byte_count = CST_MAX_ITEM_TEXT_BUFFER_LEN - 1;
567                 input_panel_cb = _cst_reject_msg_input_panel_event_callback;
568                 break;
569         case CST_IME_CALL_FORWARD:
570                 elm_entry_single_line_set(ugd->dg_entry, EINA_TRUE);
571                 elm_entry_scrollable_set(ugd->dg_entry, EINA_TRUE);
572                 elm_object_part_text_set(layout, "elm.text", T_(CST_STR_ENTER_NUMBER));
573                 panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER;
574                 elm_entry_input_panel_layout_set(ugd->dg_entry, panel_layout);
575                 limit_filter_data.max_char_count = 0;
576                 limit_filter_data.max_byte_count = CST_MAX_PHONE_NUMBER_LEN;
577                 digits_filter_data.accepted = "0123456789+*#";
578                 digits_filter_data.rejected = NULL;
579                 elm_entry_markup_filter_append(ugd->dg_entry,
580                         elm_entry_filter_accept_set, &digits_filter_data);
581                 input_panel_cb = _cst_call_forwarding_input_panel_event_callback;
582                 break;
583         case CST_IME_CALL_BAR:
584                 elm_entry_single_line_set(ugd->dg_entry, EINA_TRUE);
585                 elm_entry_scrollable_set(ugd->dg_entry, EINA_TRUE);
586                 elm_object_part_text_set(layout, "elm.text", T_(CST_STR_ENTER_PASSWORD));
587                 panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY;
588                 elm_entry_input_panel_layout_set(ugd->dg_entry, panel_layout);
589                 elm_entry_password_set(ugd->dg_entry, EINA_TRUE);
590                 limit_filter_data.max_char_count = 0;
591                 limit_filter_data.max_byte_count = CST_MAX_PASSWORD_LEN;
592                 break;
593         default:
594                 ERR("Invalid ime type.");
595                 return NULL;
596         }
597
598         elm_entry_markup_filter_append(ugd->dg_entry,
599                 elm_entry_filter_limit_size, &limit_filter_data);
600
601         elm_entry_cnp_mode_set(ugd->dg_entry, ELM_CNP_MODE_PLAINTEXT);
602
603         if (input_string != NULL)
604                 elm_entry_entry_set(ugd->dg_entry, input_string);
605
606         elm_entry_cursor_end_set(ugd->dg_entry);
607
608         imf_context = elm_entry_imf_context_get(ugd->dg_entry);
609
610         DBG("ugd->entry = 0x%x, imf_context = 0x%x", ugd->dg_entry, imf_context);
611
612         if (imf_context) {
613                 ecore_imf_context_input_panel_event_callback_add (imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, input_panel_cb, ugd);
614                 if (ime_type == CST_IME_PREFIX_DIAL && value == 0)
615                         ecore_imf_context_input_panel_enabled_set(imf_context, EINA_FALSE);
616         }
617
618         evas_object_show(ugd->dg_entry);
619         elm_object_focus_set(ugd->dg_entry, EINA_TRUE);
620
621         evas_object_smart_callback_add(ugd->dg_entry, "changed",
622                 __cst_changed_editfield_cb,
623                 ugd);
624
625         return layout;
626 }
627
628 Evas_Object *_cst_create_ime_btn_layout(Evas_Object *parent,
629         Evas_Object *ef, Evas_Smart_Cb cb, void *cb_data)
630 {
631         retv_if((NULL == ef || NULL == parent), NULL);
632
633         Evas_Object *ly = NULL;
634         Evas_Object *btn = NULL;
635         Evas_Object *icon = NULL;
636         Eina_Bool ret = EINA_FALSE;
637
638         ly = elm_layout_add(parent);
639         retv_if(NULL == ly, NULL);
640
641         ret = elm_layout_file_set(ly, EDJ_NAME, "dialoguegroup/contact");
642         if (ret == EINA_FALSE) {
643                 DBG("elm_layout_file_set() failed");
644                 evas_object_del(ly);
645                 return NULL;
646         }
647
648         evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
649         evas_object_show(ly);
650
651         elm_object_part_content_set(ly, "editfield/sw", ef);
652
653         btn = elm_button_add(ly);
654         if (!btn) {
655                 DBG("elm_button_add() failed");
656                 evas_object_del(ly);
657                 return NULL;
658         }
659
660         icon = elm_icon_add(ly);
661         if (!icon) {
662                 DBG("elm_icon_add() failed");
663                 evas_object_del(ly);
664                 evas_object_del(btn);
665                 return NULL;
666         }
667
668         elm_icon_file_set(icon, CST_CTRL_ICON_CONTACTS, NULL);
669         evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
670         elm_icon_resizable_set(icon, EINA_TRUE, EINA_TRUE);
671         elm_object_part_content_set(btn, "icon", icon);
672         elm_object_part_content_set(ly, "button/sw", btn);
673         elm_object_focus_set(ef, EINA_TRUE);
674         evas_object_smart_callback_add(btn, "clicked",
675                 cb, cb_data);
676
677         return ly;
678 }
679