/**
* @fn int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
- * @brief This API creates the package information handle from db
+ * @brief This API creates the package information handle from db which is not disabled
*
* @par This API is for package-manager client application
* @par Sync (or) Async : Synchronous API
int pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle);
/**
+ * @fn int pkgmgrinfo_pkginfo_get_all_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
+ * @brief This API creates the package information handle from db regardless of its disable status
+ *
+ * @par This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] pkgid pointer to package ID
+ * @param[in] uid the addressee user id of the instruction
+ * @param[out] handle pointer to the package info handle.
+ * @return 0 if success, error code(<0) if fail
+ * @retval PMINFO_R_OK success
+ * @retval PMINFO_R_EINVAL invalid argument
+ * @retval PMINFO_R_ERROR internal error
+ * @pre None
+ * @post pkgmgrinfo_pkginfo_destroy_pkginfo()
+ * @see pkgmgrinfo_pkginfo_get_pkgid()
+ * @see pkgmgrinfo_pkginfo_is_removable()
+ * @code
+static int get_pkg_type(const char *pkgid)
+{
+ int ret = 0;
+ char *type = NULL;
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_all_pkginfo(pkgid, &handle);
+ if (ret != PMINFO_R_OK)
+ return -1;
+ ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return -1;
+ }
+ printf("pkgtype: %s\n", type);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_get_all_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle);
+int pkgmgrinfo_pkginfo_get_usr_all_pkginfo(const char *pkgid, uid_t uid, pkgmgrinfo_pkginfo_h *handle);
+
+/**
* @fn int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
* @brief This API gets the package name from the package ID
*
}
}
- /* add package_disable='false' clause by default */
- if (__check_disable_filter_exist(tmp_filter) == false)
- pkgmgrinfo_pkginfo_filter_add_bool(tmp_filter,
- PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
-
-
query_len = strlen(query_raw);
snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
if (flag & PMINFO_PKGINFO_GET_AUTHOR) {
char *locale;
package_x *pkg;
pkgmgr_pkginfo_x info;
+ pkgmgrinfo_filter_x *tmp_filter = NULL;
GHashTable *list;
GHashTableIter iter;
gpointer value;
return PMINFO_R_ERROR;
}
+ 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");
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ if (__check_disable_filter_exist(tmp_filter) == false)
+ pkgmgrinfo_pkginfo_filter_add_bool(tmp_filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
+
ret = _pkginfo_get_packages(uid, locale, filter, flag, list);
if (ret == PMINFO_R_OK && uid != GLOBAL_USER)
ret = _pkginfo_get_packages(GLOBAL_USER, locale, filter,
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;
}
g_hash_table_destroy(list);
free(locale);
+ if (filter == NULL)
+ pkgmgrinfo_pkginfo_filter_destroy(tmp_filter);
+
return PMINFO_R_OK;
}
-API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid,
- pkgmgrinfo_pkginfo_h *handle)
+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;
- pkgmgrinfo_pkginfo_filter_h filter;
pkgmgr_pkginfo_x *info;
- if (pkgid == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
+ 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;
- ret = pkgmgrinfo_pkginfo_filter_create(&filter);
- if (ret != PMINFO_R_OK) {
- free(locale);
- 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);
- free(locale);
- return PMINFO_R_ERROR;
- }
-
list = g_hash_table_new(g_str_hash, g_str_equal);
if (list == NULL) {
pkgmgrinfo_pkginfo_filter_destroy(filter);
ret = _pkginfo_get_packages(GLOBAL_USER, locale, filter,
PMINFO_PKGINFO_GET_ALL, list);
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- if (ret != PMINFO_R_OK) {
- g_hash_table_destroy(list);
- free(locale);
- return ret;
- }
-
if (!g_hash_table_size(list)) {
_LOGI("pkginfo for [%s] is not existed for user [%d]",
pkgid, uid);
*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,
return ret;
}
+API int pkgmgrinfo_pkginfo_get_usr_all_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_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)
{
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)
{
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);
+ return PMINFO_R_ERROR;
+ }
+ }
+
ret = _pkginfo_get_packages(uid, locale,
(pkgmgrinfo_filter_x *)handle, 0, list);
if (ret == PMINFO_R_OK && uid != GLOBAL_USER)