${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/plugins_ipc_message)
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/plugins_ipc_message
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/dispatch-event)
##############################################################################
# Build type
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)
+configure_and_install_pkg(wrt-dispatch-event.pc)
################################################################################
# Cache
--- /dev/null
+prefix=/usr
+project_name=@CMAKE_PROJECT_NAME@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/wrt-dispatch-event
+
+Name: wrt dispatch event support
+Description: Support to dispatch DOM event
+Version: @CMAKE_PROJECT_VERSION@
+Requires: dpl-efl ewebkit2
+Libs: -L${libdir} -lwrt-dispatch-event
+Cflags: -I${includedir}
add_subdirectory(js-overlay)
add_subdirectory(Commons)
add_subdirectory(CommonsJavaScript)
+add_subdirectory(dispatch-event)
add_subdirectory(modules)
add_subdirectory(standards)
add_subdirectory(wrt-popup)
--- /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 Tae-Jeong Lee (taejeong.lee@samsung.com)
+# @version 1.0
+#
+
+pkg_search_module(webkit2 REQUIRED ewebkit2)
+pkg_search_module(dpl REQUIRED dpl-efl)
+
+SET(TARGET_NAME wrt-dispatch-event)
+
+SET(SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/dispatch_event_support.cpp
+)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${webkit2_INCLUDE_DIRS}
+ ${dpl_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ ${webkit2_LIBRARIES}
+ ${dpl_LIBRARIES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ COMPILE_FLAGS -fPIC
+ LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
+)
+
+SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
+ SOVERSION ${CMAKE_PROJECT_API_VERSION}
+ VERSION ${CMAKE_PROJECT_VERSION}
+)
+
+INSTALL(TARGETS ${TARGET_NAME}
+ DESTINATION ${DESTINATION_LIB_PREFIX}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+)
+
+INSTALL(FILES dispatch_event_support.h DESTINATION include/wrt-dispatch-event)
\ No newline at end of file
--- /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 dispatch_event_support.cpp
+ * @author Tae-Jeong Lee (taejeong.lee@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+
+#ifndef _DISPATCH_EVENT_SUPPORT_CPP_
+#define _DISPATCH_EVENT_SUPPORT_CPP_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/log/log.h>
+
+#include "dispatch_event_support.h"
+
+namespace DispatchEventSupport {
+
+static std::string getExceptionString(JSContextRef context, JSValueRef exception)
+{
+ if (exception)
+ {
+ JSStringRef jsString = JSValueToStringCopy(context, exception, NULL);
+ size_t bufSize = JSStringGetMaximumUTF8CStringSize(jsString);
+
+ char* buf = new char[bufSize];
+ JSStringGetUTF8CString(jsString, buf, bufSize);
+ JSStringRelease(jsString);
+
+ std::string ret = buf;
+ delete[] buf;
+
+ return ret;
+ }
+ else
+ {
+ return "NULL";
+ }
+}
+
+void dispatchAppServiceEvent(JSContextRef context, const float scale, const std::string bundle)
+{
+ LogDebug("DispatchTizenServiceEvent(" << context << ", " << scale << ", " << bundle << ")");
+
+ if (context != NULL)
+ {
+ std::stringstream script;
+
+ script << "{\n"
+ << " var event = document.createEvent(\"CustomEvent\");\n"
+ << " event.initCustomEvent(\"appservice\", true, true);\n"
+ << " event.scale = " << scale << ";\n"
+ << " event.__bundle = \"" << bundle << "\";\n"
+ << " document.dispatchEvent(event);\n"
+ << " \n"
+ << " for (var i=0; i < window.frames.length; i++)\n"
+ << " { window.frames[i].document.dispatchEvent(event); }\n"
+ << "}";
+
+ // just for debugging
+ // LogDebug("script :\n" << script.str());
+
+ JSValueRef exception = NULL, ret = NULL;
+ JSStringRef jsScript = JSStringCreateWithUTF8CString(script.str().c_str());
+
+ ret = JSEvaluateScript(context, jsScript, NULL, NULL, 1, &exception);
+
+ JSStringRelease(jsScript);
+
+ LogDebug("JSEvaluateScript() - ret:" << ret << ", exception:" << exception << " (" << getExceptionString(context, exception) << ")");
+ }
+}
+
+void dispatchSoftKeyboardChangeEvent(JSContextRef context, const std::string state, const int width, const int height)
+{
+ LogDebug("dispatchSoftKeyboardChangeEvent(" << context << ", " << state << ", " << width << ", " << height << ")");
+
+ if (context != NULL)
+ {
+ std::stringstream script;
+
+ script << "{\n"
+ << " var event = document.createEvent(\"CustomEvent\");\n"
+ << " event.initCustomEvent(\"softkeyboardchange\", true, true);\n"
+ << " event.state = \"" << state << "\";\n"
+ << " event.width = " << width << ";\n"
+ << " event.height = " << height << ";\n"
+ << " document.dispatchEvent(event);\n"
+ << " \n"
+ << " for (var i=0; i < window.frames.length; i++)\n"
+ << " { window.frames[i].document.dispatchEvent(event); }\n"
+ << "}";
+
+ // just for debugging
+ // LogDebug("script :\n" << script.str());
+
+ JSValueRef exception = NULL, ret = NULL;
+ JSStringRef jsScript = JSStringCreateWithUTF8CString(script.str().c_str());
+
+ ret = JSEvaluateScript(context, jsScript, NULL, NULL, 1, &exception);
+
+ JSStringRelease(jsScript);
+
+ LogDebug("JSEvaluateScript() - ret:" << ret << ", exception:" << exception << " (" << getExceptionString(context, exception) << ")");
+ }
+}
+
+void dispatchStorageEvent(JSContextRef context, const std::string key, const std::string oldValue, const std::string newValue, const std::string url)
+{
+ LogDebug("dispatchStorageEvent(" << context << ", " << key << ", " << oldValue << ", " << newValue << ", " << url << ")");
+
+ if (context != NULL)
+ {
+ std::stringstream script;
+
+ script << "{\n"
+ << " var event = document.createEvent(\"CustomEvent\");\n"
+ << " event.initCustomEvent(\"storage\", true, true);\n"
+ << " event.key = \"" << key << "\";\n"
+ << " event.oldValue = \"" << oldValue << "\";\n"
+ << " event.newValue = \"" << newValue << "\";\n"
+ << " event.url = \"" << url << "\";\n"
+ << " event.storageArea = widget.preferences;\n"
+ << " document.dispatchEvent(event);\n"
+ << " \n"
+ << " for (var i=0; i < window.frames.length; i++)\n"
+ << " { window.frames[i].document.dispatchEvent(event); }\n"
+ << "}";
+
+ // just for debugging
+ // LogDebug("script :\n" << script.str());
+
+ JSValueRef exception = NULL, ret = NULL;
+ JSStringRef jsScript = JSStringCreateWithUTF8CString(script.str().c_str());
+
+ ret = JSEvaluateScript(context, jsScript, NULL, NULL, 1, &exception);
+
+ JSStringRelease(jsScript);
+
+ LogDebug("JSEvaluateScript() - ret:" << ret << ", exception:" << exception << " (" << getExceptionString(context, exception) << ")");
+ }
+}
+
+}
+#endif //_DISPATCH_EVENT_SUPPORT_CPP_
--- /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 dispatch_event_support.h
+ * @author Tae-Jeong Lee (taejeong.lee@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+
+#ifndef _DISPATCH_EVENT_SUPPORT_H_
+#define _DISPATCH_EVENT_SUPPORT_H_
+
+namespace DispatchEventSupport {
+
+void dispatchAppServiceEvent(JSContextRef context, const float scale, const std::string bundle);
+void dispatchSoftKeyboardChangeEvent(JSContextRef context, const std::string state, const int width, const int height);
+void dispatchStorageEvent(JSContextRef context, const std::string key, const std::string oldValue, const std::string newValue, const std::string url);
+
+}
+#endif //_DISPATCH_EVENT_SUPPORT_H_
SET(SRCS
${CMAKE_CURRENT_SOURCE_DIR}/js_overlay_support.cpp
${CMAKE_CURRENT_SOURCE_DIR}/js_function_manager.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/js_overlay_addEventListener.cpp
${CMAKE_CURRENT_SOURCE_DIR}/js_overlay_functions.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/js_iframe_support.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/JSClass/JSStorageEvent.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/JSClass/JSTizenServiceEvent.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/JSClass/JSSoftKeyboardChangeEvent.cpp
)
INCLUDE_DIRECTORIES(
#include <dpl/singleton_safe_impl.h>
#include <js_function_manager.h>
-#include <js_iframe_support.h>
#include <js_overlay_functions.h>
-#include <js_overlay_addEventListener.h>
#include <wrt_plugin_export.h>
-using namespace WrtPlugins::W3C;
-
IMPLEMENT_SAFE_SINGLETON(JsFunctionManager)
namespace {
const char* JSPRINT_NAME = "jsPrint";
const char* JSGLOBAL_OBJECT = "GLOBAL_OBJECT";
const char* JSHOOK_NAME = "jsHook";
-const char* ADD_EVENT_LISTENER_NAME = "addEventListener";
}
namespace JavaScriptFunctions {
reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptPrintProc)
};
-class_definition_options_t addEventListenerOptions = {
- JS_FUNCTION,
- CREATE_INSTANCE,
- ALWAYS_NOTICE,
- OVERLAYED_BEFORE_ORIGINAL,
- IFrameSupport::RegisterAddEventListener,
- NULL,
- reinterpret_cast<js_function_impl>(AddEventListenerSupport::
- AddEventListener)
-};
-
js_entity_definition_t jsPrint = {
JSGLOBAL_OBJECT,
JSPRINT_NAME,
&jsHookfunctionsOptions
};
-js_entity_definition_t addEventListener = {
- JSGLOBAL_OBJECT,
- ADD_EVENT_LISTENER_NAME,
- "",
- NULL,
- NULL,
- &addEventListenerOptions
-};
const js_entity_definition_ptr_t jsPrintPtr = &jsPrint;
const js_entity_definition_ptr_t jsHookPtr = &jsHook;
-const js_entity_definition_ptr_t addEventListenerPtr = &addEventListener;
}
bool JsFunctionManager::initialize()
JSObjectDeclarationPtr jsHookObj(
new JSObjectDeclaration(JavaScriptFunctions::jsHookPtr));
- JSObjectDeclarationPtr addEventListenerObj(
- new JSObjectDeclaration(JavaScriptFunctions::addEventListenerPtr));
-
m_functions.push_back(jsPrintObj);
m_functions.push_back(jsHookObj);
- m_functions.push_back(addEventListenerObj);
return true;
}
// JS overlay
#include <js_overlay_support.h>
#include <js_overlay_types.h>
-#include <js_overlay_addEventListener.h>
-#include <TizenServiceEvent/ITizenServiceEvent.h>
-#include <TizenServiceEvent/TizenServiceEvent.h>
-#include <SoftKeyboardChangeEvent/ISoftKeyboardChangeEvent.h>
-#include <SoftKeyboardChangeEvent/SoftKeyboardChangeEvent.h>
-#include <JSClass/JSTizenServiceEvent.h>
-#include <JSClass/JSSoftKeyboardChangeEvent.h>
namespace {
//const char* SEPARATOR = ".";
JSObjectPtr frameObject =
JavaScriptInterfaceSingleton::Instance().getGlobalObject(context);
- AddEventListenerSupport::RemoveIFrame(frameObject);
m_iframeSupport.unregisterIframe(frameObject);
}
void Explorer::callEventListeners(CustomEventType eventType, void* data)
{
+#if 0 // deprecated
using namespace WrtPlugins::Tizen;
// get iframe objects from javascript global context
JavaScriptInterface::ObjectsListPtr frameLists =
LogInfo("Not supported custom event type");
return;
}
+#endif
}
WindowPropertySupport* Explorer::getWindowPropertySupport()
${API_WIDGET_PATH}
${webkit2_INCLUDE_DIRS}
${plugin-types_INCLUDE_DIRS}
-# ${API_STORAGE_EVENT_PATH}
-# ${API_LOCALSTORAGE_PATH}
)
add_library(${TARGET_NAME} SHARED ${SRCS})
wrt-plugins-widget
wrt-plugins-localstorage
wrt-plugins-storageevent
+ wrt-dispatch-event
)
INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION /usr/lib/wrt-plugins/w3c-widget-interface)
#include <CommonsJavaScript/JSDOMExceptionFactory.h>
#include <StorageEvent/StorageEventMgr.h>
#include <StorageEvent/IStorageEvent.h>
-#include <js-overlay/js_iframe_support.h>
-#include <js-overlay/js_overlay_addEventListener.h>
+#include <dispatch-event/dispatch_event_support.h>
+
+// import temporarily from JSContextRefPrivate.h
+extern "C" JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx);
using namespace std;
using namespace WrtDeviceApis;
std::string key = converter.toString(arguments[0]);
- auto event = modifyItemAndCreateEvent(ModificationType::RemoveItem,
- thisObject,
- key);
-
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
+ DPL::Optional<std::string> oldValue = getIStorage(thisObject)->getValue(key);
+ getIStorage(thisObject)->removeItem(key);
+ DPL::Optional<std::string> newValue = getIStorage(thisObject)->getValue(key);
- Assert(iframe && "Iframe is NULL");
+ JSContextRef g_context = JSContextGetGlobalContext(context);
+ std::string oldValueStr = "";
+ std::string newValueStr = "";
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, event);
+ if (!!oldValue) { oldValueStr = *oldValue; }
+ if (!!newValue) { newValueStr = *newValue; }
+
+ DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
LogDebug("end");
return JSValueMakeNull(context);
std::string key = converter.toString(arguments[0]);
std::string value = converter.tryString(arguments[1]);
- auto event = modifyItemAndCreateEvent(ModificationType::SetItem,
- thisObject,
- key,
- value);
+ DPL::Optional<std::string> oldValue = getIStorage(thisObject)->getValue(key);
+ getIStorage(thisObject)->setItem(key, value, false);
+ DPL::Optional<std::string> newValue = getIStorage(thisObject)->getValue(key);
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
- Assert(iframe && "Iframe is NULL");
+ JSContextRef g_context = JSContextGetGlobalContext(context);
+ std::string oldValueStr = "";
+ std::string newValueStr = "";
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, event);
+ if (!!oldValue) { oldValueStr = *oldValue; }
+ if (!!newValue) { newValueStr = *newValue; }
+
+ DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
LogDebug("end");
Try {
getIStorage(thisObject)->clear(false);
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
-
- Assert(iframe && "Iframe is NULL");
-
- //create event object
- IStorageEventPtr storageEvent = getStorageEvent();
+ JSContextRef g_context = JSContextGetGlobalContext(context);
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, storageEvent);
+ DispatchEventSupport::dispatchStorageEvent(g_context, "", "", "", "");
LogDebug("end");
std::string key = converter.toString(propertyName);
std::string value = converter.toString(jvalue);
- auto event = modifyItemAndCreateEvent(ModificationType::SetItem,
- object,
- key,
- value);
+ DPL::Optional<std::string> oldValue = getIStorage(object)->getValue(key);
+ getIStorage(object)->setItem(key, value, false);
+ DPL::Optional<std::string> newValue = getIStorage(object)->getValue(key);
- auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(object));
- Assert(iframe && "Iframe is NULL");
+ JSContextRef g_context = JSContextGetGlobalContext(context);
+ std::string oldValueStr = "";
+ std::string newValueStr = "";
- AddEventListenerSupport::
- CallStorageListenersFromDifferentIFrames(iframe, event);
+ if (!!oldValue) { oldValueStr = *oldValue; }
+ if (!!newValue) { newValueStr = *newValue; }
+
+ DispatchEventSupport::dispatchStorageEvent(g_context, key, oldValueStr, newValueStr, "");
LogDebug("end");
#include <Widget/IWidget.h>
#include <LocalStorage/LocalStorageMgr.h>
#include <Commons/WrtAccess/WrtAccess.h>
-#include <js-overlay/js_iframe_support.h>
#define CATCH_EXCEPTION_NO_MODIFABLE \
Catch(Commons::LocalStorageValueNoModifableException) { \
js_object_instance_t iframe,
js_object_instance_t object)
{
- IFrameSupport::RegisterWidget(global_context, iframe, object);
if (!m_globalContext) {
m_globalContext = static_cast<JSContextRef>(global_context);
LogInfo("Global context acquired.");
#include <Commons/plugin_initializer_def.h>
#include <Commons/WrtAccess/WrtAccess.h>
-#include <js-overlay/js_overlay_addEventListener.h>
-#include <js-overlay/js_iframe_support.h>
#include "JSWidget.h"
#include "JSPreferences.h"
class_definition_options_t WidgetOptions = {
JS_CLASS,
CREATE_INSTANCE,
- ALWAYS_NOTICE,
+ NONE_NOTICE,
USE_OVERLAYED, //ignored
- IFrameSupport::RegisterWidget,
+ NULL,
NULL,
NULL
};