Merge "[Bug] Modify the logic when destroying ug-image-viewer in setting > wallpaper...
[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);
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                         __node_finder((PluginNode*)ad->plugin_node, root, key_name ,val_name);
251                 }   
252                 // update the node
253                 GError *error = NULL;
254
255                 /*
256                 if(doc != NULL)
257                 {
258                         xmlSaveFormatFile(ad->plugin_path, doc, 1);
259                         // TODO: make sure this is right
260                         xmlFreeDoc(doc);
261                         doc = NULL;
262                         SETTING_TRACE("__cfg_file_write successful");
263                 }
264                 */
265
266                 // update UI
267     }
268
269     return DBUS_HANDLER_RESULT_HANDLED;
270 }
271
272 static int __send_msg(char* key, char* value)
273 {
274         DBusMessage* message;
275         int sender_pid = getpid();
276
277         if (bus == NULL)
278                 return -1;
279
280         message = dbus_message_new_signal(DBUS_PATH, DBUS_SIGNAL_INTERFACE, DBUS_SIGNAL);
281
282         SETTING_TRACE("Sending message[%s:%s] via dbus", key ,value);
283         if (dbus_message_append_args(message,
284                                 DBUS_TYPE_UINT32, &sender_pid,
285                                 DBUS_TYPE_STRING, &key,
286                                 DBUS_TYPE_STRING, &value,
287                                 DBUS_TYPE_INVALID) == FALSE)
288         {
289                 SETTING_TRACE("Fail to load data error");
290                 return -1;
291         }
292
293         if (dbus_connection_send(bus, message, NULL) == FALSE)
294         {
295                 SETTING_TRACE("Fail to send message");
296                 return -1;
297         }
298
299         dbus_connection_flush(bus);
300         dbus_message_unref(message);
301
302         SETTING_TRACE("[CLIENT] send data signal done");
303
304     return 0;
305 }
306
307
308 static void __send_int_msg(xmlNode* xmlObj, int val)
309 {
310         const char *id = (char*)xmlGetProp(xmlObj, "id");
311         const char *title = (char*)xmlGetProp(xmlObj, "title");
312         char key[MAX_CONTENT_LEN] = {0,};
313         snprintf(key, sizeof(key), "%s|%s", id, title);
314
315         char value[MAX_CONTENT_LEN] = {0,};
316         snprintf(value, sizeof(value), "INT|%d", val);
317         __send_msg(key, value);
318 }
319
320
321 static void __send_string_msg(xmlNode* xmlObj, char *string)
322 {
323         const char *id = (char*)xmlGetProp(xmlObj, "id");
324         const char *title = (char*)xmlGetProp(xmlObj, "title");
325         char key[MAX_CONTENT_LEN] = {0,};
326         snprintf(key, sizeof(key), "%s|%s", id, title);
327
328         char value[MAX_CONTENT_LEN] = {0,};
329         snprintf(value, sizeof(value), "STRING|%s", string);
330         __send_msg(key, value);
331 }
332
333
334 int setting_dbus_handler_init(void* user_data)
335 {
336         SETTING_TRACE_BEGIN;
337     DBusError error;
338     char rule[MAX_LOCAL_BUFSIZE];
339
340     dbus_error_init(&error);
341     bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
342     if (!bus)
343     {
344         SETTING_TRACE("Fail to connect to the D-BUS daemon: %s", error.message);
345         dbus_error_free(&error);
346         return -1;
347     }
348
349     dbus_connection_setup_with_g_main(bus, NULL);
350     snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
351
352     dbus_bus_add_match(bus, rule, &error);
353     if (dbus_error_is_set(&error))
354     {
355         SETTING_TRACE("Fail to rule set; %s", error.message);
356         dbus_error_free(&error);
357         return -1;
358     }
359
360     if (dbus_connection_add_filter(bus, __signal_filter, user_data, NULL) == FALSE)
361     {
362         return -1;
363     }
364
365     SETTING_TRACE("app signal initialized");
366
367     return 0;
368 }
369
370
371 int setting_dbus_handler_fini(void)
372 {
373     DBusError error;
374     char rule[MAX_LOCAL_BUFSIZE];
375
376     dbus_error_init(&error);
377     dbus_connection_remove_filter(bus, __signal_filter, NULL);
378     snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
379     dbus_bus_remove_match(bus, rule, &error);
380
381     if (dbus_error_is_set(&error))
382     {
383         SETTING_TRACE("Fail to rule unset: %s", error.message);
384         dbus_error_free(&error);
385         return -1;
386     }
387
388     dbus_connection_close(bus);
389     SETTING_TRACE("app signal finalized");
390     return 0;
391 }
392
393 /////////////////////////////
394 /////////////////////////////
395 /////////////////////////////
396
397 Elm_Genlist_Item_Class itc_layout;
398
399 // write -> update
400 static int __cfg_file_write(Draw_Data *pd)
401 {
402         SETTING_TRACE_BEGIN;
403
404         GError *error = NULL;
405         if(pd->doc != NULL)
406         {
407                 xmlSaveFormatFile(pd->cfg_file, pd->doc, 1);
408                 // TODO: make sure this is right
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 (void*)(pd->ly_main);
663         return NULL;
664 };
665
666
667 static void __check_mouse_up_cb(void *data, Evas_Object *obj,
668                                              void *event_info)
669 {
670         /* error check */
671         SETTING_TRACE_BEGIN;
672         setting_retm_if(data == NULL, "Data parameter is NULL");
673
674         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
675         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
676         elm_genlist_item_selected_set(item, 0);
677         Setting_GenGroupItem_Data *list_item =
678             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
679
680         SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
681
682         int old_status = elm_check_state_get(list_item->eo_check);
683         list_item->chk_status = !old_status;
684         elm_check_state_set(list_item->eo_check, list_item->chk_status);
685
686         xmlNode *xmlObj = data;
687         xmlAttrPtr newattr;
688         newattr = xmlSetProp(xmlObj, "state", xmlXPathCastNumberToString(list_item->chk_status));
689
690         __send_int_msg(xmlObj, list_item->chk_status);
691         __cfg_file_write((Draw_Data *)list_item->belongs_to);
692 }
693
694
695 static void __chk_btn_cb(void *data, Evas_Object *obj,
696                                              void *event_info)
697 {
698         SETTING_TRACE_BEGIN;
699         /* error check */
700         retm_if(data == NULL, "Data parameter is NULL");
701         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
702
703         xmlNode* xmlObj = list_item->userdata;
704         ret_if(!xmlObj);
705         list_item->chk_status = elm_check_state_get(obj);       /*  for genlist update status */
706
707         xmlAttrPtr newattr;
708         if (list_item->chk_status == 1) {
709                 newattr = xmlSetProp(xmlObj, "value", "true");
710         } else if (list_item->chk_status == 0) {
711                 newattr = xmlSetProp(xmlObj, "value", "false");
712         } else {
713                 newattr = xmlSetProp(xmlObj, "value", "false");
714         }
715
716         const char *id = (char*)xmlGetProp(xmlObj, "id");
717         const char *title = (char*)xmlGetProp(xmlObj, "title");
718         SETTING_TRACE(" >>>> id:%s , title:%s", id, title);
719         __send_int_msg(xmlObj, list_item->chk_status);
720         __cfg_file_write((Draw_Data *)list_item->belongs_to);
721         return;
722 }
723
724
725 static void* checkbox_func(void *data, xmlNode *xmlObj)
726 {
727         SETTING_TRACE_BEGIN;
728         ret_if(!data || !xmlObj);
729
730         PluginNode* node = (PluginNode*)data;
731         Draw_Data *pd = node->pd;
732
733         // [DATA] title, value
734         const char *title = (char*)xmlGetProp(xmlObj, "title");
735
736         // true / false
737         char* value = (char*)xmlGetProp(xmlObj, "value");
738
739         int ival = -1;
740
741         if ( 0 == safeStrCmp(value, "true")) {
742                 ival = 1;
743         } else if ( 0 == safeStrCmp(value, "false"))  {
744                 ival = 0;
745         } else {
746                 ival = 0;       // default : false (0)
747         }
748
749         // title, value, xmlObj
750         Setting_GenGroupItem_Data *list_item =
751                 setting_create_Gendial_field_def(pd->scroller,
752                                           &(itc_1text_1icon),
753                                           __check_mouse_up_cb,
754                                           xmlObj,
755                                           SWALLOW_Type_1TOGGLE,
756                                           NULL, NULL,
757                                           ival,
758                                           title,
759                                           NULL,
760                                           __chk_btn_cb);
761         if(list_item) {
762                 list_item->userdata = xmlObj;
763                 list_item->belongs_to = (int) pd;
764                 SETTING_TRACE("pd:%p,list_item->belongs_to:%d", pd, list_item->belongs_to);
765         }
766
767         return list_item;
768 }
769
770
771 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
772 {
773         SETTING_TRACE_BEGIN;
774         retm_if(!data || !obj, "Data parameter is NULL");
775
776         setting_hide_input_pannel_cb(obj);
777         const char *entry_str = elm_entry_entry_get(obj);
778         char *entry_str_utf8 = NULL;
779         entry_str_utf8 = elm_entry_markup_to_utf8(entry_str);
780
781         Setting_GenGroupItem_Data *list_item = data;
782
783         xmlNode* xmlObj = list_item->userdata;
784         ret_if(!xmlObj);
785         xmlAttrPtr newattr;
786         const char *title = (char*)xmlSetProp(xmlObj, "value",entry_str_utf8);
787
788         __send_string_msg(xmlObj, entry_str_utf8);
789         __cfg_file_write((Draw_Data *)list_item->belongs_to);
790
791         FREE(entry_str_utf8);
792 }
793
794
795 static void __editbox_list_cb(void *data, Evas_Object *obj,
796                                             void *event_info)
797 {
798         SETTING_TRACE_BEGIN;
799         /* error check */
800
801         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
802         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
803         elm_genlist_item_selected_set(item, 0);
804         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
805
806         SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
807         if (!elm_object_focus_get(list_item->eo_check)) {
808                 elm_object_focus_set(list_item->eo_check, EINA_TRUE);
809         }
810
811         Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(list_item->eo_check);
812         setting_retm_if(imf_context == NULL, "imf_context is NULL");
813         ecore_imf_context_input_panel_show(imf_context);
814 }
815
816
817 static void __editbox_changed_cb(void *data, Evas_Object *obj,
818                                        void *event_info)
819 {
820         SETTING_TRACE_BEGIN;
821         retm_if(!data || !obj, "Data parameter is NULL");
822         retm_if(!elm_object_focus_get(obj), "Entry is not focused");
823
824         Setting_GenGroupItem_Data *list_item =
825             (Setting_GenGroupItem_Data *) data;
826
827         const char *entry_str = elm_entry_entry_get(obj);
828         int entry_len = safeStrLen(entry_str);
829         SETTING_TRACE("entry_str:[%s], lenght:%d", entry_str, entry_len);
830
831         G_FREE(list_item->sub_desc);//release first
832         list_item->sub_desc = (char *)g_strdup(entry_str);
833 }
834
835
836 static void* editbox_func(void *data, xmlNode *xmlObj)
837 {
838         SETTING_TRACE_BEGIN;
839         ret_if(!data || !xmlObj);
840
841         PluginNode* node = (PluginNode*)data;
842         Draw_Data *pd = node->pd;
843
844         const char *title = (char*)xmlGetProp(xmlObj, "title");
845         const char *key_str= (char*)xmlGetProp(xmlObj, "value");
846
847         // TODO: minlength
848         // TODO: maxlength
849         Setting_GenGroupItem_Data *list_item =
850             setting_create_Gendial_field_def(pd->scroller, &(itc_1icon),
851                                              __editbox_list_cb,
852                                              pd, SWALLOW_Type_LAYOUT_ENTRY,
853                                              NULL, NULL, 0, title, key_str,
854                                              __editbox_changed_cb);
855         if (list_item) {
856                 list_item->userdata = xmlObj;
857                 list_item->stop_change_cb = __entry_unfocus_cb;
858                 list_item->belongs_to = (int)pd;
859         }
860
861         return list_item;
862 };
863
864
865 static void __expanditem_func_sel_cb(void *data, Evas_Object *obj, void *event_info)
866 {
867         SETTING_TRACE_BEGIN;
868         /* error check */
869         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
870         Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
871         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
872         elm_genlist_item_selected_set(subitem, 0);
873         Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
874         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
875         ret_if(NULL == data_subItem || NULL == data_parentItem);
876
877         elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
878
879         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
880         elm_object_item_data_set(data_parentItem->item, data_parentItem);
881         elm_genlist_item_update(data_parentItem->item);
882
883         xmlNode* xmlObj = data_parentItem->userdata;
884         ret_if(!xmlObj);
885
886         xmlAttrPtr newattr;
887         newattr = xmlSetProp(xmlObj, "string", 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         xmlNode *xmlObj = data_parentItem->userdata;
907         char *value = (char*)xmlGetProp(xmlObj, "string");
908         int i=0;
909         Evas_Object *rgd = NULL;
910
911         if (xmlObj->children && !data_parentItem->rgd) {//to protect from entering repeatly
912                 xmlNode* cur = xmlObj->children;
913
914                 rgd = elm_radio_add(scroller);
915                 elm_radio_value_set(rgd, -1);
916
917                 int i;
918                 char *type;
919                 char *subitem_title = NULL;
920                 int subitem_index = 0;
921                 int sel_idx = -1;
922
923                 while (cur != NULL) {
924                         if (!xmlStrcmp(cur->name, (const xmlChar*)"expanditem")) {
925                                 type = (char*)xmlGetProp(cur, "type");
926                                 if (0 == safeStrCmp(type, "radio")) {
927                                         subitem_title = (char*)xmlGetProp(cur, "title");
928                                         setting_create_Gendial_exp_sub_field(scroller,
929                                                                                  &(itc_1icon_1text_sub),
930                                                                                  __expanditem_func_sel_cb, NULL, parentItem,
931                                                                                  SWALLOW_Type_1RADIO, rgd,
932                                                                                  subitem_index,
933                                                                                  subitem_title, NULL);
934                                         if (0 == safeStrCmp(value, subitem_title)) {
935                                                 sel_idx = subitem_index;
936                                         }
937                                         subitem_index++;
938                                 } else {
939                                         SETTING_TRACE("invalid type[:%s]", type);
940                                 }
941
942                                 i++;
943                         }
944                         cur = cur->next;
945                 }
946
947                 // value set
948                 elm_radio_value_set(rgd, sel_idx);
949                 data_parentItem->rgd = rgd;//protecting condition
950         }
951 }
952
953
954 static void __expanditem_func_smart_cb(void *data, Evas_Object *obj, void *event_info)
955 {
956         ret_if(data == NULL || event_info == NULL);
957         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
958         Setting_GenGroupItem_Data *data_item = elm_object_item_data_get(item);
959         char *cb_type = data;
960
961         if (0 == safeStrCmp(cb_type, "contracted")) {
962                 data_item->rgd = NULL;
963                 elm_genlist_item_subitems_clear(item);
964         }
965 }
966
967
968 static void* settings_func(void *data, xmlNode *xmlObj)
969 {
970         return NULL;
971 }
972
973 // <setting>
974 static void* setting_func(void *data, xmlNode *xmlObj)
975 {
976 #if 0/*{{{*/
977         // DO NOTHING
978         //----------------------------------------------------------------
979         // [DATA] title, btn[0], btn[1]
980         Draw_Data *pd = data;
981         const char *title = (char*)xmlGetProp(xmlObj, "title");
982         char *btn[2] = {0, };
983
984         // find child nodes named 'elements'
985 #if 0
986         if (xmlObj->children) {
987                 xmlNode* cur = xmlObj->children;
988                 int i =0;
989                 while (cur != NULL)
990                 {
991                         if (!xmlStrcmp(cur->name, (const xmlChar*)"button")) {
992                                 btn[i] = xmlGetProp(cur, "title");
993                                 SETTING_TRACE("------>>> node type : Element, name=%s id=%s / btn[%d] = %s ", cur->name,xmlGetProp(cur, "id"), i, btn[i]);
994                                 i++;
995                         }
996                         cur = cur->next;
997                 }
998         }
999 #endif
1000         //----------------------------------------------------------------
1001         // [UI] with DATA
1002         pd->ly_main = setting_create_layout_navi_bar_genlist(pd->win_get,
1003                                                    pd->win_get,
1004                                                    _(title),
1005                                                    _("NO"), _("YES"),
1006                                                    ___click_softkey_back_cb,
1007                                                    ___click_softkey_back_cb, pd, &pd->scroller,
1008                                                    &(pd->navi_bar));
1009 #endif/*}}}*/
1010
1011         return NULL;
1012 }
1013
1014
1015 static void* expanditem_func(void *data, xmlNode *xmlObj)
1016 {
1017         // DO NOTHING - expandlist draws this area
1018         return NULL;
1019 }
1020
1021 static void* expandlist_func(void *data, xmlNode *xmlObj)
1022 {
1023         SETTING_TRACE_BEGIN;
1024         ret_if(!data || !xmlObj);
1025
1026         PluginNode* node = (PluginNode*)data;
1027         Draw_Data *pd = node->pd;
1028
1029         const char *key_str = (char*)xmlGetProp(xmlObj, "title");
1030         const char *value = (char*)xmlGetProp(xmlObj, "value"); // string -> value
1031
1032         setting_enable_expandable_genlist(pd->scroller, data, __expanditem_func_exp_cb, __expanditem_func_smart_cb);
1033         Setting_GenGroupItem_Data *list_item =
1034             setting_create_Gendial_exp_parent_field(pd->scroller,
1035                                                     &(itc_2text_3_parent),
1036                                                     NULL, NULL,
1037                                                     SWALLOW_Type_INVALID,
1038                                                     key_str,
1039                                                     value);
1040         if (list_item) {
1041                 list_item->userdata = xmlObj;
1042                 list_item->belongs_to = (int)pd;
1043         }
1044
1045         return list_item;
1046 }
1047
1048
1049 /////////////
1050 static int __node_walker(PluginNode* context, xmlNode* cur)
1051 {
1052         //SETTING_TRACE_BEGIN;
1053         Draw_Data *pd = context->pd;
1054
1055         retv_if(!pd, -1);
1056         xmlNode *cur_node = NULL;
1057         for (cur_node = cur; cur_node;cur_node = cur_node->next) {
1058                 if (cur_node->type == XML_ELEMENT_NODE) {
1059                         SETTING_TRACE("node type : Element, name=%s id=%s", cur_node->name,xmlGetProp(cur_node, "id"));
1060
1061                         drawer_fp  fp = __drawer_find(cur_node->name);
1062                         if (fp)
1063                         {
1064                                 // type check 
1065                                 void* vret = fp(context, cur_node); // draw it
1066
1067                                 if (vret) 
1068                                 {
1069                                         Setting_GenGroupItem_Data* genlist_node = (Setting_GenGroupItem_Data* )vret;
1070                                         //SETTING_TRACE("add node to Eina List name : %s, id : ", cur_node->name, xmlGetProp(cur_node, "id"));
1071                                         // add it to the hash table create before.
1072                                         // id, object
1073                                         // add list
1074                                         char* key_name = xmlGetProp(cur_node, "id");
1075                                         eina_hash_add(context->ui_list, strdup(key_name),(void*)genlist_node); 
1076                                         //context->ui_list= eina_list_append(context->ui_list, genlist_node);
1077                                 }
1078                         }
1079                 }
1080                 __node_walker(context, cur_node->children);     /* RECURSIVE */
1081         }
1082         return 0;
1083 }
1084
1085 /**
1086  * @param id_str [in] "id"
1087  * @param value [in] value to be udpated
1088  */
1089 // refer to __expanditem_func_sel_cb
1090 static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value)
1091 {
1092         //SETTING_TRACE_BEGIN;
1093         xmlNode *cur_node = NULL;
1094         for (cur_node = cur; cur_node;cur_node = cur_node->next) {
1095                 if (cur_node->type == XML_ELEMENT_NODE) {
1096
1097                         //SETTING_TRACE("node type : Element, name=%s id=%s", cur_node->name,xmlGetProp(cur_node, "id"));
1098                         char* id_name = (char*)xmlGetProp(cur_node, "id");
1099                         if ( id_name && 0 == strcmp(id_str, id_name))
1100                         {
1101                                 SETTING_TRACE("FOUND >>>> %s", id_name);
1102                                 // cur_node     - update xml code
1103                                 xmlAttrPtr newattr = xmlSetProp(cur_node, "value", value);
1104
1105                                 //-----------------------------------------------------------
1106                                 // UI UPDATE
1107                                 // case : slider
1108                                 if ( 0 == strcmp (cur_node->name, "integer"))
1109                                 {
1110                                         SETTING_TRACE(">>>>> UPDATE SLIDER CONTROL %x --- %s ",context->ui_list, id_name);
1111                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name); 
1112                                         if      (item_to_update)
1113                                         {
1114                                                 item_to_update->chk_status = atoi(value);
1115                                                 SETTING_TRACE(">>>   o-------------0 SLIDER VALUE = %d ", item_to_update->chk_status);
1116
1117                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1118                                                 elm_genlist_item_update(item_to_update->item);
1119                                         } else {
1120                                                 SETTING_TRACE("item_to_update is NULL");
1121                                         }
1122                                 }                               
1123                                 // case : toggle
1124                                 if ( 0 == strcmp (cur_node->name, "bool"))
1125                                 {
1126                                         SETTING_TRACE(">>>>> UPDATE TOGGLE CONTROL %x --- %s ",context->ui_list, id_name);
1127                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name); 
1128                                         if      (item_to_update)
1129                                         {
1130                                                 item_to_update->chk_status = atoi(value);
1131                                                 SETTING_TRACE(">>>   o-------------0 TOGGLE VALUE = %d ", item_to_update->chk_status);
1132
1133                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1134                                                 elm_genlist_item_update(item_to_update->item);
1135                                         } else {
1136                                                 SETTING_TRACE("item_to_update is NULL");
1137                                         }
1138                                 }
1139                                 // case : edit control          
1140                                 if ( 0 == strcmp (cur_node->name, "string"))
1141                                 {
1142                                         SETTING_TRACE(">>>>> UPDATE EDIT CONTROL CONTROL %x --- %s ",context->ui_list, id_name);
1143                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name); 
1144                                         if      (item_to_update)
1145                                         {
1146                                                 char* old_string = item_to_update->sub_desc;
1147                                                 item_to_update->sub_desc = strdup(value);
1148                                                 SETTING_TRACE(">>>   o-------------0 STRING VALUE = %s ", value);
1149                                                 
1150                                                 // free old string
1151
1152                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1153                                                 elm_genlist_item_update(item_to_update->item);
1154                                         } else {
1155                                                 SETTING_TRACE("item_to_update is NULL");
1156                                         }
1157                                 }
1158                                 // case : expand list
1159                                 // parent
1160                                 //    child1
1161                                 //    child2
1162                                 //    child3
1163                                 //    child4
1164                                 //-----------------------------------------------------------
1165                                 if ( 0 == strcmp (cur_node->name, "expandlist"))
1166                                 {
1167                                         SETTING_TRACE(">>>>> UPDATE EXPAND LIST CONTROL %x --- %s ",context->ui_list, id_name);
1168                                         Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name); 
1169                                         if      (item_to_update)
1170                                         {
1171                                                 char* old_string = item_to_update->sub_desc;
1172                                                 item_to_update->sub_desc = strdup(value);
1173                                                 SETTING_TRACE(">>>   o-------------0 EXPAND LIST VALUE = %s ", value);
1174
1175                                                 // free old string
1176                                                 elm_object_item_data_set(item_to_update->item, item_to_update);
1177                                                 elm_genlist_item_update(item_to_update->item);
1178                                         } else {
1179                                                 SETTING_TRACE("item_to_update is NULL");
1180                                         }
1181                                 }
1182                         }
1183                 }
1184                 __node_finder(context, cur_node->children, id_str, value);      /* RECURSIVE */
1185         }
1186         return 0;
1187 }
1188
1189 static unsigned int _plugin_string_key_length(const char*key)
1190 {
1191         if (!key)
1192                 return 0;
1193
1194         return (int)strlen(key) + 1;
1195 }
1196
1197 static int _plugin_string_key_cmp(const char* key1, int key1_length, 
1198                                                                         const char* key2, int key2_length)
1199 {
1200         return strcmp(key1, key2);
1201 }
1202
1203 static void _plugin_entry_free_cb(void* data)
1204 {
1205 //      free(data);
1206 //      data = NULL;
1207 }
1208
1209 //static PluginNode* g_context;
1210
1211 PluginNode* setting_plugin_create()
1212 {
1213         PluginNode *node = calloc(1, sizeof(PluginNode));
1214
1215         Draw_Data *pd = calloc(1, sizeof(Draw_Data));
1216         setting_retvm_if(!pd, -1, "Create Draw_Data obj failed");
1217         //eina_init();
1218
1219         node->pd = pd;
1220         node->ui_list = eina_hash_new(EINA_KEY_LENGTH(_plugin_string_key_length),
1221                                                                   EINA_KEY_CMP(_plugin_string_key_cmp),
1222                                                                   EINA_KEY_HASH(eina_hash_superfast),
1223                                                                   _plugin_entry_free_cb,
1224                                                                   5); // 2^5
1225
1226         return node;
1227 }
1228
1229 void setting_plugin_destroy(PluginNode* node)
1230 {
1231         SETTING_TRACE_BEGIN;
1232         if (node) {
1233                 SETTING_TRACE("node is NOT NULL")
1234                 if (node->pd) {
1235                         SETTING_TRACE("node->pd is NOT NULL")
1236                         if(node->pd->doc != NULL) {
1237                                 xmlSaveFormatFile(node->plugin_path, node->pd->doc, 1);
1238                                 // TODO: make sure this is right
1239                                 xmlFreeDoc(node->pd->doc);
1240                                 node->pd->doc = NULL;
1241                                 SETTING_TRACE("__cfg_file_write successful");
1242                         }
1243
1244                         SETTING_TRACE("before freeing node->pd");
1245                         free(node->pd);
1246                         node->pd = NULL;
1247                         SETTING_TRACE("after freeing node->pd");
1248                 }
1249
1250                 SETTING_TRACE("before freeing ui_list");
1251                 if (node->ui_list) {
1252                         eina_hash_free(node->ui_list);
1253                         node->ui_list = NULL;
1254                 }
1255                 SETTING_TRACE("after freeing ui_list");
1256
1257                 SETTING_TRACE("before freeing node");
1258                 free(node);
1259                 node = NULL;
1260                 SETTING_TRACE("after freeing node");
1261         }
1262 }
1263
1264
1265 static Eina_Bool _plugin_foreach_cb(const Eina_Hash *hash, const void*key, void* data, void* fdata)
1266 {
1267     Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data;
1268         SETTING_TRACE("%s --- %s ", (char*)key, node->keyStr);
1269
1270         return EINA_TRUE;
1271 }
1272
1273
1274 void setting_plugin_debug(PluginNode* context)
1275 {
1276         SETTING_TRACE("HASH TABLE -------------------------------------");
1277         eina_hash_foreach(context->ui_list,_plugin_foreach_cb, NULL);
1278         SETTING_TRACE("HASH TABLE -------------------------------------");
1279
1280 }
1281
1282 void setting_plugin_update(PluginNode* context)
1283 {
1284     Eina_List *li = context->ui_list;
1285
1286     while (li) {
1287         Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) eina_list_data_get(li);
1288         if (node) {
1289             // SETTING_TRACE(" ---> keyStr : %s , swallow type : %d  ", node->keyStr, node->swallow_type);
1290                         Setting_GenGroupItem_Data* item_to_update = NULL;
1291                         item_to_update = node;
1292                         elm_object_item_data_set(item_to_update->item, item_to_update);
1293                         elm_genlist_item_update(item_to_update->item);
1294         }
1295         li = eina_list_next(li);
1296         }
1297 }
1298
1299
1300 bool setting_plugin_load(PluginNode* context, const char *cfg_file)
1301 {
1302         SETTING_TRACE("cfg_file:%s", cfg_file)
1303         if (isEmptyStr(cfg_file) || 0 != access(cfg_file, R_OK|W_OK|F_OK ))
1304         {
1305                 SETTING_TRACE_ERROR(" error occured : access \n");
1306                 return FALSE;
1307         }
1308         context->pd->cfg_file = cfg_file;
1309         context->pd->win_get = (Evas_Object *) ug_get_window();
1310
1311         GError *error = NULL;
1312
1313         context->pd->doc = xmlParseFile(cfg_file);
1314         context->pd->root = xmlDocGetRootElement(context->pd->doc);
1315
1316         // TODO: error handler here
1317         __node_walker(context, context->pd->root);
1318
1319         // debug message
1320         setting_plugin_debug(context);
1321         return true;
1322 }
1323
1324