tizen 2.3.1 release
[framework/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 <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
31 #include <db-util.h>
32 #include <sqlite3.h>
33 #include <glib.h>
34 #include <ctype.h>
35 #include <assert.h>
36 #include <dlfcn.h>
37 #include <dirent.h>
38 #include <sys/stat.h>
39
40 #include "pkgmgrinfo_basic.h"
41 #include "pkgmgrinfo_debug.h"
42 #include "pkgmgr-info.h"
43
44 #ifndef DEPRECATED
45 #define DEPRECATED      __attribute__ ((__deprecated__))
46 #endif
47
48 #ifndef API
49 #define API __attribute__ ((visibility("default")))
50 #endif
51
52 #define MMC_PATH "/opt/storage/sdcard"
53 #define PKG_SD_PATH MMC_PATH"/app2sd/"
54
55 #define PKG_RW_PATH "/opt/usr/apps/"
56 #define PKG_RO_PATH "/usr/apps/"
57 #define BLOCK_SIZE      4096 /*in bytes*/
58
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_LOCALE_STRING_LEN_MAX               8
63
64 #define MAX_QUERY_LEN   4096
65 #define MAX_CERT_TYPE   9
66
67 #define MANIFEST_DB             "/opt/dbspace/.pkgmgr_parser.db"
68 #define CERT_DB                 "/opt/dbspace/.pkgmgr_cert.db"
69 #define DATACONTROL_DB  "/opt/usr/dbspace/.app-package.db"
70
71 /*String properties for filtering based on package info*/
72 typedef enum _pkgmgrinfo_pkginfo_filter_prop_str {
73         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR = 101,
74         E_PMINFO_PKGINFO_PROP_PACKAGE_ID = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR,
75         E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE,
76         E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION,
77         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION,
78         E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE,
79         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME,
80         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL,
81         E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF,
82         E_PMINFO_PKGINFO_PROP_PACKAGE_STORECLIENT_ID,
83         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR = E_PMINFO_PKGINFO_PROP_PACKAGE_STORECLIENT_ID
84 } pkgmgrinfo_pkginfo_filter_prop_str;
85
86 /*Boolean properties for filtering based on package info*/
87 typedef enum _pkgmgrinfo_pkginfo_filter_prop_bool {
88         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL = 201,
89         E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL,
90         E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD,
91         E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY,
92         E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE,
93         E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING,
94         E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING,
95         E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE,
96         E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE,
97         E_PMINFO_PKGINFO_PROP_PACKAGE_USE_RESET,
98         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL = E_PMINFO_PKGINFO_PROP_PACKAGE_USE_RESET
99 } pkgmgrinfo_pkginfo_filter_prop_bool;
100
101 /*Integer properties for filtering based on package info*/
102 typedef enum _pkgmgrinfo_pkginfo_filter_prop_int {
103         E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT = 301,
104         E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE = E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT,
105         E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_MODE,
106         E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT = E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_MODE
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_COMPONENT_TYPE,
115         E_PMINFO_APPINFO_PROP_APP_EXEC,
116         E_PMINFO_APPINFO_PROP_APP_AMBIENT_SUPPORT,
117         E_PMINFO_APPINFO_PROP_APP_ICON,
118         E_PMINFO_APPINFO_PROP_APP_TYPE,
119         E_PMINFO_APPINFO_PROP_APP_OPERATION,
120         E_PMINFO_APPINFO_PROP_APP_URI,
121         E_PMINFO_APPINFO_PROP_APP_MIME,
122         E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,
123         E_PMINFO_APPINFO_PROP_APP_CATEGORY,
124         E_PMINFO_APPINFO_PROP_APP_SCREENREADER,
125         E_PMINFO_APPINFO_PROP_APP_MAX_STR = E_PMINFO_APPINFO_PROP_APP_CATEGORY
126 } pkgmgrinfo_appinfo_filter_prop_str;
127
128 /*Boolean properties for filtering based on app info*/
129 typedef enum _pkgmgrinfo_appinfo_filter_prop_bool {
130         E_PMINFO_APPINFO_PROP_APP_MIN_BOOL = 501,
131         E_PMINFO_APPINFO_PROP_APP_NODISPLAY = E_PMINFO_APPINFO_PROP_APP_MIN_BOOL,
132         E_PMINFO_APPINFO_PROP_APP_MULTIPLE,
133         E_PMINFO_APPINFO_PROP_APP_ONBOOT,
134         E_PMINFO_APPINFO_PROP_APP_AUTORESTART,
135         E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,
136         E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,
137         E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,
138         E_PMINFO_APPINFO_PROP_APP_DISABLE,
139         E_PMINFO_APPINFO_PROP_APP_REMOVABLE,
140         E_PMINFO_APPINFO_PROP_APP_MAX_BOOL = E_PMINFO_APPINFO_PROP_APP_REMOVABLE
141 } pkgmgrinfo_appinfo_filter_prop_bool;
142
143 /*Integer properties for filtering based on app info*/
144 typedef enum _pkgmgrinfo_appinfo_filter_prop_int {
145         /*Currently No Fields*/
146         E_PMINFO_APPINFO_PROP_APP_MIN_INT = 601,
147         E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE = E_PMINFO_APPINFO_PROP_APP_MIN_INT,
148         E_PMINFO_APPINFO_PROP_APP_MAX_INT = E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE
149 } pkgmgrinfo_appinfo_filter_prop_int;
150
151 /*Integer properties for filtering based on app info*/
152 typedef enum _pkgmgrinfo_pkginfo_filter_prop_range {
153         /*Currently No Fields*/
154         E_PMINFO_PKGINFO_PROP_RANGE_MIN_INT = 701,
155         E_PMINFO_PKGINFO_PROP_RANGE_BASIC,
156         E_PMINFO_PKGINFO_PROP_RANGE_MAX_INT = E_PMINFO_PKGINFO_PROP_RANGE_BASIC
157 } pkgmgrinfo_pkginfo_filter_prop_range;
158
159 typedef struct _pkgmgr_pkginfo_x {
160         manifest_x *manifest_info;
161         char *locale;
162
163         struct _pkgmgr_pkginfo_x *prev;
164         struct _pkgmgr_pkginfo_x *next;
165 } pkgmgr_pkginfo_x;
166
167 typedef struct _pkgmgr_appinfo_x {
168         char *locale;
169         union {
170                 uiapplication_x *uiapp_info;
171                 serviceapplication_x *svcapp_info;
172         };
173 } pkgmgr_appinfo_x;
174
175 /*For filter APIs*/
176 typedef struct _pkgmgrinfo_filter_x {
177         GSList *list;
178 } pkgmgrinfo_filter_x;
179
180 typedef struct _pkgmgrinfo_node_x {
181         int prop;
182         char *key;
183         char *value;
184 } pkgmgrinfo_node_x;
185
186 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
187
188 int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data);
189 char* __convert_system_locale_to_manifest_locale();
190 gint __compare_func(gconstpointer data1, gconstpointer data2);
191 void __get_filter_condition(gpointer data, char **condition);
192
193 void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
194 void __cleanup_appinfo(pkgmgr_appinfo_x *data);
195 void __cleanup_list_pkginfo(pkgmgr_pkginfo_x *list_pkginfo, pkgmgr_pkginfo_x *node);
196
197 int __pkginfo_check_installed_storage(pkgmgr_pkginfo_x *pkginfo);
198 int __appinfo_check_installed_storage(pkgmgr_appinfo_x *appinfo);
199
200 int _pkgmgrinfo_validate_cb(void *data, int ncols, char **coltxt, char **colname);
201
202 int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
203 int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
204 int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
205 char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid);
206
207 pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
208 pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property);
209 pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property);
210
211 pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property);
212 pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
213 pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
214 pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
215
216 #endif  /* __PKGMGRINFO_PRIVATE_H__ */