4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
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>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #ifndef __PKGMGRINFO_PRIVATE_H__
25 #define __PKGMGRINFO_PRIVATE_H__
29 #include <sys/types.h>
33 #include <tzplatform_config.h>
35 #include "pkgmgrinfo_type.h"
36 #include "pkgmgrinfo_basic.h"
39 #define DEPRECATED __attribute__ ((__deprecated__))
43 #define API __attribute__ ((visibility("default")))
49 #define LOG_TAG "PKGMGR_INFO"
51 #define ASC_CHAR(s) (const char *)s
52 #define XML_CHAR(s) (const xmlChar *)s
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*/
69 #define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
70 #define PKG_INSTALLATION_PATH tzplatform_mkpath(TZ_USER_APP, "")
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"
77 #define GET_DB(X) (X).dbHandle
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;
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_CHECK_STORAGE,
106 E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL = E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE
107 } pkgmgrinfo_pkginfo_filter_prop_bool;
109 /*Integer properties for filtering based on package info*/
110 typedef enum _pkgmgrinfo_pkginfo_filter_prop_int {
111 E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT = 301,
112 E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT,
113 E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT = E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE
114 } pkgmgrinfo_pkginfo_filter_prop_int;
116 /*String properties for filtering based on app info*/
117 typedef enum _pkgmgrinfo_appinfo_filter_prop_str {
118 E_PMINFO_APPINFO_PROP_APP_MIN_STR = 401,
119 E_PMINFO_APPINFO_PROP_APP_ID = E_PMINFO_APPINFO_PROP_APP_MIN_STR,
120 E_PMINFO_APPINFO_PROP_APP_COMPONENT,
121 E_PMINFO_APPINFO_PROP_APP_EXEC,
122 E_PMINFO_APPINFO_PROP_APP_ICON,
123 E_PMINFO_APPINFO_PROP_APP_TYPE,
124 E_PMINFO_APPINFO_PROP_APP_OPERATION,
125 E_PMINFO_APPINFO_PROP_APP_URI,
126 E_PMINFO_APPINFO_PROP_APP_MIME,
127 E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,
128 E_PMINFO_APPINFO_PROP_APP_CATEGORY,
129 E_PMINFO_APPINFO_PROP_APP_SCREENREADER,
130 E_PMINFO_APPINFO_PROP_APP_PACKAGE,
131 E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,
132 E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE
133 } pkgmgrinfo_appinfo_filter_prop_str;
135 /*Boolean properties for filtering based on app info*/
136 typedef enum _pkgmgrinfo_appinfo_filter_prop_bool {
137 E_PMINFO_APPINFO_PROP_APP_MIN_BOOL = 501,
138 E_PMINFO_APPINFO_PROP_APP_NODISPLAY = E_PMINFO_APPINFO_PROP_APP_MIN_BOOL,
139 E_PMINFO_APPINFO_PROP_APP_MULTIPLE,
140 E_PMINFO_APPINFO_PROP_APP_ONBOOT,
141 E_PMINFO_APPINFO_PROP_APP_AUTORESTART,
142 E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,
143 E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,
144 E_PMINFO_APPINFO_PROP_APP_UI_GADGET,
145 E_PMINFO_APPINFO_PROP_APP_DISABLE,
146 E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,
147 E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE,
148 E_PMINFO_APPINFO_PROP_PKG_DISABLE,
149 E_PMINFO_APPINFO_PROP_APP_MAX_BOOL = E_PMINFO_APPINFO_PROP_PKG_DISABLE
150 } pkgmgrinfo_appinfo_filter_prop_bool;
152 /*Integer properties for filtering based on app info*/
153 typedef enum _pkgmgrinfo_appinfo_filter_prop_int {
154 /*Currently No Fields*/
155 E_PMINFO_APPINFO_PROP_APP_MIN_INT = 601,
156 E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE = E_PMINFO_APPINFO_PROP_APP_MIN_INT,
157 E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE
158 } pkgmgrinfo_appinfo_filter_prop_int;
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;
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;
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;
180 typedef enum _pkgmgrinfo_appinfo_disable_type {
181 E_APPINFO_DISABLE_TYPE_PKG = 0,
182 E_APPINFO_DISABLE_TYPE_APP
183 } pkgmgrinfo_appinfo_disable_type;
185 typedef struct _pkgmgr_pkginfo_x {
191 typedef struct _pkgmgr_appinfo_x {
194 pkgmgrinfo_app_component app_component;
195 application_x *app_info;
199 typedef struct _pkgmgrinfo_filter_x {
202 GSList *list_metadata;
203 } pkgmgrinfo_filter_x;
205 typedef struct _pkgmgrinfo_node_x {
211 typedef struct _pkgmgrinfo_metadata_node_x {
214 } pkgmgrinfo_metadata_node_x;
216 typedef struct _pkgmgrinfo_appcontrol_x {
225 } pkgmgrinfo_appcontrol_x;
227 typedef struct _db_handle {
232 /* TODO: refine below structures */
233 #define PKG_TYPE_STRING_LEN_MAX 128
234 #define PKG_NAME_STRING_LEN_MAX 128
235 #define PKG_VERSION_STRING_LEN_MAX 128
236 #define PKG_VALUE_STRING_LEN_MAX 512
237 #define PKG_URL_STRING_LEN_MAX 1024
238 #define PKG_LABEL_STRING_LEN_MAX 128
239 #define PKG_PATH_STRING_LEN_MAX 512
241 typedef struct _package_manager_pkg_info_t {
242 char pkg_type[PKG_TYPE_STRING_LEN_MAX];
243 char pkg_name[PKG_NAME_STRING_LEN_MAX];
244 char pkgid[PKG_NAME_STRING_LEN_MAX];
245 char version[PKG_VERSION_STRING_LEN_MAX];
246 struct _package_manager_pkg_info_t *next;
247 } package_manager_pkg_info_t;
249 typedef struct _package_manager_pkg_detail_info_t {
250 char pkg_type[PKG_TYPE_STRING_LEN_MAX];
251 char pkg_name[PKG_NAME_STRING_LEN_MAX];
252 char pkgid[PKG_NAME_STRING_LEN_MAX];
253 char version[PKG_VERSION_STRING_LEN_MAX];
254 char api_version[PKG_VERSION_STRING_LEN_MAX];
255 char pkg_description[PKG_VALUE_STRING_LEN_MAX];
256 char min_platform_version[PKG_VERSION_STRING_LEN_MAX];
257 time_t installed_time; /* installed time it must be GMT+0 time */
258 int installed_size; /* installed total size */
259 int app_size; /* installed app size */
260 int data_size; /* data size which is made on run time */
261 char optional_id[PKG_NAME_STRING_LEN_MAX]; /*package ID if exists */
262 void *pkg_optional_info;
263 char label[PKG_LABEL_STRING_LEN_MAX];
264 char author[PKG_VALUE_STRING_LEN_MAX];
267 GList *privilege_list;
268 } package_manager_pkg_detail_info_t;
270 typedef void (*_pkg_plugin_unload)(void);
271 typedef int (*_pkg_plugin_pkg_is_installed) (const char *pkgid);
272 typedef int (*_pkg_plugin_get_installed_pkg_list)(
273 const char *category, const char *option,
274 package_manager_pkg_info_t **list, int *count);
275 typedef int (*_pkg_plugin_get_pkg_detail_info)(const char *pkgid,
276 package_manager_pkg_detail_info_t *pkg_detail_info);
277 typedef int (*_pkg_plugin_get_pkg_detail_info_from_package)(
278 const char *pkg_path,
279 package_manager_pkg_detail_info_t *pkg_detail_info);
281 typedef struct _pkg_plugin_set {
282 char pkg_type[PKG_TYPE_STRING_LEN_MAX];
284 _pkg_plugin_unload plugin_on_unload;
285 _pkg_plugin_pkg_is_installed pkg_is_installed;
286 _pkg_plugin_get_installed_pkg_list get_installed_pkg_list;
287 _pkg_plugin_get_pkg_detail_info get_pkg_detail_info;
288 _pkg_plugin_get_pkg_detail_info_from_package
289 get_pkg_detail_info_from_package;
292 extern __thread db_handle manifest_db;
293 extern __thread db_handle cert_db;
295 pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
296 pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property);
297 pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property);
299 pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property);
300 pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
301 pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
303 pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
305 int _check_create_cert_db(void);
306 int __close_manifest_db(void);
307 int __open_manifest_db(uid_t uid, bool readonly);
308 int __close_cert_db(void);
309 int __open_cert_db(uid_t uid, bool readonly);
310 void _save_column_int(sqlite3_stmt *stmt, int idx, int *i);
311 void _save_column_str(sqlite3_stmt *stmt, int idx, char **str);
312 char *_get_system_locale(void);
313 int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **param);
314 int __get_metadata_filter_condition(gpointer data, char **condition, GList **param);
315 int _add_icon_info_into_list(const char *locale, char *value, GList **icon);
316 int _add_label_info_into_list(const char *locale, char *value, GList **label);
317 int __pkginfo_check_installed_storage(package_x *pkginfo);
318 int __appinfo_check_installed_storage(application_x *appinfo);
319 int __open_db(const char *path, sqlite3 **db, int flags);
320 char *__get_type_from_path(const char *pkg_path);
321 pkg_plugin_set *__load_library(const char *pkg_type);
322 void __unload_library(const char *pkg_type);
324 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
325 #define REGULAR_USER 5000
326 static inline uid_t _getuid(void)
328 uid_t uid = getuid();
330 if (uid < REGULAR_USER)
331 return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
336 #endif /* __PKGMGRINFO_PRIVATE_H__ */