4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Junsuk Oh <junsuk77.oh@samsung.com>,
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include "pkgmgrinfo_private.h"
23 #include "pkgmgr_parser.h"
28 #define LOG_TAG "PKGMGR_INFO"
30 #define LANGUAGE_LENGTH 2
31 #define MAX_PACKAGE_STR_SIZE 512
33 #define SAT_UI_APPID_1 "org.tizen.sat-ui"
34 #define SAT_UI_APPID_2 "org.tizen.sat-ui-2"
35 #define PKG_DATA_PATH "/opt/usr/data/pkgmgr"
38 #define FILTER_QUERY_COUNT_APP "select DISTINCT package_app_info.app_id, package_app_info.app_component, package_app_info.app_installed_storage " \
39 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
40 "ON package_app_info.app_id=package_app_localized_info.app_id " \
41 "and package_app_localized_info.app_locale='%s' " \
42 "LEFT OUTER JOIN package_app_app_svc " \
43 "ON package_app_info.app_id=package_app_app_svc.app_id " \
44 "LEFT OUTER JOIN package_app_app_category " \
45 "ON package_app_info.app_id=package_app_app_category.app_id where "
47 #define FILTER_QUERY_LIST_APP "select DISTINCT package_app_info.*, package_app_localized_info.app_locale, package_app_localized_info.app_label, package_app_localized_info.app_icon " \
48 "from package_app_info LEFT OUTER JOIN package_app_localized_info " \
49 "ON package_app_info.app_id=package_app_localized_info.app_id " \
50 "and package_app_localized_info.app_locale IN ('%s', '%s') " \
51 "LEFT OUTER JOIN package_app_app_svc " \
52 "ON package_app_info.app_id=package_app_app_svc.app_id " \
53 "LEFT OUTER JOIN package_app_app_category " \
54 "ON package_app_info.app_id=package_app_app_category.app_id where "
56 #define METADATA_FILTER_QUERY_SELECT_CLAUSE "select DISTINCT package_app_info.* " \
57 "from package_app_info LEFT OUTER JOIN package_app_app_metadata " \
58 "ON package_app_info.app_id=package_app_app_metadata.app_id where "
60 #define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
62 typedef struct _pkgmgr_locale_x {
66 typedef struct _pkgmgrinfo_appcontrol_x {
75 } pkgmgrinfo_appcontrol_x;
77 static char* __get_aliasid_from_db(sqlite3 *appinfo_db, const char *appid)
79 int ret = PMINFO_R_OK;
80 char *alias_id = NULL;
82 sqlite3_stmt *stmt = NULL;
84 query = sqlite3_mprintf("select alias_id from package_app_aliasid where app_id=%Q", appid);
85 tryvm_if(query == NULL, ret = PMINFO_R_ERROR,"Malloc failed!!");
88 ret = sqlite3_prepare_v2(appinfo_db, query, strlen(query), &stmt, NULL);
89 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
91 alias_id = (char*)malloc(MAX_PACKAGE_STR_SIZE);
92 tryvm_if(alias_id == NULL, ret = PMINFO_R_ERROR,"Malloc failed!!");
93 memset(alias_id,'\0',MAX_PACKAGE_STR_SIZE);
96 ret = sqlite3_step(stmt);
97 if(ret == SQLITE_ROW){
99 snprintf(alias_id, MAX_PACKAGE_STR_SIZE, "%s", (const char *)sqlite3_column_text(stmt, 0));
100 _LOGD("alias id [%s] id found for [%s] in DB",alias_id,appid);
107 sqlite3_finalize(stmt);
109 /*If alias id is not found then set the appid as alias id*/
110 if ( alias_id == NULL || strlen(alias_id) == 0 ) {
111 FREE_AND_NULL(alias_id);
112 alias_id = strdup(appid);
119 static void __get_appinfo_from_db(char *colname, char *coltxt, uiapplication_x *uiapp)
121 if (colname == NULL || uiapp == NULL)
124 if (strcmp(colname, "app_id") == 0) {
129 uiapp->appid = strdup(coltxt);
131 } else if (strcmp(colname, "app_component") == 0) {
133 uiapp->app_component = strdup(coltxt);
135 uiapp->app_component = NULL;
136 } else if (strcmp(colname, "app_exec") == 0) {
138 uiapp->exec = strdup(coltxt);
141 } else if (strcmp(colname, "app_ambient_support") == 0) {
143 uiapp->ambient_support = strdup(coltxt);
145 uiapp->ambient_support = NULL;
146 } else if (strcmp(colname, "app_nodisplay") == 0) {
148 uiapp->nodisplay = strdup(coltxt);
150 uiapp->nodisplay = NULL;
151 } else if (strcmp(colname, "app_type") == 0 ) {
153 uiapp->type = strdup(coltxt);
156 } else if (strcmp(colname, "app_onboot") == 0 ) {
158 uiapp->onboot= strdup(coltxt);
160 uiapp->onboot = NULL;
161 } else if (strcmp(colname, "app_multiple") == 0 ) {
163 uiapp->multiple = strdup(coltxt);
165 uiapp->multiple = NULL;
166 } else if (strcmp(colname, "app_autorestart") == 0 ) {
168 uiapp->autorestart= strdup(coltxt);
170 uiapp->autorestart = NULL;
171 } else if (strcmp(colname, "app_taskmanage") == 0 ) {
173 uiapp->taskmanage = strdup(coltxt);
175 uiapp->taskmanage = NULL;
176 } else if (strcmp(colname, "app_enabled") == 0 ) {
178 uiapp->enabled= strdup(coltxt);
180 uiapp->enabled = NULL;
181 } else if (strcmp(colname, "app_hwacceleration") == 0 ) {
183 uiapp->hwacceleration = strdup(coltxt);
185 uiapp->hwacceleration = NULL;
186 } else if (strcmp(colname, "app_screenreader") == 0 ) {
188 uiapp->screenreader = strdup(coltxt);
190 uiapp->screenreader = NULL;
191 } else if (strcmp(colname, "app_mainapp") == 0 ) {
193 uiapp->mainapp = strdup(coltxt);
195 uiapp->mainapp = NULL;
196 } else if (strcmp(colname, "app_recentimage") == 0 ) {
198 uiapp->recentimage = strdup(coltxt);
200 uiapp->recentimage = NULL;
201 } else if (strcmp(colname, "app_launchcondition") == 0 ) {
203 uiapp->launchcondition = strdup(coltxt);
205 uiapp->launchcondition = NULL;
206 } else if (strcmp(colname, "app_indicatordisplay") == 0){
208 uiapp->indicatordisplay = strdup(coltxt);
210 uiapp->indicatordisplay = NULL;
211 } else if (strcmp(colname, "app_portraitimg") == 0){
213 uiapp->portraitimg = strdup(coltxt);
215 uiapp->portraitimg = NULL;
216 } else if (strcmp(colname, "app_landscapeimg") == 0){
218 uiapp->landscapeimg = strdup(coltxt);
220 uiapp->landscapeimg = NULL;
221 } else if (strcmp(colname, "app_effectimage_type") == 0){
223 uiapp->effectimage_type = strdup(coltxt);
225 uiapp->effectimage_type = NULL;
226 } else if (strcmp(colname, "app_guestmodevisibility") == 0){
228 uiapp->guestmode_visibility = strdup(coltxt);
230 uiapp->guestmode_visibility = NULL;
231 } else if (strcmp(colname, "app_permissiontype") == 0 ) {
233 uiapp->permission_type = strdup(coltxt);
235 uiapp->permission_type = NULL;
236 } else if (strcmp(colname, "app_preload") == 0 ) {
238 uiapp->preload = strdup(coltxt);
240 uiapp->preload = NULL;
241 } else if (strcmp(colname, "app_submode") == 0 ) {
243 uiapp->submode = strdup(coltxt);
245 uiapp->submode = NULL;
246 } else if (strcmp(colname, "app_submode_mainid") == 0 ) {
248 uiapp->submode_mainid = strdup(coltxt);
250 uiapp->submode_mainid = NULL;
251 } else if (strcmp(colname, "app_installed_storage") == 0 ) {
253 uiapp->installed_storage = strdup(coltxt);
255 uiapp->installed_storage = NULL;
256 } else if (strcmp(colname, "app_process_pool") == 0 ) {
258 uiapp->process_pool = strdup(coltxt);
260 uiapp->process_pool = NULL;
261 } else if (strcmp(colname, "app_multi_instance") == 0 ) {
263 uiapp->multi_instance = strdup(coltxt);
265 uiapp->multi_instance = NULL;
266 } else if (strcmp(colname, "app_multi_instance_mainid") == 0 ) {
268 uiapp->multi_instance_mainid = strdup(coltxt);
270 uiapp->multi_instance_mainid = NULL;
271 } else if (strcmp(colname, "app_multi_window") == 0 ) {
273 uiapp->multi_window = strdup(coltxt);
275 uiapp->multi_window = NULL;
276 } else if (strcmp(colname, "app_support_disable") == 0 ) {
278 uiapp->support_disable= strdup(coltxt);
280 uiapp->support_disable = NULL;
281 } else if (strcmp(colname, "app_ui_gadget") == 0 ) {
283 uiapp->ui_gadget = strdup(coltxt);
285 uiapp->ui_gadget = NULL;
286 } else if (strcmp(colname, "app_removable") == 0 ) {
288 uiapp->removable = strdup(coltxt);
290 uiapp->removable = NULL;
291 } else if (strcmp(colname, "app_support_mode") == 0 ) {
293 uiapp->support_mode = strdup(coltxt);
295 uiapp->support_mode = NULL;
296 } else if (strcmp(colname, "app_support_feature") == 0 ) {
298 uiapp->support_feature = strdup(coltxt);
300 uiapp->support_feature = NULL;
301 } else if (strcmp(colname, "component_type") == 0 ) {
303 uiapp->component_type = strdup(coltxt);
305 uiapp->component_type = NULL;
306 } else if (strcmp(colname, "package") == 0 ) {
308 uiapp->package = strdup(coltxt);
310 uiapp->package = NULL;
311 } else if (strcmp(colname, "app_package_type") == 0 ) {
313 uiapp->package_type = strdup(coltxt);
315 uiapp->package_type = NULL;
316 } else if (strcmp(colname, "app_package_system") == 0 ) {
318 uiapp->package_system = strdup(coltxt);
320 uiapp->package_system = NULL;
321 } else if (strcmp(colname, "app_package_installed_time") == 0 ) {
323 uiapp->package_installed_time = strdup(coltxt);
325 uiapp->package_installed_time = NULL;
327 /*end of package_app_info table*/
329 } else if (strcmp(colname, "app_locale") == 0 ) {
331 uiapp->icon->lang = strdup(coltxt);
332 uiapp->label->lang = strdup(coltxt);
335 uiapp->icon->lang = NULL;
336 uiapp->label->lang = NULL;
338 } else if (strcmp(colname, "app_label") == 0 ) {
340 uiapp->label->text = strdup(coltxt);
342 uiapp->label->text = NULL;
343 } else if (strcmp(colname, "app_icon") == 0) {
345 uiapp->icon->text = strdup(coltxt);
347 uiapp->icon->text = NULL;
348 /*end of package_app_localized_info table*/
350 } else if (strcmp(colname, "category") == 0 ) {
352 uiapp->category->name = strdup(coltxt);
354 uiapp->category->name = NULL;
355 /*end of package_app_category_info table*/
357 } else if (strcmp(colname, "md_key") == 0 ) {
359 uiapp->metadata->key = strdup(coltxt);
361 uiapp->metadata->key = NULL;
362 } else if (strcmp(colname, "md_value") == 0 ) {
364 uiapp->metadata->value = strdup(coltxt);
366 uiapp->metadata->value = NULL;
367 /*end of package_app_metadata_info table*/
369 } else if (strcmp(colname, "pm_type") == 0 ) {
371 uiapp->permission->type= strdup(coltxt);
373 uiapp->permission->type = NULL;
374 } else if (strcmp(colname, "pm_value") == 0 ) {
376 uiapp->permission->value = strdup(coltxt);
378 uiapp->permission->value = NULL;
379 /*end of package_app_permission_info table*/
381 } else if (strcmp(colname, "app_image") == 0) {
383 uiapp->image->text= strdup(coltxt);
385 uiapp->image->text = NULL;
386 } else if (strcmp(colname, "app_image_section") == 0) {
388 uiapp->image->section= strdup(coltxt);
390 uiapp->image->section = NULL;
391 /*end of package_app_image_info table*/
395 static void __update_localed_label_for_list(sqlite3_stmt *stmt, pkgmgr_pkginfo_x *info)
399 char *colname = NULL;
402 // uiapplication_x *ptr1 = NULL;
404 // LISTHEAD(info->manifest_info->uiapplication, ptr1);
406 ncols = sqlite3_column_count(stmt);
408 for(i = 0; i < ncols; i++)
410 colname = (char *)sqlite3_column_name(stmt, i);
411 if (colname && strcmp(colname, "app_label") == 0 ){
412 coltxt = (char *)sqlite3_column_text(stmt, i);
413 FREE_AND_STRDUP(coltxt, info->manifest_info->uiapplication->label->text);
418 /* get the first locale value*/
419 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
421 pkgmgr_locale_x *info = (pkgmgr_locale_x *)data;
424 info->locale = strdup(coltxt[0]);
431 int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
433 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
436 label_x *label = NULL;
437 category_x *category = NULL;
438 metadata_x *metadata = NULL;
439 permission_x *permission = NULL;
440 image_x *image = NULL;
442 icon = calloc(1, sizeof(icon_x));
443 retvm_if(icon == NULL, PMINFO_R_ERROR, "out of memory");
444 LISTADD(info->uiapp_info->icon, icon);
445 label = calloc(1, sizeof(label_x));
446 retvm_if(label == NULL, PMINFO_R_ERROR, "out of memory");
447 LISTADD(info->uiapp_info->label, label);
448 category = calloc(1, sizeof(category_x));
449 retvm_if(category == NULL, PMINFO_R_ERROR, "out of memory");
450 LISTADD(info->uiapp_info->category, category);
451 metadata = calloc(1, sizeof(metadata_x));
452 retvm_if(metadata == NULL, PMINFO_R_ERROR, "out of memory");
453 LISTADD(info->uiapp_info->metadata, metadata);
454 permission = calloc(1, sizeof(permission_x));
455 retvm_if(permission == NULL, PMINFO_R_ERROR, "out of memory");
456 LISTADD(info->uiapp_info->permission, permission);
457 image = calloc(1, sizeof(image_x));
458 retvm_if(image == NULL, PMINFO_R_ERROR, "out of memory");
459 LISTADD(info->uiapp_info->image, image);
461 for(i = 0; i < ncols; i++)
463 __get_appinfo_from_db(colname[i], coltxt[i], info->uiapp_info);
468 int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
470 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
472 uiapplication_x *uiapp = NULL;
474 label_x *label = NULL;
476 uiapp = calloc(1, sizeof(uiapplication_x));
477 retvm_if(uiapp == NULL, PMINFO_R_ERROR, "out of memory");
478 LISTADD(info->manifest_info->uiapplication, uiapp);
479 icon = calloc(1, sizeof(icon_x));
480 retvm_if(icon == NULL, PMINFO_R_ERROR, "out of memory");
481 LISTADD(info->manifest_info->uiapplication->icon, icon);
482 label = calloc(1, sizeof(label_x));
483 retvm_if(label == NULL, PMINFO_R_ERROR, "out of memory");
484 LISTADD(info->manifest_info->uiapplication->label, label);
486 for(i = 0; i < ncols; i++)
488 __get_appinfo_from_db(colname[i], coltxt[i], info->manifest_info->uiapplication);
493 static void __get_appinfo_for_list(sqlite3_stmt *stmt, pkgmgr_pkginfo_x *udata)
497 char *colname = NULL;
500 uiapplication_x *uiapp = NULL;
502 uiapp = calloc(1, sizeof(uiapplication_x));
503 retvm_if(uiapp == NULL, PMINFO_R_ERROR, "out of memory");
504 uiapp->icon= calloc(1, sizeof(icon_x));
505 uiapp->label= calloc(1, sizeof(label_x));
507 LISTADD(udata->manifest_info->uiapplication, uiapp);
509 ncols = sqlite3_column_count(stmt);
511 for(i = 0; i < ncols; i++)
513 colname = (char *)sqlite3_column_name(stmt, i);
514 coltxt = (char *)sqlite3_column_text(stmt, i);
516 // _LOGE("field value :: %s = %s \n", colname, coltxt);
517 __get_appinfo_from_db(colname, coltxt, udata->manifest_info->uiapplication);
521 static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
523 int result_query = -1;
526 char *query = sqlite3_mprintf("select exists(select app_locale from package_app_localized_info where app_id=%Q and app_locale=%Q)", appid, locale);
527 ret = __exec_db_query(db, query, _pkgmgrinfo_validate_cb, (void *)&result_query);
529 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
533 static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
535 int result_query = -1;
537 char wildcard[2] = {'%','\0'};
538 char lang[3] = {'\0'};
539 strncpy(lang, locale, LANGUAGE_LENGTH);
541 char *query = sqlite3_mprintf("select exists(select app_locale from package_app_localized_info where app_id=%Q and app_locale like %Q%Q)", appid, lang, wildcard);
542 ret = __exec_db_query(db, query, _pkgmgrinfo_validate_cb, (void *)&result_query);
544 retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
548 static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
551 char wildcard[2] = {'%','\0'};
552 char lang[3] = {'\0'};
553 char *locale_new = NULL;
554 pkgmgr_locale_x *info = NULL;
556 info = (pkgmgr_locale_x *)malloc(sizeof(pkgmgr_locale_x));
558 _LOGE("Out of Memory!!!\n");
561 memset(info, '\0', sizeof(*info));
563 strncpy(lang, locale, LANGUAGE_LENGTH);
564 char *query = sqlite3_mprintf("select app_locale from package_app_localized_info where app_id=%Q and app_locale like %Q%Q", appid, lang, wildcard);
566 ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
571 locale_new = info->locale;
579 char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid)
584 char *locale_new = NULL;
585 int check_result = 0;
587 locale = __convert_system_locale_to_manifest_locale();
589 /*check exact matching */
590 check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
593 if (check_result == 1) {
594 // _LOGD("%s find exact locale(%s)\n", appid, locale);
598 /* fallback matching */
599 check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
600 if(check_result == 1) {
601 locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
602 FREE_AND_NULL(locale);
603 if (locale_new == NULL)
604 locale_new = strdup(DEFAULT_LOCALE);
609 FREE_AND_NULL(locale);
610 return strdup(DEFAULT_LOCALE);
613 static void __get_metadata_filter_condition(gpointer data, char **condition)
615 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
616 char key[MAX_QUERY_LEN] = {'\0'};
617 char value[MAX_QUERY_LEN] = {'\0'};
619 snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
622 snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
627 *condition = strdup(key);
631 static int __sat_ui_is_enabled(const char *appid, bool *enabled)
633 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
634 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
636 if ((strncmp(appid, SAT_UI_APPID_1, strlen(SAT_UI_APPID_1)) == 0) || (strncmp(appid, SAT_UI_APPID_2, strlen(SAT_UI_APPID_2)) == 0)) {
637 char info_file[MAX_PACKAGE_STR_SIZE] = {'\0', };
639 snprintf(info_file, MAX_PACKAGE_STR_SIZE, "%s/%s", PKG_DATA_PATH, appid);
640 if (access(info_file, F_OK)==0) {
647 return PMINFO_R_EINVAL;
650 static int __sat_ui_get_label(pkgmgrinfo_appinfo_h handle, char **label)
652 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
653 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
655 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
656 retvm_if(info->uiapp_info->appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
658 if ((strncmp((char *)info->uiapp_info->appid, SAT_UI_APPID_1, strlen(SAT_UI_APPID_1)) == 0) || (strncmp((char *)info->uiapp_info->appid, SAT_UI_APPID_2, strlen(SAT_UI_APPID_2)) == 0)) {
659 char info_file[MAX_PACKAGE_STR_SIZE] = {'\0', };
661 snprintf(info_file, MAX_PACKAGE_STR_SIZE, "%s/%s", PKG_DATA_PATH, (char *)info->uiapp_info->appid);
662 if (access(info_file, F_OK)==0) {
664 char buf[MAX_PACKAGE_STR_SIZE] = {0};
666 fp = fopen(info_file, "r");
668 _LOGE("fopen[%s] fail\n", info_file);
669 return PMINFO_R_ERROR;
672 fgets(buf, MAX_PACKAGE_STR_SIZE, fp);
673 if (buf[0] == '\0') {
674 _LOGE("[%s] use db info\n", (char *)info->uiapp_info->appid);
676 return PMINFO_R_ERROR;
679 FREE_AND_STRDUP(buf, info->uiapp_info->satui_label);
680 *label = info->uiapp_info->satui_label;
686 return PMINFO_R_ERROR;
689 API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
690 pkgmgrinfo_app_list_cb app_func, void *user_data)
692 retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
693 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
694 retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
695 retvm_if(component == PMINFO_SVC_APP, PMINFO_R_OK, "PMINFO_SVC_APP is done" );
699 char query[MAX_QUERY_LEN] = {'\0'};
700 pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
701 pkgmgr_pkginfo_x *allinfo = NULL;
702 pkgmgr_appinfo_x *appinfo = NULL;
704 label_x *ptr2 = NULL;
705 category_x *ptr3 = NULL;
706 metadata_x *ptr4 = NULL;
707 permission_x *ptr5 = NULL;
708 image_x *ptr6 = NULL;
709 sqlite3 *appinfo_db = NULL;
711 /*check installed storage*/
712 ret = __pkginfo_check_installed_storage(info);
713 retvm_if(ret < 0, PMINFO_R_EINVAL, "[%s] is installed external, but is not in mmc", info->manifest_info->package);
715 /*get system locale*/
716 locale = __convert_system_locale_to_manifest_locale();
717 tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
720 allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
721 tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
723 /*calloc manifest_info*/
724 allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
725 tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
728 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
729 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
732 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
733 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
735 snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
736 "from package_app_info where " \
737 "package='%s' and app_component='%s' and app_disable='false'",
738 info->manifest_info->package,"uiapp");
740 /*Populate ui app info */
741 ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
742 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
744 uiapplication_x *tmp = NULL;
745 SAFE_LISTHEAD(info->manifest_info->uiapplication, tmp);
747 /*Populate localized info for default locales and call callback*/
748 /*If the callback func return < 0 we break and no more call back is called*/
752 appinfo->locale = strdup(locale);
753 appinfo->uiapp_info = tmp;
754 if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
755 FREE_AND_NULL(locale);
756 locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid);
759 memset(query, '\0', MAX_QUERY_LEN);
760 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
761 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
762 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
764 memset(query, '\0', MAX_QUERY_LEN);
765 snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
766 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
767 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
769 /*store setting notification icon section*/
770 memset(query, '\0', MAX_QUERY_LEN);
771 snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
772 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
773 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
775 /*store app preview image info*/
776 memset(query, '\0', MAX_QUERY_LEN);
777 snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
778 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
779 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
781 /*Populate app category*/
782 memset(query, '\0', MAX_QUERY_LEN);
783 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appinfo->uiapp_info->appid);
784 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
785 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
787 /*Populate app metadata*/
788 memset(query, '\0', MAX_QUERY_LEN);
789 snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appinfo->uiapp_info->appid);
790 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
791 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
793 SAFE_LISTHEAD(appinfo->uiapp_info->icon, ptr1);
794 SAFE_LISTHEAD(appinfo->uiapp_info->label, ptr2);
795 SAFE_LISTHEAD(appinfo->uiapp_info->category, ptr3);
796 SAFE_LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
797 SAFE_LISTHEAD(appinfo->uiapp_info->permission, ptr5);
798 SAFE_LISTHEAD(appinfo->uiapp_info->image, ptr6);
800 ret = app_func((void *)appinfo, user_data);
802 FREE_AND_NULL(appinfo->locale);
806 FREE_AND_NULL(appinfo->locale);
813 FREE_AND_NULL(locale);
814 FREE_AND_NULL(appinfo);
815 __cleanup_pkginfo(allinfo);
816 sqlite3_close(appinfo_db);
820 API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
822 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
824 int ret = PMINFO_R_OK;
826 pkgmgr_pkginfo_x *info = NULL;
827 pkgmgr_appinfo_x *appinfo = NULL;
828 uiapplication_x *ptr1 = NULL;
829 sqlite3 *appinfo_db = NULL;
830 sqlite3_stmt *stmt = NULL;
833 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
834 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
837 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
838 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
840 /*calloc manifest_info*/
841 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
842 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
845 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
846 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
848 /*Start constructing query*/
849 query = sqlite3_mprintf("select * from package_app_info where app_disable='false'");
852 ret = sqlite3_prepare_v2(appinfo_db, query, strlen(query), &stmt, NULL);
853 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
857 ret = sqlite3_step(stmt);
858 if(ret == SQLITE_ROW) {
859 __get_appinfo_for_list(stmt, info);
866 SAFE_LISTHEAD(info->manifest_info->uiapplication, ptr1);
869 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
871 appinfo->uiapp_info = ptr1;
873 ret = app_func((void *)appinfo, user_data);
882 sqlite3_finalize(stmt);
883 sqlite3_close(appinfo_db);
884 FREE_AND_NULL(appinfo);
885 __cleanup_pkginfo(info);
890 API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
892 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
894 int ret = PMINFO_R_OK;
897 char appid[MAX_QUERY_LEN] = {0,};
898 char pre_appid[MAX_QUERY_LEN] = {0,};
900 pkgmgr_pkginfo_x *info = NULL;
901 pkgmgr_appinfo_x *appinfo = NULL;
902 uiapplication_x *ptr1 = NULL;
904 sqlite3 *appinfo_db = NULL;
905 sqlite3_stmt *stmt = NULL;
908 /*calloc manifest_info*/
909 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
910 retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
912 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
913 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
915 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
916 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
919 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
920 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "db_util_open[%s] failed!", MANIFEST_DB);
922 /*Start constructing query*/
923 locale = __convert_system_locale_to_manifest_locale();
924 query = sqlite3_mprintf("select * from package_app_info LEFT OUTER JOIN package_app_localized_info "\
925 "ON package_app_info.app_id=package_app_localized_info.app_id "\
926 "where package_app_info.app_disable='false' and package_app_localized_info.app_locale IN (%Q, %Q)", DEFAULT_LOCALE, locale);
929 ret = sqlite3_prepare_v2(appinfo_db, query, strlen(query), &stmt, NULL);
930 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
934 ret = sqlite3_step(stmt);
935 if(ret == SQLITE_ROW) {
937 memset(appid, 0, MAX_QUERY_LEN);
938 strncpy(appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
940 if (strlen(pre_appid) != 0) {
941 if (strcmp(pre_appid, appid) == 0) {
942 /*if same appid is found, then it is about exact matched locale*/
943 __update_localed_label_for_list(stmt, info);
945 memset(pre_appid, 0, MAX_QUERY_LEN);
946 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
950 memset(pre_appid, 0, MAX_QUERY_LEN);
951 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
954 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
957 __get_appinfo_for_list(stmt, info);
964 SAFE_LISTHEAD(info->manifest_info->uiapplication, ptr1);
967 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
969 if (locale && appinfo->locale == NULL)
970 appinfo->locale = strdup(locale);
971 appinfo->uiapp_info = ptr1;
973 ret = __appinfo_check_installed_storage(appinfo);
977 ret = app_func((void *)appinfo, user_data);
980 FREE_AND_NULL(appinfo->locale);
985 FREE_AND_NULL(locale);
987 sqlite3_finalize(stmt);
988 sqlite3_close(appinfo_db);
989 FREE_AND_NULL(appinfo);
990 __cleanup_pkginfo(info);
994 API int pkgmgrinfo_appinfo_get_mounted_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
996 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
998 int ret = PMINFO_R_OK;
1000 char appid[MAX_QUERY_LEN] = {0,};
1001 char pre_appid[MAX_QUERY_LEN] = {0,};
1002 char *locale = NULL;
1003 pkgmgr_pkginfo_x *info = NULL;
1004 pkgmgr_appinfo_x *appinfo = NULL;
1005 uiapplication_x *ptr1 = NULL;
1006 sqlite3 *appinfo_db = NULL;
1007 sqlite3_stmt *stmt = NULL;
1009 /*get system locale*/
1010 locale = __convert_system_locale_to_manifest_locale();
1011 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
1014 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
1015 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1018 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
1019 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
1021 /*calloc manifest_info*/
1022 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
1023 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
1026 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
1027 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
1029 /*Start constructing query*/
1030 query = sqlite3_mprintf("select * from package_app_info LEFT OUTER JOIN package_app_localized_info " \
1031 "ON package_app_info.app_id=package_app_localized_info.app_id " \
1032 "where app_installed_storage='installed_external' and package_app_info.app_disable='false' and package_app_localized_info.app_locale IN (%Q, %Q)", DEFAULT_LOCALE, locale);
1035 ret = sqlite3_prepare_v2(appinfo_db, query, strlen(query), &stmt, NULL);
1036 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1040 ret = sqlite3_step(stmt);
1041 if(ret == SQLITE_ROW) {
1043 memset(appid, 0, MAX_QUERY_LEN);
1044 strncpy(appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1046 if (strlen(pre_appid) != 0) {
1047 if (strcmp(pre_appid, appid) == 0) {
1048 /*if same appid is found, then it is about exact matched locale*/
1049 __update_localed_label_for_list(stmt, info);
1051 memset(pre_appid, 0, MAX_QUERY_LEN);
1052 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1056 memset(pre_appid, 0, MAX_QUERY_LEN);
1057 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1060 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1063 __get_appinfo_for_list(stmt, info);
1070 SAFE_LISTHEAD(info->manifest_info->uiapplication, ptr1);
1073 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
1075 appinfo->locale = strdup(locale);
1076 appinfo->uiapp_info = ptr1;
1078 ret = __appinfo_check_installed_storage(appinfo);
1080 FREE_AND_NULL(appinfo->locale);
1084 ret = app_func((void *)appinfo, user_data);
1086 FREE_AND_NULL(appinfo->locale);
1090 FREE_AND_NULL(appinfo->locale);
1095 FREE_AND_NULL(locale);
1096 sqlite3_free(query);
1097 sqlite3_finalize(stmt);
1098 sqlite3_close(appinfo_db);
1099 FREE_AND_NULL(appinfo);
1100 __cleanup_pkginfo(info);
1104 API int pkgmgrinfo_appinfo_get_unmounted_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
1106 retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
1108 int ret = PMINFO_R_OK;
1110 char appid[MAX_QUERY_LEN] = {0,};
1111 char pre_appid[MAX_QUERY_LEN] = {0,};
1112 char *locale = NULL;
1113 pkgmgr_pkginfo_x *info = NULL;
1114 pkgmgr_appinfo_x *appinfo = NULL;
1115 uiapplication_x *ptr1 = NULL;
1116 sqlite3 *appinfo_db = NULL;
1117 sqlite3_stmt *stmt = NULL;
1119 /*get system locale*/
1120 locale = __convert_system_locale_to_manifest_locale();
1121 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
1124 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
1125 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1128 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
1129 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
1131 /*calloc manifest_info*/
1132 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
1133 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
1136 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
1137 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
1139 /*Start constructing query*/
1140 query = sqlite3_mprintf("select * from package_app_info LEFT OUTER JOIN package_app_localized_info " \
1141 "ON package_app_info.app_id=package_app_localized_info.app_id " \
1142 "where app_installed_storage='installed_external' and package_app_info.app_disable='false' and package_app_localized_info.app_locale IN (%Q, %Q)", DEFAULT_LOCALE, locale);
1145 ret = sqlite3_prepare_v2(appinfo_db, query, strlen(query), &stmt, NULL);
1146 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
1150 ret = sqlite3_step(stmt);
1151 if(ret == SQLITE_ROW) {
1153 memset(appid, 0, MAX_QUERY_LEN);
1154 strncpy(appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1156 if (strlen(pre_appid) != 0) {
1157 if (strcmp(pre_appid, appid) == 0) {
1158 /*if same appid is found, then it is about exact matched locale*/
1159 __update_localed_label_for_list(stmt, info);
1161 memset(pre_appid, 0, MAX_QUERY_LEN);
1162 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1166 memset(pre_appid, 0, MAX_QUERY_LEN);
1167 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1170 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
1173 __get_appinfo_for_list(stmt, info);
1180 SAFE_LISTHEAD(info->manifest_info->uiapplication, ptr1);
1183 for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
1185 appinfo->locale = strdup(locale);
1186 appinfo->uiapp_info = ptr1;
1188 ret = app_func((void *)appinfo, user_data);
1190 FREE_AND_NULL(appinfo->locale);
1194 FREE_AND_NULL(appinfo->locale);
1199 FREE_AND_NULL(locale);
1200 sqlite3_free(query);
1201 sqlite3_finalize(stmt);
1202 sqlite3_close(appinfo_db);
1203 FREE_AND_NULL(appinfo);
1204 __cleanup_pkginfo(info);
1208 API int pkgmgrinfo_appinfo_get_unmounted_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
1210 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
1211 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1213 pkgmgr_appinfo_x *appinfo = NULL;
1214 char *locale = NULL;
1217 label_x *tmp1 = NULL;
1218 icon_x *tmp2 = NULL;
1219 category_x *tmp3 = NULL;
1220 metadata_x *tmp4 = NULL;
1221 permission_x *tmp5 = NULL;
1222 image_x *tmp6 = NULL;
1224 sqlite3 *appinfo_db = NULL;
1225 char *alias_id = NULL;
1228 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
1229 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1231 /*Get the alias id*/
1232 alias_id = __get_aliasid_from_db(appinfo_db,appid);
1234 /*check alias_id exist on db*/
1235 query = sqlite3_mprintf("select exists(select * from package_app_info where app_id=%Q and app_disable='false')", alias_id);
1236 ret = __exec_db_query(appinfo_db, query, _pkgmgrinfo_validate_cb, (void *)&exist);
1237 sqlite3_free(query);
1238 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
1239 tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", alias_id);
1241 /*get system locale*/
1242 locale = __convert_system_locale_to_manifest_locale();
1243 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
1246 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
1247 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
1249 /*calloc app_component*/
1250 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
1251 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
1253 appinfo->locale = strdup(locale);
1255 /*populate app_info from DB*/
1256 query = sqlite3_mprintf("select * from package_app_info where app_id=%Q and app_disable='false' ", alias_id);
1257 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1258 sqlite3_free(query);
1259 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
1261 query = sqlite3_mprintf("select * from package_app_localized_info where app_id=%Q and app_locale=%Q", alias_id, locale);
1262 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1263 sqlite3_free(query);
1264 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
1266 /*Also store the values corresponding to default locales*/
1267 query = sqlite3_mprintf("select * from package_app_localized_info where app_id=%Q and app_locale=%Q", alias_id, DEFAULT_LOCALE);
1268 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1269 sqlite3_free(query);
1270 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
1272 /*Populate app category*/
1273 query = sqlite3_mprintf("select * from package_app_app_category where app_id=%Q", alias_id);
1274 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1275 sqlite3_free(query);
1276 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
1278 /*Populate app metadata*/
1279 query = sqlite3_mprintf("select * from package_app_app_metadata where app_id=%Q", alias_id);
1280 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1281 sqlite3_free(query);
1282 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
1284 /*Populate app permission*/
1285 query = sqlite3_mprintf("select * from package_app_app_permission where app_id=%Q", alias_id);
1286 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1287 sqlite3_free(query);
1288 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
1290 /*store setting notification icon section*/
1291 query = sqlite3_mprintf("select * from package_app_icon_section_info where app_id=%Q", alias_id);
1292 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1293 sqlite3_free(query);
1294 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
1296 /*store app preview image info*/
1297 query = sqlite3_mprintf("select app_image_section, app_image from package_app_image_info where app_id=%Q", alias_id);
1298 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1299 sqlite3_free(query);
1300 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
1302 SAFE_LISTHEAD(appinfo->uiapp_info->label, tmp1);
1303 SAFE_LISTHEAD(appinfo->uiapp_info->icon, tmp2);
1304 SAFE_LISTHEAD(appinfo->uiapp_info->category, tmp3);
1305 SAFE_LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
1306 SAFE_LISTHEAD(appinfo->uiapp_info->permission, tmp5);
1307 SAFE_LISTHEAD(appinfo->uiapp_info->image, tmp6);
1312 if (ret == PMINFO_R_OK)
1313 *handle = (void*)appinfo;
1316 __cleanup_appinfo(appinfo);
1319 sqlite3_close(appinfo_db);
1320 FREE_AND_NULL(locale);
1321 FREE_AND_NULL(alias_id);
1325 API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
1327 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
1328 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1330 pkgmgr_appinfo_x *appinfo = NULL;
1331 char *locale = NULL;
1334 label_x *tmp1 = NULL;
1335 icon_x *tmp2 = NULL;
1336 category_x *tmp3 = NULL;
1337 metadata_x *tmp4 = NULL;
1338 permission_x *tmp5 = NULL;
1339 image_x *tmp6 = NULL;
1341 sqlite3 *appinfo_db = NULL;
1342 char *alias_id = NULL;
1345 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
1346 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
1348 /*Get the alias id*/
1349 alias_id = __get_aliasid_from_db(appinfo_db,appid);
1351 /*check alias_id exist on db*/
1352 query = sqlite3_mprintf("select exists(select * from package_app_info where app_id=%Q and app_disable='false')", alias_id);
1353 ret = __exec_db_query(appinfo_db, query, _pkgmgrinfo_validate_cb, (void *)&exist);
1354 sqlite3_free(query);
1355 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
1357 _LOGS("Appid[%s] not found in DB", alias_id);
1358 ret = PMINFO_R_ERROR;
1362 /*get system locale*/
1363 locale = __convert_system_locale_to_manifest_locale();
1364 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
1367 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
1368 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
1370 /*calloc app_component*/
1371 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
1372 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
1374 appinfo->locale = strdup(locale);
1376 /*populate app_info from DB*/
1377 query = sqlite3_mprintf("select * from package_app_info where app_id=%Q and app_disable='false' ", alias_id);
1378 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1379 sqlite3_free(query);
1380 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
1382 query = sqlite3_mprintf("select * from package_app_localized_info where app_id=%Q and app_locale=%Q", alias_id, locale);
1383 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1384 sqlite3_free(query);
1385 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
1387 /*Also store the values corresponding to default locales*/
1388 query = sqlite3_mprintf("select * from package_app_localized_info where app_id=%Q and app_locale=%Q", alias_id, DEFAULT_LOCALE);
1389 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1390 sqlite3_free(query);
1391 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
1393 /*Populate app category*/
1394 query = sqlite3_mprintf("select * from package_app_app_category where app_id=%Q", alias_id);
1395 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1396 sqlite3_free(query);
1397 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
1399 /*Populate app metadata*/
1400 query = sqlite3_mprintf("select * from package_app_app_metadata where app_id=%Q", alias_id);
1401 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1402 sqlite3_free(query);
1403 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
1405 /*Populate app permission*/
1406 query = sqlite3_mprintf("select * from package_app_app_permission where app_id=%Q", alias_id);
1407 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1408 sqlite3_free(query);
1409 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
1411 /*store setting notification icon section*/
1412 query = sqlite3_mprintf("select * from package_app_icon_section_info where app_id=%Q", alias_id);
1413 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1414 sqlite3_free(query);
1415 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
1417 /*store app preview image info*/
1418 query = sqlite3_mprintf("select app_image_section, app_image from package_app_image_info where app_id=%Q", alias_id);
1419 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
1420 sqlite3_free(query);
1421 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
1423 ret = __appinfo_check_installed_storage(appinfo);
1424 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", appinfo->uiapp_info->package);
1426 SAFE_LISTHEAD(appinfo->uiapp_info->label, tmp1);
1427 SAFE_LISTHEAD(appinfo->uiapp_info->icon, tmp2);
1428 SAFE_LISTHEAD(appinfo->uiapp_info->category, tmp3);
1429 SAFE_LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
1430 SAFE_LISTHEAD(appinfo->uiapp_info->permission, tmp5);
1431 SAFE_LISTHEAD(appinfo->uiapp_info->image, tmp6);
1436 if (ret == PMINFO_R_OK)
1437 *handle = (void*)appinfo;
1440 __cleanup_appinfo(appinfo);
1443 sqlite3_close(appinfo_db);
1444 FREE_AND_NULL(locale);
1445 FREE_AND_NULL(alias_id);
1450 API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
1452 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1453 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1454 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1456 *appid = (char *)info->uiapp_info->appid;
1461 API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
1463 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1464 retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1465 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1467 *pkg_name = (char *)info->uiapp_info->package;
1472 API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
1474 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1475 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1476 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1478 *pkgid = (char *)info->uiapp_info->package;
1483 API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
1485 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1486 retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1487 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1489 *pkgtype = (char *)info->uiapp_info->package_type;
1494 API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
1496 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1497 retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1498 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1500 *exec = (char *)info->uiapp_info->exec;
1506 API int pkgmgrinfo_appinfo_get_ambient_support(pkgmgrinfo_appinfo_h handle, bool *ambient_support)
1508 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1509 retvm_if(ambient_support == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1510 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1512 bool is_support = false;
1514 val = (char *)info->uiapp_info->ambient_support;
1516 if (strcasecmp(val, "true") == 0)
1520 *ambient_support = is_support;
1525 API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1527 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1528 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1530 char *locale = NULL;
1532 icon_x *start = NULL;
1535 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1536 locale = info->locale;
1537 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1539 start = info->uiapp_info->icon;
1541 for(ptr = start; ptr != NULL; ptr = ptr->next)
1544 if (strcmp(ptr->lang, locale) == 0) {
1546 *icon = (char *)ptr->text;
1547 if (strcasecmp(*icon, PKGMGR_PARSER_EMPTY_STR) == 0) {
1548 locale = DEFAULT_LOCALE;
1553 locale = DEFAULT_LOCALE;
1556 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1557 *icon = (char *)ptr->text;
1566 API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
1568 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1569 retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1571 char *locale = NULL;
1572 label_x *ptr = NULL;
1573 label_x *start = NULL;
1576 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1577 locale = info->locale;
1578 retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
1580 ret = __sat_ui_get_label(handle, label);
1581 retvm_if(ret == PMINFO_R_OK, PMINFO_R_OK, "sat ui(%s) is enabled", (char *)info->uiapp_info->appid);
1583 start = info->uiapp_info->label;
1585 for(ptr = start; ptr != NULL; ptr = ptr->next)
1588 if (strcmp(ptr->lang, locale) == 0) {
1590 *label = (char *)ptr->text;
1591 if (strcasecmp(*label, PKGMGR_PARSER_EMPTY_STR) == 0) {
1592 locale = DEFAULT_LOCALE;
1597 locale = DEFAULT_LOCALE;
1600 } else if (strncasecmp(ptr->lang, locale, 2) == 0) {
1601 *label = (char *)ptr->text;
1603 if (strcasecmp(*label, PKGMGR_PARSER_EMPTY_STR) == 0) {
1604 locale = DEFAULT_LOCALE;
1609 locale = DEFAULT_LOCALE;
1612 } else if (strcmp(ptr->lang, DEFAULT_LOCALE) == 0) {
1613 *label = (char *)ptr->text;
1622 API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
1624 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1625 retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1627 *component = PMINFO_UI_APP;
1632 API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
1634 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1635 retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1636 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1638 *app_type = (char *)info->uiapp_info->type;
1643 API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
1644 int *operation_count, char ***operation)
1646 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1647 retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1648 retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1649 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1650 *operation_count = data->operation_count;
1651 *operation = data->operation;
1655 API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
1656 int *uri_count, char ***uri)
1658 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1659 retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1660 retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1661 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1662 *uri_count = data->uri_count;
1667 API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
1668 int *mime_count, char ***mime)
1670 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1671 retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1672 retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1673 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1674 *mime_count = data->mime_count;
1679 API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
1680 int *subapp_count, char ***subapp)
1682 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1683 retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1684 retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1685 pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
1686 *subapp_count = data->subapp_count;
1687 *subapp = data->subapp;
1691 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1693 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1694 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1698 icon_x *start = NULL;
1699 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1701 start = info->uiapp_info->icon;
1703 for(ptr = start; ptr != NULL; ptr = ptr->next)
1706 val = (char *)ptr->section;
1707 if (strcmp(val, "setting") == 0){
1708 *icon = (char *)ptr->text;
1716 API int pkgmgrinfo_appinfo_get_small_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1718 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1719 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1723 icon_x *start = NULL;
1724 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1726 start = info->uiapp_info->icon;
1728 for(ptr = start; ptr != NULL; ptr = ptr->next)
1731 val = (char *)ptr->section;
1732 if (strcmp(val, "small") == 0){
1733 *icon = (char *)ptr->text;
1742 API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
1744 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1745 retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1749 icon_x *start = NULL;
1750 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1752 start = info->uiapp_info->icon;
1754 for(ptr = start; ptr != NULL; ptr = ptr->next)
1757 val = (char *)ptr->section;
1759 if (strcmp(val, "notification") == 0){
1760 *icon = (char *)ptr->text;
1769 API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
1771 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1772 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1774 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1775 val = (char *)info->uiapp_info->recentimage;
1777 if (strcasecmp(val, "capture") == 0)
1778 *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
1779 else if (strcasecmp(val, "icon") == 0)
1780 *type = PMINFO_RECENTIMAGE_USE_ICON;
1782 *type = PMINFO_RECENTIMAGE_USE_NOTHING;
1788 API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
1790 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1791 retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1794 image_x *ptr = NULL;
1795 image_x *start = NULL;
1796 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1798 start = info->uiapp_info->image;
1800 for(ptr = start; ptr != NULL; ptr = ptr->next)
1803 val = (char *)ptr->section;
1805 if (strcmp(val, "preview") == 0)
1806 *preview_img = (char *)ptr->text;
1814 API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
1816 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
1817 retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
1820 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1822 val = (char*)info->uiapp_info->permission_type;
1824 if (strcmp(val, "signature") == 0)
1825 *permission = PMINFO_PERMISSION_SIGNATURE;
1826 else if (strcmp(val, "privilege") == 0)
1827 *permission = PMINFO_PERMISSION_PRIVILEGE;
1829 *permission = PMINFO_PERMISSION_NORMAL;
1834 API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
1836 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1837 retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1838 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1840 *component_type = (char *)info->uiapp_info->component_type;
1845 API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
1847 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1848 retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1850 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1851 val = (char *)info->uiapp_info->hwacceleration;
1853 if (strcasecmp(val, "off") == 0)
1854 *hwacceleration = PMINFO_HWACCELERATION_OFF;
1855 else if (strcasecmp(val, "on") == 0)
1856 *hwacceleration = PMINFO_HWACCELERATION_ON;
1858 *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
1863 API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
1865 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1866 retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1868 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1869 val = (char *)info->uiapp_info->screenreader;
1871 if (strcasecmp(val, "screenreader-off") == 0)
1872 *screenreader = PMINFO_SCREENREADER_OFF;
1873 else if (strcasecmp(val, "screenreader-on") == 0)
1874 *screenreader = PMINFO_SCREENREADER_ON;
1876 *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
1881 API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
1883 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1884 retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1885 retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1886 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1888 *portrait_img = (char *)info->uiapp_info->portraitimg;
1889 *landscape_img = (char *)info->uiapp_info->landscapeimg;
1894 API int pkgmgrinfo_appinfo_get_effectimage_type(pkgmgrinfo_appinfo_h handle, char **effectimg_type)
1896 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1897 retvm_if(effectimg_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1898 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1900 *effectimg_type = (char *)info->uiapp_info->effectimage_type;
1905 API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
1907 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
1908 retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
1909 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
1911 *submode_mainid = (char *)info->uiapp_info->submode_mainid;
1916 API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
1922 char *localed_label = NULL;
1925 retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
1927 sqlite3_stmt *stmt = NULL;
1928 sqlite3 *pkgmgr_parser_db = NULL;
1929 char *alias_id = NULL;
1931 ret = db_util_open(MANIFEST_DB, &pkgmgr_parser_db, 0);
1932 if (ret != SQLITE_OK) {
1933 _LOGE("DB open fail\n");
1937 /*Get the alias id*/
1938 alias_id = __get_aliasid_from_db(pkgmgr_parser_db,appid);
1940 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", alias_id, locale);
1943 ret = sqlite3_prepare_v2(pkgmgr_parser_db, query, strlen(query), &stmt, NULL);
1944 if (ret != SQLITE_OK) {
1945 _LOGE("prepare_v2 fail\n");
1946 sqlite3_close(pkgmgr_parser_db);
1947 sqlite3_free(query);
1948 FREE_AND_NULL(alias_id);
1952 cols = sqlite3_column_count(stmt);
1955 ret = sqlite3_step(stmt);
1956 if(ret == SQLITE_ROW) {
1957 for(col = 0; col < cols; col++)
1959 val = (char*)sqlite3_column_text(stmt, col);
1963 _LOGE("success find localed_label[%s]\n", val);
1964 FREE_AND_NULL(localed_label);
1965 localed_label = strdup(val);
1966 if (localed_label == NULL)
1969 *label = localed_label;
1979 /*find default label when exact matching failed*/
1980 if (localed_label == NULL) {
1981 sqlite3_free(query);
1982 query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", alias_id, DEFAULT_LOCALE);
1983 ret = sqlite3_prepare_v2(pkgmgr_parser_db, query, strlen(query), &stmt, NULL);
1984 if (ret != SQLITE_OK) {
1985 _LOGE("prepare_v2 fail\n");
1986 sqlite3_close(pkgmgr_parser_db);
1987 sqlite3_free(query);
1988 FREE_AND_NULL(alias_id);
1992 cols = sqlite3_column_count(stmt);
1995 ret = sqlite3_step(stmt);
1996 if(ret == SQLITE_ROW) {
1997 for(col = 0; col < cols; col++)
1999 val = (char*)sqlite3_column_text(stmt, col);
2002 _LOGE("success find default localed_label[%s]\n", val);
2003 FREE_AND_NULL(localed_label);
2004 localed_label = strdup(val);
2005 if (localed_label == NULL)
2007 *label = localed_label;
2017 FREE_AND_NULL(alias_id);
2018 sqlite3_finalize(stmt);
2019 sqlite3_close(pkgmgr_parser_db);
2020 sqlite3_free(query);
2022 if (localed_label == NULL) {
2023 return PMINFO_R_ERROR;
2029 API int pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
2031 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2032 retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
2033 retvm_if(metadata_value == NULL, PMINFO_R_EINVAL, "metadata_value is NULL");
2035 metadata_x *ptr = NULL;
2036 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2038 ptr = info->uiapp_info->metadata;
2040 for (; ptr; ptr = ptr->next) {
2042 if (strcasecmp(ptr->key, metadata_key) == 0)
2044 *metadata_value = (char*)ptr->value;
2050 return PMINFO_R_EINVAL;
2053 API int pkgmgrinfo_appinfo_get_multi_instance_mainid(pkgmgrinfo_appinfo_h handle, char **multi_instance_mainid)
2055 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2056 retvm_if(multi_instance_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2057 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2059 *multi_instance_mainid = (char *)info->uiapp_info->multi_instance_mainid;
2064 API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
2066 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2067 retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2068 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2069 retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2071 int ret = PMINFO_R_OK;
2073 sqlite3 *appinfo_db = NULL;
2074 sqlite3_stmt *stmt = NULL;
2077 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
2078 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2080 /*Start constructing query*/
2081 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
2084 ret = sqlite3_prepare_v2(appinfo_db, query, strlen(query), &stmt, NULL);
2085 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2088 ret = sqlite3_step(stmt);
2089 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2091 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2092 *access = strdup((char *)sqlite3_column_text(stmt, 2));
2097 sqlite3_free(query);
2098 sqlite3_finalize(stmt);
2099 sqlite3_close(appinfo_db);
2103 API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
2105 retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
2106 retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2108 int ret = PMINFO_R_OK;
2110 sqlite3 *appinfo_db = NULL;
2111 sqlite3_stmt *stmt = NULL;
2114 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
2115 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2117 /*Start constructing query*/
2118 query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
2121 ret = sqlite3_prepare_v2(appinfo_db, query, strlen(query), &stmt, NULL);
2122 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
2125 ret = sqlite3_step(stmt);
2126 tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
2128 *appid = strdup((char *)sqlite3_column_text(stmt, 0));
2133 sqlite3_free(query);
2134 sqlite3_finalize(stmt);
2135 sqlite3_close(appinfo_db);
2139 API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
2141 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2142 retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2144 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2145 if (info->uiapp_info->support_mode)
2146 *support_mode = atoi(info->uiapp_info->support_mode);
2153 API int pkgmgrinfo_appinfo_get_support_feature(pkgmgrinfo_appinfo_h handle, int *support_feature)
2155 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2156 retvm_if(support_feature == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2158 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2159 if (info->uiapp_info->support_feature)
2160 *support_feature = atoi(info->uiapp_info->support_feature);
2162 *support_feature = 0;
2167 API int pkgmgrinfo_appinfo_get_uginfo(const char *ug_name, pkgmgrinfo_appinfo_h *handle)
2169 retvm_if(ug_name == NULL, PMINFO_R_EINVAL, "ug_name is NULL");
2170 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2172 pkgmgr_appinfo_x *appinfo = NULL;
2175 sqlite3 *appinfo_db = NULL;
2178 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
2179 retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2182 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
2183 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
2185 /*calloc app_component*/
2186 appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
2187 tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
2189 /*populate app_info from DB*/
2190 query = sqlite3_mprintf("select * from package_app_info where app_ui_gadget='true' and app_exec like '%%%s'", ug_name);
2191 ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
2192 sqlite3_free(query);
2193 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
2195 ret = __appinfo_check_installed_storage(appinfo);
2196 tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "[%s] is installed external, but is not in mmc", appinfo->uiapp_info->package);
2201 if (ret == PMINFO_R_OK)
2202 *handle = (void*)appinfo;
2205 __cleanup_appinfo(appinfo);
2208 sqlite3_close(appinfo_db);
2213 /*Get the alias id for an appid from pkgmgr DB*/
2214 API int pkgmgrinfo_appinfo_get_aliasid(const char *appid, char **alias_id)
2217 sqlite3 *appinfo_db = NULL;
2218 int ret = PMINFO_R_OK;
2220 retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
2221 retvm_if(alias_id == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2224 ret = db_util_open(MANIFEST_DB, &appinfo_db, 0);
2225 tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
2227 *alias_id = __get_aliasid_from_db(appinfo_db,appid);
2230 sqlite3_close(appinfo_db);
2234 API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
2236 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2237 retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2238 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2239 if (info->uiapp_info->package_installed_time)
2240 *installed_time = atoi(info->uiapp_info->package_installed_time);
2242 return PMINFO_R_ERROR;
2247 API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
2248 pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
2250 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2251 retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2253 permission_x *ptr = NULL;
2254 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2256 ptr = info->uiapp_info->permission;
2258 for (; ptr; ptr = ptr->next) {
2260 ret = permission_func(ptr->value, user_data);
2268 API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
2269 pkgmgrinfo_app_category_list_cb category_func, void *user_data)
2271 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2272 retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2274 category_x *ptr = NULL;
2275 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2277 ptr = info->uiapp_info->category;
2279 for (; ptr; ptr = ptr->next) {
2281 ret = category_func(ptr->name, user_data);
2289 API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
2290 pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
2292 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2293 retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2295 metadata_x *ptr = NULL;
2296 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2298 ptr = info->uiapp_info->metadata;
2300 for (; ptr; ptr = ptr->next) {
2302 ret = metadata_func(ptr->key, ptr->value, user_data);
2310 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
2311 pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
2313 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2314 retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
2322 char *manifest = NULL;
2323 char **operation = NULL;
2326 char **subapp = NULL;
2327 appsvc_x *appsvc = NULL;
2328 manifest_x *mfx = NULL;
2329 operation_x *op = NULL;
2332 subapp_x *sa = NULL;
2333 pkgmgrinfo_app_component component;
2334 pkgmgrinfo_appcontrol_x *ptr = NULL;
2335 ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
2337 _LOGE("Failed to get package name\n");
2338 return PMINFO_R_ERROR;
2340 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
2342 _LOGE("Failed to get app component name\n");
2343 return PMINFO_R_ERROR;
2345 manifest = pkgmgr_parser_get_manifest_file(pkgid);
2346 if (manifest == NULL) {
2347 _LOGE("Failed to fetch package manifest file\n");
2348 return PMINFO_R_ERROR;
2350 mfx = pkgmgr_parser_process_manifest_xml(manifest);
2352 _LOGE("Failed to parse package manifest file\n");
2353 FREE_AND_NULL(manifest);
2354 return PMINFO_R_ERROR;
2356 FREE_AND_NULL(manifest);
2357 ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
2359 _LOGE("Out of Memory!!!\n");
2360 pkgmgr_parser_free_manifest_xml(mfx);
2361 return PMINFO_R_ERROR;
2363 /*Get Operation, Uri, Mime*/
2364 if (mfx->uiapplication) {
2365 if (mfx->uiapplication->appsvc) {
2366 appsvc = mfx->uiapplication->appsvc;
2370 for (; appsvc; appsvc = appsvc->next) {
2371 op = appsvc->operation;
2372 for (; op; op = op->next)
2374 op = appsvc->operation;
2377 for (; ui; ui = ui->next)
2382 for (; mi; mi = mi->next)
2386 sa = appsvc->subapp;
2387 for (; sa; sa = sa->next)
2389 sa = appsvc->subapp;
2391 operation = (char **)calloc(oc, sizeof(char *));
2392 if (operation == NULL) {
2393 _LOGE("out of memory");
2397 for (i = 0; i < oc; i++) {
2398 operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
2402 uri = (char **)calloc(uc, sizeof(char *));
2404 _LOGE("out of memory");
2405 for (i = 0; i < oc; i++) {
2406 FREE_AND_NULL(operation[i]);
2408 FREE_AND_NULL(operation);
2412 for (i = 0; i < uc; i++) {
2413 uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
2417 mime = (char **)calloc(mc, sizeof(char *));
2419 _LOGE("out of memory");
2420 for (i = 0; i < uc; i++) {
2421 FREE_AND_NULL(uri[i]);
2424 for (i = 0; i < oc; i++) {
2425 FREE_AND_NULL(operation[i]);
2427 FREE_AND_NULL(operation);
2431 for (i = 0; i < mc; i++) {
2432 mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
2436 subapp = (char **)calloc(sc, sizeof(char *));
2437 if (subapp == NULL) {
2438 _LOGE("out of memory");
2439 for (i = 0; i < mc; i++) {
2440 FREE_AND_NULL(mime[i]);
2442 FREE_AND_NULL(mime);
2443 for (i = 0; i < uc; i++) {
2444 FREE_AND_NULL(uri[i]);
2447 for (i = 0; i < oc; i++) {
2448 FREE_AND_NULL(operation[i]);
2450 FREE_AND_NULL(operation);
2454 for (i = 0; i < sc; i++) {
2455 subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
2459 /*populate appcontrol handle*/
2460 ptr->operation_count = oc;
2461 ptr->uri_count = uc;
2462 ptr->mime_count = mc;
2463 ptr->subapp_count = sc;
2464 ptr->operation = operation;
2467 ptr->subapp = subapp;
2469 ret = appcontrol_func((void *)ptr, user_data);
2470 for (i = 0; i < oc; i++) {
2471 FREE_AND_NULL(operation[i]);
2473 FREE_AND_NULL(operation);
2474 for (i = 0; i < uc; i++) {
2475 FREE_AND_NULL(uri[i]);
2478 for (i = 0; i < mc; i++) {
2479 FREE_AND_NULL(mime[i]);
2481 FREE_AND_NULL(mime);
2482 for (i = 0; i < sc; i++) {
2483 FREE_AND_NULL(subapp[i]);
2485 FREE_AND_NULL(subapp);
2493 pkgmgr_parser_free_manifest_xml(mfx);
2498 API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
2500 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2501 retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2503 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2504 val = (char *)info->uiapp_info->nodisplay;
2506 if (strcasecmp(val, "true") == 0)
2508 else if (strcasecmp(val, "false") == 0)
2516 API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
2518 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2519 retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2521 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2522 val = (char *)info->uiapp_info->multiple;
2524 if (strcasecmp(val, "true") == 0)
2526 else if (strcasecmp(val, "false") == 0)
2534 API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
2536 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2537 retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2539 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2540 val = (char *)info->uiapp_info->indicatordisplay;
2542 if (strcasecmp(val, "true") == 0){
2543 *indicator_disp = 1;
2544 }else if (strcasecmp(val, "false") == 0){
2545 *indicator_disp = 0;
2547 *indicator_disp = 0;
2553 API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
2555 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2556 retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2558 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2559 val = (char *)info->uiapp_info->taskmanage;
2561 if (strcasecmp(val, "true") == 0)
2563 else if (strcasecmp(val, "false") == 0)
2571 API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
2573 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2574 retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2577 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2579 ret = __sat_ui_is_enabled((char *)info->uiapp_info->appid, enabled);
2580 retvm_if(ret == PMINFO_R_OK, PMINFO_R_OK, "sat ui(%s) is enabled", (char *)info->uiapp_info->appid);
2582 val = (char *)info->uiapp_info->enabled;
2585 if (strcasecmp(val, "true") == 0)
2587 else if (strcasecmp(val, "false") == 0)
2596 API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
2598 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2599 retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2601 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2603 val = (char *)info->uiapp_info->onboot;
2606 if (strcasecmp(val, "true") == 0)
2608 else if (strcasecmp(val, "false") == 0)
2616 API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
2618 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2619 retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2621 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2623 val = (char *)info->uiapp_info->autorestart;
2626 if (strcasecmp(val, "true") == 0)
2628 else if (strcasecmp(val, "false") == 0)
2636 API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
2638 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2639 retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
2641 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2642 val = (char *)info->uiapp_info->mainapp;
2644 if (strcasecmp(val, "true") == 0)
2646 else if (strcasecmp(val, "false") == 0)
2654 API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
2656 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2657 retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2659 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2660 val = (char *)info->uiapp_info->preload;
2662 if (strcasecmp(val, "true") == 0)
2664 else if (strcasecmp(val, "false") == 0)
2672 API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
2674 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2675 retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2677 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2678 val = (char *)info->uiapp_info->submode;
2680 if (strcasecmp(val, "true") == 0)
2682 else if (strcasecmp(val, "false") == 0)
2690 API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
2692 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2693 retvm_if(process_pool == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2695 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2696 val = (char *)info->uiapp_info->process_pool;
2698 if (strcasecmp(val, "true") == 0)
2700 else if (strcasecmp(val, "false") == 0)
2708 API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
2710 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2711 retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
2712 retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
2714 category_x *ptr = NULL;
2715 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2719 ptr = info->uiapp_info->category;
2721 for (; ptr; ptr = ptr->next) {
2723 if (strcasecmp(ptr->name, category) == 0)
2734 API int pkgmgrinfo_appinfo_is_multi_instance(pkgmgrinfo_appinfo_h handle, bool *multi_instance)
2736 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2737 retvm_if(multi_instance == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2739 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2740 val = (char *)info->uiapp_info->multi_instance;
2742 if (strcasecmp(val, "true") == 0)
2743 *multi_instance = 1;
2744 else if (strcasecmp(val, "false") == 0)
2745 *multi_instance = 0;
2747 *multi_instance = 0;
2752 API int pkgmgrinfo_appinfo_is_multi_window(pkgmgrinfo_appinfo_h handle, bool *multi_window)
2754 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2755 retvm_if(multi_window == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2757 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2758 val = (char *)info->uiapp_info->multi_window;
2760 if (strcasecmp(val, "true") == 0)
2762 else if (strcasecmp(val, "false") == 0)
2770 API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle, bool *support_disable)
2772 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2773 retvm_if(support_disable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2775 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2776 val = (char *)info->uiapp_info->support_disable;
2778 if (strcasecmp(val, "true") == 0)
2779 *support_disable = 1;
2780 else if (strcasecmp(val, "false") == 0)
2781 *support_disable = 0;
2783 *support_disable = 0;
2788 API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle, bool *ui_gadget)
2790 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2791 retvm_if(ui_gadget == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2793 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2794 val = (char *)info->uiapp_info->ui_gadget;
2796 if (strcasecmp(val, "true") == 0)
2798 else if (strcasecmp(val, "false") == 0)
2806 API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle, bool *removable)
2808 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2809 retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2811 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2812 val = (char *)info->uiapp_info->removable;
2814 if (strcasecmp(val, "true") == 0)
2816 else if (strcasecmp(val, "false") == 0)
2824 API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
2826 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
2827 retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
2829 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2830 val = (char *)info->uiapp_info->package_system;
2832 if (strcasecmp(val, "true") == 0)
2834 else if (strcasecmp(val, "false") == 0)
2842 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
2844 retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
2845 pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
2846 __cleanup_appinfo(info);
2850 API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
2852 return (pkgmgrinfo_pkginfo_filter_create(handle));
2855 API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
2857 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
2860 API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
2861 const char *property, const int value)
2863 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2864 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2865 char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
2867 GSList *link = NULL;
2869 prop = _pminfo_appinfo_convert_to_prop_int(property);
2870 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
2871 prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
2872 _LOGE("Invalid Integer Property\n");
2873 return PMINFO_R_EINVAL;
2875 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2876 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2878 _LOGE("Out of Memory!!!\n");
2879 return PMINFO_R_ERROR;
2881 snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
2882 val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
2884 _LOGE("Out of Memory\n");
2885 FREE_AND_NULL(node);
2886 return PMINFO_R_ERROR;
2890 /*If API is called multiple times for same property, we should override the previous values.
2891 Last value set will be used for filtering.*/
2892 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2894 filter->list = g_slist_delete_link(filter->list, link);
2895 filter->list = g_slist_append(filter->list, (gpointer)node);
2900 API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
2901 const char *property, const bool value)
2903 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2904 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2906 GSList *link = NULL;
2908 prop = _pminfo_appinfo_convert_to_prop_bool(property);
2909 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
2910 prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
2911 _LOGE("Invalid Boolean Property\n");
2912 return PMINFO_R_EINVAL;
2914 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2915 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2917 _LOGE("Out of Memory!!!\n");
2918 return PMINFO_R_ERROR;
2921 val = strndup("('true','True')", 15);
2923 val = strndup("('false','False')", 17);
2925 _LOGE("Out of Memory\n");
2926 FREE_AND_NULL(node);
2927 return PMINFO_R_ERROR;
2931 /*If API is called multiple times for same property, we should override the previous values.
2932 Last value set will be used for filtering.*/
2933 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2935 filter->list = g_slist_delete_link(filter->list, link);
2936 filter->list = g_slist_append(filter->list, (gpointer)node);
2941 API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
2942 const char *property, const char *value)
2944 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2945 retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2946 retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
2948 pkgmgrinfo_node_x *ptr = NULL;
2949 char prev[PKG_STRING_LEN_MAX] = {'\0'};
2950 char temp[PKG_STRING_LEN_MAX] = {'\0'};
2951 GSList *link = NULL;
2953 prop = _pminfo_appinfo_convert_to_prop_str(property);
2954 if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
2955 prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
2956 _LOGE("Invalid String Property\n");
2957 return PMINFO_R_EINVAL;
2959 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
2960 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
2962 _LOGE("Out of Memory!!!\n");
2963 return PMINFO_R_ERROR;
2967 case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
2968 val = strndup("uiapp", PKG_STRING_LEN_MAX - 1);
2970 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2972 filter->list = g_slist_delete_link(filter->list, link);
2973 filter->list = g_slist_append(filter->list, (gpointer)node);
2975 case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
2976 case E_PMINFO_APPINFO_PROP_APP_OPERATION:
2977 case E_PMINFO_APPINFO_PROP_APP_URI:
2978 case E_PMINFO_APPINFO_PROP_APP_MIME:
2979 val = (char *)calloc(1, PKG_STRING_LEN_MAX);
2981 _LOGE("Out of Memory\n");
2982 FREE_AND_NULL(node);
2983 return PMINFO_R_ERROR;
2985 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
2987 ptr = (pkgmgrinfo_node_x *)link->data;
2988 strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
2989 _LOGS("Previous value is %s\n", prev);
2990 filter->list = g_slist_delete_link(filter->list, link);
2991 snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
2992 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
2993 _LOGS("New value is %s\n", val);
2995 filter->list = g_slist_append(filter->list, (gpointer)node);
2996 memset(temp, '\0', PKG_STRING_LEN_MAX);
2998 snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
2999 strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
3000 _LOGS("First value is %s\n", val);
3002 filter->list = g_slist_append(filter->list, (gpointer)node);
3003 memset(temp, '\0', PKG_STRING_LEN_MAX);
3007 node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
3008 link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
3010 filter->list = g_slist_delete_link(filter->list, link);
3011 filter->list = g_slist_append(filter->list, (gpointer)node);
3017 API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
3019 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3020 retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3023 int filter_count = 0;
3025 char *locale = NULL;
3026 char *condition = NULL;
3027 char query[MAX_QUERY_LEN] = {'\0'};
3028 char where[MAX_QUERY_LEN] = {'\0'};
3030 uiapplication_x *ptr1 = NULL;
3031 pkgmgr_pkginfo_x *info = NULL;
3032 pkgmgr_appinfo_x *appinfo = NULL;
3033 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3035 sqlite3 *pkginfo_db = NULL;
3036 sqlite3_stmt *stmt = NULL;
3041 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3042 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "db_util_open[%s] failed!", MANIFEST_DB);
3045 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3046 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3048 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3049 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3051 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3052 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3054 /*Start constructing query*/
3055 locale = __convert_system_locale_to_manifest_locale();
3056 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_COUNT_APP, locale);
3058 /*Get where clause*/
3059 for (list = filter->list; list; list = g_slist_next(list)) {
3060 __get_filter_condition(list->data, &condition);
3062 strncat(where, condition, sizeof(where) - strlen(where) -1);
3063 where[sizeof(where) - 1] = '\0';
3064 FREE_AND_NULL(condition);
3066 if (g_slist_next(list)) {
3067 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3068 where[sizeof(where) - 1] = '\0';
3072 if (strstr(where, "package_app_info.app_disable") == NULL) {
3073 if (strlen(where) > 0) {
3074 strncat(where, " and package_app_info.app_disable IN ('false','False')", sizeof(where) - strlen(where) - 1);
3075 where[sizeof(where) - 1] = '\0';
3078 _LOGS("where = %s\n", where);
3080 if (strlen(where) > 0) {
3081 strncat(query, where, sizeof(query) - strlen(query) - 1);
3082 query[sizeof(query) - 1] = '\0';
3084 _LOGS("query = %s\n", query);
3087 ret = sqlite3_prepare_v2(pkginfo_db, query, strlen(query), &stmt, NULL);
3088 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
3092 ret = sqlite3_step(stmt);
3093 if(ret == SQLITE_ROW) {
3094 __get_appinfo_for_list(stmt, info);
3101 SAFE_LISTHEAD(info->manifest_info->uiapplication, ptr1);
3103 /*If the callback func return < 0 we break and no more call back is called*/
3106 appinfo->uiapp_info = ptr1;
3107 ret = __appinfo_check_installed_storage(appinfo);
3116 *count = filter_count;
3120 FREE_AND_NULL(locale);
3121 sqlite3_finalize(stmt);
3122 sqlite3_close(pkginfo_db);
3123 FREE_AND_NULL(appinfo);
3124 __cleanup_pkginfo(info);
3128 API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
3129 pkgmgrinfo_app_list_cb app_cb, void * user_data)
3131 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3132 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
3136 char *locale = NULL;
3137 char *condition = NULL;
3138 char query[MAX_QUERY_LEN] = {'\0'};
3139 char where[MAX_QUERY_LEN] = {'\0'};
3141 char appid[MAX_QUERY_LEN] = {0,};
3142 char pre_appid[MAX_QUERY_LEN] = {0,};
3144 pkgmgr_pkginfo_x *info = NULL;
3145 pkgmgr_appinfo_x *appinfo = NULL;
3146 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3147 uiapplication_x *ptr1 = NULL;
3149 sqlite3 *pkginfo_db = NULL;
3150 sqlite3_stmt *stmt = NULL;
3154 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3155 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3158 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3159 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3161 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3162 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3164 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3165 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3167 /*Start constructing query*/
3168 locale = __convert_system_locale_to_manifest_locale();
3169 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "locale is NULL\n");
3170 snprintf(query, MAX_QUERY_LEN - 1, FILTER_QUERY_LIST_APP, DEFAULT_LOCALE, locale);
3172 /*Get where clause*/
3173 for (list = filter->list; list; list = g_slist_next(list)) {
3174 __get_filter_condition(list->data, &condition);
3176 strncat(where, condition, sizeof(where) - strlen(where) -1);
3177 where[sizeof(where) - 1] = '\0';
3178 FREE_AND_NULL(condition);
3180 if (g_slist_next(list)) {
3181 strncat(where, " and ", sizeof(where) - strlen(where) - 1);
3182 where[sizeof(where) - 1] = '\0';
3186 if (strstr(where, "package_app_info.app_disable") == NULL) {
3187 if (strlen(where) > 0) {
3188 strncat(where, " and package_app_info.app_disable IN ('false','False')", sizeof(where) - strlen(where) - 1);
3189 where[sizeof(where) - 1] = '\0';
3193 _LOGS("where = %s\n", where);
3195 if (strlen(where) > 0) {
3196 strncat(query, where, sizeof(query) - strlen(query) - 1);
3197 query[sizeof(query) - 1] = '\0';
3199 _LOGS("query = %s\n", query);
3202 ret = sqlite3_prepare_v2(pkginfo_db, query, strlen(query), &stmt, NULL);
3203 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
3207 ret = sqlite3_step(stmt);
3208 if(ret == SQLITE_ROW) {
3210 memset(appid, 0, MAX_QUERY_LEN);
3211 strncpy(appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3213 if (strlen(pre_appid) != 0) {
3214 if (strcmp(pre_appid, appid) == 0) {
3215 /*if same appid is found, then it is about exact matched locale*/
3216 __update_localed_label_for_list(stmt, info);
3218 memset(pre_appid, 0, MAX_QUERY_LEN);
3219 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3223 memset(pre_appid, 0, MAX_QUERY_LEN);
3224 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3227 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3230 __get_appinfo_for_list(stmt, info);
3237 SAFE_LISTHEAD(info->manifest_info->uiapplication, ptr1);
3239 /*If the callback func return < 0 we break and no more call back is called*/
3242 appinfo->locale = strdup(locale);
3243 appinfo->uiapp_info = ptr1;
3245 ret = __appinfo_check_installed_storage(appinfo);
3247 FREE_AND_NULL(appinfo->locale);
3252 ret = app_cb((void *)appinfo, user_data);
3254 FREE_AND_NULL(appinfo->locale);
3258 FREE_AND_NULL(appinfo->locale);
3264 FREE_AND_NULL(locale);
3265 sqlite3_finalize(stmt);
3266 sqlite3_close(pkginfo_db);
3267 FREE_AND_NULL(appinfo);
3268 __cleanup_pkginfo(info);
3272 API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
3274 return (pkgmgrinfo_pkginfo_filter_create(handle));
3277 API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
3279 return (pkgmgrinfo_pkginfo_filter_destroy(handle));
3282 API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
3283 const char *key, const char *value)
3285 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
3286 retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
3287 /*value can be NULL. In that case all apps with specified key should be displayed*/
3291 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3292 pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
3293 retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
3295 tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3299 tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3302 /*If API is called multiple times, we should OR all conditions.*/
3303 filter->list = g_slist_append(filter->list, (gpointer)node);
3304 /*All memory will be freed in destroy API*/
3308 FREE_AND_NULL(node->key);
3309 FREE_AND_NULL(node->value);
3310 FREE_AND_NULL(node);
3315 API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
3316 pkgmgrinfo_app_list_cb app_cb, void *user_data)
3318 retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
3319 retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
3320 char *locale = NULL;
3321 char *condition = NULL;
3322 char query[MAX_QUERY_LEN] = {'\0'};
3323 char where[MAX_QUERY_LEN] = {'\0'};
3324 char appid[MAX_QUERY_LEN] = {0,};
3325 char pre_appid[MAX_QUERY_LEN] = {0,};
3328 pkgmgr_pkginfo_x *info = NULL;
3329 pkgmgr_appinfo_x *appinfo = NULL;
3330 uiapplication_x *ptr1 = NULL;
3331 pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
3332 sqlite3 *pkginfo_db = NULL;
3333 sqlite3_stmt *stmt = NULL;
3336 ret = db_util_open(MANIFEST_DB, &pkginfo_db, 0);
3337 retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
3340 info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
3341 tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3343 info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
3344 tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3346 appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
3347 tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
3349 /*Get current locale*/
3350 locale = __convert_system_locale_to_manifest_locale();
3351 tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
3353 /*Start constructing query*/
3354 memset(where, '\0', MAX_QUERY_LEN);
3355 memset(query, '\0', MAX_QUERY_LEN);
3356 snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
3358 /*Get where clause*/
3359 for (list = filter->list; list; list = g_slist_next(list)) {
3360 __get_metadata_filter_condition(list->data, &condition);
3362 strncat(where, condition, sizeof(where) - strlen(where) -1);
3363 FREE_AND_NULL(condition);
3365 if (g_slist_next(list)) {
3366 strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
3370 if (strstr(where, "package_app_info.app_disable") == NULL) {
3371 if (strlen(where) > 0) {
3372 strncat(where, " and package_app_info.app_disable IN ('false','False')", sizeof(where) - strlen(where) - 1);
3373 where[sizeof(where) - 1] = '\0';
3377 _LOGE("where = %s (%d)\n", where, strlen(where));
3379 if (strlen(where) > 0) {
3380 strncat(query, where, sizeof(query) - strlen(query) - 1);
3382 _LOGE("query = %s (%d)\n", query, strlen(query));
3385 ret = sqlite3_prepare_v2(pkginfo_db, query, strlen(query), &stmt, NULL);
3386 tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
3390 ret = sqlite3_step(stmt);
3391 if(ret == SQLITE_ROW) {
3393 memset(appid, 0, MAX_QUERY_LEN);
3394 strncpy(appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3396 if (strlen(pre_appid) != 0) {
3397 if (strcmp(pre_appid, appid) == 0) {
3398 /*if same appid is found, then it is about exact matched locale*/
3399 __update_localed_label_for_list(stmt, info);
3401 memset(pre_appid, 0, MAX_QUERY_LEN);
3402 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3406 memset(pre_appid, 0, MAX_QUERY_LEN);
3407 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3410 strncpy(pre_appid, (const char *)sqlite3_column_text(stmt, 0), MAX_QUERY_LEN - 1);
3413 __get_appinfo_for_list(stmt, info);
3420 SAFE_LISTHEAD(info->manifest_info->uiapplication, ptr1);
3423 while (ptr1 != NULL) {
3424 appinfo->locale = strdup(locale);
3425 appinfo->uiapp_info = ptr1;
3427 ret = __appinfo_check_installed_storage(appinfo);
3429 FREE_AND_NULL(appinfo->locale);
3434 ret = app_cb((void *)appinfo, user_data);
3436 FREE_AND_NULL(appinfo->locale);
3440 FREE_AND_NULL(appinfo->locale);
3446 FREE_AND_NULL(locale);
3447 sqlite3_finalize(stmt);
3448 sqlite3_close(pkginfo_db);
3449 FREE_AND_NULL(appinfo);
3450 __cleanup_pkginfo(info);