return ret;
}
- if (!g_hash_table_size(list)) {
+ if (!g_hash_table_size(list) || !g_hash_table_lookup(list, appid) ||
+ ((application_x *)g_hash_table_lookup(list, appid))->package == NULL) {
_LOGD("appinfo for [%s] is not existed for user [%d]",
appid, uid);
g_hash_table_destroy(list);
}
info->app_info = (application_x *)g_hash_table_lookup(list, appid);
- if (!info->app_info || !info->app_info->package) {
- _LOGD("appinfo for [%s] is not existed for user [%d]",
- appid, uid);
- g_hash_table_destroy(list);
- free(info);
- return PMINFO_R_ENOENT;
- }
info->locale = strdup(info->app_info->locale);
if (!info->locale) {
_LOGE("out of memory");
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;
}