From: MyoungJune Park Date: Mon, 17 Sep 2012 08:35:12 +0000 (+0900) Subject: fixed bug on updating UI after receiving msg from AppSetting X-Git-Tag: accepted/tizen_2.1/20130425.022820~31^2~222^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09bc8522f654580684b874c92349ed2c0ea4f46e;p=apps%2Fcore%2Fpreloaded%2Fsettings.git fixed bug on updating UI after receiving msg from AppSetting --- diff --git a/setting-common/include/setting-common-data-type.h b/setting-common/include/setting-common-data-type.h index ca44618..6a8f7c5 100755 --- a/setting-common/include/setting-common-data-type.h +++ b/setting-common/include/setting-common-data-type.h @@ -237,7 +237,11 @@ typedef enum _POPUP_BTN_RESPONSE_TYPE{ * @todo isItemDisableFlag is required? * @todo isSinglelineFlag is requred? */ -typedef struct _Setting_GenGroupItem_Data { + + +typedef struct Setting_GenGroupItem_Data Setting_GenGroupItem_Data; + +typedef struct Setting_GenGroupItem_Data { void **pBack; @@ -294,7 +298,8 @@ typedef struct _Setting_GenGroupItem_Data { Elm_Entry_Filter_Accept_Set *digits_filter_data; Elm_Entry_Filter_Limit_Size *limit_filter_data; -} Setting_GenGroupItem_Data; + Eina_List* childs; /**< child nodes if this node has child nodes for handling radio buttons */ +}; typedef enum { SETTING_VCONF_INT_TYPE = 0, diff --git a/setting-common/src/setting-common-draw-genlist.c b/setting-common/src/setting-common-draw-genlist.c index 9b2a94f..9c0f02c 100755 --- a/setting-common/src/setting-common-draw-genlist.c +++ b/setting-common/src/setting-common-draw-genlist.c @@ -216,10 +216,10 @@ static void __entry_keydown(void *data, Evas *e, Evas_Object *obj, void *event_i Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info; if(safeStrCmp(ev->key, "Return") == 0) //to disable the 'Enter' orginal function { - SETTING_TRACE("ENTER %s ev->key:%s", __FUNCTION__, ev->key); + SETTING_TRACE("ENTER %s ev->key:%s", __FUNCTION__, ev->key); //hide the eraser button //format like:xx
- const char *entry_str = remove_first_substring(elm_entry_entry_get(obj), "
"); + const char *entry_str = remove_first_substring(elm_entry_entry_get(obj), "
"); elm_entry_entry_set(obj, entry_str); FREE(entry_str); elm_entry_cursor_end_set(obj); @@ -1264,6 +1264,7 @@ Setting_GenGroupItem_Data *setting_create_Gendial_exp_parent_field( item_data->keyStr = (char *)g_strdup(keyStr); item_data->sub_desc = (char *)g_strdup(sub_desc); item_data->swallow_type = swallow_type; + item_data->childs = NULL; if (gl_sel) { item_data->item = diff --git a/src/setting-plugin.c b/src/setting-plugin.c index 776cfbb..d7288bb 100755 --- a/src/setting-plugin.c +++ b/src/setting-plugin.c @@ -50,7 +50,7 @@ static void* navigationbar_func(void *data, xmlNode *xmlObj); /* * @return void - */ + */ static void* group_func(void *data, xmlNode *xmlObj); /* @@ -100,7 +100,7 @@ static void* setting_func(void *data, xmlNode *xmlObj); static int __node_walker(PluginNode* context, xmlNode* cur); -static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value); +static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value, bool* is_end); static void __drawer_add(const char *type, drawer_fp draw) @@ -186,13 +186,13 @@ void setting_drawer_list_fini() #define DBUS_SIGNAL_INTERFACE "org.tizen.setting.signal" #define DBUS_SIGNAL "test" -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)) - return 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)) + return 0; - return strndup(str + begin, len); -} + return strndup(str + begin, len); +} //------------------------------------------------------ // for client - bus @@ -228,31 +228,32 @@ static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* mess { SETTING_TRACE("received key : %s , value : %s", key, value); //------------------------------------------------------------- - // received key : checkbox1|N/A , value : INT|1 + // received key : checkbox1|N/A , value : INT|1 //------------------------------------------------------------- //char* key = "checkbox1|N/A"; char* ptr = strchr(key, '|'); xmlDocPtr doc = NULL; if (ptr && key) - { + { //parsing for : checkbox1|N/A -> checkbox1 char* key_name = substring(key, 0, strlen(key)-strlen(ptr)); char* val_name = strchr(value, '|'); val_name++; - + // ad->plugin_path // access xml file doc = xmlParseFile(ad->plugin_path); // generate xml tree xmlNode *root = xmlDocGetRootElement(doc); // find a node - __node_finder((PluginNode*)ad->plugin_node, root, key_name ,val_name); - } + bool is_end = false; + __node_finder((PluginNode*)ad->plugin_node, root, key_name ,val_name, &is_end); + } // update the node GError *error = NULL; - /* +#if 0 if(doc != NULL) { xmlSaveFormatFile(ad->plugin_path, doc, 1); @@ -261,7 +262,7 @@ static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* mess doc = NULL; SETTING_TRACE("__cfg_file_write successful"); } - */ +#endif // update UI } @@ -405,7 +406,6 @@ static int __cfg_file_write(Draw_Data *pd) if(pd->doc != NULL) { xmlSaveFormatFile(pd->cfg_file, pd->doc, 1); - // TODO: make sure this is right //xmlFreeDoc(pd->doc); //pd->doc = NULL; SETTING_TRACE("__cfg_file_write successful"); @@ -536,7 +536,7 @@ static void* link_func(void *data, xmlNode *xmlObj) Draw_Data *pd = node->pd; const char *key_str = (char*)xmlGetProp(xmlObj, "id"); - Setting_GenGroupItem_Data * obj = + Setting_GenGroupItem_Data * obj = setting_create_Gendial_field_def(pd->scroller, &(itc_1text), __link_list_cb, xmlObj, SWALLOW_Type_INVALID, NULL, NULL, @@ -659,7 +659,6 @@ static void* navigationbar_func(void *data, xmlNode *xmlObj) ___click_softkey_back_cb, data, &pd->scroller, &(pd->navi_bar)); - //return (void*)(pd->ly_main); return NULL; }; @@ -715,7 +714,7 @@ static void __chk_btn_cb(void *data, Evas_Object *obj, const char *id = (char*)xmlGetProp(xmlObj, "id"); const char *title = (char*)xmlGetProp(xmlObj, "title"); - SETTING_TRACE(" >>>> id:%s , title:%s", id, title); + //SETTING_TRACE(" >>>> id:%s , title:%s", id, title); __send_int_msg(xmlObj, list_item->chk_status); __cfg_file_write((Draw_Data *)list_item->belongs_to); return; @@ -884,7 +883,8 @@ static void __expanditem_func_sel_cb(void *data, Evas_Object *obj, void *event_i ret_if(!xmlObj); xmlAttrPtr newattr; - newattr = xmlSetProp(xmlObj, "string", data_parentItem->sub_desc); + //newattr = xmlSetProp(xmlObj, "string", data_parentItem->sub_desc); + newattr = xmlSetProp(xmlObj, "value", data_parentItem->sub_desc); __send_string_msg(xmlObj, data_parentItem->sub_desc); __cfg_file_write((Draw_Data *)data_parentItem->belongs_to); @@ -903,8 +903,11 @@ static void __expanditem_func_exp_cb(void *data, Evas_Object *obj, void *event_i Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */ Evas_Object *scroller = elm_object_item_widget_get(parentItem); + xmlNode *xmlObj = data_parentItem->userdata; - char *value = (char*)xmlGetProp(xmlObj, "string"); + //char *value = (char*)xmlGetProp(xmlObj, "string"); + char *value = (char*)xmlGetProp(xmlObj, "value"); + SETTING_TRACE(">>> value = %s", value); int i=0; Evas_Object *rgd = NULL; @@ -925,16 +928,23 @@ static void __expanditem_func_exp_cb(void *data, Evas_Object *obj, void *event_i type = (char*)xmlGetProp(cur, "type"); if (0 == safeStrCmp(type, "radio")) { subitem_title = (char*)xmlGetProp(cur, "title"); - setting_create_Gendial_exp_sub_field(scroller, - &(itc_1icon_1text_sub), - __expanditem_func_sel_cb, NULL, parentItem, - SWALLOW_Type_1RADIO, rgd, - subitem_index, - subitem_title, NULL); + Setting_GenGroupItem_Data *list_item = + setting_create_Gendial_exp_sub_field(scroller, + &(itc_1icon_1text_sub), + __expanditem_func_sel_cb, NULL, parentItem, + SWALLOW_Type_1RADIO, rgd, + 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); } + data_parentItem->childs = eina_list_append(data_parentItem->childs, list_item); subitem_index++; + } else { SETTING_TRACE("invalid type[:%s]", type); } @@ -1046,7 +1056,7 @@ static void* expandlist_func(void *data, xmlNode *xmlObj) } -///////////// + static int __node_walker(PluginNode* context, xmlNode* cur) { //SETTING_TRACE_BEGIN; @@ -1061,10 +1071,10 @@ static int __node_walker(PluginNode* context, xmlNode* cur) drawer_fp fp = __drawer_find(cur_node->name); if (fp) { - // type check + // type check void* vret = fp(context, cur_node); // draw it - if (vret) + if (vret) { Setting_GenGroupItem_Data* genlist_node = (Setting_GenGroupItem_Data* )vret; //SETTING_TRACE("add node to Eina List name : %s, id : ", cur_node->name, xmlGetProp(cur_node, "id")); @@ -1072,8 +1082,7 @@ static int __node_walker(PluginNode* context, xmlNode* cur) // id, object // add list char* key_name = xmlGetProp(cur_node, "id"); - eina_hash_add(context->ui_list, strdup(key_name),(void*)genlist_node); - //context->ui_list= eina_list_append(context->ui_list, genlist_node); + eina_hash_add(context->ui_list, strdup(key_name),(void*)genlist_node); } } } @@ -1085,16 +1094,18 @@ static int __node_walker(PluginNode* context, xmlNode* cur) /** * @param id_str [in] "id" * @param value [in] value to be udpated + * @see __expanditem_func_sel_cb */ -// refer to __expanditem_func_sel_cb -static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value) +static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value, bool* is_end) { - //SETTING_TRACE_BEGIN; + SETTING_TRACE_BEGIN; xmlNode *cur_node = NULL; + + if (*is_end == true) return 0; + for (cur_node = cur; cur_node;cur_node = cur_node->next) { if (cur_node->type == XML_ELEMENT_NODE) { - //SETTING_TRACE("node type : Element, name=%s id=%s", cur_node->name,xmlGetProp(cur_node, "id")); char* id_name = (char*)xmlGetProp(cur_node, "id"); if ( id_name && 0 == strcmp(id_str, id_name)) { @@ -1108,7 +1119,7 @@ static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* if ( 0 == strcmp (cur_node->name, "integer")) { SETTING_TRACE(">>>>> UPDATE SLIDER 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_GenGroupItem_Data* 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); @@ -1119,12 +1130,12 @@ static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* } else { SETTING_TRACE("item_to_update is NULL"); } - } + } // 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_GenGroupItem_Data* 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); @@ -1136,21 +1147,22 @@ static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* SETTING_TRACE("item_to_update is NULL"); } } - // case : edit control + // case : edit control if ( 0 == strcmp (cur_node->name, "string")) { SETTING_TRACE(">>>>> UPDATE EDIT CONTROL 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_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 STRING VALUE = %s ", value); - + // free old string elm_object_item_data_set(item_to_update->item, item_to_update); elm_genlist_item_update(item_to_update->item); + } else { SETTING_TRACE("item_to_update is NULL"); } @@ -1165,7 +1177,7 @@ 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); + 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; @@ -1173,15 +1185,44 @@ static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* 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 (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); + // 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 + li = eina_list_next(li); + radio_index++; + } + + } } else { SETTING_TRACE("item_to_update is NULL"); } } + + *is_end = true; } } - __node_finder(context, cur_node->children, id_str, value); /* RECURSIVE */ + __node_finder(context, cur_node->children, id_str, value, is_end); /* RECURSIVE */ } return 0; } @@ -1194,7 +1235,7 @@ static unsigned int _plugin_string_key_length(const char*key) return (int)strlen(key) + 1; } -static int _plugin_string_key_cmp(const char* key1, int key1_length, +static int _plugin_string_key_cmp(const char* key1, int key1_length, const char* key2, int key2_length) { return strcmp(key1, key2); @@ -1202,8 +1243,12 @@ static int _plugin_string_key_cmp(const char* key1, int key1_length, static void _plugin_entry_free_cb(void* data) { -// free(data); -// data = NULL; + Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data; + if (node->childs) + { + eina_list_free(node->childs); + node->childs = NULL; + } } //static PluginNode* g_context; @@ -1235,29 +1280,21 @@ void setting_plugin_destroy(PluginNode* node) SETTING_TRACE("node->pd is NOT NULL") if(node->pd->doc != NULL) { xmlSaveFormatFile(node->plugin_path, node->pd->doc, 1); - // TODO: make sure this is right xmlFreeDoc(node->pd->doc); node->pd->doc = NULL; SETTING_TRACE("__cfg_file_write successful"); } - SETTING_TRACE("before freeing node->pd"); free(node->pd); node->pd = NULL; - SETTING_TRACE("after freeing node->pd"); } - SETTING_TRACE("before freeing ui_list"); if (node->ui_list) { eina_hash_free(node->ui_list); node->ui_list = NULL; } - SETTING_TRACE("after freeing ui_list"); - - SETTING_TRACE("before freeing node"); free(node); node = NULL; - SETTING_TRACE("after freeing node"); } } @@ -1266,16 +1303,15 @@ static Eina_Bool _plugin_foreach_cb(const Eina_Hash *hash, const void*key, void* { Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data; SETTING_TRACE("%s --- %s ", (char*)key, node->keyStr); - return EINA_TRUE; } void setting_plugin_debug(PluginNode* context) { - SETTING_TRACE("HASH TABLE -------------------------------------"); +// SETTING_TRACE("HASH TABLE -------------------------------------"); eina_hash_foreach(context->ui_list,_plugin_foreach_cb, NULL); - SETTING_TRACE("HASH TABLE -------------------------------------"); +// SETTING_TRACE("HASH TABLE -------------------------------------"); }