apply FSL(Flora Software License)
[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
19
20
21
22 #ifndef __DEF_SMARTSEARCH_DEFINE_H__
23 #define __DEF_SMARTSEARCH_DEFINE_H__
24
25
26 enum {
27         SEARCH_TYPE_PHONE_CONTACTS = 0,
28         SEARCH_TYPE_PHONE_MSG,
29         SEARCH_TYPE_PHONE_EMAIL,
30         SEARCH_TYPE_PHONE_IMAGES,
31         SEARCH_TYPE_PHONE_MUSIC,
32         SEARCH_TYPE_PHONE_VIDEO,
33         SEARCH_TYPE_PHONE_CALENDAR,
34         SEARCH_TYPE_PHONE_MEMO,
35         SEARCH_TYPE_PHONE_MENU,
36         SEARCH_TYPE_PHONE_MAX
37 };
38
39 enum {
40         SEARCH_TYPE_PHONE = 0,
41 };
42
43 enum {
44         LAUNCH_ERROR_FILE_NOT_FOUND = 1,
45         LAUNCH_ERROR_AUL_LAUNCH,
46         LAUNCH_ERROR_APPSVC,
47         LAUNCH_ERROR_MAX
48 };
49
50 enum {
51         BACK_BTN_TYPE_LOWER,
52         BACK_BTN_TYPE_CLOSE
53 };
54
55 enum {
56         SEARCH_CATE_BTN_IMG_TYPE_UNPRESSED,
57         SEARCH_CATE_BTN_IMG_TYPE_PRESSED,
58         SEARCH_CATE_BTN_IMG_TYPE_MAX
59 };
60
61 enum {
62         SEARCH_RET_SEARCH_FAIL = -1,
63         SEARCH_RET_SEARCH_NONE,
64         SEARCH_RET_SEARCH_SUCCESS
65 };
66
67 enum {
68         SEARCH_RET_FAIL = -1,
69         SEARCH_RET_SUCCESS
70 };
71
72 enum {
73         SEARCH_STMT_GET_HISTORY_ALL = 0,
74         SEARCH_STMT_GET_HISTORY_WITH_KEYWORD,
75         SEARCH_STMT_INSERT_KEYWORD,
76         SEARCH_STMT_MAX
77 };
78
79 enum {
80         SEARCH_SQL_BIND_TYPE_SIMPLEX = 0,
81         SEARCH_SQL_BIND_TYPE_DUPLEX
82 };      
83
84 //==============================================================================================================================
85
86 #define SEARCH_PACKAGE "smartsearch"
87 #define SEARCH_ICON_PATH  RESDIR"/icons/"
88 #define SEARCH_EDJ EDJDIR"/smartsearch.edj"
89
90 #define DEF_BUF_LEN            (512)
91 #define MAX_LENGTH_PER_LINE    (512)
92 #define MAX_LENGTH_PER_PATH    (512)
93 #define MAX_LENGTH_PER_ID      (10)
94 #define MAX_SEARCH_WORD_SIZE   (128)
95
96 #define SMARTSEARCH_KEY_KEYWORD         "db/smartsearch/keyword"
97
98 #define PHONE_CATEGORY_LIST_CNT         (SEARCH_TYPE_PHONE_MAX)
99 #define DB_QUERY_LEN                    (512)
100
101 #define NO_RESULT_BODY_LEN      7
102
103 #define SEARCH_CATEGORY_LIST_MORE_CNT   (20)
104
105 #define DB_ESCAPE_CHAR          "|"
106
107
108 //==============================================================================================================================
109
110
111 #define SEARCH_FREE(ptr)        \
112         do { \
113                 if(ptr != NULL) \
114                 {       \
115                         free(ptr);      \
116                         ptr = NULL;     \
117                 }       \
118         }while(0);
119
120 #define SEARCH_MALLOC(ptr, size, type) \
121         do { \
122                 if(size > 0) { \
123                         ptr = (type *)malloc(size); \
124                         if(ptr == NULL) \
125                                 assert(0); \
126                 } else { \
127                         assert(0); \
128                 } \
129         } while(0);     
130
131 /* Gives comparison result of two strings and returns -1 if any of two is NULL */
132 #define SEARCH_STRCMP(str1, str2)       ((str1 && str2) ? strcmp(str1, str2) : -1)      
133
134 /* Returns string length of src and 0 if it is NULL */
135 #define SEARCH_STRLEN(src)      ((src != NULL)? strlen(src): 0)
136
137 #define SEARCH_SCALABLED_SIZE(size, _scale_factor)      (int)((size) * (_scale_factor)) 
138
139 #endif
140