${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
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
--- /dev/null
+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}
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)
add_subdirectory(standards)
add_subdirectory(wrt-popup)
add_subdirectory(plugins-installer)
+add_subdirectory(plugins-ipc-message)
--- /dev/null
+# 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)
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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