X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fwrt-installer%2Fwrt-installer.cpp;h=7d2cb5258b57bd0efa680ac2343d35624080c81a;hb=24bb6c1bd2cb05f6f4cbf8098525d95caf6a6eee;hp=0a12e5dfca78c68e3d15025c622c2f49d8142a05;hpb=f947ed1728ecff4940d183999e2ee9cd8f9cec83;p=framework%2Fweb%2Fwrt-installer.git diff --git a/src/wrt-installer/wrt-installer.cpp b/src/wrt-installer/wrt-installer.cpp index 0a12e5d..7d2cb52 100644 --- a/src/wrt-installer/wrt-installer.cpp +++ b/src/wrt-installer/wrt-installer.cpp @@ -21,6 +21,7 @@ #include "wrt-installer.h" #include "plugin_utils.h" +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -160,6 +162,7 @@ void WrtInstaller::OnCreate() if (m_argc != 2) { return showHelpAndQuit(); } + if (!m_startupPluginInstallation) { AddStep(&WrtInstaller::installPluginsStep); } else { @@ -179,14 +182,57 @@ void WrtInstaller::OnCreate() m_installMode = WRT_INSTALL_MODE_INSTALL_WGT; } m_packagePath = m_argv[2]; + AddStep(&WrtInstaller::installStep); - } else if (arg == "-il" || arg == "--install-preload") { + } else if (arg == "-ip" || arg == "--install-preload") { + LogDebug("Install preload web app"); if (m_argc != 3) { return showHelpAndQuit(); } m_packagePath = m_argv[2]; m_installMode = WRT_INSTALL_MODE_INSTALL_PRELOAD; AddStep(&WrtInstaller::installStep); + } else if (arg == "-c" || arg == "--csc-update") { + // "path=/opt/system/csc/Ozq2iEG15R-2.0.0-arm.wgt:op=install:removable=true" + LogDebug("Install & uninstall by csc configuration"); + if (m_argc != 3) { + return showHelpAndQuit(); + } + std::string configuration = m_argv[2]; + m_CSCconfigurationMap = parseCSCConfiguration(configuration); + + CSCConfiguration::dataMap::iterator it; + it = m_CSCconfigurationMap.find(CSCConfiguration::KEY_OP); + if (it == m_CSCconfigurationMap.end()) { + return showHelpAndQuit(); + } + + if (it->second == CSCConfiguration::VALUE_INSTALL) { + LogDebug("operation = " << it->second); + m_installMode = WRT_INSTALL_MODE_INSTALL_WGT; + it = m_CSCconfigurationMap.find(CSCConfiguration::KEY_PATH); + if (it == m_CSCconfigurationMap.end()) { + return showHelpAndQuit(); + } + m_packagePath = it->second; + AddStep(&WrtInstaller::installStep); + LogDebug("path = " << m_packagePath); + } else if (it->second == CSCConfiguration::VALUE_UNINSTALL) { + LogDebug("operation = " << it->second); + // uninstall command isn't confirmed yet + it = m_CSCconfigurationMap.find(CSCConfiguration::KEY_PATH); + if (it == m_CSCconfigurationMap.end()) { + return showHelpAndQuit(); + } + m_packagePath = it->second; + AddStep(&WrtInstaller::unistallWgtFileStep); + LogDebug("operation = uninstall"); + LogDebug("path = " << m_packagePath); + } else { + LogError("Unknown operation : " << it->second); + LogDebug("operation = " << it->second); + return showHelpAndQuit(); + } } else if (arg == "-un" || arg == "--uninstall-name") { if (m_argc != 3) { return showHelpAndQuit(); @@ -269,7 +315,8 @@ void WrtInstaller::OnReset(bundle* /*b*/) void WrtInstaller::OnTerminate() { LogDebug("Wrt Shutdown now"); - PluginUtils::unlockPluginInstallation(); + PluginUtils::unlockPluginInstallation(m_installMode == + WRT_INSTALL_MODE_INSTALL_PRELOAD); if (m_initialized) { wrt_installer_shutdown(); } @@ -289,6 +336,8 @@ void WrtInstaller::showHelpAndQuit() " -p, --install-plugins install plugins\n" " -i, --install " "install or update widget package for given path\n" + " -c, --csc-update " + "install or uninstall by CSC configuration \n" " -un, --uninstall-name " "uninstall widget for given package name\n" " -up, --uninstall-packagepath " @@ -369,7 +418,8 @@ void WrtInstaller::installPluginsStep() if (m_startupPluginInstallation) { LogInfo("Plugin installation started because new plugin package found"); - } else if (!PluginUtils::lockPluginInstallation()) { + } else if (!PluginUtils::lockPluginInstallation(m_installMode == + WRT_INSTALL_MODE_INSTALL_PRELOAD)) { LogError("Failed to open plugin installation lock file" " Plugins are currently installed by other process"); staticWrtPluginInstallationCallback(WRT_INSTALLER_ERROR_PLUGIN_INSTALLATION_FAILED, @@ -787,6 +837,15 @@ void WrtInstaller::staticWrtStatusCallback(std::string tizenId, This->m_returnStatus = 0; resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS); + if (This->m_installMode == WRT_INSTALL_MODE_INSTALL_PRELOAD && + !This->m_packagePath.empty()) { + LogDebug("This widget is preloaded so it will be removed : " + << This->m_packagePath); + if (!WrtUtilRemove(This->m_packagePath)) { + LogError("Failed to remove " << This->m_packagePath); + } + } + This->DPL::Event::ControllerEventHandler ::PostEvent(WRTInstallerNS::NextStepEvent()); @@ -818,7 +877,8 @@ void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status, } //remove lock file - if (!PluginUtils::unlockPluginInstallation()) { + if (!PluginUtils::unlockPluginInstallation(This->m_installMode == + WRT_INSTALL_MODE_INSTALL_PRELOAD)) { LogInfo("Failed to remove installation lock"); } @@ -911,14 +971,16 @@ void WrtInstaller::installNewPlugins() { LogDebug("Install new plugins"); - if (!PluginUtils::lockPluginInstallation()) { + if (!PluginUtils::lockPluginInstallation(m_installMode == + WRT_INSTALL_MODE_INSTALL_PRELOAD)) { LogInfo("Lock NOT created"); return; } if (!PluginUtils::checkPluginInstallationRequired()) { LogDebug("Plugin installation not required"); - PluginUtils::unlockPluginInstallation(); + PluginUtils::unlockPluginInstallation(m_installMode == + WRT_INSTALL_MODE_INSTALL_PRELOAD); return; } @@ -926,6 +988,35 @@ void WrtInstaller::installNewPlugins() AddStep(&WrtInstaller::installPluginsStep); } +CSCConfiguration::dataMap WrtInstaller::parseCSCConfiguration( + std::string str) +{ + // path=/opt/system/csc/Ozq2iEG15R-2.0.0-arm.wgt:op=install:removable=true + // parsing CSC configuration string + LogDebug("parseConfiguration"); + CSCConfiguration::dataMap result; + + if (str.empty()) { + LogDebug("Input argument is empty"); + return result; + } + + char* buf = strdup(str.c_str()); + const char* ptr = strtok(buf,":"); + while (ptr != NULL) { + std::string string = ptr; + size_t pos = string.find('='); + if (pos == std::string::npos) { + continue; + } + result.insert( + CSCConfiguration::dataPair(string.substr(0, pos), + string.substr(pos+1))); + ptr = strtok (NULL, ":"); + } + return result; +} + int main(int argc, char *argv[]) { UNHANDLED_EXCEPTION_HANDLER_BEGIN