Move internal headers to src directory
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_private.h
1 /*
2  * pkgmgr-info
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>,
7  * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23
24 #ifndef __PKGMGRINFO_PRIVATE_H__
25 #define __PKGMGRINFO_PRIVATE_H__
26
27 #include <stdbool.h>
28 #include <unistd.h>
29 #include <sys/types.h>
30
31 #include <sqlite3.h>
32 #include <glib.h>
33 #include <tzplatform_config.h>
34
35 #include "pkgmgrinfo_type.h"
36 #include "pkgmgrinfo_basic.h"
37
38 #ifndef DEPRECATED
39 #define DEPRECATED      __attribute__ ((__deprecated__))
40 #endif
41
42 #ifndef API
43 #define API __attribute__ ((visibility("default")))
44 #endif
45
46 #ifdef LOG_TAG
47 #undef LOG_TAG
48 #endif
49 #define LOG_TAG "PKGMGR_INFO"
50
51 #define ASC_CHAR(s) (const char *)s
52 #define XML_CHAR(s) (const xmlChar *)s
53
54 #define MANIFEST_DB     tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
55 #define MAX_QUERY_LEN   4096
56 #define MAX_CERT_TYPE   9
57 #define CERT_DB         tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
58 #define PKG_STRING_LEN_MAX 1024
59 #define PKG_TYPE_STRING_LEN_MAX         128
60 #define PKG_VERSION_STRING_LEN_MAX      128
61 #define PKG_VALUE_STRING_LEN_MAX                512
62 #define PKG_RW_PATH tzplatform_mkpath(TZ_USER_APP, "")
63 #define PKG_RO_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "")
64 #define BLOCK_SIZE      4096 /*in bytes*/
65 #define BUFSIZE 4096
66 #define ROOT_UID 0
67 #define APPFW_UID 301
68
69 #define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
70 #define PKG_INSTALLATION_PATH tzplatform_mkpath(TZ_USER_APP, "")
71
72 #define SERVICE_NAME "org.tizen.system.deviced"
73 #define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
74 #define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
75 #define METHOD_NAME "RequestMountApp2ext"
76
77 #define GET_DB(X)  (X).dbHandle
78
79 /*String properties for filtering based on package info*/
80 typedef enum _pkgmgrinfo_pkginfo_filter_prop_str {
81         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR = 101,
82         E_PMINFO_PKGINFO_PROP_PACKAGE_ID = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR,
83         E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE,
84         E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION,
85         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION,
86         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE,
87         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME,
88         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL,
89         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF,
90         E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
91         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR = E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE
92 } pkgmgrinfo_pkginfo_filter_prop_str;
93
94 /*Boolean properties for filtering based on package info*/
95 typedef enum _pkgmgrinfo_pkginfo_filter_prop_bool {
96         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL = 201,
97         E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL,
98         E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD,
99         E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY,
100         E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE,
101         E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING,
102         E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING,
103         E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE,
104         E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE,
105         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL = E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE
106 } pkgmgrinfo_pkginfo_filter_prop_bool;
107
108 /*Integer properties for filtering based on package info*/
109 typedef enum _pkgmgrinfo_pkginfo_filter_prop_int {
110         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT = 301,
111         E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT,
112         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT = E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE
113 } pkgmgrinfo_pkginfo_filter_prop_int;
114
115 /*String properties for filtering based on app info*/
116 typedef enum _pkgmgrinfo_appinfo_filter_prop_str {
117         E_PMINFO_APPINFO_PROP_APP_MIN_STR = 401,
118         E_PMINFO_APPINFO_PROP_APP_ID = E_PMINFO_APPINFO_PROP_APP_MIN_STR,
119         E_PMINFO_APPINFO_PROP_APP_COMPONENT,
120         E_PMINFO_APPINFO_PROP_APP_EXEC,
121         E_PMINFO_APPINFO_PROP_APP_ICON,
122         E_PMINFO_APPINFO_PROP_APP_TYPE,
123         E_PMINFO_APPINFO_PROP_APP_OPERATION,
124         E_PMINFO_APPINFO_PROP_APP_URI,
125         E_PMINFO_APPINFO_PROP_APP_MIME,
126         E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,
127         E_PMINFO_APPINFO_PROP_APP_CATEGORY,
128         E_PMINFO_APPINFO_PROP_APP_SCREENREADER,
129         E_PMINFO_APPINFO_PROP_APP_PACKAGE,
130         E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,
131         E_PMINFO_APPINFO_PROP_APP_METADATA_KEY,
132         E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE,
133         E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE
134 } pkgmgrinfo_appinfo_filter_prop_str;
135
136 /*Boolean properties for filtering based on app info*/
137 typedef enum _pkgmgrinfo_appinfo_filter_prop_bool {
138         E_PMINFO_APPINFO_PROP_APP_MIN_BOOL = 501,
139         E_PMINFO_APPINFO_PROP_APP_NODISPLAY = E_PMINFO_APPINFO_PROP_APP_MIN_BOOL,
140         E_PMINFO_APPINFO_PROP_APP_MULTIPLE,
141         E_PMINFO_APPINFO_PROP_APP_ONBOOT,
142         E_PMINFO_APPINFO_PROP_APP_AUTORESTART,
143         E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,
144         E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,
145         E_PMINFO_APPINFO_PROP_APP_UI_GADGET,
146         E_PMINFO_APPINFO_PROP_APP_DISABLE,
147         E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,
148         E_PMINFO_APPINFO_PROP_APP_MAX_BOOL = E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE
149 } pkgmgrinfo_appinfo_filter_prop_bool;
150
151 /*Integer properties for filtering based on app info*/
152 typedef enum _pkgmgrinfo_appinfo_filter_prop_int {
153         /*Currently No Fields*/
154         E_PMINFO_APPINFO_PROP_APP_MIN_INT = 601,
155         E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER = E_PMINFO_APPINFO_PROP_APP_MIN_INT,
156         E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE,
157         E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE
158 } pkgmgrinfo_appinfo_filter_prop_int;
159
160 /*Integer properties for filtering based on app info*/
161 typedef enum _pkgmgrinfo_pkginfo_filter_prop_range {
162         /*Currently No Fields*/
163         E_PMINFO_PKGINFO_PROP_RANGE_MIN_INT = 701,
164         E_PMINFO_PKGINFO_PROP_RANGE_BASIC,
165         E_PMINFO_PKGINFO_PROP_RANGE_MAX_INT = E_PMINFO_PKGINFO_PROP_RANGE_BASIC
166 } pkgmgrinfo_pkginfo_filter_prop_range;
167
168 typedef enum _pkgmgrinfo_pkginfo_join_flag {
169         E_PMINFO_PKGINFO_JOIN_LOCALIZED_INFO = 0x0001,
170         E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO = 0x0002,
171 } pkgmgrinfo_pkginfo_join_flag;
172
173 typedef enum _pkgmgrinfo_appinfo_join_flag {
174         E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO = 0x0001,
175         E_PMINFO_APPINFO_JOIN_CATEGORY = 0x0002,
176         E_PMINFO_APPINFO_JOIN_APP_CONTROL = 0x0004,
177         E_PMINFO_APPINFO_JOIN_METADATA = 0x0008,
178 } pkgmgrinfo_appinfo_join_flag;
179
180 typedef struct _pkgmgr_pkginfo_x {
181         uid_t uid;
182         package_x *pkg_info;
183         char *locale;
184 } pkgmgr_pkginfo_x;
185
186 typedef struct _pkgmgr_appinfo_x {
187         const char *package;
188         char *locale;
189         pkgmgrinfo_app_component app_component;
190         application_x *app_info;
191 } pkgmgr_appinfo_x;
192
193 /*For filter APIs*/
194 typedef struct _pkgmgrinfo_filter_x {
195         uid_t uid;
196         GSList *list;
197 } pkgmgrinfo_filter_x;
198
199 typedef struct _pkgmgrinfo_node_x {
200         int prop;
201         char *key;
202         char *value;
203 } pkgmgrinfo_node_x;
204
205 typedef struct _pkgmgrinfo_appcontrol_x {
206         int operation_count;
207         int uri_count;
208         int mime_count;
209         int subapp_count;
210         char **operation;
211         char **uri;
212         char **mime;
213         char **subapp;
214 } pkgmgrinfo_appcontrol_x;
215
216 typedef struct _db_handle {
217         sqlite3 *dbHandle;
218         int ref;
219 } db_handle;
220
221 extern __thread db_handle manifest_db;
222 extern __thread db_handle cert_db;
223
224 pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
225 pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property);
226 pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property);
227
228 pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property);
229 pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
230 pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
231
232 pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
233
234 int _check_create_cert_db(sqlite3 *certdb);
235 int __close_manifest_db(void);
236 int __open_manifest_db(uid_t uid, bool readonly);
237 int __close_cert_db(void);
238 int __open_cert_db(uid_t uid, bool readonly);
239 void _save_column_int(sqlite3_stmt *stmt, int idx, int *i);
240 void _save_column_str(sqlite3_stmt *stmt, int idx, char **str);
241 char *_get_system_locale(void);
242 int __get_filter_condition(gpointer data, char **condition, GList **param);
243 int _add_icon_info_into_list(const char *locale, char *value, GList **icon);
244 int _add_label_info_into_list(const char *locale, char *value, GList **label);
245 int __pkginfo_check_installed_storage(package_x *pkginfo);
246 int __appinfo_check_installed_storage(application_x *appinfo);
247
248 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
249 #define REGULAR_USER 5000
250 static inline uid_t _getuid(void)
251 {
252         uid_t uid = getuid();
253
254         if (uid < REGULAR_USER)
255                 return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
256         else
257                 return uid;
258 }
259
260 #endif  /* __PKGMGRINFO_PRIVATE_H__ */