Upstream version 10.38.212.0 15/28115/1
authorEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Fri, 26 Sep 2014 08:43:24 +0000 (08:43 +0000)
committerEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Fri, 26 Sep 2014 08:43:24 +0000 (08:43 +0000)
Upstream commit-id b57db6aad3328fe5362714e34fae050882dee947

Change-Id: I8e03d3c1f1ba0e91282d70124ea29da84c99c0b4
Signed-off-by: Eurogiciel-BOT <eurogiciel.tizen@gmail.com>
13 files changed:
packaging/crosswalk.manifest
packaging/crosswalk.spec
src/xwalk/VERSION
src/xwalk/application/tools/tizen/xwalk_package_helper.cc [deleted file]
src/xwalk/application/tools/tizen/xwalk_package_installer.cc
src/xwalk/application/tools/tizen/xwalk_package_installer_helper.h [deleted file]
src/xwalk/application/tools/tizen/xwalk_platform_installer.cc [moved from src/xwalk/application/tools/tizen/xwalk_package_installer_helper.cc with 72% similarity]
src/xwalk/application/tools/tizen/xwalk_platform_installer.h [new file with mode: 0644]
src/xwalk/application/tools/tizen/xwalk_tizen_tools.gyp
src/xwalk/application/xwalk_application.gypi
src/xwalk/packaging/crosswalk.manifest
src/xwalk/packaging/crosswalk.spec
src/xwalk/tools/reflection_generator/java_method.py

index 4715caf..5398074 100644 (file)
@@ -6,6 +6,5 @@
     <filesystem path="/usr/bin/xwalk" exec_label="User" />
     <filesystem path="/usr/bin/xwalkctl" exec_label="User" />
     <filesystem path="/usr/bin/xwalk-launcher" exec_label="User" />
-    <filesystem path="/usr/bin/xwalk-pkg-helper" exec_label="User" />
  </assign>
 </manifest>
index faeca0b..b8c576a 100644 (file)
@@ -16,7 +16,7 @@
 %endif
 
 Name:           crosswalk
-Version:        10.38.210.0
+Version:        10.38.212.0
 Release:        0
 Summary:        Chromium-based app runtime
 License:        (BSD-3-Clause and LGPL-2.1+)
@@ -228,7 +228,7 @@ ${GYP_EXTRA_FLAGS} \
 -Dshared_process_mode=1 \
 -Denable_hidpi=1
 
-ninja %{?_smp_mflags} -C src/out/Release xwalk xwalkctl xwalk_launcher xwalk-pkg-helper xwalk-backendlib
+ninja %{?_smp_mflags} -C src/out/Release xwalk xwalk_launcher xwalk_application_tools
 
 %install
 # Binaries.
@@ -237,8 +237,6 @@ install -p -D xwalk.service %{buildroot}%{_systemduserservicedir}/xwalk.service
 install -p -D src/out/Release/xwalk %{buildroot}%{_libdir}/xwalk/xwalk
 install -p -D src/out/Release/xwalkctl %{buildroot}%{_bindir}/xwalkctl
 install -p -D src/out/Release/xwalk-launcher %{buildroot}%{_bindir}/xwalk-launcher
-# xwalk-pkg-helper needs to be set-user-ID-root so it can finish the installation process.
-install -m 0755 -p -D src/out/Release/xwalk-pkg-helper %{buildroot}%{_bindir}/xwalk-pkg-helper
 install -p -D src/out/Release/lib/libxwalk-backendlib.so %{buildroot}%{_libdir}/xwalk/libxwalk-backendlib.so
 install -p -D src/xwalk/application/tools/tizen/xwalk_backend_wrapper.sh %{buildroot}%{_libdir}/xwalk/xwalk_backend_wrapper.sh
 
@@ -283,7 +281,6 @@ ln -sf %{_libdir}/xwalk/xwalk_backend_wrapper.sh /etc/package-manager/backend/wg
 %license AUTHORS.chromium LICENSE.chromium LICENSE.xwalk
 %{_bindir}/xwalkctl
 %{_bindir}/xwalk-launcher
-%{_bindir}/xwalk-pkg-helper
 %{_libdir}/xwalk/icudtl.dat
 %{_libdir}/xwalk/libffmpegsumo.so
 %if ! %{_disable_nacl}
index a4fd7f2..2c762c0 100644 (file)
@@ -1,4 +1,4 @@
 MAJOR=10
 MINOR=38
-BUILD=210
+BUILD=212
 PATCH=0
diff --git a/src/xwalk/application/tools/tizen/xwalk_package_helper.cc b/src/xwalk/application/tools/tizen/xwalk_package_helper.cc
deleted file mode 100644 (file)
index fde8e78..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) 2013 Intel Corporation. All rights reserved.
-// Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// On Tizen installing applications requires super-user powers primarily because
-// some pieces of information of the application are put on globally accessible
-// locations. This helper will run with super-user powers (via suid) and will
-// be called by Crosswalk (now running as a normal user) so all the activities
-// that required 'root' access are done by a small code base.
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <string>
-
-#include "base/files/file_path.h"
-#include "base/file_util.h"
-#include "xwalk/application/tools/tizen/xwalk_package_installer_helper.h"
-
-namespace {
-
-char* install_option = NULL;
-char* update_option = NULL;
-char* uninstall_option = NULL;
-char* reinstall_option = NULL;
-char* operation_key = NULL;
-char* xml_path = NULL;
-char* icon_path = NULL;
-int quiet = 0;
-
-GOptionEntry entries[] = {
-  { "install", 'i', 0, G_OPTION_ARG_STRING, &install_option,
-    "Path of the application to be installed", "APPID" },
-  { "update", 'u', 0, G_OPTION_ARG_STRING, &update_option,
-    "Path of the application to be updated", "APPID" },
-  { "uninstall", 'd', 0, G_OPTION_ARG_STRING, &uninstall_option,
-    "Uninstall the application with this appid", "APPID" },
-  { "reinstall", 'r', 0, G_OPTION_ARG_STRING, &reinstall_option,
-    "Path of the application to be reinstalled", "APPID" },
-  { "key", 'k', 0, G_OPTION_ARG_STRING, &operation_key,
-    "Unique operation key", "KEY" },
-  { "quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet,
-    "Quiet mode", NULL },
-  { "xml", 'x', 0, G_OPTION_ARG_STRING, &xml_path,
-    "Xml file", "XML_FILE" },
-  { "icon", 'y', 0, G_OPTION_ARG_STRING, &icon_path,
-    "Icon file", "ICON_FILE" },
-  { NULL }
-};
-
-}  // namespace
-
-int main(int argc, char *argv[]) {
-  GError* error = NULL;
-  GOptionContext* context;
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
-  // g_type_init() is deprecated on GLib since 2.36, Tizen has 2.32.
-  g_type_init();
-#endif
-
-  context = g_option_context_new(
-        " - Crosswalk Tizen Application Installation helper");
-  if (!context) {
-    fprintf(stderr, "g_option_context_new failed\n");
-    exit(1);
-  }
-  g_option_context_add_main_entries(context, entries, NULL);
-  if (!g_option_context_parse(context, &argc, &argv, &error)) {
-    fprintf(stderr, "option parsing failed: %s\n", error->message);
-    g_option_context_free(context);
-    exit(1);
-  }
-  g_option_context_free(context);
-
-  bool result = false;
-
-  // args for pkgmgr
-  const char* pkgmgr_argv[5];
-  pkgmgr_argv[2] = "-k";
-  pkgmgr_argv[3] = operation_key;
-  pkgmgr_argv[4] = "-q";
-
-  char* appId = NULL;
-  if (install_option) {
-    appId = install_option;
-  } else if (uninstall_option) {
-    appId = uninstall_option;
-  } else if (update_option) {
-    appId = update_option;
-  } else if (reinstall_option) {
-    appId = reinstall_option;
-  } else {
-    fprintf(stderr, "Use: --install, --uninstall, --update or --reinstall\n");
-    exit(1);
-  }
-
-  PackageInstallerHelper helper(appId);
-
-  if (install_option) {
-    if (!xml_path || !icon_path) {
-      fprintf(stdout, "missing --xml or --icon option\n");
-      exit(1);
-    }
-
-     if (operation_key) {
-      pkgmgr_argv[0] = "-i";
-      pkgmgr_argv[1] = install_option;  // this value is ignored by pkgmgr
-      helper.InitializePkgmgrSignal((quiet ? 5 : 4), pkgmgr_argv);
-    }
-
-    result = helper.InstallApplication(xml_path, icon_path);
-  } else if (uninstall_option) {
-    if (operation_key) {
-      pkgmgr_argv[0] = "-d";
-      pkgmgr_argv[1] = uninstall_option;  // this value is ignored by pkgmgr
-      helper.InitializePkgmgrSignal((quiet ? 5 : 4), pkgmgr_argv);
-    }
-
-    result = helper.UninstallApplication();
-  } else if (update_option) {
-    if (!xml_path || !icon_path) {
-      fprintf(stderr, "missing --xml or --icon option\n");
-      exit(1);
-    }
-
-    if (operation_key) {
-      pkgmgr_argv[0] = "-i";
-      pkgmgr_argv[1] = update_option;  // this value is ignored by pkgmgr
-      helper.InitializePkgmgrSignal((quiet ? 5 : 4), pkgmgr_argv);
-    }
-
-    result = helper.UpdateApplication(xml_path, icon_path);
-  } else if (reinstall_option) {
-    if (operation_key) {
-      pkgmgr_argv[0] = "-r";
-      pkgmgr_argv[1] = reinstall_option;  // this value is ignored by pkgmgr
-      helper.InitializePkgmgrSignal((quiet ? 5 : 4), pkgmgr_argv);
-    }
-
-    result = helper.ReinstallApplication();
-  }
-
-  // Convention is to return 0 on success.
-  return result ? 0 : 1;
-}
index 3509ee2..f80d9d3 100644 (file)
@@ -17,8 +17,6 @@
 #include "base/files/file_enumerator.h"
 #include "base/logging.h"
 #include "base/path_service.h"
-#include "base/command_line.h"
-#include "base/process/launch.h"
 #include "base/version.h"
 #include "third_party/libxml/chromium/libxml_utils.h"
 #include "xwalk/application/common/application_data.h"
@@ -30,6 +28,7 @@
 #include "xwalk/application/common/permission_policy_manager.h"
 #include "xwalk/application/common/tizen/application_storage.h"
 #include "xwalk/application/tools/tizen/xwalk_packageinfo_constants.h"
+#include "xwalk/application/tools/tizen/xwalk_platform_installer.h"
 #include "xwalk/runtime/common/xwalk_paths.h"
 
 namespace info = application_packageinfo_constants;
@@ -53,8 +52,6 @@ const base::FilePath::CharType kUpdateTempDir[] =
 
 namespace widget_keys = xwalk::application_widget_keys;
 
-const base::FilePath kPkgHelper("/usr/bin/xwalk-pkg-helper");
-
 const base::FilePath kXWalkLauncherBinary("/usr/bin/xwalk-launcher");
 
 const base::FilePath kDefaultIcon(
@@ -242,78 +239,53 @@ bool PackageInstaller::PlatformInstall(ApplicationData* app_data) {
   base::FilePath icon =
       icon_name.empty() ? kDefaultIcon : app_dir.AppendASCII(icon_name);
 
-  CommandLine cmdline(kPkgHelper);
-  cmdline.AppendSwitchASCII("--install", app_id);
-  cmdline.AppendSwitchPath("--xml", xml_path);
-  cmdline.AppendSwitchPath("--icon", icon);
-  if (quiet_)
-    cmdline.AppendSwitch("-q");
-  if (!key_.empty()) {
-    cmdline.AppendSwitchASCII("--key", key_);
-  }
+  // args for pkgmgr
+  const char* pkgmgr_argv[5];
+  pkgmgr_argv[2] = "-k";
+  pkgmgr_argv[3] = key_.c_str();
+  pkgmgr_argv[4] = "-q";
 
-  int exit_code;
-  std::string output;
+  PlatformInstaller platform_installer(app_id);
 
-  if (!base::GetAppOutputWithExitCode(cmdline, &output, &exit_code)) {
-    LOG(ERROR) << "Could not launch the installation helper process.";
+  if (xml_path.empty() || icon.empty()) {
+    LOG(ERROR) << "Xml or icon path is empty";
     return false;
   }
 
-  if (exit_code != 0) {
-    LOG(ERROR) << "Could not install application: "
-               << output << " (" << exit_code << ")";
-    return false;
+  if (!key_.empty()) {
+    pkgmgr_argv[0] = "-i";
+    pkgmgr_argv[1] = app_id.c_str();  // this value is ignored by pkgmgr
+    platform_installer.InitializePkgmgrSignal((quiet_ ? 5 : 4), pkgmgr_argv);
   }
 
+  if (!platform_installer.InstallApplication(xml_path, icon))
+    return false;
+
   app_dir_cleaner.Dismiss();
 
   return true;
 }
 
 bool PackageInstaller::PlatformUninstall(ApplicationData* app_data) {
-  bool result = true;
   std::string app_id(app_data->ID());
   base::FilePath data_dir;
   CHECK(PathService::Get(xwalk::DIR_DATA_PATH, &data_dir));
 
-  CommandLine cmdline(kPkgHelper);
-  cmdline.AppendSwitchASCII("--uninstall", app_id);
-  if (quiet_)
-    cmdline.AppendSwitch("-q");
-  if (!key_.empty()) {
-    cmdline.AppendSwitchASCII("--key", key_);
-  }
-
-  int exit_code;
-  std::string output;
+  // args for pkgmgr
+  const char* pkgmgr_argv[5];
+  pkgmgr_argv[2] = "-k";
+  pkgmgr_argv[3] = key_.c_str();
+  pkgmgr_argv[4] = "-q";
 
-  if (!base::GetAppOutputWithExitCode(cmdline, &output, &exit_code)) {
-    LOG(ERROR) << "Could not launch installer helper";
-    result = false;
-  }
-
-  if (exit_code != 0) {
-    LOG(ERROR) << "Could not uninstall application: "
-               << output << " (" << exit_code << ")";
-    result = false;
-  }
+  PlatformInstaller platform_installer(app_id);
 
-  base::FilePath app_dir =
-      data_dir.AppendASCII(info::kAppDir).AppendASCII(app_id);
-  if (!base::DeleteFile(app_dir, true)) {
-    LOG(ERROR) << "Could not remove directory '" << app_dir.value() << "'";
-    result = false;
-  }
-
-  base::FilePath xml_path = data_dir.AppendASCII(
-      app_id + std::string(info::kXmlExtension));
-  if (!base::DeleteFile(xml_path, false)) {
-    LOG(ERROR) << "Could not remove file '" << xml_path.value() << "'";
-    result = false;
+  if (!key_.empty()) {
+    pkgmgr_argv[0] = "-d";
+    pkgmgr_argv[1] = app_id.c_str();  // this value is ignored by pkgmgr
+    platform_installer.InitializePkgmgrSignal((quiet_ ? 5 : 4), pkgmgr_argv);
   }
 
-  return result;
+  return platform_installer.UninstallApplication();
 }
 
 bool PackageInstaller::PlatformUpdate(ApplicationData* app_data) {
@@ -347,61 +319,43 @@ bool PackageInstaller::PlatformUpdate(ApplicationData* app_data) {
   base::FilePath icon =
       icon_name.empty() ? kDefaultIcon : app_dir.AppendASCII(icon_name);
 
-  CommandLine cmdline(kPkgHelper);
-  cmdline.AppendSwitchASCII("--update", app_id);
-  cmdline.AppendSwitchPath("--xml", new_xml_path);
-  cmdline.AppendSwitchPath("--icon", icon);
-  if (quiet_)
-    cmdline.AppendSwitch("-q");
-  if (!key_.empty()) {
-    cmdline.AppendSwitchASCII("--key", key_);
-  }
+  // args for pkgmgr
+  const char* pkgmgr_argv[5];
+  pkgmgr_argv[2] = "-k";
+  pkgmgr_argv[3] = key_.c_str();
+  pkgmgr_argv[4] = "-q";
 
-  int exit_code;
-  std::string output;
+  PlatformInstaller platform_installer(app_id);
 
-  if (!base::GetAppOutputWithExitCode(cmdline, &output, &exit_code)) {
-    LOG(ERROR) << "Could not launch installer helper";
-    return false;
+  if (!key_.empty()) {
+    pkgmgr_argv[0] = "-i";
+    pkgmgr_argv[1] = app_id.c_str();  // this value is ignored by pkgmgr
+    platform_installer.InitializePkgmgrSignal((quiet_ ? 5 : 4), pkgmgr_argv);
   }
 
-  if (exit_code != 0) {
-    LOG(ERROR) << "Could not update application: "
-               << output << " (" << exit_code << ")";
+  if (!platform_installer.InstallApplication(new_xml_path, icon))
     return false;
-  }
 
-  base::FilePath old_xml_path = data_dir.AppendASCII(info::kAppDir).AppendASCII(
-      app_id + std::string(info::kXmlExtension));
-  base::Move(new_xml_path, old_xml_path);
   app_dir_cleaner.Dismiss();
   return true;
 }
 
 bool PackageInstaller::PlatformReinstall(const base::FilePath& path) {
-  CommandLine cmdline(kPkgHelper);
-  cmdline.AppendSwitchPath("--reinstall", path);
-  if (quiet_)
-    cmdline.AppendSwitch("-q");
-  if (!key_.empty()) {
-    cmdline.AppendSwitchASCII("--key", key_);
-  }
+  // args for pkgmgr
+  const char* pkgmgr_argv[5];
+  pkgmgr_argv[2] = "-k";
+  pkgmgr_argv[3] = key_.c_str();
+  pkgmgr_argv[4] = "-q";
 
-  int exit_code;
-  std::string output;
+  PlatformInstaller platform_installer;
 
-  if (!base::GetAppOutputWithExitCode(cmdline, &output, &exit_code)) {
-    LOG(ERROR) << "Could not launch installer helper";
-    return false;
-  }
-
-  if (exit_code != 0) {
-    LOG(ERROR) << "Could not reinstall application: "
-               << output << " (" << exit_code << ")";
-    return false;
+  if (!key_.empty()) {
+    pkgmgr_argv[0] = "-r";
+    pkgmgr_argv[1] = path.value().c_str();  // this value is ignored by pkgmgr
+    platform_installer.InitializePkgmgrSignal((quiet_ ? 5 : 4), pkgmgr_argv);
   }
 
-  return true;
+  return platform_installer.ReinstallApplication();
 }
 
 bool PackageInstaller::Install(const base::FilePath& path, std::string* id) {
diff --git a/src/xwalk/application/tools/tizen/xwalk_package_installer_helper.h b/src/xwalk/application/tools/tizen/xwalk_package_installer_helper.h
deleted file mode 100644 (file)
index ba90c17..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2014 Intel Corporation. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PACKAGE_INSTALLER_HELPER_H_
-#define XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PACKAGE_INSTALLER_HELPER_H_
-
-#include <pkgmgr_installer.h>
-
-#include <string>
-
-class PackageInstallerHelper {
- public:
-  explicit PackageInstallerHelper(const std::string& appid);
-  ~PackageInstallerHelper();
-  bool InitializePkgmgrSignal(int argc, const char** argv);
-
-  bool InstallApplication(const std::string& xmlpath,
-                          const std::string& iconpath);
-  bool UninstallApplication();
-  bool UpdateApplication(const std::string& xmlpath,
-                         const std::string& iconpath);
-  bool ReinstallApplication();
-
- private:
-  bool InstallApplicationInternal(const std::string& xmlpath,
-                                  const std::string& iconpath);
-  bool UninstallApplicationInternal();
-  bool UpdateApplicationInternal(const std::string& xmlpath,
-                                 const std::string& iconpath);
-
-  bool SendSignal(const std::string& key, const std::string& value);
-
-  pkgmgr_installer* handle_;
-
-  std::string appid_;
-  std::string pkgid_;
-};
-
-#endif  // XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PACKAGE_INSTALLER_HELPER_H_
@@ -2,17 +2,17 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "xwalk/application/tools/tizen/xwalk_package_installer_helper.h"
+#include "xwalk/application/tools/tizen/xwalk_platform_installer.h"
 
 #include <assert.h>
-#include <stdio.h>
 #include <pkgmgr/pkgmgr_parser.h>
 #include <tzplatform_config.h>
 
-#undef LOG
 #include <string>
+
 #include "base/files/file_path.h"
 #include "base/file_util.h"
+#include "base/logging.h"
 #include "xwalk/application/common/id_util.h"
 
 namespace {
@@ -95,8 +95,8 @@ bool CopyFileToDst(const base::FilePath& file_src,
   if (!base::PathExists(dir))
     base::CreateDirectory(dir);
   if (!base::CopyFile(file_src, file_dst)) {
-    fprintf(stdout, "Couldn't copy application file from %s to '%s'\n",
-         file_src.value().c_str(), file_dst.value().c_str());
+    LOG(ERROR) << "Couldn't copy application file from "
+        << file_src.value() << " to " << file_dst.value();
     return false;
   }
   return true;
@@ -104,69 +104,72 @@ bool CopyFileToDst(const base::FilePath& file_src,
 
 }  // namespace
 
-PackageInstallerHelper::PackageInstallerHelper(const std::string& appid)
+PlatformInstaller::PlatformInstaller()
+    : handle_(NULL) {
+}
+
+PlatformInstaller::PlatformInstaller(const std::string& appid)
     : handle_(NULL),
       appid_(appid),
       pkgid_(xwalk::application::AppIdToPkgId(appid)) {
   if (appid_.empty())
-    fprintf(stdout, "Invalid app id is provided for pkg installer.\n");
+    LOG(ERROR) << "Invalid app id is provided for pkg installer";
 }
 
-PackageInstallerHelper::~PackageInstallerHelper() {
+PlatformInstaller::~PlatformInstaller() {
   if (handle_)
     pkgmgr_installer_free(handle_);
 }
 
-bool PackageInstallerHelper::InitializePkgmgrSignal(int argc,
-                                                    const char** argv) {
+bool PlatformInstaller::InitializePkgmgrSignal(int argc,
+    const char** argv) {
   handle_ = pkgmgr_installer_new();
   if (!handle_) {
-    fprintf(stdout, "Fail to get package manager installer handle.\n");
+    LOG(ERROR) << "Fail to get package manager installer handle";
     return false;
   }
 
+  LOG(INFO) << "Initializing pkgmgr request...";
   return pkgmgr_installer_receive_request(handle_,
                                           argc,
                                           const_cast<char**>(argv));
 }
 
-bool PackageInstallerHelper::InstallApplication(
-    const std::string& xmlpath,
-    const std::string& iconpath) {
+bool PlatformInstaller::InstallApplication(const base::FilePath& xmlpath,
+    const base::FilePath& iconpath) {
   SendSignal(PKGMGR_START_KEY, PKGMGR_START_INSTALL);
   bool ret = InstallApplicationInternal(xmlpath, iconpath);
   SendSignal(PKGMGR_END_KEY, ToEndStatus(ret));
   return ret;
 }
 
-bool PackageInstallerHelper::UninstallApplication() {
+bool PlatformInstaller::UninstallApplication() {
   SendSignal(PKGMGR_START_KEY, PKGMGR_START_UNINSTALL);
   bool ret = UninstallApplicationInternal();
   SendSignal(PKGMGR_END_KEY, ToEndStatus(ret));
   return ret;
 }
 
-bool PackageInstallerHelper::UpdateApplication(
-    const std::string& xmlpath,
-    const std::string& iconpath) {
+bool PlatformInstaller::UpdateApplication(const base::FilePath& xmlpath,
+    const base::FilePath& iconpath) {
   SendSignal(PKGMGR_START_KEY, PKGMGR_START_UPDATE);
   bool ret = UpdateApplicationInternal(xmlpath, iconpath);
   SendSignal(PKGMGR_END_KEY, ToEndStatus(ret));
   return ret;
 }
 
-bool PackageInstallerHelper::ReinstallApplication() {
+bool PlatformInstaller::ReinstallApplication() {
   SendSignal(PKGMGR_START_KEY, PKGMGR_START_REINSTALL);
   // FIXME not implemented, just send signal abotu failure
   SendSignal(PKGMGR_END_KEY, ToEndStatus(false));
   return false;
 }
 
-bool PackageInstallerHelper::InstallApplicationInternal(
-    const std::string& xmlpath,
-    const std::string& iconpath) {
+bool PlatformInstaller::InstallApplicationInternal(
+    const base::FilePath& xmlpath,
+    const base::FilePath& iconpath) {
   if (xmlpath.empty() || iconpath.empty()) {
-    fprintf(stdout, "Invalid xml path or icon path for installation\n");
+    LOG(ERROR) << "Invalid xml path or icon path for installation";
   }
   base::FilePath global_xml(tzplatform_mkpath(TZ_SYS_RO_PACKAGES, "/"));
   base::FilePath global_icon(tzplatform_mkpath(TZ_SYS_RO_ICONS, kIconDir));
@@ -187,24 +190,24 @@ bool PackageInstallerHelper::InstallApplicationInternal(
   FileDeleter xml_cleaner(xml_dst, false);
   FileDeleter icon_cleaner(icon_dst, false);
 
-
-  if (!CopyFileToDst(base::FilePath(xmlpath), xml_dst)
-     || !CopyFileToDst(base::FilePath(iconpath), icon_dst))
+  if (!CopyFileToDst(xmlpath, xml_dst)
+     || !CopyFileToDst(iconpath, icon_dst))
     return false;
 
-  fprintf(stdout, "uid for installation : '%d'\n", uid);
+  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.c_str(),
+    if (pkgmgr_parser_parse_usr_manifest_for_installation(
+        xmlpath.value().c_str(),
         uid, const_cast<char**>(pkgmgr_tags))) {
-      fprintf(stdout, "Couldn't parse manifest XML '%s', uid : '%d'\n",
-              xmlpath.c_str(), uid);
+      LOG(ERROR) << "Couldn't parse manifest XML '"
+          << xmlpath.value().c_str() << "', uid : " << uid;
       return false;
     }
   } else {  // For all users
-    if (pkgmgr_parser_parse_manifest_for_installation(xmlpath.c_str(),
-                                            const_cast<char**>(pkgmgr_tags))) {
-      fprintf(stdout, "Couldn't parse manifest XML '%s', uid : '%d'\n",
-           xmlpath.c_str(), uid);
+    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";
       return false;
     }
   }
@@ -214,7 +217,7 @@ bool PackageInstallerHelper::InstallApplicationInternal(
   return true;
 }
 
-bool PackageInstallerHelper::UninstallApplicationInternal() {
+bool PlatformInstaller::UninstallApplicationInternal() {
   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, "/"));
@@ -240,16 +243,16 @@ bool PackageInstallerHelper::UninstallApplicationInternal() {
   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)) {
-      fprintf(stdout, "Couldn't parse manifest XML '%s'\n",
-              xmlpath_str.c_str());
+      LOG(ERROR) << "Couldn't parse manifest XML '" << xmlpath_str << "', uid"
+          << uid;
       icon_cleaner.Dismiss();
       xml_cleaner.Dismiss();
     }
   } else {  // For all users
     if (pkgmgr_parser_parse_manifest_for_uninstallation(
         xmlpath_str.c_str(), NULL)) {
-      fprintf(stdout, "Couldn't parse manifest XML '%s'\n",
-              xmlpath_str.c_str());
+      LOG(ERROR) << "Couldn't parse manifest XML '" << xmlpath_str
+          << "' for global uninstallation";
       icon_cleaner.Dismiss();
       xml_cleaner.Dismiss();
     }
@@ -257,11 +260,10 @@ bool PackageInstallerHelper::UninstallApplicationInternal() {
   return true;
 }
 
-bool PackageInstallerHelper::UpdateApplicationInternal(
-    const std::string& xmlpath,
-    const std::string& iconpath) {
+bool PlatformInstaller::UpdateApplicationInternal(
+    const base::FilePath& xmlpath, const base::FilePath& iconpath) {
   if (xmlpath.empty() || iconpath.empty()) {
-    fprintf(stdout, "Invalid xml path or icon path for update\n");
+    LOG(ERROR) << "Invalid xml path or icon path for update";
   }
 
   base::FilePath global_xml(tzplatform_mkpath(TZ_SYS_RO_PACKAGES, "/"));
@@ -285,20 +287,22 @@ bool PackageInstallerHelper::UpdateApplicationInternal(
   FileDeleter icon_cleaner(icon_dst, false);
 
 
-  if (!CopyFileToDst(base::FilePath(xmlpath), xml_dst)
-     || !CopyFileToDst(base::FilePath(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.c_str(), uid,
-        const_cast<char**>(pkgmgr_tags))) {
-      fprintf(stdout, "Couldn't parse manifest XML '%s'\n", xmlpath.c_str());
+    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;
       return false;
     }
   } else {  // For all users
-    if (pkgmgr_parser_parse_manifest_for_upgrade(xmlpath.c_str(),
-                                            const_cast<char**>(pkgmgr_tags))) {
-      fprintf(stdout, "Couldn't parse manifest XML '%s'\n", xmlpath.c_str());
+    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";
       return false;
      }
   }
@@ -309,7 +313,7 @@ bool PackageInstallerHelper::UpdateApplicationInternal(
   return true;
 }
 
-bool PackageInstallerHelper::SendSignal(
+bool PlatformInstaller::SendSignal(
     const std::string& key,
     const std::string& value) {
   if (!handle_) {
@@ -318,14 +322,14 @@ bool PackageInstallerHelper::SendSignal(
   }
 
   if (key.empty() || value.empty()) {
-    fprintf(stdout, " Fail to send signal, key/value is empty.\n");
+    LOG(ERROR) << "Fail to send signal, key/value is empty";
     return false;
   }
 
   if (pkgmgr_installer_send_signal(
           handle_, PKGMGR_PKG_TYPE, pkgid_.c_str(),
           key.c_str(), value.c_str())) {
-    fprintf(stdout, "Fail to send package manager signal.\n");
+    LOG(ERROR) << "Fail to send package manager signal";
   }
 
   return true;
diff --git a/src/xwalk/application/tools/tizen/xwalk_platform_installer.h b/src/xwalk/application/tools/tizen/xwalk_platform_installer.h
new file mode 100644 (file)
index 0000000..5867ce2
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PLATFORM_INSTALLER_H_
+#define XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PLATFORM_INSTALLER_H_
+
+#include <pkgmgr_installer.h>
+
+#include <string>
+
+#include "base/files/file_path.h"
+
+class PlatformInstaller {
+ public:
+  PlatformInstaller();
+  explicit PlatformInstaller(const std::string& appid);
+  ~PlatformInstaller();
+  bool InitializePkgmgrSignal(int argc, const char** argv);
+
+  bool InstallApplication(const base::FilePath& xmlpath,
+                          const base::FilePath& iconpath);
+  bool UninstallApplication();
+  bool UpdateApplication(const base::FilePath& xmlpath,
+                         const base::FilePath& iconpath);
+  bool ReinstallApplication();
+
+ private:
+  bool InstallApplicationInternal(const base::FilePath& xmlpath,
+                                  const base::FilePath& iconpath);
+  bool UninstallApplicationInternal();
+  bool UpdateApplicationInternal(const base::FilePath& xmlpath,
+                                 const base::FilePath& iconpath);
+
+  bool SendSignal(const std::string& key, const std::string& value);
+
+  pkgmgr_installer* handle_;
+
+  std::string appid_;
+  std::string pkgid_;
+};
+
+#endif  // XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PLATFORM_INSTALLER_H_
index 91d992d..530b680 100644 (file)
@@ -20,6 +20,8 @@
         'xwalk_package_installer.h',
         'xwalk_packageinfo_constants.cc',
         'xwalk_packageinfo_constants.h',
+        'xwalk_platform_installer.cc',
+        'xwalk_platform_installer.h',
         'xwalk_tizen_user.cc',
         'xwalk_tizen_user.h',
         # TODO(t.iwanek) fix me - this duplicates compilation of those files
         '../../../runtime/common/xwalk_system_locale.cc',
         '../../../runtime/common/xwalk_system_locale.h',
       ],
-    },  
-    {
-      'target_name': 'xwalk-pkg-helper',
-      'type': 'executable',
-      'product_name': 'xwalk-pkg-helper',
-      'dependencies': [
-        '../../../build/system.gyp:tizen',
-        '../../../build/system.gyp:gio',
-        '../../../../base/base.gyp:base',
-        '../../common/xwalk_application_common.gypi:xwalk_application_common_lib',
-      ],
-      'include_dirs': [
-        '../../../..',
-      ],
-      'cflags': [
-        '<!@(pkg-config --cflags libtzplatform-config)',
-      ],
-      'link_settings': {
-        'libraries': [
-          '<!@(pkg-config --libs libtzplatform-config)',
-        ],
-      },
-      'sources': [
-        'xwalk_package_helper.cc',
-        'xwalk_package_installer_helper.cc',
-        'xwalk_package_installer_helper.h',
-      ],
     },
     {
       'target_name': 'xwalk-backendlib',
index d4ab10f..ac8d5d6 100644 (file)
         ['tizen == 1', {
           'dependencies': [
             'application/tools/tizen/xwalk_tizen_tools.gyp:xwalkctl',
-            'application/tools/tizen/xwalk_tizen_tools.gyp:xwalk-pkg-helper',
             'application/tools/tizen/xwalk_tizen_tools.gyp:xwalk-backendlib',
           ],
         }],
index 4715caf..5398074 100644 (file)
@@ -6,6 +6,5 @@
     <filesystem path="/usr/bin/xwalk" exec_label="User" />
     <filesystem path="/usr/bin/xwalkctl" exec_label="User" />
     <filesystem path="/usr/bin/xwalk-launcher" exec_label="User" />
-    <filesystem path="/usr/bin/xwalk-pkg-helper" exec_label="User" />
  </assign>
 </manifest>
index faeca0b..b8c576a 100644 (file)
@@ -16,7 +16,7 @@
 %endif
 
 Name:           crosswalk
-Version:        10.38.210.0
+Version:        10.38.212.0
 Release:        0
 Summary:        Chromium-based app runtime
 License:        (BSD-3-Clause and LGPL-2.1+)
@@ -228,7 +228,7 @@ ${GYP_EXTRA_FLAGS} \
 -Dshared_process_mode=1 \
 -Denable_hidpi=1
 
-ninja %{?_smp_mflags} -C src/out/Release xwalk xwalkctl xwalk_launcher xwalk-pkg-helper xwalk-backendlib
+ninja %{?_smp_mflags} -C src/out/Release xwalk xwalk_launcher xwalk_application_tools
 
 %install
 # Binaries.
@@ -237,8 +237,6 @@ install -p -D xwalk.service %{buildroot}%{_systemduserservicedir}/xwalk.service
 install -p -D src/out/Release/xwalk %{buildroot}%{_libdir}/xwalk/xwalk
 install -p -D src/out/Release/xwalkctl %{buildroot}%{_bindir}/xwalkctl
 install -p -D src/out/Release/xwalk-launcher %{buildroot}%{_bindir}/xwalk-launcher
-# xwalk-pkg-helper needs to be set-user-ID-root so it can finish the installation process.
-install -m 0755 -p -D src/out/Release/xwalk-pkg-helper %{buildroot}%{_bindir}/xwalk-pkg-helper
 install -p -D src/out/Release/lib/libxwalk-backendlib.so %{buildroot}%{_libdir}/xwalk/libxwalk-backendlib.so
 install -p -D src/xwalk/application/tools/tizen/xwalk_backend_wrapper.sh %{buildroot}%{_libdir}/xwalk/xwalk_backend_wrapper.sh
 
@@ -283,7 +281,6 @@ ln -sf %{_libdir}/xwalk/xwalk_backend_wrapper.sh /etc/package-manager/backend/wg
 %license AUTHORS.chromium LICENSE.chromium LICENSE.xwalk
 %{_bindir}/xwalkctl
 %{_bindir}/xwalk-launcher
-%{_bindir}/xwalk-pkg-helper
 %{_libdir}/xwalk/icudtl.dat
 %{_libdir}/xwalk/libffmpegsumo.so
 %if ! %{_disable_nacl}
index 2540bc4..077a8ed 100644 (file)
@@ -36,6 +36,58 @@ def HasCreateInternally(java_data):
     return java_data.HasCreateInternallyAnnotation()
 
 
+class ParamType(object):
+  """Internal representation of the type of a parameter of a method."""
+  def __init__(self, expression, class_loader):
+    self._expression = expression
+    self._modifier = ''
+    self._generic_type = ''
+    self._generic_type_parameters = []
+    self._contains_internal_class = False
+    self.ParseType(class_loader)
+    self._contains_internal_class = self._contains_internal_class or\
+        class_loader.IsInternalClass(self._generic_type)
+
+  def ParseType(self, class_loader):
+    param_type_re = re.compile('(?P<modifier>(\w+ )*)'
+                               '(?P<generic>(\w+))(?P<type_params>(<.*>)?)')
+    for match in re.finditer(param_type_re, self._expression):
+      self._modifier = match.group('modifier')
+      self._generic_type = match.group('generic')
+      type_params = match.group('type_params')
+      if len(type_params) > 1:
+        type_params = type_params[1:-1]
+        self._generic_type_parameters = [ParamType(param.strip(),
+            class_loader) for param in type_params.split(',')]
+
+    for type_param in self._generic_type_parameters:
+      if self.generic_type == 'ValueCallback':
+        print 'value callback with %s' % type_param.generic_type
+      if type_param.contains_internal_class:
+        self._contains_internal_class = True
+        break
+
+  @property
+  def expression(self):
+    return self._expression
+
+  @property
+  def modifier(self):
+    return self._modifier
+
+  @property
+  def generic_type(self):
+    return self._generic_type
+
+  @property
+  def generic_type_parameters(self):
+    return self._generic_type_parameters
+
+  @property
+  def contains_internal_class(self):
+    return self._contains_internal_class
+
+
 class ParamStringType(object):
   INTERNAL_DECLARE = 1
   BRIDGE_DECLARE = 2
@@ -77,6 +129,7 @@ class Method(object):
     self._method_name = method_name
     self._method_return = method_return
     self._params = OrderedDict() # Use OrderedDict to avoid parameter misorder.
+    self._typed_params = OrderedDict()
     self._method_annotations = {}
     self._method_doc = doc
     self._class_java_data = ''
@@ -129,6 +182,10 @@ class Method(object):
     return self._params
 
   @property
+  def typed_params(self):
+    return self._typed_params
+
+  @property
   def method_annotations(self):
     return self._method_annotations
 
@@ -147,6 +204,7 @@ class Method(object):
       param_type = ' '.join(param_list[:-1]) # To handle modifiers
       param_name = param_list[-1]
       self._params[param_name] = param_type
+      self._typed_params[param_name] = ParamType(param_type, self._class_loader)
 
   def ParseMethodAnnotation(self, annotation):
     pre_wrapline_re = re.compile('preWrapperLines\s*=\s*\{\s*('
@@ -242,6 +300,7 @@ class Method(object):
     is_internal_class = self.IsInternalClass(param_type)
     if is_internal_class:
       java_data = self.LoadJavaClass(param_type)
+    typed_param = self._typed_params[param_name]
     if param_string_type == ParamStringType.INTERNAL_DECLARE:
       # the way internal declares its params, will be used in bridge's override
       # call.
@@ -285,6 +344,20 @@ class Method(object):
       #   DirectionInternal direction => ConvertDirectionInternal(direction)
       if is_internal_class:
         return java_data.UseAsInstanceInBridgeCall(param_name)
+      elif (typed_param.generic_type == 'ValueCallback' and
+          typed_param.contains_internal_class):
+        assert len(typed_param.generic_type_parameters) == 1
+        internal_generic_type_param = typed_param.generic_type_parameters[0]
+        internal_generic_type_class = self.LoadJavaClass(
+            internal_generic_type_param.generic_type)
+        return ('new ValueCallback<Object>() {\n' +
+          '                @Override\n' +
+          '                public void onReceiveValue(Object value) {\n' +
+          '                    %sFinal.onReceiveValue((%s) ' % (
+              param_name, internal_generic_type_class.bridge_name) +
+          'ReflectionHelper.getBridgeOrWrapper(value));\n' +
+          '                }\n' +
+          '            }')
       else:
         # TODO(wang16): Here only detects enum declared in the same class as
         # the method itself. Using enum across class is not supported.
@@ -426,47 +499,21 @@ class Method(object):
     if return_is_internal:
       return_type_java_data = self.LoadJavaClass(self._method_return)
 
-    match_obj = re.search(
-        r'ValueCallback<([A-Za-z]+)Internal> ([a-zA-Z0-9_$]+)(,|$)', 
-        self._bridge_params_declare)
-    if match_obj :
-      callback_type = match_obj.group(1)
-      callback = match_obj.group(2)
-
-      template = Template(
-          '    public ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
-          '        final ValueCallback<' + callback_type + 'Internal> ' + 
-          callback + '2 = ' +  callback + ';\n' +
-          '        ${RETURN}ReflectionHelper.invokeMethod(\n' +
-          '            ${METHOD_DECLARE_NAME}, wrapper${PARAMS_PASSING});\n' +
-          '    }\n\n')
-
-      params_passing = re.sub(
-          str(callback),
-          '\n            new ValueCallback<Object>() {\n' +
-          '                @Override\n' +
-          '                public void onReceiveValue(Object value) {\n' +
-          '                    ' + callback + '2.onReceiveValue((' + 
-          callback_type + 
-          'Bridge) ReflectionHelper.getBridgeOrWrapper(value));\n' +
-          '                }\n' +
-          '            }',
-          self._bridge_params_pass_to_wrapper)
-    elif return_is_internal:
+    if return_is_internal:
       template = Template(
           '    public ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
+          '${GENERIC_TYPE_DECLARE}' +
           '        ${RETURN}ReflectionHelper.getBridgeOrWrapper(' + 
           'ReflectionHelper.invokeMethod(\n' +
           '            ${METHOD_DECLARE_NAME}, wrapper${PARAMS_PASSING}));\n' +
           '    }\n\n')
-      params_passing = self._bridge_params_pass_to_wrapper
     else :
       template = Template(
           '    public ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
+          '${GENERIC_TYPE_DECLARE}' +
           '        ${RETURN}ReflectionHelper.invokeMethod(\n' +
           '            ${METHOD_DECLARE_NAME}, wrapper${PARAMS_PASSING});\n' +
           '    }\n\n')
-      params_passing = self._bridge_params_pass_to_wrapper
 
     if no_return_value:
       return_statement = ''
@@ -475,12 +522,24 @@ class Method(object):
     else:
       return_statement = 'return (%s)' % (
           ConvertPrimitiveTypeToObject(self.method_return))
+
+    # Handling generic types, current only ValueCallback will be handled.
+    generic_type_declare = ''
+    for param_name in self._typed_params:
+      typed_param = self._typed_params[param_name]
+      if typed_param.generic_type != 'ValueCallback':
+        continue
+      if typed_param.contains_internal_class:
+        generic_type_declare += '        final %s %sFinal = %s;\n' % (
+            typed_param.expression, param_name, param_name)
+
     value = {'RETURN_TYPE': self.method_return,
              'NAME': self.method_name,
              'METHOD_DECLARE_NAME': self._method_declare_name,
              'PARAMS': self._bridge_params_declare,
              'RETURN': return_statement,
-             'PARAMS_PASSING': params_passing}
+             'GENERIC_TYPE_DECLARE': generic_type_declare,
+             'PARAMS_PASSING': self._bridge_params_pass_to_wrapper}
     return template.substitute(value)
 
   def GenerateBridgeSuperMethod(self):
@@ -583,6 +642,7 @@ class Method(object):
   def GenerateWrapperStaticMethod(self):
     no_return_value = self._method_return == 'void'
     template = Template(
+        '${DOC}\n' +
         '    public static ${RETURN_TYPE} ${NAME}(${PARAMS}) {\n' +
         '       Class<?> clazz = ReflectionHelper.loadClass(' +
         '\"${FULL_BRIDGE_NAME}\");\n' +
@@ -597,6 +657,7 @@ class Method(object):
       return_state = 'return (%s)' % ConvertPrimitiveTypeToObject(
           self.method_return)
     value = {'RETURN_TYPE': self.method_return,
+             'DOC': self.GenerateDoc(self.method_doc),
              'NAME': self.method_name,
              'FULL_BRIDGE_NAME': self._class_java_data.GetFullBridgeName(),
              'PARAMS_DECLARE_FOR_BRIDGE':