tizen 2.3 release
[apps/home/settings.git] / setting-common / include / setting-common-search.h
1 /*
2  * setting
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
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
8  *
9  *     http://floralicense.org/license/
10  *
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.
16  */
17
18 #ifndef _SETTING_SEARCH_H_
19 #define _SETTING_SEARCH_H_
20
21 #include <Elementary.h>
22 #include <Eina.h>
23
24 #include <setting-common-general-func.h>
25 #include <setting-common-draw-widget.h>
26
27 #include <setting-cfg.h>
28
29 #include <libxml/xmlmemory.h>
30 #include <libxml/parser.h>
31
32 #include <sqlite3.h>
33
34 #define EXPORT_PUBLIC __attribute__ ((visibility ("default")))
35
36 #define S_FINDER_SETTING_STR "setting_from_sfinder"
37
38 #ifndef bool
39 #define bool int
40 #define TRUE 1
41 #define FALSE 0
42 #endif
43
44 #define SEARCH_DB_PATH "/opt/usr/data/setting/test.db"
45 #define SEARCH_DB_QUERY "select * from setting_search indexed by search_index where locale = %Q and keystr LIKE '%%%q%%'"
46 #define SEARCH_DB_QUERY_SELECT_ALL "select * from setting_search indexed by search_index where locale = %Q"
47 #define SEARCH_COUNT_DB_QUERY "select count(*) from setting_search indexed by search_index where locale = %Q and keystr LIKE '%%%q%%'"
48
49
50 extern const Elm_Genlist_Item_Class g_search_genlist_ts;
51 extern const Elm_Genlist_Item_Class g_search_genlist_ts_toggle;
52 extern const Elm_Genlist_Item_Class g_search_genlist_ts_divided_toggle;
53 extern const Elm_Genlist_Item_Class itc_no_reult;
54
55 /**
56 * @brief Item declaration of genlist
57 * retreive data from Database
58 */
59 typedef struct _ListItemObject
60 {
61         char* title;            // tag text
62         char* title2;           // plain text,
63         char* type;
64         char* infostr;
65         char* viewname;
66         char* fieldname;
67         char* icon_path;
68         void* data;
69         setting_group_style group_style;
70         void **pBack; //for pointer safety
71
72         Elm_Object_Item *item;
73         // toggle button proc
74         void (*fp_check_btn_cb)(void *data, Evas_Object *obj, void *event_info);
75         char* check_value_set;
76 } ListItemObject;
77
78
79 /**
80 * @brief add serach index for Database
81 *
82 * @param keystr keyword to be searched
83 * @param infostr additional info
84 * @param data_type 1:UGname 2:menustring 3:title
85 * @param viewname to find page
86 * @param fieldname to find field in the page
87 */
88 extern int setting_search_get_module_item_state(char* keyword, char *ug_name, Cfg_Item_State* stat, cfg_func_table* pops);
89 extern int setting_search_set_module_item_state(char* keyword, char *ug_name, Cfg_Item_State stat, cfg_func_table* pops);
90
91 extern void setting_add_db_search_index(sqlite3 *db, char* locale, char* keystr, char* infostr, int data_type, char* viewname, char* fieldname, char* icon_path);
92 extern int setting_searchdb_open(sqlite3** ppdb);
93 extern void setting_searchdb_close(sqlite3* db);
94
95 extern int __setting_init_search_index_app();
96 extern int __setting_init_search_index_module();
97
98 #endif // _SETTING_SEARCH_H_