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},
75 {E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE, PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE}
78 struct _appinfo_str_map_t {
79 pkgmgrinfo_appinfo_filter_prop_str prop;
83 static struct _appinfo_str_map_t appinfo_str_prop_map[] = {
84 {E_PMINFO_APPINFO_PROP_APP_ID, PMINFO_APPINFO_PROP_APP_ID},
85 {E_PMINFO_APPINFO_PROP_APP_COMPONENT, PMINFO_APPINFO_PROP_APP_COMPONENT},
86 {E_PMINFO_APPINFO_PROP_APP_EXEC, PMINFO_APPINFO_PROP_APP_EXEC},
87 {E_PMINFO_APPINFO_PROP_APP_ICON, PMINFO_APPINFO_PROP_APP_ICON},
88 {E_PMINFO_APPINFO_PROP_APP_TYPE, PMINFO_APPINFO_PROP_APP_TYPE},
89 {E_PMINFO_APPINFO_PROP_APP_OPERATION, PMINFO_APPINFO_PROP_APP_OPERATION},
90 {E_PMINFO_APPINFO_PROP_APP_URI, PMINFO_APPINFO_PROP_APP_URI},
91 {E_PMINFO_APPINFO_PROP_APP_MIME, PMINFO_APPINFO_PROP_APP_MIME},
92 {E_PMINFO_APPINFO_PROP_APP_CATEGORY, PMINFO_APPINFO_PROP_APP_CATEGORY},
93 {E_PMINFO_APPINFO_PROP_APP_HWACCELERATION, PMINFO_APPINFO_PROP_APP_HWACCELERATION},
94 {E_PMINFO_APPINFO_PROP_APP_SCREENREADER, PMINFO_APPINFO_PROP_APP_SCREENREADER},
95 {E_PMINFO_APPINFO_PROP_APP_METADATA_KEY, PMINFO_APPINFO_PROP_APP_METADATA_KEY},
96 {E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE, PMINFO_APPINFO_PROP_APP_METADATA_VALUE},
97 {E_PMINFO_APPINFO_PROP_APP_PACKAGE, PMINFO_APPINFO_PROP_APP_PACKAGE}
100 struct _appinfo_int_map_t {
101 pkgmgrinfo_appinfo_filter_prop_int prop;
102 const char *property;
105 static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
106 /*Currently No Fields*/
109 struct _appinfo_bool_map_t {
110 pkgmgrinfo_appinfo_filter_prop_bool prop;
111 const char *property;
114 static struct _appinfo_bool_map_t appinfo_bool_prop_map[] = {
115 {E_PMINFO_APPINFO_PROP_APP_NODISPLAY, PMINFO_APPINFO_PROP_APP_NODISPLAY},
116 {E_PMINFO_APPINFO_PROP_APP_MULTIPLE, PMINFO_APPINFO_PROP_APP_MULTIPLE},
117 {E_PMINFO_APPINFO_PROP_APP_ONBOOT, PMINFO_APPINFO_PROP_APP_ONBOOT},
118 {E_PMINFO_APPINFO_PROP_APP_AUTORESTART, PMINFO_APPINFO_PROP_APP_AUTORESTART},
119 {E_PMINFO_APPINFO_PROP_APP_TASKMANAGE, PMINFO_APPINFO_PROP_APP_TASKMANAGE},
120 {E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION, PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION},
121 {E_PMINFO_APPINFO_PROP_APP_UI_GADGET, PMINFO_APPINFO_PROP_APP_UI_GADGET},
122 {E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE, PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE}
125 inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
129 pkgmgrinfo_pkginfo_filter_prop_str prop = -1;
131 if (property == NULL)
133 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR + 1;
134 for (i = 0 ; i < max; i++) {
135 if (strcmp(property, pkginfo_str_prop_map[i].property) == 0) {
136 prop = pkginfo_str_prop_map[i].prop;
143 inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
147 pkgmgrinfo_pkginfo_filter_prop_int prop = -1;
149 if (property == NULL)
151 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT + 1;
152 for (i = 0 ; i < max; i++) {
153 if (strcmp(property, pkginfo_int_prop_map[i].property) == 0) {
154 prop = pkginfo_int_prop_map[i].prop;
161 inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
165 pkgmgrinfo_pkginfo_filter_prop_bool prop = -1;
167 if (property == NULL)
169 max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL + 1;
170 for (i = 0 ; i < max; i++) {
171 if (strcmp(property, pkginfo_bool_prop_map[i].property) == 0) {
172 prop = pkginfo_bool_prop_map[i].prop;
179 inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
183 pkgmgrinfo_appinfo_filter_prop_str prop = -1;
185 if (property == NULL)
187 max = E_PMINFO_APPINFO_PROP_APP_MAX_STR - E_PMINFO_APPINFO_PROP_APP_MIN_STR + 1;
188 for (i = 0 ; i < max; i++) {
189 if (strcmp(property, appinfo_str_prop_map[i].property) == 0) {
190 prop = appinfo_str_prop_map[i].prop;
197 inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
201 pkgmgrinfo_appinfo_filter_prop_int prop = -1;
203 if (property == NULL)
205 max = E_PMINFO_APPINFO_PROP_APP_MAX_INT - E_PMINFO_APPINFO_PROP_APP_MIN_INT + 1;
206 for (i = 0 ; i < max; i++) {
207 if (strcmp(property, appinfo_int_prop_map[i].property) == 0) {
208 prop = appinfo_int_prop_map[i].prop;
215 inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
219 pkgmgrinfo_appinfo_filter_prop_bool prop = -1;
221 if (property == NULL)
223 max = E_PMINFO_APPINFO_PROP_APP_MAX_BOOL - E_PMINFO_APPINFO_PROP_APP_MIN_BOOL + 1;
224 for (i = 0 ; i < max; i++) {
225 if (strcmp(property, appinfo_bool_prop_map[i].property) == 0) {
226 prop = appinfo_bool_prop_map[i].prop;
233 void __get_filter_condition(gpointer data, char **condition)
235 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
236 char buf[MAX_QUERY_LEN] = {'\0'};
237 char temp[PKG_STRING_LEN_MAX] = {'\0'};
238 switch (node->prop) {
239 case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
240 snprintf(buf, sizeof(buf), "package_info.package='%s'", node->value);
242 case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
243 snprintf(buf, sizeof(buf), "package_info.package_type='%s'", node->value);
245 case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
246 snprintf(buf, sizeof(buf), "package_info.package_version='%s'", node->value);
248 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
249 snprintf(buf, sizeof(buf), "package_info.install_location='%s'", node->value);
251 case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
252 snprintf(buf, sizeof(buf), "package_info.installed_storage='%s'", node->value);
254 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
255 snprintf(buf, sizeof(buf), "package_info.author_name='%s'", node->value);
257 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
258 snprintf(buf, sizeof(buf), "package_info.author_href='%s'", node->value);
260 case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
261 snprintf(buf, sizeof(buf), "package_info.author_email='%s'", node->value);
263 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE:
264 snprintf(buf, sizeof(buf), "package_privilege_info.privilege='%s'", node->value);
266 case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
267 snprintf(buf, sizeof(buf), "package_info.package_size='%s'", node->value);
269 case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
270 snprintf(buf, sizeof(buf), "package_info.package_removable IN %s", node->value);
272 case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
273 snprintf(buf, sizeof(buf), "package_info.package_preload IN %s", node->value);
275 case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
276 snprintf(buf, sizeof(buf), "package_info.package_readonly IN %s", node->value);
278 case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
279 snprintf(buf, sizeof(buf), "package_info.package_update IN %s", node->value);
281 case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
282 snprintf(buf, sizeof(buf), "package_info.package_appsetting IN %s", node->value);
284 case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
285 snprintf(buf, sizeof(buf), "package_info.package_nodisplay IN %s", node->value);
287 case E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE:
288 snprintf(buf, sizeof(buf), "package_info.package_support_disable IN %s", node->value);
291 case E_PMINFO_APPINFO_PROP_APP_ID:
292 snprintf(buf, sizeof(buf), "package_app_info.app_id='%s'", node->value);
294 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
295 snprintf(buf, sizeof(buf), "package_app_info.app_component='%s'", node->value);
297 case E_PMINFO_APPINFO_PROP_APP_EXEC:
298 snprintf(buf, sizeof(buf), "package_app_info.app_exec='%s'", node->value);
300 case E_PMINFO_APPINFO_PROP_APP_ICON:
301 snprintf(buf, sizeof(buf), "package_app_localized_info.app_icon='%s'", node->value);
303 case E_PMINFO_APPINFO_PROP_APP_TYPE:
304 snprintf(buf, sizeof(buf), "package_app_info.app_type='%s'", node->value);
306 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
307 snprintf(temp, sizeof(temp), "(%s)", node->value);
308 snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE %s|%%|%%", temp);
310 case E_PMINFO_APPINFO_PROP_APP_URI:
311 snprintf(temp, sizeof(temp), "(%s)", node->value);
312 snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE %%|%s|%%", temp);
314 case E_PMINFO_APPINFO_PROP_APP_MIME:
315 snprintf(temp, sizeof(temp), "(%s)", node->value);
316 snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE %%|%%|%s", temp);
318 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
319 snprintf(temp, sizeof(temp), "(%s)", node->value);
320 snprintf(buf, sizeof(buf), "package_app_app_category.category IN %s", temp);
322 case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
323 snprintf(buf, sizeof(buf), "package_app_info.app_nodisplay IN %s", node->value);
325 case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
326 snprintf(buf, sizeof(buf), "package_app_info.app_multiple IN %s", node->value);
328 case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
329 snprintf(buf, sizeof(buf), "package_app_info.app_onboot IN %s", node->value);
331 case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
332 snprintf(buf, sizeof(buf), "package_app_info.app_autorestart IN %s", node->value);
334 case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
335 snprintf(buf, sizeof(buf), "package_app_info.app_taskmanage IN %s", node->value);
337 case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
338 snprintf(buf, sizeof(buf), "package_app_info.app_hwacceleration='%s'", node->value);
340 case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
341 snprintf(buf, sizeof(buf), "package_app_info.app_screenreader='%s'", node->value);
343 case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
344 snprintf(buf, sizeof(buf), "package_app_info.app_launchcondition IN %s", node->value);
346 case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
347 snprintf(buf, sizeof(buf), "package_app_info.package='%s'", node->value);
349 case E_PMINFO_APPINFO_PROP_APP_UI_GADGET:
350 snprintf(buf, sizeof(buf), "package_app_info.app_ui_gadget IN %s", node->value);
352 case E_PMINFO_APPINFO_PROP_APP_METADATA_KEY:
353 snprintf(buf, sizeof(buf), "package_app_app_metadata.md_key='%s'", node->value);
355 case E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE:
356 snprintf(buf, sizeof(buf), "package_app_app_metadata.md_value='%s'", node->value);
358 case E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE:
359 snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_support_disable IN %s", node->value);
362 _LOGE("Invalid Property Type\n");
366 *condition = strdup(buf);
370 char *_get_system_locale(void)
375 lang = vconf_get_str(VCONFKEY_LANGSET);
377 locale = strdup(DEFAULT_LOCALE);
378 if (locale == NULL) {
379 LOGE("out of memory");
385 locale = malloc(sizeof(char) * 6);
386 if (locale == NULL) {
387 LOGE("out of memory");
392 strncpy(locale, lang, 2);
394 locale[3] = tolower(lang[3]);
395 locale[4] = tolower(lang[4]);