Package information needed for displaying on popup.
For now, only icon info is needed.
Change-Id: I01485bc24da86ff825de6b2ced7bdfe4da46d5c3
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
elementary
libsystemd-daemon
vconf
+ pkgmgr-info
)
INCLUDE_DIRECTORIES(
logic.cpp
popup.cpp
popup-service.cpp
+ package-info.cpp
${PROJECT_SOURCE_DIR}/src/framework/ui/common.cpp
)
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file package-info.cpp
+ * @author Kyungwook Tak (k.tak@samsung.com)
+ * @version 1.0
+ * @brief Package info getter for displaying detail of package on popup.
+ */
+#include "package-info.h"
+
+#include "common/exception.h"
+
+namespace Csr {
+namespace Ui {
+
+PackageInfo::PackageInfo(const std::string &pkgid)
+{
+ auto ret = ::pkgmgrinfo_pkginfo_get_pkginfo(pkgid.c_str(), &this->m_handle);
+ if (ret != PMINFO_R_OK)
+ ThrowExc(InternalError, "Invalid package id: " << pkgid << " ret: " << ret);
+}
+
+PackageInfo::~PackageInfo()
+{
+ ::pkgmgrinfo_pkginfo_destroy_pkginfo(this->m_handle);
+}
+
+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.");
+
+ return std::string(icon);
+}
+
+}
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file package-info.h
+ * @author Kyungwook Tak (k.tak@samsung.com)
+ * @version 1.0
+ * @brief Package info getter for displaying detail of package on popup.
+ */
+#pragma once
+
+#include <pkgmgr-info.h>
+
+#include <string>
+
+namespace Csr {
+namespace Ui {
+
+class PackageInfo {
+public:
+ PackageInfo(const std::string &pkgid);
+ virtual ~PackageInfo();
+
+ PackageInfo(const PackageInfo &) = delete;
+ PackageInfo &operator=(const PackageInfo &) = delete;
+ PackageInfo(PackageInfo &&) = delete;
+ PackageInfo &operator=(PackageInfo &&) = delete;
+
+ std::string getIconPath(void);
+
+private:
+ pkgmgrinfo_pkginfo_h m_handle;
+
+};
+
+
+} // namespace Ui
+} // namespace Csr
PKG_CHECK_MODULES(${TARGET_CSR_INTERNAL_TEST}_DEP
REQUIRED
sqlite3
+ pkgmgr-info
)
SET(${TARGET_CSR_INTERNAL_TEST}_SRCS
${CSR_FW_SRC_PATH}/service/wp-loader.cpp
${CSR_FW_SRC_PATH}/service/engine-error-converter.cpp
${CSR_FW_SRC_PATH}/client/canonicalize.cpp
+ ${CSR_FW_SRC_PATH}/ui/popup/package-info.cpp
test-db.cpp
test-cpucore.cpp
test-cs-loader.cpp
test-wp-loader.cpp
test-canonicalize.cpp
+ test-package-info.cpp
test-main.cpp
)
${PROJECT_SOURCE_DIR}/src/include/csr
${PROJECT_SOURCE_DIR}/src/include/csre
${CSR_FW_SRC_PATH}
+ ${CSR_FW_SRC_PATH}/ui/popup
${CSR_TEST_SRC_PATH}
)
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+/*
+ * @file test-package-info.cpp
+ * @author Kyungwook Tak (k.tak@samsung.com)
+ * @version 1.0
+ * @brief Package info class test
+ */
+#include <package-info.h>
+
+#include <boost/test/unit_test.hpp>
+
+#include "test-common.h"
+#include "test-resource.h"
+
+using namespace Csr;
+
+BOOST_AUTO_TEST_SUITE(PACKAGE_INFO)
+
+BOOST_AUTO_TEST_CASE(get_icon_wgt)
+{
+ EXCEPTION_GUARD_START
+
+ Test::uninstall_app(TEST_WGT_PKG_ID);
+ ASSERT_INSTALL_APP(TEST_WGT_PATH, TEST_WGT_TYPE);
+
+ Ui::PackageInfo info(TEST_WGT_PKG_ID);
+
+ BOOST_MESSAGE(info.getIconPath());
+
+ EXCEPTION_GUARD_END
+}
+
+BOOST_AUTO_TEST_CASE(get_icon_tpk)
+{
+ EXCEPTION_GUARD_START
+
+ Test::uninstall_app(TEST_TPK_PKG_ID);
+ ASSERT_INSTALL_APP(TEST_TPK_PATH, TEST_TPK_TYPE);
+
+ Ui::PackageInfo info(TEST_TPK_PKG_ID);
+
+ BOOST_MESSAGE(info.getIconPath());
+
+ EXCEPTION_GUARD_END
+}
+
+BOOST_AUTO_TEST_SUITE_END()