2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file plugin_initializer.cpp
19 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
24 #include <dpl/log/log.h>
26 #include <Commons/plugin_initializer_def.h>
27 #include <Commons/WrtAccess/WrtAccess.h>
30 #include "JSPreferences.h"
32 #include "plugin_config.h"
34 #define OBJECT_WIDGET "widget"
35 #define INTERFACE_WIDGET_NAME "Widget"
36 #define OBJECT_PREFERENCES "preferences"
38 using namespace WrtPlugins::W3C;
39 using namespace WrtDeviceApis;
40 using namespace WrtDeviceApis::Commons;
43 class_definition_options_t WidgetOptions = {
47 USE_OVERLAYED, //ignored
53 class_definition_options_t WidgetInterfaceOptions = {
57 USE_OVERLAYED, //ignored
58 JSWidget::acquireGlobalContext,
64 void on_widget_init_callback(feature_mapping_interface_t *mapping)
66 LogDebug("[W3C\\widget] on_widget_init_callback");
68 WrtPlugins::W3C::WidgetDeclarations::getMappingInterface(mapping);
71 void on_widget_start_callback(int widgetId)
73 LogDebug("[W3C\\widget] on_widget_start_callback (" << widgetId << ")");
77 WrtAccessSingleton::Instance().initialize(widgetId);
79 Catch(Commons::Exception)
81 LogError("Wrt wrapper registration failed");
86 void on_widget_stop_callback(int widgetId)
88 LogDebug("[W3C\\widget] on_widget_stop_callback (" << widgetId << ")");
91 WrtAccessSingleton::Instance().deinitialize(widgetId);
93 Catch(Commons::Exception)
95 LogError("Wrt wrapper registration failed");
100 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
101 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
102 PLUGIN_ON_WIDGET_INIT(on_widget_init_callback)
104 PLUGIN_CLASS_MAP_BEGIN
105 PLUGIN_CLASS_MAP_ADD_INTERFACE(
106 WRT_JS_EXTENSION_OBJECT_GLOBAL,
107 INTERFACE_WIDGET_NAME,
108 (js_class_template_getter) WrtPlugins::W3C::JSWidget::getClassRef,
109 reinterpret_cast<js_class_constructor_cb_t>(WrtPlugins::W3C::JSWidget::
111 &Options::WidgetInterfaceOptions)
112 PLUGIN_CLASS_MAP_ADD_INTERFACE_PRODUCT(
113 WRT_JS_EXTENSION_OBJECT_GLOBAL,
115 INTERFACE_WIDGET_NAME,
116 &Options::WidgetOptions)
121 #undef OBJECT_PREFERENCES