Update changed code
[apps/home/smartsearch.git] / include / smartsearch_define.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.tizenopensource.org/license
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef __DEF_SMARTSEARCH_DEFINE_H__
19 #define __DEF_SMARTSEARCH_DEFINE_H__
20
21
22 enum {
23         SEARCH_OBJ_PHONE_CONTENTS = 0,
24         SEARCH_OBJ_APPLICATION,
25         SEARCH_OBJ_TYPE_MAX
26 };
27
28 enum {
29         SEARCH_CONT_PHONE_MIN = 0,
30         SEARCH_CONT_PHONE_CONTACTS = SEARCH_CONT_PHONE_MIN,
31         SEARCH_CONT_PHONE_MSG,
32         SEARCH_CONT_PHONE_EMAIL,
33         SEARCH_CONT_PHONE_IMAGES,
34         SEARCH_CONT_PHONE_MUSIC,
35         SEARCH_CONT_PHONE_VIDEO,
36         SEARCH_CONT_PHONE_CALENDAR,
37         SEARCH_CONT_PHONE_MEMO,
38         SEARCH_CONT_PHONE_MENU,
39         SEARCH_CONT_PHONE_BROWSER,
40         SEARCH_CONT_PHONE_MAX = SEARCH_CONT_PHONE_BROWSER,
41         SEARCH_CONT_MAX
42 };
43
44 enum {
45         SEARCH_CATE_PHONE = 0,
46         SEARCH_CATE_MAX
47 };
48
49 enum {
50         SEARCH_GENLIST_GROUP = 0,
51         SEARCH_GENLIST_ITEM,
52         SEARCH_GENLIST_MORE
53 };
54
55 enum {
56         LAUNCH_ERROR_FILE_NOT_FOUND = 1,
57         LAUNCH_ERROR_AUL_LAUNCH,
58         LAUNCH_ERROR_APPSVC,
59         LAUNCH_ERROR_MAX
60 };
61
62 enum {
63         BACK_BTN_TYPE_LOWER,
64         BACK_BTN_TYPE_CLOSE
65 };
66
67 enum {
68         SEARCH_RET_SEARCH_FAIL = -1,
69         SEARCH_RET_SEARCH_NONE,
70         SEARCH_RET_SEARCH_SUCCESS
71 };
72
73 enum {
74         SEARCH_RET_FAIL = -1,
75         SEARCH_RET_SUCCESS
76 };
77
78 enum {
79         SEARCH_STMT_GET_CATEGORY_LIST_ALL = 0,
80         SEARCH_STMT_INSERT_OBJECT_INFO,
81         SEARCH_STMT_UPDATE_OBJECT_INFO,
82         SEARCH_STMT_MAX
83 };
84
85 enum {
86         SEARCH_SQL_BIND_TYPE_SIMPLEX = 0,
87         SEARCH_SQL_BIND_TYPE_DUPLEX
88 };
89
90 enum {
91         SEARCH_PIPE_CMD_CLEAR_GENLIST = 0,
92         SEARCH_PIPE_CMD_ADD_GENLIST_PHONE,
93         SEARCH_PIPE_CMD_SET_LAYOUT,
94 };
95
96 enum {
97         SEARCH_STR_TYPE_APP_STRING = 0,
98         SEARCH_STR_TYPE_SYSTEM_STRING,
99 };
100
101 //==============================================================================================================================
102
103 #define SEARCH_PACKAGE "smartsearch"
104 #define SEARCH_ICON_PATH  RESDIR"/icons/"
105 #define SEARCH_EDJ EDJDIR"/smartsearch.edj"
106 #define SEARCH_DB_PATH "/opt/apps/org.tizen.smartsearch/data/.search.db"
107
108 #define SEARCH_FAVORITE_ICON    SEARCH_ICON_PATH"B10_icon_list_favorite.png"
109 #define SEARCH_SDCARD_ICON              SEARCH_ICON_PATH"B10_icon_list_memorycard.png"
110
111 #define SEARCH_THUMBNAIL_SIZE 96
112 #define SEARCH_ICON_SIZE 64
113
114 #define DEF_BUF_LEN            (512)
115 #define MAX_LENGTH_PER_LINE    (512)
116 #define MAX_LENGTH_PER_PATH    (512)
117 #define MAX_LENGTH_PER_ID      (10)
118 #define MAX_SEARCH_WORD_SIZE   (128)
119
120 #define SMARTSEARCH_KEY_KEYWORD         "file/private/org.tizen.smartsearch/keyword"
121
122 #define PHONE_CATEGORY_LIST_CNT         (SEARCH_CONT_PHONE_MAX)
123 #define DB_QUERY_LEN                    (512)
124
125 #define NO_RESULT_BODY_LEN      7
126
127 #define SEARCH_CATEGORY_LIST_MORE_CNT   (100)
128
129 #define DB_ESCAPE_CHAR          "|"
130
131 #define SEARCH_DB_SQL_GET_CATEGORY_LIST_ALL "SELECT item_name, item_string, item_visible, item_order, item_contents_type, item_object_type, " \
132                                                                         "def_pkg_name FROM search_category  ORDER by item_order asc;"
133 #define SEARCH_DB_SQL_INSERT_OBJECT_IFNO "REPLACE INTO search_category" \
134                                                                                 "(item_name, item_string, item_visible, item_order, item_contents_type, item_object_type, def_pkg_name) " \
135                                                                                 "VALUES(?,?,?,?,?,?,?);"
136
137 #define SEARCH_DB_SQL_UPDATE_OBJECT_INFO "UPDATE search_category SET " \
138                                                                         "item_name = ?, item_string = ?, item_visible = ?, item_order = ?, item_contents_type = ?, item_object_type = ?, " \
139                                                                         "def_pkg_name = ? WHERE item_contents_type = ?;"
140
141
142 //==============================================================================================================================
143
144
145 #define SEARCH_FREE(ptr)        \
146         do { \
147                 if(ptr != NULL) \
148                 {       \
149                         free(ptr);      \
150                         ptr = NULL;     \
151                 }       \
152         }while(0);
153
154 #define SEARCH_MALLOC(ptr, size, type) \
155         do { \
156                 if(size > 0) { \
157                         ptr = (type *)malloc(size); \
158                         if(ptr == NULL) \
159                                 assert(0); \
160                 } else { \
161                         assert(0); \
162                 } \
163         } while(0);
164
165 /* Gives comparison result of two strings and returns -1 if any of two is NULL */
166 #define SEARCH_STRCMP(str1, str2)       ((str1 && str2) ? strcmp(str1, str2) : -1)
167
168 /* Returns string length of src and 0 if it is NULL */
169 #define SEARCH_STRLEN(src)      ((src != NULL)? strlen(src): 0)
170
171 #define SEARCH_SCALABLED_SIZE(size, _scale_factor)      (int)((size) * (_scale_factor))
172
173 #endif
174