From 7f9bb20879ffc546786435bc8e09e6018b760192 Mon Sep 17 00:00:00 2001 From: MyoungJune Park Date: Mon, 8 Apr 2013 18:00:48 +0900 Subject: [PATCH] fixed the wrong path of AppSettings --- src/CMakeLists.txt | 2 + src/setting-main.c | 152 +++++++++++++++++++++++++---------------------------- 2 files changed, 74 insertions(+), 80 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ff88c6..cc64ea4 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,8 @@ pkg_check_modules(pkgs_main REQUIRED capi-network-bluetooth capi-network-nfc dbus-glib-1 ewebkit2 + pkgmgr-info + pkgmgr ##setting-service ) diff --git a/src/setting-main.c b/src/setting-main.c index 8bb499d..0dc9869 100755 --- a/src/setting-main.c +++ b/src/setting-main.c @@ -24,6 +24,8 @@ #include #include +#include + #include #define PLUGIN_PREFIX "/opt" @@ -1089,7 +1091,6 @@ static void __load_applications_level_all_list(void *data) __load_applications_menu_list(ad, Cfg_Item_Pos_Level_All); } - bool is_3rdapp_installed_setting_cfg(char* pkgname) { SETTING_TRACE_BEGIN; @@ -1112,6 +1113,60 @@ bool is_3rdapp_installed_setting_cfg(char* pkgname) return result_opt; } +static int __pkg_list_cb (const pkgmgrinfo_pkginfo_h handle, void *data) +{ + SETTING_TRACE_BEGIN; + + DrawAppInfo* pinfo = (DrawAppInfo*)data; + + int ret = -1; + char *pkgid; + ret = pkgmgr_pkginfo_get_pkgid(handle, &pkgid); + if(ret < 0) { + SETTING_TRACE(">>>>> pkgmgr_pkginfo_get_pkgid() failed\n"); + } + + char *label; + ret = pkgmgr_pkginfo_get_label(handle, &label); + if(ret < 0) { + SETTING_TRACE(">>>>> pkgmgr_pkginfo_get_pkg_name() failed\n"); + } + SETTING_TRACE(" 3rd party - pkg id : ----> %s, pkg name ----> %s ", pkgid, label); + + // appid - 1234567890.AppSetting2 + // pkgid - 1234567890 + char *name = pkgid; + + if (is_3rdapp_installed_setting_cfg(pkgid) == true ) + { + pinfo->ncount++; + // draw code here + if (pinfo->draw_app != NULL) + { + SETTING_TRACE(">>> pkg name --> %s ", pkgid); + pinfo->draw_app(pinfo->data, strdup(label)/* appname*/, strdup(pkgid)/* pkg_name*/); + } + } + + SETTING_TRACE_END; + return 0; + +} + +static void get_3rdapp_installed_setting_list() +{ + SETTING_TRACE_BEGIN; + int val = 1; + + pkgmgrinfo_pkginfo_filter_h handle; + pkgmgrinfo_pkginfo_filter_create(&handle); + pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val); + + pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, NULL); +} + + + /** * @param data * ex) name : AppSetting4 @@ -1149,66 +1204,6 @@ static void draw_3rdapp(void* data, char* name, char* pkgname) } /** - * - * ail code here - */ -static ail_cb_ret_e __download_apps_cb(ail_appinfo_h ai, void* data) -{ - DrawAppInfo* pinfo = (DrawAppInfo*)data; - char *id; - - if (AIL_ERROR_OK == ail_appinfo_get_str(ai, AIL_PROP_PACKAGE_STR, &id)) - { - SETTING_TRACE(" 3rd party - app name : ----> %s ", id); - } - - ail_appinfo_h handle; - - char *name = NULL; - char *icon = NULL; - int installed_time; - bool nodisplay = false; - bool removable = true; - - if (AIL_ERROR_OK == ail_package_get_appinfo(id, &handle)) - { - if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &name)) - SETTING_TRACE("cannot get name"); - - if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon)) - SETTING_TRACE("cannot get icon"); - - if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &nodisplay)) - SETTING_TRACE("cannot get nodisplay"); - - if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_REMOVABLE_BOOL, &removable)) - SETTING_TRACE("cannot get removable"); - - if (AIL_ERROR_OK != ail_appinfo_get_int(handle, AIL_PROP_X_SLP_INSTALLEDTIME_INT, &installed_time)) - SETTING_TRACE("cannot get installed_time"); - - //SETTING_TRACE("installed_time = %d ", installed_time); - if (installed_time != 0 && is_3rdapp_installed_setting_cfg(id) == true ) - { - SETTING_TRACE(" 3rd party - app name : ----> id : %s --- name : %s ", id, name); - SETTING_TRACE(" 3rd party - icon : ----> %s ", icon); - SETTING_TRACE(" 3rd party - nodisplay : ----> %d ", nodisplay); - pinfo->ncount++; - - // draw code here - if (pinfo->draw_app != NULL) - { - SETTING_TRACE(">>> pkg name --> %s ", id); - pinfo->draw_app(pinfo->data, strdup(name)/* appname*/, strdup(id)/* pkg_name*/); - } - } - } - SETTING_TRACE_END; - return AIL_CB_RET_CONTINUE; -} - - -/** * get 3rd party applist from AIL & searching dir/file by the defined rule * @param data ad * if data is NULL --> just get how many items are there @@ -1220,39 +1215,36 @@ static int get_downloadapp_list(void* data) setting_main_appdata *ad = data; - int ncount = 0; - ail_filter_h f; + int val = 1; + pkgmgrinfo_pkginfo_filter_h handle; + pkgmgrinfo_pkginfo_filter_create(&handle); + pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, val); + + int ncount = 0; DrawAppInfo* pinfo = (DrawAppInfo*)malloc(sizeof(DrawAppInfo)); if (pinfo) { pinfo->ncount = 0; pinfo->draw_app = draw_3rdapp; pinfo->data = ad; + pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, __pkg_list_cb, pinfo); - if (ail_filter_new(&f) == AIL_ERROR_OK) - { - if (ail_filter_add_bool(f, AIL_PROP_NODISPLAY_BOOL, false) != AIL_ERROR_OK) - { - SETTING_TRACE("ail filter error"); - - free(pinfo); - pinfo = NULL; - - ail_filter_destroy(f); - return 0; - } - - ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo); - //--------------------------------------------------------------- - ail_filter_destroy(f); - } ncount = pinfo->ncount; free(pinfo); pinfo = NULL; } + if (handle) { + if (PMINFO_R_OK == pkgmgrinfo_pkginfo_filter_destroy(handle)) { + SETTING_TRACE("remove pkginfo successfully"); + } else { + SETTING_TRACE("failed removing pkginfo"); + } + handle = NULL; + } + SETTING_TRACE_END; return ncount; } -- 2.7.4