Fix package info class return value 33/72733/3
authorsangwan.kwon <sangwan.kwon@samsung.com>
Thu, 2 Jun 2016 08:41:27 +0000 (17:41 +0900)
committersangwan kwon <sangwan.kwon@samsung.com>
Fri, 3 Jun 2016 02:19:19 +0000 (19:19 -0700)
* If pkginfo could not get information,
* return Unknown value.

Change-Id: I25b3c05a694b4830aa573cf185f8574b6c19671d

src/framework/ui/popup/package-info.cpp
src/framework/ui/popup/package-info.h

index e397029..9048faa 100644 (file)
@@ -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);
 }
index 6c80836..c74338a 100644 (file)
@@ -43,6 +43,8 @@ public:
        std::string getVersion(void);
        std::string getLabel(void);
 
+       static const std::string UNKNOWN;
+
 private:
        pkgmgrinfo_pkginfo_h m_handle;
 };