Change checking status of pkg installed storage
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_private.c
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 #include <stdlib.h>
24 #include <string.h>
25 #include <stdio.h>
26 #include <ctype.h>
27
28 #include <vconf.h>
29 #include <sqlite3.h>
30 #include <glib.h>
31
32 #include "pkgmgr-info.h"
33 #include "pkgmgrinfo_debug.h"
34 #include "pkgmgrinfo_private.h"
35 #include "pkgmgr_parser.h"
36
37 struct _pkginfo_str_map_t {
38         pkgmgrinfo_pkginfo_filter_prop_str prop;
39         const char *property;
40 };
41
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}
52 };
53
54 struct _pkginfo_int_map_t {
55         pkgmgrinfo_pkginfo_filter_prop_int prop;
56         const char *property;
57 };
58
59 static struct _pkginfo_int_map_t pkginfo_int_prop_map[] = {
60         {E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE,    PMINFO_PKGINFO_PROP_PACKAGE_SIZE}
61 };
62
63 struct _pkginfo_bool_map_t {
64         pkgmgrinfo_pkginfo_filter_prop_bool prop;
65         const char *property;
66 };
67
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},
76         {E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE},
77         {E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE,   PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE}
78 };
79
80 struct _appinfo_str_map_t {
81         pkgmgrinfo_appinfo_filter_prop_str prop;
82         const char *property;
83 };
84
85 static struct _appinfo_str_map_t appinfo_str_prop_map[] = {
86         {E_PMINFO_APPINFO_PROP_APP_ID,          PMINFO_APPINFO_PROP_APP_ID},
87         {E_PMINFO_APPINFO_PROP_APP_COMPONENT,   PMINFO_APPINFO_PROP_APP_COMPONENT},
88         {E_PMINFO_APPINFO_PROP_APP_EXEC,        PMINFO_APPINFO_PROP_APP_EXEC},
89         {E_PMINFO_APPINFO_PROP_APP_ICON,        PMINFO_APPINFO_PROP_APP_ICON},
90         {E_PMINFO_APPINFO_PROP_APP_TYPE,        PMINFO_APPINFO_PROP_APP_TYPE},
91         {E_PMINFO_APPINFO_PROP_APP_OPERATION,   PMINFO_APPINFO_PROP_APP_OPERATION},
92         {E_PMINFO_APPINFO_PROP_APP_URI, PMINFO_APPINFO_PROP_APP_URI},
93         {E_PMINFO_APPINFO_PROP_APP_MIME,        PMINFO_APPINFO_PROP_APP_MIME},
94         {E_PMINFO_APPINFO_PROP_APP_CATEGORY,    PMINFO_APPINFO_PROP_APP_CATEGORY},
95         {E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,      PMINFO_APPINFO_PROP_APP_HWACCELERATION},
96         {E_PMINFO_APPINFO_PROP_APP_SCREENREADER,        PMINFO_APPINFO_PROP_APP_SCREENREADER},
97         {E_PMINFO_APPINFO_PROP_APP_METADATA_KEY,        PMINFO_APPINFO_PROP_APP_METADATA_KEY},
98         {E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE,      PMINFO_APPINFO_PROP_APP_METADATA_VALUE},
99         {E_PMINFO_APPINFO_PROP_APP_PACKAGE,     PMINFO_APPINFO_PROP_APP_PACKAGE},
100         {E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,   PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE}
101 };
102
103 struct _appinfo_int_map_t {
104         pkgmgrinfo_appinfo_filter_prop_int prop;
105         const char *property;
106 };
107
108 static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
109         {E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,    PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER},
110         {E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE,        PMINFO_APPINFO_PROP_APP_SUPPORT_MODE}
111 };
112
113 struct _appinfo_bool_map_t {
114         pkgmgrinfo_appinfo_filter_prop_bool prop;
115         const char *property;
116 };
117
118 static struct _appinfo_bool_map_t appinfo_bool_prop_map[] = {
119         {E_PMINFO_APPINFO_PROP_APP_NODISPLAY,           PMINFO_APPINFO_PROP_APP_NODISPLAY},
120         {E_PMINFO_APPINFO_PROP_APP_MULTIPLE,            PMINFO_APPINFO_PROP_APP_MULTIPLE},
121         {E_PMINFO_APPINFO_PROP_APP_ONBOOT,              PMINFO_APPINFO_PROP_APP_ONBOOT},
122         {E_PMINFO_APPINFO_PROP_APP_AUTORESTART,         PMINFO_APPINFO_PROP_APP_AUTORESTART},
123         {E_PMINFO_APPINFO_PROP_APP_TASKMANAGE,          PMINFO_APPINFO_PROP_APP_TASKMANAGE},
124         {E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,             PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION},
125         {E_PMINFO_APPINFO_PROP_APP_UI_GADGET,           PMINFO_APPINFO_PROP_APP_UI_GADGET},
126         {E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,             PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE},
127         {E_PMINFO_APPINFO_PROP_APP_DISABLE,             PMINFO_APPINFO_PROP_APP_DISABLE},
128         {E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE,               PMINFO_APPINFO_PROP_APP_CHECK_STORAGE}
129 };
130
131 inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
132 {
133         int i = 0;
134         int max = 0;
135         pkgmgrinfo_pkginfo_filter_prop_str prop = -1;
136
137         if (property == NULL)
138                 return -1;
139         max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR + 1;
140         for (i = 0 ; i < max; i++) {
141                 if (strcmp(property, pkginfo_str_prop_map[i].property) == 0) {
142                         prop =  pkginfo_str_prop_map[i].prop;
143                         break;
144                 }
145         }
146         return prop;
147 }
148
149 inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
150 {
151         int i = 0;
152         int max = 0;
153         pkgmgrinfo_pkginfo_filter_prop_int prop = -1;
154
155         if (property == NULL)
156                 return -1;
157         max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT + 1;
158         for (i = 0 ; i < max; i++) {
159                 if (strcmp(property, pkginfo_int_prop_map[i].property) == 0) {
160                         prop =  pkginfo_int_prop_map[i].prop;
161                         break;
162                 }
163         }
164         return prop;
165 }
166
167 inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
168 {
169         int i = 0;
170         int max = 0;
171         pkgmgrinfo_pkginfo_filter_prop_bool prop = -1;
172
173         if (property == NULL)
174                 return -1;
175         max = E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL - E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL + 1;
176         for (i = 0 ; i < max; i++) {
177                 if (strcmp(property, pkginfo_bool_prop_map[i].property) == 0) {
178                         prop =  pkginfo_bool_prop_map[i].prop;
179                         break;
180                 }
181         }
182         return prop;
183 }
184
185 inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
186 {
187         int i = 0;
188         int max = 0;
189         pkgmgrinfo_appinfo_filter_prop_str prop = -1;
190
191         if (property == NULL)
192                 return -1;
193         max = E_PMINFO_APPINFO_PROP_APP_MAX_STR - E_PMINFO_APPINFO_PROP_APP_MIN_STR + 1;
194         for (i = 0 ; i < max; i++) {
195                 if (strcmp(property, appinfo_str_prop_map[i].property) == 0) {
196                         prop =  appinfo_str_prop_map[i].prop;
197                         break;
198                 }
199         }
200         return prop;
201 }
202
203 inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
204 {
205         int i = 0;
206         int max = 0;
207         pkgmgrinfo_appinfo_filter_prop_int prop = -1;
208
209         if (property == NULL)
210                 return -1;
211         max = E_PMINFO_APPINFO_PROP_APP_MAX_INT - E_PMINFO_APPINFO_PROP_APP_MIN_INT + 1;
212         for (i = 0 ; i < max; i++) {
213                 if (strcmp(property, appinfo_int_prop_map[i].property) == 0) {
214                         prop =  appinfo_int_prop_map[i].prop;
215                         break;
216                 }
217         }
218         return prop;
219 }
220
221 inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
222 {
223         int i = 0;
224         int max = 0;
225         pkgmgrinfo_appinfo_filter_prop_bool prop = -1;
226
227         if (property == NULL)
228                 return -1;
229         max = E_PMINFO_APPINFO_PROP_APP_MAX_BOOL - E_PMINFO_APPINFO_PROP_APP_MIN_BOOL + 1;
230         for (i = 0 ; i < max; i++) {
231                 if (strcmp(property, appinfo_bool_prop_map[i].property) == 0) {
232                         prop =  appinfo_bool_prop_map[i].prop;
233                         break;
234                 }
235         }
236         return prop;
237 }
238
239 int __get_filter_condition(gpointer data, char **condition, GList **params)
240 {
241         pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data;
242         char buf[MAX_QUERY_LEN] = {'\0'};
243         int flag = 0;
244         char *ptr = NULL;
245         char *saveptr = NULL;
246
247         switch (node->prop) {
248         case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
249                 snprintf(buf, sizeof(buf), "pi.package=?");
250                 break;
251         case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
252                 snprintf(buf, sizeof(buf), "pi.package_type=?");
253                 break;
254         case E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION:
255                 snprintf(buf, sizeof(buf), "pi.package_version=?");
256                 break;
257         case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
258                 snprintf(buf, sizeof(buf), "pi.install_location=?");
259                 break;
260         case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
261                 snprintf(buf, sizeof(buf), "pi.installed_storage=?");
262                 break;
263         case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
264                 snprintf(buf, sizeof(buf), "pi.author_name=?");
265                 break;
266         case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF:
267                 snprintf(buf, sizeof(buf), "pi.author_href=?");
268                 break;
269         case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL:
270                 snprintf(buf, sizeof(buf), "pi.author_email=?");
271                 break;
272         case E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE:
273                 snprintf(buf, sizeof(buf), "package_privilege_info.privilege=?");
274                 flag = E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO;
275                 break;
276         case E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE:
277                 snprintf(buf, sizeof(buf), "pi.package_size=?");
278                 break;
279         case E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE:
280                 snprintf(buf, sizeof(buf), "pi.package_removable=? COLLATE NOCASE");
281                 break;
282         case E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD:
283                 snprintf(buf, sizeof(buf), "pi.package_preload=? COLLATE NOCASE");
284                 break;
285         case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
286                 snprintf(buf, sizeof(buf), "pi.package_readonly=? COLLATE NOCASE");
287                 break;
288         case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
289                 snprintf(buf, sizeof(buf), "pi.package_update=? COLLATE NOCASE");
290                 break;
291         case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
292                 snprintf(buf, sizeof(buf), "pi.package_appsetting=? COLLATE NOCASE");
293                 break;
294         case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
295                 snprintf(buf, sizeof(buf), "pi.package_nodisplay=? COLLATE NOCASE");
296                 break;
297         case E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE:
298                 snprintf(buf, sizeof(buf), "pi.package_support_disable=? COLLATE NOCASE");
299                 break;
300         case E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE:
301                 snprintf(buf, sizeof(buf), "pi.package_disable=? COLLATE NOCASE");
302                 break;
303
304         case E_PMINFO_APPINFO_PROP_APP_ID:
305                 snprintf(buf, sizeof(buf), "ai.app_id=?");
306                 break;
307         case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
308                 snprintf(buf, sizeof(buf), "ai.app_component=?");
309                 break;
310         case E_PMINFO_APPINFO_PROP_APP_EXEC:
311                 snprintf(buf, sizeof(buf), "ai.app_exec=?");
312                 break;
313         case E_PMINFO_APPINFO_PROP_APP_ICON:
314                 snprintf(buf, sizeof(buf), "package_app_localized_info.app_icon=?");
315                 flag = E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO;
316                 break;
317         case E_PMINFO_APPINFO_PROP_APP_TYPE:
318                 snprintf(buf, sizeof(buf), "ai.app_type=?");
319                 break;
320         case E_PMINFO_APPINFO_PROP_APP_OPERATION:
321                 snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE ?||'|%%%%|%%%%'");
322                 flag = E_PMINFO_APPINFO_JOIN_APP_CONTROL;
323                 break;
324         case E_PMINFO_APPINFO_PROP_APP_URI:
325                 snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE '%%%%|'||?||'|%%%%'");
326                 flag = E_PMINFO_APPINFO_JOIN_APP_CONTROL;
327                 break;
328         case E_PMINFO_APPINFO_PROP_APP_MIME:
329                 snprintf(buf, sizeof(buf), "package_app_app_control.app_control LIKE '%%%%|%%%%|'||?");
330                 flag = E_PMINFO_APPINFO_JOIN_APP_CONTROL;
331                 break;
332         case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
333                 snprintf(buf, sizeof(buf), "package_app_app_category.category IN (");
334                 ptr = strtok_r(node->value, ",", &saveptr);
335                 if (ptr == NULL)
336                         return 0;
337                 strncat(buf, "?", MAX_QUERY_LEN - 2);
338                 *params = g_list_append(*params, strdup(ptr));
339                 while ((ptr = strtok_r(NULL, ",", &saveptr))) {
340                         strncat(buf, ", ?", MAX_QUERY_LEN - strlen(", ?") - 1);
341                         *params = g_list_append(*params, strdup(ptr));
342                 }
343                 strncat(buf, ")", MAX_QUERY_LEN - 2);
344                 *condition = strdup(buf);
345                 flag = E_PMINFO_APPINFO_JOIN_CATEGORY;
346
347                 return flag;
348         case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
349                 snprintf(buf, sizeof(buf), "ai.app_nodisplay=? COLLATE NOCASE");
350                 break;
351         case E_PMINFO_APPINFO_PROP_APP_MULTIPLE:
352                 snprintf(buf, sizeof(buf), "ai.app_multiple=? COLLATE NOCASE");
353                 break;
354         case E_PMINFO_APPINFO_PROP_APP_ONBOOT:
355                 snprintf(buf, sizeof(buf), "ai.app_onboot=? COLLATE NOCASE");
356                 break;
357         case E_PMINFO_APPINFO_PROP_APP_AUTORESTART:
358                 snprintf(buf, sizeof(buf), "ai.app_autorestart=? COLLATE NOCASE");
359                 break;
360         case E_PMINFO_APPINFO_PROP_APP_TASKMANAGE:
361                 snprintf(buf, sizeof(buf), "ai.app_taskmanage=? COLLATE NOCASE");
362                 break;
363         case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
364                 snprintf(buf, sizeof(buf), "ai.app_hwacceleration=?");
365                 break;
366         case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
367                 snprintf(buf, sizeof(buf), "ai.app_screenreader=?");
368                 break;
369         case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
370                 snprintf(buf, sizeof(buf), "ai.app_launchcondition=? COLLATE NOCASE");
371                 break;
372         case E_PMINFO_APPINFO_PROP_APP_PACKAGE:
373                 snprintf(buf, sizeof(buf), "ai.package=?");
374                 break;
375         case E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE:
376                 snprintf(buf, sizeof(buf), "ai.app_installed_storage=?");
377                 break;
378         case E_PMINFO_APPINFO_PROP_APP_UI_GADGET:
379                 snprintf(buf, sizeof(buf), "ai.app_ui_gadget=? COLLATE NOCASE");
380                 break;
381         case E_PMINFO_APPINFO_PROP_APP_METADATA_KEY:
382                 snprintf(buf, sizeof(buf), "package_app_app_metadata.md_key=?");
383                 flag = E_PMINFO_APPINFO_JOIN_METADATA;
384                 break;
385         case E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE:
386                 snprintf(buf, sizeof(buf), "package_app_app_metadata.md_value=?");
387                 flag = E_PMINFO_APPINFO_JOIN_METADATA;
388                 break;
389         case E_PMINFO_APPINFO_PROP_APP_DISABLE:
390                 snprintf(buf, MAX_QUERY_LEN, "ai.app_disable=? COLLATE NOCASE");
391                 break;
392         case E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE:
393                 snprintf(buf, MAX_QUERY_LEN, "ai.app_support_disable=? COLLATE NOCASE");
394                 break;
395         case E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER:
396                 snprintf(buf, MAX_QUERY_LEN, "ai.app_id NOT IN "
397                                 "(SELECT app_id from package_app_info_for_uid WHERE uid=? " \
398                                 "AND is_disabled='true' COLLATE NOCASE)");
399                 break;
400         case E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE:
401                 snprintf(buf, sizeof(buf), "ai.app_support_mode=?");
402                 break;
403         case E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE:
404         case E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE:
405                 *condition = NULL;
406                 return 0;
407         default:
408                 _LOGE("Invalid Property Type\n");
409                 *condition = NULL;
410                 return 0;
411         }
412         *condition = strdup(buf);
413         *params = g_list_append(*params, strdup(node->value));
414         return flag;
415 }
416
417 int _add_icon_info_into_list(const char *locale, char *value, GList **icon)
418 {
419         icon_x *info;
420
421         info = calloc(1, sizeof(icon_x));
422         if (info == NULL) {
423                 LOGE("out of memory");
424                 return PMINFO_R_ERROR;
425         }
426         info->text = value;
427         info->lang = strdup(locale);
428         *icon = g_list_append(*icon, info);
429
430         return PMINFO_R_OK;
431 }
432
433 int _add_label_info_into_list(const char *locale, char *value, GList **label)
434 {
435         label_x *info;
436
437         info = calloc(1, sizeof(label_x));
438         if (info == NULL) {
439                 LOGE("out of memory");
440                 return PMINFO_R_ERROR;
441         }
442         info->text = value;
443         info->lang = strdup(locale);
444         *label = g_list_append(*label, info);
445
446         return PMINFO_R_OK;
447 }
448
449 char *_get_system_locale(void)
450 {
451         char *lang;
452         char *locale;
453
454         lang = vconf_get_str(VCONFKEY_LANGSET);
455         if (lang == NULL) {
456                 locale = strdup(DEFAULT_LOCALE);
457                 if (locale == NULL) {
458                         LOGE("out of memory");
459                         return NULL;
460                 }
461                 return locale;
462         }
463
464         locale = malloc(sizeof(char) * 6);
465         if (locale == NULL) {
466                 LOGE("out of memory");
467                 free(lang);
468                 return NULL;
469         }
470
471         strncpy(locale, lang, 2);
472         locale[2] = '-';
473         locale[3] = tolower(lang[3]);
474         locale[4] = tolower(lang[4]);
475         locale[5] = '\0';
476
477         free(lang);
478
479         return locale;
480 }
481
482 int __pkginfo_check_installed_storage(package_x *pkginfo)
483 {
484         char buf[MAX_QUERY_LEN] = {'\0'};
485         int ret;
486
487         retvm_if(pkginfo->package == NULL, PMINFO_R_OK, "pkgid is NULL\n");
488         retvm_if(pkginfo->installed_storage == NULL, PMINFO_R_ERROR,
489                         "installed_storage is NULL\n");
490
491         if (strcmp(pkginfo->installed_storage, "installed_external") == 0) {
492                 snprintf(buf, MAX_QUERY_LEN - 1, "%s", pkginfo->external_path);
493                 ret = access(buf, R_OK);
494                 if (ret != 0) {
495                         _LOGE("can not access [%s] - %d", buf, ret);
496                         return PMINFO_R_ERROR;
497                 }
498         }
499
500         return PMINFO_R_OK;
501 }
502
503 int __appinfo_check_installed_storage(application_x *appinfo)
504 {
505         retvm_if(appinfo->installed_storage == NULL, PMINFO_R_ERROR,
506                         "installed_storage is NULL\n");
507
508         if (strcmp(appinfo->installed_storage, "installed_external") == 0) {
509                 retvm_if(appinfo->external_path == NULL, PMINFO_R_ERROR,
510                                 "external path is NULL\n");
511                 if (access(appinfo->external_path, R_OK) != 0) {
512                         _LOGE("can not access [%s]", appinfo->external_path);
513                         return PMINFO_R_ERROR;
514                 }
515         }
516
517         return PMINFO_R_OK;
518 }
519