[Release] wrt_0.8.257
authorsung-su.kim <sung-su.kim@samsung.com>
Thu, 8 Aug 2013 07:54:06 +0000 (16:54 +0900)
committerHoseon LEE <hoseon46.lee@samsung.com>
Sun, 29 Sep 2013 05:37:50 +0000 (14:37 +0900)
Change-Id: Ie1af6747c6a39ecbdee26f0b2f5b64c88b024659

21 files changed:
CMakeLists.txt
packaging/wrt.spec
src/api_new/CMakeLists.txt
src/domain/application_data.cpp
src/view/CMakeLists.txt
src/view/common/CMakeLists.txt
src/view/common/message_support.h
src/view/common/view_logic_service_support.cpp [deleted file]
src/view/common/view_logic_service_support.h [deleted file]
src/view/webkit/CMakeLists.txt
src/view/webkit/injected-bundle/wrt-injected-bundle.cpp
src/view/webkit/injected-bundle/wrt-injected-bundle.h
src/view/webkit/view_logic.cpp
src/view/webkit/view_logic.h
src/view/webkit/view_logic_scheme_support.cpp
src/wrt-client/CMakeLists.txt
src/wrt-client/client_submode_support.cpp [new file with mode: 0644]
src/wrt-client/client_submode_support.h [new file with mode: 0644]
src/wrt-client/wrt-client.cpp
src/wrt-client/wrt-client.h
src/wrt-launcher/wrt-launcher.cpp

index 12ce922..bfc8e61 100644 (file)
@@ -150,6 +150,7 @@ SET(TARGET_TESTS_COMMON_LIB "wrt-engine-tests-lib") #tests only
 SET(TARGET_PROFILING_LIB "wrt-profiling")
 SET(TARGET_PLUGIN_MODULE_LIB "wrt-plugin-module")
 SET(TARGET_VIEW_MODULE_LIB "wrt-view-module")
+SET(TARGET_VIEW_COMMON_LIB_STATIC "wrt-view-common")
 SET(TARGET_CORE_MODULE_LIB "wrt-core-module")
 SET(TARGET_INJECTED_BUNDLE_LIB "wrt-injected-bundle")
 SET(PROF_LIB "")
index b89293d..ac29efd 100644 (file)
@@ -1,7 +1,7 @@
 #git:framework/web/wrt
 Name:       wrt
 Summary:    web runtime
-Version:    0.8.251
+Version:    0.8.257
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
@@ -89,6 +89,12 @@ wrt library development headers
 %endif
 
 %build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+
 export LDFLAGS+="-Wl,--rpath=/usr/lib"
 
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
index e6b39ce..5bcd0fa 100644 (file)
@@ -43,16 +43,31 @@ INCLUDE_DIRECTORIES(
 
 INCLUDE_DIRECTORIES( SYSTEM ${SYS_CORE_MODULE_DEP_INCLUDE_DIRS})
 
+
+#
+#Set libraries that should be linked to the file that is linking wrt-core-module
+#Do not set any static libraries as it will be included in wrt-core-module
+#
+SET(WRT_CORE_MODULE_INTERFACE_LIBRARIES
+    ${WRT_ENGINE_DEPS_LIBRARIES}
+    ${SYS_WRT_ENGINE_DEPS_LIBRARIES}
+    ${CORE_MODULE_DEP_LIBRARIES}
+    ${SYS_CORE_MODULE_DEP_LIBRARIES}
+)
+
 TARGET_LINK_LIBRARIES(${TARGET_CORE_MODULE_LIB}
-# include all symbols that could be used by wrt-client
+# include all symbols that could be used by wrt-client or other binaries
     "-Wl,--whole-archive"
     ${TARGET_WRT_ENGINE_STATIC}
+    ${TARGET_VIEW_COMMON_LIB_STATIC}
     "-Wl,--no-whole-archive"
-    ${WRT_ENGINE_DEPS_LIBRARIES}
-    ${SYS_WRT_ENGINE_DEPS_LIBRARIES}
     ${TARGET_VIEW_MODULE_LIB}
-    ${CORE_MODULE_DEP_LIBRARIES}
-    ${SYS_CORE_MODULE_DEP_LIBRARIES}
+    ${WRT_CORE_MODULE_INTERFACE_LIBRARIES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_CORE_MODULE_LIB}
+    PROPERTIES
+    LINK_INTERFACE_LIBRARIES "${WRT_CORE_MODULE_INTERFACE_LIBRARIES}"
 )
 
 INSTALL(TARGETS ${TARGET_CORE_MODULE_LIB}
index 7a20756..e6fa8c7 100644 (file)
  */
 
 #include "application_data.h"
-#include <dpl/singleton_impl.h>
+#include <dpl/singleton_safe_impl.h>
 #include <dpl/log/log.h>
 #include <bundle.h>
 
-IMPLEMENT_SINGLETON(ApplicationData)
+IMPLEMENT_SAFE_SINGLETON(ApplicationData)
 
 ApplicationData::ApplicationData() :
     m_originBundle(NULL),
index 5e19ae2..ec71158 100644 (file)
@@ -20,7 +20,6 @@ SET(VIEW_MODULE_SOURCES
     ${PROJECT_SOURCE_DIR}/src/view/view_module.cpp
     ${PROJECT_SOURCE_DIR}/src/view/context_manager.cpp
 )
-SET(TARGET_VIEW_COMMON_LIB_STATIC "wrt-view-common")
 
 ADD_SUBDIRECTORY(common)  #ViewModule common library
 ADD_SUBDIRECTORY(webkit) #ViewModule based on Webkit2
index 24d5823..0588a06 100644 (file)
@@ -58,7 +58,6 @@ SET(VIEW_COMMON_SOURCES
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_custom_header_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_security_origin_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_security_support.cpp
-    ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_service_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_storage_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_uri_support.cpp
     ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_vibration_support.cpp
index 79b8e97..a90108c 100644 (file)
@@ -38,9 +38,7 @@ const char * const SET_VIEWMODES_MSGBODY_EXIT = "exit";
 
 namespace ToUIProcess {
 const char * const BLOCKED_URL = "ToUIProcess::BLOCKED_URL";
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
 const char * const SEND_WEBPROCESS_PID = "ToUIProcess::SEND_WEBPROCESS_PID";
-#endif
 } // namespace ToUIProcess
 
 namespace TizenScheme {
diff --git a/src/view/common/view_logic_service_support.cpp b/src/view/common/view_logic_service_support.cpp
deleted file mode 100644 (file)
index 3f55d2c..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    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.
- */
-/*
- * @file       view_logic_service_support.cpp
- * @author     Lukasz Marek (l.marek@samsung.com)
- * @version    1.0
- */
-
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-
-#include "view_logic_service_support.h"
-#include <string>
-#include <cstring>
-#include <sstream>
-#include <iostream>
-#include <fstream>
-#include <pcrecpp.h>
-#include <appsvc.h>
-#include <aul.h>
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xatom.h>
-
-namespace {
-const char *XWINDOW_PID_PROPERTY_NAME = "_NET_WM_PID";
-const char *XWINDOW_WEBPROCESS_PID_PROPERTY_NAME = "WRT_WEB_PROCESS_PID";
-}
-
-namespace ServiceSupport {
-
-void setWebProcessPidWindowProperty(unsigned int window, unsigned int pid)
-{
-    ecore_x_window_prop_property_set(
-        window,
-        ecore_x_atom_get(XWINDOW_WEBPROCESS_PID_PROPERTY_NAME),
-        ECORE_X_ATOM_CARDINAL, 32, &pid, 1);
-}
-
-unsigned int checkProperty(int pid, Display* display, Window window, Atom atom)
-{
-    Atom type;
-    int format;
-    unsigned long count;
-    unsigned long bytesAfter;
-    unsigned char *propPID = 0;
-
-    if (Success == XGetWindowProperty(display,
-                                      window,
-                                      atom,
-                                      0,
-                                      1,
-                                      False,
-                                      XA_CARDINAL,
-                                      &type,
-                                      &format,
-                                      &count,
-                                      &bytesAfter,
-                                      &propPID))
-    {
-        if (count) {
-            if (XA_CARDINAL == type && 32 == format) {
-                unsigned int windowpid = *((unsigned int *)propPID);
-                if (pid == windowpid) {
-                    LogDebug("found window " << window);
-                    XFree(propPID);
-                    return window;
-                }
-            }
-            else {
-                LogError("Unsupported format returned");
-            }
-        }
-        XFree(propPID);
-    }
-    return 0;
-}
-
-unsigned int XWindowIterate(int pid, Display* display, Window window)
-{
-    Atom atomPID = XInternAtom(display, XWINDOW_PID_PROPERTY_NAME, True);
-    Atom atomPIDWP = XInternAtom(display, XWINDOW_WEBPROCESS_PID_PROPERTY_NAME, True);
-    unsigned int result = checkProperty(pid, display, window, atomPID);
-    if (0 == result)
-    {
-        result = checkProperty(pid, display, window, atomPIDWP);
-    }
-    if (result) {
-        return result;
-    }
-
-    Window root;
-    Window parent;
-    Window *children = NULL;
-    unsigned int noOfChildren;
-    int status = XQueryTree(display,
-                            window,
-                            &root,
-                            &parent,
-                            &children,
-                            &noOfChildren);
-
-    if (0 == status || 0 == noOfChildren) {
-        XFree(children);
-        return 0;
-    }
-
-    for (unsigned int i = 0; i < noOfChildren; ++i) {
-        result = XWindowIterate(pid, display, children[i]);
-        if (result) {
-            break;
-        }
-    }
-
-    XFree(children);
-    return result;
-}
-
-std::string commandLineByPid(int pid)
-{
-    std::stringstream file;
-    std::string result;
-    file << "/proc/" << pid << "/cmdline";
-    std::ifstream in(file.str().c_str(), std::ios::in);
-    if (in.is_open()) {
-        std::getline(in, result);
-    }
-    else {
-        LogDebug("Cannot read cmdline");
-    }
-    return result;
-}
-
-unsigned int xWindowByPid(int pid)
-{
-   Display *display = XOpenDisplay(NULL);
-   if (!display) {
-       LogError("XOpenDisplay failed");
-       return 0;
-   }
-   int screen = DefaultScreen(display);
-   Window rootWindow = RootWindow(display, screen);
-   return XWindowIterate(pid, display, rootWindow);
-}
-
-std::string mime(bundle *b)
-{
-    const char *value = appsvc_get_mime(b);
-    return value ? value : std::string();
-}
-
-std::string operation(bundle *b)
-{
-    const char *value = appsvc_get_operation(b);
-    return value ? value : std::string();
-}
-
-std::string uri(bundle *b)
-{
-    const char *value = appsvc_get_uri(b);
-    return value ? value : std::string();
-}
-
-Disposition disposition(WidgetModel *model)
-{
-    Assert(model);
-    Assert(isService(model));
-    WrtDB::WidgetAppControlList appControlList = model->AppControlList.Get();
-    unsigned index = *model->AppControlIndex.Get();
-    FOREACH(appControlIt, appControlList)
-    {
-        if (index == appControlIt->index)
-        {
-            switch(appControlIt->disposition) {
-            case WrtDB::WidgetAppControl::Disposition::INLINE:
-                LogDebug("Control disposition: INLINE");
-                return INLINE;
-            default:
-                break;
-            }
-        }
-    }
-    return WINDOW;
-}
-
-int callerPID(bundle *b)
-{
-    const char *pid = appsvc_get_data(b, AUL_K_ORG_CALLER_PID);
-    if (pid) {
-        int result = 0;
-        std::stringstream ss(pid);
-        if (!(ss >> result)) {
-            LogError("PID value is incorrect");
-            return 0;
-        }
-        return result;
-    }
-    return 0;
-}
-
-bool isService(WidgetModel *model)
-{
-    return !model->AppControlIndex.Get().IsNull();
-}
-
-}
-
-#endif
\ No newline at end of file
diff --git a/src/view/common/view_logic_service_support.h b/src/view/common/view_logic_service_support.h
deleted file mode 100644 (file)
index 6caeb8e..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    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.
- */
-/*
- * @file       view_logic_service_support.h
- * @author     Lukasz Marek (l.marek@samsung.com)
- * @version    1.0
- */
-
-#ifndef SERVICE_SUPPORT_H_
-#define SERVICE_SUPPORT_H_
-
-#include <bundle.h>
-#include <widget_model.h>
-
-namespace ServiceSupport {
-
-typedef enum
-{
-    WINDOW,
-    INLINE
-} Disposition;
-
-void setWebProcessPidWindowProperty(unsigned int window, unsigned int pid);
-int callerPID(bundle *b);
-bool isService(WidgetModel *model);
-Disposition disposition(WidgetModel *model);
-unsigned int xWindowByPid(int pid);
-
-}
-
-#endif
index eacfeb8..186a5d2 100644 (file)
@@ -81,11 +81,8 @@ ADD_LIBRARY(${TARGET_VIEW_MODULE_LIB} STATIC
     ${VIEW_MODULE_SOURCES}
 )
 
-TARGET_LINK_LIBRARIES(
-    ${TARGET_VIEW_MODULE_LIB}
-    ${TARGET_VIEW_COMMON_LIB_STATIC}
+TARGET_LINK_LIBRARIES(${TARGET_VIEW_MODULE_LIB}
     ${VIEW_MODULE_DEP_LIBRARIES}
-    ${TARGET_WRT_ENGINE_STATIC}
     ${PROF_LIB}
 #    ${TARGET_PLUGIN_MODULE_LIB}
 )
index bd3025a..9eb6a1a 100644 (file)
@@ -114,10 +114,6 @@ Bundle::Bundle(WKBundleRef bundle) :
         _E("## Db attach was failed! Terminate WebProcess by force. ##");
         exit(-1);
     }
-
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    sendWebProcessPid();
-#endif
 }
 
 Bundle::~Bundle()
@@ -979,21 +975,6 @@ std::string Bundle::getScheme(std::string uri)
     return str;
 }
 
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-void Bundle::sendWebProcessPid()
-{
-    std::stringstream strPid;
-    strPid << getpid();
-    WKStringRef pidStr = WKStringCreateWithUTF8CString(strPid.str().c_str());
-    WKStringRef message =
-        WKStringCreateWithUTF8CString(
-            Message::ToUIProcess::SEND_WEBPROCESS_PID);
-    WKBundlePostMessage(m_bundle, message, pidStr);
-    WKRelease(pidStr);
-    WKRelease(message);
-}
-#endif
-
 extern "C"
 {
 WK_EXPORT
index 5d89fe0..fc2b774 100644 (file)
@@ -182,10 +182,6 @@ class Bundle
                           std::string & argEncodedBundle,
                           std::string & argTheme);
 
-
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    void sendWebProcessPid();
-#endif
 #ifdef CORS_WHITELISTING_ENABLED
     void bypassCORSforWARPAccessList(WrtDB::WidgetDAOReadOnly &dao);
 #endif
index f52a3fe..7ff76f2 100644 (file)
 #include <wrt-commons/custom-handler-dao-rw/custom_handler_dao.h>
 #include <popup-runner/PopupInvoker.h>
 #include <plugins-ipc-message/ipc_message_support.h>
-
-#include <appsvc/appsvc.h>
-#include <utilX.h>
-
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-#include "view_logic_service_support.h"
-
-extern "C" int appsvc_allow_transient_app(bundle *b, Ecore_X_Window id);
-extern "C" int appsvc_request_transient_app(bundle *b, Ecore_X_Window callee_id, appsvc_host_res_fn cbfunc, void *data);
-#endif
-
+#include <appsvc.h>
 namespace {
 // IME State value
 const char * const IME_STATE_ON = "on";
@@ -238,18 +228,6 @@ bool ViewLogic::createWebView(Ewk_Context* context,
     return true;
 }
 
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-int ViewLogic::appServiceCallerIsKilled(void *data)
-{
-    Assert(data);
-    ViewLogic *This = static_cast<ViewLogic *>(data);
-    if (!This->m_cbs->webkitExit.empty()) {
-        This->m_cbs->webkitExit();
-    }
-    return 0;
-}
-#endif
-
 void ViewLogic::prepareView(WidgetModel* m, const std::string &startUrl)
 {
     LogDebug("View prepare");
@@ -260,30 +238,6 @@ void ViewLogic::prepareView(WidgetModel* m, const std::string &startUrl)
     Assert(NULL != m_ewkContext);
     Assert(m_window);
 
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    if (ServiceSupport::isService(m_model))
-    {
-        bundle *b = ApplicationDataSingleton::Instance().getBundle();
-        if (ServiceSupport::Disposition::INLINE == ServiceSupport::disposition(m_model))
-        {
-            LogDebug("Set up INLINE disposition");
-            int pid = ServiceSupport::callerPID(b);
-            if (pid) {
-                unsigned windowId = ServiceSupport::xWindowByPid(pid);
-                appsvc_allow_transient_app(b, windowId);
-                appsvc_request_transient_app(b, elm_win_xwindow_get(m_window), appServiceCallerIsKilled, this);
-            }
-        }
-        else
-        {
-            LogDebug("Set up WINDOW disposition");
-        }
-    }
-    else
-    {
-        LogDebug("Starting regular widget");
-    }
-#endif
 
     ADD_PROFILING_POINT("initializeSupport", "start");
     initializeSupport();
@@ -420,6 +374,7 @@ void ViewLogic::resetWidget()
             removeEwkView(m_ewkViewList.back());
         }
         m_ewkViewList.clear();
+        m_currentEwkView = NULL;
 
         // create new webview
         createEwkView(evas_object_evas_get(m_window));
@@ -552,18 +507,7 @@ void ViewLogic::checkAsyncMessageFromBundle(const char* name, const char* body)
         // done by WebProcess itself (see: wrt-injected-bundle.cpp
         // and bundle_uri_handling.cpp)
         requestUrlBlocked(std::string(body));
-    }
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    else if (!strcmp(name, Message::ToUIProcess::SEND_WEBPROCESS_PID)) {
-        std::stringstream ss(body);
-        unsigned int pid = 0;
-        ss >> pid;
-        ServiceSupport::setWebProcessPidWindowProperty(
-            elm_win_xwindow_get(m_window),
-            pid);
-    }
-#endif
-    else if (!strcmp(name, Message::TizenScheme::CLEAR_ALL_COOKIES)) {
+    } else if (!strcmp(name, Message::TizenScheme::CLEAR_ALL_COOKIES)) {
         Ewk_Cookie_Manager* cookieManager =
             ewk_context_cookie_manager_get(m_ewkContext);
         if (!cookieManager) {
index f6ad295..739be86 100644 (file)
@@ -271,10 +271,6 @@ class ViewLogic : public ViewModule::IViewModule
                                      Evas_Object* obj,
                                      void* eventInfo);
 
-#ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE
-    static int appServiceCallerIsKilled(void *data);
-#endif
-
     void attachToCustomHandlersDao();
     void detachFromCustomHandlersDao();
 
index 84c2c37..2469c46 100644 (file)
@@ -35,8 +35,6 @@ char const * const TIZEN_CHANGE_USERAGNET = "tizen://changeUA";
 
 static Eina_Bool exitAppIdlerCallback(void* /*data*/)
 {
-    // webapp termination
-    ewk_shutdown();
     elm_exit();
     return ECORE_CALLBACK_CANCEL;
 }
index 6fb05ea..c0dd663 100644 (file)
@@ -20,6 +20,7 @@ SET(WRT_CLIENT_SRCS
     ${PROJECT_SOURCE_DIR}/src/wrt-client/client_command_line_parser.cpp
     ${PROJECT_SOURCE_DIR}/src/wrt-client/client_ide_support.cpp
     ${PROJECT_SOURCE_DIR}/src/wrt-client/client_service_support.cpp
+    ${PROJECT_SOURCE_DIR}/src/wrt-client/client_submode_support.cpp
     ${PROJECT_SOURCE_DIR}/src/wrt-client/splash_screen_support.cpp
     ${PROJECT_SOURCE_DIR}/src/wrt-client/wrt-client.cpp
     ${PROJECT_SOURCE_DIR}/src/wrt-client/auto_rotation_support.cpp
@@ -53,7 +54,6 @@ ADD_EXECUTABLE(${TARGET_WRT_CLIENT}
 TARGET_LINK_LIBRARIES(${TARGET_WRT_CLIENT}
     ${CLIENT_DEP_LIBRARIES}
     ${TARGET_CORE_MODULE_LIB}
-    ${TARGET_WRT_ENGINE_STATIC}
     ${SMACK_LABELING_SUPPORT_STATIC}
     "-pie"
 )
diff --git a/src/wrt-client/client_submode_support.cpp b/src/wrt-client/client_submode_support.cpp
new file mode 100644 (file)
index 0000000..e65718c
--- /dev/null
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/*
+ * @file       client_submode_support.cpp
+ * @author     Jihoon Chung (jihoon.chung@samsung.com)
+ * @version    1.0
+ */
+
+#include "client_submode_support.h"
+
+#include <memory>
+#include <sstream>
+#include <Ecore.h>
+#include <Elementary.h>
+#include <bundle.h>
+
+#include <dpl/assert.h>
+#include <dpl/log/secure_log.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+#include <application_data.h>
+
+namespace ClientModule {
+namespace {
+const unsigned int EMPTY = 0;
+const unsigned int INLINE_MODE = 1;
+const unsigned int TRANSIENT_WINDOW = 1 << 1;
+}
+
+ //Implementation class
+class SubmodeSupportImplementation
+{
+  private:
+    bool m_initialized;
+    WrtDB::TizenAppId m_appId;
+    unsigned int m_mode;
+
+    void setMode(const int mode)
+    {
+        m_mode |= mode;
+    }
+
+    bool getMode(const int mode)
+    {
+        return m_mode & mode;
+    }
+
+    static Eina_Bool destoryCallback(void* data, int /*type*/, void* event)
+    {
+        _D("called");
+        Ecore_X_Window callerId = reinterpret_cast<Ecore_X_Window>(data);
+
+        Assert(event);
+        Ecore_X_Event_Window_Hide* ev =
+            static_cast<Ecore_X_Event_Window_Hide*>(event);
+
+        if(ev->win == callerId) {
+            elm_exit();
+        }
+        return ECORE_CALLBACK_CANCEL;
+    }
+
+  public:
+    SubmodeSupportImplementation() :
+        m_initialized(false),
+        m_mode(EMPTY)
+    {
+    }
+
+    void initialize(WrtDB::TizenAppId appId)
+    {
+        _D("called");
+
+        m_appId = appId;
+        WrtDB::WidgetDAOReadOnly dao(m_appId);
+        WrtDB::WidgetAppControlList widgetApplicationControlList;
+        dao.getAppControlList(widgetApplicationControlList);
+        FOREACH(it, widgetApplicationControlList) {
+            if (it->disposition ==
+                WrtDB::WidgetAppControl::Disposition::INLINE)
+            {
+                _D("disposition");
+                setMode(INLINE_MODE);
+            }
+        }
+
+        m_initialized = true;
+    }
+
+    void deinitialize(void)
+    {
+        _D("called");
+        m_initialized = false;
+    }
+
+    bool isInlineMode(void)
+    {
+        return getMode(INLINE_MODE);
+    }
+
+    bool isNeedTerminateOnSuspend(void)
+    {
+        if (isInlineMode()) {
+            return !getMode(TRANSIENT_WINDOW);
+        }
+        return false;
+    }
+
+    bool transientWindow(Ecore_X_Window calleeId)
+    {
+        _D("called");
+        if (!m_initialized) {
+            _E("not initialized");
+            return false;
+        }
+
+        bundle* b = ApplicationDataSingleton::Instance().getBundle();
+        if (!b) {
+            _W("Service data is empty");
+            return false;
+        }
+        const char* callerIdPtr = bundle_get_val(b, "__APP_SVC_K_WIN_ID__");
+        if (callerIdPtr) {
+            Ecore_X_Window callerId = atoi(callerIdPtr);
+            _D("Caller x handle = %u", callerId);
+            ecore_x_icccm_transient_for_set(calleeId, callerId);
+            ecore_x_window_client_manage(callerId);
+            ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY,
+                                    destoryCallback,
+                                    reinterpret_cast<void*>(callerId));
+            setMode(TRANSIENT_WINDOW);
+        } else {
+            _W("Service data is empty");
+            return false;
+        }
+
+        return true;
+    }
+};
+
+SubmodeSupport::SubmodeSupport() :
+    m_impl(new SubmodeSupportImplementation())
+{
+}
+
+SubmodeSupport::~SubmodeSupport()
+{
+}
+
+void SubmodeSupport::initialize(WrtDB::TizenAppId appId)
+{
+    m_impl->initialize(appId);
+}
+
+void SubmodeSupport::deinitialize(void)
+{
+    m_impl->deinitialize();
+}
+
+bool SubmodeSupport::isInlineMode(void)
+{
+    return m_impl->isInlineMode();
+}
+
+bool SubmodeSupport::isNeedTerminateOnSuspend(void)
+{
+    return m_impl->isNeedTerminateOnSuspend();
+}
+
+bool SubmodeSupport::transientWindow(Ecore_X_Window calleeId)
+{
+    return m_impl->transientWindow(calleeId);
+}
+} // namespace ClientModule
diff --git a/src/wrt-client/client_submode_support.h b/src/wrt-client/client_submode_support.h
new file mode 100644 (file)
index 0000000..4fdcf66
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+/*
+ * @file       client_submode_support.h
+ * @author     Jihoon Chung (jihoon.chung@samsung.com)
+ * @version    1.0
+ */
+
+#ifndef CLIENT_SUBMODE_SUPPORT_H_
+#define CLIENT_SUBMODE_SUPPORT_H_
+
+#include <memory>
+#include <Ecore_X.h>
+
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+
+namespace ClientModule {
+class SubmodeSupportImplementation;
+class SubmodeSupport
+{
+  public:
+    SubmodeSupport();
+    virtual ~SubmodeSupport();
+    void initialize(WrtDB::TizenAppId appId);
+    void deinitialize(void);
+    bool isInlineMode(void);
+    bool isNeedTerminateOnSuspend(void);
+    bool transientWindow(Ecore_X_Window win);
+
+  private:
+    std::unique_ptr<SubmodeSupportImplementation> m_impl;
+};
+} // namespace ClientModule
+#endif // CLIENT_SUBMODE_SUPPORT_H_
\ No newline at end of file
index 6cfd050..b3a5883 100644 (file)
@@ -43,6 +43,7 @@
 #include "client_command_line_parser.h"
 #include "client_ide_support.h"
 #include "client_service_support.h"
+#include "client_submode_support.h"
 
 //W3C PACKAGING enviroment variable name
 #define W3C_DEBUG_ENV_VARIABLE "DEBUG_LOAD_FINISH"
@@ -82,7 +83,8 @@ WrtClient::WrtClient(int argc, char **argv) :
     m_initialViewMode(VIEWMODE_TYPE_MAXIMIZED),
     m_currentViewMode(VIEWMODE_TYPE_MAXIMIZED),
     m_isWebkitFullscreen(false),
-    m_isFullscreenByPlatform(false)
+    m_isFullscreenByPlatform(false),
+    m_submodeSupport(new ClientModule::SubmodeSupport())
 {
     Touch();
     LogDebug("App Created");
@@ -126,6 +128,11 @@ void WrtClient::OnPause()
         LogWarning("Widget is not running to be suspended");
         return;
     }
+    if (m_submodeSupport->isNeedTerminateOnSuspend()) {
+        LogDebug("Current mode cannot support suspend");
+        elm_exit();
+        return;
+    }
     m_widget->Suspend();
     m_widgetState = WidgetState_Suspended;
 }
@@ -396,6 +403,7 @@ void WrtClient::launchStep()
     WrtDB::WidgetSettings widgetSettings;
     m_dao->getWidgetSettings(widgetSettings);
     m_settingList.reset(new WidgetSettingList(widgetSettings));
+    m_submodeSupport->initialize(DPL::FromASCIIString(m_tizenId));
 
     DPL::Optional<DPL::String> defloc = m_dao->getDefaultlocale();
     if (!defloc.IsNull()) {
@@ -462,6 +470,18 @@ void WrtClient::launchStep()
     //you can't show window with splash screen before PrepareView
     //ewk_view_add_with_context() in viewLogic breaks window
     m_windowData->init();
+    // sub-mode support
+    if (m_submodeSupport->isInlineMode()) {
+        if (m_submodeSupport->transientWindow(
+                elm_win_xwindow_get(
+                    m_windowData->getEvasObject(Layer::WINDOW))))
+        {
+            LogDebug("Success to set submode");
+        } else {
+            LogWarning("Fail to set submode");
+        }
+
+    }
     m_windowData->smartCallbackAdd(Layer::FOCUS,
                                    "focused",
                                    focusedCallback,
@@ -779,6 +799,7 @@ void WrtClient::shutdownStep()
         m_widget->Hide();
         // AutoRotation, focusCallback use m_widget pointer internally.
         // It must be unset before m_widget is released.
+        m_submodeSupport->deinitialize();
         unsetWindowOrientation();
         m_windowData->smartCallbackDel(Layer::FOCUS,
                                        "focused",
index bed4659..7a7e703 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef WRT_CLIENT_H
 #define WRT_CLIENT_H
 
+#include <memory>
 #include <dpl/application.h>
 #include <dpl/generic_event.h>
 #include <dpl/event/controller.h>
 
 DECLARE_GENERIC_EVENT_0(NextStepEvent)
 
+namespace ClientModule {
+class SubmodeSupport;
+}
+
 class WrtClient :
     public DPL::Application,
     private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
@@ -142,6 +147,8 @@ class WrtClient :
     std::string m_currentViewMode;
     bool m_isWebkitFullscreen;
     bool m_isFullscreenByPlatform;
+
+    std::unique_ptr<ClientModule::SubmodeSupport> m_submodeSupport;
 };
 
 #endif // WRT_CLIENT_H
index e4450ab..f48d491 100644 (file)
@@ -317,33 +317,6 @@ int main(int argc, char* argv[])
                 break;
 
             case 'd':
-                // create service
-                ret = service_create(&serviceHandle);
-                if (SERVICE_ERROR_NONE != ret && NULL == serviceHandle) {
-                    LogError("Fail to create service");
-                    return FALSE;
-                }
-
-                // set debug mode
-                ret = service_add_extra_data(serviceHandle,
-                                             "debug",
-                                             "true");
-                if (SERVICE_ERROR_NONE != ret) {
-                    LogError("Fail to set debug mode [" << ret << "]");
-                    service_destroy(serviceHandle);
-                    return FALSE;
-                }
-
-                // set pid
-                snprintf(pid, sizeof(pid), "%d", getpid());
-                ret = service_add_extra_data(serviceHandle,
-                                             "pid",
-                                             pid);
-                if (SERVICE_ERROR_NONE != ret) {
-                    LogError("Fail to set pid [" << ret << "]");
-                    service_destroy(serviceHandle);
-                    return FALSE;
-                }
                 isDebugMode = true;
                 break;
 
@@ -393,68 +366,69 @@ int main(int argc, char* argv[])
         }
 
         if (op == 's') {
-            /* check if this is request for debug mode, or not */
-            if (true != isDebugMode) {
-                // case of "-d" option, service_create is already allocated
-                // create service
-                ret = service_create(&serviceHandle);
-                if (SERVICE_ERROR_NONE != ret && NULL == serviceHandle) {
-                    printf("result: %s\n", "failed");
-                    return -1;
-                }
+            if (strlen(applicationId) <= 0) {
+                printf("result: %s\n", "failed");
+                return -1;
             }
 
-            if (strlen(applicationId) > 0) {
-                // do setuid to '5000' uid to communicate
-                //with webapp using RT signal.
-                gid_t group_list[1];
-                group_list[0] = LOGGING_DEFAULT_GID;
-
-                if (setgroups(sizeof(group_list), group_list) < 0) {
-                    printf("result: %s\n", "failed");
-                    return -1;
-                }
+            // create service
+            ret = service_create(&serviceHandle);
+            if (SERVICE_ERROR_NONE != ret && NULL == serviceHandle) {
+                printf("result: %s\n", "failed");
+                return -1;
+            }
 
-                if (setreuid(WEBAPP_DEFAULT_UID, WEBAPP_DEFAULT_GID) < 0) {
-                    printf("result: %s\n", "failed");
-                    return -1;
-                }
+            // set package
+            ret = service_set_package(serviceHandle, applicationId);
+            if (SERVICE_ERROR_NONE != ret) {
+                printf("result: %s\n", "failed");
+                service_destroy(serviceHandle);
+                return -1;
+            }
 
-                // set package
-                ret = service_set_package(serviceHandle, applicationId);
+            if (true == isDebugMode) {
+                // set debug mode
+                ret = service_add_extra_data(serviceHandle, "debug", "true");
                 if (SERVICE_ERROR_NONE != ret) {
-                    printf("result: %s\n", "failed");
+                    LogError("Fail to set debug mode [" << ret << "]");
                     service_destroy(serviceHandle);
-                    return -1;
+                    return FALSE;
                 }
 
-                if (true == isDebugMode) {
-                    ecore_init();
-                    serviceTimer = ecore_timer_add(timeout, timerCallback, NULL);
+                // set pid
+                snprintf(pid, sizeof(pid), "%d", getpid());
+                ret = service_add_extra_data(serviceHandle, "pid", pid);
+                if (SERVICE_ERROR_NONE != ret) {
+                    LogError("Fail to set pid [" << ret << "]");
+                    service_destroy(serviceHandle);
+                    return FALSE;
                 }
 
-                //launch service
+                ecore_init();
+                serviceTimer = ecore_timer_add(timeout, timerCallback, NULL);
                 ret = service_send_launch_request(serviceHandle,
                                                   serviceReplyCallback,
                                                   serviceTimer);
-                if (SERVICE_ERROR_NONE != ret) {
-                    printf("result: %s\n", "failed");
-                    service_destroy(serviceHandle);
-                    return -1;
-                }
+            } else {
+                ret = service_send_launch_request(serviceHandle, NULL, NULL);
+            }
 
+            if (SERVICE_ERROR_NONE != ret) {
+                printf("result: %s\n", "");
                 service_destroy(serviceHandle);
-            } else {
-                printf("result: %s\n", "failed");
                 return -1;
             }
 
+            service_destroy(serviceHandle);
+
             if (true == isDebugMode) {
+                // wait response from callee
                 ecore_main_loop_begin();
                 return 0;
+            } else {
+                // This text should be showed for IDE
+                printf("result: %s\n", "launched");
             }
-            // This text should be showed for IDE
-            printf("result: %s\n", "launched");
             return 0;
         } else if (op == 'k') {
             bool isRunning = false;