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