Change to use dlopen for direct access
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_appinfo.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdbool.h>
4 #include <string.h>
5 #include <ctype.h>
6 #include <unistd.h>
7 #include <sys/types.h>
8 #include <dlfcn.h>
9
10 #include <glib.h>
11
12 #include "pkgmgr-info.h"
13 #include "pkgmgrinfo_debug.h"
14 #include "pkgmgrinfo_private.h"
15 #include "pkgmgr_parser.h"
16 #include "manager/pkginfo_manager.h"
17
18 static bool _get_bool_value(const char *str)
19 {
20         if (str && !strcmp(str, "true"))
21                 return true;
22         else
23                 return false;
24 }
25
26 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
27 {
28         pkgmgr_appinfo_x *info = data;
29
30         if (info != NULL) {
31                 if (info->package)
32                         free((void *)info->package);
33                 if (info->locale)
34                         free((void *)info->locale);
35
36                 pkgmgrinfo_basic_free_application(info->app_info);
37                 free((void *)info);
38         }
39 }
40
41 static void __free_applications(gpointer data)
42 {
43         pkgmgrinfo_basic_free_application((application_x *)data);
44 }
45
46 static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
47 {
48         pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
49         pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
50
51         if (value == E_APPINFO_DISABLE_TYPE_PKG)
52                 return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
53                                 ? 0 : 1;
54         else
55                 return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
56                                 ? 0 : 1;
57 }
58
59 static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
60                 pkgmgrinfo_appinfo_disable_type type)
61 {
62         GSList *link;
63
64         if (filter == NULL)
65                 return false;
66
67         link = g_slist_find_custom(filter->list,
68                         GINT_TO_POINTER(type), __disable_chk_func);
69         if (link)
70                 return true;
71
72         return false;
73 }
74
75 static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
76         pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
77 {
78         int ret = PMINFO_R_OK;
79         GHashTable *list;
80         pkgmgr_appinfo_x *info;
81
82         if (appid == NULL || filter == NULL || handle == NULL) {
83                 LOGE("invalid parameter");
84                 return PMINFO_R_EINVAL;
85         }
86
87         list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
88                         __free_applications);
89         if (list == NULL)
90                 return PMINFO_R_ERROR;
91
92         ret = _appinfo_get_applications(uid, filter,
93                         PMINFO_APPINFO_GET_ALL, list);
94         if (ret != PMINFO_R_OK) {
95                 g_hash_table_destroy(list);
96                 return ret;
97         }
98
99         if (!g_hash_table_size(list)) {
100                 _LOGD("appinfo for [%s] is not existed for user [%d]",
101                                 appid, uid);
102                 g_hash_table_destroy(list);
103                 return PMINFO_R_ENOENT;
104         }
105
106         info = calloc(1, sizeof(pkgmgr_appinfo_x));
107         if (info == NULL) {
108                 _LOGE("out of memory");
109                 g_hash_table_destroy(list);
110                 return PMINFO_R_ERROR;
111         }
112
113         info->app_info = (application_x *)g_hash_table_lookup(list, appid);
114         if (!info->app_info || !info->app_info->package) {
115                 _LOGD("appinfo for [%s] is not existed for user [%d]",
116                                 appid, uid);
117                 g_hash_table_destroy(list);
118                 free(info);
119                 return PMINFO_R_ENOENT;
120         }
121         info->locale = strdup(info->app_info->locale);
122         if (!info->locale) {
123                 _LOGE("out of memory");
124                 g_hash_table_destroy(list);
125                 free(info);
126                 return PMINFO_R_ERROR;
127         }
128         info->package = strdup(info->app_info->package);
129         if (!info->package) {
130                 _LOGE("out of memory");
131                 free(info->locale);
132                 g_hash_table_destroy(list);
133                 free(info);
134                 return PMINFO_R_ERROR;
135         }
136
137         /* just free list only */
138         g_hash_table_steal(list, (gconstpointer)appid);
139         g_hash_table_destroy(list);
140
141         *handle = info;
142
143         return ret;
144 }
145
146 API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
147                 const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
148 {
149         int ret;
150         pkgmgrinfo_appinfo_filter_h filter;
151
152         if (appid == NULL || handle == NULL) {
153                 LOGE("invalid parameter");
154                 return PMINFO_R_EINVAL;
155         }
156
157         ret = pkgmgrinfo_appinfo_filter_create(&filter);
158         if (ret != PMINFO_R_OK)
159                 return ret;
160
161         ret = pkgmgrinfo_appinfo_filter_add_string(filter,
162                         PMINFO_APPINFO_PROP_APP_ID, appid);
163         if (ret != PMINFO_R_OK) {
164                 pkgmgrinfo_appinfo_filter_destroy(filter);
165                 return PMINFO_R_ERROR;
166         }
167
168         ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
169                         PMINFO_APPINFO_PROP_APP_DISABLE, true);
170         if (ret != PMINFO_R_OK) {
171                 pkgmgrinfo_appinfo_filter_destroy(filter);
172                 return PMINFO_R_ERROR;
173         }
174
175         ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
176         pkgmgrinfo_appinfo_filter_destroy(filter);
177
178         return ret;
179 }
180
181 API int pkgmgrinfo_appinfo_get_disabled_appinfo(
182                 const char *appid, pkgmgrinfo_appinfo_h *handle)
183 {
184         return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
185                         appid, _getuid(), handle);
186 }
187
188 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
189                 pkgmgrinfo_appinfo_h *handle)
190 {
191         int ret;
192         pkgmgrinfo_appinfo_filter_h filter;
193
194         if (appid == NULL || handle == NULL) {
195                 LOGE("invalid parameter");
196                 return PMINFO_R_EINVAL;
197         }
198
199         ret = pkgmgrinfo_appinfo_filter_create(&filter);
200         if (ret != PMINFO_R_OK)
201                 return ret;
202
203         ret = pkgmgrinfo_appinfo_filter_add_string(filter,
204                         PMINFO_APPINFO_PROP_APP_ID, appid);
205         if (ret != PMINFO_R_OK) {
206                 pkgmgrinfo_appinfo_filter_destroy(filter);
207                 return PMINFO_R_ERROR;
208         }
209
210         ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
211                         PMINFO_APPINFO_PROP_APP_DISABLE, false);
212         if (ret != PMINFO_R_OK) {
213                 pkgmgrinfo_appinfo_filter_destroy(filter);
214                 return PMINFO_R_ERROR;
215         }
216
217         ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
218                         PMINFO_APPINFO_PROP_PKG_DISABLE, false);
219         if (ret != PMINFO_R_OK) {
220                 pkgmgrinfo_appinfo_filter_destroy(filter);
221                 return PMINFO_R_ERROR;
222         }
223
224         ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
225         pkgmgrinfo_appinfo_filter_destroy(filter);
226         return ret;
227 }
228
229 API int pkgmgrinfo_appinfo_get_appinfo(
230                 const char *appid, pkgmgrinfo_appinfo_h *handle)
231 {
232         return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
233 }
234
235 API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
236                 pkgmgrinfo_appinfo_h *handle)
237 {
238         int ret;
239         pkgmgrinfo_appinfo_filter_h filter;
240
241         if (appid == NULL || handle == NULL) {
242                 LOGE("invalid parameter");
243                 return PMINFO_R_EINVAL;
244         }
245
246         ret = pkgmgrinfo_appinfo_filter_create(&filter);
247         if (ret != PMINFO_R_OK)
248                 return ret;
249
250         ret = pkgmgrinfo_appinfo_filter_add_string(filter,
251                         PMINFO_APPINFO_PROP_APP_ID, appid);
252         if (ret != PMINFO_R_OK) {
253                 pkgmgrinfo_appinfo_filter_destroy(filter);
254                 return PMINFO_R_ERROR;
255         }
256
257         ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
258                         PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
259         if (ret != PMINFO_R_OK) {
260                 pkgmgrinfo_appinfo_filter_destroy(filter);
261                 return PMINFO_R_ERROR;
262         }
263
264         ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
265         pkgmgrinfo_appinfo_filter_destroy(filter);
266
267         return ret;
268 }
269
270 API int pkgmgrinfo_appinfo_get_all_appinfo(
271                 const char *appid, pkgmgrinfo_appinfo_h *handle)
272 {
273         return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
274 }
275
276 static gpointer __copy_str(gconstpointer src, gpointer data)
277 {
278         const char *tmp = (const char *)src;
279         char *buffer;
280
281         buffer = strdup(tmp);
282         if (buffer == NULL) {
283                 LOGE("memory alloc failed");
284                 *(int *)data = -1;
285                 return NULL;
286         }
287
288         return buffer;
289 }
290
291 static gpointer __copy_label(gconstpointer src, gpointer data)
292 {
293         label_x *tmp = (label_x *)src;
294         label_x *label;
295
296         label = calloc(1, sizeof(label_x));
297         if (label == NULL) {
298                 LOGE("memory alloc failed");
299                 *(int *)data = -1;
300                 return NULL;
301         }
302
303         if (tmp->name)
304                 label->name = strdup(tmp->name);
305         if (tmp->text)
306                 label->text = strdup(tmp->text);
307         if (tmp->lang)
308                 label->lang = strdup(tmp->lang);
309
310         return label;
311 }
312
313 static gpointer __copy_icon(gconstpointer src, gpointer data)
314 {
315         icon_x *tmp = (icon_x *)src;
316         icon_x *icon;
317
318         icon = calloc(1, sizeof(icon_x));
319         if (icon == NULL) {
320                 LOGE("memory alloc failed");
321                 *(int *)data = -1;
322                 return NULL;
323         }
324
325         if (tmp->text)
326                 icon->text = strdup(tmp->text);
327         if (tmp->lang)
328                 icon->lang = strdup(tmp->lang);
329         if (tmp->section)
330                 icon->section = strdup(tmp->section);
331         if (tmp->size)
332                 icon->size = strdup(tmp->size);
333         if (tmp->resolution)
334                 icon->resolution = strdup(tmp->resolution);
335
336         return icon;
337 }
338
339 static gpointer __copy_metadata(gconstpointer src, gpointer data)
340 {
341         metadata_x *tmp = (metadata_x *)src;
342         metadata_x *metadata;
343
344         metadata = calloc(1, sizeof(metadata_x));
345         if (metadata == NULL) {
346                 LOGE("memory alloc failed");
347                 *(int *)data = -1;
348                 return NULL;
349         }
350
351         if (tmp->key)
352                 metadata->key = strdup(tmp->key);
353         if (tmp->value)
354                 metadata->value = strdup(tmp->value);
355
356         return metadata;
357 }
358
359 static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
360 {
361         datacontrol_x *tmp = (datacontrol_x *)src;
362         datacontrol_x *datacontrol;
363
364         datacontrol = calloc(1, sizeof(datacontrol_x));
365         if (datacontrol == NULL) {
366                 LOGE("memory alloc failed");
367                 *(int *)data = -1;
368                 return NULL;
369         }
370
371         if (tmp->providerid)
372                 datacontrol->providerid = strdup(tmp->providerid);
373         if (tmp->access)
374                 datacontrol->access = strdup(tmp->access);
375         if (tmp->type)
376                 datacontrol->type = strdup(tmp->type);
377         if (tmp->trusted)
378                 datacontrol->trusted = strdup(tmp->trusted);
379
380         return datacontrol;
381 }
382
383 static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
384 {
385         appcontrol_x *tmp = (appcontrol_x *)src;
386         appcontrol_x *appcontrol;
387
388         appcontrol = calloc(1, sizeof(appcontrol_x));
389         if (appcontrol == NULL) {
390                 LOGE("memory alloc failed");
391                 *(int *)data = -1;
392                 return NULL;
393         }
394
395         if (tmp->operation)
396                 appcontrol->operation = strdup(tmp->operation);
397         if (tmp->uri)
398                 appcontrol->uri = strdup(tmp->uri);
399         if (tmp->mime)
400                 appcontrol->mime = strdup(tmp->mime);
401
402         return appcontrol;
403 }
404
405 static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
406 {
407         splashscreen_x *tmp = (splashscreen_x *)src;
408         splashscreen_x *splashscreen;
409
410         splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
411         if (splashscreen == NULL) {
412                 LOGE("memory alloc failed");
413                 *(int *)data = -1;
414                 return NULL;
415         }
416
417         if (tmp->src)
418                 splashscreen->src = strdup(tmp->src);
419         if (tmp->type)
420                 splashscreen->type = strdup(tmp->type);
421         if (tmp->orientation)
422                 splashscreen->orientation = strdup(tmp->orientation);
423         if (tmp->indicatordisplay)
424                 splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
425         if (tmp->operation)
426                 splashscreen->operation = strdup(tmp->operation);
427         if (tmp->color_depth)
428                 splashscreen->color_depth = strdup(tmp->color_depth);
429
430         return splashscreen;
431 }
432
433 static int _appinfo_copy_appinfo(
434                 application_x **application, application_x *data)
435 {
436         application_x *app_info;
437         int ret;
438
439         app_info = calloc(1, sizeof(application_x));
440         if (app_info == NULL) {
441                 LOGE("memory alloc failed");
442                 return PMINFO_R_ERROR;
443         }
444
445         if (data->appid != NULL)
446                 app_info->appid = strdup(data->appid);
447         if (data->exec != NULL)
448                 app_info->exec = strdup(data->exec);
449         if (data->nodisplay != NULL)
450                 app_info->nodisplay = strdup(data->nodisplay);
451         if (data->multiple != NULL)
452                 app_info->multiple = strdup(data->multiple);
453         if (data->taskmanage != NULL)
454                 app_info->taskmanage = strdup(data->taskmanage);
455         if (data->type != NULL)
456                 app_info->type = strdup(data->type);
457         if (data->categories != NULL)
458                 app_info->categories = strdup(data->categories);
459         if (data->hwacceleration != NULL)
460                 app_info->hwacceleration = strdup(data->hwacceleration);
461         if (data->screenreader != NULL)
462                 app_info->screenreader = strdup(data->screenreader);
463         if (data->mainapp != NULL)
464                 app_info->mainapp = strdup(data->mainapp);
465         if (data->package != NULL)
466                 app_info->package = strdup(data->package);
467         if (data->recentimage != NULL)
468                 app_info->recentimage = strdup(data->recentimage);
469         if (data->launchcondition != NULL)
470                 app_info->launchcondition = strdup(data->launchcondition);
471         if (data->indicatordisplay != NULL)
472                 app_info->indicatordisplay = strdup(data->indicatordisplay);
473         if (data->portraitimg != NULL)
474                 app_info->portraitimg = strdup(data->portraitimg);
475         if (data->landscapeimg != NULL)
476                 app_info->landscapeimg = strdup(data->landscapeimg);
477         if (data->guestmode_visibility != NULL)
478                 app_info->guestmode_visibility =
479                                 strdup(data->guestmode_visibility);
480         if (data->component != NULL)
481                 app_info->component = strdup(data->component);
482         if (data->permission_type != NULL)
483                 app_info->permission_type = strdup(data->permission_type);
484         if (data->component_type != NULL)
485                 app_info->component_type = strdup(data->component_type);
486         if (data->preload != NULL)
487                 app_info->preload = strdup(data->preload);
488         if (data->submode != NULL)
489                 app_info->submode = strdup(data->submode);
490         if (data->submode_mainid != NULL)
491                 app_info->submode_mainid = strdup(data->submode_mainid);
492         if (data->process_pool != NULL)
493                 app_info->process_pool = strdup(data->process_pool);
494         if (data->installed_storage != NULL)
495                 app_info->installed_storage = strdup(data->installed_storage);
496         if (data->autorestart != NULL)
497                 app_info->autorestart = strdup(data->autorestart);
498         if (data->onboot != NULL)
499                 app_info->onboot = strdup(data->onboot);
500         if (data->support_disable != NULL)
501                 app_info->support_disable = strdup(data->support_disable);
502         if (data->ui_gadget != NULL)
503                 app_info->ui_gadget = strdup(data->ui_gadget);
504         if (data->launch_mode != NULL)
505                 app_info->launch_mode = strdup(data->launch_mode);
506         if (data->package_type != NULL)
507                 app_info->package_type = strdup(data->package_type);
508         if (data->effective_appid != NULL)
509                 app_info->effective_appid = strdup(data->effective_appid);
510         if (data->splash_screen_display != NULL)
511                 app_info->splash_screen_display =
512                                 strdup(data->splash_screen_display);
513
514         /* GList */
515         ret = 0;
516         app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
517         if (ret < 0) {
518                 LOGE("memory alloc failed");
519                 pkgmgrinfo_basic_free_application(app_info);
520                 return PMINFO_R_ERROR;
521         }
522
523         ret = 0;
524         app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
525         if (ret < 0) {
526                 LOGE("memory alloc failed");
527                 pkgmgrinfo_basic_free_application(app_info);
528                 return PMINFO_R_ERROR;
529         }
530
531         ret = 0;
532         app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
533         if (ret < 0) {
534                 LOGE("memory alloc failed");
535                 pkgmgrinfo_basic_free_application(app_info);
536                 return PMINFO_R_ERROR;
537         }
538
539         ret = 0;
540         app_info->metadata = g_list_copy_deep(data->metadata,
541                         __copy_metadata, &ret);
542         if (ret < 0) {
543                 LOGE("memory alloc failed");
544                 pkgmgrinfo_basic_free_application(app_info);
545                 return PMINFO_R_ERROR;
546         }
547
548         ret = 0;
549         app_info->datacontrol = g_list_copy_deep(data->datacontrol,
550                         __copy_datacontrol, &ret);
551         if (ret < 0) {
552                 LOGE("memory alloc failed");
553                 pkgmgrinfo_basic_free_application(app_info);
554                 return PMINFO_R_ERROR;
555         }
556
557         ret = 0;
558         app_info->appcontrol = g_list_copy_deep(data->appcontrol,
559                         __copy_appcontrol, &ret);
560         if (ret < 0) {
561                 LOGE("memory alloc failed");
562                 pkgmgrinfo_basic_free_application(app_info);
563                 return PMINFO_R_ERROR;
564         }
565
566         ret = 0;
567         app_info->background_category =
568                         g_list_copy_deep(data->background_category,
569                                         __copy_str, &ret);
570         if (ret < 0) {
571                 LOGE("memory alloc failed");
572                 pkgmgrinfo_basic_free_application(app_info);
573                 return PMINFO_R_ERROR;
574         }
575
576         ret = 0;
577         app_info->splashscreens = g_list_copy_deep(data->splashscreens,
578                         __copy_splashscreens, &ret);
579         if (ret < 0) {
580                 LOGE("memory alloc failed");
581                 pkgmgrinfo_basic_free_application(app_info);
582                 return PMINFO_R_ERROR;
583         }
584
585         *application = app_info;
586
587         return PMINFO_R_OK;
588 }
589
590 API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
591                 pkgmgrinfo_appinfo_h *clone)
592 {
593         pkgmgr_appinfo_x *info;
594         pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
595
596         if (handle == NULL)
597                 return PMINFO_R_EINVAL;
598
599         info = calloc(1, sizeof(pkgmgr_appinfo_x));
600         if (info == NULL) {
601                 LOGE("memory alloc failed");
602                 return PMINFO_R_ERROR;
603         }
604
605         if (temp->package != NULL)
606                 info->package = strdup(temp->package);
607         if (temp->locale != NULL)
608                 info->locale = strdup(temp->locale);
609
610         info->app_component = temp->app_component;
611
612         if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
613                 LOGE("appinfo copy failed");
614                 if (info->package)
615                         free((void *)info->package);
616                 if (info->locale)
617                         free(info->locale);
618                 free(info);
619                 return PMINFO_R_ERROR;
620         }
621
622         *clone = info;
623
624         return PMINFO_R_OK;
625 }
626
627 static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
628                 pkgmgrinfo_filter_x *filter, int flag,
629                 pkgmgrinfo_app_list_cb app_list_cb,
630                 void *user_data)
631 {
632         application_x *app;
633         pkgmgr_appinfo_x info;
634         GHashTable *list;
635         GHashTableIter iter;
636         gpointer value;
637         int ret;
638
639         list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
640                         __free_applications);
641         if (list == NULL)
642                 return PMINFO_R_ERROR;
643
644         ret = _appinfo_get_applications(uid, filter,
645                         flag | PMINFO_APPINFO_GET_BASICINFO, list);
646         if (ret == PMINFO_R_ERROR) {
647                 g_hash_table_destroy(list);
648                 return ret;
649         }
650
651         g_hash_table_iter_init(&iter, list);
652         while (g_hash_table_iter_next(&iter, NULL, &value)) {
653                 app = (application_x *)value;
654                 info.app_info = app;
655                 info.locale = info.app_info->locale;
656                 info.package = app->package;
657                 if (app_list_cb(&info, user_data) < 0)
658                         break;
659         }
660         g_hash_table_destroy(list);
661
662         return PMINFO_R_OK;
663 }
664
665 static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
666
667 API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
668                 pkgmgrinfo_app_component component,
669                 pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
670 {
671         int ret;
672         pkgmgrinfo_appinfo_filter_h filter;
673         char *pkgid;
674         const char *comp_str = NULL;
675
676         if (handle == NULL || app_func == NULL) {
677                 LOGE("invalid parameter");
678                 return PMINFO_R_EINVAL;
679         }
680
681         if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
682                 LOGE("invalid parameter");
683                 return PMINFO_R_EINVAL;
684         }
685
686         if (pkgmgrinfo_appinfo_filter_create(&filter))
687                 return PMINFO_R_ERROR;
688
689         if (pkgmgrinfo_appinfo_filter_add_string(filter,
690                                 PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
691                 pkgmgrinfo_appinfo_filter_destroy(filter);
692                 return PMINFO_R_ERROR;
693         }
694
695         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
696                         PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
697                 pkgmgrinfo_appinfo_filter_destroy(filter);
698                 return PMINFO_R_ERROR;
699         }
700
701         comp_str = __appcomponent_str(component);
702
703         if (comp_str) {
704                 if (pkgmgrinfo_appinfo_filter_add_string(filter,
705                                         PMINFO_APPINFO_PROP_APP_COMPONENT,
706                                         comp_str)) {
707                         pkgmgrinfo_appinfo_filter_destroy(filter);
708                         return PMINFO_R_ERROR;
709                 }
710         }
711
712         ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
713                         PMINFO_APPINFO_GET_ALL, app_func, user_data);
714
715         pkgmgrinfo_appinfo_filter_destroy(filter);
716
717         return ret;
718 }
719
720 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
721                 pkgmgrinfo_app_component component,
722                 pkgmgrinfo_app_list_cb app_func, void *user_data)
723 {
724         return pkgmgrinfo_appinfo_get_usr_list(handle,
725                         component, app_func, user_data, _getuid());
726 }
727
728 API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
729                 pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
730                 void *user_data)
731 {
732         int ret;
733         pkgmgrinfo_appinfo_filter_h filter;
734
735         if (app_func == NULL) {
736                 LOGE("invalid parameter");
737                 return PMINFO_R_EINVAL;
738         }
739
740         if (pkgmgrinfo_appinfo_filter_create(&filter))
741                 return PMINFO_R_ERROR;
742
743         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
744                         PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
745                 pkgmgrinfo_appinfo_filter_destroy(filter);
746                 return PMINFO_R_ERROR;
747         }
748
749         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
750                         PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
751                 pkgmgrinfo_appinfo_filter_destroy(filter);
752                 return PMINFO_R_ERROR;
753         }
754
755         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
756                         PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
757                 pkgmgrinfo_appinfo_filter_destroy(filter);
758                 return PMINFO_R_ERROR;
759         }
760
761         ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
762                         user_data);
763
764         pkgmgrinfo_appinfo_filter_destroy(filter);
765
766         return ret;
767 }
768
769 API int pkgmgrinfo_appinfo_get_installed_list_full(
770                 pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
771 {
772         return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
773                         _getuid(), flag, user_data);
774 }
775
776 API int pkgmgrinfo_appinfo_get_usr_installed_list(
777                 pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
778 {
779         int ret;
780         pkgmgrinfo_appinfo_filter_h filter;
781
782         if (app_func == NULL) {
783                 LOGE("invalid parameter");
784                 return PMINFO_R_EINVAL;
785         }
786
787         /* create an empty filter */
788         ret = pkgmgrinfo_appinfo_filter_create(&filter);
789         if (ret != PMINFO_R_OK)
790                 return ret;
791
792         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
793                         PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
794                 pkgmgrinfo_appinfo_filter_destroy(filter);
795                 return PMINFO_R_ERROR;
796         }
797
798         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
799                         PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
800                 pkgmgrinfo_appinfo_filter_destroy(filter);
801                 return PMINFO_R_ERROR;
802         }
803
804         ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
805                         PMINFO_APPINFO_GET_ALL, app_func, user_data);
806
807         pkgmgrinfo_appinfo_filter_destroy(filter);
808
809         return ret;
810 }
811
812 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
813                 void *user_data)
814 {
815         return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
816                         user_data);
817 }
818
819 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
820 {
821         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
822
823         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
824         retvm_if(appid == NULL, PMINFO_R_EINVAL,
825                         "Argument supplied to hold return value is NULL");
826
827         if (info->app_info == NULL || info->app_info->appid == NULL)
828                 return PMINFO_R_ERROR;
829         *appid = (char *)info->app_info->appid;
830
831         return PMINFO_R_OK;
832 }
833
834 API int pkgmgrinfo_appinfo_get_pkgname(
835                 pkgmgrinfo_appinfo_h handle, char **pkg_name)
836 {
837         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
838
839         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
840         retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
841                         "Argument supplied to hold return value is NULL");
842
843         if (info->package == NULL)
844                 return PMINFO_R_ERROR;
845
846         *pkg_name = (char *)info->package;
847
848         return PMINFO_R_OK;
849 }
850
851 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
852 {
853         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
854
855         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
856         retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
857                         "Argument supplied to hold return value is NULL");
858
859         if (info->package == NULL)
860                 return PMINFO_R_ERROR;
861
862         *pkgid = (char *)info->package;
863
864         return PMINFO_R_OK;
865 }
866
867 API int pkgmgrinfo_appinfo_get_pkgtype(
868                 pkgmgrinfo_appinfo_h handle, char **pkgtype)
869 {
870         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
871         retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
872                         "Argument supplied to hold return value is NULL");
873         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
874
875         *pkgtype = (char *)info->app_info->package_type;
876
877         return PMINFO_R_OK;
878 }
879
880 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
881 {
882         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
883
884         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
885         retvm_if(exec == NULL, PMINFO_R_EINVAL,
886                         "Argument supplied to hold return value is NULL");
887
888         if (info->app_info == NULL || info->app_info->exec == NULL)
889                 return PMINFO_R_ERROR;
890         *exec = (char *)info->app_info->exec;
891
892         return PMINFO_R_OK;
893 }
894
895
896 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
897 {
898         icon_x *ptr;
899         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
900
901         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
902         retvm_if(icon == NULL, PMINFO_R_EINVAL,
903                         "Argument supplied to hold return value is NULL");
904
905         if (info->app_info == NULL)
906                 return PMINFO_R_ERROR;
907
908         if (info->app_info->icon == NULL) {
909                 *icon = "";
910                 return PMINFO_R_OK;
911         }
912
913         ptr = (icon_x *)info->app_info->icon->data;
914         if (ptr == NULL)
915                 return PMINFO_R_ERROR;
916
917         if (ptr->text == NULL)
918                 return PMINFO_R_ERROR;
919                 else
920                         *icon = ptr->text;
921
922         return PMINFO_R_OK;
923 }
924
925
926 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
927 {
928         label_x *ptr;
929         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
930         char *lbl = NULL;
931         const char *locale;
932         GList *tmp;
933
934         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
935         retvm_if(label == NULL, PMINFO_R_EINVAL,
936                         "Argument supplied to hold return value is NULL");
937
938         if (info->app_info == NULL)
939                 return PMINFO_R_ERROR;
940
941         locale = info->locale;
942         if (locale == NULL)
943                 locale = DEFAULT_LOCALE;
944
945         for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
946                 ptr = (label_x *)tmp->data;
947                 if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
948                         continue;
949                 lbl = ptr->text;
950                 break;
951         }
952
953         if (lbl != NULL) {
954                 *label = lbl;
955                 return PMINFO_R_OK;
956         }
957
958         for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
959                 ptr = (label_x *)tmp->data;
960                 if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
961                         continue;
962                 lbl = ptr->text;
963                 break;
964         }
965
966         *label = lbl ? lbl : "";
967
968         return PMINFO_R_OK;
969 }
970
971 API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
972                 const char *locale, uid_t uid, char **label)
973 {
974         char *val;
975
976         retvm_if(appid == NULL || locale == NULL || label == NULL,
977                         PMINFO_R_EINVAL, "Argument is NULL");
978         val = _appinfo_get_localed_label(appid, locale, uid);
979         if (val == NULL)
980                 return PMINFO_R_ERROR;
981
982         *label = val;
983         return PMINFO_R_OK;
984 }
985
986 API int pkgmgrinfo_appinfo_get_localed_label(
987                 const char *appid, const char *locale, char **label)
988 {
989         return pkgmgrinfo_appinfo_usr_get_localed_label(
990                         appid, locale, _getuid(), label);
991 }
992
993 API int pkgmgrinfo_appinfo_get_metadata_value(
994                 pkgmgrinfo_appinfo_h handle, const char *metadata_key,
995                 char **metadata_value)
996 {
997         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
998         retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
999         retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
1000                         "metadata_value is NULL");
1001
1002         GList *list_md = NULL;
1003         metadata_x *metadata = NULL;
1004         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1005
1006         list_md = info->app_info->metadata;
1007
1008         for (; list_md; list_md = list_md->next) {
1009                 metadata = (metadata_x *)list_md->data;
1010                 if (metadata && metadata->key) {
1011                         if (strcasecmp(metadata->key, metadata_key) == 0) {
1012                                 if (metadata->value == NULL)
1013                                         *metadata_value = "";
1014                                 else
1015                                         *metadata_value =
1016                                                         (char *)metadata->value;
1017                                 return PMINFO_R_OK;
1018                         }
1019                 }
1020         }
1021
1022         return PMINFO_R_EINVAL;
1023 }
1024
1025 static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
1026 {
1027         if (strcasecmp(comp, "uiapp") == 0)
1028                 return PMINFO_UI_APP;
1029         else if (strcasecmp(comp, "svcapp") == 0)
1030                 return PMINFO_SVC_APP;
1031         else if (strcasecmp(comp, "widgetapp") == 0)
1032                 return PMINFO_WIDGET_APP;
1033         else if (strcasecmp(comp, "watchapp") == 0)
1034                 return PMINFO_WATCH_APP;
1035         else if (strcasecmp(comp, "componentbasedapp") == 0)
1036                 return PMINFO_COMPONENT_BASED_APP;
1037         else
1038                 return -1;
1039 }
1040
1041 static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
1042 {
1043         switch (comp) {
1044         case PMINFO_UI_APP:
1045                 return "uiapp";
1046         case PMINFO_SVC_APP:
1047                 return "svcapp";
1048         case PMINFO_WIDGET_APP:
1049                 return "widgetapp";
1050         case PMINFO_WATCH_APP:
1051                 return "watchapp";
1052         case PMINFO_COMPONENT_BASED_APP:
1053                 return "componentbasedapp";
1054         default:
1055                 return NULL;
1056         }
1057 }
1058
1059 API int pkgmgrinfo_appinfo_get_component(
1060                 pkgmgrinfo_appinfo_h handle,
1061                 pkgmgrinfo_app_component *component)
1062 {
1063         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1064         int comp;
1065
1066         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1067         retvm_if(component == NULL, PMINFO_R_EINVAL,
1068                         "Argument supplied to hold return value is NULL");
1069
1070         if (info->app_info == NULL)
1071                 return PMINFO_R_ERROR;
1072
1073         comp = __appcomponent_convert(info->app_info->component);
1074         if (comp < 0)
1075                 return PMINFO_R_ERROR;
1076
1077         *component = comp;
1078
1079         return PMINFO_R_OK;
1080 }
1081
1082 API int pkgmgrinfo_appinfo_get_apptype(
1083                 pkgmgrinfo_appinfo_h handle, char **app_type)
1084 {
1085         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1086
1087         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1088         retvm_if(app_type == NULL, PMINFO_R_EINVAL,
1089                         "Argument supplied to hold return value is NULL");
1090
1091         if (info->app_info == NULL || info->app_info->type == NULL)
1092                 return PMINFO_R_ERROR;
1093         *app_type = (char *)info->app_info->type;
1094
1095         return PMINFO_R_OK;
1096 }
1097
1098 API int pkgmgrinfo_appinfo_get_notification_icon(
1099                 pkgmgrinfo_appinfo_h handle, char **icon)
1100 {
1101         char *val;
1102         icon_x *ptr;
1103         GList *tmp;
1104         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1105
1106         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1107         retvm_if(icon == NULL, PMINFO_R_EINVAL,
1108                         "Argument supplied to hold return value is NULL\n");
1109
1110         if (info->app_info == NULL)
1111                 return PMINFO_R_ERROR;
1112
1113         for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
1114                 ptr = (icon_x *)tmp->data;
1115                 if (ptr == NULL || ptr->section == NULL)
1116                         continue;
1117
1118                 val = (char *)ptr->section;
1119                 if (val && strcmp(val, "notification") == 0) {
1120                         *icon = (char *)ptr->text;
1121                         return PMINFO_R_OK;
1122                 }
1123         }
1124
1125         return PMINFO_R_ERROR;
1126 }
1127
1128 API int pkgmgrinfo_appinfo_get_recent_image_type(
1129                 pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1130 {
1131         char *val;
1132         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1133
1134         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1135         retvm_if(type == NULL, PMINFO_R_EINVAL,
1136                         "Argument supplied to hold return value is NULL");
1137
1138         if (info->app_info == NULL || info->app_info->recentimage == NULL)
1139                 return PMINFO_R_ERROR;
1140
1141         val = (char *)info->app_info->recentimage;
1142         if (strcasecmp(val, "capture") == 0)
1143                 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1144         else if (strcasecmp(val, "icon") == 0)
1145                 *type = PMINFO_RECENTIMAGE_USE_ICON;
1146         else
1147                 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1148
1149         return PMINFO_R_OK;
1150 }
1151
1152 API int pkgmgrinfo_appinfo_get_preview_image(
1153                 pkgmgrinfo_appinfo_h handle, char **preview_img)
1154 {
1155         char *val;
1156         image_x *ptr;
1157         GList *tmp;
1158         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1159
1160         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1161         retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
1162                         "Argument supplied to hold return value is NULL\n");
1163
1164         if (info->app_info == NULL)
1165                 return PMINFO_R_ERROR;
1166
1167         for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
1168                 ptr = (image_x *)tmp->data;
1169                 if (ptr == NULL || ptr->section == NULL)
1170                         continue;
1171
1172                 val = (char *)ptr->section;
1173                 if (val && strcmp(val, "preview") == 0) {
1174                         *preview_img = (char *)ptr->text;
1175                         return PMINFO_R_OK;
1176                 }
1177         }
1178
1179         return PMINFO_R_ERROR;
1180 }
1181
1182 API int pkgmgrinfo_appinfo_get_permission_type(
1183                 pkgmgrinfo_appinfo_h handle,
1184                 pkgmgrinfo_permission_type *permission)
1185 {
1186         const char *val;
1187         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1188
1189         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1190         retvm_if(permission == NULL, PMINFO_R_EINVAL,
1191                         "Argument supplied to hold return value is NULL\n");
1192
1193         val = info->app_info->permission_type;
1194         if (val == NULL)
1195                 return PMINFO_R_ERROR;
1196
1197         if (strcmp(val, "signature") == 0)
1198                 *permission = PMINFO_PERMISSION_SIGNATURE;
1199         else if (strcmp(val, "privilege") == 0)
1200                 *permission = PMINFO_PERMISSION_PRIVILEGE;
1201         else
1202                 *permission = PMINFO_PERMISSION_NORMAL;
1203
1204         return PMINFO_R_OK;
1205 }
1206
1207 API int pkgmgrinfo_appinfo_get_component_type(
1208                 pkgmgrinfo_appinfo_h handle, char **component_type)
1209 {
1210         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1211
1212         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1213         retvm_if(component_type == NULL, PMINFO_R_EINVAL,
1214                         "Argument supplied to hold return value is NULL");
1215
1216         if (info->app_info == NULL || info->app_info->component_type == NULL)
1217                 return PMINFO_R_ERROR;
1218
1219         *component_type = (char *)info->app_info->component_type;
1220
1221         return PMINFO_R_OK;
1222 }
1223
1224 API int pkgmgrinfo_appinfo_get_hwacceleration(
1225                 pkgmgrinfo_appinfo_h handle,
1226                 pkgmgrinfo_app_hwacceleration *hwacceleration)
1227 {
1228         char *val;
1229         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1230
1231         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1232         retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
1233                         "Argument supplied to hold return value is NULL");
1234
1235         if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
1236                 return PMINFO_R_ERROR;
1237
1238         val = (char *)info->app_info->hwacceleration;
1239         if (strcasecmp(val, "off") == 0)
1240                 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1241         else if (strcasecmp(val, "on") == 0)
1242                 *hwacceleration = PMINFO_HWACCELERATION_ON;
1243         else
1244                 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1245
1246         return PMINFO_R_OK;
1247 }
1248
1249 API int pkgmgrinfo_appinfo_get_screenreader(
1250                 pkgmgrinfo_appinfo_h handle,
1251                 pkgmgrinfo_app_screenreader *screenreader)
1252 {
1253         char *val;
1254         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1255
1256         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1257         retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
1258                         "Argument supplied to hold return value is NULL");
1259
1260         if (info->app_info == NULL || info->app_info->screenreader == NULL)
1261                 return PMINFO_R_ERROR;
1262
1263         val = (char *)info->app_info->screenreader;
1264         if (strcasecmp(val, "screenreader-off") == 0)
1265                 *screenreader = PMINFO_SCREENREADER_OFF;
1266         else if (strcasecmp(val, "screenreader-on") == 0)
1267                 *screenreader = PMINFO_SCREENREADER_ON;
1268         else
1269                 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1270
1271         return PMINFO_R_OK;
1272 }
1273
1274 API int pkgmgrinfo_appinfo_get_effectimage(
1275                 pkgmgrinfo_appinfo_h handle, char **portrait_img,
1276                 char **landscape_img)
1277 {
1278         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1279
1280         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1281         retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
1282                         "Argument supplied to hold return value is NULL");
1283         retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
1284                         "Argument supplied to hold return value is NULL");
1285
1286         if (info->app_info == NULL)
1287                 return PMINFO_R_ERROR;
1288
1289         if (info->app_info->portraitimg == NULL)
1290                 *portrait_img = "";
1291         else
1292                 *portrait_img = (char *)info->app_info->portraitimg;
1293
1294         if (info->app_info->landscapeimg == NULL)
1295                 *landscape_img = "";
1296         else
1297                 *landscape_img = (char *)info->app_info->landscapeimg;
1298
1299         return PMINFO_R_OK;
1300 }
1301
1302 API int pkgmgrinfo_appinfo_get_effectimage_type(
1303                 pkgmgrinfo_appinfo_h handle, char **effectimage_type)
1304 {
1305         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1306
1307         if (handle == NULL || effectimage_type == NULL) {
1308                 LOGE("invalid parameter");
1309                 return PMINFO_R_EINVAL;
1310         }
1311
1312         if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
1313                 return PMINFO_R_ERROR;
1314
1315         *effectimage_type = (char *)info->app_info->effectimage_type;
1316
1317         return PMINFO_R_OK;
1318 }
1319
1320 API int pkgmgrinfo_appinfo_get_submode_mainid(
1321                 pkgmgrinfo_appinfo_h  handle, char **submode_mainid)
1322 {
1323         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1324
1325         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1326         retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
1327                         "Argument supplied to hold return value is NULL");
1328
1329         if (info->app_info == NULL)
1330                 return PMINFO_R_ERROR;
1331
1332         if (info->app_info->submode_mainid == NULL)
1333                 *submode_mainid = "";
1334         else
1335                 *submode_mainid = (char *)info->app_info->submode_mainid;
1336
1337         return PMINFO_R_OK;
1338 }
1339
1340 API int pkgmgrinfo_appinfo_get_installed_storage_location(
1341                 pkgmgrinfo_appinfo_h handle,
1342                 pkgmgrinfo_installed_storage *storage)
1343 {
1344         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1345         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1346
1347         if (info->app_info && info->app_info->installed_storage) {
1348                 if (strcmp(info->app_info->installed_storage,
1349                                         "installed_internal") == 0)
1350                         *storage = PMINFO_INTERNAL_STORAGE;
1351                 else if (strcmp(info->app_info->installed_storage,
1352                                 "installed_external") == 0)
1353                         *storage = PMINFO_EXTERNAL_STORAGE;
1354                 else
1355                         return PMINFO_R_ERROR;
1356         } else {
1357                 return PMINFO_R_ERROR;
1358         }
1359
1360         return PMINFO_R_OK;
1361 }
1362
1363 API int pkgmgrinfo_appinfo_get_launch_mode(
1364                 pkgmgrinfo_appinfo_h handle, char **mode)
1365 {
1366         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1367
1368         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1369         retvm_if(mode == NULL, PMINFO_R_EINVAL,
1370                         "Argument supplied to hold return value is NULL\n");
1371
1372         if (info->app_info->launch_mode == NULL)
1373                 return PMINFO_R_ERROR;
1374
1375         *mode = (char *)(info->app_info->launch_mode);
1376
1377         return PMINFO_R_OK;
1378 }
1379
1380 API int pkgmgrinfo_appinfo_get_alias_appid(
1381                 pkgmgrinfo_appinfo_h handle, char **alias_appid)
1382 {
1383         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1384
1385         if (handle == NULL || alias_appid == NULL) {
1386                 LOGE("invalid parameter");
1387                 return PMINFO_R_EINVAL;
1388         }
1389
1390         if (info->app_info == NULL || info->app_info->alias_appid == NULL)
1391                 return PMINFO_R_ERROR;
1392
1393         *alias_appid = (char *)info->app_info->alias_appid;
1394
1395         return PMINFO_R_OK;
1396 }
1397
1398 API int pkgmgrinfo_appinfo_get_effective_appid(
1399                 pkgmgrinfo_appinfo_h handle, char **effective_appid)
1400 {
1401         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1402
1403         if (handle == NULL || effective_appid == NULL) {
1404                 LOGE("invalid parameter");
1405                 return PMINFO_R_EINVAL;
1406         }
1407
1408         if (info->app_info == NULL)
1409                 return PMINFO_R_ERROR;
1410
1411         if (info->app_info->effective_appid == NULL)
1412                 *effective_appid = "";
1413         else
1414                 *effective_appid = (char *)info->app_info->effective_appid;
1415
1416         return PMINFO_R_OK;
1417 }
1418
1419 API int pkgmgrinfo_appinfo_get_tep_name(
1420                 pkgmgrinfo_appinfo_h handle, char **tep_name)
1421 {
1422         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1423
1424         if (handle == NULL || tep_name == NULL) {
1425                 LOGE("invalid parameter");
1426                 return PMINFO_R_EINVAL;
1427         }
1428
1429         if (info->app_info == NULL)
1430                 return PMINFO_R_ERROR;
1431
1432         if (info->app_info->tep_name == NULL)
1433                 *tep_name = "";
1434         else
1435                 *tep_name = (char *)info->app_info->tep_name;
1436
1437         return PMINFO_R_OK;
1438 }
1439
1440 API int pkgmgrinfo_appinfo_get_zip_mount_file(
1441                 pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
1442 {
1443         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1444
1445         if (handle == NULL || zip_mount_file == NULL) {
1446                 LOGE("invalid parameter");
1447                 return PMINFO_R_EINVAL;
1448         }
1449
1450         if (info->app_info == NULL)
1451                 return PMINFO_R_ERROR;
1452
1453         if (info->app_info->zip_mount_file == NULL)
1454                 *zip_mount_file = "";
1455         else
1456                 *zip_mount_file = (char *)info->app_info->zip_mount_file;
1457
1458         return PMINFO_R_OK;
1459 }
1460
1461 API int pkgmgrinfo_appinfo_get_root_path(
1462                 pkgmgrinfo_appinfo_h handle, char **root_path)
1463 {
1464         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1465
1466         if (handle == NULL || root_path == NULL) {
1467                 LOGE("invalid parameter");
1468                 return PMINFO_R_EINVAL;
1469         }
1470
1471         if (info->app_info == NULL || info->app_info->root_path == NULL)
1472                 return PMINFO_R_ERROR;
1473
1474         *root_path = (char *)info->app_info->root_path;
1475
1476         return PMINFO_R_OK;
1477 }
1478
1479 API int pkgmgrinfo_appinfo_get_api_version(
1480                 pkgmgrinfo_appinfo_h handle, char **api_version)
1481 {
1482         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1483
1484         if (handle == NULL || api_version == NULL) {
1485                 LOGE("invalid parameter");
1486                 return PMINFO_R_EINVAL;
1487         }
1488
1489         if (info->app_info == NULL || info->app_info->api_version == NULL)
1490                 return PMINFO_R_ERROR;
1491
1492         *api_version = (char *)info->app_info->api_version;
1493
1494         return PMINFO_R_OK;
1495 }
1496
1497 API int pkgmgrinfo_appinfo_get_installed_time(
1498                 pkgmgrinfo_appinfo_h handle, int *installed_time)
1499 {
1500         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1501
1502         if (handle == NULL || installed_time == NULL) {
1503                 LOGE("invalid parameter");
1504                 return PMINFO_R_EINVAL;
1505         }
1506
1507         if (info->app_info == NULL ||
1508                         info->app_info->package_installed_time == NULL)
1509                 return PMINFO_R_ERROR;
1510
1511         *installed_time = atoi(info->app_info->package_installed_time);
1512
1513         return PMINFO_R_OK;
1514 }
1515
1516 API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
1517                 const char *type, uid_t uid, char **appid, char **access)
1518 {
1519         int ret;
1520
1521         if (providerid == NULL || type == NULL || appid == NULL ||
1522                         access == NULL) {
1523                 LOGE("invalid parameter");
1524                 return PMINFO_R_EINVAL;
1525         }
1526
1527         ret = _appinfo_get_datacontrol_info(
1528                         providerid, type, uid, appid, access);
1529         /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1530          * implementation, return PMINFO_R_ERROR. This should be
1531          * modified later...
1532          */
1533         if (ret == PMINFO_R_ENOENT) {
1534                 LOGE("no datacontrol info of %s", providerid);
1535                 ret = PMINFO_R_ERROR;
1536         }
1537
1538         return ret;
1539 }
1540
1541 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
1542                 const char *type, char **appid, char **access)
1543 {
1544         return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
1545                         type, _getuid(), appid, access);
1546 }
1547
1548 API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
1549                 uid_t uid, char **appid)
1550 {
1551         int ret;
1552
1553         if (providerid == NULL || appid == NULL) {
1554                 LOGE("invalid parameter");
1555                 return PMINFO_R_EINVAL;
1556         }
1557
1558         ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
1559         /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1560          * implementation, return PMINFO_R_ERROR. This should be
1561          * modified later...
1562          */
1563         if (ret == PMINFO_R_ENOENT) {
1564                 LOGE("no datacontrol appid of %s", providerid);
1565                 ret = PMINFO_R_ERROR;
1566         }
1567
1568         return ret;
1569 }
1570
1571 API int pkgmgrinfo_appinfo_get_datacontrol_appid(
1572                 const char *providerid, char **appid)
1573 {
1574         return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
1575                                 providerid, _getuid(), appid);
1576 }
1577
1578 API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
1579                 const char *providerid, const char *type, uid_t uid,
1580                 char **appid, bool *is_trusted)
1581 {
1582         int ret;
1583         char *trusted = NULL;
1584
1585         if (providerid == NULL || type == NULL || appid == NULL ||
1586                         is_trusted == NULL) {
1587                 LOGE("invalid parameter");
1588                 return PMINFO_R_EINVAL;
1589         }
1590
1591         ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
1592                         appid, &trusted);
1593
1594         /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
1595          * implementation, return PMINFO_R_ERROR. This should be
1596          * modified later...
1597          */
1598         if (ret == PMINFO_R_ENOENT) {
1599                 LOGE("no datacontrol trusted info of %s", providerid);
1600                 ret = PMINFO_R_ERROR;
1601         }
1602         *is_trusted = _get_bool_value(trusted);
1603         free(trusted);
1604
1605         return ret;
1606 }
1607
1608 API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
1609                 const char *type, char **appid, bool *is_trusted)
1610 {
1611         return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
1612                         type, _getuid(), appid, is_trusted);
1613 }
1614
1615 API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1616                 const char *providerid, const char *type,
1617                 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1618                 void *user_data, uid_t uid)
1619 {
1620         int ret;
1621         int count = 0;
1622         GList *list = NULL;
1623         GList *tmp = NULL;
1624
1625         if (providerid == NULL || type == NULL || privilege_func == NULL) {
1626                 LOGE("invalid parameter");
1627                 return PMINFO_R_EINVAL;
1628         }
1629
1630         ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
1631         if (ret == PMINFO_R_ERROR) {
1632                 g_list_free_full(list, free);
1633                 return ret;
1634         }
1635
1636         for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
1637                 count++;
1638                 ret = privilege_func((char *)tmp->data, user_data);
1639                 if (ret < 0)
1640                         break;
1641         }
1642
1643         g_list_free_full(list, free);
1644         return PMINFO_R_OK;
1645 }
1646
1647 API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
1648                 const char *providerid, const char *type,
1649                 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1650                 void *user_data)
1651 {
1652         return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
1653                         providerid, type, privilege_func, user_data, _getuid());
1654 }
1655
1656 API int pkgmgrinfo_appinfo_get_support_mode(
1657                 pkgmgrinfo_appinfo_h  handle, int *support_mode)
1658 {
1659         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1660         retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
1661                         "Argument supplied to hold return value is NULL");
1662
1663         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1664
1665         if (info->app_info->support_mode)
1666                 *support_mode = atoi(info->app_info->support_mode);
1667         else
1668                 *support_mode = 0;
1669
1670         return PMINFO_R_OK;
1671 }
1672
1673 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
1674                 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
1675 {
1676         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1677         retvm_if(category_func == NULL, PMINFO_R_EINVAL,
1678                         "Callback function is NULL");
1679         int ret = -1;
1680         const char *category;
1681         GList *tmp;
1682         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1683
1684         if (info->app_info == NULL)
1685                 return PMINFO_R_ERROR;
1686
1687         for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
1688                 category = (const char *)tmp->data;
1689                 if (category) {
1690                         ret = category_func(category, user_data);
1691                         if (ret < 0)
1692                                 break;
1693                 }
1694         }
1695         return PMINFO_R_OK;
1696 }
1697
1698 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
1699                 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
1700 {
1701         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1702         retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
1703                         "Callback function is NULL");
1704         int ret = -1;
1705         metadata_x *ptr;
1706         GList *tmp;
1707         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1708
1709         if (info->app_info == NULL)
1710                 return PMINFO_R_ERROR;
1711
1712         for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
1713                 ptr = (metadata_x *)tmp->data;
1714                 if (ptr == NULL)
1715                         continue;
1716                 if (ptr->key) {
1717                         ret = metadata_func(ptr->key, ptr->value ?
1718                                         ptr->value : "", user_data);
1719                         if (ret < 0)
1720                                 break;
1721                 }
1722         }
1723         return PMINFO_R_OK;
1724 }
1725
1726 API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
1727                 const char *operation,
1728                 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1729                 void *user_data, uid_t uid)
1730 {
1731         int ret;
1732         GList *privilege_list = NULL;
1733         GList *tmp_list;
1734
1735         if (appid == NULL || operation == NULL || privilege_func == NULL) {
1736                 LOGE("invalid parameter");
1737                 return PMINFO_R_EINVAL;
1738         }
1739
1740         ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
1741                         &privilege_list);
1742         if (ret == PMINFO_R_ENOENT) {
1743                 return PMINFO_R_OK;
1744         } else if (ret != PMINFO_R_OK) {
1745                 g_list_free_full(privilege_list, free);
1746                 return ret;
1747         }
1748
1749         for (tmp_list = privilege_list; tmp_list != NULL;
1750                         tmp_list = g_list_next(tmp_list)) {
1751                 ret = privilege_func((char *)tmp_list->data, user_data);
1752                 if (ret != 0)
1753                         break;
1754         }
1755
1756         g_list_free_full(privilege_list, free);
1757         return PMINFO_R_OK;
1758 }
1759
1760 API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
1761                 const char *operation,
1762                 pkgmgrinfo_pkg_privilege_list_cb privilege_func,
1763                 void *user_data)
1764 {
1765         return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
1766                         operation, privilege_func, user_data, _getuid());
1767 }
1768
1769 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
1770                 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1771 {
1772         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1773         retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1774                         "Callback function is NULL");
1775         int ret;
1776         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1777         appcontrol_x *appcontrol;
1778         GList *tmp;
1779
1780         if (info->app_info == NULL)
1781                 return PMINFO_R_ERROR;
1782
1783         for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1784                 appcontrol = (appcontrol_x *)tmp->data;
1785                 if (appcontrol == NULL || !strcasecmp(
1786                                 appcontrol->visibility, "remote-only"))
1787                         continue;
1788                 ret = appcontrol_func(appcontrol->operation,
1789                                 appcontrol->uri, appcontrol->mime, user_data);
1790                 if (ret < 0)
1791                         break;
1792         }
1793
1794         return PMINFO_R_OK;
1795 }
1796
1797 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
1798                 pkgmgrinfo_appinfo_h handle,
1799                 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
1800 {
1801         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1802         retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
1803                         "Callback function is NULL");
1804         int ret;
1805         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1806         appcontrol_x *appcontrol;
1807         GList *tmp;
1808
1809         if (info->app_info == NULL)
1810                 return PMINFO_R_ERROR;
1811
1812         for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
1813                 appcontrol = (appcontrol_x *)tmp->data;
1814                 if (appcontrol == NULL || !strcasecmp(
1815                                 appcontrol->visibility, "local-only"))
1816                         continue;
1817                 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
1818                                 appcontrol->mime, user_data);
1819                 if (ret < 0)
1820                         break;
1821         }
1822
1823         return PMINFO_R_OK;
1824 }
1825
1826 API int pkgmgrinfo_appinfo_foreach_background_category(
1827                 pkgmgrinfo_appinfo_h handle,
1828                 pkgmgrinfo_app_background_category_list_cb category_func,
1829                 void *user_data)
1830 {
1831         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1832         GList *tmp;
1833         char *category;
1834
1835         if (handle == NULL || category_func == NULL || info->app_info == NULL) {
1836                 LOGE("invalid parameter");
1837                 return PMINFO_R_EINVAL;
1838         }
1839
1840         for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
1841                 category = (char *)tmp->data;
1842                 if (category == NULL)
1843                         continue;
1844
1845                 if (category_func(category, user_data) < 0)
1846                         break;
1847         }
1848
1849         return PMINFO_R_OK;
1850 }
1851
1852 API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
1853                 pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
1854                 void *user_data)
1855 {
1856         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1857         splashscreen_x *splashscreen;
1858         GList *tmp;
1859         int ret;
1860
1861         if (info == NULL || info->app_info == NULL
1862                         || splash_screen_func == NULL) {
1863                 LOGE("invalid parameter");
1864                 return PMINFO_R_EINVAL;
1865         }
1866
1867         for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
1868                 splashscreen = (splashscreen_x *)tmp->data;
1869                 if (splashscreen == NULL)
1870                         continue;
1871                 ret = splash_screen_func(splashscreen->src,
1872                                 splashscreen->type,
1873                                 splashscreen->orientation,
1874                                 splashscreen->indicatordisplay,
1875                                 splashscreen->operation,
1876                                 splashscreen->color_depth,
1877                                 user_data);
1878                 if (ret < 0)
1879                         break;
1880         }
1881
1882         return PMINFO_R_OK;
1883 }
1884
1885 API int pkgmgrinfo_appinfo_is_nodisplay(
1886                 pkgmgrinfo_appinfo_h handle, bool *nodisplay)
1887 {
1888         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1889         retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
1890                         "Argument supplied to hold return value is NULL");
1891         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1892
1893         if (info->app_info == NULL || info->app_info->nodisplay == NULL)
1894                 return PMINFO_R_ERROR;
1895
1896         *nodisplay = _get_bool_value(info->app_info->nodisplay);
1897
1898         return PMINFO_R_OK;
1899 }
1900
1901 API int pkgmgrinfo_appinfo_is_multiple(
1902                 pkgmgrinfo_appinfo_h handle, bool *multiple)
1903 {
1904         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1905         retvm_if(multiple == NULL, PMINFO_R_EINVAL,
1906                         "Argument supplied to hold return value is NULL");
1907         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1908
1909         if (info->app_info == NULL || info->app_info->multiple == NULL)
1910                 return PMINFO_R_ERROR;
1911
1912         *multiple = _get_bool_value(info->app_info->multiple);
1913
1914         return PMINFO_R_OK;
1915 }
1916
1917 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
1918                 pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
1919 {
1920         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1921         retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
1922                         "Argument supplied to hold return value is NULL");
1923         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1924
1925         if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
1926                 return PMINFO_R_ERROR;
1927
1928         *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
1929
1930         return PMINFO_R_OK;
1931 }
1932
1933 API int pkgmgrinfo_appinfo_is_taskmanage(
1934                 pkgmgrinfo_appinfo_h  handle, bool *taskmanage)
1935 {
1936         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1937         retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
1938                         "Argument supplied to hold return value is NULL");
1939         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1940
1941         if (info->app_info == NULL || info->app_info->taskmanage == NULL)
1942                 return PMINFO_R_ERROR;
1943
1944         *taskmanage = _get_bool_value(info->app_info->taskmanage);
1945
1946         return PMINFO_R_OK;
1947 }
1948
1949 API int pkgmgrinfo_appinfo_is_enabled(
1950                 pkgmgrinfo_appinfo_h  handle, bool *enabled)
1951 {
1952         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1953         retvm_if(enabled == NULL, PMINFO_R_EINVAL,
1954                         "Argument supplied to hold return value is NULL");
1955         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1956
1957         if (info->app_info == NULL || info->app_info->is_disabled == NULL)
1958                 return PMINFO_R_ERROR;
1959
1960         *enabled = !_get_bool_value(info->app_info->is_disabled);
1961
1962         return PMINFO_R_OK;
1963 }
1964
1965 API int pkgmgrinfo_appinfo_is_onboot(
1966                 pkgmgrinfo_appinfo_h  handle, bool *onboot)
1967 {
1968         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1969         retvm_if(onboot == NULL, PMINFO_R_EINVAL,
1970                         "Argument supplied to hold return value is NULL");
1971         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1972
1973         if (info->app_info == NULL || info->app_info->onboot == NULL)
1974                 return PMINFO_R_ERROR;
1975
1976         *onboot = _get_bool_value(info->app_info->onboot);
1977
1978         return PMINFO_R_OK;
1979 }
1980
1981 API int pkgmgrinfo_appinfo_is_autorestart(
1982                 pkgmgrinfo_appinfo_h  handle, bool *autorestart)
1983 {
1984         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1985         retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
1986                         "Argument supplied to hold return value is NULL");
1987         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1988
1989         if (info->app_info == NULL || info->app_info->autorestart == NULL)
1990                 return PMINFO_R_ERROR;
1991
1992         *autorestart = _get_bool_value(info->app_info->autorestart);
1993
1994         return PMINFO_R_OK;
1995 }
1996
1997 API int pkgmgrinfo_appinfo_is_mainapp(
1998                 pkgmgrinfo_appinfo_h  handle, bool *mainapp)
1999 {
2000         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2001         retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
2002                         "Argument supplied to hold return value is NULL");
2003         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2004
2005         if (info->app_info == NULL || info->app_info->mainapp == NULL)
2006                 return PMINFO_R_ERROR;
2007
2008         *mainapp = _get_bool_value(info->app_info->mainapp);
2009
2010         return PMINFO_R_OK;
2011 }
2012
2013 API int pkgmgrinfo_appinfo_is_preload(
2014                 pkgmgrinfo_appinfo_h handle, bool *preload)
2015 {
2016         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2017         retvm_if(preload == NULL, PMINFO_R_EINVAL,
2018                         "Argument supplied to hold return value is NULL\n");
2019         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2020
2021         if (info->app_info == NULL || info->app_info->preload == NULL)
2022                 return PMINFO_R_ERROR;
2023
2024         *preload = _get_bool_value(info->app_info->preload);
2025
2026         return PMINFO_R_OK;
2027 }
2028
2029 API int pkgmgrinfo_appinfo_is_submode(
2030                 pkgmgrinfo_appinfo_h handle, bool *submode)
2031 {
2032         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2033         retvm_if(submode == NULL, PMINFO_R_EINVAL,
2034                         "Argument supplied to hold return value is NULL\n");
2035         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2036
2037         if (info->app_info == NULL || info->app_info->submode == NULL)
2038                 return PMINFO_R_ERROR;
2039
2040         *submode = _get_bool_value(info->app_info->submode);
2041
2042         return PMINFO_R_OK;
2043 }
2044
2045 API int pkgmgrinfo_appinfo_is_process_pool(
2046                 pkgmgrinfo_appinfo_h handle, bool *process_pool)
2047 {
2048         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2049
2050         if (handle == NULL || process_pool == NULL) {
2051                 LOGE("invalid parameter");
2052                 return PMINFO_R_EINVAL;
2053         }
2054
2055         if (info->app_info == NULL)
2056                 return PMINFO_R_ERROR;
2057
2058         *process_pool = _get_bool_value(info->app_info->process_pool);
2059
2060         return PMINFO_R_OK;
2061 }
2062
2063 API int pkgmgrinfo_appinfo_is_category_exist(
2064                 pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2065 {
2066         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2067         retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2068         retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2069
2070         const char *val;
2071         GList *tmp;
2072         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2073
2074         if (info->app_info == NULL)
2075                 return PMINFO_R_ERROR;
2076
2077         *exist = 0;
2078         for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
2079                 val = (const char *)tmp->data;
2080                 if (val == NULL)
2081                         continue;
2082                 if (strcasecmp(val, category) == 0) {
2083                         *exist = 1;
2084                         break;
2085                 }
2086         }
2087
2088         return PMINFO_R_OK;
2089 }
2090
2091 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
2092                 bool *ui_gadget)
2093 {
2094         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2095
2096         if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
2097                 _LOGE("invalid parameter");
2098                 return PMINFO_R_EINVAL;
2099         }
2100         if (info->app_info->ui_gadget == NULL)
2101                 info->app_info->ui_gadget = strdup("false");
2102
2103         *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
2104
2105         return PMINFO_R_OK;
2106 }
2107
2108 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
2109                 bool *support_disable)
2110 {
2111         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2112
2113         if (info == NULL || info->app_info == NULL || support_disable == NULL) {
2114                 _LOGE("invalid parameter");
2115                 return PMINFO_R_EINVAL;
2116         }
2117
2118         *support_disable = _get_bool_value(info->app_info->support_disable);
2119
2120         return PMINFO_R_OK;
2121 }
2122
2123 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
2124                 bool *removable)
2125 {
2126         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2127
2128         if (info == NULL || info->app_info == NULL || removable == NULL) {
2129                 _LOGE("invalid parameter");
2130                 return PMINFO_R_EINVAL;
2131         }
2132
2133         *removable = _get_bool_value(info->app_info->removable);
2134
2135         return PMINFO_R_OK;
2136 }
2137
2138 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2139 {
2140         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2141
2142         if (info == NULL || info->app_info == NULL || system == NULL) {
2143                 _LOGE("invalid parameter");
2144                 return PMINFO_R_EINVAL;
2145         }
2146
2147         *system = _get_bool_value(info->app_info->package_system);
2148
2149         return PMINFO_R_OK;
2150 }
2151
2152 API int pkgmgrinfo_appinfo_is_disabled(
2153                 pkgmgrinfo_appinfo_h handle, bool *disabled)
2154 {
2155         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2156         retvm_if(disabled == NULL, PMINFO_R_EINVAL,
2157                         "Argument supplied to hold return value is NULL");
2158         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2159
2160         if (info->app_info == NULL || info->app_info->is_disabled == NULL)
2161                 return PMINFO_R_ERROR;
2162
2163         *disabled = _get_bool_value(info->app_info->is_disabled);
2164
2165         return PMINFO_R_OK;
2166 }
2167
2168 API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
2169 {
2170         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2171
2172         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2173         retvm_if(global == NULL, PMINFO_R_EINVAL,
2174                         "Argument supplied to hold return value is NULL\n");
2175
2176         if (info->app_info == NULL || info->app_info->for_all_users == NULL)
2177                 return PMINFO_R_ERROR;
2178
2179         *global = _get_bool_value(info->app_info->for_all_users);
2180
2181         return PMINFO_R_OK;
2182 }
2183
2184 API int pkgmgrinfo_appinfo_get_splash_screen_display(
2185                 pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
2186 {
2187         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2188
2189         if (info == NULL || splash_screen_display == NULL) {
2190                 _LOGE("Invalid parameter");
2191                 return PMINFO_R_EINVAL;
2192         }
2193
2194         if (info->app_info == NULL ||
2195                         info->app_info->splash_screen_display == NULL)
2196                 return PMINFO_R_ERROR;
2197
2198         *splash_screen_display =
2199                         _get_bool_value(info->app_info->splash_screen_display);
2200
2201         return PMINFO_R_OK;
2202 }
2203
2204 API int pkgmgrinfo_appinfo_get_setup_appid(
2205                 pkgmgrinfo_appinfo_h handle, char **setup_appid)
2206 {
2207         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2208
2209         if (info == NULL || setup_appid == NULL) {
2210                 _LOGE("Invalid parameter");
2211                 return PMINFO_R_EINVAL;
2212         }
2213
2214         if (info->app_info == NULL || info->app_info->setup_appid == NULL)
2215                 return PMINFO_R_ERROR;
2216
2217         *setup_appid = info->app_info->setup_appid;
2218         return PMINFO_R_OK;
2219 }
2220
2221 API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
2222                 bool *support_ambient)
2223 {
2224         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2225
2226         if (info == NULL || support_ambient == NULL) {
2227                 _LOGE("Invalid parameter");
2228                 return PMINFO_R_EINVAL;
2229         }
2230
2231         if (info->app_info == NULL || info->app_info->support_ambient == NULL)
2232                 return PMINFO_R_ERROR;
2233
2234         *support_ambient = _get_bool_value(info->app_info->support_ambient);
2235
2236         return PMINFO_R_OK;
2237 }
2238
2239 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2240 {
2241         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2242         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2243
2244         __cleanup_appinfo(info);
2245         return PMINFO_R_OK;
2246 }
2247
2248 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2249 {
2250         return pkgmgrinfo_pkginfo_filter_create(handle);
2251 }
2252
2253 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2254 {
2255         return pkgmgrinfo_pkginfo_filter_destroy(handle);
2256 }
2257
2258 static gint __compare_func(gconstpointer data1, gconstpointer data2)
2259 {
2260         pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
2261         pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
2262
2263         if (node1->prop == node2->prop)
2264                 return 0;
2265         else if (node1->prop > node2->prop)
2266                 return 1;
2267         else
2268                 return -1;
2269 }
2270
2271 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2272                                 const char *property, const int value)
2273 {
2274         retvm_if(handle == NULL, PMINFO_R_EINVAL,
2275                         "Filter handle input parameter is NULL\n");
2276         retvm_if(property == NULL, PMINFO_R_EINVAL,
2277                         "Filter handle input parameter is NULL\n");
2278         char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2279         char *val = NULL;
2280         GSList *link = NULL;
2281         int prop = -1;
2282
2283         prop = _pminfo_appinfo_convert_to_prop_int(property);
2284         if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2285                 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2286                 _LOGE("Invalid Integer Property\n");
2287                 return PMINFO_R_EINVAL;
2288         }
2289         pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2290         pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2291                         sizeof(pkgmgrinfo_node_x));
2292         if (node == NULL) {
2293                 _LOGE("Out of Memory!!!\n");
2294                 return PMINFO_R_ERROR;
2295         }
2296         snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2297         val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2298         if (val == NULL) {
2299                 _LOGE("Out of Memory\n");
2300                 free(node);
2301                 node = NULL;
2302                 return PMINFO_R_ERROR;
2303         }
2304         node->prop = prop;
2305         node->value = val;
2306
2307         /*
2308          * If API is called multiple times for same property,
2309          * we should override the previous values.
2310          * Last value set will be used for filtering.
2311          */
2312         link = g_slist_find_custom(filter->list,
2313                         (gconstpointer)node, __compare_func);
2314         if (link)
2315                 filter->list = g_slist_delete_link(filter->list, link);
2316         filter->list = g_slist_append(filter->list, (gpointer)node);
2317         return PMINFO_R_OK;
2318
2319 }
2320
2321 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2322                                 const char *property, const bool value)
2323 {
2324         retvm_if(handle == NULL, PMINFO_R_EINVAL,
2325                         "Filter handle input parameter is NULL\n");
2326         retvm_if(property == NULL, PMINFO_R_EINVAL,
2327                         "Filter handle input parameter is NULL\n");
2328         char *val = NULL;
2329         GSList *link = NULL;
2330         int prop = -1;
2331
2332         prop = _pminfo_appinfo_convert_to_prop_bool(property);
2333         if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2334                 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2335                 _LOGE("Invalid Boolean Property\n");
2336                 return PMINFO_R_EINVAL;
2337         }
2338         pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2339         pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2340                         sizeof(pkgmgrinfo_node_x));
2341         if (node == NULL) {
2342                 _LOGE("Out of Memory!!!\n");
2343                 return PMINFO_R_ERROR;
2344         }
2345         if (value)
2346                 val = strndup("true", 4);
2347         else
2348                 val = strndup("false", 5);
2349         if (val == NULL) {
2350                 _LOGE("Out of Memory\n");
2351                 free(node);
2352                 node = NULL;
2353                 return PMINFO_R_ERROR;
2354         }
2355         node->prop = prop;
2356         node->value = val;
2357         /*
2358          * If API is called multiple times for same property,
2359          * we should override the previous values.
2360          * Last value set will be used for filtering.
2361          */
2362         link = g_slist_find_custom(filter->list,
2363                         (gconstpointer)node, __compare_func);
2364         if (link)
2365                 filter->list = g_slist_delete_link(filter->list, link);
2366         filter->list = g_slist_append(filter->list, (gpointer)node);
2367         return PMINFO_R_OK;
2368
2369 }
2370
2371 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2372                                 const char *property, const char *value)
2373 {
2374         retvm_if(handle == NULL, PMINFO_R_EINVAL,
2375                         "Filter handle input parameter is NULL\n");
2376         retvm_if(property == NULL, PMINFO_R_EINVAL,
2377                         "Filter handle input parameter is NULL\n");
2378         retvm_if(value == NULL, PMINFO_R_EINVAL,
2379                         "Filter handle input parameter is NULL\n");
2380         char *val = NULL;
2381         pkgmgrinfo_node_x *ptr = NULL;
2382         char prev[PKG_STRING_LEN_MAX] = {'\0'};
2383         char temp[PKG_STRING_LEN_MAX] = {'\0'};
2384         GSList *link = NULL;
2385         int prop = -1;
2386         int ret;
2387
2388         prop = _pminfo_appinfo_convert_to_prop_str(property);
2389         if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2390                 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2391                 _LOGE("Invalid String Property\n");
2392                 return PMINFO_R_EINVAL;
2393         }
2394         pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2395         pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
2396                         sizeof(pkgmgrinfo_node_x));
2397         if (node == NULL) {
2398                 _LOGE("Out of Memory!!!\n");
2399                 return PMINFO_R_ERROR;
2400         }
2401         node->prop = prop;
2402         switch (prop) {
2403         case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2404                 node->value = strdup(value);
2405                 link = g_slist_find_custom(filter->list,
2406                                 (gconstpointer)node, __compare_func);
2407                 if (link)
2408                         filter->list = g_slist_delete_link(filter->list, link);
2409                 filter->list = g_slist_append(filter->list, (gpointer)node);
2410                 break;
2411         case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2412                 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2413                 if (val == NULL) {
2414                         _LOGE("Out of Memory\n");
2415                         free(node);
2416                         node = NULL;
2417                         return PMINFO_R_ERROR;
2418                 }
2419                 link = g_slist_find_custom(filter->list,
2420                                 (gconstpointer)node, __compare_func);
2421                 if (link) {
2422                         ptr = (pkgmgrinfo_node_x *)link->data;
2423                         strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2424                         _LOGI("Previous value is %s\n", prev);
2425                         filter->list = g_slist_delete_link(filter->list, link);
2426                         ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
2427                                         "%s,%s", prev, value);
2428                         if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
2429                                 _LOGE("snprintf fail\n");
2430                                 free(node);
2431                                 free(val);
2432                                 return PMINFO_R_ERROR;
2433                         }
2434                         strncpy(val, temp, PKG_STRING_LEN_MAX);
2435                         _LOGI("New value is %s\n", val);
2436                         node->value = val;
2437                         filter->list = g_slist_append(
2438                                         filter->list, (gpointer)node);
2439                         memset(temp, '\0', PKG_STRING_LEN_MAX);
2440                 } else {
2441                         snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
2442                         strncpy(val, temp, PKG_STRING_LEN_MAX);
2443                         _LOGI("First value is %s\n", val);
2444                         node->value = val;
2445                         filter->list = g_slist_append(
2446                                         filter->list, (gpointer)node);
2447                         memset(temp, '\0', PKG_STRING_LEN_MAX);
2448                 }
2449                 break;
2450         default:
2451                 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
2452                 link = g_slist_find_custom(filter->list,
2453                                 (gconstpointer)node, __compare_func);
2454                 if (link)
2455                         filter->list = g_slist_delete_link(filter->list, link);
2456                 filter->list = g_slist_append(filter->list, (gpointer)node);
2457                 break;
2458         }
2459         return PMINFO_R_OK;
2460 }
2461
2462 API int pkgmgrinfo_appinfo_usr_filter_count(
2463                 pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
2464 {
2465         GHashTable *list;
2466         int ret;
2467         int query_count;
2468         pkgmgrinfo_filter_x *filter;
2469
2470         if (handle == NULL || count == NULL) {
2471                 _LOGE("invalid parameter");
2472                 return PMINFO_R_EINVAL;
2473         }
2474
2475         filter = (pkgmgrinfo_filter_x *)handle;
2476         list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
2477                         __free_applications);
2478         if (list == NULL)
2479                 return PMINFO_R_ERROR;
2480
2481         if (__check_disable_filter_exist(
2482                         handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2483                 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2484                                 PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
2485                         g_hash_table_destroy(list);
2486                         return PMINFO_R_ERROR;
2487                 }
2488         }
2489
2490         if (__check_disable_filter_exist(
2491                         handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2492                 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2493                                 PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
2494                         g_hash_table_destroy(list);
2495                         return PMINFO_R_ERROR;
2496                 }
2497         }
2498
2499         ret = _appinfo_get_applications(uid, filter, 0, list);
2500         query_count = g_hash_table_size(list);
2501         g_hash_table_destroy(list);
2502         if (ret == PMINFO_R_ERROR)
2503                 return ret;
2504
2505         *count = query_count;
2506         return PMINFO_R_OK;
2507 }
2508
2509 API int pkgmgrinfo_appinfo_filter_count(
2510                 pkgmgrinfo_appinfo_filter_h handle, int *count)
2511 {
2512         return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
2513 }
2514
2515 API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2516                 pkgmgrinfo_appinfo_filter_h handle,
2517                 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2518 {
2519         if (handle == NULL || app_cb == NULL) {
2520                 LOGE("invalid parameter");
2521                 return PMINFO_R_EINVAL;
2522         }
2523
2524         if (__check_disable_filter_exist(
2525                         handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
2526                 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2527                                 PMINFO_APPINFO_PROP_APP_DISABLE, false))
2528                         return PMINFO_R_ERROR;
2529         }
2530
2531         if (__check_disable_filter_exist(
2532                         handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
2533                 if (pkgmgrinfo_appinfo_filter_add_bool(handle,
2534                                 PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2535                         return PMINFO_R_ERROR;
2536         }
2537
2538         return _appinfo_get_filtered_foreach_appinfo(uid,
2539                         handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
2540 }
2541
2542 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
2543                 pkgmgrinfo_appinfo_filter_h handle,
2544                 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2545 {
2546         return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
2547                         handle, app_cb, user_data, _getuid());
2548 }
2549
2550 API int pkgmgrinfo_appinfo_metadata_filter_create(
2551                 pkgmgrinfo_appinfo_metadata_filter_h *handle)
2552 {
2553         return pkgmgrinfo_pkginfo_filter_create(handle);
2554 }
2555
2556 API int pkgmgrinfo_appinfo_metadata_filter_destroy(
2557                 pkgmgrinfo_appinfo_metadata_filter_h handle)
2558 {
2559         return pkgmgrinfo_pkginfo_filter_destroy(handle);
2560 }
2561
2562 API int pkgmgrinfo_appinfo_metadata_filter_add(
2563                 pkgmgrinfo_appinfo_metadata_filter_h handle,
2564                 const char *key, const char *value)
2565 {
2566         pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2567         pkgmgrinfo_metadata_node_x *node;
2568
2569         /* value can be NULL.
2570          * In that case all apps with specified key should be displayed
2571          */
2572         if (key == NULL) {
2573                 LOGE("invalid parameter");
2574                 return PMINFO_R_EINVAL;
2575         }
2576
2577         node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
2578         if (node == NULL) {
2579                 LOGE("out of memory");
2580                 return PMINFO_R_ERROR;
2581         }
2582
2583         node->key = strdup(key);
2584         if (value && strlen(value))
2585                 node->value = strdup(value);
2586
2587         filter->list_metadata = g_slist_append(filter->list_metadata,
2588                         (gpointer)node);
2589
2590         return PMINFO_R_OK;
2591 }
2592
2593 API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
2594                 pkgmgrinfo_appinfo_metadata_filter_h handle,
2595                 pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
2596 {
2597         if (handle == NULL || app_cb == NULL) {
2598                 LOGE("invalid parameter");
2599                 return PMINFO_R_EINVAL;
2600         }
2601
2602         pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
2603
2604         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2605                         PMINFO_APPINFO_PROP_APP_DISABLE, false))
2606                 return PMINFO_R_ERROR;
2607
2608         if (pkgmgrinfo_appinfo_filter_add_bool(filter,
2609                         PMINFO_APPINFO_PROP_PKG_DISABLE, false))
2610                 return PMINFO_R_ERROR;
2611
2612         return _appinfo_get_filtered_foreach_appinfo(uid, handle,
2613                         PMINFO_APPINFO_GET_ALL, app_cb,
2614                         user_data);
2615 }
2616
2617 API int pkgmgrinfo_appinfo_metadata_filter_foreach(
2618                 pkgmgrinfo_appinfo_metadata_filter_h handle,
2619                 pkgmgrinfo_app_list_cb app_cb, void *user_data)
2620 {
2621         return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
2622                         user_data, _getuid());
2623 }
2624
2625 API int pkgmgrinfo_appinfo_is_guestmode_visibility(
2626                 pkgmgrinfo_appinfo_h handle, bool *status)
2627 {
2628         const char *val;
2629         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2630
2631         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2632         retvm_if(status == NULL, PMINFO_R_EINVAL,
2633                         "Argument supplied to hold return value is NULL\n");
2634
2635         val = info->app_info->guestmode_visibility;
2636         *status = _get_bool_value(val);
2637         return PMINFO_R_OK;
2638 }
2639
2640 API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
2641                 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2642                 void *user_data)
2643 {
2644         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2645         retvm_if(appcontrol_func == NULL,
2646                         PMINFO_R_EINVAL, "Callback function is NULL");
2647         int ret;
2648         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2649         appcontrol_x *appcontrol;
2650         GList *tmp;
2651
2652         if (info->app_info == NULL)
2653                 return PMINFO_R_ERROR;
2654
2655         for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2656                 appcontrol = (appcontrol_x *)tmp->data;
2657                 if (appcontrol == NULL ||
2658                                 !strcasecmp(appcontrol->visibility,
2659                                                 "remote-only"))
2660                         continue;
2661                 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2662                                 appcontrol->mime, appcontrol->id, user_data);
2663                 if (ret < 0)
2664                         break;
2665         }
2666
2667         return PMINFO_R_OK;
2668 }
2669
2670 API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
2671                 pkgmgrinfo_appinfo_h handle,
2672                 pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
2673                 void *user_data)
2674 {
2675         retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2676         retvm_if(appcontrol_func == NULL,
2677                         PMINFO_R_EINVAL, "Callback function is NULL");
2678         int ret;
2679         pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2680         appcontrol_x *appcontrol;
2681         GList *tmp;
2682
2683         if (info->app_info == NULL)
2684                 return PMINFO_R_ERROR;
2685
2686         for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
2687                 appcontrol = (appcontrol_x *)tmp->data;
2688                 if (appcontrol == NULL ||
2689                                 !strcasecmp(appcontrol->visibility,
2690                                                 "local-only"))
2691                         continue;
2692                 ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
2693                                 appcontrol->mime, appcontrol->id, user_data);
2694                 if (ret < 0)
2695                         break;
2696         }
2697
2698         return PMINFO_R_OK;
2699 }