WebRuntime Refatoring
authorWonYoung Choi <wy80.choi@samsung.com>
Tue, 31 Mar 2015 00:13:23 +0000 (09:13 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 2 Apr 2015 02:09:16 +0000 (11:09 +0900)
Redesign WebRuntime for more simple and clean code.

Change-Id: I51bfa5c2c37057dfac9a92ba203529d33fe5ad27

32 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE [new file with mode: 0644]
LICENSE.AL2 [new file with mode: 0644]
packaging/wrt.spec [new file with mode: 0644]
src/CMakeLists.txt [new file with mode: 0644]
src/bundle/extension_renderer_controller.h [new file with mode: 0644]
src/bundle/injected_bundle.cc [new file with mode: 0644]
src/common/CMakeLists.txt [new file with mode: 0644]
src/common/file_utils.cc [new file with mode: 0644]
src/common/file_utils.h [new file with mode: 0644]
src/common/logger.h [new file with mode: 0644]
src/extension/extension.cc [new file with mode: 0644]
src/extension/extension.h [new file with mode: 0644]
src/extension/extension_instance.cc [new file with mode: 0644]
src/extension/extension_instance.h [new file with mode: 0644]
src/extension/extension_loader.cc [new file with mode: 0644]
src/extension/extension_loader.h [new file with mode: 0644]
src/extension/extension_server.cc [new file with mode: 0644]
src/extension/extension_server.h [new file with mode: 0644]
src/runtime/CMakeLists.txt [new file with mode: 0644]
src/runtime/command_line.cc [new file with mode: 0644]
src/runtime/command_line.h [new file with mode: 0644]
src/runtime/native_app_window.cc [new file with mode: 0644]
src/runtime/native_app_window.h [new file with mode: 0644]
src/runtime/native_window.cc [new file with mode: 0644]
src/runtime/native_window.h [new file with mode: 0644]
src/runtime/runtime.cc [new file with mode: 0644]
src/runtime/runtime.h [new file with mode: 0644]
src/runtime/web_application.cc [new file with mode: 0644]
src/runtime/web_application.h [new file with mode: 0644]
src/runtime/web_view.cc [new file with mode: 0644]
src/runtime/web_view.h [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b581c8c
--- /dev/null
@@ -0,0 +1,45 @@
+# 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.
+
+# Check minimum CMake version
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+# Project name
+PROJECT(wrt)
+
+INCLUDE(FindPkgConfig)
+
+# Options
+OPTION(X11_SUPPORT "Support x11 for window manager" OFF)
+OPTION(WAYLAND_SUPPORT "Support wayland for window manager" OFF)
+
+# Compiler flags
+SET(CMAKE_C_FLAGS_PROFILING    "-O2")
+SET(CMAKE_CXX_FLAGS_PROFILING  "-O2 -std=c++0x")
+SET(CMAKE_C_FLAGS_DEBUG        "-O0 -g")
+SET(CMAKE_CXX_FLAGS_DEBUG      "-O0 -std=c++0x -g")
+SET(CMAKE_C_FLAGS_RELEASE      "-Os")
+SET(CMAKE_CXX_FLAGS_RELEASE    "-Os -std=c++0x -fvisibility-inlines-hidden")
+SET(CMAKE_C_FLAGS_CCOV         "-O0 -g --coverage")
+SET(CMAKE_CXX_FLAGS_CCOV       "-O0 -std=c++0x -g --coverage")
+
+ADD_DEFINITIONS("-Wall")
+ADD_DEFINITIONS("-Wextra")
+ADD_DEFINITIONS("-Wno-variadic-macros")
+
+IF(X11_SUPPORT)
+  ADD_DEFINITIONS("-DHAVE_X11")
+ENDIF(X11_SUPPORT)
+IF(WAYLAND_SUPPORT)
+  ADD_DEFINITIONS("-DHAVE_WAYLAND")
+ENDIF(WAYLAND_SUPPORT)
+
+# Targets names
+SET(TARGET_RUNTIME  "wrt")
+SET(TARGET_COMMON_STATIC "wrt-common-static")
+SET(TARGET_EXTENSION "wrt-extension")
+SET(TARGET_INJECTED_BUNDLE "wrt-injected-bundle")
+
+# Sub Directories
+ADD_SUBDIRECTORY(src)
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..3776b42
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,27 @@
+// Copyright (c) 2015 Samsung Electronics Co, Ltd. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//    * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//    * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//    * Neither the name of Samsung Electronics nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
diff --git a/LICENSE.AL2 b/LICENSE.AL2
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/packaging/wrt.spec b/packaging/wrt.spec
new file mode 100644 (file)
index 0000000..4a24aab
--- /dev/null
@@ -0,0 +1,69 @@
+%bcond_with wayland
+%bcond_with x
+
+Name:       wrt
+Summary:    Runtime for Web Application
+Version:    2.0.0
+Release:    1
+Group:      Development/Libraries
+License:    Apache License, Version 2.0 / BSD
+URL:        N/A
+Source0:    %{name}-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(capi-appfw-application)
+%if %{with x}
+BuildRequires: pkgconfig(ecore-x)
+%endif
+%if %{with wayland}
+BuildRequires: pkgconfig(ecore-wayland)
+%endif
+
+%description
+Runtime for Web Application
+
+%prep
+%setup -q
+
+%build
+
+%ifarch %{arm}
+%define build_dir build-arm
+%else
+%define build_dir build-x86
+%endif
+
+%if %{with x}
+%define enable_x11 On
+%else
+%define enable_x11 Off
+%endif
+
+%if %{with wayland}
+%define enable_wayland On
+%else
+%define enable_wayland Off
+%endif
+
+mkdir -p %{build_dir}
+cd %{build_dir}
+
+cmake .. \
+  -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
+  -DX11_SUPPORT=%{enable_x11} \
+  -DWAYLAND_SUPPORT=%{enable_wayland}
+
+make %{?jobs:-j%jobs}
+
+%install
+cd %{build_dir}
+%make_install
+
+%clean
+rm -fr %{buildroot}
+
+%files
+/usr/local/bin/wrt
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1456372
--- /dev/null
@@ -0,0 +1,6 @@
+# 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.
+
+ADD_SUBDIRECTORY(common)
+ADD_SUBDIRECTORY(runtime)
diff --git a/src/bundle/extension_renderer_controller.h b/src/bundle/extension_renderer_controller.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/bundle/injected_bundle.cc b/src/bundle/injected_bundle.cc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3e0b4e9
--- /dev/null
@@ -0,0 +1,11 @@
+# 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.
+
+SET(TARGET_COMMON_STATIC_SRCS
+  ${PROJECT_SOURCE_DIR}/src/common/file_utils.cc
+)
+
+ADD_LIBRARY(${TARGET_COMMON_STATIC} STATIC
+  ${TARGET_COMMON_STATIC_SRCS}
+)
\ No newline at end of file
diff --git a/src/common/file_utils.cc b/src/common/file_utils.cc
new file mode 100644 (file)
index 0000000..77d3c66
--- /dev/null
@@ -0,0 +1,30 @@
+// 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 "file_utils.h"
+
+#include <unistd.h>
+#include <libgen.h>
+#include <string>
+
+namespace wrt {
+namespace utils {
+
+bool Exist(const std::string& path) {
+  return (access(path.c_str(), F_OK) != -1);
+}
+
+std::string BaseName(const std::string& path) {
+  char* p = basename(const_cast<char*>(path.c_str()));
+  return std::string(p);
+}
+
+std::string DirName(const std::string& path) {
+  char* p = dirname(const_cast<char*>(path.c_str()));
+  return std::string(p);
+}
+
+
+} // namespace utils
+} // namespace wrt
diff --git a/src/common/file_utils.h b/src/common/file_utils.h
new file mode 100644 (file)
index 0000000..66a0ea4
--- /dev/null
@@ -0,0 +1,23 @@
+// 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.
+
+#ifndef WRT_COMMON_FILE_UTILS_H_
+#define WRT_COMMON_FILE_UTILS_H_
+
+#include <string>
+
+namespace wrt {
+namespace utils {
+
+bool Exist(const std::string& path);
+
+std::string BaseName(const std::string& path);
+
+std::string DirName(const std::string& path);
+
+
+} //namespace utils
+} // namespace wrt
+
+#endif // WRT_COMMON_FILE_UTILS_H_
diff --git a/src/common/logger.h b/src/common/logger.h
new file mode 100644 (file)
index 0000000..2f1c0c5
--- /dev/null
@@ -0,0 +1,29 @@
+// 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.
+
+#ifndef WRT_COMMON_LOGGER_H_
+#define WRT_COMMON_LOGGER_H_
+
+#include <dlog.h>
+
+#undef LOGGER_TAG
+#define LOGGER_TAG "WRT"
+
+#define _LOGGER_LOG(prio, fmt, args...) \
+  LOG_(LOG_ID_MAIN, prio, LOGGER_TAG, fmt, ##args)
+
+#define _LOGGER_SLOG(prio, fmt, args...) \
+  SECURE_LOG_(LOG_ID_MAIN, prio, LOGGER_TAG, fmt, ##args)
+
+#define LoggerD(fmt, args...) _LOGGER_LOG(DLOG_DEBUG, fmt, ##args)
+#define LoggerI(fmt, args...) _LOGGER_LOG(DLOG_INFO, fmt, ##args)
+#define LoggerW(fmt, args...) _LOGGER_LOG(DLOG_WARN, fmt, ##args)
+#define LoggerE(fmt, args...) _LOGGER_LOG(DLOG_ERROR, fmt, ##args)
+
+#define SLoggerD(fmt, args...) _LOGGER_SLOG(DLOG_DEBUG, fmt, ##args)
+#define SLoggerI(fmt, args...) _LOGGER_SLOG(DLOG_INFO, fmt, ##args)
+#define SLoggerW(fmt, args...) _LOGGER_SLOG(DLOG_WARN, fmt, ##args)
+#define SLoggerE(fmt, args...) _LOGGER_SLOG(DLOG_ERROR, fmt, ##args)
+
+#endif // WRT_COMMON_LOGGER_H_
diff --git a/src/extension/extension.cc b/src/extension/extension.cc
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/extension/extension.h b/src/extension/extension.h
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/extension/extension_instance.cc b/src/extension/extension_instance.cc
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/extension/extension_instance.h b/src/extension/extension_instance.h
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/extension/extension_loader.cc b/src/extension/extension_loader.cc
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/extension/extension_loader.h b/src/extension/extension_loader.h
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/extension/extension_server.cc b/src/extension/extension_server.cc
new file mode 100644 (file)
index 0000000..fe76fb4
--- /dev/null
@@ -0,0 +1,4 @@
+// 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.
+
diff --git a/src/extension/extension_server.h b/src/extension/extension_server.h
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt
new file mode 100644 (file)
index 0000000..e674f8e
--- /dev/null
@@ -0,0 +1,64 @@
+# 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.
+
+# Package Dependencies
+IF(X11_SUPPORT)
+  SET(WIN_PKG "ecore-x")
+ENDIF(X11_SUPPORT)
+IF(WAYLAND_SUPPORT)
+  SET(WIN_PKG "ecore-wayland")
+ENDIF(WAYLAND_SUPPORT)
+
+PKG_CHECK_MODULES(TARGET_RUNTIME_DEPS
+  dlog
+  ${WIN_PKG}
+  elementary
+  capi-appfw-application
+  REQUIRED
+)
+
+# Include Directories
+SET(TARGET_RUNTIME_INCS
+  ${PROJECT_SOURCE_DIR}/src/common/
+  ${TARGET_RUNTIME_DEPS_INCLUDE_DIRS}
+)
+
+# Libraries
+SET(TARGET_RUNTIME_LIBS
+  ${TARGET_RUNTIME_DEPS_LIBRARIES}
+)
+
+# Source Files
+SET(TARGET_RUNTIME_SRCS
+  ${PROJECT_SOURCE_DIR}/src/runtime/command_line.cc
+  ${PROJECT_SOURCE_DIR}/src/runtime/native_window.cc
+  ${PROJECT_SOURCE_DIR}/src/runtime/native_app_window.cc
+  ${PROJECT_SOURCE_DIR}/src/runtime/web_application.cc
+  ${PROJECT_SOURCE_DIR}/src/runtime/runtime.cc
+)
+
+# Compiler Flags
+SET(TARGET_RUNTIME_CFLAGS
+  "-fPIE"
+)
+
+# Linker Flags
+SET(TARGET_RUNTIME_LDFLAGS
+  "-pie"
+)
+
+# Build Executable
+INCLUDE_DIRECTORIES(${TARGET_RUNTIME_INCS})
+ADD_DEFINITIONS(${TARGET_RUNTIME_CFLAGS})
+ADD_EXECUTABLE(${TARGET_RUNTIME} ${TARGET_RUNTIME_SRCS})
+TARGET_LINK_LIBRARIES(${TARGET_RUNTIME}
+  "-Wl,--whole-archive"
+  ${TARGET_COMMON_STATIC}
+  "-Wl,--no-whole-archive"
+  ${TARGET_RUNTIME_LIBS}
+  ${TARGET_RUNTIME_LDFLAGS}
+)
+
+# Install
+INSTALL(TARGETS ${TARGET_RUNTIME} DESTINATION bin)
diff --git a/src/runtime/command_line.cc b/src/runtime/command_line.cc
new file mode 100644 (file)
index 0000000..4956ab4
--- /dev/null
@@ -0,0 +1,53 @@
+// 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 "command_line.h"
+
+#include <string>
+
+#include "file_utils.h"
+
+namespace wrt {
+
+namespace {
+  const char* kRuntimeName = "wrt";
+}
+
+CommandLine* CommandLine::current_process_commandline_ = NULL;
+
+CommandLine::CommandLine(int argc, char* argv[]) {
+  // parse program name and appid from arguments
+  if (argc > 0) {
+    program_ = utils::BaseName(argv[0]);
+    if (program_ == kRuntimeName) {
+      if (argc > 1) {
+        appid_ = argv[1];
+      }
+    } else {
+      appid_ = program_;
+    }
+  }
+
+  // make a string vector with arguments
+  for (int i=0; i < argc; ++i) {
+    argv_.push_back(argv[i]);
+  }
+}
+
+CommandLine::~CommandLine() {
+}
+
+void CommandLine::Init(int argc, char* argv[]) {
+  if (!current_process_commandline_) {
+    current_process_commandline_ = new CommandLine(argc, argv);
+  }
+}
+
+CommandLine* CommandLine::ForCurrentProcess() {
+  return current_process_commandline_;
+}
+
+
+
+} // namespace wrt
diff --git a/src/runtime/command_line.h b/src/runtime/command_line.h
new file mode 100644 (file)
index 0000000..ed62d60
--- /dev/null
@@ -0,0 +1,36 @@
+// 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.
+
+#ifndef WRT_RUNTIME_COMMAND_LINE_H_
+#define WRT_RUNTIME_COMMAND_LINE_H_
+
+#include <string>
+#include <vector>
+
+namespace wrt {
+
+class CommandLine {
+ public:
+  static void Init(int argc, char* argv[]);
+  static CommandLine* ForCurrentProcess();
+
+  const std::string& appid() const { return appid_; }
+  const std::string& program() const { return program_; }
+  const std::vector<std::string>& argv() const { return argv_; }
+
+ private:
+  CommandLine(int argc, char* argv[]);
+  virtual ~CommandLine();
+
+  // The singleton CommandLine instance of current process
+  static CommandLine* current_process_commandline_;
+
+  std::string appid_;
+  std::string program_;
+  std::vector<std::string> argv_;
+};
+
+} // namespace wrt
+
+#endif // WRT_RUNTIME_COMMAND_LINE_H_
diff --git a/src/runtime/native_app_window.cc b/src/runtime/native_app_window.cc
new file mode 100644 (file)
index 0000000..e78f824
--- /dev/null
@@ -0,0 +1,21 @@
+// 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 "native_app_window.h"
+
+namespace wrt {
+
+NativeAppWindow::NativeAppWindow() {
+}
+
+NativeAppWindow::~NativeAppWindow() {
+}
+
+Evas_Object* NativeAppWindow::createWindowInternal() {
+  elm_config_preferred_engine_set("opengl_x11");
+  return elm_win_add(NULL, "wrt-widget", ELM_WIN_BASIC);
+}
+
+
+} // namespace wrt
diff --git a/src/runtime/native_app_window.h b/src/runtime/native_app_window.h
new file mode 100644 (file)
index 0000000..6f24bf8
--- /dev/null
@@ -0,0 +1,22 @@
+// 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.
+
+#ifndef WRT_RUNTIME_NATIVE_APP_WINDOW_H_
+#define WRT_RUNTIME_NATIVE_APP_WINDOW_H_
+
+#include "native_window.h"
+
+namespace wrt {
+
+class NativeAppWindow: public NativeWindow {
+ public:
+  NativeAppWindow();
+  virtual ~NativeAppWindow();
+ protected:
+  Evas_Object* createWindowInternal(); // override
+};
+
+} // namespace wrt
+
+#endif // WRT_RUNTIME_NATIVE_APP_WINDOW_H_
diff --git a/src/runtime/native_window.cc b/src/runtime/native_window.cc
new file mode 100644 (file)
index 0000000..02a0dbe
--- /dev/null
@@ -0,0 +1,119 @@
+// 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 "native_window.h"
+
+#if defined(HAVE_X11)
+#include <Ecore_X.h>
+#elif defined(HAVE_WAYLAND)
+#include <Ecore_Wayland.h>
+#endif
+
+#include "logger.h"
+
+namespace wrt {
+
+namespace {
+  const char* kWRTEdjePath = "/usr/share/edje/wrt/Wrt.edj";
+} // namespace
+
+NativeWindow::NativeWindow()
+    : initialized_(false),
+      window_(NULL) {
+}
+
+NativeWindow::~NativeWindow() {
+}
+
+void NativeWindow::Initialize() {
+  unsigned long pid = getpid();
+
+  // window
+  window_ = createWindowInternal();
+  elm_win_conformant_set(window_, EINA_TRUE);
+  int w, h;
+#if defined(HAVE_X11)
+  ecore_x_window_prop_property_set(
+    elm_win_xwindow_get(window_),
+    ECORE_X_ATOM_NET_WM_PID,
+    ECORE_X_ATOM_CARDINAL, 32, &pid, 1);
+  ecore_x_vsync_animator_tick_source_set(elm_win_xwindow_get(window_));
+  ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+#elif defined(HAVE_WAYLAND)
+  ecore_wl_screen_size_get(&w, &h);
+#endif
+  evas_object_resize(window_, w, h);
+  elm_win_autodel_set(window_, EINA_TRUE);
+  evas_object_smart_callback_add(window_, "delete,request",
+                                 didDeleteRequested, this);
+  evas_object_smart_callback_add(window_, "profile,changed",
+                                 didProfileChanged, this);
+
+  #define EVAS_SIZE_EXPAND_FILL(obj) \
+    evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); \
+    evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+  // background
+  Evas_Object* bg = evas_object_rectangle_add(evas_object_evas_get(window_));
+  evas_object_color_set(bg, 0, 0, 0, 0);
+  EVAS_SIZE_EXPAND_FILL(bg);
+  elm_win_resize_object_add(window_, bg);
+  evas_object_render_op_set(bg, EVAS_RENDER_BLEND);
+  evas_object_show(bg);
+
+  // conformant
+  Evas_Object* conformant = elm_conformant_add(window_);
+  EVAS_SIZE_EXPAND_FILL(conformant);
+  elm_win_resize_object_add(window_, conformant);
+  evas_object_show(conformant);
+
+  // top layout
+  Evas_Object* top_layout = elm_layout_add(conformant);
+  elm_layout_theme_set(top_layout, "layout", "application", "default");
+  EVAS_SIZE_EXPAND_FILL(top_layout);
+  elm_object_content_set(conformant, top_layout);
+  evas_object_show(top_layout);
+
+  // naviframe
+  Evas_Object* naviframe = elm_naviframe_add(top_layout);
+  EVAS_SIZE_EXPAND_FILL(naviframe);
+  elm_object_part_content_set(top_layout, "elm.swallow.content", naviframe);
+  evas_object_show(naviframe);
+
+  // main layout
+  Evas_Object* main_layout = elm_layout_add(naviframe);
+  elm_layout_file_set(main_layout, kWRTEdjePath, "web-application");
+  EVAS_SIZE_EXPAND_FILL(main_layout);
+  Elm_Object_Item* navi_item = elm_naviframe_item_push(
+      naviframe, NULL, NULL, NULL, main_layout, NULL);
+  elm_naviframe_item_title_enabled_set(navi_item, EINA_FALSE, EINA_FALSE);
+  //elm_naviframe_item_pop_cb_set(navi_item, naviframeItemPopCallback, NULL);
+  evas_object_show(main_layout);
+
+  // focus
+  Evas_Object* focus = elm_button_add(main_layout);
+  elm_theme_extension_add(NULL, kWRTEdjePath);
+  elm_object_style_set(focus, "wrt");
+  elm_object_part_content_set(main_layout, "elm.swallow.content", focus);
+  EVAS_SIZE_EXPAND_FILL(focus);
+  elm_access_object_unregister(focus);
+  evas_object_show(focus);
+
+  initialized_ = true;
+}
+
+void NativeWindow::didDeleteRequested(void* /*data*/,
+    Evas_Object* /*obj*/, void* /*event_info*/) {
+  LoggerD("didDeleteRequested");
+  elm_exit();
+}
+
+void NativeWindow::didProfileChanged(void* data,
+    Evas_Object* /*obj*/, void* /*event_info*/) {
+  LoggerD("didProfileChanged");
+}
+
+
+
+} // namespace wrt
diff --git a/src/runtime/native_window.h b/src/runtime/native_window.h
new file mode 100644 (file)
index 0000000..dae4491
--- /dev/null
@@ -0,0 +1,40 @@
+// 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.
+
+#ifndef WRT_RUNTIME_NATIVE_WINDOW_H_
+#define WRT_RUNTIME_NATIVE_WINDOW_H_
+
+#include <Elementary.h>
+
+namespace wrt {
+
+class NativeWindow {
+ public:
+  NativeWindow();
+  virtual ~NativeWindow();
+
+  void Initialize();
+
+  bool initialized() const { return initialized_; }
+
+ protected:
+  virtual Evas_Object* createWindowInternal() = 0;
+
+
+ private:
+  static void didDeleteRequested(void* data, Evas_Object* obj, void* event_info);
+  static void didProfileChanged(void* data, Evas_Object* obj, void* event_info);
+
+
+
+  bool initialized_;
+  Evas_Object* window_;
+
+
+};
+
+} // namespace wrt
+
+
+#endif // WRT_RUNTIME_NATIVE_WINDOW_H_
diff --git a/src/runtime/runtime.cc b/src/runtime/runtime.cc
new file mode 100644 (file)
index 0000000..3c10ae1
--- /dev/null
@@ -0,0 +1,96 @@
+// 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 "runtime.h"
+
+#include "logger.h"
+#include "command_line.h"
+#include "native_app_window.h"
+
+namespace wrt {
+
+Runtime::Runtime() {
+
+}
+
+Runtime::~Runtime() {
+  if (application_) {
+    delete application_;
+  }
+}
+
+bool Runtime::onCreate(void* data) {
+  Runtime* runtime = reinterpret_cast<Runtime*>(data);
+  if (!runtime) {
+    LoggerE("Runtime has not been created.");
+    return false;
+  }
+  std::string appid = CommandLine::ForCurrentProcess()->appid();
+  runtime->application_ = new WebApplication(appid);
+  if (!runtime->application_) {
+    LoggerE("WebApplication couldn't be created.");
+    return false;
+  }
+  return true;
+}
+
+void Runtime::onTerminate(void* data) {
+}
+
+void Runtime::onPause(void* data) {
+  Runtime* runtime = reinterpret_cast<Runtime*>(data);
+  if (runtime->application_->initialized()) {
+    runtime->application_->Suspend();
+  }
+}
+
+void Runtime::onResume(void* data) {
+  Runtime* runtime = reinterpret_cast<Runtime*>(data);
+  if (runtime->application_->initialized()) {
+    runtime->application_->Resume();
+  }
+}
+
+void Runtime::onAppControl(app_control_h app_control, void* data) {
+  Runtime* runtime = reinterpret_cast<Runtime*>(data);
+  if (runtime->application_->initialized()) {
+    // Process AppControl
+  } else {
+    // Process First Launch
+    runtime->createNativeWindow();
+    runtime->application_->Launch();
+  }
+}
+
+int Runtime::Exec(int argc, char* argv[]) {
+  ui_app_lifecycle_callback_s ops = {0,};
+
+  ops.create = onCreate;
+  ops.terminate = onTerminate;
+  ops.pause = onPause;
+  ops.resume = onResume;
+  ops.app_control = onAppControl;
+
+  return ui_app_main(argc, argv, &ops, this);
+}
+
+void Runtime::createNativeWindow() {
+  // TODO(wy80.choi) : consider other type of native window.
+  native_window_ = new NativeAppWindow();
+
+  native_window_->Initialize();
+}
+
+} // namespace wrt
+
+int main(int argc, char* argv[]) {
+
+  // Initalize CommandLineParser
+  wrt::CommandLine::Init(argc, argv);
+
+  wrt::Runtime runtime;
+  int ret = runtime.Exec(argc, argv);
+
+  return ret;
+}
diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h
new file mode 100644 (file)
index 0000000..6c02b4d
--- /dev/null
@@ -0,0 +1,36 @@
+// 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.
+
+#ifndef WRT_RUNTIME_RUNTIME_H_
+#define WRT_RUNTIME_RUNTIME_H_
+
+#include <app.h>
+
+#include "web_application.h"
+#include "native_window.h"
+
+namespace wrt {
+
+class Runtime {
+ public:
+  Runtime();
+  virtual ~Runtime();
+
+  int Exec(int argc, char* argv[]);
+ private:
+  static bool onCreate(void* data);
+  static void onTerminate(void* data);
+  static void onPause(void* data);
+  static void onResume(void* data);
+  static void onAppControl(app_control_h app_control, void* data);
+
+  void createNativeWindow();
+
+  WebApplication* application_;
+  NativeWindow* native_window_;
+};
+
+} // namespace wrt
+
+#endif // WRT_RUNTIME_RUNTIME_H_
diff --git a/src/runtime/web_application.cc b/src/runtime/web_application.cc
new file mode 100644 (file)
index 0000000..ada737a
--- /dev/null
@@ -0,0 +1,31 @@
+// 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 "web_application.h"
+
+namespace wrt {
+
+WebApplication::WebApplication(const std::string& appid)
+    : initialized_(false),
+      appid_(appid) {
+}
+
+WebApplication::~WebApplication() {
+}
+
+void WebApplication::Launch() {
+
+  initialized_ = true;
+}
+
+void WebApplication::Resume() {
+
+}
+
+void WebApplication::Suspend() {
+
+}
+
+
+} // namespace wrt
diff --git a/src/runtime/web_application.h b/src/runtime/web_application.h
new file mode 100644 (file)
index 0000000..5a9ad71
--- /dev/null
@@ -0,0 +1,32 @@
+// 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.
+
+#ifndef WRT_RUNTIME_WEB_APPLICATION_H_
+#define WRT_RUNTIME_WEB_APPLICATION_H_
+
+#include <string>
+
+namespace wrt {
+
+class WebApplication {
+ public:
+  WebApplication(const std::string& appid);
+  virtual ~WebApplication();
+
+  void Launch();
+  void Resume();
+  void Suspend();
+
+  bool initialized() const { return initialized_; }
+
+ private:
+  bool initialized_;
+  std::string appid_;
+
+};
+
+} // namespace wrt
+
+
+#endif // WRT_RUNTIME_WEB_APPLICATION_H_
diff --git a/src/runtime/web_view.cc b/src/runtime/web_view.cc
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file
diff --git a/src/runtime/web_view.h b/src/runtime/web_view.h
new file mode 100644 (file)
index 0000000..09a75a1
--- /dev/null
@@ -0,0 +1,3 @@
+// 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.
\ No newline at end of file