TSAM-10406 Obtaining application's label and icon path using app-manager api 71/101571/1
authorAndrey Klimenko <and.klimenko@samsung.com>
Thu, 1 Dec 2016 12:24:55 +0000 (14:24 +0200)
committerAndrey Klimenko <and.klimenko@samsung.com>
Thu, 1 Dec 2016 12:24:55 +0000 (14:24 +0200)
Change-Id: Ibc94abe5bbcf8553a50af06f1af510d8380a57b4
Signed-off-by: Andrey Klimenko <and.klimenko@samsung.com>
src/pkgmgr-setting-info.c

index 5b26b55642c17a3eb97580b7fdaaf63a69cdad0a..701979ef34cb3194d522a1f0f9d2a83a2477c164 100755 (executable)
 * limitations under the License.
 */
 
-
-#include <package_manager.h>
 #include <stdlib.h>
 
 #include "pkgmgr-setting-info.h"
+#include <app_info.h>
+#include <app_manager.h>
 
 int apps_sort_cb(const void *d1, const void *d2)
 {
@@ -34,38 +34,33 @@ int apps_sort_cb(const void *d1, const void *d2)
 HAPI char *get_app_icon(const char *appid)
 {
        char *icon_path = NULL;
-       char *package_id = NULL;
-       package_manager_get_package_id_by_app_id(appid, &package_id);
-       if (package_id) {
-
-               package_info_h package_info = NULL;
-               package_manager_get_package_info(package_id, &package_info);
-               if (!package_info)
-                       return NULL;
-
-               package_info_get_icon(package_info, &icon_path);
-               package_info_destroy(package_info);
+       app_info_h app_info;
+       int error_code = app_info_create(appid, &app_info);
+       if (error_code == APP_MANAGER_ERROR_NONE) {
+               error_code = app_info_get_icon(app_info, &icon_path);
+               if (error_code != APP_MANAGER_ERROR_NONE) {
+                       NOTISET_ERR("app_info_get_icon() failed with error-code %d", error_code);
+               }
+               app_info_destroy(app_info);
+       } else {
+               NOTISET_ERR("app_info_create() failed with error-code %d", error_code);
        }
-       free(package_id);
        return icon_path;
 }
 
-
 HAPI char *get_app_name(const char *appid)
 {
        char *name = NULL;
-       char *package_id = NULL;
-       package_manager_get_package_id_by_app_id(appid, &package_id);
-       if (package_id) {
-
-               package_info_h package_info = NULL;
-               package_manager_get_package_info(package_id, &package_info);
-               if (!package_info)
-                       return NULL;
-
-               package_info_get_label(package_info, &name);
-               package_info_destroy(package_info);
+       app_info_h app_info;
+       int error_code = app_info_create(appid, &app_info);
+       if (error_code == APP_MANAGER_ERROR_NONE) {
+               error_code = app_info_get_label(app_info, &name);
+               if (error_code != APP_MANAGER_ERROR_NONE) {
+                       NOTISET_ERR("app_info_get_label() failed with error-code %d", error_code);
+               }
+               app_info_destroy(app_info);
+       } else {
+               NOTISET_ERR("app_info_create() failed with error-code %d", error_code);
        }
-       free(package_id);
        return name;
 }