Update wrt-plugins-common_0.3.53
[framework/web/wrt-plugins-common.git] / src / standards / W3C / Widget / plugin_initializer.cpp
index f03858a..05d385b 100644 (file)
 
 #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"
-#include "JSTest.h"
 
-#include "IFrameSupport.h"
-#include "AddEventListenerSupport.h"
+#include "plugin_config.h"
 
 #define OBJECT_WIDGET "widget"
+#define INTERFACE_WIDGET_NAME "Widget"
 #define OBJECT_PREFERENCES "preferences"
-#define OBJECT_TEST "__test"
 
 using namespace WrtPlugins::W3C;
 using namespace WrtDeviceApis;
@@ -50,21 +50,30 @@ class_definition_options_t WidgetOptions =
     ALWAYS_NOTICE,
     USE_OVERLAYED, //ignored
     IFrameSupport::RegisterWidget,
+    NULL,
     NULL
 };
 
-class_definition_options_t AddEventListenerOptions =
+class_definition_options_t WidgetInterfaceOptions =
 {
-    JS_FUNCTION,
+    JS_INTERFACE,
     CREATE_INSTANCE,
     ALWAYS_NOTICE,
-    OVERLAYED_BEFORE_ORIGINAL,
-    IFrameSupport::RegisterAddEventListener,
+    USE_OVERLAYED, //ignored
+    JSWidget::acquireGlobalContext,
+    NULL,
     NULL
 };
 
 };
 
+void on_widget_init_callback(feature_mapping_interface_t *mapping)
+{
+    LogDebug("[W3C\\widget] on_widget_init_callback");
+
+    WrtPlugins::W3C::WidgetDeclarations::getMappingInterface(mapping);
+}
+
 void on_widget_start_callback(int widgetId)
 {
     LogDebug("[W3C\\widget] on_widget_start_callback (" << widgetId << ")");
@@ -97,28 +106,25 @@ void on_widget_stop_callback(int widgetId)
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+PLUGIN_ON_WIDGET_INIT(on_widget_init_callback)
 
 PLUGIN_CLASS_MAP_BEGIN
-PLUGIN_CLASS_MAP_ADD_CLASS (WRT_JS_EXTENSION_OBJECT_GLOBAL,
+PLUGIN_CLASS_MAP_ADD_INTERFACE(
+        WRT_JS_EXTENSION_OBJECT_GLOBAL,
+        INTERFACE_WIDGET_NAME,
+        (js_class_template_getter)WrtPlugins::W3C::JSWidget::getClassRef,
+        reinterpret_cast<js_class_constructor_cb_t>(WrtPlugins::W3C::JSWidget::callAsConstructor),
+        &Options::WidgetInterfaceOptions)
+PLUGIN_CLASS_MAP_ADD_INTERFACE_PRODUCT(
+        WRT_JS_EXTENSION_OBJECT_GLOBAL,
+        OBJECT_WIDGET,
+        INTERFACE_WIDGET_NAME,
+        &Options::WidgetOptions)
+
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_GLOBAL,
         OBJECT_WIDGET,
-        WrtPlugins::W3C::JSWidget::getClassRef(),
+        (js_class_template_getter)WrtPlugins::W3C::JSWidget::getClassRef,
         &Options::WidgetOptions)
-//PLUGIN_CLASS_MAP_ADD_CLASS(OBJECT_WIDGET,
-//                           OBJECT_PREFERENCES,
-//                           WrtPlugins::W3C::JSPreferences::getClassRef(),
-//                           NULL)
-//Function::AddEventListener
-PLUGIN_CLASS_MAP_ADD_CLASS (WRT_JS_EXTENSION_OBJECT_GLOBAL,
-                            "addEventListener",
-                            (const void*)
-                                AddEventListenerSupport::AddEventListener,
-                            &Options::AddEventListenerOptions)
-#ifdef W3C_TEST
-PLUGIN_CLASS_MAP_ADD_CLASS(OBJECT_WIDGET,
-                           OBJECT_TEST,
-                           WrtPlugins::W3C::JSTest::getClassRef(),
-                           NULL)
-#endif // W3C_TEST
 PLUGIN_CLASS_MAP_END
 
 #undef OBJECT_WIDGET