Unify uiapplication_x and serviceapplication_x
[platform/core/appfw/pkgmgr-info.git] / include / 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_TYPE_STRING_LEN_MAX         128
59 #define PKG_VERSION_STRING_LEN_MAX      128
60 #define PKG_VALUE_STRING_LEN_MAX                512
61 #define PKG_RW_PATH tzplatform_mkpath(TZ_USER_APP, "")
62 #define PKG_RO_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "")
63 #define BLOCK_SIZE      4096 /*in bytes*/
64 #define BUFSIZE 4096
65 #define ROOT_UID 0
66
67 #define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
68 #define PKG_INSTALLATION_PATH tzplatform_mkpath(TZ_USER_APP, "")
69
70 #define SERVICE_NAME "org.tizen.system.deviced"
71 #define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
72 #define INTERFACE_NAME "org.tizen.system.deviced.Mmc"
73 #define METHOD_NAME "RequestMountApp2ext"
74
75 #define GET_DB(X)  (X).dbHandle
76
77 /*String properties for filtering based on package info*/
78 typedef enum _pkgmgrinfo_pkginfo_filter_prop_str {
79         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR = 101,
80         E_PMINFO_PKGINFO_PROP_PACKAGE_ID = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR,
81         E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE,
82         E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION,
83         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION,
84         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE,
85         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME,
86         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL,
87         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF,
88         E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,
89         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR = E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE
90 } pkgmgrinfo_pkginfo_filter_prop_str;
91
92 /*Boolean properties for filtering based on package info*/
93 typedef enum _pkgmgrinfo_pkginfo_filter_prop_bool {
94         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL = 201,
95         E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL,
96         E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD,
97         E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY,
98         E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE,
99         E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING,
100         E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING,
101         E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE,
102         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL = E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE
103 } pkgmgrinfo_pkginfo_filter_prop_bool;
104
105 /*Integer properties for filtering based on package info*/
106 typedef enum _pkgmgrinfo_pkginfo_filter_prop_int {
107         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT = 301,
108         E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT,
109         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT = E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE
110 } pkgmgrinfo_pkginfo_filter_prop_int;
111
112 /*String properties for filtering based on app info*/
113 typedef enum _pkgmgrinfo_appinfo_filter_prop_str {
114         E_PMINFO_APPINFO_PROP_APP_MIN_STR = 401,
115         E_PMINFO_APPINFO_PROP_APP_ID = E_PMINFO_APPINFO_PROP_APP_MIN_STR,
116         E_PMINFO_APPINFO_PROP_APP_COMPONENT,
117         E_PMINFO_APPINFO_PROP_APP_EXEC,
118         E_PMINFO_APPINFO_PROP_APP_ICON,
119         E_PMINFO_APPINFO_PROP_APP_TYPE,
120         E_PMINFO_APPINFO_PROP_APP_OPERATION,
121         E_PMINFO_APPINFO_PROP_APP_URI,
122         E_PMINFO_APPINFO_PROP_APP_MIME,
123         E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,
124         E_PMINFO_APPINFO_PROP_APP_CATEGORY,
125         E_PMINFO_APPINFO_PROP_APP_SCREENREADER,
126         E_PMINFO_APPINFO_PROP_APP_PACKAGE,
127         E_PMINFO_APPINFO_PROP_APP_METADATA_KEY,
128         E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE,
129         E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE
130 } pkgmgrinfo_appinfo_filter_prop_str;
131
132 /*Boolean properties for filtering based on app info*/
133 typedef enum _pkgmgrinfo_appinfo_filter_prop_bool {
134         E_PMINFO_APPINFO_PROP_APP_MIN_BOOL = 501,
135         E_PMINFO_APPINFO_PROP_APP_NODISPLAY = E_PMINFO_APPINFO_PROP_APP_MIN_BOOL,
136         E_PMINFO_APPINFO_PROP_APP_MULTIPLE,
137         E_PMINFO_APPINFO_PROP_APP_ONBOOT,
138         E_PMINFO_APPINFO_PROP_APP_AUTORESTART,
139         E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,
140         E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,
141         E_PMINFO_APPINFO_PROP_APP_UI_GADGET,
142         E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,
143         E_PMINFO_APPINFO_PROP_APP_MAX_BOOL = E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE
144 } pkgmgrinfo_appinfo_filter_prop_bool;
145
146 /*Integer properties for filtering based on app info*/
147 typedef enum _pkgmgrinfo_appinfo_filter_prop_int {
148         /*Currently No Fields*/
149         E_PMINFO_APPINFO_PROP_APP_MIN_INT = 601,
150         E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_MIN_INT
151 } pkgmgrinfo_appinfo_filter_prop_int;
152
153 /*Integer properties for filtering based on app info*/
154 typedef enum _pkgmgrinfo_pkginfo_filter_prop_range {
155         /*Currently No Fields*/
156         E_PMINFO_PKGINFO_PROP_RANGE_MIN_INT = 701,
157         E_PMINFO_PKGINFO_PROP_RANGE_BASIC,
158         E_PMINFO_PKGINFO_PROP_RANGE_MAX_INT = E_PMINFO_PKGINFO_PROP_RANGE_BASIC
159 } pkgmgrinfo_pkginfo_filter_prop_range;
160
161 typedef struct _pkgmgr_pkginfo_x {
162         uid_t uid;
163         package_x *pkg_info;
164         char *locale;
165
166         struct _pkgmgr_pkginfo_x *prev;
167         struct _pkgmgr_pkginfo_x *next;
168 } pkgmgr_pkginfo_x;
169
170 typedef struct _pkgmgr_appinfo_x {
171         const char *package;
172         char *locale;
173         pkgmgrinfo_app_component app_component;
174         application_x *app_info;
175         struct _pkgmgr_appinfo_x *prev;
176         struct _pkgmgr_appinfo_x *next;
177 } pkgmgr_appinfo_x;
178
179 /*For filter APIs*/
180 typedef struct _pkgmgrinfo_filter_x {
181         uid_t uid;
182         GSList *list;
183 } pkgmgrinfo_filter_x;
184
185 typedef struct _pkgmgrinfo_node_x {
186         int prop;
187         char *key;
188         char *value;
189 } pkgmgrinfo_node_x;
190
191 typedef struct _pkgmgrinfo_appcontrol_x {
192         int operation_count;
193         int uri_count;
194         int mime_count;
195         int subapp_count;
196         char **operation;
197         char **uri;
198         char **mime;
199         char **subapp;
200 } pkgmgrinfo_appcontrol_x;
201
202 typedef struct _db_handle {
203         sqlite3 *dbHandle;
204         int ref;
205 } db_handle;
206
207 extern __thread db_handle manifest_db;
208 extern __thread db_handle cert_db;
209
210 pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
211 pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property);
212 pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property);
213
214 pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property);
215 pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
216 pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
217
218 pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
219
220 int _check_create_cert_db(sqlite3 *certdb);
221 int __close_manifest_db(void);
222 int __open_manifest_db(uid_t uid, bool readonly);
223 int __close_cert_db(void);
224 int __open_cert_db(uid_t uid, bool readonly);
225 void _save_column_str(sqlite3_stmt *stmt, int idx, const char **str);
226 char *_get_system_locale(void);
227 void __get_filter_condition(gpointer data, char **condition);
228
229 #endif  /* __PKGMGRINFO_PRIVATE_H__ */