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},
51 {E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE, PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE}
54 struct _pkginfo_int_map_t {
55 pkgmgrinfo_pkginfo_filter_prop_int prop;
59 static struct _pkginfo_int_map_t pkginfo_int_prop_map[] = {
60 {E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE, PMINFO_PKGINFO_PROP_PACKAGE_SIZE}
63 struct _pkginfo_bool_map_t {
64 pkgmgrinfo_pkginfo_filter_prop_bool prop;
68 static struct _pkginfo_bool_map_t pkginfo_bool_prop_map[] = {
69 {E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE, PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE},
70 {E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD, PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD},
71 {E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY, PMINFO_PKGINFO_PROP_PACKAGE_READONLY},
72 {E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE, PMINFO_PKGINFO_PROP_PACKAGE_UPDATE},
73 {E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING},
74 {E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING, PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING}
77 struct _appinfo_str_map_t {
78 pkgmgrinfo_appinfo_filter_prop_str prop;
82 static struct _appinfo_str_map_t appinfo_str_prop_map[] = {
83 {E_PMINFO_APPINFO_PROP_APP_ID, PMINFO_APPINFO_PROP_APP_ID},
84 {E_PMINFO_APPINFO_PROP_APP_COMPONENT, PMINFO_APPINFO_PROP_APP_COMPONENT},
85 {E_PMINFO_APPINFO_PROP_APP_EXEC, PMINFO_APPINFO_PROP_APP_EXEC},
86 {E_PMINFO_APPINFO_PROP_APP_ICON, PMINFO_APPINFO_PROP_APP_ICON},
87 {E_PMINFO_APPINFO_PROP_APP_TYPE, PMINFO_APPINFO_PROP_APP_TYPE},
88 {E_PMINFO_APPINFO_PROP_APP_OPERATION, PMINFO_APPINFO_PROP_APP_OPERATION},
89 {E_PMINFO_APPINFO_PROP_APP_URI, PMINFO_APPINFO_PROP_APP_URI},
90 {E_PMINFO_APPINFO_PROP_APP_MIME, PMINFO_APPINFO_PROP_APP_MIME},
91 {E_PMINFO_APPINFO_PROP_APP_CATEGORY, PMINFO_APPINFO_PROP_APP_CATEGORY},
92 {E_PMINFO_APPINFO_PROP_APP_HWACCELERATION, PMINFO_APPINFO_PROP_APP_HWACCELERATION},
93 {E_PMINFO_APPINFO_PROP_APP_SCREENREADER, PMINFO_APPINFO_PROP_APP_SCREENREADER},
94 {E_PMINFO_APPINFO_PROP_APP_METADATA_KEY, PMINFO_APPINFO_PROP_APP_METADATA_KEY},
95 {E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE, PMINFO_APPINFO_PROP_APP_METADATA_VALUE},
96 {E_PMINFO_APPINFO_PROP_APP_PACKAGE, PMINFO_APPINFO_PROP_APP_PACKAGE}
99 struct _appinfo_int_map_t {
100 pkgmgrinfo_appinfo_filter_prop_int prop;
101 const char *property;
104 static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
105 /*Currently No Fields*/
108 struct _appinfo_bool_map_t {
109 pkgmgrinfo_appinfo_filter_prop_bool prop;
110 const char *property;
113 static struct _appinfo_bool_map_t appinfo_bool_prop_map[] = {
114 {E_PMINFO_APPINFO_PROP_APP_NODISPLAY, PMINFO_APPINFO_PROP_APP_NODISPLAY},
115 {E_PMINFO_APPINFO_PROP_APP_MULTIPLE, PMINFO_APPINFO_PROP_APP_MULTIPLE},
116 {E_PMINFO_APPINFO_PROP_APP_ONBOOT, PMINFO_APPINFO_PROP_APP_ONBOOT},
117 {E_PMINFO_APPINFO_PROP_APP_AUTORESTART, PMINFO_APPINFO_PROP_APP_AUTORESTART},
118 {E_PMINFO_APPINFO_PROP_APP_TASKMANAGE, PMINFO_APPINFO_PROP_APP_TASKMANAGE},
119 {E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION, PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION},
120 {E_PMINFO_APPINFO_PROP_APP_UI_GADGET, PMINFO_APPINFO_PROP_APP_UI_GADGET}
123 inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
127 pkgmgrinfo_pkginfo_filter_prop_str prop = -1;
129 if (property == NULL)
131 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR + 1;
132 for (i = 0 ; i < max; i++) {
133 if (strcmp(property, pkginfo_str_prop_map[i].property) == 0) {
134 prop = pkginfo_str_prop_map[i].prop;
141 inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
145 pkgmgrinfo_pkginfo_filter_prop_int prop = -1;
147 if (property == NULL)
149 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT + 1;
150 for (i = 0 ; i < max; i++) {
151 if (strcmp(property, pkginfo_int_prop_map[i].property) == 0) {
152 prop = pkginfo_int_prop_map[i].prop;
159 inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
163 pkgmgrinfo_pkginfo_filter_prop_bool prop = -1;
165 if (property == NULL)
167 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL + 1;
168 for (i = 0 ; i < max; i++) {
169 if (strcmp(property, pkginfo_bool_prop_map[i].property) == 0) {
170 prop = pkginfo_bool_prop_map[i].prop;
177 inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
181 pkgmgrinfo_appinfo_filter_prop_str prop = -1;
183 if (property == NULL)
185 max = E_PMINFO_APPINFO_PROP_APP_MAX_STR - E_PMINFO_APPINFO_PROP_APP_MIN_STR + 1;
186 for (i = 0 ; i < max; i++) {
187 if (strcmp(property, appinfo_str_prop_map[i].property) == 0) {
188 prop = appinfo_str_prop_map[i].prop;
195 inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
199 pkgmgrinfo_appinfo_filter_prop_int prop = -1;
201 if (property == NULL)
203 max = E_PMINFO_APPINFO_PROP_APP_MAX_INT - E_PMINFO_APPINFO_PROP_APP_MIN_INT + 1;
204 for (i = 0 ; i < max; i++) {
205 if (strcmp(property, appinfo_int_prop_map[i].property) == 0) {
206 prop = appinfo_int_prop_map[i].prop;
213 inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
217 pkgmgrinfo_appinfo_filter_prop_bool prop = -1;
219 if (property == NULL)
221 max = E_PMINFO_APPINFO_PROP_APP_MAX_BOOL - E_PMINFO_APPINFO_PROP_APP_MIN_BOOL + 1;
222 for (i = 0 ; i < max; i++) {
223 if (strcmp(property, appinfo_bool_prop_map[i].property) == 0) {
224 prop = appinfo_bool_prop_map[i].prop;
231 void __get_filter_condition(gpointer data, char **condition)
233 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
234 char buf[MAX_QUERY_LEN] = {'\0'};
235 char temp[PKG_STRING_LEN_MAX] = {'\0'};
236 switch (node->prop) {
237 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
238 snprintf(buf, sizeof(buf), "package_info.package='%s'", node->value);
240 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
241 snprintf(buf, sizeof(buf), "package_info.package_type='%s'", node->value);
243 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
244 snprintf(buf, sizeof(buf), "package_info.package_version='%s'", node->value);
246 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
247 snprintf(buf, sizeof(buf), "package_info.install_location='%s'", node->value);
249 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
250 snprintf(buf, sizeof(buf), "package_info.installed_storage='%s'", node->value);
252 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
253 snprintf(buf, sizeof(buf), "package_info.author_name='%s'", node->value);
255 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
256 snprintf(buf, sizeof(buf), "package_info.author_href='%s'", node->value);
258 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
259 snprintf(buf, sizeof(buf), "package_info.author_email='%s'", node->value);
261 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE:
262 snprintf(buf, sizeof(buf), "package_privilege_info.privilege='%s'", node->value);
264 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
265 snprintf(buf, sizeof(buf), "package_info.package_size='%s'", node->value);
267 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
268 snprintf(buf, sizeof(buf), "package_info.package_removable IN %s", node->value);
270 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
271 snprintf(buf, sizeof(buf), "package_info.package_preload IN %s", node->value);
273 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
274 snprintf(buf, sizeof(buf), "package_info.package_readonly IN %s", node->value);
276 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
277 snprintf(buf, sizeof(buf), "package_info.package_update IN %s", node->value);
279 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
280 snprintf(buf, sizeof(buf), "package_info.package_appsetting IN %s", node->value);
282 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
283 snprintf(buf, sizeof(buf), "package_info.package_nodisplay IN %s", node->value);
286 case E_PMINFO_APPINFO_PROP_APP_ID:
287 snprintf(buf, sizeof(buf), "package_app_info.app_id='%s'", node->value);
289 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
290 snprintf(buf, sizeof(buf), "package_app_info.app_component='%s'", node->value);
292 case E_PMINFO_APPINFO_PROP_APP_EXEC:
293 snprintf(buf, sizeof(buf), "package_app_info.app_exec='%s'", node->value);
295 case E_PMINFO_APPINFO_PROP_APP_ICON:
296 snprintf(buf, sizeof(buf), "package_app_localized_info.app_icon='%s'", node->value);
298 case E_PMINFO_APPINFO_PROP_APP_TYPE:
299 snprintf(buf, sizeof(buf), "package_app_info.app_type='%s'", node->value);
301 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
302 snprintf(temp, sizeof(temp), "(%s)", node->value);
303 snprintf(buf, sizeof(buf), "package_app_app_svc.operation IN %s", temp);
305 case E_PMINFO_APPINFO_PROP_APP_URI:
306 snprintf(temp, sizeof(temp), "(%s)", node->value);
307 snprintf(buf, sizeof(buf), "package_app_app_svc.uri_scheme IN %s", temp);
309 case E_PMINFO_APPINFO_PROP_APP_MIME:
310 snprintf(temp, sizeof(temp), "(%s)", node->value);
311 snprintf(buf, sizeof(buf), "package_app_app_svc.mime_type IN %s", temp);
313 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
314 snprintf(temp, sizeof(temp), "(%s)", node->value);
315 snprintf(buf, sizeof(buf), "package_app_app_category.category IN %s", temp);
317 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
318 snprintf(buf, sizeof(buf), "package_app_info.app_nodisplay IN %s", node->value);
320 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
321 snprintf(buf, sizeof(buf), "package_app_info.app_multiple IN %s", node->value);
323 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
324 snprintf(buf, sizeof(buf), "package_app_info.app_onboot IN %s", node->value);
326 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
327 snprintf(buf, sizeof(buf), "package_app_info.app_autorestart IN %s", node->value);
329 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
330 snprintf(buf, sizeof(buf), "package_app_info.app_taskmanage IN %s", node->value);
332 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
333 snprintf(buf, sizeof(buf), "package_app_info.app_hwacceleration='%s'", node->value);
335 case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
336 snprintf(buf, sizeof(buf), "package_app_info.app_screenreader='%s'", node->value);
338 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
339 snprintf(buf, sizeof(buf), "package_app_info.app_launchcondition IN %s", node->value);
341 case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
342 snprintf(buf, sizeof(buf), "package_app_info.package='%s'", node->value);
344 case E_PMINFO_APPINFO_PROP_APP_UI_GADGET:
345 snprintf(buf, sizeof(buf), "package_app_info.app_ui_gadget IN %s", node->value);
347 case E_PMINFO_APPINFO_PROP_APP_METADATA_KEY:
348 snprintf(buf, sizeof(buf), "package_app_app_metadata.md_key='%s'", node->value);
350 case E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE:
351 snprintf(buf, sizeof(buf), "package_app_app_metadata.md_value='%s'", node->value);
354 _LOGE("Invalid Property Type\n");
358 *condition = strdup(buf);
362 char *_get_system_locale(void)
367 lang = vconf_get_str(VCONFKEY_LANGSET);
369 locale = strdup(DEFAULT_LOCALE);
370 if (locale == NULL) {
371 LOGE("out of memory");
377 locale = malloc(sizeof(char) * 6);
378 if (locale == NULL) {
379 LOGE("out of memory");
384 strncpy(locale, lang, 2);
386 locale[3] = tolower(lang[3]);
387 locale[4] = tolower(lang[4]);