From 7d762bc06db3c8f667a25f8d76c06dc890697e03 Mon Sep 17 00:00:00 2001 From: Duyoung Jang Date: Mon, 13 May 2013 15:58:22 +0900 Subject: [PATCH] Modify GetType() API Change-Id: I3b389c47b09de268f07ecae4c8d029a4d1092a30 Signed-off-by: Duyoung Jang --- src/app/FApp_PackageManagerProxy.cpp | 32 ----------- src/app/inc/FApp_PackageManagerProxy.h | 2 - src/app/package/FAppPkg_PackageInfoImpl.cpp | 15 +++++- .../app/package/FAppPkg_PackageManagerServer.cpp | 62 ++-------------------- src/server/inc/FAppPkg_PackageManagerServer.h | 2 - 5 files changed, 18 insertions(+), 95 deletions(-) diff --git a/src/app/FApp_PackageManagerProxy.cpp b/src/app/FApp_PackageManagerProxy.cpp index 37334e1..4260ebf 100644 --- a/src/app/FApp_PackageManagerProxy.cpp +++ b/src/app/FApp_PackageManagerProxy.cpp @@ -107,38 +107,6 @@ _PackageManagerProxy::GetPackageInfoFromFileN(const String& filePath, PackageInf return response; } -long long -_PackageManagerProxy::GetSize(const PackageId& packageId) -{ - SysTryReturn(NID_APP, __pIpcClient != null, 0, E_INVALID_STATE, "__pIpcClient instance must not be null."); - - SysLog(NID_APP, "packageId = [%ls]", packageId.GetPointer()); - - long long size = 0; - std::auto_ptr pMsg (new (std::nothrow) PackageManager_GetSize(packageId, &size)); - - result r = __pIpcClient->SendRequest(*pMsg.get()); - SysTryReturn(NID_APP, !IsFailed(r), 0, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r)); - - return size; -} - -long long -_PackageManagerProxy::GetDataSize(const PackageId& packageId) -{ - SysTryReturn(NID_APP, __pIpcClient != null, 0, E_INVALID_STATE, "__pIpcClient instance must not be null."); - - SysLog(NID_APP, "packageId = [%ls]", packageId.GetPointer()); - - long long dataSize = 0; - std::auto_ptr pMsg (new (std::nothrow) PackageManager_GetDataSize(packageId, &dataSize)); - - result r = __pIpcClient->SendRequest(*pMsg.get()); - SysTryReturn(NID_APP, !IsFailed(r), 0, r, "__pIpcClient->SendRequest is failed. (%s)", GetErrorMessage(r)); - - return dataSize; -} - PackageType _PackageManagerProxy::GetType(const PackageId& packageId) { diff --git a/src/app/inc/FApp_PackageManagerProxy.h b/src/app/inc/FApp_PackageManagerProxy.h index b1bafb2..c6fea65 100644 --- a/src/app/inc/FApp_PackageManagerProxy.h +++ b/src/app/inc/FApp_PackageManagerProxy.h @@ -56,8 +56,6 @@ public: result InstallPackage(const PackageId& packageId, const Tizen::Base::String& packagePath, Tizen::App::Package::IPackageInstallationResponseListener* pListener); result UninstallPackage(const PackageId& packageId, Tizen::App::Package::IPackageUninstallationResponseListener* pListener); result GetPackageInfoFromFileN(const Tizen::Base::String& filePath, Tizen::App::Package::PackageInfo* pPackageInfo); - long long GetSize(const PackageId& packageId); - long long GetDataSize(const PackageId& packageId); Tizen::App::Package::PackageType GetType(const PackageId& packageId); private: diff --git a/src/app/package/FAppPkg_PackageInfoImpl.cpp b/src/app/package/FAppPkg_PackageInfoImpl.cpp index 0f6bd09..6c085ea 100755 --- a/src/app/package/FAppPkg_PackageInfoImpl.cpp +++ b/src/app/package/FAppPkg_PackageInfoImpl.cpp @@ -36,6 +36,7 @@ #include #include +#include "FApp_PackageManagerProxy.h" #include "FAppPkg_PackageManagerImpl.h" #include "FAppPkg_PackageInfoImpl.h" #include "FAppPkg_PackageAppInfoImpl.h" @@ -78,7 +79,19 @@ _PackageInfoImpl::SetVersion(const String& version) PackageType _PackageInfoImpl::GetType(void) const { - return __packageType; + SysTryReturn(NID_APP, __id.IsEmpty() == false, PACKAGE_TYPE_TPK, E_SYSTEM, "[E_SYSTEM] id.IsEmpty() is empty."); + + result r = E_SUCCESS; + PackageType type = PACKAGE_TYPE_TPK; + + _PackageManagerProxy packageManagerProxy; + r = packageManagerProxy.Construct(); + SysTryReturn(NID_APP, r == E_SUCCESS, PACKAGE_TYPE_TPK, E_SYSTEM, "packageManagerProxy.Construct() failed."); + + type = packageManagerProxy.GetType(__id); + SysTryReturn(NID_APP, r == E_SUCCESS, PACKAGE_TYPE_TPK, r, "packageManagerProxy.GetType(%ls) failed.", __id.GetPointer()); + + return type; } result diff --git a/src/server/app/package/FAppPkg_PackageManagerServer.cpp b/src/server/app/package/FAppPkg_PackageManagerServer.cpp index fce03f9..744f0c1 100755 --- a/src/server/app/package/FAppPkg_PackageManagerServer.cpp +++ b/src/server/app/package/FAppPkg_PackageManagerServer.cpp @@ -172,64 +172,6 @@ _PackageManagerServer::GetPackageInfoFromFileN(const String& filePath) const return pPackageInfo.release(); } -long long -_PackageManagerServer::GetSize(const PackageId& packageId) const -{ - int res = PMINFO_R_OK; - pkgmgrinfo_pkginfo_h handle = null; - int size = 0; - - std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(packageId)); - SysTryReturn(NID_APP, pPackageId, 0, E_OUT_OF_MEMORY, "pPackageId is null."); - - res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &handle); - SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_PKG_NOT_INSTALLED, "pkgmgrinfo_pkginfo_get_pkginfo() is failed. result=[%d], package=[%s]", res, pPackageId.get()); - SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "[E_SYSTEM] handle is null."); - - res = pkgmgrinfo_pkginfo_get_total_size(handle, &size); - if (res == PMINFO_R_OK) - { - SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size(): size = [%d]", size); - } - else - { - SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size() is failed. result = [%d]", res); - } - - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - - return (long long) size; -} - -long long -_PackageManagerServer::GetDataSize(const PackageId& packageId) const -{ - int res = PMINFO_R_OK; - pkgmgrinfo_pkginfo_h handle = null; - int dataSize = 0; - - std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(packageId)); - SysTryReturn(NID_APP, pPackageId, 0, E_OUT_OF_MEMORY, "pPackageId is null."); - - res = pkgmgrinfo_pkginfo_get_pkginfo(pPackageId.get(), &handle); - SysTryReturn(NID_APP, res == PMINFO_R_OK, 0, E_PKG_NOT_INSTALLED, "pkgmgrinfo_pkginfo_get_pkginfo() is failed. result=[%d], package=[%s]", res, pPackageId.get()); - SysTryReturn(NID_APP, handle, 0, E_SYSTEM, "[E_SYSTEM] handle is null."); - - res = pkgmgrinfo_pkginfo_get_data_size(handle, &dataSize); - if (res == PMINFO_R_OK) - { - SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size(): dataSize = [%d]", dataSize); - } - else - { - SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_total_size() is failed. result = [%d]", res); - } - - pkgmgrinfo_pkginfo_destroy_pkginfo(handle); - - return (long long) dataSize; -} - PackageType _PackageManagerServer::GetType(const PackageId& packageId) const { @@ -260,6 +202,10 @@ _PackageManagerServer::GetType(const PackageId& packageId) const { packageType = PACKAGE_TYPE_WGT; } + else if (strcmp(pType, "rpm") == 0) + { + packageType = PACKAGE_TYPE_RPM; + } } else { diff --git a/src/server/inc/FAppPkg_PackageManagerServer.h b/src/server/inc/FAppPkg_PackageManagerServer.h index d01090f..0da3aa2 100644 --- a/src/server/inc/FAppPkg_PackageManagerServer.h +++ b/src/server/inc/FAppPkg_PackageManagerServer.h @@ -42,8 +42,6 @@ public: static _PackageManagerServer* GetInstance(void); PackageInfo* GetPackageInfoFromFileN(const Tizen::Base::String& filePath) const; - long long GetSize(const Tizen::App::PackageId& packageId) const; - long long GetDataSize(const Tizen::App::PackageId& packageId) const; PackageType GetType(const Tizen::App::PackageId& packageId) const; -- 2.7.4