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