1.Limit the max length of Network connection profile
[apps/core/preloaded/settings.git] / setting-common / src / setting-common-draw-genlist.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 #include <setting-common-draw-widget.h>
22 #include <glib.h>
23 #include <utilX.h>
24 #include <Ecore_X.h>
25 #include <system_settings.h>
26
27 #define EXCEED_LIMITATION_STR           "Name is too long."
28
29 static Evas_Object *_gl_Gendial_content_get(void *data, Evas_Object *obj, const char *part);
30 static char *_gl_Gendial_text_get(void *data, Evas_Object *obj, const char *part);
31 static void _gl_Gendial_del(void *data, Evas_Object *obj);
32 const Elm_Genlist_Item_Class itc_seperator = {
33         .item_style = "dialogue/separator/21/with_line",
34         .func.text_get = NULL,
35         .func.content_get = NULL,
36         .func.state_get = NULL,
37         .func.del = NULL,
38 };
39
40 const Elm_Genlist_Item_Class itc_bottom_seperator = {
41         .item_style = "dialogue/separator/20",
42         .func.text_get = NULL,
43         .func.content_get = NULL,
44         .func.state_get = NULL,
45         .func.del = NULL,
46 };
47
48 const Elm_Genlist_Item_Class itc_sep_line = {
49         .item_style = "dialogue/separator/1/with_line",
50         .func.text_get = _gl_Gendial_text_get,
51         .func.content_get = NULL,
52         .func.state_get = NULL,
53         .func.del = NULL,
54 };
55
56 #define DEFINE_ITC1(style, name) \
57 const Elm_Genlist_Item_Class name = {\
58         .item_style = style,\
59         .func.text_get = _gl_Gendial_text_get,\
60         .func.content_get = _gl_Gendial_content_get,\
61         .func.state_get = NULL,\
62         .func.del = _gl_Gendial_del,\
63 };
64
65 DEFINE_ITC1("dialogue/1text", itc_1text);
66 DEFINE_ITC1("dialogue/1text.1icon.2", itc_1text_1icon_2);
67
68 DEFINE_ITC1("dialogue/1icon", itc_1icon);
69 DEFINE_ITC1("dialogue/1text.1icon/expandable2", itc_1icon_1text_sub);
70 DEFINE_ITC1("dialogue/1text.1icon", itc_1text_1icon);
71 DEFINE_ITC1("dialogue/1text.2icon", itc_1text_2icon);
72 DEFINE_ITC1("dialogue/1text.2icon.2", itc_1text_2icon_2);
73
74 DEFINE_ITC1("dialogue/2text.2", itc_2text_2);
75 DEFINE_ITC1("dialogue/2text", itc_2text);
76 DEFINE_ITC1("multiline/2text.1icon", itc_multiline_2text_1icon);
77 DEFINE_ITC1("dialogue/2text.1icon.3", itc_2text_1icon_3);
78 DEFINE_ITC1("dialogue/2text.1icon.6", itc_2text_1icon_6);
79 DEFINE_ITC1("dialogue/2text.1icon.7", itc_2text_1icon_7);
80
81 DEFINE_ITC1("dialogue/2text.3/expandable", itc_2text_3_parent);
82 DEFINE_ITC1("dialogue/2text.3", itc_2text_3);
83 DEFINE_ITC1("dialogue/2text.2icon.3", itc_2text_2icon_3);
84
85 DEFINE_ITC1("multiline/1text", itc_multiline_text);
86 DEFINE_ITC1("1text.1icon.2", itc_cm_1text_1icon_2);
87 DEFINE_ITC1("select_all", itc_sel_all);
88 DEFINE_ITC1("dialogue/bg/1icon", itc_bg_1icon);
89 DEFINE_ITC1("dialogue/title", itc_group_item);
90
91 /**
92  * Do process when clicking on a common genlist item
93  */
94 void setting_mouse_up_Gendial_list_radio_cb(void *data, Evas_Object *obj,
95                                             void *event_info)
96 {
97         /* error check */
98         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
99         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
100         elm_genlist_item_selected_set(item, 0);
101         Setting_GenGroupItem_Data *list_item =
102             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
103
104         setting_retm_if(data == NULL, "Data parameter is NULL");
105         Evas_Object *radio = data;
106         elm_radio_value_set(radio, list_item->chk_status);
107 }
108
109 static void __radio_changed(void *data, Evas_Object *obj, void *event_info)
110 {
111         retm_if(data == NULL, "Data parameter is NULL");
112         Setting_GenGroupItem_Data *list_item =
113             (Setting_GenGroupItem_Data *) data;
114         list_item->chk_status = elm_radio_value_get(obj);       /*  for update */
115 }
116
117 static void __entry_changed(void *data, Evas_Object *obj, void *event_info)
118 {
119         retm_if(data == NULL, "Data parameter is NULL");
120         SETTING_TRACE_BEGIN;
121         Setting_GenGroupItem_Data *list_item =
122             (Setting_GenGroupItem_Data *) data;
123         list_item->sub_desc = (char *)g_strdup(elm_entry_entry_get(obj));
124         Evas_Object *entry_container = elm_object_parent_widget_get(obj);
125         if (entry_container)
126         {
127                 if (elm_entry_is_empty(obj))
128                 {
129                         elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
130                         elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
131                 }
132                 else
133                 {
134                         if (elm_object_focus_get(obj)) //only do when entry is focused
135                         {
136                                 elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
137                                 elm_object_signal_emit(entry_container, "elm,state,eraser,show", "elm");
138                         }
139                 }
140         }
141 }
142
143 static void __entry_unfocused(void *data, Evas_Object *obj, void *event_info) // Unfocused callback will show guidetext and hide X marked button.
144 {
145         ret_if(!data);
146         SETTING_TRACE_BEGIN;
147         Evas_Object *entry_container = data;
148         //whe entry unfocused, its guidetext will becomes "Input here"
149         elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
150         if (elm_entry_is_empty(obj))
151                 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
152         elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
153 }
154 static void __entry_focused(void *data, Evas_Object *obj, void *event_info) // Focused callback will show X marked button and hide guidetext.
155 {
156         ret_if(!data);
157         SETTING_TRACE_BEGIN;
158         Evas_Object *entry_container = data;
159         //whe entry focused, its guidetext will becomes "Input here"
160         elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
161         if (!elm_entry_is_empty(obj))
162                 elm_object_signal_emit(entry_container, "elm,state,eraser,show", "elm");
163         elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
164 }
165 static void __eraser_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) // When X marked button is clicked, empty entry's contents.
166 {
167         ret_if(!data);
168         Evas_Object *entry = data;
169         elm_entry_entry_set(entry, "");
170         elm_object_focus_set(entry, EINA_TRUE);
171 }
172
173 static void __chk_changed(void *data, Evas_Object *obj, void *event_info)
174 {
175         retm_if(data == NULL, "Data parameter is NULL");
176         Setting_GenGroupItem_Data *list_item =
177             (Setting_GenGroupItem_Data *) data;
178         list_item->chk_status = elm_check_state_get(obj);       /*  for update */
179 }
180
181 static void __error_popup_response_cb(void *data, Evas_Object *obj,
182                                      void *event_info)
183 {
184         SETTING_TRACE_BEGIN;
185         retm_if(data == NULL, "Data parameter is NULL");
186         Setting_GenGroupItem_Data *list_item = data;
187         if (list_item->notify) {
188                 evas_object_del(list_item->notify);
189                 list_item->notify = NULL;
190         }
191 }
192
193 static void __max_len_reached(void *data, Evas_Object *obj, void *event_info)
194 {
195         SETTING_TRACE_BEGIN;
196         retm_if(data == NULL, "Data parameter is NULL");
197         retm_if(!elm_object_focus_get(obj), "Entry is not focused");//notify only when entry is being focused on.
198
199         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
200         if (!list_item->notify)
201         {
202                 list_item->notify = setting_create_popup_without_btn(list_item, list_item->win_main,
203                                                          NULL, _(EXCEED_LIMITATION_STR),
204                                                          __error_popup_response_cb,
205                                                          POPUP_INTERVAL, FALSE, FALSE);
206                 elm_object_focus_set(list_item->eo_check, EINA_FALSE);
207         } else {
208                 //postpone 2 seconds again
209                 elm_popup_timeout_set(list_item->notify, POPUP_INTERVAL);
210         }
211
212 }
213 static void __entry_keydown(void *data, Evas *e, Evas_Object *obj, void *event_info)
214 {
215         ret_if(event_info == NULL);
216         Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
217         if(safeStrCmp(ev->key, "Return") == 0) //to disable the 'Enter' orginal function
218         {
219                 SETTING_TRACE("ENTER %s ev->key:%s", __FUNCTION__, ev->key);            
220                 //hide the eraser button
221                 //format like:xx<br/>
222                 const char *entry_str = remove_first_substring(elm_entry_entry_get(obj), "<br/>");              
223                 elm_entry_entry_set(obj, entry_str);
224                 FREE(entry_str);
225                 elm_entry_cursor_end_set(obj);
226                 setting_hide_input_pannel_cb(obj);
227         } else {
228                 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
229                 if(safeStrLen(elm_entry_entry_get(obj)) > 0) {
230                         elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
231                 } else {
232                         elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
233                 }
234         }
235
236 }
237
238 /**
239  * Do process when clicking radio in subitem of expandable item
240  */
241 void setting_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
242 {
243         SETTING_TRACE_BEGIN;
244         retm_if(data == NULL, "Data parameter is NULL");
245         Setting_GenGroupItem_Data *list_item =
246             (Setting_GenGroupItem_Data *) data;
247         list_item->chk_status = elm_radio_value_get(obj);       /*  for update */
248
249         Elm_Object_Item *subItem = list_item->item;
250         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
251
252         Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem);    /* subItem data */
253         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
254
255         ret_if(NULL == data_subItem || NULL == data_parentItem);
256         int err;
257         setting_set_int_slp_key(data_parentItem->int_slp_setting_binded,
258                                 list_item->chk_status, &err);
259         ret_if(0 != err);
260         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
261         elm_object_item_data_set(data_parentItem->item, data_parentItem);
262         elm_genlist_item_update(data_parentItem->item);
263 }
264
265 /**
266  * Do process when clicking on subitem of expandable item
267  */
268 void setting_sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
269 {
270         SETTING_TRACE_BEGIN;
271         /* error check */
272         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
273         Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
274         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
275         elm_genlist_item_selected_set(subitem, 0);
276         Setting_GenGroupItem_Data *data_subItem =
277             elm_object_item_data_get(subitem);
278         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
279         ret_if(NULL == data_subItem || NULL == data_parentItem);
280
281         elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
282         int err;
283         setting_set_int_slp_key(data_parentItem->int_slp_setting_binded,
284                                 data_subItem->chk_status, &err);
285         setting_retm_if(0 != err, "Set vconf error[%d]",data_parentItem->int_slp_setting_binded);
286
287         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
288         elm_object_item_data_set(data_parentItem->item, data_parentItem);
289         elm_genlist_item_update(data_parentItem->item);
290 }
291
292 static void __exp_list_smart_cb(void *data, Evas_Object *obj, void *event_info)
293 {
294         ret_if(data == NULL || event_info == NULL);
295         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
296         char *cb_type = data;
297
298         if (0 == safeStrCmp(cb_type, "drag")
299             || 0 == safeStrCmp(cb_type, "longpressed")) {
300                 //Evas_Object *base_view = (Evas_Object *) elm_genlist_item_object_get(item);
301                 //edje_object_signal_emit(base_view, "mouse,out", "touch_arrow");
302         } else if (0 == safeStrCmp(cb_type, "contracted")) {
303                 elm_genlist_item_subitems_clear(item);
304         }
305 }
306
307 static void _gl_Gendial_sel(void *data, Evas_Object *obj, void *event_info)
308 {
309         /* SETTING_TRACE_BEGIN; */
310         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
311         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
312         elm_genlist_item_selected_set(item, 0);
313 }
314
315 static void _gl_Gendial_sel_expand(void *data, Evas_Object *obj,
316                                    void *event_info)
317 {
318         /* SETTING_TRACE_BEGIN; */
319         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
320         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
321         elm_genlist_item_selected_set(item, 0);
322         bool status = !elm_genlist_item_expanded_get(item);
323         elm_genlist_item_expanded_set(item, status);
324 }
325
326 static char *_gl_Gendial_text_get(void *data, Evas_Object *obj,
327                                    const char *part)
328 {
329         /* SETTING_TRACE_BEGIN; */
330         Setting_GenGroupItem_Data *item_data =
331             (Setting_GenGroupItem_Data *) data;
332         /* SETTING_TRACE("part:%s", part); */
333         if (SWALLOW_Type_LAYOUT_ENTRY == item_data->swallow_type) {     /* no need to create 'text' part */
334                 return NULL;
335         }
336
337         /* for font size view */
338         if (SWALLOW_Type_1RADIO_1LABLE == item_data->swallow_type) {
339                 char speciliztion[MAX_SPECIALIZITION_LEN] = {0,};
340                 int font_size = -1;
341                 SETTING_TRACE("item_data->chk_status:%d", item_data->chk_status);
342                 if (SYSTEM_SETTINGS_FONT_SIZE_SMALL == item_data->chk_status) {
343                         font_size = LABEL_FONT_SIZE_SMALL;
344                 } else if (SYSTEM_SETTINGS_FONT_SIZE_LARGE == item_data->chk_status) {
345                         font_size = LABEL_FONT_SIZE_LARGE;
346                 } else if (SYSTEM_SETTINGS_FONT_SIZE_HUGE == item_data->chk_status) {
347                         font_size = LABEL_FONT_SIZE_HUGE;
348                 } else if (SYSTEM_SETTINGS_FONT_SIZE_GIANT == item_data->chk_status) {
349                         font_size = LABEL_FONT_SIZE_GIANT;
350                 } else {
351                         font_size = LABEL_FONT_SIZE_NORMAL;
352                 }
353                 SETTING_TRACE("font_size:%d", font_size);
354                 snprintf(speciliztion, sizeof(speciliztion), "<font_size=%d>%s</font_size>",
355                         font_size, _(item_data->keyStr));
356                 return (char *)g_strdup(speciliztion);
357         }
358
359         if (!safeStrCmp(part, "elm.text") || !safeStrCmp(part, "elm.text.1")) { /* title */
360                 if (item_data->keyStr) {
361                         return (char *)g_strdup(_(item_data->keyStr));  /* use item_data->keyStr */
362                 }
363
364         } else if (!safeStrCmp(part, "elm.text.2")) {   /* bottom or right */
365                 if (item_data->sub_desc) {
366                         return (char *)g_strdup(item_data->sub_desc);
367                 }
368         }
369
370         return NULL;
371 }
372
373 static Evas_Object *__add_check(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
374 {
375         retv_if(!item_data || !parent, NULL);
376         Evas_Object *check = elm_check_add(parent);
377         elm_check_state_set(check, item_data->chk_status);
378         evas_object_show(check);
379         evas_object_pass_events_set(check, 1);
380         evas_object_propagate_events_set(check, 0);
381
382         item_data->eo_check = check;
383
384         if (item_data->chk_change_cb) {
385                 evas_object_smart_callback_add(check,"changed",item_data->chk_change_cb,item_data);
386         } else {
387                 evas_object_smart_callback_add(check,"changed", __chk_changed, item_data);
388         }
389         return check;
390 }
391 static Evas_Object *__add_check_icon(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
392 {
393         retv_if(!item_data || !parent, NULL);
394         Evas_Object *check = __add_check(item_data, parent);
395
396         Evas_Object *thumb = NULL;
397         if (item_data->r_swallow_path) {
398                 thumb = elm_icon_add(parent);
399                 elm_icon_file_set(thumb,
400                                   item_data->r_swallow_path,
401                                   NULL);
402                 evas_object_size_hint_aspect_set(thumb,
403                                                  EVAS_ASPECT_CONTROL_VERTICAL,
404                                                  1, 1);
405         }
406
407         Evas_Object *layout = elm_layout_add(parent);
408         elm_layout_file_set(layout, SETTING_THEME_EDJ_NAME,
409                             "thumbnail_icon2");
410         evas_object_size_hint_weight_set(layout,
411                                          EVAS_HINT_EXPAND,
412                                          EVAS_HINT_EXPAND);
413         elm_object_part_content_set(layout, "checkbox", check);
414         elm_object_part_content_set(layout, "thumbnail", thumb);
415         evas_object_show(layout);
416         return layout;
417 }
418 static Evas_Object *__add_toggle(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
419 {
420         retv_if(!item_data || !parent, NULL);
421         Evas_Object *check = __add_check(item_data, parent);
422         elm_object_style_set(check, "on&off");
423         return check;
424 }
425 static Evas_Object *__add_multiline_toggle(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
426 {
427         retv_if(!item_data || !parent, NULL);
428         Evas_Object *chk = __add_toggle(item_data, parent);
429         elm_object_style_set(chk, "on&off");
430         return chk;
431 }
432
433 static Evas_Object *__add_radio(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
434 {
435         retv_if(!item_data || !parent, NULL);
436         if (!item_data->rgd) {  /* exceptional handling */
437                 item_data->rgd = elm_radio_add(parent);
438                 elm_radio_state_value_set(item_data->rgd, -1);
439         }
440         Evas_Object *radio = elm_radio_add(parent);
441         elm_radio_state_value_set(radio,
442                                   item_data->chk_status);
443         elm_radio_group_add(radio, item_data->rgd);
444         evas_object_show(radio);
445         item_data->eo_check = radio;
446         if (item_data->chk_change_cb) {
447                 evas_object_smart_callback_add(radio,
448                                                "changed",
449                                                item_data->chk_change_cb,
450                                                item_data);
451         } else {
452                 evas_object_smart_callback_add(radio,
453                                                "changed",
454                                                __radio_changed,
455                                                item_data);
456         }
457         return radio;
458 }
459 static Evas_Object *__add_button(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
460 {
461         retv_if(!item_data || !parent, NULL);
462         Evas_Object *btn = elm_button_add(parent);
463         evas_object_show(btn);
464         if (item_data->r_swallow_path)
465         {
466                 elm_object_style_set(btn, item_data->r_swallow_path);
467         }
468         if (item_data->keyStr)
469         {
470                 elm_object_text_set(btn, _(item_data->keyStr));
471         }
472         evas_object_propagate_events_set(btn, EINA_FALSE);
473         if (item_data->chk_change_cb)
474                 evas_object_smart_callback_add(btn,
475                                                "clicked",
476                                                item_data->chk_change_cb,
477                                                item_data);
478         return btn;
479 }
480 static Evas_Object *__add_entry(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
481 {
482         retv_if(!item_data || !parent, NULL);
483         elm_genlist_mode_set(parent, ELM_LIST_COMPRESS);        /* resolve abnormal height issue */
484         Evas_Object *ed_name =
485             setting_create_editfiled(parent, _(item_data->keyStr),
486                                      item_data->sub_desc);
487         Evas_Object *entry = elm_object_part_content_get(ed_name, "elm.swallow.content");
488         item_data->eo_check = entry;
489         elm_entry_input_panel_layout_set(entry,
490                                          item_data->input_type);
491
492         if (item_data->isSinglelineFlag) {
493                 elm_entry_single_line_set(entry, EINA_TRUE);
494         }
495
496         if (item_data->isPasswordFlag) {
497                 elm_entry_single_line_set(entry, EINA_TRUE);
498                 elm_entry_password_set(entry, EINA_TRUE);
499         }
500
501         if (item_data->limit_filter_data) {
502                 elm_entry_markup_filter_append
503                     (entry,
504                      elm_entry_filter_limit_size,
505                      item_data->limit_filter_data);
506
507                 evas_object_smart_callback_add(entry,
508                                               "maxlength,reached",
509                                               __max_len_reached,
510                                               item_data);
511
512         }
513         if (item_data->stop_change_cb) {//invoked when stop focusing on
514                 evas_object_smart_callback_add(entry,
515                                                       "unfocused",
516                                                       item_data->stop_change_cb,
517                                                       item_data);
518         }
519         else
520         {
521                 evas_object_smart_callback_add(entry,
522                                               "unfocused",
523                                               __entry_unfocused,
524                                               ed_name);
525         }
526         if (item_data->digits_filter_data) {
527                 elm_entry_markup_filter_append
528                     (entry,
529                      elm_entry_filter_accept_set,
530                      item_data->digits_filter_data);
531         }
532
533         /* for Setting App, All the entrys's context popup shouldn't be able */
534         /* to insert images, text is the only one can be inserted. */
535         elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
536
537         if (item_data->chk_change_cb) {
538                 evas_object_smart_callback_add
539                     (entry,
540                      "changed", item_data->chk_change_cb,
541                      item_data);
542         }
543         //default handle
544         evas_object_smart_callback_add(entry, "changed", __entry_changed, item_data);
545         evas_object_smart_callback_add(entry, "focused", __entry_focused, ed_name);
546         elm_object_signal_callback_add(ed_name, "elm,eraser,clicked", "elm", __eraser_clicked, entry);
547
548         if (item_data->start_change_cb) {
549                 evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, (Evas_Object_Event_Cb)(item_data->start_change_cb), item_data->userdata);
550         }
551         evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, __entry_keydown, item_data);
552
553         if (item_data->input_panel_disable_flag) {
554                 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
555         }
556         return ed_name;
557 }
558 static Evas_Object *__add_slider(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
559 {
560         retv_if(!item_data || !parent, NULL);
561         Evas_Object *li_slider =
562             setting_create_slider(parent, item_data->evas,
563                                   item_data->l_swallow_path,
564                                   item_data->r_swallow_path,
565                                   item_data->chk_status,
566                                   item_data->isIndicatorVisible,
567                                   item_data->slider_min,
568                                   item_data->slider_max,
569                                   item_data->chk_change_cb,
570                                   item_data->start_change_cb,
571                                   item_data->stop_change_cb,
572                                   item_data);
573         evas_object_pass_events_set(li_slider, 1);
574         evas_object_propagate_events_set(li_slider, 0);
575         item_data->eo_check = li_slider;
576         return li_slider;
577 }
578
579 static Evas_Object *__add_datefield(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
580 {
581         retv_if(!item_data || !parent, NULL);
582         /* **********create time/date field */
583         Evas_Object *datetimefield = item_data->eo_check = elm_datetime_add(parent);
584         evas_object_size_hint_weight_set(datetimefield, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
585         evas_object_size_hint_align_set(datetimefield, EVAS_HINT_FILL, 0.5);
586         evas_object_show(datetimefield);
587
588         char date_format[MAX_DATETIME_FORMAT_LEN + 1] = {0, };
589         const char *time_format = NULL;
590         if (item_data->chk_status)//12 hours
591         {
592                 time_format = "%I : %M %p";
593         } else { //24 hours
594                 time_format = "%H : %M";
595         }
596
597 #if SUPPORT_DATEFIELD_DATE_FORMAT_AUTOSET //Get date-format from datefiled itself, if elm_datetime_add() supports set date-format via ICU.
598         char *old_format = elm_datetime_format_get(datetimefield);
599         snprintf(date_format, MAX_DATE_FORMAT_LEN + 1, //add one space " "
600                  "%s", old_format);
601         safeStrNCat(date_format, time_format, MAX_DATETIME_FORMAT_LEN);
602         FREE(old_format);
603         SETTING_TRACE("datefield_format:%s", date_format);
604 #else
605         snprintf(date_format, MAX_DATETIME_FORMAT_LEN,
606                  "%s %s", item_data->sub_desc, time_format);
607 #endif
608         elm_datetime_format_set(datetimefield, date_format);
609
610         // min : 1970 1, 01, Thursday 00:00:00
611         // max : 2038 1, 19, Thursday 03:14:07
612         struct tm ts_ret;
613         memset(&ts_ret, 0, sizeof(struct tm));
614         ts_ret.tm_year = 138;
615         ts_ret.tm_mon = 1;
616         ts_ret.tm_mday = 19;
617         elm_datetime_value_max_set(datetimefield, &ts_ret);
618
619         ts_ret.tm_year = 70;
620         ts_ret.tm_mon = 0;
621         ts_ret.tm_mday = 1;
622         elm_datetime_value_min_set(datetimefield, &ts_ret);
623
624
625         time_t ctime = time(NULL);
626         //struct tm ts_ret;
627         struct tm *ts = localtime_r(&ctime, &ts_ret);
628         retv_if(!ts, NULL);
629
630         elm_datetime_value_set(datetimefield, &ts_ret);
631
632         if (item_data->chk_change_cb) {
633                 evas_object_smart_callback_add(datetimefield,
634                                                "changed",
635                                                item_data->chk_change_cb,
636                                                item_data);
637         }
638
639         if (item_data->isItemDisableFlag) {
640                 setting_disable_evas_object(datetimefield);
641         }
642         return datetimefield;
643 }
644 static Evas_Object *__add_radio_search(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
645 {
646         retv_if(!item_data || !parent, NULL);
647         Evas_Object *box = elm_box_add(parent);
648         elm_box_horizontal_set(box, 1);
649
650         //a.radio..
651         Evas_Object *radio = __add_radio(item_data, parent);
652         setting_disable_evas_object(radio);
653         elm_box_pack_end(box, radio);
654
655         //b.separator..
656         Evas_Object *separator =
657                 setting_create_blank_rect_customize(box,
658                                 SETTING_HALF_SCREEN_WIDTH,
659                                 SETTING_PADDING_HEIGHT);
660         elm_box_pack_end(box, separator);
661
662         //c.progressbar..
663         Evas_Object *progressbar = elm_progressbar_add(parent);
664         elm_object_style_set(progressbar, "list_process");
665         evas_object_size_hint_align_set(progressbar,
666                                         EVAS_HINT_FILL, 0.5);
667         evas_object_size_hint_weight_set(progressbar,
668                                          EVAS_HINT_EXPAND,
669                                          EVAS_HINT_EXPAND);
670         elm_progressbar_pulse(progressbar, EINA_TRUE);
671         evas_object_show(progressbar);
672         elm_box_pack_end(box, progressbar);
673
674         evas_object_show(box);
675         return box;
676 }
677 static Evas_Object *__add_search(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
678 {
679         retv_if(!item_data || !parent, NULL);
680         // added by JTS: CQ H0100135171
681         Evas_Object *box = elm_box_add(parent);
682         elm_box_horizontal_set(box, 1);
683
684         //b.separator..
685         Evas_Object *separator =
686                 setting_create_blank_rect_customize(box,
687                 SETTING_HALF_SCREEN_WIDTH, SETTING_PADDING_HEIGHT);
688         elm_box_pack_end(box, separator);
689
690         //c.progressbar..
691         Evas_Object *progressbar = elm_progressbar_add(parent);
692         elm_object_style_set(progressbar, "list_process");
693         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
694         evas_object_size_hint_weight_set(progressbar,
695                                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
696         elm_progressbar_pulse(progressbar, EINA_TRUE);
697         evas_object_show(progressbar);
698         elm_box_pack_end(box, progressbar);
699
700         evas_object_show(box);
701         return box;
702
703 }
704 static Evas_Object *__add_process(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
705 {
706         retv_if(!item_data || !parent, NULL);
707         Evas_Object *progressbar = elm_progressbar_add(parent);
708         elm_object_style_set(progressbar, "list_process");
709         evas_object_size_hint_align_set(progressbar,
710                                         EVAS_HINT_FILL, 0.5);
711         evas_object_size_hint_weight_set(progressbar,
712                                          EVAS_HINT_EXPAND,
713                                          EVAS_HINT_EXPAND);
714         elm_progressbar_pulse(progressbar, EINA_TRUE);
715         evas_object_show(progressbar);
716         return progressbar;
717 }
718
719 static Evas_Object *__add_radio_lable(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
720 {
721         retv_if(!item_data || !parent, NULL);
722
723         //a.radio..
724         Evas_Object *radio = __add_radio(item_data, parent);
725
726         return radio;
727 }
728
729 static Evas_Object *__add_left_default(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
730 {
731         retv_if(!item_data || !parent || !item_data->l_swallow_path, NULL);
732         Evas_Object *icon = elm_icon_add(parent);
733         elm_icon_file_set(icon, item_data->l_swallow_path,NULL);
734         evas_object_size_hint_aspect_set(icon,EVAS_ASPECT_CONTROL_VERTICAL,1, 1);
735         return icon;
736 }
737 static Evas_Object *__add_right_default(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
738 {
739         retv_if(!item_data || !parent || !item_data->r_swallow_path, NULL);
740         Evas_Object *icon = elm_icon_add(parent);
741         elm_icon_file_set(icon, item_data->r_swallow_path,NULL);
742         evas_object_size_hint_aspect_set(icon,EVAS_ASPECT_CONTROL_VERTICAL,1, 1);
743         return icon;
744 }
745
746 // draw handler
747 typedef Evas_Object * (*__drawer_fp)(Setting_GenGroupItem_Data *item_data, Evas_Object *parent);
748 typedef struct
749 {
750         SWALLOW_Type type;                      // ui type
751         __drawer_fp draw;
752 } __Content_Drawer;
753 static __Content_Drawer __cd_left[SWALLOW_Type_MAX] = {
754         //base objects
755         {SWALLOW_Type_1CHECK, __add_check},
756         {SWALLOW_Type_1TOGGLE, __add_toggle},
757         {SWALLOW_Type_1RADIO, __add_radio},
758         {SWALLOW_Type_1BUTTON, __add_button},
759
760         //base objects in an layout
761         {SWALLOW_Type_LAYOUT_ENTRY, __add_entry},
762         {SWALLOW_Type_LAYOUT_SLIDER, __add_slider},
763         {SWALLOW_Type_LAYOUT_DATEFIELD, __add_datefield},
764
765         //other compelx objects
766         {SWALLOW_Type_1SEARCH, __add_search},
767         {SWALLOW_Type_1PROCESS, __add_process},
768         {SWALLOW_Type_MULTILINE_1TOGGLE, __add_multiline_toggle},
769         {SWALLOW_Type_1CHECKICON, __add_check_icon},
770         {SWALLOW_Type_1RADIO_1SEARCH, __add_radio_search},
771         {SWALLOW_Type_1RADIO_1LABLE, __add_radio_lable},
772
773         //left part object of the type
774         {SWALLOW_Type_1ICON_1RADIO, __add_left_default},
775         {SWALLOW_Type_1RADIO_1PROCESS, __add_radio},
776 };
777 static __Content_Drawer __cd_right[SWALLOW_Type_MAX] = {
778         //right part object of the type
779         {SWALLOW_Type_1ICON_1RADIO, __add_toggle},
780         {SWALLOW_Type_1RADIO_1PROCESS, __add_process},
781 };
782
783 static __Content_Drawer __cd_end[SWALLOW_Type_MAX] = {
784         //end part object of the type
785         {SWALLOW_Type_1RADIO, __add_radio},
786 };
787 /*static __Part_Drawer __pd[__MAX_PART_NUM] = {
788         {"elm.icon", __cd_left},
789         {"elm.icon.1", __cd_left},
790         {"elm.icon.2", __cd_right},
791         {"elm.swallow.end", __cd_end},
792 };*/
793
794 static Evas_Object *_gl_Gendial_content_get(void *data, Evas_Object *obj,
795                                          const char *part)
796 {
797         retv_if(!data, NULL);
798         Setting_GenGroupItem_Data *item_data = data;
799         retv_if(!data, NULL);
800         __Content_Drawer *cd_list = NULL;
801         __drawer_fp fp = NULL;
802         if (!safeStrCmp(part, "elm.icon") || !safeStrCmp(part, "elm.icon.1"))
803         {
804                 fp = __add_left_default; //hold default drawer
805                 cd_list = __cd_left;
806         }
807         else if (!safeStrCmp(part, "elm.icon.2"))
808         {
809                 fp = __add_right_default; //hold default drawer
810                 cd_list = __cd_right;
811         }
812         else if (!safeStrCmp(part, "elm.swallow.end"))
813         {
814                 //the default value of fp is NULL here
815                 cd_list = __cd_end;
816         }
817         if (!cd_list) return NULL;//invalid part
818
819         int idx = 0;
820         for (; idx < SWALLOW_Type_MAX; idx++)
821         {
822                 if (item_data->swallow_type == cd_list[idx].type)//match using swallow type
823                 {
824                         fp = cd_list[idx].draw;
825                         break;
826                 }
827         }
828         return fp ? fp(item_data, obj) : NULL;
829 }
830
831 static void _gl_Gendial_del(void *data, Evas_Object *obj)
832 {
833         /* SETTING_TRACE_BEGIN; */
834         Setting_GenGroupItem_Data *item_data =
835             (Setting_GenGroupItem_Data *) data;
836         if (item_data) {
837                 G_FREE(item_data->keyStr);
838                 G_FREE(item_data->sub_desc);
839                 G_FREE((item_data->l_swallow_path));
840                 G_FREE((item_data->r_swallow_path));
841                 G_FREE(item_data->item_style);
842
843
844                 if (item_data->digits_filter_data)
845                 {
846                         G_FREE(item_data->digits_filter_data->accepted);
847                         G_FREE(item_data->digits_filter_data->rejected);
848                         FREE(item_data->digits_filter_data);
849
850                 }
851
852                 if (item_data->notify) {
853                         evas_object_del(item_data->notify);
854                         item_data->notify = NULL;
855                 }
856
857                 FREE(item_data->limit_filter_data);
858                 __BACK_POINTER_UNSET(item_data);
859                 FREE(item_data);
860         }
861         /* SETTING_TRACE_END; */
862 }
863
864 /**
865  * To intialize an Elm_Genlist_Item_Class, according to item style
866  *
867  * @param[in] item_style
868  * @param[in/out] itc
869  */
870 bool setting_create_Gendial_itc(const char *item_style,
871                                 Elm_Genlist_Item_Class *itc)
872 {
873         itc->item_style = item_style;
874         itc->func.text_get = _gl_Gendial_text_get;
875         itc->func.content_get = _gl_Gendial_content_get;
876         itc->func.state_get = NULL;
877         itc->func.del = _gl_Gendial_del;        /* _gl_Gendial_del; */
878         return TRUE;
879 }
880
881 /**
882  * Create group style item
883  *
884  * @return a pointer to Setting_GenGroupItem_Data
885  */
886 Setting_GenGroupItem_Data *setting_create_Gendial_field_group_titleItem(Evas_Object *genlist,
887                                                 const Elm_Genlist_Item_Class *itc,
888                                                 Elm_Object_Item *parent,
889                                                 Elm_Genlist_Item_Type flag,     /* ELM_GENLIST_ITEM_GROUP or ELM_GENLIST_ITEM_NONE */
890                                                 const char *keyStr,
891                                                 setting_call_back_func gl_sel)
892 {
893         /* SETTING_TRACE_BEGIN; */
894         Setting_GenGroupItem_Data *item_data =
895             (Setting_GenGroupItem_Data *) calloc(1,
896                                                  sizeof
897                                                  (Setting_GenGroupItem_Data));
898         setting_retvm_if(!item_data, NULL, "calloc failed");
899         item_data->keyStr = (char *)g_strdup(keyStr);
900         if (gl_sel) {
901                 item_data->item =
902                     elm_genlist_item_append(genlist, itc, item_data, parent,
903                                             flag, gl_sel, NULL);
904         } else {
905                 item_data->item =
906                     elm_genlist_item_append(genlist, itc, item_data, parent,
907                                             flag, _gl_Gendial_sel, NULL);
908         }
909         return item_data;
910 }
911
912 /**
913  * Create separator style item with title
914  *
915  * @return a pointer to Setting_GenGroupItem_Data
916  */
917 Setting_GenGroupItem_Data *setting_create_Gendial_field_titleItem(
918                                                 Evas_Object *genlist,
919                                                 const Elm_Genlist_Item_Class *itc,
920                                                 const char *keyStr,
921                                                 setting_call_back_func gl_sel)
922 {
923         /* SETTING_TRACE_BEGIN; */
924         Setting_GenGroupItem_Data *item_data =
925             (Setting_GenGroupItem_Data *) calloc(1,
926                                                  sizeof
927                                                  (Setting_GenGroupItem_Data));
928         setting_retvm_if(!item_data, NULL, "calloc failed");
929         item_data->keyStr = (char *)g_strdup(keyStr);
930         if (gl_sel) {
931                 item_data->item =
932                     elm_genlist_item_append(genlist, itc, item_data, NULL,
933                                             ELM_GENLIST_ITEM_NONE, gl_sel,
934                                             NULL);
935         } else {
936                 item_data->item =
937                     elm_genlist_item_append(genlist, itc, item_data, NULL,
938                                             ELM_GENLIST_ITEM_NONE,
939                                             _gl_Gendial_sel, NULL);
940         }
941         return item_data;
942 }
943
944 /**
945  * Create 1radio-1text style item
946  *
947  * @return a pointer to Setting_GenGroupItem_Data
948  */
949
950 Setting_GenGroupItem_Data *setting_create_Gendial_field_1radio(
951                                         Evas_Object *genlist,
952                                         const Elm_Genlist_Item_Class *itc,
953                                         setting_call_back_func gl_sel,
954                                         void *sel_data,
955                                         SWALLOW_Type swallow_type,
956                                         Evas_Object *rgd, int chk_status,
957                                         const char *keyStr,
958                                         setting_call_back_func chk_change_cb)
959 {
960         /* SETTING_TRACE_BEGIN; */
961         Setting_GenGroupItem_Data *item_data =
962             (Setting_GenGroupItem_Data *) calloc(1,
963                                                  sizeof
964                                                  (Setting_GenGroupItem_Data));
965         setting_retvm_if(!item_data, NULL, "calloc failed");
966         item_data->keyStr = (char *)g_strdup(keyStr);
967         item_data->swallow_type = swallow_type;
968         item_data->chk_status = chk_status;
969         item_data->chk_change_cb = chk_change_cb;
970         item_data->rgd = rgd;
971
972         if (gl_sel) {
973                 item_data->item =
974                     elm_genlist_item_append(genlist, itc, item_data, NULL,
975                                             ELM_GENLIST_ITEM_NONE, gl_sel,
976                                             sel_data);
977         } else {
978                 item_data->item =
979                     elm_genlist_item_append(genlist, itc, item_data, NULL,
980                                             ELM_GENLIST_ITEM_NONE,
981                                             _gl_Gendial_sel, sel_data);
982         }
983         return item_data;
984 }
985
986 Setting_GenGroupItem_Data *setting_create_Gendial_field_2radio(
987                                         Evas_Object *genlist,
988                                         const Elm_Genlist_Item_Class *itc,
989                                         setting_call_back_func gl_sel,
990                                         void *sel_data,
991                                         SWALLOW_Type swallow_type,
992                                         Evas_Object *rgd, int chk_status,
993                                         const char *keyStr,
994                                         const char *sub_desc,
995                                         setting_call_back_func chk_change_cb)
996 {
997         /* SETTING_TRACE_BEGIN; */
998         Setting_GenGroupItem_Data *item_data =
999             (Setting_GenGroupItem_Data *) calloc(1,
1000                                                  sizeof
1001                                                  (Setting_GenGroupItem_Data));
1002         setting_retvm_if(!item_data, NULL, "calloc failed");
1003         item_data->keyStr = (char *)g_strdup(keyStr);
1004         item_data->sub_desc = (char *)g_strdup(sub_desc);
1005         item_data->swallow_type = swallow_type;
1006         item_data->chk_status = chk_status;
1007         item_data->chk_change_cb = chk_change_cb;
1008         item_data->rgd = rgd;
1009
1010         if (gl_sel) {
1011                 item_data->item =
1012                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1013                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1014                                             sel_data);
1015         } else {
1016                 item_data->item =
1017                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1018                                             ELM_GENLIST_ITEM_NONE,
1019                                             _gl_Gendial_sel, sel_data);
1020         }
1021         return item_data;
1022 }
1023
1024 /**
1025  * Create common style item with menu icon
1026  *
1027  * @return a pointer to Setting_GenGroupItem_Data
1028  */
1029 Setting_GenGroupItem_Data *setting_create_Gendial_field_groupitem(
1030                                         Evas_Object *genlist,
1031                                         const Elm_Genlist_Item_Class *itc,
1032                                         Elm_Object_Item *parent,
1033                                         setting_call_back_func gl_sel,
1034                                         void *sel_data,
1035                                         SWALLOW_Type swallow_type,
1036                                         char *l_icon_path,
1037                                         char *r_icon_path, int chk_status,
1038                                         const char *keyStr, char *sub_desc,
1039                                         setting_call_back_func
1040                                         chk_change_cb)
1041 {
1042 //      SETTING_TRACE_BEGIN;
1043         Setting_GenGroupItem_Data *item_data = (
1044                 Setting_GenGroupItem_Data *) calloc(1, sizeof(Setting_GenGroupItem_Data));
1045         setting_retvm_if(!item_data, NULL, "calloc failed");
1046
1047         /* to do formatting customizition in one place */
1048         if (SWALLOW_Type_LAYOUT_SPECIALIZTION == swallow_type
1049             || SWALLOW_Type_LAYOUT_SPECIALIZTION_X == swallow_type) {
1050                 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1051
1052                 char speciliztion[MAX_SPECIALIZITION_LEN] = { 0, };
1053                 char* temp1 = (char *)keyStr;
1054                 char*temp2 = strchr(temp1, '&');
1055                 char* temp = NULL;
1056
1057                 while (NULL != temp2) {
1058                         if (0 == safeStrNCmp(temp2, "&amp;", strlen("&amp;")) ||//'&'
1059                             0 == safeStrNCmp(temp2, "&lt;", strlen("&lt;")) ||//'<'
1060                             0 == safeStrNCmp(temp2, "&gt;", strlen("&gt;")) ||//'>'
1061                             0 == safeStrNCmp(temp2, "&quot;", strlen("&quot;")) ||//double quotes
1062                             0 == safeStrNCmp(temp2, "&apos;", strlen("&apos;")) ||//single quotes
1063                             0 == safeStrNCmp(temp2, "&nbsp;", strlen("&nbsp;")) ||//space character
1064                             0 == safeStrNCmp(temp2, "&copy;", strlen("&copy;")) ||//copyright character
1065                             0 == safeStrNCmp(temp2, "&reg;", strlen("&reg;"))//registeration character
1066                            ) {//escape character,do nothing
1067                            temp = temp2 + 1;
1068                            if ('\0' == temp[0]) break;
1069                            temp2 = strchr(temp, '&');
1070                         }
1071                         else
1072                         {
1073                                 g_strlcat(speciliztion, temp1, temp2 - temp1 +1);
1074                                 g_strlcat(speciliztion, "&amp;", MAX_SPECIALIZITION_LEN);
1075                                 temp1 = temp2 + 1;
1076                                 if ('\0' == temp1[0]) break;
1077                                 temp2 = strchr(temp1, '&');
1078                         }
1079                 }
1080                 if ('\0' != temp1[0]) {
1081                         g_strlcat(speciliztion, temp1, MAX_SPECIALIZITION_LEN);
1082                 }
1083
1084
1085                 item_data->keyStr = (char *)g_strdup(speciliztion);
1086         } else {
1087                 item_data->keyStr = (char *)g_strdup(keyStr);
1088         }
1089
1090         item_data->sub_desc = (char *)g_strdup(sub_desc);
1091         item_data->swallow_type = swallow_type;
1092         item_data->l_swallow_path = (char *)g_strdup(l_icon_path);
1093         item_data->r_swallow_path = (char *)g_strdup(r_icon_path);
1094         item_data->chk_status = chk_status;
1095         item_data->chk_change_cb = chk_change_cb;
1096
1097         if (gl_sel) {
1098                 item_data->item =
1099                     elm_genlist_item_append(genlist, itc, item_data, parent,
1100                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1101                                             sel_data);
1102         } else {
1103                 item_data->item =
1104                     elm_genlist_item_append(genlist, itc, item_data, parent,
1105                                             ELM_GENLIST_ITEM_NONE,
1106                                             _gl_Gendial_sel, sel_data);
1107         }
1108         if (SWALLOW_Type_LAYOUT_SPECIALIZTION == swallow_type) {
1109                 Elm_Object_Item *item = elm_genlist_item_append(genlist,
1110                                                                 &(itc_sep_line),
1111                                                                 NULL, NULL,
1112                                                                 ELM_GENLIST_ITEM_NONE,
1113                                                                 NULL, NULL);
1114                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1115                 //Fix the separator line disappear issue when clicking "SPECIALIZTION" words in new HD theme
1116                 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1117         }
1118
1119         return item_data;
1120 }
1121
1122 /**
1123  * Common function to create a genlist item
1124  * @return a pointer to Setting_GenGroupItem_Data
1125  */
1126 Setting_GenGroupItem_Data *setting_create_Gendial_field_def(Evas_Object *
1127                                                             genlist,
1128                                                             const Elm_Genlist_Item_Class *itc,
1129                                                             setting_call_back_func
1130                                                             gl_sel,
1131                                                             void *sel_data,
1132                                                             SWALLOW_Type
1133                                                             swallow_type,
1134                                                             char *l_icon_path,
1135                                                             char *r_icon_path,
1136                                                             int chk_status,
1137                                                             const char *keyStr,
1138                                                             char *sub_desc,
1139                                                             setting_call_back_func chk_change_cb)
1140 {
1141         return setting_create_Gendial_field_groupitem(genlist, itc, NULL,
1142                                                       gl_sel, sel_data,
1143                                                       swallow_type, l_icon_path,
1144                                                       r_icon_path, chk_status,
1145                                                       keyStr, sub_desc,
1146                                                       chk_change_cb);
1147 }
1148
1149 /**
1150  * Create 1entry style item
1151  * @return a pointer to Setting_GenGroupItem_Data
1152  */
1153 Setting_GenGroupItem_Data *setting_create_Gendial_field_entry(Evas_Object *
1154                                                               genlist,
1155                                                               const Elm_Genlist_Item_Class *itc,
1156                                                               setting_call_back_func gl_sel,
1157                                                               void *sel_data,
1158                                                               SWALLOW_Type
1159                                                               swallow_type,
1160                                                               char *l_icon_path,
1161                                                               char *r_icon_path,
1162                                                               int chk_status,
1163                                                               const char *keyStr,
1164                                                               char *sub_desc,
1165                                                               setting_call_back_func
1166                                                               chk_change_cb,
1167                                                               Elm_Input_Panel_Layout
1168                                                               input_type,
1169                                                               bool isPasswordFlag,
1170                                                               bool isFocusFlag,
1171                                                               int max_char_count,
1172                                                               int max_byte_count,
1173                                                               char *accepted,
1174                                                               char *rejected)
1175 {
1176         /* SETTING_TRACE_BEGIN; */
1177         Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) calloc(1,
1178                                                  sizeof (Setting_GenGroupItem_Data));
1179         setting_retvm_if(!item_data, NULL, "calloc failed");
1180         item_data->keyStr = (char *)g_strdup(keyStr);
1181         item_data->sub_desc = (char *)g_strdup(sub_desc);
1182         item_data->swallow_type = swallow_type;
1183         item_data->l_swallow_path = (char *)g_strdup(l_icon_path);
1184         item_data->r_swallow_path = (char *)g_strdup(r_icon_path);
1185         item_data->chk_status = chk_status;
1186         item_data->chk_change_cb = chk_change_cb;
1187
1188         item_data->input_type = input_type;
1189         item_data->isPasswordFlag = isPasswordFlag;
1190         item_data->isFocusFlag = isFocusFlag;
1191
1192         Elm_Entry_Filter_Accept_Set *digits_filter_data =
1193             (Elm_Entry_Filter_Accept_Set *) calloc(1, sizeof (Elm_Entry_Filter_Accept_Set));
1194         if(!digits_filter_data) {
1195                 SETTING_TRACE_ERROR("calloc Elm_Entry_Filter_Accept_Set failed");
1196                 // free allocated data
1197                 G_FREE(item_data->keyStr);
1198                 G_FREE(item_data->sub_desc);
1199                 G_FREE(item_data->l_swallow_path);
1200                 G_FREE(item_data->r_swallow_path);
1201                 FREE(item_data);
1202                 return NULL;
1203         }
1204
1205
1206         Elm_Entry_Filter_Limit_Size *limit_filter_data =
1207             (Elm_Entry_Filter_Limit_Size *) calloc(1, sizeof (Elm_Entry_Filter_Limit_Size));
1208         if(!limit_filter_data) {
1209                 SETTING_TRACE_ERROR("calloc Elm_Entry_Filter_Limit_Size failed");
1210
1211                 // free allocated data
1212                 G_FREE(item_data->keyStr);
1213                 G_FREE(item_data->sub_desc);
1214                 G_FREE(item_data->l_swallow_path);
1215                 G_FREE(item_data->r_swallow_path);
1216                 FREE(item_data);
1217                 FREE(digits_filter_data);
1218                 return NULL;
1219         }
1220
1221         limit_filter_data->max_char_count = max_char_count;
1222         limit_filter_data->max_byte_count = max_byte_count;
1223         digits_filter_data->accepted = (char *)g_strdup(accepted);
1224         digits_filter_data->rejected = (char *)g_strdup(rejected);
1225
1226         item_data->digits_filter_data = digits_filter_data;
1227         item_data->limit_filter_data = limit_filter_data;
1228         item_data->userdata = sel_data;
1229
1230         if (gl_sel) {
1231                 item_data->item =
1232                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1233                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1234                                             sel_data);
1235         } else {
1236                 item_data->item =
1237                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1238                                             ELM_GENLIST_ITEM_NONE,
1239                                             _gl_Gendial_sel, sel_data);
1240         }
1241         return item_data;
1242 }
1243
1244 /**
1245  * General function to create a parent item of expandable item
1246  *
1247  * @return a pointer to Setting_GenGroupItem_Data
1248  */
1249 Setting_GenGroupItem_Data *setting_create_Gendial_exp_parent_field(
1250                                                 Evas_Object *genlist,
1251                                                 const Elm_Genlist_Item_Class *itc,
1252                                                 setting_call_back_func gl_sel,
1253                                                 void *sel_data,
1254                                                 SWALLOW_Type swallow_type,
1255                                                 const char *keyStr,
1256                                                 char *sub_desc)
1257 {
1258         /* SETTING_TRACE_BEGIN; */
1259         Setting_GenGroupItem_Data *item_data =
1260             (Setting_GenGroupItem_Data *) calloc(1,
1261                                                  sizeof
1262                                                  (Setting_GenGroupItem_Data));
1263         setting_retvm_if(!item_data, NULL, "calloc failed");
1264         item_data->keyStr = (char *)g_strdup(keyStr);
1265         item_data->sub_desc = (char *)g_strdup(sub_desc);
1266         item_data->swallow_type = swallow_type;
1267
1268         if (gl_sel) {
1269                 item_data->item =
1270                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1271                                             ELM_GENLIST_ITEM_TREE, gl_sel,
1272                                             sel_data);
1273         } else {
1274                 item_data->item =
1275                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1276                                             ELM_GENLIST_ITEM_TREE,
1277                                             _gl_Gendial_sel_expand, sel_data);
1278         }
1279         return item_data;
1280 }
1281
1282 /**
1283  * General function to create a subitem of expandable item
1284  *
1285  * @return a pointer to Setting_GenGroupItem_Data
1286  */
1287 Setting_GenGroupItem_Data *setting_create_Gendial_exp_sub_field(
1288                                         Evas_Object *genlist,
1289                                         const Elm_Genlist_Item_Class *itc,
1290                                         setting_call_back_func gl_sel,
1291                                         void *sel_data,
1292                                         Elm_Object_Item *parent,
1293                                         SWALLOW_Type swallow_type,
1294                                         Evas_Object *rgd, int chk_status,
1295                                         const char *keyStr,
1296                                         setting_call_back_func
1297                                         chk_change_cb)
1298 {
1299         /* SETTING_TRACE_BEGIN; */
1300         Setting_GenGroupItem_Data *item_data =
1301             (Setting_GenGroupItem_Data *) calloc(1,
1302                                                  sizeof
1303                                                  (Setting_GenGroupItem_Data));
1304         setting_retvm_if(!item_data, NULL, "calloc failed");
1305         item_data->keyStr = (char *)g_strdup(keyStr);
1306         item_data->swallow_type = swallow_type;
1307         item_data->chk_status = chk_status;
1308         item_data->rgd = rgd;
1309
1310         if (!gl_sel) {
1311                 gl_sel = setting_sub_list_sel_cb;
1312         }
1313         if (!chk_change_cb) {
1314                 chk_change_cb = setting_sub_list_rd_change;
1315         }
1316
1317         item_data->chk_change_cb = chk_change_cb;
1318         item_data->item =
1319             elm_genlist_item_append(genlist, itc, item_data, parent,
1320                                     ELM_GENLIST_ITEM_NONE, gl_sel, sel_data);
1321         return item_data;
1322 }
1323
1324 /**
1325  * To make genlist support expandable style item
1326  */
1327 void setting_enable_expandable_genlist(Evas_Object *genlist, void *data,
1328                                        setting_call_back_func gl_exp_cb,
1329                                        setting_call_back_func gl_smart_cb)
1330 {
1331         ret_if(NULL == genlist);
1332         elm_genlist_tree_effect_enabled_set(genlist, TRUE);
1333         if (!gl_smart_cb) {
1334                 gl_smart_cb = __exp_list_smart_cb;
1335         }
1336
1337         if (gl_exp_cb)
1338                 evas_object_smart_callback_add(genlist, "expanded", gl_exp_cb, data);
1339         evas_object_smart_callback_add(genlist, "contracted", gl_smart_cb, "contracted");
1340
1341         evas_object_smart_callback_add(genlist, "drag", gl_smart_cb, "drag");
1342         evas_object_smart_callback_add(genlist, "longpressed", gl_smart_cb, "longpressed");
1343 }
1344
1345 /*
1346 example:
1347
1348 setting_create_Gendial_itc("dialogue/1text.2icon.2",
1349                                                         &(networkUG->itc_1text_2icon));
1350
1351 1. create a process genlist item : [intial state is 'PROCESS']
1352 ad->data_searching_net = setting_create_Gendial_field_1radio(scroller, &(ad->itc_1text_2icon),
1353                                                 setting_network_select_network_mouse_up_Gendial_list_radio_cb, ad,
1354                                                 SWALLOW_Type_1RADIO_1PROCESS,
1355                                                 ad->chk_sel, TAPI_NETWORK_SELECTIONMODE_MANUAL,
1356                                                 "Searching..", NULL);
1357 or [intial state is 'UNPROCESS']
1358 ad->data_searching_net = setting_create_Gendial_field_1radio(scroller, &(ad->itc_1text_2icon),
1359                                                 setting_network_select_network_mouse_up_Gendial_list_radio_cb, ad,
1360                                                 SWALLOW_Type_1RADIO,
1361                                                 ad->chk_sel, TAPI_NETWORK_SELECTIONMODE_MANUAL,
1362                                                 "Searching..", NULL);
1363
1364 2. to set the PROCESS state at any place as you like:
1365 setting_begin_progress_genlist_item(ad->data_searching_net); -- change from UNPROCESS->PROCESS
1366 setting_finish_progress_genlist_item(ad->data_searching_net);--change from PROCESS->UNPROCESS
1367 */
1368 void setting_begin_progress_genlist_item(Setting_GenGroupItem_Data *data_item)
1369 {
1370         if (data_item) {
1371                 if (SWALLOW_Type_1RADIO != data_item->swallow_type) {
1372                         return;
1373                 }
1374
1375                 data_item->swallow_type = SWALLOW_Type_1RADIO_1PROCESS;
1376                 elm_object_item_data_set(data_item->item, data_item);
1377                 elm_genlist_item_update(data_item->item);
1378         }
1379 }
1380
1381 void setting_finish_progress_genlist_item(Setting_GenGroupItem_Data *data_item)
1382 {
1383         if (data_item) {
1384                 if (SWALLOW_Type_1RADIO_1PROCESS != data_item->swallow_type) {
1385                         return;
1386                 }
1387                 data_item->swallow_type = SWALLOW_Type_1RADIO;
1388                 elm_object_item_data_set(data_item->item, data_item);
1389                 elm_genlist_item_update(data_item->item);
1390         }
1391 }
1392
1393 /**
1394 * Check if some item is selected in done-list
1395 */
1396
1397 bool setting_done_list_is_some_item_selected(Setting_Done_List_Data *list_data)
1398 {
1399         SETTING_TRACE_BEGIN;
1400         bool isFound = FALSE;   /* wether can found some item checked */
1401         int idx = 0;
1402         int state = 0;
1403         for (; idx < list_data->cur_item_num; idx++) {
1404                 state =
1405                     elm_check_state_get(list_data->chk_items[idx].
1406                                         data_GenItem->eo_check);
1407                 if (state) {
1408                         isFound = TRUE;
1409                         break;
1410                 }
1411         }
1412         return isFound;
1413 }
1414
1415 static void __setting_done_list_item_sel(void *data)
1416 {
1417         SETTING_TRACE_BEGIN;
1418         retm_if(data == NULL, "data == NULL");
1419         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1420
1421         int sel_num = 0;
1422         int idx = 0;
1423
1424         setting_create_sel_info_popup(list_data->ly_parent,
1425                                       &(list_data->selInfoPop_layout),
1426                                       &(list_data->selInfoPop));
1427
1428         /* else for other checks, do rotinue checking */
1429         bool isFound = FALSE;   /* wether found the item not checked */
1430         for (idx = 0; idx < list_data->cur_item_num; idx++) {
1431                 if (!list_data->chk_items[idx].data_GenItem->chk_status) {
1432                         /* SETTING_TRACE("%s not select", _(list_data->chk_items[idx].item_name)); */
1433                         isFound = TRUE;
1434                         /* break; */
1435                 } else {
1436                         /* SETTING_TRACE("%s select", _(list_data->chk_items[idx].item_name)); */
1437                         sel_num++;
1438                 }
1439         }
1440
1441         if (isFound) {  /* reset state of chk_sel_all */
1442                 list_data->select_all_checked = 0;
1443                 elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1444         } else {
1445                 list_data->select_all_checked = 1;
1446                 elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1447         }
1448
1449         /* SETTING_TRACE("sel_num:%d", sel_num); */
1450         if (!sel_num) {
1451                 evas_object_hide(list_data->selInfoPop);
1452                 return;
1453         }
1454         char text[MAX_DISPLAY_NAME_LEN_ON_UI +1] = {0, };
1455         snprintf(text, MAX_DISPLAY_NAME_LEN_ON_UI, "%s(%d)", _("IDS_ST_OPT_SELECTED"), sel_num);
1456
1457         /*  text set and timeout set */
1458         edje_object_part_text_set(_EDJ(list_data->selInfoPop_layout), "elm.text", text);
1459
1460 }
1461
1462 /**
1463 * Do process when clicking the check object in the done-list item
1464 */
1465 void setting_done_list_Gendial_chk_btn_cb(void *data, Evas_Object *obj,
1466                                           void *event_info)
1467 {
1468         SETTING_TRACE_BEGIN;
1469         /* error check */
1470         retm_if(data == NULL, "Data parameter is NULL");
1471         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
1472
1473         /* new status */
1474         list_item->chk_status = elm_check_state_get(list_item->eo_check);
1475
1476         Setting_Done_List_Data *list_data = list_item->userdata;
1477         __setting_done_list_item_sel(list_data);
1478 }
1479
1480 static void setting_done_list_Gendial_mouse_up_cb(void *data, Evas_Object *obj,
1481                                                   void *event_info)
1482 {
1483         /* error check */
1484         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1485         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1486         elm_genlist_item_selected_set(item, 0);
1487         Setting_GenGroupItem_Data *list_item =
1488             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
1489
1490         int old_status = elm_check_state_get(list_item->eo_check);
1491         /* new status */
1492         list_item->chk_status = !old_status;
1493         elm_check_state_set(list_item->eo_check, list_item->chk_status);
1494
1495         /* other process.. */
1496         Setting_Done_List_Data *list_data = list_item->userdata;
1497         __setting_done_list_item_sel(list_data);
1498 }
1499
1500 static void __setting_select_all_done(void *data)
1501 {
1502         SETTING_TRACE_BEGIN;
1503         retm_if(data == NULL, "data == NULL");
1504         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1505
1506         int sel_num = 0;
1507         int idx = 0;
1508
1509         setting_create_sel_info_popup(list_data->ly_parent,
1510                                       &(list_data->selInfoPop_layout),
1511                                       &(list_data->selInfoPop));
1512
1513         if (list_data->select_all_checked) {
1514                 /* set all other checks state to be 1 */
1515                 SETTING_TRACE_DEBUG("Select All checked");
1516                 for (idx = 0; idx < list_data->cur_item_num; idx++) {
1517                         list_data->chk_items[idx].data_GenItem->chk_status = 1;
1518                         elm_object_item_data_set(list_data->chk_items[idx].data_GenItem->item, list_data->chk_items [idx].data_GenItem);
1519                         elm_genlist_item_update(list_data->chk_items [idx].data_GenItem->item);
1520                 }
1521                 sel_num = list_data->cur_item_num;
1522         } else {
1523                 SETTING_TRACE_DEBUG("Select All unchecked");
1524                 /* set all other checks state to be 0 */
1525                 for (idx = 0; idx < list_data->cur_item_num; idx++) {
1526                         list_data->chk_items[idx].data_GenItem->chk_status = 0;
1527                         elm_object_item_data_set(list_data->chk_items[idx].data_GenItem->item, list_data->chk_items[idx].data_GenItem);
1528                         elm_genlist_item_update(list_data->chk_items[idx].data_GenItem->item);
1529                 }
1530                 sel_num = 0;
1531         }
1532
1533         /* SETTING_TRACE("sel_num:%d", sel_num); */
1534         if (!sel_num) {
1535                 evas_object_hide(list_data->selInfoPop);
1536                 return;
1537         }
1538         char text[MAX_DISPLAY_NAME_LEN_ON_UI +1] = {0, };
1539         snprintf(text, MAX_DISPLAY_NAME_LEN_ON_UI, "%s(%d)", _("IDS_ST_OPT_SELECTED"), sel_num);
1540
1541         /*  text set and timeout set */
1542         edje_object_part_text_set(_EDJ(list_data->selInfoPop_layout), "elm.text", text);
1543
1544 }
1545
1546 static void __setting_select_all_layout_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1547 {
1548         SETTING_TRACE_BEGIN;
1549         retm_if(data == NULL, "data == NULL");
1550         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1551
1552         list_data->select_all_checked = !list_data->select_all_checked;
1553         elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1554
1555         __setting_select_all_done(list_data);
1556 }
1557
1558 static void __setting_select_all_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1559 {
1560         SETTING_TRACE_BEGIN;
1561         retm_if(data == NULL, "data == NULL");
1562         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1563
1564         list_data->select_all_checked = elm_check_state_get(list_data->select_all_checkbox);
1565         elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1566         __setting_select_all_done(data);
1567 }
1568
1569 /**
1570 * The API to create done-list.
1571 *
1572 * @param[in] list_data
1573 * @return a done-list
1574 */
1575 Evas_Object *setting_create_done_list(Setting_Done_List_Data *list_data)
1576 {
1577         SETTING_TRACE_BEGIN;
1578         retvm_if(list_data == NULL, NULL, "list_data == NULL");
1579         Evas_Object *sub_layout = elm_layout_add(list_data->win_main);
1580         elm_layout_file_set(sub_layout, SETTING_THEME_EDJ_NAME, "search_layout");
1581         evas_object_size_hint_weight_set(sub_layout, EVAS_HINT_EXPAND, 0.0);
1582         evas_object_show(sub_layout);
1583
1584         setting_create_Gendial_itc("1text.1icon.2", &(list_data->itc_1text_1icon));
1585
1586         Evas_Object *select_all_layout = elm_layout_add(sub_layout);
1587         retvm_if(select_all_layout == NULL, NULL, "select_all_layout == NULL");
1588         elm_layout_theme_set(select_all_layout, "genlist", "item", "select_all/default");
1589         evas_object_size_hint_weight_set(select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
1590         evas_object_size_hint_align_set(select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1591         evas_object_event_callback_add(select_all_layout, EVAS_CALLBACK_MOUSE_DOWN, __setting_select_all_layout_mouse_down_cb, list_data);
1592
1593         Eina_Bool select_all_checked = list_data->select_all_checked;
1594         Evas_Object *select_all_checkbox = elm_check_add(select_all_layout);
1595         elm_check_state_pointer_set(select_all_checkbox, &select_all_checked);
1596         evas_object_smart_callback_add(select_all_checkbox, "changed", __setting_select_all_check_changed_cb, list_data);
1597         evas_object_propagate_events_set(select_all_checkbox, EINA_FALSE);
1598         elm_object_part_content_set(select_all_layout, "elm.icon", select_all_checkbox);
1599
1600         list_data->select_all_checkbox = select_all_checkbox;
1601         elm_object_part_text_set(select_all_layout, "elm.text", _(KeyStr_Select_All));
1602
1603         Evas_Object *scroller = elm_genlist_add(list_data->win_main);
1604         retvm_if(scroller == NULL, NULL, "scroller == NULL");
1605         elm_genlist_clear(scroller);    /* first to clear list */
1606
1607         elm_object_part_content_set(sub_layout, "search_list", scroller);
1608         elm_object_part_content_set(sub_layout, "search_bar", select_all_layout);
1609
1610         int index = 0;
1611         for (; index < list_data->cur_item_num; index++) {
1612                 list_data->chk_items[index].data_GenItem =
1613                     setting_create_Gendial_field_def(scroller,
1614                                                      &(list_data->itc_1text_1icon),
1615                                                      setting_done_list_Gendial_mouse_up_cb,
1616                                                      list_data,
1617                                                      SWALLOW_Type_1CHECK, NULL,
1618                                                      NULL, 0,
1619                                                      list_data->chk_items
1620                                                      [index].item_name, NULL,
1621                                                      setting_done_list_Gendial_chk_btn_cb);
1622                 if (list_data->chk_items[index].data_GenItem) {
1623                         list_data->chk_items[index].data_GenItem->userdata = list_data;
1624                 } else {
1625                         SETTING_TRACE_ERROR("list_data->chk_items[index].data_GenItem is NULL");
1626                 }
1627
1628         }
1629
1630         return sub_layout;
1631 }
1632
1633 /**
1634 * To disable a specialized genlist item
1635 *
1636 * @param[in] item
1637 */
1638 void setting_disable_genlist_item(Elm_Object_Item *item)
1639 {
1640         if (item) {
1641                 elm_object_item_disabled_set(item, EINA_TRUE); /* make it be dim displayed */
1642         }
1643 }
1644
1645 /**
1646 * To enable a specialized genlist item
1647 *
1648 * @param[in] item
1649 */
1650 void setting_enable_genlist_item(Elm_Object_Item *item)
1651 {
1652         if (item) {
1653                 elm_object_item_disabled_set(item, EINA_FALSE); /* make it be normally displayed */
1654         }
1655 }
1656