#include <sys/types.h>
#include <dlfcn.h>
-#include <sqlite3.h>
#include <glib.h>
#include "pkgmgr-info.h"
appid, _getuid(), handle);
}
+static char *__get_real_appid(const char *appid)
+{
+ char *str;
+ char *saveptr;
+ char *token;
+
+ str = strdup(appid);
+ if (str == NULL)
+ return NULL;
+
+ token = strtok_r(str, "::", &saveptr);
+ if (token == NULL)
+ return str;
+
+ LOGD("Real appid = %s", token);
+ token = strdup(token);
+ free(str);
+ return token;
+}
+
API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
pkgmgrinfo_appinfo_h *handle)
{
int ret;
pkgmgrinfo_appinfo_filter_h filter;
+ char *real_appid;
if (appid == NULL || handle == NULL) {
LOGE("invalid parameter");
if (ret != PMINFO_R_OK)
return ret;
+ real_appid = __get_real_appid(appid);
+ if (real_appid == NULL) {
+ LOGE("Out of memory");
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
ret = pkgmgrinfo_appinfo_filter_add_string(filter,
- PMINFO_APPINFO_PROP_APP_ID, appid);
+ PMINFO_APPINFO_PROP_APP_ID, real_appid);
if (ret != PMINFO_R_OK) {
pkgmgrinfo_appinfo_filter_destroy(filter);
+ free(real_appid);
return PMINFO_R_ERROR;
}
PMINFO_APPINFO_PROP_APP_DISABLE, false);
if (ret != PMINFO_R_OK) {
pkgmgrinfo_appinfo_filter_destroy(filter);
+ free(real_appid);
return PMINFO_R_ERROR;
}
PMINFO_APPINFO_PROP_PKG_DISABLE, false);
if (ret != PMINFO_R_OK) {
pkgmgrinfo_appinfo_filter_destroy(filter);
+ free(real_appid);
return PMINFO_R_ERROR;
}
- ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
+ ret = _pkgmgrinfo_get_appinfo(real_appid, uid, filter, handle);
+ free(real_appid);
pkgmgrinfo_appinfo_filter_destroy(filter);
return ret;
}
return splashscreen;
}
+static gpointer __copy_res_control(gconstpointer src, gpointer data)
+{
+ res_control_x *tmp = (res_control_x *)src;
+ res_control_x *res_control;
+
+ res_control = (res_control_x *)calloc(1, sizeof(res_control_x));
+ if (res_control == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->res_type)
+ res_control->res_type = strdup(tmp->res_type);
+ if (tmp->min_res_version)
+ res_control->min_res_version = strdup(tmp->min_res_version);
+ if (tmp->max_res_version)
+ res_control->max_res_version = strdup(tmp->max_res_version);
+ if (tmp->auto_close)
+ res_control->auto_close = strdup(tmp->auto_close);
+
+ return res_control;
+}
+
static int _appinfo_copy_appinfo(
application_x **application, application_x *data)
{
return PMINFO_R_ERROR;
}
+ ret = 0;
+ app_info->res_control = g_list_copy_deep(data->res_control, __copy_res_control, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
*application = app_info;
return PMINFO_R_OK;
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_res_control_list_cb res_control_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(res_control_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret = -1;
+ res_control_x *res_control;
+ GList *tmp;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->res_control; tmp; tmp = tmp->next) {
+ res_control = (res_control_x *)tmp->data;
+ if (res_control == NULL)
+ continue;
+ ret = res_control_func(res_control->res_type,
+ res_control->min_res_version,
+ res_control->max_res_version,
+ res_control->auto_close,
+ user_data);
+ if (ret < 0)
+ break;
+ }
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_is_nodisplay(
pkgmgrinfo_appinfo_h handle, bool *nodisplay)
{
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_get_light_user_switch_mode(
+ pkgmgrinfo_appinfo_h handle, char **mode)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || mode == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->light_user_switch_mode == NULL)
+ return PMINFO_R_ERROR;
+
+ *mode = info->app_info->light_user_switch_mode;
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
{
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
*/
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
return PMINFO_R_OK;
*/
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
return PMINFO_R_OK;
node->value = strdup(value);
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
break;
case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
ptr = (pkgmgrinfo_node_x *)link->data;
strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
_LOGI("Previous value is %s\n", prev);
+ _pkgmgrinfo_node_destroy(ptr);
filter->list = g_slist_delete_link(filter->list, link);
ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
"%s,%s", prev, value);
node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
link = g_slist_find_custom(filter->list,
(gconstpointer)node, __compare_func);
- if (link)
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
filter->list = g_slist_delete_link(filter->list, link);
+ }
filter->list = g_slist_append(filter->list, (gpointer)node);
break;
}