const char kHybridConfigLocation[] = "res/wgt/config.xml";
const char kTizenManifestLocation[] = "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,
- "config.xml")) {
- ci::RemoveAll(tmp_path);
+std::string ReadPkgidFromRecovery(const std::string& recovery_path) {
+ std::unique_ptr<ci::recovery::RecoveryFile> recovery_file =
+ ci::recovery::RecoveryFile::OpenRecoveryFileForPath(recovery_path);
+ recovery_file->Detach();
+ return recovery_file->pkgid();
+}
+
+} // namespace
+
+namespace wgt {
+
+std::string WgtAppQueryInterface::GetManifestFileName() const {
+ return "config.xml";
+}
+
+std::string WgtAppQueryInterface::GetPkgIdFromPath(
+ const std::string& path) const {
+ bf::path tmp_path = ExtractManifest(path);
+ if (tmp_path.empty())
return {};
- }
- bf::path config_path = tmp_path / "config.xml";
std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
std::make_shared<wgt::parse::WidgetHandler>(),
std::make_shared<wgt::parse::TizenApplicationHandler>()
new parser::ManifestHandlerRegistry(handlers));
std::unique_ptr<parser::ManifestParser> parser(
new parser::ManifestParser(std::move(registry)));
+ bf::path config_path = tmp_path / GetManifestFileName();
if (!parser->ParseManifest(config_path)) {
ci::RemoveAll(tmp_path);
return {};
return pkg_id;
}
-std::string ReadPkgidFromRecovery(const std::string& recovery_path) {
- std::unique_ptr<ci::recovery::RecoveryFile> recovery_file =
- ci::recovery::RecoveryFile::OpenRecoveryFileForPath(recovery_path);
- recovery_file->Detach();
- return recovery_file->pkgid();
-}
-
-} // namespace
-
-namespace wgt {
-
-bool WgtAppQueryInterface::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);
-}
-
bool WgtAppQueryInterface::IsHybridApplication(const std::string& arg,
- uid_t uid) {
+ uid_t uid) const {
std::string info;
bool is_recovery = arg.find("wgt-recovery-") != std::string::npos;
if (is_recovery)
return false;
}
-std::string WgtAppQueryInterface::GetPkgId(const std::string& arg) {
- return GetPkgIdFromPath(arg);
-}
-
} // namespace wgt
*/
class WgtAppQueryInterface : public common_installer::AppQueryInterface {
public:
- /**
- * \brief method for checking if package is installed based
- * on argv
- *
- * \return true if package is installed
- */
- bool IsPkgInstalled(const std::string& arg, uid_t uid) override;
-
/**
* \brief This method is workaround for detecting installation of hybrid
* application.
*
* \return true if package is hybrid
*/
- bool IsHybridApplication(const std::string& arg, uid_t uid);
+ bool IsHybridApplication(const std::string& arg, uid_t uid) const;
- /**
- * \brief method for getting package id from package file
- *
- * \return package id
- */
- std::string GetPkgId(const std::string& arg) override;
+ private:
+ std::string GetPkgIdFromPath(const std::string& path) const override;
+ std::string GetManifestFileName() const override;
};
} // namespace wgt