add default code for flight mode
[apps/core/preloaded/settings.git] / src / setting-plugin.c
index 5af68ad..73c2cad 100755 (executable)
@@ -1,24 +1,19 @@
 /*
  * setting
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
- *
- * Contact: MyoungJune Park <mj2004.park@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * Licensed under the Flora License, Version 1.0 (the License);
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ *     http://floralicense.org/license/
  *
  * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *
  */
-
 #include <unistd.h>
 #include <eina_list.h>
 #include <glib.h>
 #include <setting-plugin.h>
 
 
+extern setting_main_appdata *g_main_ad;
 
 static Setting_GenGroupItem_Data *g_list_item; /*TEST*/
 
-
-
 /*
  * UI draw handler table : _g_draw_list
  *  - contains Object_Drawer typed object.
  */
 Eina_List *_g_drawer_list = NULL;
 
+#if 0
 /**
  * @return Evas_Object * obj
  */
 static void* navigationbar_func(void *data, xmlNode *xmlObj);
-
+#endif
 
 /*
  * @return void
@@ -116,6 +111,7 @@ static void __drawer_add(const char *type, drawer_fp draw)
 
                _g_drawer_list = eina_list_append(_g_drawer_list, node);
        }
+       // FREE(node);
 }
 
 
@@ -124,7 +120,7 @@ static drawer_fp __drawer_find(char* type)
        SETTING_TRACE_BEGIN;
        SETTING_TRACE("node type:%s", type);
        Eina_List *check_list = _g_drawer_list;
-       Object_Drawer *list_item = NULL;
+       Object_Drawer *list_item = NULL;
 
        while (check_list) {
                list_item = (Object_Drawer *) eina_list_data_get(check_list);
@@ -190,8 +186,13 @@ void setting_drawer_list_fini()
 #define MAX_LOCAL_BUFSIZE 128
 #define DBUS_PATH "/setting/dbus_handler"
 #define DBUS_SIGNAL_INTERFACE "org.tizen.setting.signal"
-#define DBUS_SIGNAL "test"
 
+#define APPID_LENGTH 10
+#define APPID_POS_FROM_PATH 10
+
+static char* s_pkg_name;
+
+#if 0
 static char* substring(const char* str, size_t begin, size_t len)
 {
   if (str == 0 || strlen(str) == 0 || strlen(str) < begin || strlen(str) < (begin+len))
@@ -199,6 +200,21 @@ static char* substring(const char* str, size_t begin, size_t len)
 
   return strndup(str + begin, len);
 }
+#endif
+
+/**
+ * package ID
+ *
+ * ncbyusjryr.AppSetting --> package ID is ncbyusjryr
+ * "Update_" "ncbyusjryr"
+ */
+static char* get_app_string(char* path)
+{
+       SETTING_TRACE_BEGIN;
+       char* temp = substring(path, APPID_POS_FROM_PATH, APPID_LENGTH/*string size*/);
+       SETTING_TRACE("package ID : >>> %s ",temp );
+       return temp;
+}
 
 //------------------------------------------------------
 // for client - bus
@@ -215,8 +231,32 @@ static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* mess
     dbus_error_init(&error);
 
        setting_main_appdata *ad = user_data;
+       char* plugin_path = ad->plugin_path;
+       char* pkg_name = get_app_string(plugin_path);
+
+       if (pkg_name == NULL)
+       {
+               SETTING_TRACE("pkg_name is NULL - it's abnormal operation");
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       }
 
-    if (dbus_message_is_signal(message, DBUS_SIGNAL_INTERFACE, DBUS_SIGNAL))
+       char str_buf[MAX_COMMON_BUFFER_LEN];
+       snprintf(str_buf, MAX_COMMON_BUFFER_LEN, "Update_%s", pkg_name);
+       s_pkg_name = strdup(str_buf);
+
+       if (pkg_name)
+       {
+               free(pkg_name);
+               pkg_name = NULL;
+       }
+
+       if (s_pkg_name == NULL)
+       {
+               SETTING_TRACE("s_pkg_name is NULL - it's abnormal operation");
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+       }
+       SETTING_TRACE("s_pkg_name : %s ", s_pkg_name);
+    if (dbus_message_is_signal(message, DBUS_SIGNAL_INTERFACE, s_pkg_name))
     {
         if (dbus_message_get_args(message, &error,
                 DBUS_TYPE_UINT32, &sender_pid,
@@ -237,7 +277,11 @@ static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* mess
                // received key : checkbox1|N/A , value : INT|1
                //-------------------------------------------------------------
                //char* key = "checkbox1|N/A";
-               char* ptr = strchr(key, '|');
+               char* ptr = NULL;
+
+               if (key) {
+                       ptr = strchr(key, '|');
+               }
 
                xmlDocPtr doc = NULL;
                if (ptr && key)
@@ -247,14 +291,25 @@ static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* mess
                        char* val_name = strchr(value, '|');
                        val_name++;
 
-                       // ad->plugin_path
                        // access xml file
-                       doc = xmlParseFile(ad->plugin_path);
+                       doc = xmlParseFile(plugin_path);
+                       if (doc == NULL)
+                       {
+                               SETTING_TRACE("unable to parse file : %s", plugin_path);
+                               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;     /* xml parsing error */
+                       }
                        // generate xml tree
                        xmlNode *root = xmlDocGetRootElement(doc);
                        // find a node
                        bool is_end = false;
+
+                       // TODO : message queing
+                       // get key/value from d-bus and parse xml and search xml data with key
+                       static int count = 0;
+                       SETTING_TRACE(" BEGIN ---------------------------- dbus--> before __node_finder : %d", count);
                        __node_finder((PluginNode*)ad->plugin_node, root, key_name ,val_name, &is_end);
+                       SETTING_TRACE(" END  ----------------------------- dbus--> after __node_finder : %d", count);
+                       count += 1;
                }
                // update the node
                GError *error = NULL;
@@ -279,12 +334,20 @@ static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* mess
 static int __send_msg(char* key, char* value)
 {
        DBusMessage* message;
+
        int sender_pid = getpid();
 
        if (bus == NULL)
                return -1;
 
-       message = dbus_message_new_signal(DBUS_PATH, DBUS_SIGNAL_INTERFACE, DBUS_SIGNAL);
+       // ex) in gdb --> $15 = 0x43b6eb78 "Update_(null)" -> error codintion
+       if (s_pkg_name == NULL)
+       {
+               SETTING_TRACE("s_pkg_name is NULL - it's abnormal operation");
+               return -1;
+       }
+
+       message = dbus_message_new_signal(DBUS_PATH, DBUS_SIGNAL_INTERFACE, s_pkg_name);
 
        SETTING_TRACE("Sending message[%s:%s] via dbus", key ,value);
        if (dbus_message_append_args(message,
@@ -314,6 +377,7 @@ static int __send_msg(char* key, char* value)
 
 static void __send_int_msg(xmlNode* xmlObj, int val)
 {
+       SETTING_TRACE_BEGIN;
        const char *id = (char*)xmlGetProp(xmlObj, "id");
        const char *title = (char*)xmlGetProp(xmlObj, "title");
        char key[MAX_CONTENT_LEN] = {0,};
@@ -322,6 +386,7 @@ static void __send_int_msg(xmlNode* xmlObj, int val)
        char value[MAX_CONTENT_LEN] = {0,};
        snprintf(value, sizeof(value), "INT|%d", val);
        __send_msg(key, value);
+       SETTING_TRACE_END;
 }
 
 
@@ -345,6 +410,7 @@ int setting_dbus_handler_init(void* user_data)
        {
                SETTING_TRACE("already get a bus, need release first.");
                setting_dbus_handler_fini();
+//             return -1;
        }
        DBusError error;
        memset(&error, 0, sizeof(DBusError));
@@ -387,6 +453,7 @@ int setting_dbus_handler_init(void* user_data)
 
 int setting_dbus_handler_fini(void)
 {
+       SETTING_TRACE_BEGIN;
        //do safty checking first.
        setting_retvm_if(!bus, 0, "!bus");
        DBusError error;
@@ -394,7 +461,13 @@ int setting_dbus_handler_fini(void)
        char rule[MAX_LOCAL_BUFSIZE + 1] = {0, };
 
        dbus_error_init(&error);
+
+       // why??
+       bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+
        //dbus_connection_remove_filter(bus, __signal_filter, NULL);
+
+
        snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
        dbus_bus_remove_match(bus, rule, &error);
 
@@ -431,6 +504,7 @@ static int __cfg_file_write(Draw_Data *pd)
                SETTING_TRACE("__cfg_file_write successful");
        }
 
+       SETTING_TRACE_END;
        return TRUE;
 }
 
@@ -449,11 +523,17 @@ static void ___click_softkey_back_cb(void *data, Evas_Object *obj,
        }
 
        setting_plugin_destroy(node);
-
+       if (g_main_ad->navibar_main)
+       {
+               elm_naviframe_item_pop(g_main_ad->navibar_main);
+       }
        pd->scroller = NULL;
        pd->navi_bar = NULL;
        pd->cfg_file = NULL;
 
+
+
+
        pd->root = NULL;
 }
 
@@ -461,7 +541,7 @@ static void ___click_softkey_back_cb(void *data, Evas_Object *obj,
 static void* group_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
 
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
@@ -502,27 +582,27 @@ static void* group_func(void *data, xmlNode *xmlObj)
 static void* __link_list_cb(void *data, Evas_Object *obj, void *event_info)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(data == NULL);
-       retm_if(event_info == NULL, "Invalid argument: event info is NULL");
+       retv_if(data == NULL, NULL);
+       retvm_if(event_info == NULL, NULL, "Invalid argument: event info is NULL");
        Elm_Object_Item *item = (Elm_Object_Item *) event_info;
        elm_genlist_item_selected_set(item, 0);
        Setting_GenGroupItem_Data *list_item =
            (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
 
        xmlNode* xmlObj = data;
-       ret_if(!xmlObj);
+       retv_if(!xmlObj, NULL);
        const char *link_file = (char*)xmlGetProp(xmlObj, "value");
 
        if(!link_file)
        {
                SETTING_TRACE_ERROR("Invalidate liked file");
-               return;
+               return NULL;
        }
        char file[1024] = {0,};
        snprintf(file, sizeof(file), "%s/%s", PLUGIN_CFG_DIR, link_file);
        SETTING_TRACE("file:%s", file);
 
-       PluginNode* plugin_node = setting_plugin_create();
+       PluginNode* plugin_node = setting_plugin_create(file);
        setting_plugin_load(plugin_node, (const char *)file);
 
        //setting_plugin_load(NULL, file);
@@ -533,15 +613,15 @@ static void* __link_list_cb(void *data, Evas_Object *obj, void *event_info)
 static void* __launch_list_cb(void *data, Evas_Object *obj, void *event_info)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(data == NULL);
-       retm_if(event_info == NULL, "Invalid argument: event info is NULL");
+       retv_if(data == NULL, NULL);
+       retvm_if(event_info == NULL, NULL, "Invalid argument: event info is NULL");
        Elm_Object_Item *item = (Elm_Object_Item *) event_info;
        elm_genlist_item_selected_set(item, 0);
        Setting_GenGroupItem_Data *list_item =
            (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
 
        xmlNode* xmlObj = data;
-       ret_if(!xmlObj);
+       retv_if(!xmlObj, NULL);
        const char *key_str = (char*)xmlGetProp(xmlObj, "id");
        const char *title_str = (char*)xmlGetProp(xmlObj, "title");
        const char *appid_str = (char*)xmlGetProp(xmlObj, "appid");
@@ -561,7 +641,7 @@ static void* __launch_list_cb(void *data, Evas_Object *obj, void *event_info)
 static void* label_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
 
@@ -579,7 +659,7 @@ static void* label_func(void *data, xmlNode *xmlObj)
 static void* link_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
 
@@ -596,7 +676,7 @@ static void* link_func(void *data, xmlNode *xmlObj)
 static void* launch_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
 
@@ -643,7 +723,7 @@ static void __slider_stop_cb(void *data, Evas_Object *obj,
 static void* slider_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
 
@@ -682,6 +762,7 @@ static void* slider_func(void *data, xmlNode *xmlObj)
        return (void*)list_item;
 };
 
+#if 0
 /*
   elm_object_item_data_set(item_to_update->item, item_to_update);
   elm_genlist_item_update(item_to_update->item);
@@ -730,7 +811,7 @@ static void* navigationbar_func(void *data, xmlNode *xmlObj)
 #endif
        return NULL;
 };
-
+#endif
 
 static void __check_mouse_up_cb(void *data, Evas_Object *obj,
                                             void *event_info)
@@ -793,7 +874,7 @@ static void __chk_btn_cb(void *data, Evas_Object *obj,
 static void* checkbox_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
 
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
@@ -849,7 +930,11 @@ static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
        Setting_GenGroupItem_Data *list_item = data;
 
        xmlNode* xmlObj = list_item->userdata;
-       ret_if(!xmlObj);
+       if(!xmlObj) {
+               FREE(entry_str_utf8);
+               return;
+       }
+
        xmlAttrPtr newattr;
        const char *title = (char*)xmlSetProp(xmlObj, "value",entry_str_utf8);
 
@@ -857,6 +942,7 @@ static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
        __cfg_file_write((Draw_Data *)list_item->belongs_to);
 
        FREE(entry_str_utf8);
+       SETTING_TRACE_END;
 }
 
 
@@ -901,10 +987,16 @@ static void __editbox_changed_cb(void *data, Evas_Object *obj,
 }
 
 
+/**
+ *  editbox
+ *
+ * @see also __editbox_changed_cb
+ * @see also __entry_unfocus_cb
+ */
 static void* editbox_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
 
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
@@ -912,14 +1004,48 @@ static void* editbox_func(void *data, xmlNode *xmlObj)
        const char *title = (char*)xmlGetProp(xmlObj, "title");
        const char *key_str= (char*)xmlGetProp(xmlObj, "value");
 
-       // TODO: minlength
-       // TODO: maxlength
-       Setting_GenGroupItem_Data *list_item =
-           setting_create_Gendial_field_def(pd->scroller, &(itc_1icon),
-                                            __editbox_list_cb,
-                                            pd, SWALLOW_Type_LAYOUT_ENTRY,
-                                            NULL, NULL, 0, title, key_str,
-                                            __editbox_changed_cb);
+       const char *minlength= (char*)xmlGetProp(xmlObj, "minlength");
+       const char *maxlength= (char*)xmlGetProp(xmlObj, "maxlength");
+
+       int max_len = -1;
+       if (maxlength)
+       {
+               max_len = atoi(maxlength);
+               SETTING_TRACE(" >> MAXLENGTH FILTER IS AVAILABLE !!!! maxlength = %d", max_len);
+       }
+
+       Setting_GenGroupItem_Data *list_item = NULL;
+
+#if 1
+       if (max_len == -1)
+       {
+               // without maxlength filter
+               list_item = setting_create_Gendial_field_def(pd->scroller, &(itc_1icon),
+                                                                __editbox_list_cb,
+                                                        pd, SWALLOW_Type_LAYOUT_ENTRY,
+                                                        NULL, NULL, 0, title, key_str,
+                                                        __editbox_changed_cb);
+
+       } else {
+               // add max length filter
+               list_item = setting_create_Gendial_field_entry_fo(
+                                                                       pd->scroller,
+                                                                       &(itc_1icon),
+                                                                       __editbox_list_cb,
+                                                                       pd,
+                                                                       SWALLOW_Type_LAYOUT_ENTRY,
+                                                                       NULL, NULL, 0, title, key_str,
+                                                                       __editbox_changed_cb,
+                                                                       __entry_unfocus_cb,
+                                                                       ELM_INPUT_PANEL_LAYOUT_NORMAL,
+                                                                       false,
+                                                                       false,
+                                                                       max_len,
+                                                                       0,
+                                                                       NULL, NULL);
+
+       }
+#endif
        if (list_item) {
                list_item->userdata = xmlObj;
                list_item->stop_change_cb = __entry_unfocus_cb;
@@ -974,10 +1100,8 @@ static void __expanditem_func_exp_cb(void *data, Evas_Object *obj, void *event_i
 
 
        xmlNode *xmlObj = data_parentItem->userdata;
-       //char *value = (char*)xmlGetProp(xmlObj, "string");
        char *value = (char*)xmlGetProp(xmlObj, "value");
        SETTING_TRACE(">>> value = %s", value);
-       int i=0;
        Evas_Object *rgd = NULL;
 
        if (xmlObj->children && !data_parentItem->rgd) {//to protect from entering repeatly
@@ -986,12 +1110,35 @@ static void __expanditem_func_exp_cb(void *data, Evas_Object *obj, void *event_i
                rgd = elm_radio_add(scroller);
                elm_radio_value_set(rgd, -1);
 
-               int i;
                char *type;
                char *subitem_title = NULL;
                int subitem_index = 0;
                int sel_idx = -1;
 
+#if 1
+               // print out debug message
+               if (data_parentItem->childs)
+               {
+                       int howmany = 0;
+                       Eina_List *li = data_parentItem->childs;
+                       while(li)
+                       {
+                               Setting_GenGroupItem_Data* node = eina_list_data_get(li);
+                               howmany += 1;
+                               SETTING_TRACE(" <<< node->keyStr : %s >>> ", node->keyStr);
+
+                               // go next
+                               li = eina_list_next(li);
+                       }
+                       SETTING_TRACE(" <<<how many : %d>>> ", howmany);
+               }
+#endif
+               if (data_parentItem->childs)
+               {
+                       eina_list_free(data_parentItem->childs);
+                       data_parentItem->childs = NULL;
+               }
+
                while (cur != NULL) {
                        if (!xmlStrcmp(cur->name, (const xmlChar*)"expanditem")) {
                                type = (char*)xmlGetProp(cur, "type");
@@ -1005,20 +1152,18 @@ static void __expanditem_func_exp_cb(void *data, Evas_Object *obj, void *event_i
                                                                                                        subitem_index,
                                                                                                        subitem_title, NULL);
 
-                                       // SETTING_TRACE(">>> value = %s, subitem_title = %s ", value, subitem_title);
 
                                        if (0 == safeStrCmp(value, subitem_title)) {
                                                sel_idx = subitem_index;
                                                SETTING_TRACE("%d is selected in Radio Group", sel_idx);
                                        }
+                                       SETTING_TRACE(" eina list add >>> value = %s, subitem_title = %s ", value, subitem_title);
                                        data_parentItem->childs = eina_list_append(data_parentItem->childs, list_item);
                                        subitem_index++;
 
                                } else {
                                        SETTING_TRACE("invalid type[:%s]", type);
                                }
-
-                               i++;
                        }
                        cur = cur->next;
                }
@@ -1049,69 +1194,99 @@ static void* settings_func(void *data, xmlNode *xmlObj)
        return NULL;
 }
 
+
+static Evas_Object *setting_create_win_layout2(Evas_Object *win_layout, Evas_Object *win_obj)
+{
+
+    Evas_Object *layout = NULL;
+
+    /*  Base Layout */
+    layout = elm_layout_add(win_obj);
+    setting_retvm_if(layout == NULL, FALSE, "layout == NULL");
+
+    elm_layout_theme_set(layout, "layout", "application", "default");
+    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_win_resize_object_add(win_obj, layout);
+
+    Evas_Object *bg = setting_create_bg(layout, win_obj, "group_list");
+    elm_object_part_content_set(layout, "elm.swallow.bg", bg);
+    evas_object_show(layout);
+    return layout;
+}
+
+
+Evas_Object *setting_create_layout_navi_bar2(Evas_Object *win_layout, Evas_Object *win_obj, char *title_str, char *lbutton_str, char *rbutton_str, char *mbutton_str, setting_call_back_func lbutton_click_cb, setting_call_back_func rbutton_click_cb, setting_call_back_func mbutton_click_cb, void *cb_data, Evas_Object *eo_view,  /*any container obj constructed on any evas obj */
+                                           Evas_Object **navi_bar,
+                                           Evas_Object **titleobj)
+{
+
+       Evas_Object *layout = setting_create_win_layout2(win_layout, win_obj);
+       *navi_bar = setting_create_navi_bar(layout);
+
+       setting_create_navi_bar_buttons(title_str,
+                                       lbutton_str, rbutton_str, mbutton_str,
+                                       lbutton_click_cb, rbutton_click_cb,
+                                       mbutton_click_cb, cb_data, eo_view /*content */ ,
+                                       *navi_bar, NULL);
+       return layout;
+}
+
+static void __plugin_genlist_unrealized_cb(void* data,Evas_Object* obj, void* event_info)
+{
+       SETTING_TRACE_BEGIN;
+       ret_if(data == NULL);
+
+       Elm_Object_Item *item = (Elm_Object_Item*)event_info;
+       Setting_GenGroupItem_Data *node = (Setting_GenGroupItem_Data *)elm_object_item_data_get(item);
+       ret_if(node== NULL);
+
+       SETTING_TRACE("keyStr : %s ", node->keyStr);
+       //item_to_update->childs)
+
+       if (node->childs)
+       {
+               eina_list_free(node->childs);
+               node->childs = NULL;
+       }
+}
+
 // <setting>
 static void* setting_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
-
-#if 1/*{{{*/
-       //Draw_Data *pd = node->pd;
+       retv_if(!data || !xmlObj, NULL);
+#if 1
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
 
-       //----------------------------------------------------------------
        // [DATA] title, btn[0], btn[1]
        const char *title = (char*)xmlGetProp(xmlObj, "title");
        char *btn[2] = {/* 0 */"OK", /* 1 */"NO"};
 
-       // find child nodes named 'elements'
-       #if 0
-       if (xmlObj->children) {
-               xmlNode* cur = xmlObj->children;
-               int i =0;
-               while (cur != NULL)
-               {
-                       if (!xmlStrcmp(cur->name, (const xmlChar*)"button")) {
-                               btn[i] = xmlGetProp(cur, "title");
-                               SETTING_TRACE("------>>> node type : Element, name=%s id=%s / btn[%d] = %s ",
-                                                               cur->name,xmlGetProp(cur, "id"),
-                                                               i,
-                                                               btn[i]);
-                               i++;
-                       }
-                       cur = cur->next;
-               }
-       }
-       #endif
-       //----------------------------------------------------------------
        SETTING_TRACE("before setting_create_layout_navi_bar_genlist");
+
        // [UI] with DATA
-       pd->scroller = elm_genlist_add(pd->win_get);
+       pd->scroller = elm_genlist_add(g_main_ad->win_main);
        retvm_if(pd->scroller == NULL, NULL,
                 "Cannot set scroller object  as contento of layout");
        elm_object_style_set(pd->scroller, "dialogue");
        elm_genlist_clear(pd->scroller);        /* first to clear list */
 
-       /*  Enabling illume notification property for window */
-       elm_win_conformant_set(pd->win_get, 1);
-       Evas_Object *conformant = elm_conformant_add(pd->win_get);
-       elm_object_style_set(conformant, "internal_layout");    /*  By Kollus. 2011-01-04 */
-       evas_object_show(conformant);
-       elm_object_content_set(conformant, pd->scroller);
+       evas_object_smart_callback_add(pd->scroller, "unrealized", __plugin_genlist_unrealized_cb, node);
+
 
        SETTING_TRACE("_(title):%s", _(title));
-       pd->ly_main =
-           setting_create_layout_navi_bar(pd->win_get, pd->win_get,
+
+       setting_push_layout_navi_bar(
                                           _(title),
                                           _("IDS_COM_BODY_BACK"), NULL, NULL,
                                           ___click_softkey_back_cb,
                                           NULL, NULL,
-                                          data, conformant,
-                                          &(pd->navi_bar), NULL);
+                                          data, pd->scroller,
+                                          g_main_ad->navibar_main, NULL);
        SETTING_TRACE("after setting_create_layout_navi_bar_genlist");
-
-#endif/*}}}*/
+#endif
        return NULL;
 }
 
@@ -1125,7 +1300,7 @@ static void* expanditem_func(void *data, xmlNode *xmlObj)
 static void* expandlist_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
-       ret_if(!data || !xmlObj);
+       retv_if(!data || !xmlObj, NULL);
 
        PluginNode* node = (PluginNode*)data;
        Draw_Data *pd = node->pd;
@@ -1144,6 +1319,7 @@ static void* expandlist_func(void *data, xmlNode *xmlObj)
        if (list_item) {
                list_item->userdata = xmlObj;
                list_item->belongs_to = (int)pd;
+               list_item->childs = NULL;               /* init */
        }
 
        return list_item;
@@ -1157,11 +1333,12 @@ static int __node_walker(PluginNode* context, xmlNode* cur)
        Draw_Data *pd = context->pd;
 
        retv_if(!pd, -1);
+       retv_if(!context->ui_list, -1);
+
        xmlNode *cur_node = NULL;
        for (cur_node = cur; cur_node;cur_node = cur_node->next) {
                if (cur_node->type == XML_ELEMENT_NODE) {
-                       SETTING_TRACE("node type : %s id= %s", cur_node->name,xmlGetProp(cur_node, "id"));
-
+                       // SETTING_TRACE("node type : %s id= %s", cur_node->name,xmlGetProp(cur_node, "id"));
                        drawer_fp  fp = __drawer_find(cur_node->name);
                        if (fp)
                        {
@@ -1178,6 +1355,8 @@ static int __node_walker(PluginNode* context, xmlNode* cur)
                                        char* key_name = xmlGetProp(cur_node, "id");
                                        eina_hash_add(context->ui_list, strdup(key_name),(void*)genlist_node);
                                }
+                       }else {
+                               SETTING_TRACE(" >>>> fp is NULL ");
                        }
                }
                __node_walker(context, cur_node->children);     /* RECURSIVE */
@@ -1195,6 +1374,13 @@ static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char*
        SETTING_TRACE_BEGIN;
        xmlNode *cur_node = NULL;
 
+       if (! context)
+       {
+               SETTING_TRACE("context is NULL - it's error CONDITION ");
+               return -1;
+       }
+
+       retv_if(!context->ui_list, -1);
        if (*is_end == true) return 0;
 
        for (cur_node = cur; cur_node;cur_node = cur_node->next) {
@@ -1228,8 +1414,9 @@ static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char*
                                // case : toggle
                                if ( 0 == strcmp (cur_node->name, "bool"))
                                {
-                                       SETTING_TRACE(">>>>> UPDATE TOGGLE CONTROL %x --- %s ",context->ui_list, id_name);
-                                       Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
+                                       SETTING_TRACE(">>>>> UPDATE TOGGLE CONTROL pluginpath:%s, ----  %x --- %s ", context->plugin_path, context->ui_list, id_name);
+                                       Setting_GenGroupItem_Data* item_to_update = NULL;
+                                       item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
                                        if      (item_to_update)
                                        {
                                                item_to_update->chk_status = atoi(value);
@@ -1270,49 +1457,78 @@ static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char*
                                //-----------------------------------------------------------
                                if ( 0 == strcmp (cur_node->name, "expandlist"))
                                {
-                                       SETTING_TRACE(">>>>> UPDATE EXPAND LIST CONTROL %x --- %s ",context->ui_list, id_name);
-                                       Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
-                                       if      (item_to_update)
-                                       {
-                                               char* old_string = item_to_update->sub_desc;
-                                               item_to_update->sub_desc = strdup(value);
-                                               SETTING_TRACE(">>>   o-------------0 EXPAND LIST VALUE = %s ", value);
-
-                                               // free old string
-                                               // string update
-                                               elm_object_item_data_set(item_to_update->item, item_to_update);
-                                               elm_genlist_item_update(item_to_update->item);
-
-                                               // TODO: need to update child elements
-                                               // item_to_update->childs ---> expanded list
+                                       #if 1
+                    SETTING_TRACE(">>>>> UPDATE EXPAND LIST CONTROL %x --- %s ",context->ui_list, id_name);
+                    Setting_GenGroupItem_Data* item_to_update = NULL;
+                                       item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
+                    if  (item_to_update)
+                    {
+                        char* old_string = item_to_update->sub_desc;
+                        item_to_update->sub_desc = strdup(value);
+                        SETTING_TRACE(">>>   o-------------0 EXPAND LIST VALUE = %s ", value);
+
+                        // free old string
+                        // string update
+                        elm_object_item_data_set(item_to_update->item, item_to_update);
+                        elm_genlist_item_update(item_to_update->item);
+
+                        // TODO: need to update child elements
+                        // item_to_update->childs ---> expanded list
+
+                                               // debug log
+                                               // there should have 4 sub items.
+                                               //-----------------------------------------------------
+                                               // has it already freed by someone?
+                                               //-----------------------------------------------------
                                                if (item_to_update->childs)
                                                {
+                                                       int howmany2 =0;
                                                        Eina_List *li = item_to_update->childs;
-                                                       int radio_index = 0;
                                                        while(li)
                                                        {
                                                                Setting_GenGroupItem_Data* node = eina_list_data_get(li);
-                                                               // do something more
-                                                               // SETTING_TRACE(">>> RADIO LIST STRING VALUE = %s ", node->keyStr);
-                                                               // set position of radio button
-                                                               if (strcmp(node->keyStr, value) == 0)
-                                                               {
-                                                                       elm_radio_value_set(node->rgd, radio_index);
-                                                               }
-                                                               elm_object_item_data_set(item_to_update->item, item_to_update);
-                                                               elm_genlist_item_update(item_to_update->item);
-
-                                                               // go next
+                                                               howmany2 += 1;
                                                                li = eina_list_next(li);
-                                                               radio_index++;
                                                        }
-
+                                                       SETTING_TRACE(" expandlist -- how many items are there? : %d ", howmany2);
                                                }
-                                       } else {
-                                               SETTING_TRACE("item_to_update is NULL");
-                                       }
-                               }
 
+                        if (item_to_update->childs)
+                        {
+                            Eina_List *li = item_to_update->childs;
+                            int radio_index = 0;
+                            while(li)
+                            {
+                                Setting_GenGroupItem_Data* node = eina_list_data_get(li);
+
+                                if (node->item && node->keyStr)
+                                {
+                                    // do something more
+                                    // SETTING_TRACE(">>> RADIO LIST STRING VALUE = %s ", node->keyStr);
+                                    // set position of radio button
+                                    if (strcmp(node->keyStr, value) == 0) // << CRAAH !!!!
+                                    {
+                                        elm_radio_value_set(node->rgd, radio_index);
+                                    }
+                                } else {
+                                     SETTING_TRACE(">>> node has unproper values - Setting_GenGroupItem_Data");
+                                }
+                                elm_object_item_data_set(item_to_update->item, item_to_update);
+                                elm_genlist_item_update(item_to_update->item);
+
+                                // go next
+                                li = eina_list_next(li);
+                                radio_index++;
+                            }
+
+                        }
+                    } else {
+                        SETTING_TRACE("item_to_update is NULL");
+                    }
+
+
+                                       #endif
+                               }
                                *is_end = true;
                        }
                }
@@ -1345,13 +1561,17 @@ static void _plugin_entry_free_cb(void* data)
        }
 }
 
-//static PluginNode* g_context;
-
 PluginNode* setting_plugin_create()
 {
        PluginNode *node = calloc(1, sizeof(PluginNode));
-
+       setting_retvm_if(!node, -1, "Create PluginNode obj failed");
        Draw_Data *pd = calloc(1, sizeof(Draw_Data));
+
+
+       if (!pd) {
+               FREE(node);
+       }
+
        setting_retvm_if(!pd, -1, "Create Draw_Data obj failed");
        //eina_init();
 
@@ -1389,6 +1609,7 @@ void setting_plugin_destroy(PluginNode* node)
                }
                free(node);
                node = NULL;
+//             PLUGIN_FINI;
        }
 }
 
@@ -1404,7 +1625,9 @@ static Eina_Bool _plugin_foreach_cb(const Eina_Hash *hash, const void*key, void*
 void setting_plugin_debug(PluginNode* context)
 {
 //     SETTING_TRACE("HASH TABLE -------------------------------------");
-       eina_hash_foreach(context->ui_list,_plugin_foreach_cb, NULL);
+       if (context->ui_list) {
+               eina_hash_foreach(context->ui_list,_plugin_foreach_cb, NULL);
+       }
 //     SETTING_TRACE("HASH TABLE -------------------------------------");
 
 }
@@ -1427,6 +1650,9 @@ void setting_plugin_update(PluginNode* context)
 }
 
 
+/**
+ * set modifiable
+ */
 bool setting_plugin_load(PluginNode* context, const char *cfg_file)
 {
        SETTING_TRACE("cfg_file:%s", cfg_file)
@@ -1436,13 +1662,53 @@ bool setting_plugin_load(PluginNode* context, const char *cfg_file)
                return FALSE;
        }
        context->pd->cfg_file = cfg_file;
-       context->pd->win_get = (Evas_Object *) ug_get_window();
 
-       GError *error = NULL;
+       //GError *error = NULL;
 
        context->pd->doc = xmlParseFile(cfg_file);
        context->pd->root = xmlDocGetRootElement(context->pd->doc);
 
+       // signal filter change
+       //setting_dbus_handler_init(g_main_ad);
+       void* user_data = (void*)g_main_ad;
+
+       DBusError error;
+       dbus_error_init(&error);
+       char rule[MAX_LOCAL_BUFSIZE + 1] = {0,};
+       bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+       if (!bus)
+       {
+               SETTING_TRACE("Fail to connect to the D-BUS daemon: %s", error.message);
+               dbus_error_free(&error);
+               return -1;
+       }
+
+       // remove filter
+       // dbus_connection_remove_filter(bus, __signal_filter, NULL);
+
+       // get rule
+       snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
+       dbus_bus_add_match(bus, rule, &error);
+       if (dbus_error_is_set(&error))
+       {
+               SETTING_TRACE("Fail to rule set; %s", error.message);
+               dbus_bus_remove_match(bus, rule, &error);
+               dbus_error_free(&error);
+               dbus_connection_close(bus);
+               bus = NULL;
+               return -1;
+       }
+
+       // re-add filter
+       if (dbus_connection_add_filter(bus, __signal_filter, user_data, NULL) == FALSE)
+       {
+               dbus_bus_remove_match(bus, rule, &error);
+               dbus_error_free(&error);
+               dbus_connection_close(bus);
+               bus = NULL;
+               return -1;
+       }
+
        // TODO: error handler here
        __node_walker(context, context->pd->root);