Remove unused variable
[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         E_PMINFO_PKGINFO_JOIN_METADATA = 0x0008,
177 } pkgmgrinfo_pkginfo_join_flag;
178
179 typedef enum _pkgmgrinfo_appinfo_join_flag {
180         E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO = 0x0001,
181         E_PMINFO_APPINFO_JOIN_CATEGORY = 0x0002,
182         E_PMINFO_APPINFO_JOIN_APP_CONTROL = 0x0004,
183         E_PMINFO_APPINFO_JOIN_METADATA = 0x0008,
184         E_PMINFO_APPINFO_JOIN_PRIVILEGE = 0x0010,
185 } pkgmgrinfo_appinfo_join_flag;
186
187 typedef enum _pkgmgrinfo_appinfo_disable_type {
188         E_APPINFO_DISABLE_TYPE_PKG = 0,
189         E_APPINFO_DISABLE_TYPE_APP
190 } pkgmgrinfo_appinfo_disable_type;
191
192 typedef struct _pkgmgr_pkginfo_x {
193         uid_t uid;
194         package_x *pkg_info;
195         char *locale;
196 } pkgmgr_pkginfo_x;
197
198 typedef struct _pkgmgr_appinfo_x {
199         const char *package;
200         char *locale;
201         pkgmgrinfo_app_component app_component;
202         application_x *app_info;
203 } pkgmgr_appinfo_x;
204
205 /*For filter APIs*/
206 typedef struct _pkgmgrinfo_filter_x {
207         uid_t uid;
208         GSList *list;
209         GSList *list_metadata;
210         GSList *list_pkg_metadata;
211         bool cache_flag;        /* flag for pkginfo-server used to make cache */
212 } pkgmgrinfo_filter_x;
213
214 typedef struct _pkgmgrinfo_node_x {
215         int prop;
216         char *key;
217         char *value;
218 } pkgmgrinfo_node_x;
219
220 typedef struct _pkgmgrinfo_metadata_node_x {
221         char *key;
222         char *value;
223 } pkgmgrinfo_metadata_node_x;
224
225 typedef struct _pkgmgrinfo_appcontrol_x {
226         int operation_count;
227         int uri_count;
228         int mime_count;
229         int subapp_count;
230         char **operation;
231         char **uri;
232         char **mime;
233         char **subapp;
234 } pkgmgrinfo_appcontrol_x;
235
236 typedef struct _pkgmgr_certinfo_x {
237         int for_all_users;
238         char *pkgid;
239         char *cert_value;
240         char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
241         int cert_id[MAX_CERT_TYPE];             /*certificate ID in index table*/
242 } pkgmgr_certinfo_x;
243
244 /* TODO: refine below structures */
245 #define PKG_TYPE_STRING_LEN_MAX 128
246 #define PKG_NAME_STRING_LEN_MAX 128
247 #define PKG_VERSION_STRING_LEN_MAX      128
248 #define PKG_VALUE_STRING_LEN_MAX 512
249 #define PKG_URL_STRING_LEN_MAX 1024
250 #define PKG_LABEL_STRING_LEN_MAX 128
251 #define PKG_PATH_STRING_LEN_MAX 512
252 #define PKG_DEP_TYPE_STRING_LEN_MAX 128
253
254 typedef struct _package_manager_pkg_info_t {
255         char pkg_type[PKG_TYPE_STRING_LEN_MAX];
256         char pkg_name[PKG_NAME_STRING_LEN_MAX];
257         char pkgid[PKG_NAME_STRING_LEN_MAX];
258         char version[PKG_VERSION_STRING_LEN_MAX];
259         struct _package_manager_pkg_info_t *next;
260 } package_manager_pkg_info_t;
261
262 typedef struct _package_manager_pkg_dependency_info_t {
263         char pkgid[PKG_NAME_STRING_LEN_MAX];
264         char type[PKG_DEP_TYPE_STRING_LEN_MAX];
265         char required_version[PKG_VERSION_STRING_LEN_MAX];
266 } pkg_dependency_info_t;
267
268 typedef struct _package_manager_pkg_detail_info_t {
269         char pkg_type[PKG_TYPE_STRING_LEN_MAX];
270         char pkg_name[PKG_NAME_STRING_LEN_MAX];
271         char pkgid[PKG_NAME_STRING_LEN_MAX];
272         char version[PKG_VERSION_STRING_LEN_MAX];
273         char api_version[PKG_VERSION_STRING_LEN_MAX];
274         char pkg_description[PKG_VALUE_STRING_LEN_MAX];
275         char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
276         time_t installed_time;  /* installed time it must be GMT+0 time */
277         size_t installed_size;          /* installed total size */
278         size_t app_size;                        /* installed app size */
279         size_t data_size;                       /* data size which is made on run time */
280         char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */
281         void *pkg_optional_info;
282         char label[PKG_LABEL_STRING_LEN_MAX];
283         char author[PKG_VALUE_STRING_LEN_MAX];
284         char *icon_buf;
285         size_t icon_size;
286         GList *privilege_list;
287         GList *dependency_list;
288 } package_manager_pkg_detail_info_t;
289
290 typedef void (*_pkg_plugin_unload)(void);
291 typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkgid);
292 typedef int (*_pkg_plugin_get_installed_pkg_list)(
293                 const char *category, const char *option,
294                 package_manager_pkg_info_t **list, int *count);
295 typedef int (*_pkg_plugin_get_pkg_detail_info)(const char *pkgid,
296                 package_manager_pkg_detail_info_t *pkg_detail_info);
297 typedef int (*_pkg_plugin_get_pkg_detail_info_from_package)(
298                 const char *pkg_path,
299                 package_manager_pkg_detail_info_t *pkg_detail_info);
300
301 typedef struct _pkg_plugin_set {
302         char pkg_type[PKG_TYPE_STRING_LEN_MAX];
303         void *plugin_handle;
304         _pkg_plugin_unload plugin_on_unload;
305         _pkg_plugin_pkg_is_installed pkg_is_installed;
306         _pkg_plugin_get_installed_pkg_list get_installed_pkg_list;
307         _pkg_plugin_get_pkg_detail_info get_pkg_detail_info;
308         _pkg_plugin_get_pkg_detail_info_from_package
309         get_pkg_detail_info_from_package;
310 } pkg_plugin_set;
311
312 pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
313 pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property);
314 pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property);
315
316 pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property);
317 pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
318 pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
319
320 pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
321
322 void _pkgmgrinfo_node_destroy(pkgmgrinfo_node_x *node);
323
324 int _check_create_cert_db(void);
325 int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **param);
326 int __get_pkg_metadata_filter_condition(gpointer data, char **condition, GList **param);
327 int __get_metadata_filter_condition(gpointer data, char **condition, GList **param);
328 int _add_icon_info_into_list(const char *locale, char *value, GList **icon);
329 int _add_label_info_into_list(const char *locale, char *value, GList **label);
330 int __pkginfo_check_installed_storage(package_x *pkginfo);
331 int __appinfo_check_installed_storage(application_x *appinfo);
332 char *__get_type_from_path(const char *pkg_path);
333 pkg_plugin_set *__load_library(const char *pkg_type);
334 void __unload_library(const char *pkg_type);
335
336 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
337 #define REGULAR_USER 5000
338 static inline uid_t _getuid(void)
339 {
340         uid_t uid = getuid();
341
342         if (uid < REGULAR_USER)
343                 return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
344         else
345                 return uid;
346 }
347
348 #ifdef __cplusplus
349 }
350 #endif
351
352 #endif  /* __PKGMGRINFO_PRIVATE_H__ */