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.
32 #include "pkgmgr-info.h"
33 #include "pkgmgrinfo_debug.h"
34 #include "pkgmgrinfo_private.h"
35 #include "pkgmgr_parser.h"
37 struct _pkginfo_str_map_t {
38 pkgmgrinfo_pkginfo_filter_prop_str prop;
42 static struct _pkginfo_str_map_t pkginfo_str_prop_map[] = {
43 {E_PMINFO_PKGINFO_PROP_PACKAGE_ID, PMINFO_PKGINFO_PROP_PACKAGE_ID},
44 {E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE, PMINFO_PKGINFO_PROP_PACKAGE_TYPE},
45 {E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION, PMINFO_PKGINFO_PROP_PACKAGE_VERSION},
46 {E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION,PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION},
47 {E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE,PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE},
48 {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME, PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME},
49 {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL, PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL},
50 {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF, PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF}
53 struct _pkginfo_int_map_t {
54 pkgmgrinfo_pkginfo_filter_prop_int prop;
58 static struct _pkginfo_int_map_t pkginfo_int_prop_map[] = {
59 {E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE, PMINFO_PKGINFO_PROP_PACKAGE_SIZE}
62 struct _pkginfo_bool_map_t {
63 pkgmgrinfo_pkginfo_filter_prop_bool prop;
67 static struct _pkginfo_bool_map_t pkginfo_bool_prop_map[] = {
68 {E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE},
69 {E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD},
70 {E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY, PMINFO_PKGINFO_PROP_PACKAGE_READONLY},
71 {E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE, PMINFO_PKGINFO_PROP_PACKAGE_UPDATE},
72 {E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING},
73 {E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING, PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING}
76 struct _appinfo_str_map_t {
77 pkgmgrinfo_appinfo_filter_prop_str prop;
81 static struct _appinfo_str_map_t appinfo_str_prop_map[] = {
82 {E_PMINFO_APPINFO_PROP_APP_ID, PMINFO_APPINFO_PROP_APP_ID},
83 {E_PMINFO_APPINFO_PROP_APP_COMPONENT, PMINFO_APPINFO_PROP_APP_COMPONENT},
84 {E_PMINFO_APPINFO_PROP_APP_EXEC, PMINFO_APPINFO_PROP_APP_EXEC},
85 {E_PMINFO_APPINFO_PROP_APP_ICON, PMINFO_APPINFO_PROP_APP_ICON},
86 {E_PMINFO_APPINFO_PROP_APP_TYPE, PMINFO_APPINFO_PROP_APP_TYPE},
87 {E_PMINFO_APPINFO_PROP_APP_OPERATION, PMINFO_APPINFO_PROP_APP_OPERATION},
88 {E_PMINFO_APPINFO_PROP_APP_URI, PMINFO_APPINFO_PROP_APP_URI},
89 {E_PMINFO_APPINFO_PROP_APP_MIME, PMINFO_APPINFO_PROP_APP_MIME},
90 {E_PMINFO_APPINFO_PROP_APP_CATEGORY, PMINFO_APPINFO_PROP_APP_CATEGORY},
91 {E_PMINFO_APPINFO_PROP_APP_HWACCELERATION, PMINFO_APPINFO_PROP_APP_HWACCELERATION},
92 {E_PMINFO_APPINFO_PROP_APP_SCREENREADER, PMINFO_APPINFO_PROP_APP_SCREENREADER},
93 {E_PMINFO_APPINFO_PROP_APP_PACKAGE, PMINFO_APPINFO_PROP_APP_PACKAGE}
96 struct _appinfo_int_map_t {
97 pkgmgrinfo_appinfo_filter_prop_int prop;
101 static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
102 /*Currently No Fields*/
105 struct _appinfo_bool_map_t {
106 pkgmgrinfo_appinfo_filter_prop_bool prop;
107 const char *property;
110 static struct _appinfo_bool_map_t appinfo_bool_prop_map[] = {
111 {E_PMINFO_APPINFO_PROP_APP_NODISPLAY, PMINFO_APPINFO_PROP_APP_NODISPLAY},
112 {E_PMINFO_APPINFO_PROP_APP_MULTIPLE, PMINFO_APPINFO_PROP_APP_MULTIPLE},
113 {E_PMINFO_APPINFO_PROP_APP_ONBOOT, PMINFO_APPINFO_PROP_APP_ONBOOT},
114 {E_PMINFO_APPINFO_PROP_APP_AUTORESTART, PMINFO_APPINFO_PROP_APP_AUTORESTART},
115 {E_PMINFO_APPINFO_PROP_APP_TASKMANAGE, PMINFO_APPINFO_PROP_APP_TASKMANAGE},
116 {E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION, PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION},
117 {E_PMINFO_APPINFO_PROP_APP_UI_GADGET, PMINFO_APPINFO_PROP_APP_UI_GADGET}
120 inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
124 pkgmgrinfo_pkginfo_filter_prop_str prop = -1;
126 if (property == NULL)
128 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR + 1;
129 for (i = 0 ; i < max; i++) {
130 if (strcmp(property, pkginfo_str_prop_map[i].property) == 0) {
131 prop = pkginfo_str_prop_map[i].prop;
138 inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
142 pkgmgrinfo_pkginfo_filter_prop_int prop = -1;
144 if (property == NULL)
146 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT + 1;
147 for (i = 0 ; i < max; i++) {
148 if (strcmp(property, pkginfo_int_prop_map[i].property) == 0) {
149 prop = pkginfo_int_prop_map[i].prop;
156 inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
160 pkgmgrinfo_pkginfo_filter_prop_bool prop = -1;
162 if (property == NULL)
164 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL + 1;
165 for (i = 0 ; i < max; i++) {
166 if (strcmp(property, pkginfo_bool_prop_map[i].property) == 0) {
167 prop = pkginfo_bool_prop_map[i].prop;
174 inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
178 pkgmgrinfo_appinfo_filter_prop_str prop = -1;
180 if (property == NULL)
182 max = E_PMINFO_APPINFO_PROP_APP_MAX_STR - E_PMINFO_APPINFO_PROP_APP_MIN_STR + 1;
183 for (i = 0 ; i < max; i++) {
184 if (strcmp(property, appinfo_str_prop_map[i].property) == 0) {
185 prop = appinfo_str_prop_map[i].prop;
192 inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
196 pkgmgrinfo_appinfo_filter_prop_int prop = -1;
198 if (property == NULL)
200 max = E_PMINFO_APPINFO_PROP_APP_MAX_INT - E_PMINFO_APPINFO_PROP_APP_MIN_INT + 1;
201 for (i = 0 ; i < max; i++) {
202 if (strcmp(property, appinfo_int_prop_map[i].property) == 0) {
203 prop = appinfo_int_prop_map[i].prop;
210 inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
214 pkgmgrinfo_appinfo_filter_prop_bool prop = -1;
216 if (property == NULL)
218 max = E_PMINFO_APPINFO_PROP_APP_MAX_BOOL - E_PMINFO_APPINFO_PROP_APP_MIN_BOOL + 1;
219 for (i = 0 ; i < max; i++) {
220 if (strcmp(property, appinfo_bool_prop_map[i].property) == 0) {
221 prop = appinfo_bool_prop_map[i].prop;
228 void __get_filter_condition(gpointer data, char **condition)
230 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
231 char buf[MAX_QUERY_LEN + 1] = {'\0'};
232 char temp[PKG_STRING_LEN_MAX] = {'\0'};
233 switch (node->prop) {
234 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
235 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
237 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
238 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
240 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
241 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
243 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
244 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
246 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
247 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
249 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
250 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
252 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
253 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
255 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
256 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
258 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
259 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
261 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
262 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
264 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
265 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
267 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
268 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
270 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
271 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
273 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
274 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
276 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
277 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
280 case E_PMINFO_APPINFO_PROP_APP_ID:
281 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
283 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
284 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
286 case E_PMINFO_APPINFO_PROP_APP_EXEC:
287 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
289 case E_PMINFO_APPINFO_PROP_APP_ICON:
290 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
292 case E_PMINFO_APPINFO_PROP_APP_TYPE:
293 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
295 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
296 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
297 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
299 case E_PMINFO_APPINFO_PROP_APP_URI:
300 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
301 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
303 case E_PMINFO_APPINFO_PROP_APP_MIME:
304 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
305 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
307 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
308 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
309 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
311 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
312 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
314 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
315 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
317 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
318 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
320 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
321 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
323 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
324 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
326 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
327 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
329 case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
330 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
332 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
333 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
335 case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
336 snprintf(buf, MAX_QUERY_LEN, "package_app_info.package='%s'", node->value);
338 case E_PMINFO_APPINFO_PROP_APP_UI_GADGET:
339 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_ui_gadget IN %s", node->value);
342 _LOGE("Invalid Property Type\n");
346 *condition = strdup(buf);
350 char *_get_system_locale(void)
355 lang = vconf_get_str(VCONFKEY_LANGSET);
357 locale = strdup(DEFAULT_LOCALE);
358 if (locale == NULL) {
359 LOGE("out of memory");
365 locale = malloc(sizeof(char) * 6);
366 if (locale == NULL) {
367 LOGE("out of memory");
372 strncpy(locale, lang, 2);
374 locale[3] = tolower(lang[3]);
375 locale[4] = tolower(lang[4]);