From 9bb46afaa58d8eb99e4f35a271adce895bc4b1c5 Mon Sep 17 00:00:00 2001 From: Duyoung Jang Date: Wed, 10 Apr 2013 20:40:41 +0900 Subject: [PATCH] Fix GetAppMetadataListN() API Change-Id: I535037756f3bf26a69693f253f97a4d93db8daaa Signed-off-by: Duyoung Jang --- src/app/package/FAppPkg_PackageAppInfoImpl.cpp | 45 +++++++++----------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/app/package/FAppPkg_PackageAppInfoImpl.cpp b/src/app/package/FAppPkg_PackageAppInfoImpl.cpp index ac447b9..c9d2903 100755 --- a/src/app/package/FAppPkg_PackageAppInfoImpl.cpp +++ b/src/app/package/FAppPkg_PackageAppInfoImpl.cpp @@ -167,74 +167,61 @@ _PackageAppInfoImpl::GetAppMenuIconN(void) const HashMap* _PackageAppInfoImpl::GetAppMetadataListN(void) const { - HashMap* pMap = null; - if (__fromDatabase) { SysTryReturn(NID_APP, __pAppInfoHandle, null, E_SYSTEM, "__pAppInfoHandle is null."); - result r = E_SUCCESS; int res = PMINFO_R_OK; - pMap = new (std::nothrow) HashMap(); + std::unique_ptr< HashMap > pMap(new (std::nothrow) HashMap()); SysTryReturn(NID_APP, pMap, null, E_OUT_OF_MEMORY, "ArrayList creation failure."); pMap->Construct(); - res = pkgmgrinfo_appinfo_foreach_metadata(__pAppInfoHandle, MetadataHandler, pMap); - if (res != PMINFO_R_OK) - { - SysLog(NID_APP, "pkgmgrinfo_appinfo_foreach_metadata() is failed. result = [%d]", res); - r = E_SYSTEM; + res = pkgmgrinfo_appinfo_foreach_metadata(__pAppInfoHandle, MetadataHandler, pMap.get()); + SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_foreach_metadata() failed. [%d]", res); - pMap->RemoveAll(true); - pMap = null; + if (pMap->GetCount() <= 0) + { + return null; } - SetLastResult(r); + return pMap.release(); } else { SysLog(NID_APP, "GetAppMetadataListN() is not available."); + return null; } - - return pMap; } ArrayList* _PackageAppInfoImpl::GetAppCategoryListN(void) const { - ArrayList* pList = null; - if (__fromDatabase) { SysTryReturn(NID_APP, __pAppInfoHandle, null, E_SYSTEM, "[E_SYSTEM] __pAppInfoHandle is null."); - result r = E_SUCCESS; int res = PMINFO_R_OK; - pList = new (std::nothrow) ArrayList(); + std::unique_ptr< ArrayList > pList(new (std::nothrow) ArrayList()); SysTryReturn(NID_APP, pList, null, E_OUT_OF_MEMORY, "ArrayList creation failure."); pList->Construct(); - res = pkgmgrinfo_appinfo_foreach_category(__pAppInfoHandle, CategoryHandler, pList); - if (res != PMINFO_R_OK) - { - SysLog(NID_APP, "pkgmgrinfo_appinfo_foreach_category() is failed. result = [%d]", res); - r = E_SYSTEM; + res = pkgmgrinfo_appinfo_foreach_category(__pAppInfoHandle, CategoryHandler, pList.get()); + SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_foreach_category() failed. [%d]", res); - pList->RemoveAll(true); - pList = null; + if (pList->GetCount() <= 0) + { + return null; } - SetLastResult(r); - + return pList.release(); } else { SysLog(NID_APP, "GetAppCategoryListN() is not available."); + return null; } - - return pList; } bool -- 2.7.4