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