#include "pkgmgr_parser.h"
#include "pkgmgrinfo_internal.h"
-static int __free_applications(gpointer key, gpointer value,
- gpointer user_data) {
- pkgmgrinfo_basic_free_application((application_x *)value);
- return 0;
-}
-
static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str,
char *visibility, char *id) {
char *dup;
API int appinfo_internal_filter_get_list(sqlite3 *db,
pkgmgrinfo_appinfo_filter_h filter,
uid_t uid, const char *locale,
- GHashTable **appinfo_list) {
+ GHashTable *appinfo_list) {
int ret;
- GHashTable *list;
if (db == NULL || filter == NULL || appinfo_list == NULL) {
// TODO: add log
return PMINFO_R_EINVAL;
}
- list = g_hash_table_new(g_str_hash, g_str_equal);
- if (list == NULL) return PMINFO_R_ERROR;
-
ret = _appinfo_get_applications(db, uid, uid, locale, filter,
- PMINFO_APPINFO_GET_ALL, list);
- if (!g_hash_table_size(list) && uid != GLOBAL_USER)
+ PMINFO_APPINFO_GET_ALL, appinfo_list);
+ if (!g_hash_table_size(appinfo_list) && uid != GLOBAL_USER)
ret = _appinfo_get_applications(db, GLOBAL_USER, uid, locale, filter,
- PMINFO_APPINFO_GET_ALL, list);
+ PMINFO_APPINFO_GET_ALL, appinfo_list);
- if (ret != PMINFO_R_OK) {
- g_hash_table_foreach_remove(list, __free_applications, NULL);
- g_hash_table_destroy(list);
+ if (ret != PMINFO_R_OK)
return ret;
- }
- if (!g_hash_table_size(list)) {
- // TODO: add logs that failed to find appid
- g_hash_table_destroy(list);
+ if (!g_hash_table_size(appinfo_list))
return PMINFO_R_ENOENT;
- }
- *appinfo_list = list;
return ret;
}
#include <vector>
+#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_internal.h"
#include "pkgmgrinfo_debug.h"
SetDBType(DB_TYPE_FILE_PKGDB);
if (!Connect()) return PMINFO_R_ERROR;
- GHashTable* list = nullptr;
+ GHashTable* list = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
std::vector<sqlite3*> conn_list = GetConnection();
int ret = PMINFO_R_OK;
for (auto conn : conn_list) {
ret = appinfo_internal_filter_get_list(conn, filter_, uid_,
- GetLocale().c_str(), &list);
+ GetLocale().c_str(), list);
if (ret == PMINFO_R_ERROR) {
_LOGE("Failed to appinfo_internal_filter_get_list (%d)", ret);
+ g_hash_table_destroy(list);
break;
}
}
// TODO: should we get sqlite handle as parameter??
int pkginfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_pkginfo_filter_h filter, uid_t uid, const char *locale, GHashTable **list);
-int appinfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_appinfo_filter_h filter, uid_t uid, const char *locale, GHashTable **list);
+int appinfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_appinfo_filter_h filter, uid_t uid, const char *locale, GHashTable *list);
int certinfo_internal_get(sqlite3 *db, const char *pkgid, uid_t uid, pkgmgrinfo_certinfo_h certinfo);
int certinfo_internal_set(sqlite3 *db, const char *pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid);
int certinfo_internal_delete(sqlite3 *db, const char *pkgid);