#include "xwalk/application/tools/tizen/xwalk_platform_installer.h"
#include <assert.h>
+#include <pkgmgr_installer.h>
#include <pkgmgr/pkgmgr_parser.h>
-#include <pkgmgr_installer.h>
// logging and dlog uses same macro name
// to avoid warnings we need to undefine dlog's one
#undef LOG
base::CreateDirectory(dir);
if (!base::CopyFile(file_src, file_dst)) {
LOG(ERROR) << "Couldn't copy application file from "
- << file_src.value() << " to " << file_dst.value();
+ << file_src.value() << " to " << file_dst.value();
return false;
}
return true;
return ret;
}
-bool PlatformInstaller::ReinstallApplication() {
+bool PlatformInstaller::ReinstallApplication(const std::string& pkgid) {
SendSignal(PKGMGR_START_KEY, PKGMGR_START_REINSTALL);
- // FIXME not implemented, just send signal abotu failure
- SendSignal(PKGMGR_END_KEY, ToEndStatus(false));
- return false;
+ bool ret = ReinstallApplicationInternal(pkgid);
+ SendSignal(PKGMGR_END_KEY, ToEndStatus(ret));
+ return ret;
}
bool PlatformInstaller::InstallApplicationInternal(
LOG(INFO) << "UID of installation : " << uid;
if (uid != GLOBAL_USER) { // For only the user that request installation
if (pkgmgr_parser_parse_usr_manifest_for_installation(
- xmlpath.value().c_str(),
- uid, const_cast<char**>(pkgmgr_tags))) {
+ xmlpath.value().c_str(), uid, const_cast<char**>(pkgmgr_tags))) {
LOG(ERROR) << "Couldn't parse manifest XML '"
- << xmlpath.value().c_str() << "', uid : " << uid;
+ << xmlpath.value().c_str() << "', uid : " << uid;
return false;
}
} else { // For all users
- if (pkgmgr_parser_parse_manifest_for_installation(xmlpath.value().c_str(),
- const_cast<char**>(pkgmgr_tags))) {
+ if (pkgmgr_parser_parse_manifest_for_installation(
+ xmlpath.value().c_str(), const_cast<char**>(pkgmgr_tags))) {
LOG(ERROR) << "Couldn't parse manifest XML '"
- << xmlpath.value().c_str() << "' for global installation";
+ << xmlpath.value().c_str() << "' for global installation";
return false;
}
}
assert(!xmlpath_str.empty());
if (uid != GLOBAL_USER) { // For only the user that request installation
- if (pkgmgr_parser_parse_usr_manifest_for_uninstallation(
- xmlpath_str.c_str(), uid, NULL)) {
+ if (pkgmgr_parser_parse_usr_manifest_for_uninstallation(xmlpath_str.c_str(),
+ uid, NULL)) {
LOG(ERROR) << "Couldn't parse manifest XML '" << xmlpath_str << "', uid"
- << uid;
+ << uid;
icon_cleaner.Dismiss();
xml_cleaner.Dismiss();
}
} else { // For all users
- if (pkgmgr_parser_parse_manifest_for_uninstallation(
- xmlpath_str.c_str(), NULL)) {
+ if (pkgmgr_parser_parse_manifest_for_uninstallation(xmlpath_str.c_str(),
+ NULL)) {
LOG(ERROR) << "Couldn't parse manifest XML '" << xmlpath_str
- << "' for global uninstallation";
+ << "' for global uninstallation";
icon_cleaner.Dismiss();
xml_cleaner.Dismiss();
}
if (xmlpath.empty() || iconpath.empty()) {
LOG(ERROR) << "Invalid xml path or icon path for update";
}
-
base::FilePath global_xml(tzplatform_mkpath(TZ_SYS_RO_PACKAGES, "/"));
base::FilePath global_icon(tzplatform_mkpath(TZ_SYS_RO_ICONS, kIconDir));
base::FilePath user_xml(tzplatform_mkpath(TZ_USER_PACKAGES, "/"));
xml = global_xml;
icon = global_icon;
}
-
// FIXME(vcgomes): Add support for more icon types
base::FilePath xml_dst = GetDestFilePath(xml, appid_, kXmlFileExt);
base::FilePath icon_dst = GetDestFilePath(icon, appid_, kPngFileExt);
FileDeleter xml_cleaner(xml_dst, false);
FileDeleter icon_cleaner(icon_dst, false);
-
- if (!CopyFileToDst(xmlpath, xml_dst)
- || !CopyFileToDst(iconpath, icon_dst))
+ if (!CopyFileToDst(xmlpath, xml_dst) || !CopyFileToDst(iconpath, icon_dst))
return false;
if (uid != GLOBAL_USER) { // For only the user that request installation
if (pkgmgr_parser_parse_usr_manifest_for_upgrade(xmlpath.value().c_str(),
uid, const_cast<char**>(pkgmgr_tags))) {
LOG(ERROR) << "Couldn't parse manifest XML '" << xmlpath.value()
- << "', uid: " << uid;
+ << "', uid: " << uid;
return false;
}
} else { // For all users
if (pkgmgr_parser_parse_manifest_for_upgrade(xmlpath.value().c_str(),
const_cast<char**>(pkgmgr_tags))) {
LOG(ERROR) << "Couldn't parse manifest XML '"
- << xmlpath.value() << "' for global update installation";
+ << xmlpath.value() << "' for global update installation";
return false;
}
}
-
xml_cleaner.Dismiss();
icon_cleaner.Dismiss();
return true;
}
-bool PlatformInstaller::SendSignal(
- const std::string& key,
- const std::string& value) {
+bool PlatformInstaller::ReinstallApplicationInternal(const std::string& pkgid) {
+ if (pkgid.empty()) {
+ LOG(ERROR) << "Invalid package ID for reinstallation!";
+ return false;
+ }
+ return true;
+}
+
+bool PlatformInstaller::SendSignal(const std::string& key,
+ const std::string& value) {
if (!handle_) {
// this is installation with xwalkctl not pkgmgr
return true;
return false;
}
- if (pkgmgr_installer_send_signal(
- handle_, PKGMGR_PKG_TYPE, pkgid_.c_str(),
- key.c_str(), value.c_str())) {
+ if (pkgmgr_installer_send_signal(handle_, PKGMGR_PKG_TYPE, pkgid_.c_str(),
+ key.c_str(), value.c_str())) {
LOG(ERROR) << "Fail to send package manager signal";
}
-
return true;
}