g_hash_table_remove(user_tbl, GINT_TO_POINTER(uid));
}
-static struct user_appinfo *__add_user_appinfo(uid_t uid)
+static struct user_appinfo *__create_user_appinfo(uid_t uid)
{
- int r;
struct user_appinfo *info;
- pkgmgrinfo_appinfo_get_option option;
info = calloc(1, sizeof(struct user_appinfo));
- if (info == NULL) {
- _E("out of memory");
+ if (!info) {
+ _E("Out of memory");
return NULL;
}
- info->uid = uid;
- info->tbl = g_hash_table_new_full(g_str_hash, g_str_equal, free,
- __appinfo_remove_handler);
- if (info->tbl == NULL) {
- _E("out of memory");
+ info->tbl = g_hash_table_new_full(g_str_hash, g_str_equal,
+ free, __appinfo_remove_handler);
+ if (!info->tbl) {
+ _E("g_hash_table_new_full() is failed");
free(info);
return NULL;
}
+ info->uid = uid;
+
+ return info;
+}
+
+static struct user_appinfo *__add_user_appinfo(uid_t uid)
+{
+ int r;
+ struct user_appinfo *info;
+ pkgmgrinfo_appinfo_get_option option;
+
+ info = __create_user_appinfo(uid);
+ if (!info)
+ return NULL;
+
g_hash_table_insert(user_tbl, GINT_TO_POINTER(uid), info);
info->initializing = true;
pkgmgr_client_free(pc);
}
-static void __reload_appinfo(gpointer key, gpointer value, gpointer user_data)
+static int __dispatch_amd_reload_appinfo(request_h req)
{
- int r;
- struct user_appinfo *info = (struct user_appinfo *)value;
+ uid_t uid = _request_get_target_uid(req);
pkgmgrinfo_appinfo_get_option option;
+ struct user_appinfo *info;
+ int ret;
- g_hash_table_remove_all(info->tbl);
+ _E("[AMD_RELOAD_APPINFO] uid(%u)", uid);
+ info = __find_user_appinfo(uid);
+ if (info) {
+ g_hash_table_remove_all(info->tbl);
+ } else {
+ info = __create_user_appinfo(uid);
+ if (!info) {
+ _request_send_result(req, -1);
+ return -1;
+ }
+
+ g_hash_table_insert(user_tbl, GUINT_TO_POINTER(uid), info);
+ }
option = PMINFO_APPINFO_GET_CATEGORY |
PMINFO_APPINFO_GET_APP_CONTROL |
PMINFO_APPINFO_GET_SPLASH_SCREEN |
PMINFO_APPINFO_GET_RES_CONTROL |
PMINFO_APPINFO_GET_METADATA;
- r = pkgmgrinfo_appinfo_get_usr_installed_list_full(
- __appinfo_insert_handler, info->uid, option, info);
- if (r != PMINFO_R_OK) {
- __remove_user_appinfo(info->uid);
- return;
+ ret = pkgmgrinfo_appinfo_get_usr_installed_list_full(
+ __appinfo_insert_handler, uid, option, info);
+ if (ret != PMINFO_R_OK) {
+ _E("Failed to get installed list. uid(%u), error(%d)",
+ uid, ret);
+ __remove_user_appinfo(uid);
+ } else {
+ _noti_send(AMD_NOTI_MSG_APPINFO_RELOAD, (int)uid, 0, NULL,
+ NULL);
}
- _noti_send(AMD_NOTI_MSG_APPINFO_RELOAD, (int)info->uid, 0, NULL, NULL);
- _D("reloaded appinfo table for uid %d", info->uid);
-}
-
-static int __dispatch_amd_reload_appinfo(request_h req)
-{
- _D("AMD_RELOAD_APPINFO");
- g_hash_table_foreach(user_tbl, __reload_appinfo, NULL);
- _request_send_result(req, 0);
-
- return 0;
+ _request_send_result(req, ret);
+ _E("[AMD_RELOAD_APPINFO] result(%d)", ret);
+ return ret;
}
static request_cmd_dispatch __dispatch_table[] = {