3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.1 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include <setting-common-plugin.h>
21 #include <eina_list.h>
25 //#include <libxml/xmlmemory.h>
26 //#include <libxml/parser.h>
28 #include <setting-debug.h>
29 #include <setting-common-general-func.h>
30 #include <setting-common-draw-widget.h>
32 //extern setting_main_appdata *g_main_ad;
34 static Setting_GenGroupItem_Data *g_list_item; /*TEST*/
37 * UI draw handler table : _g_draw_list
38 * - contains Object_Drawer typed object.
40 static Eina_List *_g_drawer_list = NULL;
44 * @return Evas_Object * obj
46 static void* navigationbar_func(void *data, xmlNode *xmlObj);
52 static void* group_func(void *data, xmlNode *xmlObj);
55 * @return Setting_GenGroupItem_Data* ptr
57 static void* link_func(void *data, xmlNode *xmlObj);
60 * @return Setting_GenGroupItem_Data* ptr
62 static void* slider_func(void *data, xmlNode *xmlObj);
65 * @return Setting_GenGroupItem_Data* ptr
67 static void* label_func(void *data, xmlNode *xmlObj);
70 * @return Setting_GenGroupItem_Data* ptr
72 static void* checkbox_func(void *data, xmlNode *xmlObj);
75 * @return Setting_GenGroupItem_Data* ptr
77 static void* editbox_func(void *data, xmlNode *xmlObj);
80 * @return Setting_GenGroupItem_Data* ptr
82 static void* expandlist_func(void *data, xmlNode *xmlObj);
87 static void* expanditem_func(void *data, xmlNode *xmlObj);
92 static void* settings_func(void *data, xmlNode *xmlObj);
95 static void* launch_func(void *data, xmlNode *xmlObj);
100 static void* setting_func(void *data, xmlNode *xmlObj);
102 static int __node_walker(PluginNode* context, xmlNode* cur);
104 static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value, bool* is_end);
107 static void __drawer_add(const char *type, drawer_fp draw)
109 Object_Drawer *node = calloc(1, sizeof(Object_Drawer));
110 if (node && type && draw)
115 _g_drawer_list = eina_list_append(_g_drawer_list, node);
121 static drawer_fp __drawer_find(char* type)
124 SETTING_TRACE("node type:%s", type);
125 Eina_List *check_list = _g_drawer_list;
126 Object_Drawer *list_item = NULL;
129 list_item = (Object_Drawer *) eina_list_data_get(check_list);
130 if (NULL == list_item)
133 if (0 == safeStrCmp(list_item->type, type))
135 //SETTING_TRACE("list_item->type:%s", list_item->type);
138 //if not matched,to check next node.
139 check_list = eina_list_next(check_list);
142 //SETTING_TRACE("list_item:%p", list_item);
143 return list_item ? list_item->draw : NULL;
146 void setting_drawer_list_init()
150 /* <navigationbar> */__drawer_add("navigationbar", navigationbar_func);
152 /* <bool> */__drawer_add("bool", checkbox_func);
153 /* <string> */__drawer_add("string", editbox_func);
154 /* <group> */__drawer_add("group", group_func);
155 /* <integer> */__drawer_add("integer", slider_func);
156 /* <label> */__drawer_add("label", label_func);
157 /* <link> */__drawer_add("link", link_func);
158 /* <launch> */__drawer_add("launch", launch_func);
159 /* <extendlist> */__drawer_add("expandlist", expandlist_func);
160 /* <extenditem> */__drawer_add("expanditem", expanditem_func);
161 /* <settings> */__drawer_add("settings", settings_func);
162 /* <setting> */__drawer_add("setting", setting_func);
165 void setting_drawer_list_fini()
169 Object_Drawer *node = NULL;
170 Eina_List *li = _g_drawer_list;
172 node = (Object_Drawer *) eina_list_data_get(li);
175 //SETTING_TRACE("Deregister %s", node->type);
178 li = eina_list_next(li);
180 _g_drawer_list = eina_list_free(_g_drawer_list);
181 _g_drawer_list = NULL;
185 /////////////////////////
186 /////////////////////////
187 /////////////////////////
189 #define MAX_CONTENT_LEN 512
190 #define MAX_LOCAL_BUFSIZE 128
191 #define DBUS_PATH "/setting/dbus_handler"
192 #define DBUS_SIGNAL_INTERFACE "org.tizen.setting.signal"
194 #define APPID_LENGTH 10
195 #define APPID_POS_FROM_PATH 10
197 static char* s_pkg_name;
198 static char* s_plugin_path;
203 * ncbyusjryr.AppSetting --> package ID is ncbyusjryr
204 * "Update_" "ncbyusjryr"
206 static char* get_app_string(char* path)
209 char* temp = substring(path, APPID_POS_FROM_PATH, APPID_LENGTH/*string size*/);
210 SETTING_TRACE("package ID : >>> %s ",temp );
214 //------------------------------------------------------
216 static DBusConnection *bus;
217 //------------------------------------------------------
218 static DBusHandlerResult __signal_filter(DBusConnection* conn, DBusMessage* message, void* user_data)
220 int my_pid = getpid();
226 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
229 dbus_error_init(&error);
231 PluginNode* ad = (PluginNode*)user_data;
233 //char* plugin_path = ad->plugin_path;
234 char* plugin_path = s_plugin_path;
235 char* pkg_name = get_app_string(plugin_path);
237 if (pkg_name == NULL)
239 SETTING_TRACE("pkg_name is NULL - it's abnormal operation");
240 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
243 char str_buf[MAX_COMMON_BUFFER_LEN];
244 snprintf(str_buf, MAX_COMMON_BUFFER_LEN, "Update_%s", pkg_name);
245 s_pkg_name = strdup(str_buf);
253 if (s_pkg_name == NULL)
255 SETTING_TRACE("s_pkg_name is NULL - it's abnormal operation");
256 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
258 SETTING_TRACE("s_pkg_name : %s ", s_pkg_name);
259 if (dbus_message_is_signal(message, DBUS_SIGNAL_INTERFACE, s_pkg_name))
261 if (dbus_message_get_args(message, &error,
262 DBUS_TYPE_UINT32, &sender_pid,
263 DBUS_TYPE_STRING, &key,
264 DBUS_TYPE_STRING, &value,
265 DBUS_TYPE_INVALID) == FALSE)
267 SETTING_TRACE_ERROR("Fail to get data : %s", error.message);
268 dbus_error_free(&error);
269 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
273 if (sender_pid != 0 && my_pid != sender_pid)
275 SETTING_TRACE("received key : %s , value : %s", key, value);
276 //-------------------------------------------------------------
277 // received key : checkbox1|N/A , value : INT|1
278 //-------------------------------------------------------------
279 //char* key = "checkbox1|N/A";
283 ptr = strchr(key, '|');
286 xmlDocPtr doc = NULL;
289 //parsing for : checkbox1|N/A -> checkbox1
290 char* key_name = substring(key, 0, strlen(key)-strlen(ptr));
291 char* val_name = strchr(value, '|');
294 if (key_name == NULL)
298 doc = xmlParseFile(plugin_path);
301 SETTING_TRACE("unable to parse file : %s", plugin_path);
303 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; /* xml parsing error */
306 xmlNode *root = xmlDocGetRootElement(doc);
310 // TODO : message queing
311 // get key/value from d-bus and parse xml and search xml data with key
312 static int count = 0;
313 SETTING_TRACE(" BEGIN ---------------------------- dbus--> before __node_finder : %d", count);
314 __node_finder((PluginNode*)ad, root, key_name ,val_name, &is_end);
315 SETTING_TRACE(" END ----------------------------- dbus--> after __node_finder : %d", count);
319 GError *error = NULL;
323 xmlSaveFormatFile(ad->plugin_path, doc, 1);
324 // TODO: make sure this is right
327 SETTING_TRACE("__cfg_file_write successful");
334 return DBUS_HANDLER_RESULT_HANDLED;
337 static int __send_msg(char* key, char* value)
339 DBusMessage* message;
341 int sender_pid = getpid();
346 // ex) in gdb --> $15 = 0x43b6eb78 "Update_(null)" -> error codintion
347 if (s_pkg_name == NULL)
349 SETTING_TRACE("s_pkg_name is NULL - it's abnormal operation");
353 message = dbus_message_new_signal(DBUS_PATH, DBUS_SIGNAL_INTERFACE, s_pkg_name);
355 SETTING_TRACE("Sending message[%s:%s] via dbus", key ,value);
356 if (dbus_message_append_args(message,
357 DBUS_TYPE_UINT32, &sender_pid,
358 DBUS_TYPE_STRING, &key,
359 DBUS_TYPE_STRING, &value,
360 DBUS_TYPE_INVALID) == FALSE)
362 SETTING_TRACE("Fail to load data error");
366 if (dbus_connection_send(bus, message, NULL) == FALSE)
368 SETTING_TRACE("Fail to send message");
372 dbus_connection_flush(bus);
373 dbus_message_unref(message);
375 SETTING_TRACE("[CLIENT] send data signal done");
381 static void __send_int_msg(xmlNode* xmlObj, int val)
384 const char *id = (char*)xmlGetProp(xmlObj, "id");
385 const char *title = (char*)xmlGetProp(xmlObj, "title");
386 char key[MAX_CONTENT_LEN] = {0,};
387 snprintf(key, sizeof(key), "%s|%s", id, title);
389 char value[MAX_CONTENT_LEN] = {0,};
390 snprintf(value, sizeof(value), "INT|%d", val);
391 __send_msg(key, value);
396 static void __send_string_msg(xmlNode* xmlObj, char *string)
398 const char *id = (char*)xmlGetProp(xmlObj, "id");
399 const char *title = (char*)xmlGetProp(xmlObj, "title");
400 char key[MAX_CONTENT_LEN] = {0,};
401 snprintf(key, sizeof(key), "%s|%s", id, title);
403 char value[MAX_CONTENT_LEN] = {0,};
404 snprintf(value, sizeof(value), "STRING|%s", string);
405 __send_msg(key, value);
409 int setting_dbus_handler_init(void* user_data)
414 SETTING_TRACE("already get a bus, need release first.");
415 setting_dbus_handler_fini();
419 memset(&error, 0, sizeof(DBusError));
420 char rule[MAX_LOCAL_BUFSIZE + 1] = {0,};
421 dbus_error_init(&error);
422 bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
425 SETTING_TRACE("Fail to connect to the D-BUS daemon: %s", error.message);
426 dbus_error_free(&error);
430 dbus_connection_setup_with_g_main(bus, NULL);
431 snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
433 dbus_bus_add_match(bus, rule, &error);
434 if (dbus_error_is_set(&error))
436 SETTING_TRACE("Fail to rule set; %s", error.message);
437 dbus_bus_remove_match(bus, rule, &error);
438 dbus_error_free(&error);
439 dbus_connection_close(bus);
443 PluginNode* temp = (PluginNode*)user_data;
444 s_plugin_path = temp->plugin_path;
446 if (dbus_connection_add_filter(bus, __signal_filter, user_data, NULL) == FALSE)
448 dbus_bus_remove_match(bus, rule, &error);
449 dbus_error_free(&error);
450 dbus_connection_close(bus);
455 SETTING_TRACE("app signal initialized");
459 int setting_dbus_handler_fini(void)
462 //do safty checking first.
463 setting_retvm_if(!bus, 0, "!bus");
465 memset(&error, 0, sizeof(DBusError));
466 char rule[MAX_LOCAL_BUFSIZE + 1] = {0, };
468 dbus_error_init(&error);
471 bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
473 //dbus_connection_remove_filter(bus, __signal_filter, NULL);
476 snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
477 dbus_bus_remove_match(bus, rule, &error);
479 if (dbus_error_is_set(&error))
481 SETTING_TRACE("Fail to rule unset: %s", error.message);
482 dbus_error_free(&error);
486 dbus_connection_close(bus);
488 SETTING_TRACE("app signal finalized");
492 /////////////////////////////
493 /////////////////////////////
494 /////////////////////////////
496 Elm_Genlist_Item_Class itc_layout;
499 static int __cfg_file_write(Draw_Data *pd)
503 GError *error = NULL;
506 xmlSaveFormatFile(pd->cfg_file, pd->doc, 1);
507 //xmlFreeDoc(pd->doc);
509 SETTING_TRACE("__cfg_file_write successful");
518 Setting_GenGroupItem_Data* obj;
521 static Eina_Bool _plugin_foreach_cb_check_editfield(const Eina_Hash *hash, const void*key, void* data, void* fdata)
524 HashArgs* pret = (HashArgs*)fdata;
525 //int* pret = (int*)fdata;
527 Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data;
528 //SETTING_TRACE("%s --- %s ", (char*)key, node->keyStr);
530 if (node->keyStr && !strcmp(node->keyStr, "string"))
533 if (elm_object_focus_get(node->eo_check))
535 SETTING_TRACE("FOCUS SET !!! ");
540 SETTING_TRACE("FOCUS UN -- SET !!! ");
548 int setting_plugin_is_editfield_exist(PluginNode* context)
555 if (context->ui_list) {
556 eina_hash_foreach(context->ui_list,_plugin_foreach_cb_check_editfield, &arg);
558 SETTING_TRACE("%d -- (%x)", arg.state, arg.obj);
564 Setting_GenGroupItem_Data* list_item = arg.obj;
565 int min_length = list_item->minlength;
566 int entry_len = safeStrLen(list_item->sub_desc);
567 //SETTING_TRACE(" >>> entry _ len : %d ", entry_len);
568 //SETTING_TRACE(" >>> minlength _ len : %d ", min_length);
570 if ( entry_len < min_length)
572 if (!list_item->notify) {
573 SETTING_TRACE("notify 1");
574 list_item->notify = setting_create_popup_without_btn(list_item, list_item->win_main,
575 NULL, _(EXCEED_MINLENGTH_LIMITATION_STR),
576 __error_popup_response_cb,
577 POPUP_INTERVAL, FALSE, FALSE);
578 elm_object_focus_set(list_item->eo_check, EINA_FALSE);
580 SETTING_TRACE("notify 0 ");
581 //postpone 2 seconds again
582 elm_popup_timeout_set(list_item->notify, POPUP_INTERVAL);
584 //elm_object_focus_set(obj, EINA_TRUE);
593 static Eina_Bool ___click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info)
597 PluginNode* node = (PluginNode*)data;
598 Draw_Data *pd = node->pd;
600 int is_stop = setting_plugin_is_editfield_exist(node);
613 elm_naviframe_item_pop(node->navi_bar);
616 ui_gadget_h ug = node->ug;
619 //pd->scroller = NULL;
620 //pd->cfg_file = NULL;
624 // check callback -----------------------------------------
626 //---------------------------------------------------------
631 SETTING_TRACE(" before ug_destory me ----<<<<<< ");
633 SETTING_TRACE(" after ug_destory me ----<<<<<< ");
635 setting_plugin_destroy(node);
638 elm_naviframe_item_pop(node->navi_bar);
640 SETTING_TRACE(" UG is NULL now ----<<<<<< ");
648 static void* group_func(void *data, xmlNode *xmlObj)
651 retv_if(!data || !xmlObj, NULL);
653 PluginNode* node = (PluginNode*)data;
654 Draw_Data *pd = node->pd;
656 // new code is recursive
657 const char *title = (char*)xmlGetProp(xmlObj, "title");
658 SETTING_TRACE (" >>> GROUP NAME : %s \n", title);
659 (void)setting_create_Gendial_field_titleItem(pd->scroller, &(itc_group_item), title, NULL);
664 static void* __link_list_cb(void *data, Evas_Object *obj, void *event_info)
667 retv_if(data == NULL, NULL);
668 retvm_if(event_info == NULL, NULL, "Invalid argument: event info is NULL");
669 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
670 elm_genlist_item_selected_set(item, 0);
671 Setting_GenGroupItem_Data *list_item =
672 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
674 xmlNode* xmlObj = data;
675 retv_if(!xmlObj, NULL);
676 const char *link_file = (char*)xmlGetProp(xmlObj, "value");
680 SETTING_TRACE_ERROR("Invalidate liked file");
683 char file[1024] = {0,};
684 snprintf(file, sizeof(file), "%s/%s", PLUGIN_CFG_DIR, link_file);
685 SETTING_TRACE("file:%s", file);
687 // Evas_Object* navi_bar, Evas_Object* win_main
688 PluginNode* plugin_node = setting_plugin_create( NULL, NULL );
689 setting_plugin_load(plugin_node, (const char *)file);
693 static void* __launch_list_cb(void *data, Evas_Object *obj, void *event_info)
696 retv_if(data == NULL, NULL);
697 retvm_if(event_info == NULL, NULL, "Invalid argument: event info is NULL");
698 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
699 elm_genlist_item_selected_set(item, 0);
700 Setting_GenGroupItem_Data *list_item =
701 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
703 xmlNode* xmlObj = data;
704 retv_if(!xmlObj, NULL);
705 const char *key_str = (char*)xmlGetProp(xmlObj, "id");
706 const char *title_str = (char*)xmlGetProp(xmlObj, "title");
707 const char *appid_str = (char*)xmlGetProp(xmlObj, "appid");
708 const char *operation_str = (char*)xmlGetProp(xmlObj, "operation");
711 service_h svc = NULL;
712 service_create(&svc);
713 if (!appid_str) appid_str = "";
714 if (!operation_str) operation_str = "";
716 service_set_app_id(svc, appid_str); // xml property – appid
717 service_set_operation(svc, operation_str); // property : operation
718 service_send_launch_request(svc, NULL, NULL);
719 service_destroy(svc);
724 static void* label_func(void *data, xmlNode *xmlObj)
727 retv_if(!data || !xmlObj, NULL);
728 PluginNode* node = (PluginNode*)data;
729 Draw_Data *pd = node->pd;
731 const char *title = (char*)xmlGetProp(xmlObj, "title");
733 Setting_GenGroupItem_Data *obj =
734 setting_create_Gendial_field_def(pd->scroller, &(itc_1text),
736 xmlObj, SWALLOW_Type_INVALID, NULL, NULL,
737 0, title, NULL, NULL);
742 static void* link_func(void *data, xmlNode *xmlObj)
745 retv_if(!data || !xmlObj, NULL);
746 PluginNode* node = (PluginNode*)data;
747 Draw_Data *pd = node->pd;
749 const char *key_str = (char*)xmlGetProp(xmlObj, "id");
750 Setting_GenGroupItem_Data * obj =
751 setting_create_Gendial_field_def(pd->scroller, &(itc_1text),
753 xmlObj, SWALLOW_Type_INVALID, NULL, NULL,
754 0, key_str, NULL, NULL);
759 static void* launch_func(void *data, xmlNode *xmlObj)
762 retv_if(!data || !xmlObj, NULL);
763 PluginNode* node = (PluginNode*)data;
764 Draw_Data *pd = node->pd;
766 const char *title_str = (char*)xmlGetProp(xmlObj, "title");
768 Setting_GenGroupItem_Data * obj =
769 setting_create_Gendial_field_def(pd->scroller, &(itc_1text),
771 xmlObj, SWALLOW_Type_INVALID, NULL, NULL,
772 0, title_str, NULL, NULL);
777 static void __slider_stop_cb(void *data, Evas_Object *obj,
780 ret_if(data == NULL || obj == NULL);
781 double val = elm_slider_value_get(obj);
782 SETTING_TRACE("val = %f", val);
783 Setting_GenGroupItem_Data *list_item = data;
784 ret_if(list_item->userdata == NULL);
786 xmlNode* xmlObj = list_item->userdata;
789 //apply the vconf changes after stopping moving slider..
790 list_item->chk_status = (int)(val + 0.5);
791 elm_slider_value_set(obj, list_item->chk_status);
793 SETTING_TRACE(" slider after ---> val = %d", (int) list_item->chk_status);
795 // int -> double -> xmlChar*
798 sprintf(buf, "%d", (int) list_item->chk_status);
799 newattr = xmlSetProp(xmlObj, "value", buf);
801 __send_int_msg(xmlObj, list_item->chk_status);
802 __cfg_file_write((Draw_Data *)list_item->belongs_to);
806 static void* slider_func(void *data, xmlNode *xmlObj)
809 retv_if(!data || !xmlObj, NULL);
810 PluginNode* node = (PluginNode*)data;
811 Draw_Data *pd = node->pd;
814 const char *title = (char*)xmlGetProp(xmlObj, "title");
816 SETTING_TRACE (" >>> [slider input] min=%s max=%s value=%s ",(char*)xmlGetProp(xmlObj, "min"), (char*)xmlGetProp(xmlObj, "max"), (char*)xmlGetProp(xmlObj, "value"));
818 int value = atoi((char*)xmlGetProp(xmlObj, "value"));
819 int min = atoi((char*)xmlGetProp(xmlObj, "min"));
820 int max = atoi((char*)xmlGetProp(xmlObj, "max"));
822 SETTING_TRACE ("[slider input] min=%d max=%d value=%d ", min, max, value);
824 setting_create_Gendial_itc("dialogue/1text.1icon.5", &(itc_layout));
825 Setting_GenGroupItem_Data *list_item =
826 setting_create_Gendial_field_def(pd->scroller, &(itc_layout), NULL,
828 SWALLOW_Type_LAYOUT_SLIDER,
829 IMG_SENSITIVITY_ICON_01,
830 IMG_SENSITIVITY_ICON_02, value,
833 list_item->win_main = NULL;
834 list_item->evas = NULL;
835 list_item->isIndicatorVisible = true;
836 list_item->slider_min = min;
837 list_item->slider_max = max;
838 list_item->userdata = xmlObj;
839 list_item->stop_change_cb = __slider_stop_cb;
840 list_item->belongs_to = (int)pd;
843 g_list_item = list_item;
845 return (void*)list_item;
848 static void __check_mouse_up_cb(void *data, Evas_Object *obj,
853 setting_retm_if(data == NULL, "Data parameter is NULL");
855 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
856 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
857 elm_genlist_item_selected_set(item, 0);
858 Setting_GenGroupItem_Data *list_item =
859 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
861 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
863 int old_status = elm_check_state_get(list_item->eo_check);
864 list_item->chk_status = !old_status;
865 elm_check_state_set(list_item->eo_check, list_item->chk_status);
867 xmlNode *xmlObj = data;
869 newattr = xmlSetProp(xmlObj, "state", xmlXPathCastNumberToString(list_item->chk_status));
871 __send_int_msg(xmlObj, list_item->chk_status);
872 __cfg_file_write((Draw_Data *)list_item->belongs_to);
876 static void __chk_btn_cb(void *data, Evas_Object *obj,
881 retm_if(data == NULL, "Data parameter is NULL");
882 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
884 xmlNode* xmlObj = list_item->userdata;
886 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
889 if (list_item->chk_status == 1) {
890 newattr = xmlSetProp(xmlObj, "value", "true");
891 } else if (list_item->chk_status == 0) {
892 newattr = xmlSetProp(xmlObj, "value", "false");
894 newattr = xmlSetProp(xmlObj, "value", "false");
897 const char *id = (char*)xmlGetProp(xmlObj, "id");
898 const char *title = (char*)xmlGetProp(xmlObj, "title");
899 //SETTING_TRACE(" >>>> id:%s , title:%s", id, title);
900 __send_int_msg(xmlObj, list_item->chk_status);
901 __cfg_file_write((Draw_Data *)list_item->belongs_to);
906 static void* checkbox_func(void *data, xmlNode *xmlObj)
909 retv_if(!data || !xmlObj, NULL);
911 PluginNode* node = (PluginNode*)data;
912 Draw_Data *pd = node->pd;
914 // [DATA] title, value
915 const char *title = (char*)xmlGetProp(xmlObj, "title");
918 char* value = (char*)xmlGetProp(xmlObj, "value");
922 if ( 0 == safeStrCmp(value, "true")) {
924 } else if ( 0 == safeStrCmp(value, "false")) {
927 ival = 0; // default : false (0)
930 // title, value, xmlObj
931 Setting_GenGroupItem_Data *list_item =
932 setting_create_Gendial_field_def(pd->scroller,
936 SWALLOW_Type_1TOGGLE,
943 list_item->userdata = xmlObj;
944 list_item->belongs_to = (int) pd;
945 SETTING_TRACE("pd:%p,list_item->belongs_to:%d", pd, list_item->belongs_to);
952 static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
955 retm_if(!data || !obj, "Data parameter is NULL");
957 //-------------------------------------------------------------------------------------------
958 Evas_Object *entry_container = data;
959 //whe entry unfocused, its guidetext will becomes "Input here"
960 elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
961 if (elm_entry_is_empty(obj))
962 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
963 elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
964 //-------------------------------------------------------------------------------------------
967 //setting_hide_input_pannel_cb(obj);
969 const char *entry_str = elm_entry_entry_get(obj);
970 char *entry_str_utf8 = NULL;
971 entry_str_utf8 = elm_entry_markup_to_utf8(entry_str);
973 Setting_GenGroupItem_Data *list_item = data;
975 // check minlentgh of the string
976 int min_length = list_item->minlength;
977 int entry_len = safeStrLen(entry_str_utf8);
979 SETTING_TRACE(" >>> minlength _ len : %d ", min_length);
980 SETTING_TRACE(" >>> entry _ len : %d ", entry_len);
982 SETTING_TRACE(" >>> 1");
983 if (entry_len < min_length) {
985 if (!list_item->notify) {
986 list_item->notify = setting_create_popup_without_btn(list_item, list_item->win_main,
987 NULL, _(EXCEED_MINLENGTH_LIMITATION_STR),
988 __error_popup_response_cb,
989 POPUP_INTERVAL, FALSE, FALSE);
990 elm_object_focus_set(list_item->eo_check, EINA_FALSE);
992 //postpone 2 seconds again
993 elm_popup_timeout_set(list_item->notify, POPUP_INTERVAL);
995 // elm_object_focus_set(obj, EINA_TRUE);
1000 xmlNode* xmlObj = list_item->userdata;
1002 FREE(entry_str_utf8);
1007 const char *title = (char*)xmlSetProp(xmlObj, "value",entry_str_utf8);
1009 __send_string_msg(xmlObj, entry_str_utf8);
1010 __cfg_file_write((Draw_Data *)list_item->belongs_to);
1012 FREE(entry_str_utf8);
1017 static void __editbox_list_cb(void *data, Evas_Object *obj,
1020 SETTING_TRACE_BEGIN;
1023 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1024 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1025 elm_genlist_item_selected_set(item, 0);
1026 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
1028 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
1029 if (!elm_object_focus_get(list_item->eo_check)) {
1030 elm_object_focus_set(list_item->eo_check, EINA_TRUE);
1032 Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(list_item->eo_check);
1033 setting_retm_if(imf_context == NULL, "imf_context is NULL");
1034 ecore_imf_context_input_panel_show(imf_context);
1039 static void __editbox_changed_cb(void *data, Evas_Object *obj,
1042 SETTING_TRACE_BEGIN;
1043 retm_if(!data || !obj, "Data parameter is NULL");
1044 retm_if(!elm_object_focus_get(obj), "Entry is not focused");
1046 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
1048 const char *entry_str = elm_entry_entry_get(obj);
1049 int entry_len = safeStrLen(entry_str);
1050 SETTING_TRACE("entry_str:[%s], length:%d", entry_str, entry_len);
1052 G_FREE(list_item->sub_desc);//release first
1053 list_item->sub_desc = (char *)g_strdup(entry_str);
1060 * @see also __editbox_changed_cb
1061 * @see also __entry_unfocus_cb
1063 static void* editbox_func(void *data, xmlNode *xmlObj)
1065 SETTING_TRACE_BEGIN;
1066 retv_if(!data || !xmlObj, NULL);
1068 PluginNode* node = (PluginNode*)data;
1069 Draw_Data *pd = node->pd;
1071 const char *title = (char*)xmlGetProp(xmlObj, "title");
1072 const char *key_str= (char*)xmlGetProp(xmlObj, "value");
1074 const char *minlength= (char*)xmlGetProp(xmlObj, "minlength");
1075 const char *maxlength= (char*)xmlGetProp(xmlObj, "maxlength");
1077 // MAXLENGTH HANDLER
1081 max_len = atoi(maxlength);
1082 SETTING_TRACE(" >> MAXLENGTH FILTER IS AVAILABLE !!!! maxlength = %d", max_len);
1088 min_len = atoi(minlength);
1089 SETTING_TRACE(" >> MINLENGTH FILTER IS AVAILABLE !!!! minlength = %d", min_len);
1092 Setting_GenGroupItem_Data *list_item = NULL;
1094 if (max_len == -1 && min_len == -1 )
1096 // without maxlength filter
1097 list_item = setting_create_Gendial_field_def(pd->scroller, &(itc_dialogue_editfield_title),
1099 pd, SWALLOW_Type_LAYOUT_ENTRY,
1100 NULL, NULL, 0, title, key_str,
1101 __editbox_changed_cb);
1104 // add max length filter
1105 list_item = setting_create_Gendial_field_entry_fo(
1107 &(itc_dialogue_editfield_title),
1110 SWALLOW_Type_LAYOUT_ENTRY,
1111 NULL, NULL, 0, title, key_str,
1112 __editbox_changed_cb,
1114 ELM_INPUT_PANEL_LAYOUT_NORMAL,
1124 list_item->userdata = xmlObj;
1125 list_item->stop_change_cb = __entry_unfocus_cb;
1126 list_item->belongs_to = (int)pd;
1129 list_item->win_main = node->win_main;
1136 static void __expanditem_func_sel_cb(void *data, Evas_Object *obj, void *event_info)
1138 SETTING_TRACE_BEGIN;
1140 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1141 Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
1142 Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
1143 elm_genlist_item_selected_set(subitem, 0);
1144 Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subitem);
1145 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
1146 ret_if(NULL == data_subItem || NULL == data_parentItem);
1148 elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
1150 data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
1151 elm_object_item_data_set(data_parentItem->item, data_parentItem);
1152 elm_genlist_item_update(data_parentItem->item);
1154 xmlNode* xmlObj = data_parentItem->userdata;
1158 //newattr = xmlSetProp(xmlObj, "string", data_parentItem->sub_desc);
1159 newattr = xmlSetProp(xmlObj, "value", data_parentItem->sub_desc);
1161 __send_string_msg(xmlObj, data_parentItem->sub_desc);
1162 __cfg_file_write((Draw_Data *)data_parentItem->belongs_to);
1166 static void __expanditem_func_exp_cb(void *data, Evas_Object *obj, void *event_info)
1168 ret_if(NULL == data || NULL == event_info);
1169 SETTING_TRACE_BEGIN;
1171 PluginNode* node = (PluginNode*)data;
1172 Draw_Data *pd = node->pd;
1174 Elm_Object_Item *parentItem = event_info; /* parent item */
1175 Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem); /* parent data */
1176 Evas_Object *scroller = elm_object_item_widget_get(parentItem);
1179 xmlNode *xmlObj = data_parentItem->userdata;
1180 char *value = (char*)xmlGetProp(xmlObj, "value");
1181 SETTING_TRACE(">>> value = %s", value);
1182 Evas_Object *rgd = NULL;
1184 if (xmlObj->children && !data_parentItem->rgd) {//to protect from entering repeatly
1185 xmlNode* cur = xmlObj->children;
1187 rgd = elm_radio_add(scroller);
1188 elm_radio_value_set(rgd, -1);
1191 char *subitem_title = NULL;
1192 int subitem_index = 0;
1196 // print out debug message
1197 if (data_parentItem->childs)
1200 Eina_List *li = data_parentItem->childs;
1203 Setting_GenGroupItem_Data* node = eina_list_data_get(li);
1205 //SETTING_TRACE(" <<< node->keyStr : %s >>> ", node->keyStr);
1208 li = eina_list_next(li);
1210 //SETTING_TRACE(" <<<how many : %d>>> ", howmany);
1213 if (data_parentItem->childs)
1215 eina_list_free(data_parentItem->childs);
1216 data_parentItem->childs = NULL;
1219 while (cur != NULL) {
1220 if (!xmlStrcmp(cur->name, (const xmlChar*)"expanditem")) {
1221 type = (char*)xmlGetProp(cur, "type");
1222 if (0 == safeStrCmp(type, "radio")) {
1223 subitem_title = (char*)xmlGetProp(cur, "title");
1224 Setting_GenGroupItem_Data *list_item =
1225 setting_create_Gendial_exp_sub_field(scroller,
1226 &(itc_1icon_1text_sub),
1227 __expanditem_func_sel_cb, NULL, parentItem,
1228 SWALLOW_Type_1RADIO, rgd,
1230 subitem_title, NULL);
1233 if (0 == safeStrCmp(value, subitem_title)) {
1234 sel_idx = subitem_index;
1235 SETTING_TRACE("%d is selected in Radio Group", sel_idx);
1237 SETTING_TRACE(" eina list add >>> value = %s, subitem_title = %s ", value, subitem_title);
1238 data_parentItem->childs = eina_list_append(data_parentItem->childs, list_item);
1242 SETTING_TRACE("invalid type[:%s]", type);
1249 elm_radio_value_set(rgd, sel_idx);
1250 data_parentItem->rgd = rgd;//protecting condition
1255 static void __expanditem_func_smart_cb(void *data, Evas_Object *obj, void *event_info)
1257 ret_if(data == NULL || event_info == NULL);
1258 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1259 Setting_GenGroupItem_Data *data_item = elm_object_item_data_get(item);
1260 char *cb_type = data;
1262 if (0 == safeStrCmp(cb_type, "contracted")) {
1263 data_item->rgd = NULL;
1264 elm_genlist_item_subitems_clear(item);
1269 static void* settings_func(void *data, xmlNode *xmlObj)
1271 SETTING_TRACE_BEGIN;
1272 retv_if(!data || !xmlObj, NULL);
1273 PluginNode* node = (PluginNode*)data;
1276 count = node->nitems;
1278 if (count == 1) // if there's <settings> only
1280 SETTING_TRACE("there's only <settings>");
1281 setting_func(data, xmlObj);
1287 static void __plugin_genlist_unrealized_cb(void* data,Evas_Object* obj, void* event_info)
1289 SETTING_TRACE_BEGIN;
1290 ret_if(data == NULL);
1292 Elm_Object_Item *item = (Elm_Object_Item*)event_info;
1293 Setting_GenGroupItem_Data *node = (Setting_GenGroupItem_Data *)elm_object_item_data_get(item);
1294 ret_if(node== NULL);
1296 // SETTING_TRACE("keyStr : %s ", node->keyStr);
1297 // item_to_update->childs)
1301 eina_list_free(node->childs);
1302 node->childs = NULL;
1307 // 1st create a window
1308 // 2nd push a window
1309 //--------------------------------------------------------
1310 static void* setting_func(void *data, xmlNode *xmlObj)
1312 SETTING_TRACE_BEGIN;
1313 retv_if(!data || !xmlObj, NULL);
1315 PluginNode* node = (PluginNode*)data;
1316 Draw_Data *pd = node->pd;
1319 const char *title = (char*)xmlGetProp(xmlObj, "title");
1322 SETTING_TRACE("before setting_create_layout_navi_bar_genlist");
1325 pd->scroller = elm_genlist_add(node->win_main);
1326 retvm_if(pd->scroller == NULL, NULL,
1327 "Cannot set scroller object as contento of layout");
1328 elm_object_style_set(pd->scroller, "dialogue");
1329 elm_genlist_clear(pd->scroller); /* first to clear list */
1331 evas_object_smart_callback_add(pd->scroller, "unrealized", __plugin_genlist_unrealized_cb, node);
1333 SETTING_TRACE("_(title):%s", _(title));
1335 if (node->ug == NULL)
1337 setting_push_layout_navi_bar(
1339 _("IDS_COM_BODY_BACK"), NULL, NULL,
1340 ___click_softkey_back_cb,
1343 node->navi_bar, NULL);
1345 node->ly_main = setting_create_layout_navi_bar(node->win_main_layout, node->win_main,
1347 _("IDS_COM_BODY_BACK"), NULL, NULL,
1348 ___click_softkey_back_cb,
1351 &node->navi_bar, NULL);
1353 SETTING_TRACE("after setting_create_layout_navi_bar_genlist");
1358 static void* expanditem_func(void *data, xmlNode *xmlObj)
1360 // DO NOTHING - expandlist draws this area
1364 static void* expandlist_func(void *data, xmlNode *xmlObj)
1366 SETTING_TRACE_BEGIN;
1367 retv_if(!data || !xmlObj, NULL);
1369 PluginNode* node = (PluginNode*)data;
1370 Draw_Data *pd = node->pd;
1372 const char *key_str = (char*)xmlGetProp(xmlObj, "title");
1373 const char *value = (char*)xmlGetProp(xmlObj, "value"); // string -> value
1375 setting_enable_expandable_genlist(pd->scroller, data, __expanditem_func_exp_cb, __expanditem_func_smart_cb);
1376 Setting_GenGroupItem_Data *list_item =
1377 setting_create_Gendial_exp_parent_field(pd->scroller,
1378 &(itc_2text_3_parent),
1380 SWALLOW_Type_INVALID,
1384 list_item->userdata = xmlObj;
1385 list_item->belongs_to = (int)pd;
1386 list_item->childs = NULL; /* init */
1392 static int __node_walk_check(PluginNode* context, xmlNode* cur, int* pcount)
1394 //SETTING_TRACE_BEGIN;
1395 Draw_Data *pd = context->pd;
1397 retv_if(!context->ui_list, -1);
1399 xmlNode *cur_node = NULL;
1400 for (cur_node = cur; cur_node;cur_node = cur_node->next) {
1401 if (cur_node->type == XML_ELEMENT_NODE) {
1402 //SETTING_TRACE("node type : %s id= %s", cur_node->name,xmlGetProp(cur_node, "id"));
1405 __node_walk_check(context, cur_node->children, pcount); /* RECURSIVE */
1410 static int __node_walker(PluginNode* context, xmlNode* cur)
1412 //SETTING_TRACE_BEGIN;
1413 Draw_Data *pd = context->pd;
1416 retv_if(!context->ui_list, -1);
1418 xmlNode *cur_node = NULL;
1419 for (cur_node = cur; cur_node;cur_node = cur_node->next) {
1420 if (cur_node->type == XML_ELEMENT_NODE) {
1421 // SETTING_TRACE("node type : %s id= %s", cur_node->name,xmlGetProp(cur_node, "id"));
1422 drawer_fp fp = __drawer_find(cur_node->name);
1426 void* vret = fp(context, cur_node); // draw it
1430 Setting_GenGroupItem_Data* genlist_node = (Setting_GenGroupItem_Data* )vret;
1431 //SETTING_TRACE("add node to Eina List name : %s, id : ", cur_node->name, xmlGetProp(cur_node, "id"));
1432 // add it to the hash table create before.
1435 char* key_name = xmlGetProp(cur_node, "id");
1436 eina_hash_add(context->ui_list, strdup(key_name),(void*)genlist_node);
1439 SETTING_TRACE(" >>>> fp is NULL ");
1442 __node_walker(context, cur_node->children); /* RECURSIVE */
1448 * @param id_str [in] "id"
1449 * @param value [in] value to be udpated
1450 * @see __expanditem_func_sel_cb
1452 static int __node_finder(PluginNode* context, xmlNode* cur, char* id_str, char* value, bool* is_end)
1454 SETTING_TRACE_BEGIN;
1455 xmlNode *cur_node = NULL;
1459 SETTING_TRACE("context is NULL - it's error CONDITION ");
1463 retv_if(!context->ui_list, -1);
1464 if (*is_end == true) return 0;
1466 for (cur_node = cur; cur_node;cur_node = cur_node->next) {
1467 if (cur_node->type == XML_ELEMENT_NODE) {
1469 char* id_name = (char*)xmlGetProp(cur_node, "id");
1470 if ( id_name && 0 == strcmp(id_str, id_name))
1472 SETTING_TRACE("FOUND >>>> %s", id_name);
1473 // cur_node - update xml code
1474 xmlAttrPtr newattr = xmlSetProp(cur_node, "value", value);
1476 //-----------------------------------------------------------
1479 if ( 0 == strcmp (cur_node->name, "integer"))
1481 SETTING_TRACE(">>>>> UPDATE SLIDER CONTROL %x --- %s ",context->ui_list, id_name);
1482 Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1485 item_to_update->chk_status = atoi(value);
1486 SETTING_TRACE(">>> o-------------0 SLIDER VALUE = %d ", item_to_update->chk_status);
1488 elm_object_item_data_set(item_to_update->item, item_to_update);
1489 elm_genlist_item_update(item_to_update->item);
1491 SETTING_TRACE("item_to_update is NULL");
1495 if ( 0 == strcmp (cur_node->name, "bool"))
1497 SETTING_TRACE(">>>>> UPDATE TOGGLE CONTROL pluginpath:%s, ---- %x --- %s ", context->plugin_path, context->ui_list, id_name);
1498 Setting_GenGroupItem_Data* item_to_update = NULL;
1499 item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1502 item_to_update->chk_status = atoi(value);
1503 SETTING_TRACE(">>> o-------------0 TOGGLE VALUE = %d ", item_to_update->chk_status);
1505 elm_object_item_data_set(item_to_update->item, item_to_update);
1506 elm_genlist_item_update(item_to_update->item);
1508 SETTING_TRACE("item_to_update is NULL");
1511 // case : edit control
1512 if ( 0 == strcmp (cur_node->name, "string"))
1514 SETTING_TRACE(">>>>> UPDATE EDIT CONTROL CONTROL %x --- %s ",context->ui_list, id_name);
1515 Setting_GenGroupItem_Data* item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1518 char* old_string = item_to_update->sub_desc;
1519 item_to_update->sub_desc = strdup(value);
1520 SETTING_TRACE(">>> o-------------0 STRING VALUE = %s ", value);
1524 elm_object_item_data_set(item_to_update->item, item_to_update);
1525 elm_genlist_item_update(item_to_update->item);
1528 SETTING_TRACE("item_to_update is NULL");
1531 // case : expand list
1537 //-----------------------------------------------------------
1538 if ( 0 == strcmp (cur_node->name, "expandlist"))
1541 SETTING_TRACE(">>>>> UPDATE EXPAND LIST CONTROL %x --- %s ",context->ui_list, id_name);
1542 Setting_GenGroupItem_Data* item_to_update = NULL;
1543 item_to_update = (Setting_GenGroupItem_Data*)eina_hash_find(context->ui_list, id_name);
1546 char* old_string = item_to_update->sub_desc;
1547 item_to_update->sub_desc = strdup(value);
1548 SETTING_TRACE(">>> o-------------0 EXPAND LIST VALUE = %s ", value);
1552 elm_object_item_data_set(item_to_update->item, item_to_update);
1553 elm_genlist_item_update(item_to_update->item);
1555 // TODO: need to update child elements
1556 // item_to_update->childs ---> expanded list
1559 // there should have 4 sub items.
1560 //-----------------------------------------------------
1561 // has it already freed by someone?
1562 //-----------------------------------------------------
1563 if (item_to_update->childs)
1566 Eina_List *li = item_to_update->childs;
1569 Setting_GenGroupItem_Data* node = eina_list_data_get(li);
1571 li = eina_list_next(li);
1573 SETTING_TRACE(" expandlist -- how many items are there? : %d ", howmany2);
1576 if (item_to_update->childs)
1578 Eina_List *li = item_to_update->childs;
1579 int radio_index = 0;
1582 Setting_GenGroupItem_Data* node = eina_list_data_get(li);
1584 if (node->item && node->keyStr)
1586 // do something more
1587 // SETTING_TRACE(">>> RADIO LIST STRING VALUE = %s ", node->keyStr);
1588 // set position of radio button
1589 if (value && strcmp(node->keyStr, value) == 0) // << CRAAH !!!!
1591 elm_radio_value_set(node->rgd, radio_index);
1594 SETTING_TRACE(">>> node has unproper values - Setting_GenGroupItem_Data");
1596 elm_object_item_data_set(item_to_update->item, item_to_update);
1597 elm_genlist_item_update(item_to_update->item);
1600 li = eina_list_next(li);
1606 SETTING_TRACE("item_to_update is NULL");
1614 __node_finder(context, cur_node->children, id_str, value, is_end); /* RECURSIVE */
1619 static unsigned int _plugin_string_key_length(const char*key)
1624 return (int)strlen(key) + 1;
1627 static int _plugin_string_key_cmp(const char* key1, int key1_length,
1628 const char* key2, int key2_length)
1630 return strcmp(key1, key2);
1633 static void _plugin_entry_free_cb(void* data)
1636 // this code already have done in genlist_unrealized
1637 Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data;
1640 eina_list_free(node->childs);
1641 node->childs = NULL;
1646 PluginNode* setting_plugin_create(Evas_Object* navi, Evas_Object* win)
1648 PluginNode *plugin = calloc(1, sizeof(PluginNode));
1649 setting_retvm_if(!plugin, -1, "Create PluginNode obj failed");
1650 Draw_Data *pd = calloc(1, sizeof(Draw_Data));
1656 setting_retvm_if(!pd, -1, "Create Draw_Data obj failed");
1658 plugin->ly_main = NULL;
1660 plugin->navi_bar = navi;
1661 plugin->win_main = win;
1663 plugin->ui_list = eina_hash_new(EINA_KEY_LENGTH(_plugin_string_key_length),
1664 EINA_KEY_CMP(_plugin_string_key_cmp),
1665 EINA_KEY_HASH(eina_hash_superfast),
1666 _plugin_entry_free_cb,
1672 void setting_plugin_destroy(PluginNode* node)
1674 SETTING_TRACE_BEGIN;
1676 SETTING_TRACE("node is NOT NULL")
1678 SETTING_TRACE("node->pd is NOT NULL")
1679 if(node->pd->doc != NULL) {
1680 xmlSaveFormatFile(node->plugin_path, node->pd->doc, 1);
1681 xmlFreeDoc(node->pd->doc);
1682 node->pd->doc = NULL;
1683 SETTING_TRACE("__cfg_file_write successful");
1690 if (node->ui_list) {
1691 eina_hash_free(node->ui_list);
1692 node->ui_list = NULL;
1701 static Eina_Bool _plugin_foreach_cb(const Eina_Hash *hash, const void*key, void* data, void* fdata)
1703 Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) data;
1704 SETTING_TRACE("%s --- %s ", (char*)key, node->keyStr);
1709 void setting_plugin_debug(PluginNode* context)
1711 // SETTING_TRACE("HASH TABLE -------------------------------------");
1712 if (context->ui_list) {
1713 eina_hash_foreach(context->ui_list,_plugin_foreach_cb, NULL);
1715 // SETTING_TRACE("HASH TABLE -------------------------------------");
1719 void setting_plugin_update(PluginNode* context)
1721 Eina_List *li = context->ui_list;
1724 Setting_GenGroupItem_Data* node = (Setting_GenGroupItem_Data*) eina_list_data_get(li);
1726 // SETTING_TRACE(" ---> keyStr : %s , swallow type : %d ", node->keyStr, node->swallow_type);
1727 Setting_GenGroupItem_Data* item_to_update = NULL;
1728 item_to_update = node;
1729 elm_object_item_data_set(item_to_update->item, item_to_update);
1730 elm_genlist_item_update(item_to_update->item);
1732 li = eina_list_next(li);
1740 int setting_plugin_load(PluginNode* node, const char *cfg_file)
1742 SETTING_TRACE("cfg_file:%s", cfg_file)
1743 if (isEmptyStr(cfg_file) || 0 != access(cfg_file, R_OK|W_OK|F_OK ))
1745 SETTING_TRACE_ERROR(" error occured : access = %d ", errno);
1748 node->pd->cfg_file = cfg_file;
1750 node->pd->doc = xmlParseFile(cfg_file);
1751 node->pd->root = xmlDocGetRootElement(node->pd->doc);
1753 // signal filter change
1754 //void* user_data = (void*)g_main_ad;
1755 void* user_data = (void*)node;
1758 dbus_error_init(&error);
1759 char rule[MAX_LOCAL_BUFSIZE + 1] = {0,};
1760 bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
1763 SETTING_TRACE("Fail to connect to the D-BUS daemon: %s", error.message);
1764 dbus_error_free(&error);
1769 snprintf(rule, MAX_LOCAL_BUFSIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH, DBUS_SIGNAL_INTERFACE);
1770 dbus_bus_add_match(bus, rule, &error);
1771 if (dbus_error_is_set(&error))
1773 SETTING_TRACE("Fail to rule set; %s", error.message);
1774 dbus_bus_remove_match(bus, rule, &error);
1775 dbus_error_free(&error);
1776 dbus_connection_close(bus);
1782 if (dbus_connection_add_filter(bus, __signal_filter, user_data, NULL) == FALSE)
1784 SETTING_TRACE("Fail to add filter ----- ");
1785 dbus_bus_remove_match(bus, rule, &error);
1786 dbus_error_free(&error);
1787 dbus_connection_close(bus);
1793 __node_walk_check(node, node->pd->root, &count);
1794 SETTING_TRACE(" node count : %d ", count);
1795 node->nitems = count;
1796 __node_walker(node, node->pd->root);
1799 //setting_plugin_debug(node);