Add debugging log for disabled pkg/app for db
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_private.c
index 4696af7..e6d023d 100644 (file)
 #include <string.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <dlfcn.h>
 
 #include <vconf.h>
-#include <sqlite3.h>
 #include <glib.h>
+#include <unzip.h>
 
 #include "pkgmgr-info.h"
 #include "pkgmgrinfo_debug.h"
 #include "pkgmgrinfo_private.h"
 #include "pkgmgr_parser.h"
 
+static GHashTable *plugin_set_list;
+
 struct _pkginfo_str_map_t {
        pkgmgrinfo_pkginfo_filter_prop_str prop;
        const char *property;
@@ -48,7 +51,8 @@ static struct _pkginfo_str_map_t pkginfo_str_prop_map[] = {
        {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME,     PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME},
        {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL,    PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL},
        {E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF,     PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF},
-       {E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,       PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE}
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE,       PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE,        PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE}
 };
 
 struct _pkginfo_int_map_t {
@@ -73,7 +77,9 @@ static struct _pkginfo_bool_map_t pkginfo_bool_prop_map[] = {
        {E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING,      PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING},
        {E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING,       PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING},
        {E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE, PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE},
-       {E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE}
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, PMINFO_PKGINFO_PROP_PACKAGE_DISABLE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE,   PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE},
+       {E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM,          PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM}
 };
 
 struct _appinfo_str_map_t {
@@ -93,10 +99,9 @@ static struct _appinfo_str_map_t appinfo_str_prop_map[] = {
        {E_PMINFO_APPINFO_PROP_APP_CATEGORY,    PMINFO_APPINFO_PROP_APP_CATEGORY},
        {E_PMINFO_APPINFO_PROP_APP_HWACCELERATION,      PMINFO_APPINFO_PROP_APP_HWACCELERATION},
        {E_PMINFO_APPINFO_PROP_APP_SCREENREADER,        PMINFO_APPINFO_PROP_APP_SCREENREADER},
-       {E_PMINFO_APPINFO_PROP_APP_METADATA_KEY,        PMINFO_APPINFO_PROP_APP_METADATA_KEY},
-       {E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE,      PMINFO_APPINFO_PROP_APP_METADATA_VALUE},
        {E_PMINFO_APPINFO_PROP_APP_PACKAGE,     PMINFO_APPINFO_PROP_APP_PACKAGE},
-       {E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,   PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE}
+       {E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE,   PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE},
+       {E_PMINFO_APPINFO_PROP_PRIVILEGE,       PMINFO_APPINFO_PROP_PRIVILEGE}
 };
 
 struct _appinfo_int_map_t {
@@ -105,7 +110,7 @@ struct _appinfo_int_map_t {
 };
 
 static struct _appinfo_int_map_t appinfo_int_prop_map[] = {
-       {E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER,    PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER}
+       {E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE,        PMINFO_APPINFO_PROP_APP_SUPPORT_MODE}
 };
 
 struct _appinfo_bool_map_t {
@@ -122,10 +127,12 @@ static struct _appinfo_bool_map_t appinfo_bool_prop_map[] = {
        {E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION,             PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION},
        {E_PMINFO_APPINFO_PROP_APP_UI_GADGET,           PMINFO_APPINFO_PROP_APP_UI_GADGET},
        {E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE,             PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE},
-       {E_PMINFO_APPINFO_PROP_APP_DISABLE,             PMINFO_APPINFO_PROP_APP_DISABLE}
+       {E_PMINFO_APPINFO_PROP_APP_DISABLE,             PMINFO_APPINFO_PROP_APP_DISABLE},
+       {E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE,               PMINFO_APPINFO_PROP_APP_CHECK_STORAGE},
+       {E_PMINFO_APPINFO_PROP_PKG_DISABLE,             PMINFO_APPINFO_PROP_PKG_DISABLE}
 };
 
-inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
+API pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property)
 {
        int i = 0;
        int max = 0;
@@ -143,7 +150,7 @@ inline pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(co
        return prop;
 }
 
-inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
+API pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(const char *property)
 {
        int i = 0;
        int max = 0;
@@ -161,7 +168,7 @@ inline pkgmgrinfo_pkginfo_filter_prop_int _pminfo_pkginfo_convert_to_prop_int(co
        return prop;
 }
 
-inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
+API pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(const char *property)
 {
        int i = 0;
        int max = 0;
@@ -179,7 +186,7 @@ inline pkgmgrinfo_pkginfo_filter_prop_bool _pminfo_pkginfo_convert_to_prop_bool(
        return prop;
 }
 
-inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
+API pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(const char *property)
 {
        int i = 0;
        int max = 0;
@@ -197,7 +204,7 @@ inline pkgmgrinfo_appinfo_filter_prop_str _pminfo_appinfo_convert_to_prop_str(co
        return prop;
 }
 
-inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
+API pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property)
 {
        int i = 0;
        int max = 0;
@@ -215,7 +222,7 @@ inline pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(co
        return prop;
 }
 
-inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
+API pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property)
 {
        int i = 0;
        int max = 0;
@@ -233,11 +240,22 @@ inline pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(
        return prop;
 }
 
-int __get_filter_condition(gpointer data, char **condition, GList **params)
+void _pkgmgrinfo_node_destroy(pkgmgrinfo_node_x *node)
 {
-       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
+       if (node == NULL)
+               return;
+
+       free(node->value);
+       free(node->key);
+       free(node);
+}
+
+API int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **params)
+{
+       pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data;
        char buf[MAX_QUERY_LEN] = {'\0'};
        int flag = 0;
+       char *value;
        char *ptr = NULL;
        char *saveptr = NULL;
 
@@ -295,9 +313,23 @@ int __get_filter_condition(gpointer data, char **condition, GList **params)
                snprintf(buf, sizeof(buf), "pi.package_support_disable=? COLLATE NOCASE");
                break;
        case E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE:
-               snprintf(buf, sizeof(buf), "pi.package_disable=? COLLATE NOCASE");
-               break;
-
+               return 0;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM:
+               snprintf(buf, sizeof(buf), "pi.package_system=? COLLATE NOCASE");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE:
+               if (node->value == NULL || strlen(node->value) == 0) {
+                       *condition = strdup("package_res_info.res_type IS NOT NULL COLLATE NOCASE");
+                       if (*condition == NULL) {
+                               _LOGE("out of memeory");
+                               return 0;
+                       }
+                       return E_PMINFO_PKGINFO_JOIN_RES_INFO;
+               } else {
+                       snprintf(buf, sizeof(buf), "package_res_info.res_type=? COLLATE NOCASE");
+                       flag = E_PMINFO_PKGINFO_JOIN_RES_INFO;
+                       break;
+               }
        case E_PMINFO_APPINFO_PROP_APP_ID:
                snprintf(buf, sizeof(buf), "ai.app_id=?");
                break;
@@ -328,18 +360,26 @@ int __get_filter_condition(gpointer data, char **condition, GList **params)
                break;
        case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
                snprintf(buf, sizeof(buf), "package_app_app_category.category IN (");
-               ptr = strtok_r(node->value, ",", &saveptr);
-               if (ptr == NULL)
+               value = strdup(node->value);
+               if (value == NULL) {
+                       _LOGE("out of memeory");
                        return 0;
-               strncat(buf, "?", MAX_QUERY_LEN - 2);
+               }
+               ptr = strtok_r(value, ",", &saveptr);
+               if (ptr == NULL) {
+                       free(value);
+                       return 0;
+               }
+               strncat(buf, "?", sizeof(buf) - strlen(buf) - 1);
                *params = g_list_append(*params, strdup(ptr));
                while ((ptr = strtok_r(NULL, ",", &saveptr))) {
-                       strncat(buf, ", ?", MAX_QUERY_LEN - strlen(", ?") - 1);
+                       strncat(buf, ", ?", sizeof(buf) - strlen(buf) - 1);
                        *params = g_list_append(*params, strdup(ptr));
                }
-               strncat(buf, ")", MAX_QUERY_LEN - 2);
+               strncat(buf, ")", sizeof(buf) - strlen(buf) - 1);
                *condition = strdup(buf);
                flag = E_PMINFO_APPINFO_JOIN_CATEGORY;
+               free(value);
 
                return flag;
        case E_PMINFO_APPINFO_PROP_APP_NODISPLAY:
@@ -370,29 +410,30 @@ int __get_filter_condition(gpointer data, char **condition, GList **params)
                snprintf(buf, sizeof(buf), "ai.package=?");
                break;
        case E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE:
-               snprintf(buf, sizeof(buf), "ai.installed_storage=?");
+               snprintf(buf, sizeof(buf), "ai.app_installed_storage=?");
                break;
        case E_PMINFO_APPINFO_PROP_APP_UI_GADGET:
                snprintf(buf, sizeof(buf), "ai.app_ui_gadget=? COLLATE NOCASE");
                break;
-       case E_PMINFO_APPINFO_PROP_APP_METADATA_KEY:
-               snprintf(buf, sizeof(buf), "package_app_app_metadata.md_key=?");
-               flag = E_PMINFO_APPINFO_JOIN_METADATA;
-               break;
-       case E_PMINFO_APPINFO_PROP_APP_METADATA_VALUE:
-               snprintf(buf, sizeof(buf), "package_app_app_metadata.md_value=?");
-               flag = E_PMINFO_APPINFO_JOIN_METADATA;
-               break;
        case E_PMINFO_APPINFO_PROP_APP_DISABLE:
-               snprintf(buf, MAX_QUERY_LEN, "ai.app_disable=? COLLATE NOCASE");
+               return 0;
                break;
        case E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE:
                snprintf(buf, MAX_QUERY_LEN, "ai.app_support_disable=? COLLATE NOCASE");
                break;
-       case E_PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER:
-               snprintf(buf, MAX_QUERY_LEN, "ai.app_id NOT IN "
-                               "(SELECT app_id from package_app_info_for_uid WHERE uid=? " \
-                               "AND is_disabled='true' COLLATE NOCASE)");
+       case E_PMINFO_APPINFO_PROP_PKG_DISABLE:
+               return 0;
+               break;
+       case E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE:
+               snprintf(buf, sizeof(buf), "ai.app_support_mode=?");
+               break;
+       case E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE:
+       case E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE:
+               *condition = NULL;
+               return 0;
+       case E_PMINFO_APPINFO_PROP_PRIVILEGE:
+               snprintf(buf, sizeof(buf), "package_privilege_info.privilege=?");
+               flag = E_PMINFO_APPINFO_JOIN_PRIVILEGE;
                break;
        default:
                _LOGE("Invalid Property Type\n");
@@ -404,7 +445,47 @@ int __get_filter_condition(gpointer data, char **condition, GList **params)
        return flag;
 }
 
-int _add_icon_info_into_list(const char *locale, char *value, GList **icon)
+API int __get_pkg_metadata_filter_condition(gpointer data, char **condition,
+               GList **params)
+{
+       pkgmgrinfo_metadata_node_x *node = (pkgmgrinfo_metadata_node_x *)data;
+       char buf[MAX_QUERY_LEN];
+
+       snprintf(buf, sizeof(buf), "(package_metadata.md_key=?");
+       if (node->value)
+               strncat(buf, " AND package_metadata.md_value=?",
+                               sizeof(buf) - strlen(buf) - 1);
+       strncat(buf, ")", sizeof(buf) - strlen(buf) - 1);
+
+       *condition = strdup(buf);
+       *params = g_list_append(*params, strdup(node->key));
+       if (node->value)
+               *params = g_list_append(*params, strdup(node->value));
+
+       return E_PMINFO_PKGINFO_JOIN_METADATA;
+}
+
+API int __get_metadata_filter_condition(gpointer data, char **condition,
+               GList **params)
+{
+       pkgmgrinfo_metadata_node_x *node = (pkgmgrinfo_metadata_node_x *)data;
+       char buf[MAX_QUERY_LEN];
+
+       snprintf(buf, sizeof(buf), "(package_app_app_metadata.md_key=?");
+       if (node->value)
+               strncat(buf, " AND package_app_app_metadata.md_value=?",
+                               sizeof(buf) - strlen(buf) - 1);
+       strncat(buf, ")", sizeof(buf) - strlen(buf) - 1);
+
+       *condition = strdup(buf);
+       *params = g_list_append(*params, strdup(node->key));
+       if (node->value)
+               *params = g_list_append(*params, strdup(node->value));
+
+       return E_PMINFO_APPINFO_JOIN_METADATA;
+}
+
+API int _add_icon_info_into_list(const char *locale, char *value, GList **icon)
 {
        icon_x *info;
 
@@ -415,12 +496,12 @@ int _add_icon_info_into_list(const char *locale, char *value, GList **icon)
        }
        info->text = value;
        info->lang = strdup(locale);
-       *icon = g_list_append(*icon, info);
+       *icon = g_list_prepend(*icon, info);
 
        return PMINFO_R_OK;
 }
 
-int _add_label_info_into_list(const char *locale, char *value, GList **label)
+API int _add_label_info_into_list(const char *locale, char *value, GList **label)
 {
        label_x *info;
 
@@ -431,45 +512,12 @@ int _add_label_info_into_list(const char *locale, char *value, GList **label)
        }
        info->text = value;
        info->lang = strdup(locale);
-       *label = g_list_append(*label, info);
+       *label = g_list_prepend(*label, info);
 
        return PMINFO_R_OK;
 }
 
-char *_get_system_locale(void)
-{
-       char *lang;
-       char *locale;
-
-       lang = vconf_get_str(VCONFKEY_LANGSET);
-       if (lang == NULL) {
-               locale = strdup(DEFAULT_LOCALE);
-               if (locale == NULL) {
-                       LOGE("out of memory");
-                       return NULL;
-               }
-               return locale;
-       }
-
-       locale = malloc(sizeof(char) * 6);
-       if (locale == NULL) {
-               LOGE("out of memory");
-               free(lang);
-               return NULL;
-       }
-
-       strncpy(locale, lang, 2);
-       locale[2] = '-';
-       locale[3] = tolower(lang[3]);
-       locale[4] = tolower(lang[4]);
-       locale[5] = '\0';
-
-       free(lang);
-
-       return locale;
-}
-
-int __pkginfo_check_installed_storage(package_x *pkginfo)
+API int __pkginfo_check_installed_storage(package_x *pkginfo)
 {
        char buf[MAX_QUERY_LEN] = {'\0'};
        int ret;
@@ -480,7 +528,7 @@ int __pkginfo_check_installed_storage(package_x *pkginfo)
 
        if (strcmp(pkginfo->installed_storage, "installed_external") == 0) {
                snprintf(buf, MAX_QUERY_LEN - 1, "%s", pkginfo->external_path);
-               ret = access(buf, F_OK);
+               ret = access(buf, R_OK);
                if (ret != 0) {
                        _LOGE("can not access [%s] - %d", buf, ret);
                        return PMINFO_R_ERROR;
@@ -490,7 +538,7 @@ int __pkginfo_check_installed_storage(package_x *pkginfo)
        return PMINFO_R_OK;
 }
 
-int __appinfo_check_installed_storage(application_x *appinfo)
+API int __appinfo_check_installed_storage(application_x *appinfo)
 {
        retvm_if(appinfo->installed_storage == NULL, PMINFO_R_ERROR,
                        "installed_storage is NULL\n");
@@ -507,3 +555,143 @@ int __appinfo_check_installed_storage(application_x *appinfo)
        return PMINFO_R_OK;
 }
 
+struct type_map {
+       const char *manifest;
+       const char *type;
+};
+
+const struct type_map type_map[] = {
+       { "res/wgt/config.xml", "wgt" },
+       { "config.xml", "wgt" },
+       { "tizen-manifest.xml", "tpk" },
+       { NULL, NULL}
+};
+
+API char *__get_type_from_path(const char *pkg_path)
+{
+       const char *type = NULL;
+       unzFile uf;
+       int i;
+
+       uf = unzOpen(pkg_path);
+       if (uf == NULL) {
+               _LOGE("failed to open zip file %s", pkg_path);
+               return NULL;
+       }
+
+       for (i = 0; type_map[i].manifest != NULL; i++) {
+               if (unzLocateFile(uf, type_map[i].manifest, 0) == UNZ_OK) {
+                       _LOGD("pkgtype of %s: [%s]", pkg_path,
+                                       type_map[i].type);
+                       type = type_map[i].type;
+                       break;
+               }
+       }
+       unzClose(uf);
+
+       if (type == NULL) {
+               _LOGE("cannot get pkg type of file %s", pkg_path);
+               return NULL;
+       }
+
+       return strdup(type);
+}
+
+static void __get_library_path(const char *pkg_type, const char **path)
+{
+       char buf[64];
+
+       snprintf(buf, sizeof(buf), "package-manager/backendlib/lib%s.so",
+                       pkg_type);
+
+       *path = tzplatform_mkpath(TZ_SYS_RO_ETC, buf);
+}
+
+API pkg_plugin_set *__load_library(const char *pkg_type)
+{
+       void *library_handle;
+       pkg_plugin_set *plugin_set;
+       bool (*on_load)(pkg_plugin_set *plugin);
+       const char *library_path;
+
+       __get_library_path(pkg_type, &library_path);
+       if (library_path == NULL) {
+               _LOGE("cannot get library path for %s", pkg_type);
+               return NULL;
+       }
+
+       if (plugin_set_list == NULL) {
+               plugin_set_list = g_hash_table_new_full(g_str_hash,
+                               g_str_equal, free, free);
+               if (plugin_set_list == NULL) {
+                       _LOGE("out of memory");
+                       return NULL;
+               }
+       }
+
+       plugin_set = (pkg_plugin_set *)g_hash_table_lookup(plugin_set_list,
+                       (gconstpointer)pkg_type);
+       if (plugin_set) {
+               _LOGD("already loaded [%s]", library_path);
+               return plugin_set;
+       }
+
+       library_handle = dlopen(library_path, RTLD_LAZY);
+       if (library_handle == NULL) {
+               _LOGE("dlopen is failed library_path[%s]", library_path);
+               return NULL;
+       }
+
+       on_load = dlsym(library_handle, "pkg_plugin_on_load");
+       if (on_load == NULL || dlerror() != NULL) {
+               _LOGE("cannot find symbol");
+               dlclose(library_handle);
+               return NULL;
+       }
+
+       plugin_set = (pkg_plugin_set *)calloc(1, sizeof(pkg_plugin_set));
+       if (plugin_set == NULL) {
+               _LOGE("out of memory");
+               dlclose(library_handle);
+               return NULL;
+       }
+
+       if (on_load(plugin_set) != 0) {
+               _LOGE("pkg_plugin_on_load failed");
+               free(plugin_set);
+               dlclose(library_handle);
+               plugin_set = NULL;
+               return NULL;
+       }
+
+       plugin_set->plugin_handle = library_handle;
+       snprintf(plugin_set->pkg_type,
+                       sizeof(plugin_set->pkg_type), "%s", pkg_type);
+
+       g_hash_table_insert(plugin_set_list, (gpointer)strdup(pkg_type),
+                       (gpointer)plugin_set);
+
+       _LOGD("library [%s] is loaded", library_path);
+
+       return plugin_set;
+}
+
+API void __unload_library(const char *pkg_type)
+{
+       pkg_plugin_set *plugin_set;
+
+       if (plugin_set_list == NULL)
+               return;
+
+       plugin_set = (pkg_plugin_set *)g_hash_table_lookup(plugin_set_list,
+                       (gconstpointer)pkg_type);
+
+       if (plugin_set == NULL) {
+               _LOGE("pkg plugin for %s is not loaded", pkg_type);
+               return;
+       }
+
+       plugin_set->plugin_on_unload();
+       dlclose(plugin_set->plugin_handle);
+       g_hash_table_remove(plugin_set_list, (gconstpointer)pkg_type);
+}