5784285f2111c19b8a60e12885fd86b484f43cff
[apps/core/preloaded/settings.git] / src / setting-plugin.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
22 #include <unistd.h>
23 #include <eina_list.h>
24 #include <glib.h>
25
26
27 #include <setting-debug.h>
28 #include <setting-common-general-func.h>
29 #include <setting-common-draw-widget.h>
30
31 #include <setting-plugin.h>
32
33
34
35 static Setting_GenGroupItem_Data *g_list_item;  /*TEST*/
36
37
38
39 /*
40  * UI draw handler table : _g_draw_list
41  *  - contains Object_Drawer typed object.
42  */
43 Eina_List *_g_drawer_list = NULL;
44
45 #if 0
46 /**
47  * @return Evas_Object * obj
48  */
49 static void* navigationbar_func(void *data, xmlNode *xmlObj);
50 #endif
51
52 /*
53  * @return void
54  */
55 static void* group_func(void *data, xmlNode *xmlObj);
56
57 /*
58  * @return Setting_GenGroupItem_Data* ptr
59  */
60 static void* link_func(void *data, xmlNode *xmlObj);
61
62 /*
63  * @return Setting_GenGroupItem_Data* ptr
64  */
65 static void* slider_func(void *data, xmlNode *xmlObj);
66
67 /*
68  * @return Setting_GenGroupItem_Data* ptr
69  */
70 static void* label_func(void *data, xmlNode *xmlObj);
71
72 /*
73  * @return Setting_GenGroupItem_Data* ptr
74  */
75 static void* checkbox_func(void *data, xmlNode *xmlObj);
76
77 /*
78  * @return Setting_GenGroupItem_Data* ptr
79  */
80 static void* editbox_func(void *data, xmlNode *xmlObj);
81
82 /*
83  * @return Setting_GenGroupItem_Data* ptr
84  */
85 static void* expandlist_func(void *data, xmlNode *xmlObj);
86
87 /**
88  * @return nothing
89  */
90 static void* expanditem_func(void *data, xmlNode *xmlObj);
91
92 /**
93  * do nothing
94  */
95 static void* settings_func(void *data, xmlNode *xmlObj);
96
97
98 static void* launch_func(void *data, xmlNode *xmlObj);
99
100 /**
101  * do nothing
102  */
103 static void* setting_func(void *data, xmlNode *xmlObj);
104
105 static int __node_walker(PluginNode* context, xmlNode* cur);
106
107 static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value, bool* is_end);
108
109
110 static void __drawer_add(const char *type, drawer_fp draw)
111 {
112         Object_Drawer *node = calloc(1, sizeof(Object_Drawer));
113         if (node && type && draw)
114         {
115                 node->type = type;
116                 node->draw = draw;
117
118                 _g_drawer_list = eina_list_append(_g_drawer_list, node);
119         }
120 }
121
122
123 static drawer_fp __drawer_find(char* type)
124 {
125         SETTING_TRACE_BEGIN;
126         SETTING_TRACE("node type:%s", type);
127         Eina_List *check_list = _g_drawer_list;
128         Object_Drawer *list_item = NULL;
129
130         while (check_list) {
131                 list_item = (Object_Drawer *) eina_list_data_get(check_list);
132                 if (NULL == list_item)
133                         continue;
134
135                 if (0 == safeStrCmp(list_item->type, type))
136                 {
137                         //SETTING_TRACE("list_item->type:%s", list_item->type);
138                         break;
139                 }
140                 //if not matched,to check next node.
141                 check_list = eina_list_next(check_list);
142                 list_item = NULL;
143         }
144         //SETTING_TRACE("list_item:%p", list_item);
145         return list_item ? list_item->draw : NULL;
146 }
147 void setting_drawer_list_init()
148 {
149         SETTING_TRACE_BEGIN;
150 #if 0
151         /* <navigationbar> */__drawer_add("navigationbar", navigationbar_func);
152 #endif
153         /* <bool>          */__drawer_add("bool", checkbox_func);
154         /* <string>        */__drawer_add("string", editbox_func);
155         /* <group>         */__drawer_add("group", group_func);
156         /* <integer>       */__drawer_add("integer", slider_func);
157         /* <label>         */__drawer_add("label", label_func);
158         /* <link>          */__drawer_add("link", link_func);
159         /* <launch>        */__drawer_add("launch", launch_func);
160         /* <extendlist>    */__drawer_add("expandlist", expandlist_func);
161         /* <extenditem>    */__drawer_add("expanditem", expanditem_func);
162         /* <settings>      */__drawer_add("settings", settings_func);
163         /* <setting>       */__drawer_add("setting", setting_func);
164 }
165
166 void setting_drawer_list_fini()
167 {
168         if (_g_drawer_list)
169         {
170                 Object_Drawer *node = NULL;
171                 Eina_List *li = _g_drawer_list;
172                 while (li) {
173                         node = (Object_Drawer *) eina_list_data_get(li);
174                         if (node)
175                         {
176                                 //SETTING_TRACE("Deregister %s", node->type);
177                                 FREE(node);
178                         }
179                         li = eina_list_next(li);
180                 }
181                 _g_drawer_list = eina_list_free(_g_drawer_list);
182                 _g_drawer_list = NULL;
183         }
184 }
185
186 /////////////////////////
187 /////////////////////////
188 /////////////////////////
189
190 #define MAX_CONTENT_LEN 512
191 #define MAX_LOCAL_BUFSIZE 128
192 #define DBUS_PATH "/setting/dbus_handler"
193 #define DBUS_SIGNAL_INTERFACE "org.tizen.setting.signal"
194
195 #define APPID_LENGTH 10
196 #define APPID_POS_FROM_PATH 10
197
198 static char* s_pkg_name;
199
200 #if 0
201 static char* substring(const char* str, size_t begin, size_t len)
202 {
203   if (str == 0 || strlen(str) == 0 || strlen(str) < begin || strlen(str) < (begin+len))
204     return 0;
205
206   return strndup(str + begin, len);
207 }
208 #endif
209
210 /**
211  * package ID
212  *
213  * ncbyusjryr.AppSetting --> package ID is ncbyusjryr
214  * "Update_" "ncbyusjryr"
215  */
216 static char* get_app_string(char* path)
217 {
218         SETTING_TRACE_BEGIN;
219         char* temp = substring(path, APPID_POS_FROM_PATH, APPID_LENGTH/*string size*/);
220         SETTING_TRACE("package ID : >>> %s ",temp );
221         return temp;
222 }
223
224 //------------------------------------------------------
225 // for client - bus
226 static DBusConnection *bus;
227 //------------------------------------------------------
228 static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* message, void* user_data)
229 {
230     int my_pid = getpid();
231     int sender_pid = 0;
232     char* key = NULL;
233     char* value = NULL;
234
235     DBusError error;
236     dbus_error_init(&error);
237
238         setting_main_appdata *ad = user_data;
239
240         char* pkg_name = get_app_string(ad->plugin_path);
241
242         char str_buf[MAX_COMMON_BUFFER_LEN];
243         snprintf(str_buf, MAX_COMMON_BUFFER_LEN, "Update_%s", pkg_name);
244         s_pkg_name = strdup(str_buf);
245
246         if (pkg_name)
247         {
248                 free(pkg_name);
249                 pkg_name = NULL;
250         }
251
252         if (s_pkg_name == NULL)
253         {
254                 SETTING_TRACE("s_pkg_name is NULL - it's abnormal operation");
255                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
256         }
257         SETTING_TRACE("s_pkg_name : %s ", s_pkg_name);
258     if (dbus_message_is_signal(message, DBUS_SIGNAL_INTERFACE, s_pkg_name))
259     {
260         if (dbus_message_get_args(message, &error,
261                 DBUS_TYPE_UINT32, &sender_pid,
262                 DBUS_TYPE_STRING, &key,
263                 DBUS_TYPE_STRING, &value,
264                 DBUS_TYPE_INVALID) == FALSE)
265         {
266             SETTING_TRACE_ERROR("Fail to get data : %s", error.message);
267             dbus_error_free(&error);
268             return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
269         }
270     }
271
272     if (sender_pid != 0 && my_pid != sender_pid)
273     {
274         SETTING_TRACE("received key : %s , value : %s", key, value);
275                 //-------------------------------------------------------------
276                 // received key : checkbox1|N/A , value : INT|1
277                 //-------------------------------------------------------------
278                 //char* key = "checkbox1|N/A";
279                 char* ptr = strchr(key, '|');
280
281                 xmlDocPtr doc = NULL;
282                 if (ptr && key)
283                 {
284                         //parsing for : checkbox1|N/A  -> checkbox1
285                         char* key_name = substring(key, 0, strlen(key)-strlen(ptr));
286                         char* val_name = strchr(value, '|');
287                         val_name++;
288
289                         // ad->plugin_path
290                         // access xml file
291                         doc = xmlParseFile(ad->plugin_path);
292                         // generate xml tree
293                         xmlNode *root = xmlDocGetRootElement(doc);
294                         // find a node
295                         bool is_end = false;
296                         __node_finder((PluginNode*)ad->plugin_node, root, key_name ,val_name, &is_end);
297                 }
298                 // update the node
299                 GError *error = NULL;
300
301 #if 0
302                 if(doc != NULL)
303                 {
304                         xmlSaveFormatFile(ad->plugin_path, doc, 1);
305                         // TODO: make sure this is right
306                         xmlFreeDoc(doc);
307                         doc = NULL;
308                         SETTING_TRACE("__cfg_file_write successful");
309                 }
310 #endif
311
312                 // update UI
313     }
314
315     return DBUS_HANDLER_RESULT_HANDLED;
316 }
317
318 static int __send_msg(char* key, char* value)
319 {
320         DBusMessage* message;
321
322         int sender_pid = getpid();
323
324         if (bus == NULL)
325                 return -1;
326
327         if (s_pkg_name == NULL)
328         {
329                 SETTING_TRACE("s_pkg_name is NULL - it's abnormal operation");
330                 return -1;
331         }
332
333         message = dbus_message_new_signal(DBUS_PATH, DBUS_SIGNAL_INTERFACE, s_pkg_name);
334
335         SETTING_TRACE("Sending message[%s:%s] via dbus", key ,value);
336         if (dbus_message_append_args(message,
337                                 DBUS_TYPE_UINT32, &sender_pid,
338                                 DBUS_TYPE_STRING, &key,
339                                 DBUS_TYPE_STRING, &value,
340                                 DBUS_TYPE_INVALID) == FALSE)
341         {
342                 SETTING_TRACE("Fail to load data error");
343                 return -1;
344         }
345
346         if (dbus_connection_send(bus, message, NULL) == FALSE)
347         {
348                 SETTING_TRACE("Fail to send message");
349                 return -1;
350         }
351
352         dbus_connection_flush(bus);
353         dbus_message_unref(message);
354
355         SETTING_TRACE("[CLIENT] send data signal done");
356
357     return 0;
358 }
359
360
361 static void __send_int_msg(xmlNode* xmlObj, int val)
362 {
363         const char *id = (char*)xmlGetProp(xmlObj, "id");
364         const char *title = (char*)xmlGetProp(xmlObj, "title");
365         char key[MAX_CONTENT_LEN] = {0,};
366         snprintf(key, sizeof(key), "%s|%s", id, title);
367
368         char value[MAX_CONTENT_LEN] = {0,};
369         snprintf(value, sizeof(value), "INT|%d", val);
370         __send_msg(key, value);
371 }
372
373
374 static void __send_string_msg(xmlNode* xmlObj, char *string)
375 {
376         const char *id = (char*)xmlGetProp(xmlObj, "id");
377         const char *title = (char*)xmlGetProp(xmlObj, "title");
378         char key[MAX_CONTENT_LEN] = {0,};
379         snprintf(key, sizeof(key), "%s|%s", id, title);
380
381         char value[MAX_CONTENT_LEN] = {0,};
382         snprintf(value, sizeof(value), "STRING|%s", string);
383         __send_msg(key, value);
384 }
385
386
387 int setting_dbus_handler_init(void* user_data)
388 {
389         SETTING_TRACE_BEGIN;
390         if (bus)
391         {
392                 SETTING_TRACE("already get a bus, need release first.");
393                 setting_dbus_handler_fini();
394         }
395         DBusError error;
396         memset(&error, 0, sizeof(DBusError));
397         char rule[MAX_LOCAL_BUFSIZE + 1] = {0,};
398         dbus_error_init(&error);
399         bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
400         if (!bus)
401         {
402                 SETTING_TRACE("Fail to connect to the D-BUS daemon: %s", error.message);
403                 dbus_error_free(&error);
404                 return -1;
405         }
406
407         dbus_connection_setup_with_g_main(bus, NULL);
408         snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
409
410         dbus_bus_add_match(bus, rule, &error);
411         if (dbus_error_is_set(&error))
412         {
413                 SETTING_TRACE("Fail to rule set; %s", error.message);
414                 dbus_bus_remove_match(bus, rule, &error);
415                 dbus_error_free(&error);
416                 dbus_connection_close(bus);
417                 bus = NULL;
418                 return -1;
419         }
420
421         if (dbus_connection_add_filter(bus, __signal_filter, user_data, NULL) == FALSE)
422         {
423                 dbus_bus_remove_match(bus, rule, &error);
424                 dbus_error_free(&error);
425                 dbus_connection_close(bus);
426                 bus = NULL;
427                 return -1;
428         }
429
430         SETTING_TRACE("app signal initialized");
431         return 0;
432 }
433
434 int setting_dbus_handler_fini(void)
435 {
436         //do safty checking first.
437         setting_retvm_if(!bus, 0, "!bus");
438         DBusError error;
439         memset(&error, 0, sizeof(DBusError));
440         char rule[MAX_LOCAL_BUFSIZE + 1] = {0, };
441
442         dbus_error_init(&error);
443         //dbus_connection_remove_filter(bus, __signal_filter, NULL);
444         snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
445         dbus_bus_remove_match(bus, rule, &error);
446
447         if (dbus_error_is_set(&error))
448         {
449                 SETTING_TRACE("Fail to rule unset: %s", error.message);
450                 dbus_error_free(&error);
451                 //return -1;
452         }
453
454         dbus_connection_close(bus);
455         bus = NULL;
456         SETTING_TRACE("app signal finalized");
457         return 0;
458 }
459
460 /////////////////////////////
461 /////////////////////////////
462 /////////////////////////////
463
464 Elm_Genlist_Item_Class itc_layout;
465
466 // write -> update
467 static int __cfg_file_write(Draw_Data *pd)
468 {
469         SETTING_TRACE_BEGIN;
470
471         GError *error = NULL;
472         if(pd->doc != NULL)
473         {
474                 xmlSaveFormatFile(pd->cfg_file, pd->doc, 1);
475                 //xmlFreeDoc(pd->doc);
476                 //pd->doc = NULL;
477                 SETTING_TRACE("__cfg_file_write successful");
478         }
479
480         return TRUE;
481 }
482
483
484 static void ___click_softkey_back_cb(void *data, Evas_Object *obj,
485                                           void *event_info)
486 {
487         SETTING_TRACE_BEGIN;
488         ret_if(!data);
489
490         PluginNode* node = (PluginNode*)data;
491         Draw_Data *pd = node->pd;
492         if (pd->ly_main) {
493                 evas_object_del(pd->ly_main);
494                 pd->ly_main = NULL;
495         }
496
497         setting_plugin_destroy(node);
498
499         pd->scroller = NULL;
500         pd->navi_bar = NULL;
501         pd->cfg_file = NULL;
502
503
504
505
506         pd->root = NULL;
507 }
508
509
510 static void* group_func(void *data, xmlNode *xmlObj)
511 {
512         SETTING_TRACE_BEGIN;
513         ret_if(!data || !xmlObj);
514
515         PluginNode* node = (PluginNode*)data;
516         Draw_Data *pd = node->pd;
517
518         // original code is non-recursive
519 #if 0
520         const char *title = (char*)json_object_get_string_member(jsonObj, "title");
521         (void)setting_create_Gendial_field_titleItem(pd->scroller,
522                                                      &(itc_group_item),
523                                                      title, NULL);
524
525         // non recursive method
526         if (json_object_has_member(jsonObj, "elements"))
527         {
528                 JsonNode* elements_node = json_object_get_member(jsonObj, "elements");
529                 int i;
530                 JsonObject* tempobj;
531                 char* type;
532                 for (i=0; i < json_array_get_length(json_node_get_array(elements_node)); i++)
533                 {
534                         tempobj  = json_array_get_object_element(json_node_get_array(elements_node), i);
535                         type = (char*)json_object_get_string_member(tempobj, "type");
536                         drawer_fp  fp = __drawer_find(type);
537                         if (fp) fp(pd, tempobj); // draw it
538                 }
539         }
540 #else
541         // new code is recursive
542         const char *title = (char*)xmlGetProp(xmlObj, "title");
543         SETTING_TRACE (" >>> GROUP NAME : %s \n", title);
544         (void)setting_create_Gendial_field_titleItem(pd->scroller, &(itc_group_item), title, NULL);
545 #endif
546
547         return NULL;
548 };
549
550
551 static void* __link_list_cb(void *data, Evas_Object *obj, void *event_info)
552 {
553         SETTING_TRACE_BEGIN;
554         ret_if(data == NULL);
555         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
556         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
557         elm_genlist_item_selected_set(item, 0);
558         Setting_GenGroupItem_Data *list_item =
559             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
560
561         xmlNode* xmlObj = data;
562         ret_if(!xmlObj);
563         const char *link_file = (char*)xmlGetProp(xmlObj, "value");
564
565         if(!link_file)
566         {
567                 SETTING_TRACE_ERROR("Invalidate liked file");
568                 return;
569         }
570         char file[1024] = {0,};
571         snprintf(file, sizeof(file), "%s/%s", PLUGIN_CFG_DIR, link_file);
572         SETTING_TRACE("file:%s", file);
573
574         PluginNode* plugin_node = setting_plugin_create();
575         setting_plugin_load(plugin_node, (const char *)file);
576
577         //setting_plugin_load(NULL, file);
578
579         return NULL;
580 }
581
582 static void* __launch_list_cb(void *data, Evas_Object *obj, void *event_info)
583 {
584         SETTING_TRACE_BEGIN;
585         ret_if(data == NULL);
586         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
587         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
588         elm_genlist_item_selected_set(item, 0);
589         Setting_GenGroupItem_Data *list_item =
590             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
591
592         xmlNode* xmlObj = data;
593         ret_if(!xmlObj);
594         const char *key_str = (char*)xmlGetProp(xmlObj, "id");
595         const char *title_str = (char*)xmlGetProp(xmlObj, "title");
596         const char *appid_str = (char*)xmlGetProp(xmlObj, "appid");
597         const char *operation_str = (char*)xmlGetProp(xmlObj, "operation");
598
599
600         service_h svc = NULL;
601         service_create(&svc);
602         service_set_app_id(svc, appid_str);                                                     // xml property â€“ appid
603         service_set_operation(svc, operation_str);                                              // property : operation
604         service_send_launch_request(svc, NULL, NULL);
605         service_destroy(svc);
606
607         return NULL;
608 }
609
610 static void* label_func(void *data, xmlNode *xmlObj)
611 {
612         SETTING_TRACE_BEGIN;
613         ret_if(!data || !xmlObj);
614         PluginNode* node = (PluginNode*)data;
615         Draw_Data *pd = node->pd;
616
617         const char *title = (char*)xmlGetProp(xmlObj, "title");
618
619         Setting_GenGroupItem_Data *obj =
620                 setting_create_Gendial_field_def(pd->scroller, &(itc_1text),
621                                                  NULL,
622                                                  xmlObj, SWALLOW_Type_INVALID, NULL, NULL,
623                                                  0, title, NULL, NULL);
624
625         return obj;
626 }
627
628 static void* link_func(void *data, xmlNode *xmlObj)
629 {
630         SETTING_TRACE_BEGIN;
631         ret_if(!data || !xmlObj);
632         PluginNode* node = (PluginNode*)data;
633         Draw_Data *pd = node->pd;
634
635         const char *key_str = (char*)xmlGetProp(xmlObj, "id");
636         Setting_GenGroupItem_Data * obj =
637                 setting_create_Gendial_field_def(pd->scroller, &(itc_1text),
638                                                  __link_list_cb,
639                                                  xmlObj, SWALLOW_Type_INVALID, NULL, NULL,
640                                                  0, key_str, NULL, NULL);
641
642         return (void*)obj;
643 };
644
645 static void* launch_func(void *data, xmlNode *xmlObj)
646 {
647         SETTING_TRACE_BEGIN;
648         ret_if(!data || !xmlObj);
649         PluginNode* node = (PluginNode*)data;
650         Draw_Data *pd = node->pd;
651
652         const char *title_str = (char*)xmlGetProp(xmlObj, "title");
653
654         Setting_GenGroupItem_Data * obj =
655                 setting_create_Gendial_field_def(pd->scroller, &(itc_1text),
656                                                  __launch_list_cb,
657                                                  xmlObj, SWALLOW_Type_INVALID, NULL, NULL,
658                                                  0, title_str, NULL, NULL);
659
660         return (void*)obj;
661 };
662
663 static void __slider_stop_cb(void *data, Evas_Object *obj,
664                                     void *event_info)
665 {
666         ret_if(data == NULL || obj == NULL);
667         double val = elm_slider_value_get(obj);
668         SETTING_TRACE("val = %f", val);
669         Setting_GenGroupItem_Data *list_item = data;
670         ret_if(list_item->userdata == NULL);
671
672         xmlNode* xmlObj = list_item->userdata;
673         ret_if(!xmlObj);
674
675         //apply the vconf changes after stopping moving slider..
676         list_item->chk_status = (int)(val + 0.5);
677         elm_slider_value_set(obj, list_item->chk_status);
678
679         SETTING_TRACE(" slider after ---> val = %d", (int) list_item->chk_status);
680
681         // int -> double -> xmlChar*
682         xmlAttrPtr newattr;
683         char buf[10];
684         sprintf(buf, "%d", (int) list_item->chk_status);
685         newattr = xmlSetProp(xmlObj, "value", buf);
686
687         __send_int_msg(xmlObj, list_item->chk_status);
688         __cfg_file_write((Draw_Data *)list_item->belongs_to);
689 }
690
691
692 static void* slider_func(void *data, xmlNode *xmlObj)
693 {
694         SETTING_TRACE_BEGIN;
695         ret_if(!data || !xmlObj);
696         PluginNode* node = (PluginNode*)data;
697         Draw_Data *pd = node->pd;
698
699         // type casting
700         const char *title = (char*)xmlGetProp(xmlObj, "title");
701
702         SETTING_TRACE (" >>> [slider input] min=%s max=%s value=%s ",(char*)xmlGetProp(xmlObj, "min"), (char*)xmlGetProp(xmlObj, "max"), (char*)xmlGetProp(xmlObj, "value"));
703
704         int value = atoi((char*)xmlGetProp(xmlObj, "value"));
705         int min = atoi((char*)xmlGetProp(xmlObj, "min"));
706         int max = atoi((char*)xmlGetProp(xmlObj, "max"));
707
708         SETTING_TRACE ("[slider input] min=%d max=%d value=%d ", min, max, value);
709
710         setting_create_Gendial_itc("dialogue/1text.1icon.5", &(itc_layout));
711         Setting_GenGroupItem_Data *list_item =
712             setting_create_Gendial_field_def(pd->scroller, &(itc_layout), NULL,
713                                              NULL,
714                                              SWALLOW_Type_LAYOUT_SLIDER,
715                                              IMG_SENSITIVITY_ICON_01,
716                                              IMG_SENSITIVITY_ICON_02, value,
717                                              title, NULL, NULL);
718         if (list_item) {
719                 list_item->win_main = NULL;
720                 list_item->evas = NULL;
721                 list_item->isIndicatorVisible = true;
722                 list_item->slider_min = min;
723                 list_item->slider_max = max;
724                 list_item->userdata = xmlObj;
725                 list_item->stop_change_cb = __slider_stop_cb;
726                 list_item->belongs_to = (int)pd;
727         }
728
729         g_list_item = list_item;
730
731         return (void*)list_item;
732 };
733
734 #if 0
735 /*
736   elm_object_item_data_set(item_to_update->item, item_to_update);
737   elm_genlist_item_update(item_to_update->item);
738 */
739 static void* navigationbar_func(void *data, xmlNode *xmlObj)
740 {
741 #if 1
742         SETTING_TRACE_BEGIN;
743         ret_if(!data || !xmlObj);
744
745         PluginNode* node = (PluginNode*)data;
746         Draw_Data *pd = node->pd;
747
748         //----------------------------------------------------------------
749         // [DATA] title, btn[0], btn[1]
750         const char *title = (char*)xmlGetProp(xmlObj, "title");
751         char *btn[2] = {0, };
752
753         // find child nodes named 'elements'
754         if (xmlObj->children) {
755                 xmlNode* cur = xmlObj->children;
756                 int i =0;
757                 while (cur != NULL)
758                 {
759                         if (!xmlStrcmp(cur->name, (const xmlChar*)"button")) {
760                                 btn[i] = xmlGetProp(cur, "title");
761                                 SETTING_TRACE("------>>> node type : Element, name=%s id=%s / btn[%d] = %s ",
762                                                                 cur->name,xmlGetProp(cur, "id"),
763                                                                 i,
764                                                                 btn[i]);
765                                 i++;
766                         }
767                         cur = cur->next;
768                 }
769         }
770         //----------------------------------------------------------------
771         // [UI] with DATA
772         pd->ly_main = setting_create_layout_navi_bar_genlist(pd->win_get,
773                                                    pd->win_get,
774                                                    _(title),
775                                                    _(btn[1]), _(btn[0]),
776                                                    ___click_softkey_back_cb,
777                                                    ___click_softkey_back_cb, data, &pd->scroller,
778                                                    &(pd->navi_bar));
779
780 #endif
781         return NULL;
782 };
783 #endif
784
785 static void __check_mouse_up_cb(void *data, Evas_Object *obj,
786                                              void *event_info)
787 {
788         /* error check */
789         SETTING_TRACE_BEGIN;
790         setting_retm_if(data == NULL, "Data parameter is NULL");
791
792         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
793         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
794         elm_genlist_item_selected_set(item, 0);
795         Setting_GenGroupItem_Data *list_item =
796             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
797
798         SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
799
800         int old_status = elm_check_state_get(list_item->eo_check);
801         list_item->chk_status = !old_status;
802         elm_check_state_set(list_item->eo_check, list_item->chk_status);
803
804         xmlNode *xmlObj = data;
805         xmlAttrPtr newattr;
806         newattr = xmlSetProp(xmlObj, "state", xmlXPathCastNumberToString(list_item->chk_status));
807
808         __send_int_msg(xmlObj, list_item->chk_status);
809         __cfg_file_write((Draw_Data *)list_item->belongs_to);
810 }
811
812
813 static void __chk_btn_cb(void *data, Evas_Object *obj,
814                                              void *event_info)
815 {
816         SETTING_TRACE_BEGIN;
817         /* error check */
818         retm_if(data == NULL, "Data parameter is NULL");
819         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
820
821         xmlNode* xmlObj = list_item->userdata;
822         ret_if(!xmlObj);
823         list_item->chk_status = elm_check_state_get(obj);       /*  for genlist update status */
824
825         xmlAttrPtr newattr;
826         if (list_item->chk_status == 1) {
827                 newattr = xmlSetProp(xmlObj, "value", "true");
828         } else if (list_item->chk_status == 0) {
829                 newattr = xmlSetProp(xmlObj, "value", "false");
830         } else {
831                 newattr = xmlSetProp(xmlObj, "value", "false");
832         }
833
834         const char *id = (char*)xmlGetProp(xmlObj, "id");
835         const char *title = (char*)xmlGetProp(xmlObj, "title");
836         //SETTING_TRACE(" >>>> id:%s , title:%s", id, title);
837         __send_int_msg(xmlObj, list_item->chk_status);
838         __cfg_file_write((Draw_Data *)list_item->belongs_to);
839         return;
840 }
841
842
843 static void* checkbox_func(void *data, xmlNode *xmlObj)
844 {
845         SETTING_TRACE_BEGIN;
846         ret_if(!data || !xmlObj);
847
848         PluginNode* node = (PluginNode*)data;
849         Draw_Data *pd = node->pd;
850
851         // [DATA] title, value
852         const char *title = (char*)xmlGetProp(xmlObj, "title");
853
854         // true / false
855         char* value = (char*)xmlGetProp(xmlObj, "value");
856
857         int ival = -1;
858
859         if ( 0 == safeStrCmp(value, "true")) {
860                 ival = 1;
861         } else if ( 0 == safeStrCmp(value, "false"))  {
862                 ival = 0;
863         } else {
864                 ival = 0;       // default : false (0)
865         }
866
867         // title, value, xmlObj
868         Setting_GenGroupItem_Data *list_item =
869                 setting_create_Gendial_field_def(pd->scroller,
870                                           &(itc_1text_1icon),
871                                           __check_mouse_up_cb,
872                                           xmlObj,
873                                           SWALLOW_Type_1TOGGLE,
874                                           NULL, NULL,
875                                           ival,
876                                           title,
877                                           NULL,
878                                           __chk_btn_cb);
879         if(list_item) {
880                 list_item->userdata = xmlObj;
881                 list_item->belongs_to = (int) pd;
882                 SETTING_TRACE("pd:%p,list_item->belongs_to:%d", pd, list_item->belongs_to);
883         }
884
885         return list_item;
886 }
887
888
889 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
890 {
891         SETTING_TRACE_BEGIN;
892         retm_if(!data || !obj, "Data parameter is NULL");
893
894         setting_hide_input_pannel_cb(obj);
895         const char *entry_str = elm_entry_entry_get(obj);
896         char *entry_str_utf8 = NULL;
897         entry_str_utf8 = elm_entry_markup_to_utf8(entry_str);
898
899         Setting_GenGroupItem_Data *list_item = data;
900
901         xmlNode* xmlObj = list_item->userdata;
902         ret_if(!xmlObj);
903         xmlAttrPtr newattr;
904         const char *title = (char*)xmlSetProp(xmlObj, "value",entry_str_utf8);
905
906         __send_string_msg(xmlObj, entry_str_utf8);
907         __cfg_file_write((Draw_Data *)list_item->belongs_to);
908
909         FREE(entry_str_utf8);
910 }
911
912
913 static void __editbox_list_cb(void *data, Evas_Object *obj,
914                                             void *event_info)
915 {
916         SETTING_TRACE_BEGIN;
917         /* error check */
918
919         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
920         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
921         elm_genlist_item_selected_set(item, 0);
922         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
923
924         SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
925         if (!elm_object_focus_get(list_item->eo_check)) {
926                 elm_object_focus_set(list_item->eo_check, EINA_TRUE);
927         }
928
929         Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(list_item->eo_check);
930         setting_retm_if(imf_context == NULL, "imf_context is NULL");
931         ecore_imf_context_input_panel_show(imf_context);
932 }
933
934
935 static void __editbox_changed_cb(void *data, Evas_Object *obj,
936                                        void *event_info)
937 {
938         SETTING_TRACE_BEGIN;
939         retm_if(!data || !obj, "Data parameter is NULL");
940         retm_if(!elm_object_focus_get(obj), "Entry is not focused");
941
942         Setting_GenGroupItem_Data *list_item =
943             (Setting_GenGroupItem_Data *) data;
944
945         const char *entry_str = elm_entry_entry_get(obj);
946         int entry_len = safeStrLen(entry_str);
947         SETTING_TRACE("entry_str:[%s], lenght:%d", entry_str, entry_len);
948
949         G_FREE(list_item->sub_desc);//release first
950         list_item->sub_desc = (char *)g_strdup(entry_str);
951 }
952
953
954 static void* editbox_func(void *data, xmlNode *xmlObj)
955 {
956         SETTING_TRACE_BEGIN;
957         ret_if(!data || !xmlObj);
958
959         PluginNode* node = (PluginNode*)data;
960         Draw_Data *pd = node->pd;
961
962         const char *title = (char*)xmlGetProp(xmlObj, "title");
963         const char *key_str= (char*)xmlGetProp(xmlObj, "value");
964
965         const char *minlength= (char*)xmlGetProp(xmlObj, "minlength");
966         const char *maxlength= (char*)xmlGetProp(xmlObj, "maxlength");
967
968         int max_len = -1;
969         if (maxlength)
970         {
971                 max_len = atoi(maxlength);
972                 SETTING_TRACE(" >> MAXLENGTH FILTER IS AVAILABLE !!!! maxlength = %d", max_len);
973         }
974
975         Setting_GenGroupItem_Data *list_item = NULL;
976
977         if (max_len == -1)
978         {
979                 // without maxlength filter
980                 list_item = setting_create_Gendial_field_def(pd->scroller, &(itc_1icon),
981                                                                  __editbox_list_cb,
982                                                          pd, SWALLOW_Type_LAYOUT_ENTRY,
983                                                          NULL, NULL, 0, title, key_str,
984                                                          __editbox_changed_cb);
985
986         } else {
987                 // add max length filter
988                 list_item = setting_create_Gendial_field_entry(
989                                                                         pd->scroller,
990                                                                         &(itc_1icon),
991                                                                         __editbox_list_cb,
992                                                                         pd,
993                                                                         SWALLOW_Type_LAYOUT_ENTRY,
994                                                                         NULL, NULL, 0, title, key_str, __editbox_changed_cb,
995                                                                         ELM_INPUT_PANEL_LAYOUT_NORMAL,
996                                                                         false,
997                                                                         false,
998                                                                         max_len,
999                                                                         0,
1000                                                                         NULL, NULL);
1001
1002         }
1003         if (list_item) {
1004                 list_item->userdata = xmlObj;
1005                 list_item->stop_change_cb = __entry_unfocus_cb;
1006                 list_item->belongs_to = (int)pd;
1007         }
1008
1009         return list_item;
1010 };
1011
1012
1013 static void __expanditem_func_sel_cb(void *data, Evas_Object *obj, void *event_info)
1014 {
1015         SETTING_TRACE_BEGIN;
1016         /* error check */
1017         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1018         Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
1019         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
1020         elm_genlist_item_selected_set(subitem, 0);
1021         Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
1022         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
1023         ret_if(NULL == data_subItem || NULL == data_parentItem);
1024
1025         elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
1026
1027         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
1028         elm_object_item_data_set(data_parentItem->item, data_parentItem);
1029         elm_genlist_item_update(data_parentItem->item);
1030
1031         xmlNode* xmlObj = data_parentItem->userdata;
1032         ret_if(!xmlObj);
1033
1034         xmlAttrPtr newattr;
1035         //newattr = xmlSetProp(xmlObj, "string", data_parentItem->sub_desc);
1036         newattr = xmlSetProp(xmlObj, "value", data_parentItem->sub_desc);
1037
1038         __send_string_msg(xmlObj, data_parentItem->sub_desc);
1039         __cfg_file_write((Draw_Data *)data_parentItem->belongs_to);
1040 }
1041
1042
1043 static void __expanditem_func_exp_cb(void *data, Evas_Object *obj, void *event_info)
1044 {
1045         ret_if(NULL == data || NULL == event_info);
1046         SETTING_TRACE_BEGIN;
1047
1048         PluginNode* node = (PluginNode*)data;
1049         Draw_Data *pd = node->pd;
1050
1051         Elm_Object_Item *parentItem = event_info;       /* parent item */
1052         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
1053         Evas_Object *scroller = elm_object_item_widget_get(parentItem);
1054
1055
1056         xmlNode *xmlObj = data_parentItem->userdata;
1057         //char *value = (char*)xmlGetProp(xmlObj, "string");
1058         char *value = (char*)xmlGetProp(xmlObj, "value");
1059         SETTING_TRACE(">>> value = %s", value);
1060         int i=0;
1061         Evas_Object *rgd = NULL;
1062
1063         if (xmlObj->children && !data_parentItem->rgd) {//to protect from entering repeatly
1064                 xmlNode* cur = xmlObj->children;
1065
1066                 rgd = elm_radio_add(scroller);
1067                 elm_radio_value_set(rgd, -1);
1068
1069                 int i;
1070                 char *type;
1071                 char *subitem_title = NULL;
1072                 int subitem_index = 0;
1073                 int sel_idx = -1;
1074
1075                 while (cur != NULL) {
1076                         if (!xmlStrcmp(cur->name, (const xmlChar*)"expanditem")) {
1077                                 type = (char*)xmlGetProp(cur, "type");
1078                                 if (0 == safeStrCmp(type, "radio")) {
1079                                         subitem_title = (char*)xmlGetProp(cur, "title");
1080                                         Setting_GenGroupItem_Data *list_item =
1081                                                                                         setting_create_Gendial_exp_sub_field(scroller,
1082                                                                                                         &(itc_1icon_1text_sub),
1083                                                                                                         __expanditem_func_sel_cb, NULL, parentItem,
1084                                                                                                         SWALLOW_Type_1RADIO, rgd,
1085                                                                                                         subitem_index,
1086                                                                                                         subitem_title, NULL);
1087
1088                                         // SETTING_TRACE(">>> value = %s, subitem_title = %s ", value, subitem_title);
1089
1090                                         if (0 == safeStrCmp(value, subitem_title)) {
1091                                                 sel_idx = subitem_index;
1092                                                 SETTING_TRACE("%d is selected in Radio Group", sel_idx);
1093                                         }
1094                                         data_parentItem->childs = eina_list_append(data_parentItem->childs, list_item);
1095                                         subitem_index++;
1096
1097                                 } else {
1098                                         SETTING_TRACE("invalid type[:%s]", type);
1099                                 }
1100
1101                                 i++;
1102                         }
1103                         cur = cur->next;
1104                 }
1105
1106                 // value set
1107                 elm_radio_value_set(rgd, sel_idx);
1108                 data_parentItem->rgd = rgd;//protecting condition
1109         }
1110 }
1111
1112
1113 static void __expanditem_func_smart_cb(void *data, Evas_Object *obj, void *event_info)
1114 {
1115         ret_if(data == NULL || event_info == NULL);
1116         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1117         Setting_GenGroupItem_Data *data_item = elm_object_item_data_get(item);
1118         char *cb_type = data;
1119
1120         if (0 == safeStrCmp(cb_type, "contracted")) {
1121                 data_item->rgd = NULL;
1122                 elm_genlist_item_subitems_clear(item);
1123         }
1124 }
1125
1126
1127 static void* settings_func(void *data, xmlNode *xmlObj)
1128 {
1129         return NULL;
1130 }
1131
1132
1133 static Evas_Object *setting_create_win_layout2(Evas_Object *win_layout, Evas_Object *win_obj)
1134 {
1135
1136     Evas_Object *layout = NULL;
1137     Evas_Object *conform = elm_conformant_add(win_obj);
1138     //setting_main_appdata *ad = (setting_main_appdata *) data;
1139
1140     /*  Base Layout */
1141     layout = elm_layout_add(conform);
1142     evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1143     setting_retvm_if(layout == NULL, FALSE, "layout == NULL");
1144
1145     elm_layout_theme_set(layout, "layout", "application", "default");
1146     evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1147     evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
1148     elm_win_resize_object_add(win_obj, conform);
1149     elm_object_content_set(conform, layout);
1150
1151     Evas_Object *bg = setting_create_bg(layout, win_obj, "group_list");
1152     elm_object_part_content_set(layout, "elm.swallow.bg", bg);
1153     evas_object_show(layout);
1154     evas_object_show(conform);
1155
1156     //ad->conformant = conform;
1157     return layout;
1158 }
1159
1160
1161 Evas_Object *setting_create_layout_navi_bar2(Evas_Object *win_layout, Evas_Object *win_obj, char *title_str, char *lbutton_str, char *rbutton_str, char *mbutton_str, setting_call_back_func lbutton_click_cb, setting_call_back_func rbutton_click_cb, setting_call_back_func mbutton_click_cb, void *cb_data, Evas_Object *eo_view,   /*any container obj constructed on any evas obj */
1162                                             Evas_Object **navi_bar,
1163                                             Evas_Object **titleobj)
1164 {
1165
1166         Evas_Object *layout = setting_create_win_layout2(win_layout, win_obj);
1167         *navi_bar = setting_create_navi_bar(layout);
1168
1169         setting_create_navi_bar_buttons(title_str,
1170                                         lbutton_str, rbutton_str, mbutton_str,
1171                                         lbutton_click_cb, rbutton_click_cb,
1172                                         mbutton_click_cb, cb_data, eo_view /*content */ ,
1173                                         *navi_bar, NULL);
1174         return layout;
1175 }
1176
1177 // <setting>
1178 static void* setting_func(void *data, xmlNode *xmlObj)
1179 {
1180         SETTING_TRACE_BEGIN;
1181         ret_if(!data || !xmlObj);
1182
1183 #if 1
1184         PluginNode* node = (PluginNode*)data;
1185         Draw_Data *pd = node->pd;
1186
1187         // [DATA] title, btn[0], btn[1]
1188         const char *title = (char*)xmlGetProp(xmlObj, "title");
1189         char *btn[2] = {/* 0 */"OK", /* 1 */"NO"};
1190
1191         SETTING_TRACE("before setting_create_layout_navi_bar_genlist");
1192
1193         // [UI] with DATA
1194         pd->scroller = elm_genlist_add(pd->win_get);
1195         retvm_if(pd->scroller == NULL, NULL,
1196                  "Cannot set scroller object  as contento of layout");
1197         elm_object_style_set(pd->scroller, "dialogue");
1198         elm_genlist_clear(pd->scroller);        /* first to clear list */
1199
1200
1201         SETTING_TRACE("_(title):%s", _(title));
1202         pd->ly_main = setting_create_layout_navi_bar2(pd->win_get, pd->win_get,
1203                                            _(title),
1204                                            _("IDS_COM_BODY_BACK"), NULL, NULL,
1205                                            ___click_softkey_back_cb,
1206                                            NULL, NULL,
1207                                            data, pd->scroller,
1208                                            &(pd->navi_bar), NULL);
1209         SETTING_TRACE("after setting_create_layout_navi_bar_genlist");
1210
1211 #endif
1212         return NULL;
1213 }
1214
1215
1216 static void* expanditem_func(void *data, xmlNode *xmlObj)
1217 {
1218         // DO NOTHING - expandlist draws this area
1219         return NULL;
1220 }
1221
1222 static void* expandlist_func(void *data, xmlNode *xmlObj)
1223 {
1224         SETTING_TRACE_BEGIN;
1225         ret_if(!data || !xmlObj);
1226
1227         PluginNode* node = (PluginNode*)data;
1228         Draw_Data *pd = node->pd;
1229
1230         const char *key_str = (char*)xmlGetProp(xmlObj, "title");
1231         const char *value = (char*)xmlGetProp(xmlObj, "value"); // string -> value
1232
1233         setting_enable_expandable_genlist(pd->scroller, data, __expanditem_func_exp_cb, __expanditem_func_smart_cb);
1234         Setting_GenGroupItem_Data *list_item =
1235             setting_create_Gendial_exp_parent_field(pd->scroller,
1236                                                     &(itc_2text_3_parent),
1237                                                     NULL, NULL,
1238                                                     SWALLOW_Type_INVALID,
1239                                                     key_str,
1240                                                     value);
1241         if (list_item) {
1242                 list_item->userdata = xmlObj;
1243                 list_item->belongs_to = (int)pd;
1244         }
1245
1246         return list_item;
1247 }
1248
1249
1250
1251 static int __node_walker(PluginNode* context, xmlNode* cur)
1252 {
1253         //SETTING_TRACE_BEGIN;
1254         Draw_Data *pd = context->pd;
1255
1256         retv_if(!pd, -1);
1257         xmlNode *cur_node = NULL;
1258         for (cur_node = cur; cur_node;cur_node = cur_node->next) {
1259                 if (cur_node->type == XML_ELEMENT_NODE) {
1260                         // SETTING_TRACE("node type : %s id= %s", cur_node->name,xmlGetProp(cur_node, "id"));
1261                         drawer_fp  fp = __drawer_find(cur_node->name);
1262                         if (fp)
1263                         {
1264                                 // type check
1265                                 void* vret = fp(context, cur_node); // draw it
1266
1267                                 if (vret)
1268                                 {
1269                                         Setting_GenGroupItem_Data* genlist_node = (Setting_GenGroupItem_Data* )vret;
1270                                         //SETTING_TRACE("add node to Eina List name : %s, id : ", cur_node->name, xmlGetProp(cur_node, "id"));
1271                                         // add it to the hash table create before.
1272                                         // id, object
1273                                         // add list
1274                                         char* key_name = xmlGetProp(cur_node, "id");
1275                                         eina_hash_add(context->ui_list, strdup(key_name),(void*)genlist_node);
1276                                 }
1277                         }
1278                 }
1279                 __node_walker(context, cur_node->children);     /* RECURSIVE */
1280         }
1281         return 0;
1282 }
1283
1284 /**
1285  * @param id_str [in] "id"
1286  * @param value [in] value to be udpated
1287  * @see __expanditem_func_sel_cb
1288  */
1289 static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value, bool* is_end)
1290 {
1291         SETTING_TRACE_BEGIN;
1292         xmlNode *cur_node = NULL;
1293
1294         if (*is_end == true) return 0;
1295
1296         for (cur_node = cur; cur_node;cur_node = cur_node->next) {
1297                 if (cur_node->type == XML_ELEMENT_NODE) {
1298
1299                         char* id_name = (char*)xmlGetProp(cur_node, "id");
1300                         if ( id_name && 0 == strcmp(id_str, id_name))
1301                         {
1302                                 SETTING_TRACE("FOUND >>>> %s", id_name);
1303                                 // cur_node     - update xml code
1304                                 xmlAttrPtr newattr = xmlSetProp(cur_node, "value", value);
1305
1306                                 //-----------------------------------------------------------
1307                                 // UI UPDATE
1308                                 // case : slider
1309                                 if ( 0 == strcmp (cur_node->name, "integer"))
1310                                 {
1311                                         SETTING_TRACE(">>>>> UPDATE SLIDER CONTROL %x --- %s ",context->ui_list, id_name);
1312                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1313                                         if      (item_to_update)
1314                                         {
1315                                                 item_to_update->chk_status = atoi(value);
1316                                                 SETTING_TRACE(">>>   o-------------0 SLIDER VALUE = %d ", item_to_update->chk_status);
1317
1318                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1319                                                 elm_genlist_item_update(item_to_update->item);
1320                                         } else {
1321                                                 SETTING_TRACE("item_to_update is NULL");
1322                                         }
1323                                 }
1324                                 // case : toggle
1325                                 if ( 0 == strcmp (cur_node->name, "bool"))
1326                                 {
1327                                         SETTING_TRACE(">>>>> UPDATE TOGGLE CONTROL %x --- %s ",context->ui_list, id_name);
1328                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1329                                         if      (item_to_update)
1330                                         {
1331                                                 item_to_update->chk_status = atoi(value);
1332                                                 SETTING_TRACE(">>>   o-------------0 TOGGLE VALUE = %d ", item_to_update->chk_status);
1333
1334                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1335                                                 elm_genlist_item_update(item_to_update->item);
1336                                         } else {
1337                                                 SETTING_TRACE("item_to_update is NULL");
1338                                         }
1339                                 }
1340                                 // case : edit control
1341                                 if ( 0 == strcmp (cur_node->name, "string"))
1342                                 {
1343                                         SETTING_TRACE(">>>>> UPDATE EDIT CONTROL CONTROL %x --- %s ",context->ui_list, id_name);
1344                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1345                                         if      (item_to_update)
1346                                         {
1347                                                 char* old_string = item_to_update->sub_desc;
1348                                                 item_to_update->sub_desc = strdup(value);
1349                                                 SETTING_TRACE(">>>   o-------------0 STRING VALUE = %s ", value);
1350
1351                                                 // free old string
1352
1353                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1354                                                 elm_genlist_item_update(item_to_update->item);
1355
1356                                         } else {
1357                                                 SETTING_TRACE("item_to_update is NULL");
1358                                         }
1359                                 }
1360                                 // case : expand list
1361                                 // parent
1362                                 //    child1
1363                                 //    child2
1364                                 //    child3
1365                                 //    child4
1366                                 //-----------------------------------------------------------
1367                                 if ( 0 == strcmp (cur_node->name, "expandlist"))
1368                                 {
1369                                         SETTING_TRACE(">>>>> UPDATE EXPAND LIST CONTROL %x --- %s ",context->ui_list, id_name);
1370                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1371                                         if      (item_to_update)
1372                                         {
1373                                                 char* old_string = item_to_update->sub_desc;
1374                                                 item_to_update->sub_desc = strdup(value);
1375                                                 SETTING_TRACE(">>>   o-------------0 EXPAND LIST VALUE = %s ", value);
1376
1377                                                 // free old string
1378                                                 // string update
1379                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1380                                                 elm_genlist_item_update(item_to_update->item);
1381
1382                                                 // TODO: need to update child elements
1383                                                 // item_to_update->childs ---> expanded list
1384                                                 if (item_to_update->childs)
1385                                                 {
1386                                                         Eina_List *li = item_to_update->childs;
1387                                                         int radio_index = 0;
1388                                                         while(li)
1389                                                         {
1390                                                                 Setting_GenGroupItem_Data* node = eina_list_data_get(li);
1391                                                                 // do something more
1392                                                                 // SETTING_TRACE(">>> RADIO LIST STRING VALUE = %s ", node->keyStr);
1393                                                                 // set position of radio button
1394                                                                 if (strcmp(node->keyStr, value) == 0)
1395                                                                 {
1396                                                                         elm_radio_value_set(node->rgd, radio_index);
1397                                                                 }
1398                                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1399                                                                 elm_genlist_item_update(item_to_update->item);
1400
1401                                                                 // go next
1402                                                                 li = eina_list_next(li);
1403                                                                 radio_index++;
1404                                                         }
1405
1406                                                 }
1407                                         } else {
1408                                                 SETTING_TRACE("item_to_update is NULL");
1409                                         }
1410                                 }
1411
1412                                 *is_end = true;
1413                         }
1414                 }
1415                 __node_finder(context, cur_node->children, id_str, value, is_end);      /* RECURSIVE */
1416         }
1417         return 0;
1418 }
1419
1420 static unsigned int _plugin_string_key_length(const char*key)
1421 {
1422         if (!key)
1423                 return 0;
1424
1425         return (int)strlen(key) + 1;
1426 }
1427
1428 static int _plugin_string_key_cmp(const char* key1, int key1_length,
1429                                                                         const char* key2, int key2_length)
1430 {
1431         return strcmp(key1, key2);
1432 }
1433
1434 static void _plugin_entry_free_cb(void* data)
1435 {
1436     Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data;
1437         if (node->childs)
1438         {
1439                 eina_list_free(node->childs);
1440                 node->childs = NULL;
1441         }
1442 }
1443
1444 //static PluginNode* g_context;
1445
1446 PluginNode* setting_plugin_create()
1447 {
1448         PluginNode *node = calloc(1, sizeof(PluginNode));
1449
1450         Draw_Data *pd = calloc(1, sizeof(Draw_Data));
1451         setting_retvm_if(!pd, -1, "Create Draw_Data obj failed");
1452         //eina_init();
1453
1454         node->pd = pd;
1455         node->ui_list = eina_hash_new(EINA_KEY_LENGTH(_plugin_string_key_length),
1456                                                                   EINA_KEY_CMP(_plugin_string_key_cmp),
1457                                                                   EINA_KEY_HASH(eina_hash_superfast),
1458                                                                   _plugin_entry_free_cb,
1459                                                                   5); // 2^5
1460
1461         return node;
1462 }
1463
1464 void setting_plugin_destroy(PluginNode* node)
1465 {
1466         SETTING_TRACE_BEGIN;
1467         if (node) {
1468                 SETTING_TRACE("node is NOT NULL")
1469                 if (node->pd) {
1470                         SETTING_TRACE("node->pd is NOT NULL")
1471                         if(node->pd->doc != NULL) {
1472                                 xmlSaveFormatFile(node->plugin_path, node->pd->doc, 1);
1473                                 xmlFreeDoc(node->pd->doc);
1474                                 node->pd->doc = NULL;
1475                                 SETTING_TRACE("__cfg_file_write successful");
1476                         }
1477
1478                         free(node->pd);
1479                         node->pd = NULL;
1480                 }
1481
1482                 if (node->ui_list) {
1483                         eina_hash_free(node->ui_list);
1484                         node->ui_list = NULL;
1485                 }
1486                 free(node);
1487                 node = NULL;
1488         }
1489 }
1490
1491
1492 static Eina_Bool _plugin_foreach_cb(const Eina_Hash *hash, const void*key, void* data, void* fdata)
1493 {
1494     Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data;
1495         SETTING_TRACE("%s --- %s ", (char*)key, node->keyStr);
1496         return EINA_TRUE;
1497 }
1498
1499
1500 void setting_plugin_debug(PluginNode* context)
1501 {
1502 //      SETTING_TRACE("HASH TABLE -------------------------------------");
1503         eina_hash_foreach(context->ui_list,_plugin_foreach_cb, NULL);
1504 //      SETTING_TRACE("HASH TABLE -------------------------------------");
1505
1506 }
1507
1508 void setting_plugin_update(PluginNode* context)
1509 {
1510     Eina_List *li = context->ui_list;
1511
1512     while (li) {
1513         Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) eina_list_data_get(li);
1514         if (node) {
1515             // SETTING_TRACE(" ---> keyStr : %s , swallow type : %d  ", node->keyStr, node->swallow_type);
1516                         Setting_GenGroupItem_Data* item_to_update = NULL;
1517                         item_to_update = node;
1518                         elm_object_item_data_set(item_to_update->item, item_to_update);
1519                         elm_genlist_item_update(item_to_update->item);
1520         }
1521         li = eina_list_next(li);
1522         }
1523 }
1524
1525
1526 /**
1527  * set modifiable
1528  */
1529 bool setting_plugin_load(PluginNode* context, const char *cfg_file)
1530 {
1531         SETTING_TRACE("cfg_file:%s", cfg_file)
1532         if (isEmptyStr(cfg_file) || 0 != access(cfg_file, R_OK|W_OK|F_OK ))
1533         {
1534                 SETTING_TRACE_ERROR(" error occured : access \n");
1535                 return FALSE;
1536         }
1537         context->pd->cfg_file = cfg_file;
1538         context->pd->win_get = (Evas_Object *) ug_get_window();
1539
1540         GError *error = NULL;
1541
1542         context->pd->doc = xmlParseFile(cfg_file);
1543         context->pd->root = xmlDocGetRootElement(context->pd->doc);
1544
1545         // TODO: error handler here
1546         __node_walker(context, context->pd->root);
1547
1548         // debug message
1549         setting_plugin_debug(context);
1550         return true;
1551 }
1552
1553