[Release] wrt-plugins-common_0.3.85 submit/tizen_2.1/20130508.123532
authorJihoon Chung <jihoon.chung@samsung.com>
Wed, 8 May 2013 12:34:48 +0000 (21:34 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Wed, 8 May 2013 12:35:22 +0000 (21:35 +0900)
CMakeLists.txt
packaging/wrt-plugins-common.spec
pkgconfigs/wrt-plugins-ipc-message.pc.in [new file with mode: 0644]
src/CMakeLists.txt
src/Commons/IEvent.h
src/CommonsJavaScript/Converter.cpp
src/plugin-loading/plugin_logic.cpp
src/plugins-ipc-message/CMakeLists.txt [new file with mode: 0644]
src/plugins-ipc-message/ipc_message_support.cpp [new file with mode: 0644]
src/plugins-ipc-message/ipc_message_support.h [new file with mode: 0644]

index 6d2eeb9..12ec039 100644 (file)
@@ -34,7 +34,8 @@ include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}/src/CommonsJavaScript
   ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-loading
   ${CMAKE_CURRENT_SOURCE_DIR}/src/js-overlay
-  ${CMAKE_CURRENT_SOURCE_DIR}/src/wrt-popup/ace/popup-runner)
+  ${CMAKE_CURRENT_SOURCE_DIR}/src/wrt-popup/ace/popup-runner
+  ${CMAKE_CURRENT_SOURCE_DIR}/src/plugins_ipc_message)
 
 ##############################################################################
 # Build type
@@ -151,6 +152,7 @@ configure_and_install_pkg(wrt-popup-runner.pc)
 configure_and_install_pkg(wrt-popup-ace-runner.pc)
 configure_and_install_pkg(wrt-popup-wrt-runner.pc)
 configure_and_install_pkg(wrt-plugins-api-support.pc)
+configure_and_install_pkg(wrt-plugins-ipc-message.pc)
 
 ################################################################################
 # Cache
index c857083..9c599f7 100644 (file)
@@ -1,7 +1,7 @@
-#git:framework/web/wrt-plugins-common wrt-plugins-common_0.3.84
+#git:framework/web/wrt-plugins-common wrt-plugins-common_0.3.85
 Name:       wrt-plugins-common
 Summary:    wrt-plugins common library
-Version:    0.3.84
+Version:    0.3.85
 Release:    1
 Group:      Development/Libraries
 License:    Apache License, Version 2.0
diff --git a/pkgconfigs/wrt-plugins-ipc-message.pc.in b/pkgconfigs/wrt-plugins-ipc-message.pc.in
new file mode 100644 (file)
index 0000000..8088720
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=/usr
+project_name=@CMAKE_PROJECT_NAME@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/${project_name}
+
+Name: wrt ipc message support
+Description: Support IPC between plugins and UI Process
+Version: @CMAKE_PROJECT_VERSION@
+Requires: dpl-efl ewebkit2
+Libs: -L${libdir} -lwrt-plugins-ipc-message
+Cflags: -I${includedir}
index 9c0d041..259b2da 100644 (file)
@@ -45,9 +45,11 @@ SET(TARGET_POPUP_ACE_RUNNER_LIB "wrt-popup-ace-runner")
 SET(TARGET_POPUP_WRT "wrt-popup-wrt-runtime")
 SET(TARGET_POPUP_WRT_RUNNER_LIB "wrt-popup-wrt-runner")
 set(TARGET_PLUGINS_API_SUPPORT "wrt-plugins-api-support")
+set(TARGET_PLUGINS_IPC_MESSAGE_LIB "wrt-plugins-ipc-message")
 
 set(PLUGIN_LOADING_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/plugin-loading)
 set(PLUGINS_API_SUPPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/plugins-api-support)
+set(PLUGINS_IPC_MESSAGE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/plugins-ipc-message)
 
 add_subdirectory(plugins-api-support)
 add_subdirectory(plugin-loading)
@@ -58,3 +60,4 @@ add_subdirectory(modules)
 add_subdirectory(standards)
 add_subdirectory(wrt-popup)
 add_subdirectory(plugins-installer)
+add_subdirectory(plugins-ipc-message)
index 7764fde..207f5bb 100644 (file)
@@ -114,6 +114,7 @@ class IEvent : /*private DPL::WaitableEvent, */ public IEventController
     DPL::WaitableEvent *m_synchronousEventFlag;
     DPL::WaitableEvent *m_finishedFlag;
     DPL::WaitableEvent *m_cancelStatusFlag;
+    bool m_cancelSignalAhead;
     bool m_cancelled;
     bool m_cancelAllowed;
 
@@ -125,6 +126,7 @@ class IEvent : /*private DPL::WaitableEvent, */ public IEventController
         m_synchronousEventFlag(NULL),
         m_finishedFlag(NULL),
         m_cancelStatusFlag(NULL),
+        m_cancelSignalAhead(false),
         m_cancelled(false),
         m_cancelAllowed(false)
     {}
@@ -161,6 +163,8 @@ class IEvent : /*private DPL::WaitableEvent, */ public IEventController
     void signalCancelStatusFlag()
     {
         LogDebug("signaling cancel");
+        DPL::Mutex::ScopedLock lock(&m_stateMutex);
+        m_cancelSignalAhead = true;
         if (m_cancelStatusFlag) {
             m_cancelStatusFlag->Signal();
         }
@@ -333,9 +337,9 @@ class IEvent : /*private DPL::WaitableEvent, */ public IEventController
     bool cancelRequest()
     {
         LogDebug("trying to cancel");
-        assert(
-            HANDLING_ASYNCHRONOUS == m_handlingType ||
-            HANDLING_ASYNCHRONOUS_MANUAL_ANSWER == m_handlingType);
+        assert(HANDLING_ASYNCHRONOUS == m_handlingType ||
+               HANDLING_ASYNCHRONOUS_MANUAL_ANSWER == m_handlingType);
+        bool signaled = false;
         {
             DPL::Mutex::ScopedLock lock(&m_stateMutex);
             if (m_cancelled) {
@@ -358,12 +362,16 @@ class IEvent : /*private DPL::WaitableEvent, */ public IEventController
             }
             LogDebug("cancelling");
             m_cancelled = true;
+            signaled = m_cancelSignalAhead;
+            if (!signaled) {
+                //create waitable handle
+                getCancelStatusFlag();
+            }
         }
         LogDebug("waiting for cancel flag");
-
-#if 0   // temporary fix for ApplicationLaunchAppControl eventhandling
-        DPL::WaitForSingleHandle(getCancelStatusFlag().GetHandle());
-#endif
+        if (!signaled) {
+            DPL::WaitForSingleHandle(getCancelStatusFlag().GetHandle());
+        }
         delete m_cancelStatusFlag;
         m_cancelStatusFlag = NULL;
         return m_cancelAllowed;
index 2d3aa9f..cdaed58 100644 (file)
@@ -291,7 +291,8 @@ JSValueRef Converter::toJSValueRef(const tm& arg)
 
 JSValueRef Converter::toJSValueRef(const time_t arg)
 {
-    struct tm tminfo = {0, };
+    struct tm tminfo;
+    memset(&tminfo,0,sizeof(tminfo));
     localtime_r(&arg, &tminfo);
     return toJSValueRef(tminfo);
 }
index 08d056a..aef6950 100644 (file)
@@ -433,7 +433,10 @@ void PluginLogic::Impl::dispatchJavaScriptEvent(JSGlobalContextRef context,
 
 unsigned int PluginLogic::Impl::windowHandle() const
 {
-    PLUGIN_LOGIC_SANITY_CHECK
+    if (!s_sanityCheck)
+    {
+        LogError("Object is not available. Wrong flow occured");
+    }
     return m_windowHandle;
 }
 
diff --git a/src/plugins-ipc-message/CMakeLists.txt b/src/plugins-ipc-message/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d3da03e
--- /dev/null
@@ -0,0 +1,60 @@
+# 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     CMakeLists.txt
+# @author   Jihoon Chung (jihoon.chung@samsung.com)
+# @version  1.0
+#
+
+pkg_search_module(dpl REQUIRED dpl-efl)
+pkg_search_module(webkit2 REQUIRED ewebkit2)
+
+set(PLUGINS_IPC_MESSAGE_SOURCES
+    ${PLUGINS_IPC_MESSAGE_DIRS}/ipc_message_support.cpp
+)
+
+INCLUDE_DIRECTORIES(
+    ${PLUGINS_IPC_MESSAGE_DIRS}
+    ${webkit2_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(${TARGET_PLUGINS_IPC_MESSAGE_LIB} SHARED
+    ${PLUGINS_IPC_MESSAGE_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_PLUGINS_IPC_MESSAGE_LIB} PROPERTIES
+    COMPILE_FLAGS -fPIC
+    LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
+)
+
+SET_TARGET_PROPERTIES(${TARGET_PLUGINS_IPC_MESSAGE_LIB} PROPERTIES
+    SOVERSION ${CMAKE_PROJECT_API_VERSION}
+    VERSION ${CMAKE_PROJECT_VERSION}
+)
+
+target_link_libraries(${TARGET_PLUGINS_IPC_MESSAGE_LIB}
+    ${dpl_LIBRARIES}
+    ${webkit2_LIBRARIES}
+)
+
+INSTALL(TARGETS ${TARGET_PLUGINS_IPC_MESSAGE_LIB}
+    DESTINATION lib
+    PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+    GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+)
+
+INSTALL(FILES
+    ipc_message_support.h
+    DESTINATION include/plugins-ipc-message)
diff --git a/src/plugins-ipc-message/ipc_message_support.cpp b/src/plugins-ipc-message/ipc_message_support.cpp
new file mode 100644 (file)
index 0000000..db1e8a8
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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        ipc_message_support.cpp
+ * @author      Jihoon Chung (jihoon.chung@samsung.com)
+ * @version     1.0
+ * @brief       Implementation of IPC between plugins and UI Process
+ */
+#include "ipc_message_support.h"
+
+#include <string>
+#include <sstream>
+#include <WKBundle.h>
+#include <WKString.h>
+#include <WKType.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+
+static WKBundleRef s_injectedBundleRef = NULL;
+
+namespace {
+std::string toString(WKStringRef str)
+{
+    if (WKStringIsEmpty(str)) {
+        return std::string();
+    }
+    size_t size = WKStringGetMaximumUTF8CStringSize(str);
+    char buffer[size + 1];
+    WKStringGetUTF8CString(str, buffer, size + 1);
+    return buffer;
+}
+}
+
+void IPCMessageSupport::setWKBundleRef(WKBundleRef bundleRef)
+{
+    LogDebug("setWKBundleRef called");
+    s_injectedBundleRef = bundleRef;
+}
+
+const char* IPCMessageSupport::sendMessageToUiProcess(
+    const char* name,
+    const char* body)
+{
+    LogDebug("sendMessageToUiProcess called");
+    if (s_injectedBundleRef == NULL) {
+        LogError("UI Process information isn't set");
+        return NULL;
+    }
+    LogDebug("name = [" << name << "]");
+    LogDebug("body = [" << body << "]");
+
+    if (!name) {
+        return NULL;
+    }
+    WKStringRef bodyWKString = NULL;
+    WKStringRef nameWKString = WKStringCreateWithUTF8CString(name);
+    if (body) {
+        bodyWKString = WKStringCreateWithUTF8CString(body);
+    }
+    WKTypeRef retWKType = NULL;
+    WKBundlePostSynchronousMessage(s_injectedBundleRef,
+                                   nameWKString,
+                                   bodyWKString,
+                                   &retWKType);
+    WKRelease(nameWKString);
+    if (bodyWKString) {
+        WKRelease(bodyWKString);
+    }
+    std::string retString = toString(static_cast<WKStringRef>(retWKType));
+    WKRelease(retWKType);
+
+    return strdup(retString.c_str());
+}
diff --git a/src/plugins-ipc-message/ipc_message_support.h b/src/plugins-ipc-message/ipc_message_support.h
new file mode 100644 (file)
index 0000000..0bde70a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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        ipc_message_support.h
+ * @author      Jihoon Chung (jihoon.chung@samsung.com)
+ * @version     1.0
+ * @brief       Implementation of IPC between plugins and UI Process
+ */
+#ifndef WRT_SRC_IPC_MESSAGE_SUPPORT
+#define WRT_SRC_IPC_MESSAGE_SUPPORT
+
+#include <string>
+#include <WKBundle.h>
+
+namespace IPCMessageSupport {
+void setWKBundleRef(WKBundleRef bundleRef);
+const char* sendMessageToUiProcess(const char* name, const char* body);
+}
+
+#endif // WRT_SRC_IPC_MESSAGE_SUPPORT
\ No newline at end of file