From c985b21d58113738f3ad87e541b3751c5882e6dd Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 30 Sep 2016 17:07:00 +0900 Subject: [PATCH] Fix TpkAppQueryInterface Don't parse again argv, argc. They are already parsed by PkgMgrInterface. Requires: - https://review.tizen.org/gerrit/90478 Change-Id: Ieb8b9468eb60d21561f6f3e54b79dbc1bd1c81a3 Signed-off-by: Sangyoon Jang --- src/tpk/tpk_app_query_interface.cc | 59 ++++++-------------------------------- src/tpk/tpk_app_query_interface.h | 6 +++- 2 files changed, 13 insertions(+), 52 deletions(-) diff --git a/src/tpk/tpk_app_query_interface.cc b/src/tpk/tpk_app_query_interface.cc index e910fd0..d048ef8 100644 --- a/src/tpk/tpk_app_query_interface.cc +++ b/src/tpk/tpk_app_query_interface.cc @@ -31,47 +31,9 @@ namespace { const char kManifestFileName[] = "tizen-manifest.xml"; -uid_t GetUid(int argc, char** argv) { - uid_t uid = 0; - for (int i = 0; i < argc; ++i) { - if (!strcmp(argv[i], "-u")) { - if (i + 1 < argc) { - uid = atoi(argv[i + 1]); - break; - } - } - } - - return uid; -} - -std::string GetInstallationPackagePath(int argc, char** argv) { - std::string path; - for (int i = 0; i < argc; ++i) { - if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "-w")) { - if (i + 1 < argc) { - path = argv[i + 1]; - break; - } - } - } - return path; -} - -std::string GetPkgIdFromCmd(int argc, char** argv) { - std::string pkgid; - for (int i = 0; i < argc; ++i) { - if (!strcmp(argv[i], "-y")) { - if (i + 1 < argc) { - pkgid = argv[i + 1]; - break; - } - } - } - return pkgid; -} - 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); @@ -104,21 +66,16 @@ std::string GetPkgIdFromPath(const std::string& path) { namespace tpk { -bool TpkAppQueryInterface::IsAppInstalledByArgv(int argc, char** argv) { - std::string path = GetInstallationPackagePath(argc, argv); - std::string pkg_id; - if (path.empty()) { - // check if it is manifest direct install - pkg_id = GetPkgIdFromCmd(argc, argv); - } else { - pkg_id = GetPkgIdFromPath(path); - } +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; - uid_t uid = GetUid(argc, argv); return ci::QueryIsPackageInstalled(pkg_id, ci::GetRequestMode(uid), uid); } } // namespace tpk - diff --git a/src/tpk/tpk_app_query_interface.h b/src/tpk/tpk_app_query_interface.h index e2ca078..21d6824 100644 --- a/src/tpk/tpk_app_query_interface.h +++ b/src/tpk/tpk_app_query_interface.h @@ -9,6 +9,10 @@ #define TPK_BACKEND_EXPORT_API #endif +#include + +#include + #include namespace tpk { @@ -16,7 +20,7 @@ namespace tpk { class TPK_BACKEND_EXPORT_API TpkAppQueryInterface : public common_installer::AppQueryInterface { public: - bool IsAppInstalledByArgv(int argc, char** argv) override; + bool IsPkgInstalled(const std::string& arg, uid_t uid) override; }; } // namespace tpk -- 2.7.4