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}
119 inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
123 pkgmgrinfo_pkginfo_filter_prop_str prop = -1;
125 if (property == NULL)
127 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR + 1;
128 for (i = 0 ; i < max; i++) {
129 if (strcmp(property, pkginfo_str_prop_map[i].property) == 0) {
130 prop = pkginfo_str_prop_map[i].prop;
137 inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
141 pkgmgrinfo_pkginfo_filter_prop_int prop = -1;
143 if (property == NULL)
145 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT + 1;
146 for (i = 0 ; i < max; i++) {
147 if (strcmp(property, pkginfo_int_prop_map[i].property) == 0) {
148 prop = pkginfo_int_prop_map[i].prop;
155 inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
159 pkgmgrinfo_pkginfo_filter_prop_bool prop = -1;
161 if (property == NULL)
163 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL + 1;
164 for (i = 0 ; i < max; i++) {
165 if (strcmp(property, pkginfo_bool_prop_map[i].property) == 0) {
166 prop = pkginfo_bool_prop_map[i].prop;
173 inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
177 pkgmgrinfo_appinfo_filter_prop_str prop = -1;
179 if (property == NULL)
181 max = E_PMINFO_APPINFO_PROP_APP_MAX_STR - E_PMINFO_APPINFO_PROP_APP_MIN_STR + 1;
182 for (i = 0 ; i < max; i++) {
183 if (strcmp(property, appinfo_str_prop_map[i].property) == 0) {
184 prop = appinfo_str_prop_map[i].prop;
191 inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
195 pkgmgrinfo_appinfo_filter_prop_int prop = -1;
197 if (property == NULL)
199 max = E_PMINFO_APPINFO_PROP_APP_MAX_INT - E_PMINFO_APPINFO_PROP_APP_MIN_INT + 1;
200 for (i = 0 ; i < max; i++) {
201 if (strcmp(property, appinfo_int_prop_map[i].property) == 0) {
202 prop = appinfo_int_prop_map[i].prop;
209 inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
213 pkgmgrinfo_appinfo_filter_prop_bool prop = -1;
215 if (property == NULL)
217 max = E_PMINFO_APPINFO_PROP_APP_MAX_BOOL - E_PMINFO_APPINFO_PROP_APP_MIN_BOOL + 1;
218 for (i = 0 ; i < max; i++) {
219 if (strcmp(property, appinfo_bool_prop_map[i].property) == 0) {
220 prop = appinfo_bool_prop_map[i].prop;
227 void __get_filter_condition(gpointer data, char **condition)
229 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
230 char buf[MAX_QUERY_LEN + 1] = {'\0'};
231 char temp[PKG_STRING_LEN_MAX] = {'\0'};
232 switch (node->prop) {
233 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
234 snprintf(buf, MAX_QUERY_LEN, "package_info.package='%s'", node->value);
236 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
237 snprintf(buf, MAX_QUERY_LEN, "package_info.package_type='%s'", node->value);
239 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
240 snprintf(buf, MAX_QUERY_LEN, "package_info.package_version='%s'", node->value);
242 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
243 snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
245 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
246 snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
248 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
249 snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
251 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
252 snprintf(buf, MAX_QUERY_LEN, "package_info.author_href='%s'", node->value);
254 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
255 snprintf(buf, MAX_QUERY_LEN, "package_info.author_email='%s'", node->value);
257 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
258 snprintf(buf, MAX_QUERY_LEN, "package_info.package_size='%s'", node->value);
260 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
261 snprintf(buf, MAX_QUERY_LEN, "package_info.package_removable IN %s", node->value);
263 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
264 snprintf(buf, MAX_QUERY_LEN, "package_info.package_preload IN %s", node->value);
266 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
267 snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
269 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
270 snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
272 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
273 snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
275 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
276 snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
279 case E_PMINFO_APPINFO_PROP_APP_ID:
280 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
282 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
283 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_component='%s'", node->value);
285 case E_PMINFO_APPINFO_PROP_APP_EXEC:
286 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_exec='%s'", node->value);
288 case E_PMINFO_APPINFO_PROP_APP_ICON:
289 snprintf(buf, MAX_QUERY_LEN, "package_app_localized_info.app_icon='%s'", node->value);
291 case E_PMINFO_APPINFO_PROP_APP_TYPE:
292 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_type='%s'", node->value);
294 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
295 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
296 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.operation IN %s", temp);
298 case E_PMINFO_APPINFO_PROP_APP_URI:
299 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
300 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.uri_scheme IN %s", temp);
302 case E_PMINFO_APPINFO_PROP_APP_MIME:
303 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
304 snprintf(buf, MAX_QUERY_LEN, "package_app_app_svc.mime_type IN %s", temp);
306 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
307 snprintf(temp, PKG_STRING_LEN_MAX, "(%s)", node->value);
308 snprintf(buf, MAX_QUERY_LEN, "package_app_app_category.category IN %s", temp);
310 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
311 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_nodisplay IN %s", node->value);
313 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
314 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_multiple IN %s", node->value);
316 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
317 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_onboot IN %s", node->value);
319 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
320 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_autorestart IN %s", node->value);
322 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
323 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_taskmanage IN %s", node->value);
325 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
326 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
328 case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
329 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
331 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
332 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
334 case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
335 snprintf(buf, MAX_QUERY_LEN, "package_app_info.package='%s'", node->value);
338 _LOGE("Invalid Property Type\n");
342 *condition = strdup(buf);
346 char *_get_system_locale(void)
351 lang = vconf_get_str(VCONFKEY_LANGSET);
353 locale = strdup(DEFAULT_LOCALE);
354 if (locale == NULL) {
355 LOGE("out of memory");
361 locale = malloc(sizeof(char) * 6);
362 if (locale == NULL) {
363 LOGE("out of memory");
368 strncpy(locale, lang, 2);
370 locale[3] = tolower(lang[3]);
371 locale[4] = tolower(lang[4]);