From: Damian Pietruchowski Date: Mon, 12 Jun 2017 14:03:42 +0000 (+0200) Subject: AppQueryInterface logic export X-Git-Tag: submit/tizen/20170829.115218~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aa6e61f543234181fa7ef08a2ea7ecd280f52f7a;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git AppQueryInterface logic export IsPkgInstalled() and GetPkgId() have the same implementation for wgt-backend and tpk-backend, so only GetPkgIdFromPath() should be overrided in each backend. Submit together: - https://review.tizen.org/gerrit/#/c/133518/ - https://review.tizen.org/gerrit/#/c/133519/ Change-Id: I280e6d6c2bc718c34238bb3a96c81b4584e5d964 Signed-off-by: Damian Pietruchowski --- diff --git a/src/tpk/tpk_app_query_interface.cc b/src/tpk/tpk_app_query_interface.cc index 49adc0f..1f44687 100644 --- a/src/tpk/tpk_app_query_interface.cc +++ b/src/tpk/tpk_app_query_interface.cc @@ -31,19 +31,19 @@ namespace { const char kManifestFileName[] = "tizen-manifest.xml"; -std::string GetPkgIdFromPath(const std::string& path) { - if (!bf::exists(path)) - return {}; - bf::path tmp_path = common_installer::GenerateTmpDir("/tmp"); - bs::error_code code; - bf::create_directories(tmp_path, code); - if (code) - return {}; - if (!common_installer::ExtractToTmpDir(path.c_str(), tmp_path, - kManifestFileName)) { - ci::RemoveAll(tmp_path); +} // namespace + +namespace tpk { + +std::string TpkAppQueryInterface::GetManifestFileName() const { + return std::string(kManifestFileName); +} + +std::string TpkAppQueryInterface::GetPkgIdFromPath( + const std::string& path) const { + bf::path tmp_path = ExtractManifest(path); + if (tmp_path.empty()) return {}; - } bf::path manifest_path = tmp_path / kManifestFileName; if (!bf::exists(manifest_path)) { ci::RemoveAll(tmp_path); @@ -62,24 +62,4 @@ std::string GetPkgIdFromPath(const std::string& path) { return pkg_id; } -} // namespace - -namespace tpk { - -bool TpkAppQueryInterface::IsPkgInstalled(const std::string& arg, uid_t uid) { - // argument from commandline is package id - if (ci::QueryIsPackageInstalled(arg, ci::GetRequestMode(uid), uid)) - return true; - - // argument from commandline is path to file - std::string pkg_id = GetPkgIdFromPath(arg); - if (pkg_id.empty()) - return false; - return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode(uid), uid); -} - -std::string TpkAppQueryInterface::GetPkgId(const std::string& arg) { - return GetPkgIdFromPath(arg); -} - } // namespace tpk diff --git a/src/tpk/tpk_app_query_interface.h b/src/tpk/tpk_app_query_interface.h index 011a9f5..a34c952 100644 --- a/src/tpk/tpk_app_query_interface.h +++ b/src/tpk/tpk_app_query_interface.h @@ -19,9 +19,9 @@ namespace tpk { class TPK_BACKEND_EXPORT_API TpkAppQueryInterface : public common_installer::AppQueryInterface { - public: - bool IsPkgInstalled(const std::string& arg, uid_t uid) override; - std::string GetPkgId(const std::string& arg) override; + private: + std::string GetPkgIdFromPath(const std::string& path) const override; + std::string GetManifestFileName() const override; }; } // namespace tpk