Tizen 2.1 base
[platform/core/appfw/ail.git] / src / ail_private.h
1 /*
2  * ail
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23
24
25 #ifndef __AIL_PRIVATE_H__
26 #define __AIL_PRIVATE_H__
27
28 #include <stdbool.h>
29 #include <sqlite3.h>
30
31 #ifndef EXPORT_API
32 #define EXPORT_API __attribute__ ((visibility("default")))
33 #endif
34
35 #undef LOG_TAG
36 #define LOG_TAG "AIL"
37
38 #if 1
39 #include <dlog.h>
40 #define _E(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
41 #define _D(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
42 #else
43 #include <stdio.h>
44 #define _E(fmt, arg...) fprintf(stderr, "[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
45 #define _D(fmt, arg...) fprintf(stderr, "[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
46 #endif
47
48 #define retv_if(expr, val) do { \
49         if(expr) { \
50                 _E("(%s) -> %s() return\n", #expr, __FUNCTION__); \
51                 return (val); \
52         } \
53 } while (0)
54
55 #define SAFE_FREE_AND_STRDUP(from, to) do { \
56         if (to) free(to); \
57         to = strdup(from); \
58 } while (0)
59
60 #define SAFE_FREE(ptr) do { \
61         if (ptr) free(ptr); \
62 } while (0)
63
64 struct element {
65         int prop;
66 };
67
68 struct element_int {
69         int prop;
70         int value;
71 };
72
73 struct element_bool {
74         int prop;
75         bool value;
76 };
77
78 struct element_str {
79         int prop;
80         char *value;
81 };
82
83 enum {
84         VAL_TYPE_BOOL,
85         VAL_TYPE_INT,
86         VAL_TYPE_STR,
87 };
88
89 #define ELEMENT_INT(e) ((struct element_int *)(e))
90 #define ELEMENT_STR(e) ((struct element_str *)(e))
91 #define ELEMENT_BOOL(e) ((struct element_bool *)(e))
92
93 #define AIL_SQL_QUERY_MAX_LEN   2048
94 #define APP_INFO_DB "/opt/dbspace/.app_info.db"
95
96 #define ELEMENT_TYPE(e, t) do { \
97         if(e->prop >= E_AIL_PROP_STR_MIN && e->prop <= E_AIL_PROP_STR_MAX) t= (int)VAL_TYPE_STR; \
98         else if (e->prop >= E_AIL_PROP_INT_MIN && e->prop <= E_AIL_PROP_INT_MAX) t= (int)VAL_TYPE_INT; \
99         else if (e->prop >= E_AIL_PROP_BOOL_MIN && e->prop <= E_AIL_PROP_BOOL_MAX) t= (int)VAL_TYPE_BOOL; \
100         else t = -1; \
101 } while(0)
102
103
104 #define PROP_TYPE(p, t) do { \
105         if(p >= E_AIL_PROP_STR_MIN && p <= E_AIL_PROP_STR_MAX) t= (int)VAL_TYPE_STR; \
106         else if (p >= E_AIL_PROP_INT_MIN && p <= E_AIL_PROP_INT_MAX) t= (int)VAL_TYPE_INT; \
107         else if (p >= E_AIL_PROP_BOOL_MIN && p <= E_AIL_PROP_BOOL_MAX) t= (int)VAL_TYPE_BOOL; \
108         else t = NULL; \
109 } while(0)
110
111
112 /**
113  * @brief string type properties
114  */
115 typedef enum {
116         E_AIL_PROP_STR_MIN = 0,
117         E_AIL_PROP_PACKAGE_STR = E_AIL_PROP_STR_MIN,
118         E_AIL_PROP_EXEC_STR,
119         E_AIL_PROP_NAME_STR,
120         E_AIL_PROP_TYPE_STR,
121         E_AIL_PROP_ICON_STR,
122         E_AIL_PROP_CATEGORIES_STR,
123         E_AIL_PROP_VERSION_STR,
124         E_AIL_PROP_MIMETYPE_STR,
125         E_AIL_PROP_X_SLP_SERVICE_STR,
126         E_AIL_PROP_X_SLP_PACKAGETYPE_STR,
127         E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR,
128         E_AIL_PROP_X_SLP_PACKAGEID_STR,
129         E_AIL_PROP_X_SLP_URI_STR,
130         E_AIL_PROP_X_SLP_SVC_STR,
131         E_AIL_PROP_X_SLP_EXE_PATH,
132         E_AIL_PROP_X_SLP_APPID_STR,
133         E_AIL_PROP_X_SLP_PKGID_STR,
134         E_AIL_PROP_X_SLP_DOMAIN_STR,
135         E_AIL_PROP_STR_MAX = E_AIL_PROP_X_SLP_DOMAIN_STR,
136 } ail_prop_str_e;
137
138
139 /**
140  * @brief integer type properties
141  */
142 typedef enum {
143         E_AIL_PROP_INT_MIN = E_AIL_PROP_STR_MAX + 1,
144         E_AIL_PROP_X_SLP_TEMP_INT = E_AIL_PROP_INT_MIN,
145         E_AIL_PROP_X_SLP_INSTALLEDTIME_INT,
146         E_AIL_PROP_INT_MAX = E_AIL_PROP_X_SLP_INSTALLEDTIME_INT,
147 } ail_prop_int_e;
148
149
150 /**
151  * @brief boolean type properties
152  */
153 typedef enum {
154         E_AIL_PROP_BOOL_MIN = E_AIL_PROP_INT_MAX + 1,
155         E_AIL_PROP_NODISPLAY_BOOL = E_AIL_PROP_BOOL_MIN,
156         E_AIL_PROP_X_SLP_TASKMANAGE_BOOL,
157         E_AIL_PROP_X_SLP_MULTIPLE_BOOL,
158         E_AIL_PROP_X_SLP_REMOVABLE_BOOL,
159         E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL,
160         E_AIL_PROP_X_SLP_INACTIVATED_BOOL,
161         E_AIL_PROP_BOOL_MAX = E_AIL_PROP_X_SLP_INACTIVATED_BOOL,
162 } ail_prop_bool_e;
163
164 #define NUM_OF_PROP E_AIL_PROP_BOOL_MAX + 1
165
166 #endif