# Targets names
SET(TARGET_RUNTIME "wrt")
SET(TARGET_COMMON_STATIC "wrt-common-static")
-SET(TARGET_EXTENSION "wrt-extension")
+SET(TARGET_EXTENSION_STATIC "wrt-extension-static")
SET(TARGET_INJECTED_BUNDLE "wrt-injected-bundle")
# Sub Directories
%endif
#web-engine
-BuildRequires: pkgconfig(chromium-efl)
+BuildRequires: pkgconfig(chromium-efl)
%description
Runtime for Web Application
%files
%attr(755,root,root) %{_bindir}/wrt
-%attr(755,root,root) %{_bindir}/wrt-extension
-%attr(755,root,root) %{_bindir}/wrt-extension-client-test
%attr(644,root,root) %{_datadir}/edje/wrt/wrt.edj
%attr(644,root,root) %{_libdir}/libwrt-injected-bundle.so
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
-
-
-# Build Executable for Test
-SET(TARGET_EXTENSION_TEST "wrt-extension-client-test")
-INCLUDE_DIRECTORIES(
- ${BASE_SRCDIR}
- ${TARGET_INJECTED_BUNDLE_INCS})
-ADD_EXECUTABLE(${TARGET_EXTENSION_TEST}
- ${BASE_SRCDIR}/bundle/extension_client.cc
- ${BASE_SRCDIR}/bundle/extension_client_test.cc)
-TARGET_LINK_LIBRARIES(${TARGET_EXTENSION_TEST}
- ${TARGET_COMMON_STATIC}
- ${TARGET_INJECTED_BUNDLE_LIBS}
- "-ldl"
-)
-
-INSTALL(TARGETS ${TARGET_EXTENSION_TEST} DESTINATION bin)
\ No newline at end of file
+++ /dev/null
-// Copyright 2015 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.
-
-#include <stdio.h>
-#include <iostream>
-
-#include "bundle/extension_client.h"
-
-using namespace std;
-using namespace wrt;
-
-int main(int argc, char* argv[]) {
-
- if (argc < 2) {
- fprintf(stderr, "uuid is requried.\n");
- }
-
- ExtensionClient extension_client;
-
- extension_client.Initialize(argv[1]);
-
- string instance_id = extension_client.CreateInstance("tizen", NULL);
- extension_client.DestroyInstance(instance_id);
- cout << instance_id << endl;
-
- return 0;
-}
)
TARGET_LINK_LIBRARIES(${TARGET_COMMON_STATIC}
${TARGET_COMMON_STATIC_DEPS_LIBRARIES}
-)
\ No newline at end of file
+)
}
// Parse program name and appid from argv_ or arguments_
+ program_ = std::string(argv[0]);
if (argc > 0) {
- program_ = utils::BaseName(argv[0]);
- if (program_ == kRuntimeName) {
+ std::string tmp = utils::BaseName(argv[0]);
+ if (tmp == kRuntimeName) {
if (arguments_.size() > 0) {
// Suppose that appid is at the first of arguments_
appid_ = arguments_[0];
}
} else {
- appid_ = program_;
+ appid_ = tmp;
}
}
}
CommandLine::~CommandLine() {
}
-void CommandLine::AppendOption(const char* argument) {
- std::string option_string(argument);
+void CommandLine::AppendOption(const char* value) {
+ std::string option_string(value);
std::string option_name;
std::string option_value;
}
}
+std::string CommandLine::GetCommandString() {
+ std::string result;
+ result.append(program_);
+ result.append(" ");
+ for (auto& it : options_) {
+ result.append(kOptionPrefix);
+ result.append(it.first);
+ if (!it.second.empty()) {
+ result.append(kOptionValueSeparator);
+ result.append(it.second);
+ }
+ result.append(" ");
+ }
+ for (auto& it : arguments_) {
+ result.append(it);
+ result.append(" ");
+ }
+ return result;
+}
+
// static
void CommandLine::Reset() {
if (!!current_process_commandline_) {
bool HasOptionName(const std::string& option_name);
// Get the option's value
std::string GetOptionValue(const std::string& option_name);
+ // Get command string include options and arguments
+ std::string GetCommandString();
- const std::string appid() const { return appid_; }
- const std::string program() const { return program_; }
+ std::string appid() const { return appid_; }
+ std::string program() const { return program_; }
const OptionMap& options() const { return options_; }
const Arguments& arguments() const { return arguments_; }
char** argv() const { return argv_; }
CommandLine(int argc, char* argv[]);
virtual ~CommandLine();
- void AppendOption(const char* argument);
+ void AppendOption(const char* value);
// The singleton CommandLine instance of current process
static CommandLine* current_process_commandline_;
namespace wrt {
+// Extension
const char kSystemExtensionPath[] = "/usr/lib/tizen-extensions-crosswalk";
const char kExtensionPrefix[] = "lib";
const char kExtensionSuffix[] = ".so";
+const char kSwitchExtensionServer[] = "extension-server";
+// DBus for Application
const char kDBusNameForApplication[] = "Application";
const char kDBusInterfaceNameForApplication[] = "org.tizen.wrt.Application";
const char kMethodNotifyEPCreated[] = "NotifyEPCreated";
const char kMethodGetRuntimeVariable[] = "GetRuntimeVariable";
+// DBus for Extension
const char kDBusNameForExtension[] = "Extension";
const char kDBusInterfaceNameForExtension[] = "org.tizen.wrt.Extension";
const char kMethodGetExtensions[] = "GetExtensions";
const char kMethodPostMessage[] = "PostMessage";
const char kSignalOnMessageToJS[] = "OnMessageToJS";
+
+
+
} // namespace wrt
extern const char kSystemExtensionPath[];
extern const char kExtensionPrefix[];
extern const char kExtensionSuffix[];
+extern const char kSwitchExtensionServer[];
extern const char kDBusNameForApplication[];
extern const char kDBusInterfaceNameForApplication[];
if (server_) {
g_object_unref(server_);
}
+
+ if (!address_path_.empty()) {
+ unlink(address_path_.c_str());
+ }
}
void DBusServer::Start(const std::string& name) {
GError* err = NULL;
- std::string address(g_get_user_runtime_dir());
- address.append("/.");
- address.append(name);
-
+ address_path_.clear();
+ address_path_.append(g_get_user_runtime_dir());
+ address_path_.append("/.");
+ address_path_.append(name);
// unlink existing bus address
- unlink(address.c_str());
- address = "unix:path=" + address;
+ unlink(address_path_.c_str());
+
+ std::string address("unix:path=");
+ address.append(address_path_);
// create new bus socket
// TODO(wy80.choi): bus socket (Address) should be removed gracefully
PropertyGetter GetPropertyGetter(const std::string& iface);
private:
+ std::string address_path_;
GDBusServer* server_;
GDBusNodeInfo* node_info_;
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# Dependencies
-PKG_CHECK_MODULES(TARGET_EXTENSION_DEPS
- uuid
+PKG_CHECK_MODULES(TARGET_EXTENSION_STATIC_DEPS
dlog
glib-2.0
- gio-2.0
REQUIRED
)
-# Includes
-SET(TARGET_EXTENSION_INCS
+SET(TARGET_EXTENSION_STATIC_INCS
${BASE_SRCDIR}
- ${TARGET_EXTENSION_DEPS_INCLUDE_DIRS}
+ ${TARGET_EXTENSION_STATIC_DEPS_INCLUDE_DIRS}
)
-# Libraries
-SET(TARGET_EXTENSION_LIBS
- ${TARGET_EXTENSION_DEPS_LIBRARIES}
-)
-
-# Source Files
-SET(TARGET_EXTENSION_SRCS
- ${BASE_SRCDIR}/extension/extension_main.cc
+SET(TARGET_EXTENSION_STATIC_SRCS
${BASE_SRCDIR}/extension/extension.cc
${BASE_SRCDIR}/extension/extension_instance.cc
${BASE_SRCDIR}/extension/extension_adapter.cc
${BASE_SRCDIR}/extension/extension_server.cc
)
-# Compiler Flags
-SET(TARGET_EXTENSION_CFLAGS
- "-fPIE"
-)
-
-# Linker Flags
-SET(TARGET_EXTENSION_LDFLAGS
- "-pie -ldl"
+INCLUDE_DIRECTORIES(${TARGET_EXTENSION_STATIC_INCS})
+ADD_LIBRARY(${TARGET_EXTENSION_STATIC} STATIC
+ ${TARGET_EXTENSION_STATIC_SRCS}
)
-
-# Build Executable
-INCLUDE_DIRECTORIES(${TARGET_EXTENSION_INCS})
-ADD_DEFINITIONS(${TARGET_EXTENSION_CFLAGS})
-ADD_EXECUTABLE(${TARGET_EXTENSION} ${TARGET_EXTENSION_SRCS})
-TARGET_LINK_LIBRARIES(${TARGET_EXTENSION}
+TARGET_LINK_LIBRARIES(${TARGET_EXTENSION_STATIC}
+ ${TARGET_EXTENSION_STATIC_DEPS_LIBRARIES}
${TARGET_COMMON_STATIC}
- ${TARGET_EXTENSION_LIBS}
- ${TARGET_EXTENSION_LDFLAGS}
)
-
-# Install
-INSTALL(TARGETS ${TARGET_EXTENSION} DESTINATION bin)
+++ /dev/null
-// Copyright 2015 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.
-
-#include <glib.h>
-#include <glib-unix.h>
-
-#include "common/logger.h"
-#include "common/command_line.h"
-#include "extension/extension_server.h"
-
-namespace {
-
-gboolean HandleQuitSignal(gpointer data) {
- GMainLoop* loop = reinterpret_cast<GMainLoop*>(data);
- g_main_loop_quit(loop);
- return false;
-}
-
-} // namespace
-
-// TODO(wy80.choi): This main function should be merged to wrt runtime
-// to reduce static code size of memory.
-int main(int argc, char* argv[]) {
- GMainLoop* loop;
-
- loop = g_main_loop_new(NULL, FALSE);
- g_unix_signal_add(SIGINT, HandleQuitSignal, loop);
- g_unix_signal_add(SIGTERM, HandleQuitSignal, loop);
-
- wrt::CommandLine::Init(argc, argv);
- wrt::CommandLine* cmd = wrt::CommandLine::ForCurrentProcess();
-
- // TODO(wy80.choi): Receive extension paths for user defined extensions.
-
- // Receive AppID from arguments.
- if (cmd->arguments().size() < 1) {
- LoggerE("uuid is required.");
- exit(1);
- }
- std::string uuid = cmd->arguments()[0];
-
- // Start ExtensionServer
- wrt::ExtensionServer server(uuid);
- if (!server.Start()) {
- LoggerE("Failed to start extension server.");
- exit(1);
- }
-
- LoggerI("extension process has been started.");
-
- g_main_loop_run(loop);
-
- LoggerI("extension process is exiting.");
-
- g_main_loop_unref(loop);
-
- return 0;
-}
#include "extension/extension_server.h"
#include <glob.h>
+#include <glib.h>
+#include <glib-unix.h>
+
#include <string>
#include <vector>
#include "common/constants.h"
#include "common/file_utils.h"
#include "common/string_utils.h"
+#include "common/command_line.h"
#include "extension/extension.h"
namespace wrt {
}
bool ExtensionServer::Start(const StringVector& paths) {
- // Register system extensions to support Tizen Device APIs
- RegisterSystemExtensions();
-
- // Register user extensions
- for (auto it = paths.begin(); it != paths.end(); ++it) {
- if (utils::Exists(*it)) {
- RegisterExtension(*it);
- }
- }
-
// Connect to DBusServer for Application of Runtime
if (!dbus_application_client_.ConnectByName(
app_uuid_ + "." + std::string(kDBusNameForApplication))) {
std::bind(&ExtensionServer::HandleDBusMethod, this, _1, _2, _3, _4));
dbus_server_.Start(app_uuid_ + "." + std::string(kDBusNameForExtension));
+ // Register system extensions to support Tizen Device APIs
+ RegisterSystemExtensions();
+
+ // Register user extensions
+ for (auto it = paths.begin(); it != paths.end(); ++it) {
+ if (utils::Exists(*it)) {
+ RegisterExtension(*it);
+ }
+ }
+
// Send 'ready' signal to Injected Bundle.
NotifyEPCreatedToApplication();
msg.c_str()));
}
+// static
+bool ExtensionServer::StartExtensionProcess() {
+ GMainLoop* loop;
+
+ loop = g_main_loop_new(NULL, FALSE);
+
+ // Register Quit Signal Handlers
+ auto quit_callback = [](gpointer data) -> gboolean {
+ GMainLoop* loop = reinterpret_cast<GMainLoop*>(data);
+ g_main_loop_quit(loop);
+ return false;
+ };
+ g_unix_signal_add(SIGINT, quit_callback, loop);
+ g_unix_signal_add(SIGTERM, quit_callback, loop);
+
+ CommandLine* cmd = CommandLine::ForCurrentProcess();
+
+ // TODO(wy80.choi): Receive extension paths for user defined extensions.
+
+ // Receive AppID from arguments.
+ if (cmd->arguments().size() < 1) {
+ LoggerE("uuid is required.");
+ return false;
+ }
+ std::string uuid = cmd->arguments()[0];
+
+ // Start ExtensionServer
+ ExtensionServer server(uuid);
+ if (!server.Start()) {
+ LoggerE("Failed to start extension server.");
+ return false;
+ }
+
+ LoggerI("extension process has been started.");
+
+ g_main_loop_run(loop);
+
+ LoggerI("extension process is exiting.");
+
+ g_main_loop_unref(loop);
+
+ return true;
+}
+
} // namespace wrt
explicit ExtensionServer(const std::string& appid);
virtual ~ExtensionServer();
+ static bool StartExtensionProcess();
+
bool Start();
bool Start(const StringVector& paths);
ENDIF(WAYLAND_SUPPORT)
PKG_CHECK_MODULES(TARGET_RUNTIME_DEPS
- glib-2.0
- gio-2.0
- uuid
dlog
${WIN_PKG}
elementary
# Source Files
SET(TARGET_RUNTIME_SRCS
+ ${BASE_SRCDIR}/runtime/main.cc
${BASE_SRCDIR}/runtime/native_window.cc
${BASE_SRCDIR}/runtime/native_app_window.cc
${BASE_SRCDIR}/runtime/web_application.cc
ADD_DEFINITIONS(${TARGET_RUNTIME_CFLAGS})
ADD_EXECUTABLE(${TARGET_RUNTIME} ${TARGET_RUNTIME_SRCS})
TARGET_LINK_LIBRARIES(${TARGET_RUNTIME}
- ${TARGET_COMMON_STATIC}
${TARGET_RUNTIME_LIBS}
+ ${TARGET_COMMON_STATIC}
+ ${TARGET_EXTENSION_STATIC}
${TARGET_RUNTIME_LDFLAGS}
)
--- /dev/null
+// Copyright 2015 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.
+
+#include <ewk_chromium.h>
+
+#include "common/logger.h"
+#include "common/constants.h"
+#include "common/command_line.h"
+#include "runtime/runtime.h"
+#include "extension/extension_server.h"
+
+int main(int argc, char* argv[]) {
+ // Parse commandline.
+ wrt::CommandLine::Init(argc, argv);
+
+ wrt::CommandLine* cmd = wrt::CommandLine::ForCurrentProcess();
+ if (cmd->HasOptionName(wrt::kSwitchExtensionServer)) {
+ // If cmd has the switch '--extension-server', run as extension server.
+ LoggerI("Extension server process has been created.");
+ if (!wrt::ExtensionServer::StartExtensionProcess()) {
+ LoggerE("Failed to start extension server.");
+ exit(EXIT_FAILURE);
+ }
+ } else {
+ // Default dehavior, run as runtime.
+ LoggerI("Runtime process has been created.");
+ ewk_init();
+ char* chromium_arg_options[] = {
+ argv[0],
+ const_cast<char*>("--enable-file-cookies"),
+ const_cast<char*>("--allow-file-access-from-files"),
+ const_cast<char*>("--allow-universal-access-from-files")
+ };
+ const int chromium_arg_cnt =
+ sizeof(chromium_arg_options) / sizeof(chromium_arg_options[0]);
+ ewk_set_arguments(chromium_arg_cnt, chromium_arg_options);
+
+ wrt::Runtime runtime;
+ int ret = runtime.Exec(argc, argv);
+ ewk_shutdown();
+ exit(ret);
+ }
+
+ return EXIT_SUCCESS;
+}
#include <memory>
#include "common/logger.h"
-#include "common/constants.h"
#include "common/command_line.h"
-#include "runtime/native_app_window.h"
#include "common/app_control.h"
#include "common/application_data.h"
+#include "runtime/native_app_window.h"
namespace wrt {
}
} // namespace wrt
-
-int main(int argc, char* argv[]) {
- // Initialize CommandLineParser
- wrt::CommandLine::Init(argc, argv);
-
- ewk_init();
- char* chromium_arg_options[] = {
- argv[0],
- const_cast<char*>("--enable-file-cookies"),
- const_cast<char*>("--allow-file-access-from-files"),
- const_cast<char*>("--allow-universal-access-from-files")
- };
- const int chromium_arg_cnt =
- sizeof(chromium_arg_options) / sizeof(chromium_arg_options[0]);
- ewk_set_arguments(chromium_arg_cnt, chromium_arg_options);
-
- wrt::Runtime runtime;
- int ret = runtime.Exec(argc, argv);
- ewk_shutdown();
- return ret;
-}
#include "common/application_data.h"
#include "common/resource_manager.h"
+namespace wrt {
+
namespace {
// TODO(sngn.lee) : It should be declare in common header
const char* kKeyNameBack = "back";
LoggerE("Failed to fork child process for extension process.");
}
if (pid == 0) {
- // TODO(wy80.choi): wrt-extension should be merged to this runtime exec.
- // It should be changed to "/usr/bin/wrt --extension-process"
- execl("/usr/bin/wrt-extension",
- "/usr/bin/wrt-extension", uuid.c_str(), NULL);
+ CommandLine* cmd = CommandLine::ForCurrentProcess();
+ std::string switch_ext("--");
+ switch_ext.append(kSwitchExtensionServer);
+ execl(cmd->program().c_str(),
+ cmd->program().c_str(), switch_ext.c_str(), uuid.c_str(), NULL);
}
}
} // namespace
-namespace wrt {
-
WebApplication::WebApplication(
NativeWindow* window, std::unique_ptr<ApplicationData> app_data)
: launched_(false),