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