3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.0 (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-search.h>
21 #include <eina_list.h>
25 #include <setting-debug.h>
26 #include <setting-cfg.h>
27 #include <setting-common-general-func.h>
28 #include <setting-common-draw-widget.h>
35 static char *__search_label_get(void *data, Evas_Object *obj, const char *part);
36 static char *___add_tag_for_search(char *target, char *searcher);
38 static Evas_Object *__search_icon_get(void *data, Evas_Object *obj, const char *part);
39 static void __search_item_del(void *data, Evas_Object *obj);
40 static Evas_Object *__no_result_icon_get(void *data, Evas_Object *obj, const char *part);
43 * plain list item style
47 const Elm_Genlist_Item_Class itc_no_reult = {
48 .item_style = "1icon/with_no_line",
49 .func.text_get = NULL,
50 .func.content_get = __no_result_icon_get,
51 .func.state_get = NULL,
52 .func.del = __search_item_del,
55 #define DEFINE_ITC2(style, name) \
56 EXPORT_PUBLIC const Elm_Genlist_Item_Class name = {\
58 .func.text_get = __search_label_get,\
59 .func.content_get = __search_icon_get,\
60 .func.state_get = NULL,\
61 .func.del = __search_item_del,\
64 DEFINE_ITC2("dialogue/1text.1icon.3.tb", g_search_genlist_ts);
65 DEFINE_ITC2("dialogue/newset.1text.2icon.4.tb", g_search_genlist_ts_toggle);
66 DEFINE_ITC2("dialogue/newset.1text.2icon.4.divider.tb", g_search_genlist_ts_divided_toggle);
69 char *___add_tag_for_search(char *target, char *searcher)
72 const char *pre = NULL;
73 char buf[BUF_SIZE] = {0,};
74 char str_tag_added[BUF_SIZE] = {0,};
77 p = (const char *)strcasestr(pre, searcher);
79 /* append characters before matched string */
82 strncat(buf, pre, p - pre);
83 sncat(str_tag_added, BUF_SIZE, buf);
86 sncat(str_tag_added, BUF_SIZE, "<match>");
88 strncat(buf, p, strlen(searcher));
89 sncat(str_tag_added, BUF_SIZE, buf);
90 sncat(str_tag_added, BUF_SIZE, "</match>");
91 /* set pointer after matched string */
92 pre = p + strlen(searcher);
94 sncat(str_tag_added, BUF_SIZE, pre);
95 return strdup(str_tag_added);
103 * Callback function used for get label as member in genlist item
105 * @param[in] data data used for this function
106 * @param[in] obj object which caused this function
107 * @param[in] part part name of the label member in genlist item
108 * @return pointer to content of label
111 char *__search_label_get(void *data, Evas_Object *obj, const char *part)
113 /*SETTING_TRACE_BEGIN; */
114 /*SETTING_TRACE("part : %s", part); */
115 ListItemObject *item = (ListItemObject *)data;
117 char buf[BUF_SIZE] = "";
119 char *tag_str = NULL;
121 retv_if(NULL == part, NULL);
123 if (!strcmp(part, "elm.text.1")) {
124 snprintf(buf, BUF_SIZE, "%s", "elm.text.1"); /* print out test message */
125 } else if (!strcmp(part, "elm.text.2")) {
126 snprintf(buf, BUF_SIZE, "%s", "elm.text.2"); /* print out test message */
127 } else if (!strcmp(part, "elm.text.3")) {
128 snprintf(buf, BUF_SIZE, "%s", "elm.text.3"); /* print out test message */
129 } else if (!strcmp(part, "elm.text")) {
131 /*snprintf(buf, BUF_SIZE, "[%s] - %s", item->type, item->title); // print out "[type] - title" */
132 snprintf(buf, BUF_SIZE, "%s", item->title); /* print out "[type] - title" */
135 /*tag_str = ___add_tag_for_search(item->title, g_ad->search_text); */
136 tag_str = ___add_tag_for_search(item->title, "");
137 snprintf(buf, BUF_SIZE, "%s", tag_str); /* print out "[type] - title" */
146 /*--------------------------------------------------- */
147 /* wifi -> go to wifi after calling the set_state */
150 /*--------------------------------------------------- */
151 static void ___toggle_chg_cb(void *data, Evas_Object *obj, void *event_info)
157 static Evas_Object *__no_result_icon_get(void *data, Evas_Object *obj, const char *part)
160 setting_retvm_if(!data || !obj, NULL, "!data || !obj");
162 if (!safeStrCmp(part, "elm.icon")) {
163 Evas_Object *box = elm_box_add(obj);
165 int rot = elm_win_rotation_get(obj);
166 SETTING_TRACE_DEBUG("....change_ang:%d", rot);
167 if (APP_DEVICE_ORIENTATION_0 == rot
168 || APP_DEVICE_ORIENTATION_180 == rot) {
170 Evas_Object *separator = setting_create_blank_rect_customize(box, 1, 270);
171 elm_box_pack_end(box, separator);
174 Evas_Object *sub_layout = elm_layout_add(obj);
175 elm_layout_theme_set(sub_layout, "layout", "nocontents", "search");
176 evas_object_size_hint_weight_set(sub_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
177 evas_object_size_hint_align_set(sub_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
179 elm_object_part_text_set(sub_layout, "elm.text", _("IDS_ST_BODY_NO_RESULTS_FOUND"));
180 setting_resize_object(sub_layout, 500, 500);
181 evas_object_show(sub_layout);
182 elm_box_pack_end(box, sub_layout);
190 * Get icon of given part in genlist item
192 * @param[in] data Data used in this function
193 * @param[in] obj Evas_Object who emit this event
194 * @param[in] part Name of the part in genlist item
196 * @return NULL if meet error
197 * Pointer to new icon
200 Evas_Object *__search_icon_get(void *data, Evas_Object *obj, const char *part)
202 /*SETTING_TRACE_BEGIN; */
203 retv_if(NULL == part, NULL);
204 ListItemObject *item = (ListItemObject *)data;
206 SETTING_TRACE(" genlist :: part : (%s) ", part);
208 retv_if(!item || !obj || !item->title, NULL);
209 if (!safeStrCmp(part, "elm.icon") || !safeStrCmp(part, "elm.icon.1")) {
210 Evas_Object *icon = elm_icon_add(obj);
212 char *icon_path = NULL;
213 icon_path = IMG_SETTING;
214 if (item->icon_path) {
215 if (safeStrCmp(item->icon_path, "") == 0)
216 icon_path = IMG_SETTING;
218 icon_path = item->icon_path;
220 /*SET//TING_TRACE("item->title:%s", item->title); */
221 /*SETTING_TRACE("item->title2:%s", item->title2); // plain text */
222 /*SETTING_TRACE("item->iconpath:%s", icon_path); // plain text */
223 elm_image_file_set(icon, icon_path, NULL);
224 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
226 Evas_Object *ly_outer = elm_layout_add(obj);
227 elm_layout_file_set(ly_outer, SETTING_THEME_EDJ_NAME, "nocontents");
228 evas_object_show(ly_outer);
230 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(63), ELM_SCALE_SIZE(63));
231 evas_object_size_hint_max_set(icon, 63, 63);
232 elm_object_part_content_set(ly_outer, "contents", icon);
237 } else if (!safeStrCmp(part, "elm.icon.2")) {
238 Evas_Object *toggle = elm_check_add(obj);
240 if (item->fp_check_btn_cb)
241 evas_object_smart_callback_add(toggle, "changed", item->fp_check_btn_cb, item);
243 evas_object_smart_callback_add(toggle, "changed", ___toggle_chg_cb, item);
245 /* get state------------------------------------- */
246 /* if it is the 1'st depth item, get the pnode */
247 /* display UG need to get the pointer */
249 Setting_Cfg_Node_T *pnode = get_cfg_node_by_keystr(item->title2);
251 Cfg_Item_State state = Cfg_Item_Error;
252 if (pnode && pnode->tfunc && pnode->tfunc->get_item_state) {
253 pnode->tfunc->get_item_state(&state, NULL);
254 } else if (!pnode && item->viewname) {
255 /* if get_cfg_node_by_keystr returns NULL, search for UG's keyword */
256 int ret = setting_search_get_module_item_state(item->title2, item->viewname, &state, NULL);
257 SETTING_TRACE("---------------------------------------");
258 SETTING_TRACE(" >>> ret : %d, state : %d <<< ", ret, state);
259 SETTING_TRACE("---------------------------------------");
262 if (state == Cfg_Item_On)
263 elm_check_state_set(toggle, EINA_TRUE);
265 elm_check_state_set(toggle, EINA_FALSE);
266 /* get state------------------------------------- */
268 evas_object_propagate_events_set(toggle, 0);
269 elm_object_style_set(toggle, "on&off");
271 evas_object_pass_events_set(toggle, 1);
273 evas_object_show(toggle);
282 * used for genlist item style - callback function destroying an item of list
285 void __search_item_del(void *data, Evas_Object *obj)
287 /*SETTING_TRACE_BEGIN; */
288 ListItemObject *item = (ListItemObject *)data;
293 FREE(item->viewname);
294 FREE(item->fieldname);
295 FREE(item->icon_path);
296 __BACK_POINTER_UNSET(item); /*for pointer safety */
302 static void sql_stmt(sqlite3 *db, const char *stmt)
307 ret = sqlite3_exec(db, stmt, 0, 0, &errmsg);
308 if (ret != SQLITE_OK) {
309 SETTING_TRACE("Error in statement: %s [%s].", stmt, errmsg);
310 } else if (ret == SQLITE_OK) {
311 SETTING_TRACE("OK running : (%s) --- [%s].", stmt, errmsg);
316 int setting_searchdb_open(sqlite3 **ppdb)
319 /*char *zErrMsg = NULL; */
321 /*char query[512]; */
322 rc = sqlite3_open(SEARCH_DB_PATH, ppdb);
324 SETTING_TRACE_ERROR("Can't open database: %s", sqlite3_errmsg(*ppdb));
325 sqlite3_close(*ppdb);
328 SETTING_TRACE("open database - OK - %d ", *ppdb);
335 void setting_searchdb_close(sqlite3 *db)
342 void setting_add_db_search_clean(sqlite3 *db)
345 sql_stmt(db, "BEGIN");
346 char *query = "DELETE FROM setting_search";
349 sql_stmt(db, "COMMIT");
354 * @brief add index to DB
357 * @param locale locale name (ko_KR, en_US ...)
358 * @param keystr string name (ex. Wi-Fi)
359 * @param infostr UG path, memta info, URL
360 * @param data_type 0, 1, 2, 3, 4 ... type
362 * @param fieldname ""
363 * @param icon_path ""
366 void setting_add_db_search_index(sqlite3 *db, char *locale, char *keystr, char *infostr, int data_type, char *viewname, char *fieldname, char *icon_path)
369 sql_stmt(db, "BEGIN");
370 /*char query[1024]; */
372 /*snprintf(query, sizeof(query), "INSERT INTO setting_search VALUES (%Q, %Q, %Q, %d, NULL, %Q, %Q, %Q)", */
373 /* locale, fieldname, viewname, data_type, keystr, infostr, icon_path); */
374 char *query = sqlite3_mprintf("INSERT INTO setting_search VALUES (%Q, %Q, %Q, %d, NULL, %Q, %Q, %Q)",
375 locale, fieldname, viewname, data_type, keystr, infostr, icon_path);
379 sql_stmt(db, "COMMIT");
384 int setting_invoke_search_db_function(char *ug_name, app_control_h service, void *ext, char **ppapplocale)
386 SETTING_TRACE("Enter %s with ug_name:%s", __FUNCTION__, ug_name);
387 int (*search_plugin)(app_control_h pair, void **ptr, char **applocale);
388 int ret = OPERATE_LIB_SUCESS;
390 /*1.first do exist-checking in /opt/ug/lib */
391 char ug_file[PATH_MAX + 1];
392 snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH, ug_name);
394 if (stat(ug_file, &st) != 0) {
396 /*2.if it does not exit in /opt/ug/lib, then do exist-checking in /usr/ug/lib */
397 memset(ug_file, 0x00, PATH_MAX + 1);
398 snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH_USR, ug_name);
399 if (stat(ug_file, &st) != 0) {
400 /*both not exist,skip it */
401 SETTING_TRACE_ERROR(" libug-%s.so is *NOT* present, so skip it..\n", ug_name);
402 return OPERATE_LIB_SUCESS;
405 /*------------------------------------------------------------------------------------- */
406 void *handle = dlopen(ug_file, RTLD_LAZY);
408 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", dlerror());
409 return LOAD_LIB_FAILED;
413 search_plugin = dlsym(handle, "setting_plugin_search_init");
414 if ((error = dlerror()) != NULL) {
415 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", error);
417 return UNDEFINED_LIB_SYMBOL;
421 ret = (*search_plugin)(service, ext, ppapplocale); /* CALL */
422 SETTING_TRACE(" after calling PLUGIN WITH -APP LOCALE ID = %s", *ppapplocale);
424 if (ret < 0) ret += UNDEFINED_LIB_SYMBOL;/*from -2 on */
433 int setting_search_set_module_item_state(char *keyword, char *ug_name, Cfg_Item_State item_state, cfg_func_table *pops)
435 SETTING_TRACE("Enter %s with ug_name:%s", __FUNCTION__, ug_name);
436 /* int setting_plugin_search_query_ops(char* str_id, void** tfunc_obj) */
437 int (*query_ops)(char *str_id, void **tfunc_obj);
438 int ret = OPERATE_LIB_SUCESS;
440 /*1.first do exist-checking in /opt/ug/lib */
441 char ug_file[PATH_MAX + 1];
442 snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH, ug_name);
444 if (stat(ug_file, &st) != 0) {
446 /*2.if it does not exit in /opt/ug/lib, then do exist-checking in /usr/ug/lib */
447 memset(ug_file, 0x00, PATH_MAX + 1);
448 snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH_USR, ug_name);
449 if (stat(ug_file, &st) != 0) {
450 /*both not exist,skip it */
451 SETTING_TRACE_ERROR(" libug-%s.so is *NOT* present, so skip it..\n", ug_name);
452 return OPERATE_LIB_SUCESS;
455 /*------------------------------------------------------------------------------------- */
456 void *handle = dlopen(ug_file, RTLD_LAZY);
458 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", dlerror());
459 return LOAD_LIB_FAILED;
463 query_ops = dlsym(handle, "setting_plugin_search_query_ops");
464 if ((error = dlerror()) != NULL) {
465 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", error);
467 return UNDEFINED_LIB_SYMBOL;
470 if (query_ops && keyword) {
471 /* OPS RETURNS NULL, IT'S PROBLEM */
472 cfg_func_table *ops = NULL;
473 /*ret = (*query_ops) ("MOCK_STR_ID", &ops); */
474 ret = (*query_ops)(keyword, (void **)&ops); /* CALL */
475 SETTING_TRACE(" ops = %x ", ops);
476 /*------------------------------------------------------------- */
477 /* ACTUAL PROCESSING */
478 /*------------------------------------------------------------- */
479 if ((ops) && (ops)->set_item_state) {
480 (ops)->set_item_state(item_state, NULL, NULL);
482 SETTING_TRACE(" ---> ppops.set_item_state(stat, NULL); -- after, sstat : %d", item_state);
483 /*------------------------------------------------------------- */
485 if (ret < 0) ret += UNDEFINED_LIB_SYMBOL;/*from -2 on */
494 int setting_search_get_module_item_state(char *keyword, char *ug_name, Cfg_Item_State *pstat, cfg_func_table *pops)
496 SETTING_TRACE("Enter %s with ug_name:%s", __FUNCTION__, ug_name);
497 /* int setting_plugin_search_query_ops(char* str_id, void** tfunc_obj) */
498 int (*query_ops)(char *str_id, void **tfunc_obj);
499 int ret = OPERATE_LIB_SUCESS;
501 /*1.first do exist-checking in /opt/ug/lib */
502 char ug_file[PATH_MAX + 1];
503 snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH, ug_name);
505 if (stat(ug_file, &st) != 0) {
507 /*2.if it does not exit in /opt/ug/lib, then do exist-checking in /usr/ug/lib */
508 memset(ug_file, 0x00, PATH_MAX + 1);
509 snprintf(ug_file, PATH_MAX, "%s/libug-%s.so", SETTING_UG_PATH_USR, ug_name);
510 if (stat(ug_file, &st) != 0) {
511 /*both not exist,skip it */
512 SETTING_TRACE_ERROR(" libug-%s.so is *NOT* present, so skip it..\n", ug_name);
513 return OPERATE_LIB_SUCESS;
516 /*------------------------------------------------------------------------------------- */
517 void *handle = dlopen(ug_file, RTLD_LAZY);
519 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", dlerror());
520 return LOAD_LIB_FAILED;
524 query_ops = dlsym(handle, "setting_plugin_search_query_ops");
525 if ((error = dlerror()) != NULL) {
526 SETTING_TRACE_ERROR(" >>>>>>>>>>> %s", error);
528 return UNDEFINED_LIB_SYMBOL;
531 if (query_ops && keyword) {
532 /* OPS RETURNS NULL, IT'S PROBLEM */
533 cfg_func_table *ops = NULL;
534 /*ret = (*query_ops) ("MOCK_STR_ID", &ops); /* CALL * / */
535 ret = (*query_ops)(keyword, (void **)&ops); /* CALL */
536 SETTING_TRACE(" ops = %x ", ops);
537 /*------------------------------------------------------------- */
538 /* ACTUAL PROCESSING */
539 /*------------------------------------------------------------- */
540 if ((ops) && (ops)->get_item_state)
541 (ops)->get_item_state(pstat, NULL);
543 SETTING_TRACE(" ---> ppops.get_item_state(pstat, NULL); -- after, pstat : %d", *pstat);
544 /*------------------------------------------------------------- */
546 if (ret < 0) ret += UNDEFINED_LIB_SYMBOL;/*from -2 on */
555 int __setting_init_search_index_module()
558 /* test, adding sql query */
560 setting_searchdb_open(&db);
561 SETTING_TRACE("search db = %d", db);
563 char *backup_langset = vconf_get_str(VCONFKEY_LANGSET);
564 char *ug_name_arr[] = {
565 "setting-display-efl", /* finish */
566 "setting-profile-efl", /* finish */
567 "setting-call-efl", /* NO CODE !!! -- put node here for testing */
568 "setting-cloud-efl", /*finish */
569 "quickcommand-setting-efl", /* finish */
570 "setting-mobileap-efl", /* finish */
571 "lockscreen-options", /* finish */
572 "email-setting-efl", /* NO CODE !!! */
573 "emergency-msg-setting-efl", /* NO CODE !!! */
574 "msg-setting-efl", /* NO CODE !!! */
575 "setting-allshare-cast-efl", /* NO CODE !!! */
576 "setting-allshare-efl", /* NO CODE !!! */
577 "setting-blockingmode-efl", /* NO CODE !!! */
578 /*"ug-bluetooth-efl", */
579 "setting-dock-efl", /* NO CODE !!! */
580 "setting-drivingmode-efl", /* NO CODE !!! */
581 "setting-gallery-efl", /* NO CODE !!! */
582 "setting-homescreen-efl", /* NO CODE !!! */
583 "setting-ledindicator-efl", /* NO CODE !!! */
584 "setting-location-efl", /* NO CODE !!! */
585 "setting-manage-applications-efl", /* NO CODE !!! */
586 "setting-manage-certificates-efl", /* NO CODE !!! */
587 "setting-myaccount-efl", /* NO CODE !!! */
588 "setting-phone-efl", /* NO CODE !!! */
589 "setting-readytoshare-efl", /* NO CODE !!! */
590 "setting-synchronise-efl", /* NO CODE !!! */
591 "wifi-efl-UG", /* NO CODE !!! */
592 "setting-wifidirect-efl", /* NO CODE !!! */
593 "worldclock-efl" /* NO CODE !!! */
594 "setting-nfc-efl", /* NO CODE !!! */
595 "setting-font-efl", /* NO CODE !!! */
596 "quickpanel-setting-efl", /* NO CODE !!! */
597 "setting-easymode-efl", /* NO CODE !!! */
598 "setting-accessibility-efl", /* NO CODE !!! */
599 "setting-personalpage-efl", /* NO CODE !!! */
600 "setting-voice-efl", /* NO CODE !!! */
601 "setting-motion-efl", /* NO CODE !!! */
602 "setting-palmmotion-efl", /* NO CODE !!! */
603 "setting-time-efl", /* NO CODE !!! */
604 "setting-accessory-efl", /* NO CODE !!! */
605 "setting-powersaving-efl", /* NO CODE !!! */
606 "setting-storage-efl", /* NO CODE !!! */
607 "setting-security-efl", /* NO CODE !!! */
608 "setting-privacy-efl", /* NO CODE !!! */
609 "isfsetting-efl", /* NO CODE !!! */
610 "setting-developeroption-efl", /* NO CODE !!! */
611 "setting-about-efl", /* NO CODE !!! */
612 "setting-network-efl", /*finish */
613 "setting-datausage-efl",
614 "setting-fingerscanner-efl",
619 for (i = 0; i < sizeof(ug_name_arr) / sizeof(ug_name_arr[0]); i++) {
620 /*SETTING_TRACE("---------> UG NAME : %s", ug_name_arr[i]); */
622 Eina_List *plist = NULL;
623 Setting_Cfg_Node_T *n = calloc(1, sizeof(Setting_Cfg_Node_T));
625 n->key_name = strdup("Sentinal");
626 plist = eina_list_append(plist, n);
629 char *domainname = NULL;
630 ret = setting_invoke_search_db_function(ug_name_arr[i], NULL, &plist, &domainname);
631 if (ret != OPERATE_LIB_SUCESS) {
632 SETTING_TRACE_ERROR(" no plugin -- code : %s : %d ", ug_name_arr[i], ret);
635 /*SETTING_TRACE(" return : %d", ret); */
636 SETTING_TRACE(" plugin -- code : %s O.K : %d ", ug_name_arr[i], ret);
640 SETTING_TRACE_ERROR("domainname == NULL, it's error by plugin, not go next");
642 Setting_Cfg_Node_T *node = NULL;
644 EINA_LIST_FOREACH(plist, l, node) {
645 FREE(node->key_name);
647 FREE(node->icon_path);
651 eina_list_free(plist);
656 char *p = strchr(domainname, ':');
658 char *domain_appname = NULL;
661 domain_appname = strtok(domainname, ":");
662 SETTING_TRACE("p1:appname : %s\n", domain_appname);
663 SETTING_TRACE("p2:localedir : %s\n", p + 1);
665 setting_set_i18n(domain_appname, p + 1);
667 domain_appname = domainname;
669 setting_set_i18n(domain_appname, "/usr/ug/res/locale");
674 Eina_List *langlist = setting_get_language_list2(LANGLIST_ALL_FILE_PATH);
676 Eina_List *elist = NULL;
677 setting_lang_entry *pnode = NULL;
679 EINA_LIST_FOREACH(langlist, elist, pnode) {
680 locale = pnode->locale;
683 snprintf(str, 256, "%s.UTF-8", locale);
684 (void)setlocale(LC_MESSAGES, str);
686 /*-------------------------------------------------------------- */
687 SETTING_TRACE(" (locale : %s) --------- BEFORE EINA LOOP : %x ", locale, plist);
690 Setting_Cfg_Node_T *node = NULL;
692 EINA_LIST_FOREACH(plist, l, node) {
695 SETTING_TRACE(" key_name : %s", node->key_name);
696 SETTING_TRACE(" ug_args : %s", node->ug_args);
697 SETTING_TRACE(" icon_path : %s", node->icon_path);
699 SETTING_TRACE(" pos : %d", node->pos);
700 SETTING_TRACE(" reset_type : %d", node->reset_type);
701 SETTING_TRACE(" click_times : %d", node->click_times);
702 SETTING_TRACE(" item_type : %d", node->item_type);
703 SETTING_TRACE(" data : %x", node->data);
704 SETTING_TRACE(" -----------------------------");
706 SETTING_TRACE(" add DB :: key_name : %s", node->key_name);
709 char *subindex = (node->sub_index) ? node->sub_index : "";
710 char *icon_path = (node->icon_path) ? node->icon_path : "";
712 setting_add_db_search_index(db, locale, __(node->key_name, domain_appname), node->ug_args, node->item_type, ug_name_arr[i], __(subindex, domain_appname), icon_path);
717 /*SETTING_TRACE(" --------- AFTER EINA LOOP "); */
719 } /* locale - LOOP */
723 Setting_Cfg_Node_T *node = NULL;
725 EINA_LIST_FOREACH(plist, l, node) {
726 FREE(node->key_name);
728 FREE(node->icon_path);
730 FREE(node->sub_index);
733 eina_list_free(plist);
736 /*-------------------------------------------------------------- */
737 } /* end of for loop */
741 (void)setlocale(LC_MESSAGES, backup_langset);
742 setting_searchdb_close(db);
748 int __setting_init_search_index_app()
750 /* test, adding sql query */
752 setting_searchdb_open(&db);
753 SETTING_TRACE("search db = %d", db);
755 /* clean all entries */
756 setting_add_db_search_clean(db);
758 /* add index for testing */
759 Setting_Cfg_Node_T *pitem = get_cfg_node_first(); /* head */
760 int size = get_cfg_array_size();
761 SETTING_TRACE(" size of array : %d ", size);
764 char *backup_langset = vconf_get_str(VCONFKEY_LANGSET);
766 /* get langlist // load language table from XML file */
767 Eina_List *elist = NULL;
768 setting_lang_entry *pnode = NULL;
769 Eina_List *langlist = setting_get_language_list2(LANGLIST_ALL_FILE_PATH);
771 EINA_LIST_FOREACH(langlist, elist, pnode) {
772 /*SETTING_TRACE(" locale = %s --- language = %s --- mcc = %s ", pnode->locale, pnode->title, pnode->mcc); */
773 locale = pnode->locale;
776 snprintf(str, 256, "%s.UTF-8", locale);
777 (void)setlocale(LC_MESSAGES, str);
780 for (i = 0; i < size; i++) {
781 /*SETTING_TRACE(" index : %d ", i); */
782 char *subindex = (pitem[i].sub_index) ? _(pitem[i].sub_index) : "";
783 char *icon_path = (pitem[i].icon_path) ? pitem[i].icon_path : "";
784 if (pitem[i].item_type == Cfg_Item_Title_Node) {
786 setting_add_db_search_index(db, locale, _(pitem[i].key_name), pitem[i].ug_args, pitem[i].item_type/*title in Genlist*/, "", subindex, icon_path);
788 } else if (pitem[i].item_type == Cfg_Item_Ug_Node
789 || pitem[i].item_type == Cfg_Item_Ug_Node_Toggle
790 || pitem[i].item_type == Cfg_Item_AppLauncher_Node
791 || pitem[i].item_type == Cfg_Item_AppLauncher_Node_Toggle
794 if (pitem[i].key_name && _(pitem[i].key_name)) {
795 setting_add_db_search_index(db, locale, _(pitem[i].key_name), pitem[i].ug_args, pitem[i].item_type/*UG name*/, "", subindex, icon_path);
797 } else if (pitem[i].item_type == Cfg_Item_App_Node) {
799 if (pitem[i].key_name && _(pitem[i].key_name)) {
800 setting_add_db_search_index(db, locale, _(pitem[i].key_name), pitem[i].ug_args, pitem[i].item_type/*App Launching*/, "", subindex, icon_path);
802 } else if (pitem[i].item_type == Cfg_Item_Ui_Node
803 || pitem[i].item_type == Cfg_Item_Ui_Node_Toggle
806 setting_add_db_search_index(db, locale, _(pitem[i].key_name), pitem[i].ug_args, pitem[i].item_type/*UI type*/, "", subindex, icon_path);
812 (void)setlocale(LC_MESSAGES, backup_langset);
813 setting_searchdb_close(db);