e774708b795e7b7a5e408e8783ca2c18c117e789
[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 <glib.h>
32 #include <tzplatform_config.h>
33
34 #include "pkgmgrinfo_type.h"
35 #include "pkgmgrinfo_basic.h"
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 #ifndef DEPRECATED
42 #define DEPRECATED      __attribute__ ((__deprecated__))
43 #endif
44
45 #ifndef API
46 #define API __attribute__ ((visibility("default")))
47 #endif
48
49 #ifdef LOG_TAG
50 #undef LOG_TAG
51 #endif
52 #define LOG_TAG "PKGMGR_INFO"
53
54 #define ASC_CHAR(s) (const char *)s
55 #define XML_CHAR(s) (const xmlChar *)s
56
57 #define MANIFEST_DB     tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
58 #define MAX_QUERY_LEN   4096
59 #define MAX_CERT_TYPE   9
60 #define CERT_DB         tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
61 #define PKG_STRING_LEN_MAX 1024
62 #define PKG_TYPE_STRING_LEN_MAX         128
63 #define PKG_VERSION_STRING_LEN_MAX      128
64 #define PKG_VALUE_STRING_LEN_MAX                512
65 #define PKG_RW_PATH tzplatform_mkpath(TZ_USER_APP, "")
66 #define PKG_RO_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "")
67 #define BLOCK_SIZE      4096 /*in bytes*/
68 #define BUFSIZE 4096
69 #define ROOT_UID 0
70 #define APPFW_UID 301
71
72 #define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
73 #define PKG_INSTALLATION_PATH tzplatform_mkpath(TZ_USER_APP, "")
74
75 #define SERVICE_NAME "org.tizen.system.deviced"
76 #define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
77 #define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
78 #define METHOD_NAME "RequestMountApp2ext"
79
80 /*String properties for filtering based on package info*/
81 typedef enum _pkgmgrinfo_pkginfo_filter_prop_str {
82         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR = 101,
83         E_PMINFO_PKGINFO_PROP_PACKAGE_ID = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR,
84         E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE,
85         E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION,
86         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION,
87         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE,
88         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME,
89         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL,
90         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF,
91         E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
92         E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE,
93         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR = E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE
94 } pkgmgrinfo_pkginfo_filter_prop_str;
95
96 /*Boolean properties for filtering based on package info*/
97 typedef enum _pkgmgrinfo_pkginfo_filter_prop_bool {
98         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL = 201,
99         E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL,
100         E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD,
101         E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY,
102         E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE,
103         E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING,
104         E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING,
105         E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE,
106         E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE,
107         E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE,
108         E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM,
109         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL = E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM
110 } pkgmgrinfo_pkginfo_filter_prop_bool;
111
112 /*Integer properties for filtering based on package info*/
113 typedef enum _pkgmgrinfo_pkginfo_filter_prop_int {
114         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT = 301,
115         E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT,
116         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT = E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE
117 } pkgmgrinfo_pkginfo_filter_prop_int;
118
119 /*String properties for filtering based on app info*/
120 typedef enum _pkgmgrinfo_appinfo_filter_prop_str {
121         E_PMINFO_APPINFO_PROP_APP_MIN_STR = 401,
122         E_PMINFO_APPINFO_PROP_APP_ID = E_PMINFO_APPINFO_PROP_APP_MIN_STR,
123         E_PMINFO_APPINFO_PROP_APP_COMPONENT,
124         E_PMINFO_APPINFO_PROP_APP_EXEC,
125         E_PMINFO_APPINFO_PROP_APP_ICON,
126         E_PMINFO_APPINFO_PROP_APP_TYPE,
127         E_PMINFO_APPINFO_PROP_APP_OPERATION,
128         E_PMINFO_APPINFO_PROP_APP_URI,
129         E_PMINFO_APPINFO_PROP_APP_MIME,
130         E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,
131         E_PMINFO_APPINFO_PROP_APP_CATEGORY,
132         E_PMINFO_APPINFO_PROP_APP_SCREENREADER,
133         E_PMINFO_APPINFO_PROP_APP_PACKAGE,
134         E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,
135         E_PMINFO_APPINFO_PROP_PRIVILEGE,
136         E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_PRIVILEGE
137 } pkgmgrinfo_appinfo_filter_prop_str;
138
139 /*Boolean properties for filtering based on app info*/
140 typedef enum _pkgmgrinfo_appinfo_filter_prop_bool {
141         E_PMINFO_APPINFO_PROP_APP_MIN_BOOL = 501,
142         E_PMINFO_APPINFO_PROP_APP_NODISPLAY = E_PMINFO_APPINFO_PROP_APP_MIN_BOOL,
143         E_PMINFO_APPINFO_PROP_APP_MULTIPLE,
144         E_PMINFO_APPINFO_PROP_APP_ONBOOT,
145         E_PMINFO_APPINFO_PROP_APP_AUTORESTART,
146         E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,
147         E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,
148         E_PMINFO_APPINFO_PROP_APP_UI_GADGET,
149         E_PMINFO_APPINFO_PROP_APP_DISABLE,
150         E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,
151         E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE,
152         E_PMINFO_APPINFO_PROP_PKG_DISABLE,
153         E_PMINFO_APPINFO_PROP_APP_MAX_BOOL = E_PMINFO_APPINFO_PROP_PKG_DISABLE
154 } pkgmgrinfo_appinfo_filter_prop_bool;
155
156 /*Integer properties for filtering based on app info*/
157 typedef enum _pkgmgrinfo_appinfo_filter_prop_int {
158         /*Currently No Fields*/
159         E_PMINFO_APPINFO_PROP_APP_MIN_INT = 601,
160         E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE = E_PMINFO_APPINFO_PROP_APP_MIN_INT,
161         E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE
162 } pkgmgrinfo_appinfo_filter_prop_int;
163
164 /*Integer properties for filtering based on app info*/
165 typedef enum _pkgmgrinfo_pkginfo_filter_prop_range {
166         /*Currently No Fields*/
167         E_PMINFO_PKGINFO_PROP_RANGE_MIN_INT = 701,
168         E_PMINFO_PKGINFO_PROP_RANGE_BASIC,
169         E_PMINFO_PKGINFO_PROP_RANGE_MAX_INT = E_PMINFO_PKGINFO_PROP_RANGE_BASIC
170 } pkgmgrinfo_pkginfo_filter_prop_range;
171
172 typedef enum _pkgmgrinfo_pkginfo_join_flag {
173         E_PMINFO_PKGINFO_JOIN_LOCALIZED_INFO = 0x0001,
174         E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO = 0x0002,
175         E_PMINFO_PKGINFO_JOIN_RES_INFO = 0x0004,
176 } pkgmgrinfo_pkginfo_join_flag;
177
178 typedef enum _pkgmgrinfo_appinfo_join_flag {
179         E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO = 0x0001,
180         E_PMINFO_APPINFO_JOIN_CATEGORY = 0x0002,
181         E_PMINFO_APPINFO_JOIN_APP_CONTROL = 0x0004,
182         E_PMINFO_APPINFO_JOIN_METADATA = 0x0008,
183         E_PMINFO_APPINFO_JOIN_PRIVILEGE = 0x0010,
184 } pkgmgrinfo_appinfo_join_flag;
185
186 typedef enum _pkgmgrinfo_appinfo_disable_type {
187         E_APPINFO_DISABLE_TYPE_PKG = 0,
188         E_APPINFO_DISABLE_TYPE_APP
189 } pkgmgrinfo_appinfo_disable_type;
190
191 typedef struct _pkgmgr_pkginfo_x {
192         uid_t uid;
193         package_x *pkg_info;
194         char *locale;
195 } pkgmgr_pkginfo_x;
196
197 typedef struct _pkgmgr_appinfo_x {
198         const char *package;
199         char *locale;
200         pkgmgrinfo_app_component app_component;
201         application_x *app_info;
202 } pkgmgr_appinfo_x;
203
204 /*For filter APIs*/
205 typedef struct _pkgmgrinfo_filter_x {
206         uid_t uid;
207         GSList *list;
208         GSList *list_metadata;
209 } pkgmgrinfo_filter_x;
210
211 typedef struct _pkgmgrinfo_node_x {
212         int prop;
213         char *key;
214         char *value;
215 } pkgmgrinfo_node_x;
216
217 typedef struct _pkgmgrinfo_metadata_node_x {
218         char *key;
219         char *value;
220 } pkgmgrinfo_metadata_node_x;
221
222 typedef struct _pkgmgrinfo_appcontrol_x {
223         int operation_count;
224         int uri_count;
225         int mime_count;
226         int subapp_count;
227         char **operation;
228         char **uri;
229         char **mime;
230         char **subapp;
231 } pkgmgrinfo_appcontrol_x;
232
233 typedef struct _pkgmgr_certinfo_x {
234         int for_all_users;
235         char *pkgid;
236         char *cert_value;
237         char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
238         int cert_id[MAX_CERT_TYPE];             /*certificate ID in index table*/
239 } pkgmgr_certinfo_x;
240
241 /* TODO: refine below structures */
242 #define PKG_TYPE_STRING_LEN_MAX 128
243 #define PKG_NAME_STRING_LEN_MAX 128
244 #define PKG_VERSION_STRING_LEN_MAX      128
245 #define PKG_VALUE_STRING_LEN_MAX 512
246 #define PKG_URL_STRING_LEN_MAX 1024
247 #define PKG_LABEL_STRING_LEN_MAX 128
248 #define PKG_PATH_STRING_LEN_MAX 512
249 #define PKG_DEP_TYPE_STRING_LEN_MAX 128
250
251 typedef struct _package_manager_pkg_info_t {
252         char pkg_type[PKG_TYPE_STRING_LEN_MAX];
253         char pkg_name[PKG_NAME_STRING_LEN_MAX];
254         char pkgid[PKG_NAME_STRING_LEN_MAX];
255         char version[PKG_VERSION_STRING_LEN_MAX];
256         struct _package_manager_pkg_info_t *next;
257 } package_manager_pkg_info_t;
258
259 typedef struct _package_manager_pkg_dependency_info_t {
260         char pkgid[PKG_NAME_STRING_LEN_MAX];
261         char type[PKG_DEP_TYPE_STRING_LEN_MAX];
262         char required_version[PKG_VERSION_STRING_LEN_MAX];
263 } pkg_dependency_info_t;
264
265 typedef struct _package_manager_pkg_detail_info_t {
266         char pkg_type[PKG_TYPE_STRING_LEN_MAX];
267         char pkg_name[PKG_NAME_STRING_LEN_MAX];
268         char pkgid[PKG_NAME_STRING_LEN_MAX];
269         char version[PKG_VERSION_STRING_LEN_MAX];
270         char api_version[PKG_VERSION_STRING_LEN_MAX];
271         char pkg_description[PKG_VALUE_STRING_LEN_MAX];
272         char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
273         time_t installed_time;  /* installed time it must be GMT+0 time */
274         int installed_size;             /* installed total size */
275         int app_size;                   /* installed app size */
276         int data_size;                  /* data size which is made on run time */
277         char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */
278         void *pkg_optional_info;
279         char label[PKG_LABEL_STRING_LEN_MAX];
280         char author[PKG_VALUE_STRING_LEN_MAX];
281         char *icon_buf;
282         int icon_size;
283         GList *privilege_list;
284         GList *dependency_list;
285 } package_manager_pkg_detail_info_t;
286
287 typedef void (*_pkg_plugin_unload)(void);
288 typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkgid);
289 typedef int (*_pkg_plugin_get_installed_pkg_list)(
290                 const char *category, const char *option,
291                 package_manager_pkg_info_t **list, int *count);
292 typedef int (*_pkg_plugin_get_pkg_detail_info)(const char *pkgid,
293                 package_manager_pkg_detail_info_t *pkg_detail_info);
294 typedef int (*_pkg_plugin_get_pkg_detail_info_from_package)(
295                 const char *pkg_path,
296                 package_manager_pkg_detail_info_t *pkg_detail_info);
297
298 typedef struct _pkg_plugin_set {
299         char pkg_type[PKG_TYPE_STRING_LEN_MAX];
300         void *plugin_handle;
301         _pkg_plugin_unload plugin_on_unload;
302         _pkg_plugin_pkg_is_installed pkg_is_installed;
303         _pkg_plugin_get_installed_pkg_list get_installed_pkg_list;
304         _pkg_plugin_get_pkg_detail_info get_pkg_detail_info;
305         _pkg_plugin_get_pkg_detail_info_from_package
306         get_pkg_detail_info_from_package;
307 } pkg_plugin_set;
308
309 pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
310 pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property);
311 pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property);
312
313 pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property);
314 pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
315 pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
316
317 pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
318
319 void _pkgmgrinfo_node_destroy(pkgmgrinfo_node_x *node);
320
321 int _check_create_cert_db(void);
322 int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **param);
323 int __get_metadata_filter_condition(gpointer data, char **condition, GList **param);
324 int _add_icon_info_into_list(const char *locale, char *value, GList **icon);
325 int _add_label_info_into_list(const char *locale, char *value, GList **label);
326 int __pkginfo_check_installed_storage(package_x *pkginfo);
327 int __appinfo_check_installed_storage(application_x *appinfo);
328 char *__get_type_from_path(const char *pkg_path);
329 pkg_plugin_set *__load_library(const char *pkg_type);
330 void __unload_library(const char *pkg_type);
331
332 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
333 #define REGULAR_USER 5000
334 static inline uid_t _getuid(void)
335 {
336         uid_t uid = getuid();
337
338         if (uid < REGULAR_USER)
339                 return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
340         else
341                 return uid;
342 }
343
344 #ifdef __cplusplus
345 }
346 #endif
347
348 #endif  /* __PKGMGRINFO_PRIVATE_H__ */