From b663679b1597714cef31ea649436dcc188304d65 Mon Sep 17 00:00:00 2001 From: Duyoung Jang Date: Mon, 18 Mar 2013 14:33:55 +0900 Subject: [PATCH] GetPackageAppInfoListN() API is added. Change-Id: Ida98c7f27a13c773927de527bac7f0821014260f Signed-off-by: Duyoung Jang --- src/app/inc/FAppPkg_PackageManagerImpl.h | 8 ++ src/app/package/FAppPkg_PackageManagerImpl.cpp | 126 +++++++++++++++++++++---- 2 files changed, 116 insertions(+), 18 deletions(-) diff --git a/src/app/inc/FAppPkg_PackageManagerImpl.h b/src/app/inc/FAppPkg_PackageManagerImpl.h index 4870977..3c59004 100755 --- a/src/app/inc/FAppPkg_PackageManagerImpl.h +++ b/src/app/inc/FAppPkg_PackageManagerImpl.h @@ -59,6 +59,12 @@ class IPackageUninstallationResponseListener; static const int MAX_DATABASE_RETRY_COUNT = 30; static const wchar_t PACKAGE_DATABASE_FILE_NAME[] = L"/opt/usr/dbspace/.app-package.db"; +// PackageFilter + +// PackageAppFilter +static const wchar_t PACKAGE_APP_FILTER_MENUICON_VISIBLE[] = L"http://tizen.org/package/app/menuiconvisible"; +static const wchar_t PACKAGE_APP_FILTER_CATEGORY[] = L"http://tizen.org/package/app/category"; + enum PackageStorageType { PACKAGE_STORAGE_TYPE_INTERNAL, @@ -129,6 +135,8 @@ public: Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageAppFilterMap) const; Tizen::Base::Collection::IList* GetPackageAppInfoListN(const Tizen::Base::Collection::IMap& packageFilterMap, const Tizen::Base::Collection::IMap& packageAppFilterMap) const; + static int PackageAppInfoHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData); + void SendPackageEvent(PackageType type, const PackageId& packageId, const char* eventKey, const char* eventValue); Tizen::Base::String* GetAppIdOfDataControlN(const Tizen::Base::String& providerId); diff --git a/src/app/package/FAppPkg_PackageManagerImpl.cpp b/src/app/package/FAppPkg_PackageManagerImpl.cpp index 7d5aaf7..b7eb50a 100755 --- a/src/app/package/FAppPkg_PackageManagerImpl.cpp +++ b/src/app/package/FAppPkg_PackageManagerImpl.cpp @@ -704,23 +704,6 @@ _PackageManagerImpl::UninstallationEventHandler(int reqId, const char* pType, co return 0; } -_PackageManagerImpl* -_PackageManagerImpl::GetInstance(void) -{ - return PackageManager::GetInstance()->__pPackageManagerImpl; -} - -result -_PackageManagerImpl::Construct(void) -{ - ClearLastResult(); - - result r = __installationList.Construct(); - SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "The memory is insufficient."); - - return E_SUCCESS; -} - PackageInfo* _PackageManagerImpl::GetPackageInfoFromFileN(const String& filePath) const { @@ -772,7 +755,71 @@ _PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageAppFilterMap) con { SysTryReturn(NID_APP, packageAppFilterMap.GetCount() > 0, null, E_INVALID_ARG, "packageAppFilterMap.GetCount() is invalid."); - return null; + std::unique_ptr pEnum(packageAppFilterMap.GetMapEnumeratorN()); + SysTryReturn(NID_APP, pEnum, null, E_INVALID_ARG, "GetMapEnumeratorN() is failed."); + + int res = 0; + ArrayList* pList = null; + pkgmgrinfo_appinfo_filter_h handle = null; + + res = pkgmgrinfo_appinfo_filter_create(&handle); + SysTryReturn(NID_APP, res == PMINFO_R_OK, null, E_SYSTEM, "pkgmgrinfo_appinfo_filter_create() is failed. [%d]", res); + + while(pEnum->MoveNext() == E_SUCCESS) + { + String* pKey = static_cast(pEnum->GetKey()); + SysTryCatch(NID_APP, pKey, , E_INVALID_ARG, "GetKey() is failed."); + + if ((*pKey) == PACKAGE_APP_FILTER_MENUICON_VISIBLE) + { + Boolean* pVal = static_cast(pEnum->GetValue()); + SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed."); + + bool nodisplay = !(pVal->ToBool()); + SysLog(NID_APP, "Key[%ls], Value[%d]", pKey->GetPointer(), nodisplay); + + res = pkgmgrinfo_appinfo_filter_add_bool(handle, PMINFO_APPINFO_PROP_APP_NODISPLAY, nodisplay); + SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(NODISPLAY, %d) is failed. [%d]", nodisplay, res); + } + else if ((*pKey) == PACKAGE_APP_FILTER_CATEGORY) + { + String* pVal = static_cast(pEnum->GetValue()); + SysTryCatch(NID_APP, pVal, , E_INVALID_ARG, "GetValue() is failed."); + + SysLog(NID_APP, "Key[%ls], Value[%ls]", pKey->GetPointer(), pVal->GetPointer()); + + std::unique_ptr pValue(_StringConverter::CopyToCharArrayN(*pVal)); + SysTryCatch(NID_APP, pValue, , E_OUT_OF_MEMORY, "pValue is null."); + + res = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, pValue.get()); + SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_appinfo_filter_add_string(CATEGORY, %s) is failed. [%d]", pValue.get(), res); + } + else + { + SysTryCatch(NID_APP, false, , E_INVALID_ARG, "Invalid key(%ls)", pKey->GetPointer()); + } + } + + pList = new (std::nothrow) ArrayList(); + SysTryCatch(NID_APP, pList, , E_OUT_OF_MEMORY, "ArrayList creation failure."); + pList->Construct(); + + res = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, PackageAppInfoHandler, pList); + if (res != 0) + { + SysLog(NID_APP, "pkgmgrinfo_appinfo_filter_foreach_appinfo() is failed. result = [%d]", res); + + pList->RemoveAll(true); + pList = null; + } + +CATCH: + if (handle) + { + pkgmgrinfo_appinfo_filter_destroy(handle); + } + + return pList; } IList* @@ -784,6 +831,49 @@ _PackageManagerImpl::GetPackageAppInfoListN(const IMap& packageFilterMap, const return null; } +int +_PackageManagerImpl::PackageAppInfoHandler(const pkgmgrinfo_appinfo_h handle, void* pUserData) +{ + SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "handle must not be null."); + SysTryReturn(NID_APP, pUserData, 0, E_SYSTEM, "pUserData must not be null."); + + result r = E_SUCCESS; + int res = PMINFO_R_OK; + char* pAppId = null; + ArrayList* pList = (ArrayList*)pUserData; + + res = pkgmgrinfo_appinfo_get_appid(handle, &pAppId); + SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_SYSTEM, "pkgmgrinfo_appinfo_get_appid is failed. [%d]", res); + + std::unique_ptr pPackageAppInfo(new (std::nothrow) PackageAppInfo); + SysTryReturn(NID_APP, pPackageAppInfo, 0, E_OUT_OF_MEMORY, "pPackageAppInfo instance must not be null."); + + _PackageAppInfoImpl* pPackageAppInfoImpl = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get()); + r = pPackageAppInfoImpl->Construct(pAppId); + SysTryReturn(NID_APP, r == E_SUCCESS, 0, E_SYSTEM, "Construct(%s) is failed.", pAppId); + + pList->Add(*pPackageAppInfo.release()); + + return 0; +} + +_PackageManagerImpl* +_PackageManagerImpl::GetInstance(void) +{ + return PackageManager::GetInstance()->__pPackageManagerImpl; +} + +result +_PackageManagerImpl::Construct(void) +{ + ClearLastResult(); + + result r = __installationList.Construct(); + SysTryReturnResult(NID_APP, r == E_SUCCESS, r, "The memory is insufficient."); + + return E_SUCCESS; +} + _PackageManagerImpl::_PackageManagerImpl(void) :__pRequestClient(null), __pListeningClient(null), -- 2.7.4