[Release] wrt-installer_0.1.40 accepted/tizen_2.1/20130425.023916 submit/tizen_2.1/20130424.235352
authorJihoon Chung <jihoon.chung@samsung.com>
Wed, 24 Apr 2013 07:46:52 +0000 (16:46 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Wed, 24 Apr 2013 07:46:52 +0000 (16:46 +0900)
Change-Id: I6fcd84aee013787753cf4d227c5451cf93004afe

packaging/wrt-installer.spec
src/misc/widget_install_to_external.cpp
src/wrt-installer/wrt-installer.cpp
src/wrt-installer/wrt-installer.h

index 9a6fed8..2976c26 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt-installer wrt-installer 0.1.39
+#git:framework/web/wrt-installer wrt-installer 0.1.40
 Name:       wrt-installer
 Summary:    Installer for tizen Webruntime
-Version:    0.1.39
+Version:    0.1.40
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
index 4f794b6..42bcc4f 100644 (file)
@@ -74,14 +74,15 @@ void WidgetInstallToExt::preInstallation(GList *dirList, int dSize)
 void WidgetInstallToExt::postInstallation(bool status)
 {
     LogDebug("WidgetInstallToExt::postInstallation()");
-    Assert(m_handle);
 
-    if (status) {
-        m_handle->interface.post_install(m_appId.c_str(),
-                                         APP2EXT_STATUS_SUCCESS);
-    } else {
-        m_handle->interface.post_install(m_appId.c_str(),
-                                         APP2EXT_STATUS_FAILED);
+    if (NULL != m_handle) {
+        if (status) {
+            m_handle->interface.post_install(m_appId.c_str(),
+                                             APP2EXT_STATUS_SUCCESS);
+        } else {
+            m_handle->interface.post_install(m_appId.c_str(),
+                                             APP2EXT_STATUS_FAILED);
+        }
     }
 }
 
@@ -102,14 +103,14 @@ void WidgetInstallToExt::preUpgrade(GList *dirList, int dSize)
 void WidgetInstallToExt::postUpgrade(bool status)
 {
     LogDebug("WidgetInstallToExt::postUpgrade()");
-    Assert(m_handle);
-
-    if (status) {
-        m_handle->interface.post_upgrade(m_appId.c_str(),
-                                         APP2EXT_STATUS_SUCCESS);
-    } else {
-        m_handle->interface.post_upgrade(m_appId.c_str(),
-                                         APP2EXT_STATUS_FAILED);
+    if (NULL != m_handle) {
+        if (status) {
+            m_handle->interface.post_upgrade(m_appId.c_str(),
+                                             APP2EXT_STATUS_SUCCESS);
+        } else {
+            m_handle->interface.post_upgrade(m_appId.c_str(),
+                                             APP2EXT_STATUS_FAILED);
+        }
     }
 }
 
index 1f5bc8c..7d2cb52 100644 (file)
@@ -21,6 +21,7 @@
 #include "wrt-installer.h"
 #include "plugin_utils.h"
 
+#include <map>
 #include <string>
 #include <cstring>
 #include <cstdlib>
@@ -191,6 +192,47 @@ void WrtInstaller::OnCreate()
             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();
@@ -294,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                "
@@ -944,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
index 9cd0173..b2288e3 100644 (file)
@@ -27,6 +27,7 @@
 #include <dpl/task.h>
 #include <dpl/string.h>
 #include <string>
+#include <map>
 #include <wrt_installer_api.h>
 
 namespace WRTInstallerNS { //anonymous
@@ -37,6 +38,14 @@ DECLARE_GENERIC_EVENT_0(InstallPluginEvent)
 
 typedef void (*ShowResultCallback)(void *data, Evas_Object *obj,
                                    void *event_info);
+namespace CSCConfiguration {
+typedef std::map<std::string, std::string> dataMap;
+typedef std::pair<std::string, std::string> dataPair;
+const char* const KEY_OP = "op";
+const char* const KEY_PATH = "path";
+const char* const VALUE_INSTALL = "install";
+const char* const VALUE_UNINSTALL = "uninstall";
+}
 
 enum ReturnValue
 {
@@ -109,6 +118,7 @@ class WrtInstaller :
 
     void installNewPlugins();
     bool popupsEnabled() const;
+    CSCConfiguration::dataMap parseCSCConfiguration(std::string str);
 
     // Private data
     std::shared_ptr<PackageManager::IPkgmgrSignal> pkgmgrSignalInterface;
@@ -122,6 +132,7 @@ class WrtInstaller :
     bool m_installByPkgmgr;
     bool m_quiet;
     bool m_startupPluginInstallation;
+    CSCConfiguration::dataMap m_CSCconfigurationMap;
 
     typedef std::list<std::string> PluginPathList;
     DPL::Optional<PluginPathList> m_pluginsPaths;