From 6a038552c128b3585b9af077b05fa4d03bfa0e8c Mon Sep 17 00:00:00 2001 From: "sangwan.kwon" Date: Thu, 2 Jun 2016 17:41:27 +0900 Subject: [PATCH] Fix package info class return value * If pkginfo could not get information, * return Unknown value. Change-Id: I25b3c05a694b4830aa573cf185f8574b6c19671d --- src/framework/ui/popup/package-info.cpp | 38 ++++++++++++--------------------- src/framework/ui/popup/package-info.h | 2 ++ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/framework/ui/popup/package-info.cpp b/src/framework/ui/popup/package-info.cpp index e397029..9048faa 100644 --- a/src/framework/ui/popup/package-info.cpp +++ b/src/framework/ui/popup/package-info.cpp @@ -39,18 +39,16 @@ PackageInfo::~PackageInfo() ::pkgmgrinfo_pkginfo_destroy_pkginfo(this->m_handle); } +const std::string PackageInfo::UNKNOWN = "Unknown"; + std::string PackageInfo::getIconPath(void) { char *icon = nullptr; auto ret = ::pkgmgrinfo_pkginfo_get_icon(this->m_handle, &icon); - if (ret != PMINFO_R_OK) - ThrowExc(InternalError, - "Failed to get icon with pkginfo. ret: " << ret); - - if (icon == nullptr) - ThrowExc(InternalError, - "pkgmgrinfo_pkginfo_get_icon success" - ", but null returned on icon path."); + if (ret != PMINFO_R_OK || icon == nullptr) { + WARN("Failed to get icon with pkginfo. ret: " << ret); + return this->UNKNOWN; + } return std::string(icon); } @@ -59,14 +57,10 @@ std::string PackageInfo::getVersion(void) { char *version = nullptr; auto ret = ::pkgmgrinfo_pkginfo_get_version(this->m_handle, &version); - if (ret != PMINFO_R_OK) - ThrowExc(InternalError, - "Failed to get version with pkginfo. ret: " << ret); - - if (version == nullptr) - ThrowExc(InternalError, - "pkgmgrinfo_pkginfo_get_version success" - ", but null returned on icon path."); + if (ret != PMINFO_R_OK || version == nullptr) { + WARN("Failed to get version with pkginfo. ret: " << ret); + return this->UNKNOWN; + } return std::string(version); } @@ -75,14 +69,10 @@ std::string PackageInfo::getLabel(void) { char *label = nullptr; auto ret = ::pkgmgrinfo_pkginfo_get_label(this->m_handle, &label); - if (ret != PMINFO_R_OK) - ThrowExc(InternalError, - "Failed to get label with pkginfo. ret: " << ret); - - if (label == nullptr) - ThrowExc(InternalError, - "pkgmgrinfo_pkginfo_get_label success" - ", but null returned on icon path."); + if (ret != PMINFO_R_OK || label == nullptr) { + WARN("Failed to get label with pkginfo. ret: " << ret); + return this->UNKNOWN; + } return std::string(label); } diff --git a/src/framework/ui/popup/package-info.h b/src/framework/ui/popup/package-info.h index 6c80836..c74338a 100644 --- a/src/framework/ui/popup/package-info.h +++ b/src/framework/ui/popup/package-info.h @@ -43,6 +43,8 @@ public: std::string getVersion(void); std::string getLabel(void); + static const std::string UNKNOWN; + private: pkgmgrinfo_pkginfo_h m_handle; }; -- 2.7.4