X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fpkgmgrinfo_pkginfo.c;h=d7a6a52696a559acb9d748e87c508f0796783f76;hb=b2280aa76ba825de25ea726614a25be31f7e05cb;hp=8423b8a9bea0ffa06ebd5c209fbfc295fb8598d2;hpb=5bd3f7adcef7105b577414ee69779c7cc527cb99;p=platform%2Fcore%2Fappfw%2Fpkgmgr-info.git diff --git a/src/pkgmgrinfo_pkginfo.c b/src/pkgmgrinfo_pkginfo.c index 8423b8a..d7a6a52 100644 --- a/src/pkgmgrinfo_pkginfo.c +++ b/src/pkgmgrinfo_pkginfo.c @@ -35,13 +35,10 @@ #include #include -#include "pkgmgr_parser.h" #include "pkgmgrinfo_basic.h" #include "pkgmgrinfo_private.h" #include "pkgmgrinfo_debug.h" #include "pkgmgr-info.h" -#include "pkgmgr_parser_db.h" -#include "pkgmgr_parser_internal.h" static bool _get_bool_value(const char *str) { @@ -53,8 +50,8 @@ static bool _get_bool_value(const char *str) static gint __compare_func(gconstpointer data1, gconstpointer data2) { - pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x*)data1; - pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x*)data2; + pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1; + pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2; if (node1->prop == node2->prop) return 0; else if (node1->prop > node2->prop) @@ -63,10 +60,20 @@ static gint __compare_func(gconstpointer data1, gconstpointer data2) return -1; } +static gint __pkg_disable_chk_func(gconstpointer data1, gconstpointer data2) +{ + pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1; + + if (node->prop == E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE) + return 0; + else + return 1; +} + static void __destroy_each_node(gpointer data, gpointer user_data) { ret_if(data == NULL); - pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data; + pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data; if (node->value) { free(node->value); node->value = NULL; @@ -79,10 +86,20 @@ static void __destroy_each_node(gpointer data, gpointer user_data) node = NULL; } +static void __destroy_metadata_node(gpointer data) +{ + pkgmgrinfo_metadata_node_x *node = (pkgmgrinfo_metadata_node_x *)data; + if (node->key) + free(node->key); + if (node->value) + free(node->value); + free(node); +} + static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data) { ret_if(data == NULL); - if (data->locale){ + if (data->locale) { free((void *)data->locale); data->locale = NULL; } @@ -100,7 +117,7 @@ long long _pkgmgr_calculate_dir_size(char *dirname) int q = 0; /*quotient*/ int r = 0; /*remainder*/ DIR *dp = NULL; - struct dirent ep, *result; + struct dirent *ep; struct stat fileinfo; char abs_filename[FILENAME_MAX] = { 0, }; retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL"); @@ -111,22 +128,20 @@ long long _pkgmgr_calculate_dir_size(char *dirname) return -1; } - for (ret = readdir_r(dp, &ep, &result); - ret == 0 && result != NULL; - ret = readdir_r(dp, &ep, &result)) { - if (!strcmp(ep.d_name, ".") || - !strcmp(ep.d_name, "..")) { + for (ep = readdir(dp); ep != NULL; ep = readdir(dp)) { + if (!strcmp(ep->d_name, ".") || + !strcmp(ep->d_name, "..")) { continue; } snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname, - ep.d_name); + ep->d_name); if (lstat(abs_filename, &fileinfo) < 0) perror(abs_filename); else { if (S_ISDIR(fileinfo.st_mode)) { total += fileinfo.st_size; - if (strcmp(ep.d_name, ".") - && strcmp(ep.d_name, "..")) { + if (strcmp(ep->d_name, ".") + && strcmp(ep->d_name, "..")) { ret = _pkgmgr_calculate_dir_size (abs_filename); total = total + ret; @@ -138,9 +153,8 @@ long long _pkgmgr_calculate_dir_size(char *dirname) size occupied (in terms of 4096 blocks)*/ q = (fileinfo.st_size / BLOCK_SIZE); r = (fileinfo.st_size % BLOCK_SIZE); - if (r) { + if (r) q = q + 1; - } total += q * BLOCK_SIZE; } } @@ -150,72 +164,35 @@ long long _pkgmgr_calculate_dir_size(char *dirname) } -static int _pkginfo_get_author(sqlite3 *db, const char *pkgid, - GList **author) +static int _pkginfo_add_description_info_into_list(const char *locale, + char *record, GList **description) { - static const char query_raw[] = - "SELECT author_name, author_email, author_href " - "FROM package_info WHERE package=%Q"; - int ret; - char *query; - sqlite3_stmt *stmt; - int idx = 0; - author_x *info; - - query = sqlite3_mprintf(query_raw, pkgid); - if (query == NULL) { - LOGE("out of memory"); - return PMINFO_R_ERROR; - } - - ret = sqlite3_prepare_v2(db, query, strlen(query), - &stmt, NULL); - sqlite3_free(query); - if (ret != SQLITE_OK) { - LOGE("prepare failed: %s", sqlite3_errmsg(db)); - return PMINFO_R_ERROR; - } - - if (sqlite3_step(stmt) == SQLITE_ERROR) { - LOGE("step error: %s", sqlite3_errmsg(db)); - sqlite3_finalize(stmt); - return PMINFO_R_ERROR; - } + description_x *info; - /* one author per one package */ - info = calloc(1, sizeof(author_x)); + info = calloc(1, sizeof(description_x)); if (info == NULL) { LOGE("out of memory"); - sqlite3_finalize(stmt); return PMINFO_R_ERROR; } - - _save_column_str(stmt, idx++, &info->text); - _save_column_str(stmt, idx++, &info->email); - _save_column_str(stmt, idx++, &info->href); - - /* TODO: revised */ - *author = g_list_append(*author, info); - - sqlite3_finalize(stmt); + info->lang = strdup(locale); + info->text = record; + *description = g_list_append(*description, info); return PMINFO_R_OK; } -static int _pkginfo_get_label(sqlite3 *db, const char *pkgid, - const char *locale, GList **label) +static int _pkginfo_get_plugin_execution_info(sqlite3 *db, const char *pkgid, + GList **plugins) { static const char query_raw[] = - "SELECT package_label, package_locale " - "FROM package_localized_info " - "WHERE package=%Q AND package_locale IN (%Q, %Q)"; + "SELECT appid, plugin_type, plugin_name FROM package_plugin_info " + "WHERE pkgid=%Q"; int ret; char *query; sqlite3_stmt *stmt; - int idx; - label_x *info; + plugin_x *plugin; - query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE); + query = sqlite3_mprintf(query_raw, pkgid); if (query == NULL) { LOGE("out of memory"); return PMINFO_R_ERROR; @@ -230,16 +207,18 @@ static int _pkginfo_get_label(sqlite3 *db, const char *pkgid, } while (sqlite3_step(stmt) == SQLITE_ROW) { - info = calloc(1, sizeof(label_x)); - if (info == NULL) { + plugin = calloc(1, sizeof(plugin_x)); + if (!plugin) { LOGE("out of memory"); sqlite3_finalize(stmt); return PMINFO_R_ERROR; } - idx = 0; - _save_column_str(stmt, idx++, &info->text); - _save_column_str(stmt, idx++, &info->lang); - *label = g_list_append(*label, info); + plugin->pkgid = strdup(pkgid); + _save_column_str(stmt, 0, &plugin->appid); + _save_column_str(stmt, 1, &plugin->plugin_type); + _save_column_str(stmt, 2, &plugin->plugin_name); + *plugins = g_list_append(*plugins, + (gpointer)plugin); } sqlite3_finalize(stmt); @@ -247,20 +226,18 @@ static int _pkginfo_get_label(sqlite3 *db, const char *pkgid, return PMINFO_R_OK; } -static int _pkginfo_get_icon(sqlite3 *db, const char *pkgid, const char *locale, - GList **icon) +static int _pkginfo_get_privilege(sqlite3 *db, const char *pkgid, + GList **privileges) { static const char query_raw[] = - "SELECT package_icon, package_locale " - "FROM package_localized_info " - "WHERE package=%Q AND package_locale IN (%Q, %Q)"; + "SELECT DISTINCT privilege, type FROM package_privilege_info " + "WHERE package=%Q"; int ret; char *query; sqlite3_stmt *stmt; - int idx; - icon_x *info; + privilege_x *privilege; - query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE); + query = sqlite3_mprintf(query_raw, pkgid); if (query == NULL) { LOGE("out of memory"); return PMINFO_R_ERROR; @@ -275,16 +252,11 @@ static int _pkginfo_get_icon(sqlite3 *db, const char *pkgid, const char *locale, } while (sqlite3_step(stmt) == SQLITE_ROW) { - info = calloc(1, sizeof(icon_x)); - if (info == NULL) { - LOGE("out of memory"); - sqlite3_finalize(stmt); - return PMINFO_R_ERROR; - } - idx = 0; - _save_column_str(stmt, idx++, &info->text); - _save_column_str(stmt, idx++, &info->lang); - *icon = g_list_append(*icon, info); + privilege = calloc(1, sizeof(privilege_x)); + _save_column_str(stmt, 0, &privilege->value); + _save_column_str(stmt, 1, &privilege->type); + *privileges = g_list_append(*privileges, + (gpointer)privilege); } sqlite3_finalize(stmt); @@ -292,20 +264,18 @@ static int _pkginfo_get_icon(sqlite3 *db, const char *pkgid, const char *locale, return PMINFO_R_OK; } -static int _pkginfo_get_description(sqlite3 *db, const char *pkgid, - const char *locale, GList **description) +static int _pkginfo_get_appdefined_privilege(sqlite3 *db, const char *pkgid, + GList **privileges) { static const char query_raw[] = - "SELECT package_description, package_locale " - "FROM package_localized_info " - "WHERE package=%Q AND package_locale IN (%Q, %Q)"; + "SELECT DISTINCT privilege, license, type FROM " + "package_appdefined_privilege_info WHERE package=%Q"; int ret; char *query; sqlite3_stmt *stmt; - int idx; - description_x *info; + appdefined_privilege_x *privilege; - query = sqlite3_mprintf(query_raw, pkgid, locale, DEFAULT_LOCALE); + query = sqlite3_mprintf(query_raw, pkgid); if (query == NULL) { LOGE("out of memory"); return PMINFO_R_ERROR; @@ -320,16 +290,17 @@ static int _pkginfo_get_description(sqlite3 *db, const char *pkgid, } while (sqlite3_step(stmt) == SQLITE_ROW) { - info = calloc(1, sizeof(description_x)); - if (info == NULL) { - LOGE("out of memory"); + privilege = calloc(1, sizeof(appdefined_privilege_x)); + if (!privilege) { + LOGE("failed to alloc memory"); sqlite3_finalize(stmt); return PMINFO_R_ERROR; } - idx = 0; - _save_column_str(stmt, idx++, &info->text); - _save_column_str(stmt, idx++, &info->lang); - *description = g_list_append(*description, info); + _save_column_str(stmt, 0, &privilege->value); + _save_column_str(stmt, 1, &privilege->license); + _save_column_str(stmt, 2, &privilege->type); + *privileges = g_list_append(*privileges, + (gpointer)privilege); } sqlite3_finalize(stmt); @@ -337,36 +308,34 @@ static int _pkginfo_get_description(sqlite3 *db, const char *pkgid, return PMINFO_R_OK; } -static int _pkginfo_get_privilege(sqlite3 *db, const char *pkgid, - GList **privileges) +static int _pkginfo_get_dependency(sqlite3 *db, const char *pkgid, + GList **dependencies) { - static const char query_raw[] = - "SELECT privilege FROM package_privilege_info WHERE package=%Q"; + static const char query[] = + "SELECT DISTINCT depends_on, type, required_version " + "FROM package_dependency_info WHERE package=?"; int ret; - char *query; sqlite3_stmt *stmt; - char *privilege; - - query = sqlite3_mprintf(query_raw, pkgid); - if (query == NULL) { - LOGE("out of memory"); - return PMINFO_R_ERROR; - } + dependency_x *dependency; - ret = sqlite3_prepare_v2(db, query, strlen(query), - &stmt, NULL); - sqlite3_free(query); + ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); if (ret != SQLITE_OK) { LOGE("prepare failed: %s", sqlite3_errmsg(db)); return PMINFO_R_ERROR; } while (sqlite3_step(stmt) == SQLITE_ROW) { - privilege = NULL; - _save_column_str(stmt, 0, &privilege); - if (privilege) - *privileges = g_list_append(*privileges, - (gpointer)privilege); + dependency = calloc(1, sizeof(dependency_x)); + if (!dependency) { + LOGE("failed to alloc memory"); + sqlite3_finalize(stmt); + return PMINFO_R_ERROR; + } + _save_column_str(stmt, 0, &dependency->depends_on); + _save_column_str(stmt, 1, &dependency->type); + _save_column_str(stmt, 2, &dependency->required_version); + *dependencies = g_list_append(*dependencies, + (gpointer)dependency); } sqlite3_finalize(stmt); @@ -383,45 +352,38 @@ static const char join_privilege_info[] = " ON pi.package=package_privilege_info.package"; static int _get_filtered_query(pkgmgrinfo_filter_x *filter, - const char *locale, char **query, GList **bind_params) + const char *locale, uid_t uid, char **query, GList **bind_params) { int joined = 0; char buf[MAX_QUERY_LEN] = { '\0' }; char buf2[MAX_QUERY_LEN] = { '\0' }; char *condition = NULL; - size_t len = 0; GSList *list = NULL; if (filter == NULL) return PMINFO_R_OK; - len += strlen(" WHERE 1=1 "); - strncat(buf, " WHERE 1=1 ", MAX_QUERY_LEN - len - 1); + snprintf(buf, sizeof(buf), "%s", " WHERE 1=1 "); for (list = filter->list; list; list = list->next) { - joined |= __get_filter_condition(list->data, &condition, + joined |= __get_filter_condition(list->data, uid, &condition, bind_params); if (condition == NULL) continue; - len += strlen(" AND "); - strncat(buf, " AND ", MAX_QUERY_LEN - len - 1); + strncat(buf, " AND ", sizeof(buf) - strlen(buf) - 1); - len += strlen(condition); - strncat(buf, condition, sizeof(buf) - len - 1); + strncat(buf, condition, sizeof(buf) - strlen(buf) - 1); free(condition); condition = NULL; } if (joined & E_PMINFO_PKGINFO_JOIN_LOCALIZED_INFO) { - strncat(buf2, join_localized_info, MAX_QUERY_LEN - len - 1); - len += strlen(join_localized_info); + strncat(buf2, join_localized_info, sizeof(buf2) - strlen(buf2) - 1); *bind_params = g_list_append(*bind_params, strdup(locale)); } - if (joined & E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO) { - strncat(buf2, join_privilege_info, MAX_QUERY_LEN - len - 1); - len += strlen(join_privilege_info); - } - strncat(buf2, buf, MAX_QUERY_LEN - len - 1); + if (joined & E_PMINFO_PKGINFO_JOIN_PRIVILEGE_INFO) + strncat(buf2, join_privilege_info, sizeof(buf2) - strlen(buf2) - 1); + strncat(buf2, buf, sizeof(buf2) - strlen(buf2) - 1); *query = strdup(buf2); if (*query == NULL) @@ -435,6 +397,20 @@ static void __free_packages(gpointer data) pkgmgrinfo_basic_free_package((package_x *)data); } +static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter) +{ + GSList *link; + + if (filter == NULL) + return false; + + link = g_slist_find_custom(filter->list, NULL, __pkg_disable_chk_func); + if (link) + return true; + + return false; +} + static int __bind_params(sqlite3_stmt *stmt, GList *params) { GList *tmp_list = NULL; @@ -455,40 +431,81 @@ static int __bind_params(sqlite3_stmt *stmt, GList *params) return PMINFO_R_OK; } +static bool __check_package_storage_status(pkgmgrinfo_filter_x *tmp_filter) +{ + GSList *tmp_list = NULL; + pkgmgrinfo_node_x *tmp_node = NULL; + int property = -1; + + property = _pminfo_pkginfo_convert_to_prop_bool(PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE); + for (tmp_list = tmp_filter->list; tmp_list != NULL; + tmp_list = g_slist_next(tmp_list)) { + tmp_node = (pkgmgrinfo_node_x *)tmp_list->data; + if (property == tmp_node->prop) { + if (strcmp(tmp_node->value, "true") == 0) + return true; + else + return false; + } + } + return true; +} + static int _pkginfo_get_packages(uid_t uid, const char *locale, pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages) { static const char query_raw[] = - "SELECT DISTINCT pi.package, pi.package_version, " - "pi.install_location, pi.package_removable, " - "pi.package_preload, pi.package_readonly, pi.package_update, " - "pi.package_appsetting, pi.package_system, pi.package_type, " - "pi.package_size, pi.installed_time, pi.installed_storage, " - "pi.storeclient_id, pi.mainapp_id, pi.package_url, " - "pi.root_path, pi.csc_path, pi.package_nodisplay, " - "pi.package_api_version, pi.package_support_disable, " - "pi.package_tep_name, pi.package_zip_mount_file " - "FROM package_info as pi "; + "SELECT DISTINCT pi.package, pi.installed_storage, pi.external_path"; + static const char query_basic[] = + ", pi.package_version, pi.install_location, " + "pi.package_removable, pi.package_preload, pi.package_readonly, " + "pi.package_update, pi.package_appsetting, pi.package_system, " + "pi.package_type, pi.package_size, pi.installed_time, " + "pi.storeclient_id, pi.mainapp_id, pi.package_url, pi.root_path, " + "pi.csc_path, pi.package_nodisplay, pi.package_api_version, " + "pi.package_support_disable, pi.package_tep_name, " + "pi.package_zip_mount_file, pi.package_support_mode"; + static const char query_author[] = + ", pi.author_name, pi.author_email, pi.author_href"; + static const char query_label[] = + ", COALESCE(" + "(SELECT package_label FROM package_localized_info WHERE pi.package=package AND package_locale=?), " + "(SELECT package_label FROM package_localized_info WHERE pi.package=package AND package_locale='No Locale'))"; + static const char query_icon[] = + ", COALESCE(" + "(SELECT package_icon FROM package_localized_info WHERE pi.package=package AND package_locale=?), " + "(SELECT package_icon FROM package_localized_info WHERE pi.package=package AND package_locale='No Locale'))"; + static const char query_description[] = + ", COALESCE(" + "(SELECT package_description FROM package_localized_info WHERE pi.package=package AND package_locale=?), " + "(SELECT package_description FROM package_localized_info WHERE pi.package=package AND package_locale='No Locale'))"; + static const char query_from_clause[] = " FROM package_info as pi"; int ret = PMINFO_R_ERROR; int idx = 0; - const char *dbpath; + char *dbpath; + char *tmp_record = NULL; char *constraints = NULL; char query[MAX_QUERY_LEN] = { '\0' }; package_x *info = NULL; + author_x *author = NULL; GList *bind_params = NULL; sqlite3 *db; - sqlite3_stmt *stmt; + sqlite3_stmt *stmt = NULL; pkgmgrinfo_filter_x *tmp_filter = NULL; + bool is_check_storage = true; + const uid_t global_user_uid = GLOBAL_USER; dbpath = getUserPkgParserDBPathUID(uid); if (dbpath == NULL) return PMINFO_R_ERROR; - ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL); + ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY); if (ret != SQLITE_OK) { - _LOGD("failed to open db: %d", ret); + _LOGD("failed to open db(%s): %d", dbpath, ret); + free(dbpath); return PMINFO_R_ERROR; } + free(dbpath); if (filter != NULL) { tmp_filter = filter; @@ -500,19 +517,36 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale, } } - /* add package_disable='false' clause by default */ - pkgmgrinfo_pkginfo_filter_add_bool(tmp_filter, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false); + is_check_storage = __check_package_storage_status(tmp_filter); + + snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw); + if (flag & PMINFO_APPINFO_GET_BASICINFO) + strncat(query, query_basic, sizeof(query) - strlen(query) - 1); + if (flag & PMINFO_PKGINFO_GET_AUTHOR) + strncat(query, query_author, sizeof(query) - strlen(query) - 1); + if (flag & PMINFO_PKGINFO_GET_LABEL) { + strncat(query, query_label, sizeof(query) - strlen(query) - 1); + bind_params = g_list_append(bind_params, strdup(locale)); + } + if (flag & PMINFO_PKGINFO_GET_ICON) { + strncat(query, query_icon, sizeof(query) - strlen(query) - 1); + bind_params = g_list_append(bind_params, strdup(locale)); + } + if (flag & PMINFO_PKGINFO_GET_DESCRIPTION) { + strncat(query, query_description, sizeof(query) - strlen(query) - 1); + bind_params = g_list_append(bind_params, strdup(locale)); + } - ret = _get_filtered_query(tmp_filter, locale, &constraints, &bind_params); + strncat(query, query_from_clause, sizeof(query) - strlen(query) - 1); + + ret = _get_filtered_query(tmp_filter, locale, uid, &constraints, &bind_params); if (ret != PMINFO_R_OK) { LOGE("Failed to get WHERE clause"); goto catch; } if (constraints) - snprintf(query, MAX_QUERY_LEN - 1, "%s%s", query_raw, constraints); - else - snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw); + strncat(query, constraints, sizeof(query) - strlen(query) - 1); ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); if (ret != SQLITE_OK) { @@ -531,93 +565,121 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale, info = calloc(1, sizeof(package_x)); if (info == NULL) { LOGE("out of memory"); - sqlite3_finalize(stmt); - sqlite3_close_v2(db); - return PMINFO_R_ERROR; + ret = PMINFO_R_ERROR; + goto catch; } idx = 0; _save_column_str(stmt, idx++, &info->package); - if (g_hash_table_contains(packages, - (gconstpointer)info->package)) { - free(info->package); - free(info); - continue; - } - _save_column_str(stmt, idx++, &info->version); - _save_column_str(stmt, idx++, &info->installlocation); - _save_column_str(stmt, idx++, &info->removable); - _save_column_str(stmt, idx++, &info->preload); - _save_column_str(stmt, idx++, &info->readonly); - _save_column_str(stmt, idx++, &info->update); - _save_column_str(stmt, idx++, &info->appsetting); - _save_column_str(stmt, idx++, &info->system); - _save_column_str(stmt, idx++, &info->type); - _save_column_str(stmt, idx++, &info->package_size); - _save_column_str(stmt, idx++, &info->installed_time); _save_column_str(stmt, idx++, &info->installed_storage); - _save_column_str(stmt, idx++, &info->storeclient_id); - _save_column_str(stmt, idx++, &info->mainapp_id); - _save_column_str(stmt, idx++, &info->package_url); - _save_column_str(stmt, idx++, &info->root_path); - _save_column_str(stmt, idx++, &info->csc_path); - _save_column_str(stmt, idx++, &info->nodisplay_setting); - _save_column_str(stmt, idx++, &info->api_version); - _save_column_str(stmt, idx++, &info->support_disable); - _save_column_str(stmt, idx++, &info->tep_name); - _save_column_str(stmt, idx++, &info->zip_mount_file); + _save_column_str(stmt, idx++, &info->external_path); + + if (flag & PMINFO_APPINFO_GET_BASICINFO) { + _save_column_str(stmt, idx++, &info->version); + _save_column_str(stmt, idx++, &info->installlocation); + _save_column_str(stmt, idx++, &info->removable); + _save_column_str(stmt, idx++, &info->preload); + _save_column_str(stmt, idx++, &info->readonly); + _save_column_str(stmt, idx++, &info->update); + _save_column_str(stmt, idx++, &info->appsetting); + _save_column_str(stmt, idx++, &info->system); + _save_column_str(stmt, idx++, &info->type); + _save_column_str(stmt, idx++, &info->package_size); + _save_column_str(stmt, idx++, &info->installed_time); + _save_column_str(stmt, idx++, &info->storeclient_id); + _save_column_str(stmt, idx++, &info->mainapp_id); + _save_column_str(stmt, idx++, &info->package_url); + _save_column_str(stmt, idx++, &info->root_path); + _save_column_str(stmt, idx++, &info->csc_path); + _save_column_str(stmt, idx++, &info->nodisplay_setting); + _save_column_str(stmt, idx++, &info->api_version); + _save_column_str(stmt, idx++, &info->support_disable); + _save_column_str(stmt, idx++, &info->tep_name); + _save_column_str(stmt, idx++, &info->zip_mount_file); + _save_column_str(stmt, idx++, &info->support_mode); + } + info->for_all_users = - strdup((uid != GLOBAL_USER) ? "false" : "true"); + strdup((uid != global_user_uid) ? "false" : "true"); + + if (_pkginfo_get_plugin_execution_info(db, info->package, &info->plugin)) { + ret = PMINFO_R_ERROR; + goto catch; + } if (flag & PMINFO_PKGINFO_GET_AUTHOR) { - if (_pkginfo_get_author(db, info->package, - &info->author)) { - pkgmgrinfo_basic_free_package(info); - sqlite3_finalize(stmt); - sqlite3_close_v2(db); - return PMINFO_R_ERROR; + /* TODO : author should be retrieved at package_localized_info */ + author = calloc(1, sizeof(author_x)); + if (author == NULL) { + ret = PMINFO_R_ERROR; + goto catch; } + _save_column_str(stmt, idx++, &author->text); + _save_column_str(stmt, idx++, &author->email); + _save_column_str(stmt, idx++, &author->href); + info->author = g_list_append(info->author, author); } if (flag & PMINFO_PKGINFO_GET_LABEL) { - if (_pkginfo_get_label(db, info->package, locale, - &info->label)) { - pkgmgrinfo_basic_free_package(info); - sqlite3_finalize(stmt); - sqlite3_close_v2(db); - return PMINFO_R_ERROR; + tmp_record = NULL; + _save_column_str(stmt, idx++, &tmp_record); + + if (_add_label_info_into_list(locale, tmp_record, &info->label)) { + ret = PMINFO_R_ERROR; + goto catch; } } if (flag & PMINFO_PKGINFO_GET_ICON) { - if (_pkginfo_get_icon(db, info->package, locale, - &info->icon)) { - pkgmgrinfo_basic_free_package(info); - sqlite3_finalize(stmt); - sqlite3_close_v2(db); - return PMINFO_R_ERROR; + tmp_record = NULL; + _save_column_str(stmt, idx++, &tmp_record); + if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) { + ret = PMINFO_R_ERROR; + goto catch; } } if (flag & PMINFO_PKGINFO_GET_DESCRIPTION) { - if (_pkginfo_get_description(db, info->package, locale, - &info->description)) { - pkgmgrinfo_basic_free_package(info); - sqlite3_finalize(stmt); - sqlite3_close_v2(db); - return PMINFO_R_ERROR; + tmp_record = NULL; + _save_column_str(stmt, idx++, &tmp_record); + if (_pkginfo_add_description_info_into_list(locale, tmp_record, + &info->description)) { + ret = PMINFO_R_ERROR; + goto catch; } } if (flag & PMINFO_PKGINFO_GET_PRIVILEGE) { if (_pkginfo_get_privilege(db, info->package, &info->privileges)) { - pkgmgrinfo_basic_free_package(info); - sqlite3_finalize(stmt); - sqlite3_close_v2(db); - return PMINFO_R_ERROR; + ret = PMINFO_R_ERROR; + goto catch; + } + } + + if (flag & PMINFO_PKGINFO_GET_APPDEFINED_PRIVILEGE) { + if (_pkginfo_get_appdefined_privilege(db, info->package, + &info->appdefined_privileges)) { + ret = PMINFO_R_ERROR; + goto catch; } } + if (flag & PMINFO_PKGINFO_GET_DEPENDENCY) { + if (_pkginfo_get_dependency(db, info->package, + &info->dependencies)) { + ret = PMINFO_R_ERROR; + goto catch; + } + } + + if (is_check_storage && + __pkginfo_check_installed_storage(info) != PMINFO_R_OK) { + ret = PMINFO_R_ERROR; + pkgmgrinfo_basic_free_package(info); + info = NULL; + continue; + } + g_hash_table_insert(packages, (gpointer)info->package, (gpointer)info); } @@ -625,6 +687,9 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale, ret = PMINFO_R_OK; catch: + sqlite3_finalize(stmt); + sqlite3_close_v2(db); + if (constraints) free(constraints); @@ -635,8 +700,6 @@ catch: pkgmgrinfo_pkginfo_filter_destroy(tmp_filter); g_list_free_full(bind_params, free); - sqlite3_close_v2(db); - sqlite3_finalize(stmt); return ret; } @@ -649,6 +712,7 @@ static int _pkginfo_get_filtered_foreach_pkginfo(uid_t uid, char *locale; package_x *pkg; pkgmgr_pkginfo_x info; + pkgmgrinfo_filter_x *tmp_filter = NULL; GHashTable *list; GHashTableIter iter; gpointer value; @@ -664,14 +728,42 @@ static int _pkginfo_get_filtered_foreach_pkginfo(uid_t uid, return PMINFO_R_ERROR; } - ret = _pkginfo_get_packages(uid, locale, filter, flag, list); + if (filter != NULL) { + tmp_filter = (pkgmgrinfo_filter_x *)filter; + } else { + ret = pkgmgrinfo_pkginfo_filter_create((void *)&tmp_filter); + if (ret != PMINFO_R_OK) { + _LOGE("Failed to create filter"); + g_hash_table_destroy(list); + free(locale); + return PMINFO_R_ERROR; + } + } + + if (__check_disable_filter_exist(tmp_filter) == false) { + ret = pkgmgrinfo_pkginfo_filter_add_bool(tmp_filter, + PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false); + if (ret != PMINFO_R_OK) { + _LOGE("Failed to add filter"); + g_hash_table_destroy(list); + free(locale); + if (filter == NULL) + pkgmgrinfo_pkginfo_filter_destroy(tmp_filter); + return PMINFO_R_ERROR; + } + } + + ret = _pkginfo_get_packages(uid, locale, tmp_filter, + flag | PMINFO_PKGINFO_GET_BASICINFO, list); if (ret == PMINFO_R_OK && uid != GLOBAL_USER) - ret = _pkginfo_get_packages(GLOBAL_USER, locale, filter, - flag, list); + ret = _pkginfo_get_packages(GLOBAL_USER, locale, tmp_filter, + flag | PMINFO_PKGINFO_GET_BASICINFO, list); if (ret != PMINFO_R_OK) { g_hash_table_destroy(list); free(locale); + if (filter == NULL) + pkgmgrinfo_pkginfo_filter_destroy(tmp_filter); return PMINFO_R_ERROR; } @@ -688,13 +780,122 @@ static int _pkginfo_get_filtered_foreach_pkginfo(uid_t uid, g_hash_table_destroy(list); free(locale); + if (filter == NULL) + pkgmgrinfo_pkginfo_filter_destroy(tmp_filter); + return PMINFO_R_OK; } +static int _pkgmgrinfo_get_pkginfo(const char *pkgid, uid_t uid, + pkgmgrinfo_pkginfo_filter_h filter, pkgmgrinfo_pkginfo_h *handle) +{ + int ret; + char *locale; + GHashTable *list; + pkgmgr_pkginfo_x *info; + + if (pkgid == NULL || filter == NULL || handle == NULL) { + LOGE("invalid parameter"); + return PMINFO_R_EINVAL; + } + + locale = _get_system_locale(); + if (locale == NULL) + return PMINFO_R_ERROR; + + list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, + __free_packages); + if (list == NULL) { + free(locale); + return PMINFO_R_ERROR; + } + + ret = _pkginfo_get_packages(uid, locale, filter, + PMINFO_PKGINFO_GET_ALL, list); + if (!g_hash_table_size(list) && uid != GLOBAL_USER) + ret = _pkginfo_get_packages(GLOBAL_USER, locale, filter, + PMINFO_PKGINFO_GET_ALL, list); + + if (ret != PMINFO_R_OK) { + g_hash_table_destroy(list); + free(locale); + return ret; + } + + if (!g_hash_table_size(list)) { + _LOGD("pkginfo for [%s] is not existed for user [%d]", + pkgid, uid); + g_hash_table_destroy(list); + free(locale); + return PMINFO_R_ENOENT; + } + + info = calloc(1, sizeof(pkgmgr_pkginfo_x)); + if (info == NULL) { + _LOGE("out of memory"); + g_hash_table_destroy(list); + free(locale); + return PMINFO_R_ERROR; + } + + info->uid = uid; + info->pkg_info = (package_x *)g_hash_table_lookup(list, pkgid); + info->locale = locale; + + /* just free list only */ + g_hash_table_steal(list, (gconstpointer)pkgid); + g_hash_table_destroy(list); + + *handle = info; + + return ret; +} + API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle) { int ret; + pkgmgrinfo_pkginfo_filter_h filter; + + if (pkgid == NULL || handle == NULL) { + LOGE("invalid parameter"); + return PMINFO_R_EINVAL; + } + + ret = pkgmgrinfo_pkginfo_filter_create(&filter); + if (ret != PMINFO_R_OK) + return ret; + + ret = pkgmgrinfo_pkginfo_filter_add_string(filter, + PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_filter_destroy(filter); + return PMINFO_R_ERROR; + } + + ret = pkgmgrinfo_pkginfo_filter_add_bool(filter, + PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_filter_destroy(filter); + return PMINFO_R_ERROR; + } + + ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle); + pkgmgrinfo_pkginfo_filter_destroy(filter); + + return ret; +} + +API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, + pkgmgrinfo_pkginfo_h *handle) +{ + return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, _getuid(), handle); +} + +API int pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(const char *pkgid, + uid_t uid, pkgmgrinfo_pkginfo_h *handle) +{ + int ret; char *locale; GHashTable *list; pkgmgrinfo_pkginfo_filter_h filter; @@ -723,7 +924,16 @@ API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, return PMINFO_R_ERROR; } - list = g_hash_table_new(g_str_hash, g_str_equal); + ret = pkgmgrinfo_pkginfo_filter_add_bool(filter, + PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, true); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_filter_destroy(filter); + free(locale); + return PMINFO_R_ERROR; + } + + list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, + __free_packages); if (list == NULL) { pkgmgrinfo_pkginfo_filter_destroy(filter); free(locale); @@ -744,7 +954,7 @@ API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, } if (!g_hash_table_size(list)) { - _LOGI("pkginfo for [%s] is not existed for user [%d]", + _LOGD("disabled pkginfo for [%s] is not existed for user [%d]", pkgid, uid); g_hash_table_destroy(list); free(locale); @@ -764,6 +974,7 @@ API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, info->locale = locale; /* just free list only */ + g_hash_table_steal(list, (gconstpointer)pkgid); g_hash_table_destroy(list); *handle = info; @@ -771,22 +982,77 @@ API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, return ret; } -API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, +API int pkgmgrinfo_pkginfo_get_usr_all_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle) { - return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, _getuid(), handle); + + int ret; + pkgmgrinfo_pkginfo_filter_h filter; + + if (pkgid == NULL || handle == NULL) { + LOGE("invalid parameter"); + return PMINFO_R_EINVAL; + } + + ret = pkgmgrinfo_pkginfo_filter_create(&filter); + if (ret != PMINFO_R_OK) + return ret; + + ret = pkgmgrinfo_pkginfo_filter_add_string(filter, + PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_filter_destroy(filter); + return PMINFO_R_ERROR; + } + + ret = pkgmgrinfo_pkginfo_filter_add_bool(filter, + PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE, false); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_filter_destroy(filter); + return PMINFO_R_ERROR; + } + + ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle); + pkgmgrinfo_pkginfo_filter_destroy(filter); + + return ret; +} + +API int pkgmgrinfo_pkginfo_get_disabled_pkginfo(const char *pkgid, + pkgmgrinfo_pkginfo_h *handle) +{ + return pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(pkgid, _getuid(), + handle); +} + +API int pkgmgrinfo_pkginfo_get_all_pkginfo(const char *pkgid, + pkgmgrinfo_pkginfo_h *handle) +{ + return pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid, _getuid(), handle); } API int pkgmgrinfo_pkginfo_get_usr_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb, int flag, void *user_data, uid_t uid) { + int ret; + pkgmgrinfo_pkginfo_filter_h filter; + if (pkg_list_cb == NULL) { LOGE("invalid parameter"); return PMINFO_R_EINVAL; } - return _pkginfo_get_filtered_foreach_pkginfo(uid, NULL, flag, + /* create an empty filter */ + ret = pkgmgrinfo_pkginfo_filter_create(&filter); + if (ret != PMINFO_R_OK) + return ret; + + ret = _pkginfo_get_filtered_foreach_pkginfo(uid, filter, flag, pkg_list_cb, user_data); + + pkgmgrinfo_pkginfo_filter_destroy(filter); + + return ret; } API int pkgmgrinfo_pkginfo_get_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb, @@ -799,13 +1065,25 @@ API int pkgmgrinfo_pkginfo_get_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb, API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid) { + int ret; + pkgmgrinfo_pkginfo_filter_h filter; + if (pkg_list_cb == NULL) { LOGE("invalid parameter"); return PMINFO_R_EINVAL; } - return _pkginfo_get_filtered_foreach_pkginfo(uid, NULL, + /* create an empty filter */ + ret = pkgmgrinfo_pkginfo_filter_create(&filter); + if (ret != PMINFO_R_OK) + return ret; + + ret = _pkginfo_get_filtered_foreach_pkginfo(uid, filter, PMINFO_PKGINFO_GET_ALL, pkg_list_cb, user_data); + + pkgmgrinfo_pkginfo_filter_destroy(filter); + + return ret; } API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, @@ -815,6 +1093,43 @@ API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, _getuid()); } +API int pkgmgrinfo_pkginfo_get_usr_disabled_list( + pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid) +{ + int ret; + pkgmgrinfo_pkginfo_filter_h filter; + + if (pkg_list_cb == NULL) { + LOGE("invalid parameter"); + return PMINFO_R_EINVAL; + } + + ret = pkgmgrinfo_pkginfo_filter_create(&filter); + if (ret != PMINFO_R_OK) + return ret; + + ret = pkgmgrinfo_pkginfo_filter_add_bool(filter, + PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, true); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_pkginfo_filter_destroy(filter); + return PMINFO_R_ERROR; + } + + ret = _pkginfo_get_filtered_foreach_pkginfo(uid, filter, + PMINFO_PKGINFO_GET_ALL, pkg_list_cb, user_data); + + pkgmgrinfo_pkginfo_filter_destroy(filter); + + return ret; +} + +API int pkgmgrinfo_pkginfo_get_disabled_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, + void *user_data) +{ + return pkgmgrinfo_pkginfo_get_usr_disabled_list(pkg_list_cb, user_data, + _getuid()); +} + API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name) { pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; @@ -854,10 +1169,11 @@ API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type) if (info->pkg_info == NULL) return PMINFO_R_ERROR; - if (info->pkg_info->type == NULL) - info->pkg_info->type = strdup(""); - *type = (char *)info->pkg_info->type; + if (info->pkg_info->type == NULL) + *type = ""; + else + *type = (char *)info->pkg_info->type; return PMINFO_R_OK; } @@ -871,10 +1187,11 @@ API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **versi if (info->pkg_info == NULL) return PMINFO_R_ERROR; - if (info->pkg_info->version == NULL) - info->pkg_info->version = strdup(""); - *version = (char *)info->pkg_info->version; + if (info->pkg_info->version == NULL) + *version = ""; + else + *version = (char *)info->pkg_info->version; return PMINFO_R_OK; } @@ -888,10 +1205,11 @@ API int pkgmgrinfo_pkginfo_get_api_version(pkgmgrinfo_pkginfo_h handle, char **a if (info->pkg_info == NULL) return PMINFO_R_ERROR; - if (info->pkg_info->api_version == NULL) - info->pkg_info->api_version = strdup(""); - *api_version = (char *)info->pkg_info->api_version; + if (info->pkg_info->api_version == NULL) + *api_version = ""; + else + *api_version = (char *)info->pkg_info->api_version; return PMINFO_R_OK; } @@ -911,19 +1229,38 @@ API int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_ return PMINFO_R_OK; } -API int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char **zip_mount_file) +API int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char **zip_mount_file) +{ + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); + retvm_if(zip_mount_file == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + + if (info->pkg_info == NULL) + return PMINFO_R_ERROR; + + if (info->pkg_info->zip_mount_file == NULL) + *zip_mount_file = ""; + else + *zip_mount_file = (char *)info->pkg_info->zip_mount_file; + + return PMINFO_R_OK; +} + +API int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path) { pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); - retvm_if(zip_mount_file == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + retvm_if(ext_image_path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); if (info->pkg_info == NULL) return PMINFO_R_ERROR; - if (info->pkg_info->zip_mount_file == NULL) - info->pkg_info->zip_mount_file = strdup(""); - *zip_mount_file = (char *)info->pkg_info->zip_mount_file; + if (info->pkg_info->external_path == NULL) + return PMINFO_R_ENOENT; + + *ext_image_path = (char *)info->pkg_info->external_path; return PMINFO_R_OK; } @@ -978,120 +1315,71 @@ API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *si API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon) { - const char *locale; icon_x *ptr; - GList *tmp; pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL"); - locale = info->locale; - retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL"); - if (info->pkg_info == NULL || info->pkg_info->icon == NULL) return PMINFO_R_ERROR; - for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) { - ptr = (icon_x *)tmp->data; - if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || - strcmp(ptr->lang, locale)) - continue; - *icon = (char *)ptr->text; - return PMINFO_R_OK; - } - - locale = DEFAULT_LOCALE; - for (tmp = info->pkg_info->icon; tmp; tmp = tmp->next) { - ptr = (icon_x *)tmp->data; - if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || - strcmp(ptr->lang, locale)) - continue; - *icon = (char *)ptr->text; - return PMINFO_R_OK; - } + ptr = (icon_x *)info->pkg_info->icon->data; + if (ptr == NULL) + return PMINFO_R_ERROR; - *icon = ""; + /* TODO : should we return empty string if there was no icon? */ + if (ptr->text == NULL) + *icon = ""; + else + *icon = ptr->text; return PMINFO_R_OK; } API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label) { - const char *locale; label_x *ptr; - GList *tmp; pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL"); - locale = info->locale; - retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL"); - if (info->pkg_info == NULL || info->pkg_info->label == NULL) return PMINFO_R_ERROR; - for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) { - ptr = (label_x *)tmp->data; - if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || - strcmp(ptr->lang, locale)) - continue; - *label = (char *)ptr->text; - return PMINFO_R_OK; - } - - locale = DEFAULT_LOCALE; - for (tmp = info->pkg_info->label; tmp != NULL; tmp = tmp->next) { - ptr = (label_x *)tmp->data; - if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || - strcmp(ptr->lang, locale)) - continue; - *label = (char *)ptr->text; - return PMINFO_R_OK; - } + ptr = (label_x *)info->pkg_info->label->data; + if (ptr == NULL) + return PMINFO_R_ERROR; - *label = ""; + /* TODO : should we return empty string if there was no label? */ + if (ptr->text == NULL) + *label = ""; + else + *label = ptr->text; return PMINFO_R_OK; } API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description) { - const char *locale; description_x *ptr; - GList *tmp; pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); - locale = info->locale; - retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL"); - if (info->pkg_info == NULL || info->pkg_info->description == NULL) return PMINFO_R_ERROR; - for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) { - ptr = (description_x *)tmp->data; - if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || - strcmp(ptr->lang, locale)) - continue; - *description = (char *)ptr->text; - return PMINFO_R_OK; - } + ptr = (description_x *)info->pkg_info->description->data; + if (ptr == NULL) + return PMINFO_R_ERROR; - locale = DEFAULT_LOCALE; - for (tmp = info->pkg_info->description; tmp; tmp = tmp->next) { - ptr = (description_x *)tmp->data; - if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL || - strcmp(ptr->lang, locale)) - continue; + if (ptr->text == NULL) + *description = ""; + else *description = (char *)ptr->text; - return PMINFO_R_OK; - } - - *description = ""; return PMINFO_R_OK; } @@ -1110,10 +1398,11 @@ API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **a author = (author_x *)info->pkg_info->author->data; if (author == NULL) return PMINFO_R_ERROR; - if (author->text == NULL) - author->text = strdup(""); - *author_name = (char *)author->text; + if (author->text == NULL) + *author_name = ""; + else + *author_name = (char *)author->text; return PMINFO_R_OK; } @@ -1132,10 +1421,11 @@ API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char ** author = (author_x *)info->pkg_info->author->data; if (author == NULL) return PMINFO_R_ERROR; - if (author->email == NULL) - author->email = strdup(""); - *author_email = (char *)author->email; + if (author->email == NULL) + *author_email = ""; + else + *author_email = (char *)author->email; return PMINFO_R_OK; } @@ -1154,10 +1444,11 @@ API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **a author = (author_x *)info->pkg_info->author->data; if (author == NULL) return PMINFO_R_ERROR; - if (author->href == NULL) - author->href = strdup(""); - *author_href = (char *)author->href; + if (author->href == NULL) + *author_href = ""; + else + *author_href = (char *)author->href; return PMINFO_R_OK; } @@ -1172,10 +1463,12 @@ API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pk if (info->pkg_info == NULL || info->pkg_info->installed_storage == NULL) return PMINFO_R_ERROR; - if (strcmp(info->pkg_info->installed_storage,"installed_internal") == 0) + if (strcmp(info->pkg_info->installed_storage, "installed_internal") == 0) *storage = PMINFO_INTERNAL_STORAGE; - else if (strcmp(info->pkg_info->installed_storage,"installed_external") == 0) + else if (strcmp(info->pkg_info->installed_storage, "installed_external") == 0) *storage = PMINFO_EXTERNAL_STORAGE; + else if (strcmp(info->pkg_info->installed_storage, "installed_extended") == 0) + *storage = PMINFO_EXTENDED_STORAGE; else return PMINFO_R_ERROR; @@ -1206,10 +1499,11 @@ API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char * if (info->pkg_info == NULL) return PMINFO_R_ERROR; - if (info->pkg_info->storeclient_id == NULL) - info->pkg_info->storeclient_id = strdup(""); - *storeclientid = (char *)info->pkg_info->storeclient_id; + if (info->pkg_info->storeclient_id == NULL) + *storeclientid = ""; + else + *storeclientid = (char *)info->pkg_info->storeclient_id; return PMINFO_R_OK; } @@ -1238,10 +1532,11 @@ API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url) if (info->pkg_info == NULL) return PMINFO_R_ERROR; - if (info->pkg_info->package_url == NULL) - info->pkg_info->package_url = strdup(""); - *url = (char *)info->pkg_info->package_url; + if (info->pkg_info->package_url == NULL) + *url = ""; + else + *url = (char *)info->pkg_info->package_url; return PMINFO_R_OK; } @@ -1270,24 +1565,38 @@ API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path if (info->pkg_info == NULL) return PMINFO_R_ERROR; - if (info->pkg_info->csc_path == NULL) - info->pkg_info->csc_path = strdup(""); - *path = (char *)info->pkg_info->csc_path; + if (info->pkg_info->csc_path == NULL) + *path = ""; + else + *path = (char *)info->pkg_info->csc_path; return PMINFO_R_OK; } +API int pkgmgrinfo_pkginfo_get_support_mode(pkgmgrinfo_pkginfo_h handle, int *support_mode) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); + retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); + + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + if (info->pkg_info->support_mode) + *support_mode = atoi(info->pkg_info->support_mode); + else + *support_mode = 0; + + return PMINFO_R_OK; +} API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible) { retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n"); retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n"); -#if 0 //smack issue occured, check later +#if 0 /* smack issue occured, check later */ char *pkgid = NULL; pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid); - if (pkgid == NULL){ + if (pkgid == NULL) { _LOGD("invalid func parameters\n"); return PMINFO_R_ERROR; } @@ -1297,13 +1606,13 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce char app_mmc_path[FILENAME_MAX] = { 0, }; char app_dir_path[FILENAME_MAX] = { 0, }; char app_mmc_internal_path[FILENAME_MAX] = { 0, }; - snprintf(app_dir_path, FILENAME_MAX,"%s%s", PKG_INSTALLATION_PATH, pkgid); - snprintf(app_mmc_path, FILENAME_MAX,"%s%s", PKG_SD_PATH, pkgid); - snprintf(app_mmc_internal_path, FILENAME_MAX,"%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid); + snprintf(app_dir_path, FILENAME_MAX, "%s%s", PKG_INSTALLATION_PATH, pkgid); + snprintf(app_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid); + snprintf(app_mmc_internal_path, FILENAME_MAX, "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid); /*check whether application is in external memory or not */ fp = fopen(app_mmc_path, "r"); - if (fp == NULL){ + if (fp == NULL) { _LOGD(" app path in external memory not accesible\n"); } else { fclose(fp); @@ -1323,12 +1632,11 @@ API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *acce /*check whether the application is installed in SD card but SD card is not present*/ fp = fopen(app_mmc_internal_path, "r"); - if (fp == NULL){ + if (fp == NULL) { *accessible = 1; _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n"); return PMINFO_R_OK; - } - else{ + } else { *accessible = 0; _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n"); } @@ -1371,8 +1679,6 @@ API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable val = (char *)info->pkg_info->installlocation; if (strcmp(val, "internal-only") == 0) *movable = 0; - else if (strcmp(val, "prefer-external") == 0) - *movable = 1; else *movable = 1; @@ -1491,7 +1797,7 @@ API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle) retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n"); - filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x)); + filter = (pkgmgrinfo_filter_x *)calloc(1, sizeof(pkgmgrinfo_filter_x)); if (filter == NULL) { _LOGE("Out of Memory!!!"); return PMINFO_R_ERROR; @@ -1513,6 +1819,8 @@ API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle) g_slist_free(filter->list); } + g_slist_free_full(filter->list_metadata, __destroy_metadata_node); + free(filter); return PMINFO_R_OK; @@ -1680,6 +1988,16 @@ API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, return PMINFO_R_ERROR; } + if (__check_disable_filter_exist((pkgmgrinfo_filter_x *)handle) == false) { + ret = pkgmgrinfo_pkginfo_filter_add_bool(handle, + PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false); + if (ret != PMINFO_R_OK) { + free(locale); + g_hash_table_destroy(list); + return PMINFO_R_ERROR; + } + } + ret = _pkginfo_get_packages(uid, locale, (pkgmgrinfo_filter_x *)handle, 0, list); if (ret == PMINFO_R_OK && uid != GLOBAL_USER) @@ -1730,7 +2048,8 @@ API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle, retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL"); int ret; - const char *privilege; + privilege_x *privilege; + appdefined_privilege_x *appdefined_privilege; GList *tmp; pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; @@ -1738,12 +2057,385 @@ API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle, return PMINFO_R_ERROR; for (tmp = info->pkg_info->privileges; tmp; tmp = tmp->next) { - privilege = (const char *)tmp->data; + privilege = (privilege_x *)tmp->data; + if (privilege == NULL) + continue; + ret = privilege_func(privilege->value, user_data); + if (ret < 0) + return PMINFO_R_OK; + } + + for (tmp = info->pkg_info->appdefined_privileges; tmp; + tmp = tmp->next) { + appdefined_privilege = (appdefined_privilege_x *)tmp->data; + if (appdefined_privilege == NULL) + continue; + ret = privilege_func(appdefined_privilege->value, user_data); + if (ret < 0) + return PMINFO_R_OK; + } + return PMINFO_R_OK; +} + +API int pkgmgrinfo_pkginfo_foreach_plugin(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_plugin_list_cb plugin_func, void *user_data) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); + retvm_if(plugin_func == NULL, PMINFO_R_EINVAL, + "Callback function is NULL"); + int ret; + plugin_x *plugin; + GList *tmp; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + + if (info->pkg_info == NULL) + return PMINFO_R_ERROR; + + for (tmp = info->pkg_info->plugin; tmp; tmp = tmp->next) { + plugin = (plugin_x *)tmp->data; + if (plugin == NULL) + continue; + ret = plugin_func(plugin->pkgid, plugin->appid, + plugin->plugin_type, plugin->plugin_name, user_data); + if (ret < 0) + return PMINFO_R_OK; + } + + return PMINFO_R_OK; +} + +API int pkgmgrinfo_pkginfo_foreach_appdefined_privilege( + pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_appdefined_privilege_list_cb privilege_func, + void *user_data) +{ + retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL"); + retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, + "Callback function is NULL"); + int ret; + appdefined_privilege_x *privilege; + GList *tmp; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + + if (info->pkg_info == NULL) + return PMINFO_R_ERROR; + + for (tmp = info->pkg_info->appdefined_privileges; tmp; + tmp = tmp->next) { + privilege = (appdefined_privilege_x *)tmp->data; if (privilege == NULL) continue; - ret = privilege_func(privilege, user_data); + ret = privilege_func(privilege->value, privilege->license, + user_data); + if (ret < 0) + break; + } + return PMINFO_R_OK; +} + +API int pkgmgrinfo_pkginfo_foreach_dependency(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_dependency_list_cb dependency_cb, + void *user_data) +{ + int ret; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + GList *tmp; + dependency_x *dependency; + + if (handle == NULL || dependency_cb == NULL) { + LOGE("invalid parameter"); + return PMINFO_R_EINVAL; + } + + if (info->pkg_info == NULL) + return PMINFO_R_ERROR; + + for (tmp = info->pkg_info->dependencies; tmp; tmp = tmp->next) { + dependency = (dependency_x *)tmp->data; + if (dependency == NULL) + continue; + ret = dependency_cb(dependency->depends_on, dependency->type, + dependency->required_version, user_data); + if (ret < 0) + break; + } + + return PMINFO_R_OK; +} + +struct required_by { + char *pkgid; + char *type; + char *version; +}; + +static int _get_required_by(sqlite3 *db, const char *pkgid, GQueue **queue, + GHashTable **table, GList **pkg_list) +{ + static const char query[] = + "SELECT package, type, required_version " + "FROM package_dependency_info WHERE depends_on=?"; + int ret; + sqlite3_stmt *stmt; + struct required_by *req; + + /* already checked */ + if (!g_hash_table_insert(*table, strdup(pkgid), GINT_TO_POINTER(1))) + return PMINFO_R_OK; + + ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL); + if (ret != SQLITE_OK) { + LOGE("prepare failed: %s", sqlite3_errmsg(db)); + return PMINFO_R_ERROR; + } + + ret = sqlite3_bind_text(stmt, 1, pkgid, -1, SQLITE_STATIC); + if (ret != SQLITE_OK) { + LOGE("bind failed: %s", sqlite3_errmsg(db)); + sqlite3_finalize(stmt); + return PMINFO_R_ERROR; + } + + while (sqlite3_step(stmt) == SQLITE_ROW) { + req = calloc(1, sizeof(struct required_by)); + if (req == NULL) { + LOGE("out of memory"); + sqlite3_finalize(stmt); + return PMINFO_R_ERROR; + } + _save_column_str(stmt, 0, &req->pkgid); + _save_column_str(stmt, 1, &req->type); + _save_column_str(stmt, 2, &req->version); + + *pkg_list = g_list_append(*pkg_list, req); + g_queue_push_tail(*queue, strdup(req->pkgid)); + } + + sqlite3_finalize(stmt); + + return PMINFO_R_OK; +} + +static int _pkginfo_foreach_required_by(uid_t uid, const char *pkgid, + GList **pkg_list) +{ + int ret; + char *dbpath; + sqlite3 *db; + GQueue *queue; + GHashTable *table; + char *item; + + dbpath = getUserPkgParserDBPathUID(uid); + if (dbpath == NULL) + return PMINFO_R_ERROR; + + ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY); + if (ret != SQLITE_OK) { + LOGD("failed to open db(%s): %d", dbpath, ret); + free(dbpath); + return PMINFO_R_ERROR; + } + free(dbpath); + + queue = g_queue_new(); + if (queue == NULL) { + LOGE("out of memory"); + sqlite3_close_v2(db); + return PMINFO_R_ERROR; + } + + table = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL); + + g_queue_push_tail(queue, strdup(pkgid)); + while (!g_queue_is_empty(queue)) { + item = g_queue_pop_head(queue); + ret = _get_required_by(db, item, &queue, &table, pkg_list); + free(item); + if (ret != PMINFO_R_OK) { + LOGE("failed to get required by pkgs"); + g_hash_table_destroy(table); + g_queue_free_full(queue, free); + sqlite3_close_v2(db); + return PMINFO_R_ERROR; + } + } + + g_hash_table_destroy(table); + g_queue_free_full(queue, free); + sqlite3_close_v2(db); + + return PMINFO_R_OK; +} + +static void __free_required_by(gpointer data) +{ + struct required_by *req = (struct required_by *)data; + + free(req->pkgid); + free(req->type); + free(req->version); + free(req); +} + +API int pkgmgrinfo_pkginfo_foreach_required_by(pkgmgrinfo_pkginfo_h handle, + pkgmgrinfo_pkg_dependency_list_cb dependency_cb, + void *user_data) +{ + int ret; + pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle; + GList *pkg_list = NULL; + GList *l; + struct required_by *req; + + if (handle == NULL || dependency_cb == NULL || info->pkg_info == NULL) { + LOGE("invalid parameter"); + return PMINFO_R_EINVAL; + } + + ret = _pkginfo_foreach_required_by(info->uid, info->pkg_info->package, + &pkg_list); + if (ret == PMINFO_R_OK && info->uid != GLOBAL_USER) + ret = _pkginfo_foreach_required_by(GLOBAL_USER, + info->pkg_info->package, &pkg_list); + + if (ret != PMINFO_R_OK) { + g_list_free_full(pkg_list, __free_required_by); + return ret; + } + + for (l = pkg_list; l != NULL; l = l->next) { + req = (struct required_by *)l->data; + ret = dependency_cb(req->pkgid, req->type, req->version, + user_data); if (ret < 0) break; } + + g_list_free_full(pkg_list, __free_required_by); + + return PMINFO_R_OK; +} + +int __compare_package_version(const char *version, int *major, + int *minor, int *macro, int *nano) +{ + char *version_temp = NULL; + char *major_str = NULL; + char *minor_str = NULL; + char *macro_str = NULL; + char *nano_str = NULL; + char *save_str = NULL; + + if (version == NULL || major == NULL || minor == NULL || + macro == NULL || nano == NULL) { + return PMINFO_R_EINVAL; + } + + version_temp = strdup(version); + if (version_temp == NULL) { + LOGE("Out of memory"); + return PMINFO_R_ERROR; + } + + major_str = strtok_r(version_temp, ".", &save_str); + if (major_str == NULL) { + _LOGE("major version is NULL"); + free(version_temp); + return PMINFO_R_ERROR; + } + + minor_str = strtok_r(NULL, ".", &save_str); + if (minor_str == NULL) { + _LOGE("minor version is NULL"); + free(version_temp); + return PMINFO_R_ERROR; + } + + *major = atoi(major_str); + *minor = atoi(minor_str); + *macro = 0; + *nano = 0; + macro_str = strtok_r(NULL, ".", &save_str); + if (macro_str == NULL) { + _LOGD("macro version is NULL"); + } else { + *macro = atoi(macro_str); + nano_str = strtok_r(NULL, ".", &save_str); + if (nano_str) { + *nano = atoi(nano_str); + _LOGD("nano version exists"); + } + } + _LOGD("version = [%s] -> major = [%d], minor = [%d]," \ + " macro = [%d], nano = [%d]", version, *major, + *minor, *macro, *nano); + + free(version_temp); + + return PMINFO_R_OK; +} + +API int pkgmgrinfo_compare_package_version(const char *current_version, + const char *target_version, + pkgmgrinfo_version_compare_type *res) +{ + int ret = 0; + int current_version_major = 0; + int current_version_minor = 0; + int current_version_macro = 0; + int current_version_nano = 0; + int target_version_major = 0; + int target_version_minor = 0; + int target_version_macro = 0; + int target_version_nano = 0; + + if (current_version == NULL || target_version == NULL || + res == NULL) { + _LOGE("Invalid parameter"); + return PMINFO_R_EINVAL; + } + + ret = __compare_package_version(target_version, + &target_version_major, &target_version_minor, + &target_version_macro, &target_version_nano); + if (ret < 0) { + _LOGE("Failed to compare target version(%d)", ret); + return PMINFO_R_ERROR; + } + + ret = __compare_package_version(current_version, + ¤t_version_major, ¤t_version_minor, + ¤t_version_macro, ¤t_version_nano); + if (ret < 0) { + _LOGE("Failed to compare current version(%d)", ret); + return PMINFO_R_ERROR; + } + + _LOGD("new[%d.%d.%d.%d] old[%d.%d.%d.%d]", target_version_major, + target_version_minor, target_version_macro, + target_version_nano, current_version_major, + current_version_minor, current_version_macro, + target_version_nano); + + if (target_version_major > current_version_major) + *res = PMINFO_VERSION_NEW; + else if (target_version_major < current_version_major) + *res = PMINFO_VERSION_OLD; + else if (target_version_minor > current_version_minor) + *res = PMINFO_VERSION_NEW; + else if (target_version_minor < current_version_minor) + *res = PMINFO_VERSION_OLD; + else if (target_version_macro > current_version_macro) + *res = PMINFO_VERSION_NEW; + else if (target_version_macro < current_version_macro) + *res = PMINFO_VERSION_OLD; + else if (target_version_nano > current_version_nano) + *res = PMINFO_VERSION_NEW; + else if (target_version_nano < current_version_nano) + *res = PMINFO_VERSION_OLD; + else + *res = PMINFO_VERSION_SAME; + return PMINFO_R_OK; }