int PkgmgrBackendPlugin::DetailedInfoPkg(
const std::string& pkg_path,
package_manager_pkg_detail_info_t* pkg_detail_info) {
- if (!base::PathExists(base::FilePath(pkg_path))) {
+ base::FilePath path(pkg_path);
+ if (!base::PathExists(path)) {
return kPkgmgrPluginFalse;
}
return kPkgmgrPluginFalse;
}
- SaveDetailInfo(app_data, pkg_detail_info);
+ SaveDetailInfo(app_data, pkg_detail_info,
+ !path.Extension().empty() ? path.Extension() : std::string("unknown"));
return kPkgmgrPluginTrue;
}
int PkgmgrBackendPlugin::IsAppInstalled(const std::string& pkgid) {
// this will fetch app_id if exists
std::string app_id = xwalk::application::PkgIdToAppId(pkgid);
- return app_id.empty() ? kPkgmgrPluginFalse : kPkgmgrPluginTrue;
+
+ if (app_id.empty())
+ return kPkgmgrPluginFalse;
+
+ // backendlib handles both xpk and wgt
+ // check if plugin was loaded for given type of package
+ std::string type_from_db = xwalk::application::GetPackageType(pkgid);
+
+ return type() == type_from_db ? kPkgmgrPluginTrue : kPkgmgrPluginFalse;
}
int PkgmgrBackendPlugin::AppsList(package_manager_pkg_info_t** list,
return kPkgmgrPluginTrue;
}
+void PkgmgrBackendPlugin::SetLoadSet(pkg_plugin_set* set) {
+ set_ = set;
+}
+
+std::string PkgmgrBackendPlugin::type() const {
+ return std::string(set_->pkg_type);
+}
+
PkgmgrBackendPlugin::PkgmgrBackendPlugin() {
base::FilePath data_path;
xwalk::RegisterPathProvider();
void PkgmgrBackendPlugin::SaveInfo(
scoped_refptr<xwalk::application::ApplicationData> app_data,
- package_manager_pkg_info_t* pkg_detail_info) {
- strncpy(pkg_detail_info->pkg_type, "xpk", PKG_TYPE_STRING_LEN_MAX - 1);
- strncpy(pkg_detail_info->pkg_name, app_data->GetPackageID().c_str(),
+ package_manager_pkg_info_t* pkg_detail_info,
+ const std::string& force_type) {
+ std::string pkg_id = app_data->GetPackageID();
+ if (force_type.empty())
+ strncpy(pkg_detail_info->pkg_type,
+ xwalk::application::GetPackageType(pkg_id).c_str(),
+ PKG_TYPE_STRING_LEN_MAX - 1);
+ else // force package type
+ strncpy(pkg_detail_info->pkg_type,
+ force_type.c_str(),
+ PKG_TYPE_STRING_LEN_MAX - 1);
+ strncpy(pkg_detail_info->pkg_name, pkg_id.c_str(),
PKG_NAME_STRING_LEN_MAX - 1);
- strncpy(pkg_detail_info->pkgid, app_data->GetPackageID().c_str(),
+ strncpy(pkg_detail_info->pkgid, pkg_id.c_str(),
PKG_NAME_STRING_LEN_MAX - 1);
if (app_data->Version() != NULL) {
strncpy(pkg_detail_info->version, app_data->Version()->GetString().c_str(),
void PkgmgrBackendPlugin::SaveDetailInfo(
scoped_refptr<xwalk::application::ApplicationData> app_data,
- package_manager_pkg_detail_info_t* pkg_detail_info) {
- strncpy(pkg_detail_info->pkg_type, "xpk", PKG_TYPE_STRING_LEN_MAX - 1);
- strncpy(pkg_detail_info->pkg_name, app_data->GetPackageID().c_str(),
+ package_manager_pkg_detail_info_t* pkg_detail_info,
+ const std::string& force_type) {
+ std::string pkg_id = app_data->GetPackageID();
+ if (force_type.empty())
+ strncpy(pkg_detail_info->pkg_type,
+ xwalk::application::GetPackageType(pkg_id).c_str(),
+ PKG_TYPE_STRING_LEN_MAX - 1);
+ else // force package type
+ strncpy(pkg_detail_info->pkg_type,
+ force_type.c_str(),
+ PKG_TYPE_STRING_LEN_MAX - 1);
+ strncpy(pkg_detail_info->pkg_name, pkg_id.c_str(),
PKG_NAME_STRING_LEN_MAX - 1);
- strncpy(pkg_detail_info->pkgid, app_data->GetPackageID().c_str(),
+ strncpy(pkg_detail_info->pkgid, pkg_id.c_str(),
PKG_NAME_STRING_LEN_MAX - 1);
if (app_data->Version() != NULL) {
strncpy(pkg_detail_info->version, app_data->Version()->GetString().c_str(),
DCHECK(tizen_app_info);
strncpy(pkg_detail_info->min_platform_version,
- tizen_app_info->required_version().c_str(),
- PKG_VERSION_STRING_LEN_MAX -1);
+ tizen_app_info->required_version().c_str(),
+ PKG_VERSION_STRING_LEN_MAX -1);
}
pkg_detail_info->installed_time =
scoped_refptr<xwalk::application::ApplicationData>
PkgmgrBackendPlugin::GetApplicationDataFromPkg(const std::string& pkg_path,
- base::ScopedTempDir* dir) {
+ base::ScopedTempDir* dir) {
base::FilePath unpacked_dir = dir->path();
-
scoped_ptr<xwalk::application::Package> package =
xwalk::application::Package::Create(base::FilePath(pkg_path));
if (!package)
return nullptr;
- package->ExtractToTemporaryDir(&unpacked_dir);
- std::string app_id = package->Id();
+ package->ExtractToTemporaryDir(&unpacked_dir);
std::string error;
+ std::string app_id = package->Id();
scoped_refptr<xwalk::application::ApplicationData> app_data = LoadApplication(
unpacked_dir, app_id, xwalk::application::ApplicationData::TEMP_DIRECTORY,
package->manifest_type(), &error);
+
return app_data;
}