Fix Prevent and remove compile warning messages
[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 #include <tzplatform_config.h>
31
32 #ifndef EXPORT_API
33 #define EXPORT_API __attribute__ ((visibility("default")))
34 #endif
35
36 #undef LOG_TAG
37 #define LOG_TAG "AIL"
38
39 #if 1
40 #include <dlog.h>
41 #define _E(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
42 #define _D(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
43 #else
44 #include <stdio.h>
45 #define _E(fmt, arg...) fprintf(stderr, "[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
46 #define _D(fmt, arg...) fprintf(stderr, "[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)
47 #endif
48
49 #define retv_if(expr, val) do { \
50         if(expr) { \
51                 _E("(%s) -> %s() return\n", #expr, __FUNCTION__); \
52                 return (val); \
53         } \
54 } while (0)
55
56 #define SAFE_FREE_AND_STRDUP(from, to) do { \
57         if (to) free(to); \
58         to = strdup(from); \
59 } while (0)
60
61 #define SAFE_FREE(ptr) do { \
62         if (ptr) free(ptr); \
63 } while (0)
64
65 struct element {
66         int prop;
67 };
68
69 struct element_int {
70         int prop;
71         int value;
72 };
73
74 struct element_bool {
75         int prop;
76         bool value;
77 };
78
79 struct element_str {
80         int prop;
81         char *value;
82 };
83
84 enum {
85         VAL_TYPE_BOOL,
86         VAL_TYPE_INT,
87         VAL_TYPE_STR,
88 };
89
90 #define ELEMENT_INT(e) ((struct element_int *)(e))
91 #define ELEMENT_STR(e) ((struct element_str *)(e))
92 #define ELEMENT_BOOL(e) ((struct element_bool *)(e))
93
94 #define AIL_SQL_QUERY_MAX_LEN   2048
95 #define APP_INFO_DB tzplatform_mkpath(TZ_SYS_DB,".app_info.db")
96
97 #define ELEMENT_TYPE(e, t) do { \
98         if(e->prop >= E_AIL_PROP_STR_MIN && e->prop <= E_AIL_PROP_STR_MAX) t= (int)VAL_TYPE_STR; \
99         else if (e->prop >= E_AIL_PROP_INT_MIN && e->prop <= E_AIL_PROP_INT_MAX) t= (int)VAL_TYPE_INT; \
100         else if (e->prop >= E_AIL_PROP_BOOL_MIN && e->prop <= E_AIL_PROP_BOOL_MAX) t= (int)VAL_TYPE_BOOL; \
101         else t = -1; \
102 } while(0)
103
104
105 #define PROP_TYPE(p, t) do { \
106         if(p >= E_AIL_PROP_STR_MIN && p <= E_AIL_PROP_STR_MAX) t= (int)VAL_TYPE_STR; \
107         else if (p >= E_AIL_PROP_INT_MIN && p <= E_AIL_PROP_INT_MAX) t= (int)VAL_TYPE_INT; \
108         else if (p >= E_AIL_PROP_BOOL_MIN && p <= E_AIL_PROP_BOOL_MAX) t= (int)VAL_TYPE_BOOL; \
109         else t = NULL; \
110 } while(0)
111
112
113 /**
114  * @brief string type properties
115  */
116 typedef enum {
117         E_AIL_PROP_STR_MIN = 0,
118         E_AIL_PROP_PACKAGE_STR = E_AIL_PROP_STR_MIN,
119         E_AIL_PROP_EXEC_STR,
120         E_AIL_PROP_NAME_STR,
121         E_AIL_PROP_TYPE_STR,
122         E_AIL_PROP_ICON_STR,
123         E_AIL_PROP_CATEGORIES_STR,
124         E_AIL_PROP_VERSION_STR,
125         E_AIL_PROP_MIMETYPE_STR,
126         E_AIL_PROP_X_SLP_SERVICE_STR,
127         E_AIL_PROP_X_SLP_PACKAGETYPE_STR,
128         E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR,
129         E_AIL_PROP_X_SLP_PACKAGEID_STR,
130         E_AIL_PROP_X_SLP_URI_STR,
131         E_AIL_PROP_X_SLP_SVC_STR,
132         E_AIL_PROP_X_SLP_EXE_PATH,
133         E_AIL_PROP_X_SLP_APPID_STR,
134         E_AIL_PROP_X_SLP_PKGID_STR,
135         E_AIL_PROP_X_SLP_DOMAIN_STR,
136         E_AIL_PROP_X_SLP_SUBMODEMAINID_STR,
137         E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR,
138         E_AIL_PROP_STR_MAX = E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR,
139 } ail_prop_str_e;
140
141 /**
142  * @brief integer type properties
143  */
144 typedef enum {
145         E_AIL_PROP_INT_MIN = E_AIL_PROP_STR_MAX + 1,
146         E_AIL_PROP_X_SLP_TEMP_INT = E_AIL_PROP_INT_MIN,
147         E_AIL_PROP_X_SLP_INSTALLEDTIME_INT,
148         E_AIL_PROP_INT_MAX = E_AIL_PROP_X_SLP_INSTALLEDTIME_INT,
149 } ail_prop_int_e;
150
151
152 /**
153  * @brief boolean type properties
154  */
155 typedef enum {
156         E_AIL_PROP_BOOL_MIN = E_AIL_PROP_INT_MAX + 1,
157         E_AIL_PROP_NODISPLAY_BOOL = E_AIL_PROP_BOOL_MIN,
158         E_AIL_PROP_X_SLP_TASKMANAGE_BOOL,
159         E_AIL_PROP_X_SLP_MULTIPLE_BOOL,
160         E_AIL_PROP_X_SLP_REMOVABLE_BOOL,
161         E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL,
162         E_AIL_PROP_X_SLP_ENABLED_BOOL,
163         E_AIL_PROP_X_SLP_SUBMODE_BOOL,
164         E_AIL_PROP_BOOL_MAX = E_AIL_PROP_X_SLP_SUBMODE_BOOL,
165 } ail_prop_bool_e;
166
167 #define NUM_OF_PROP E_AIL_PROP_BOOL_MAX + 1
168
169 #endif