2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include <Commons/plugin_initializer_def.h>
19 #include <Commons/WrtAccess/WrtAccess.h>
20 #include "JSMessagingServiceManager.h"
21 #include "JSMessagingStorage.h"
22 #include "JSMessage.h"
23 #include "JSMessageAttachment.h"
24 #include "MessageAsyncCallbackManager.h"
25 #include "MessageListenerManager.h"
27 #include <GlobalContextManager.h>
30 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
37 class_definition_options_t TizenOptions =
42 USE_OVERLAYED, //ignored
47 class_definition_options_t MessagingInterfaceOptions = {
51 USE_OVERLAYED, //ignored
52 NULL, // JSWidget::acquireGlobalContext,
59 using namespace WrtDeviceApis;
60 using namespace WrtDeviceApis::Commons;
62 void on_widget_start_callback(int widgetId) {
63 LoggerD("[Tizen\\MessagingServiceManager] on_widget_start_callback ("<<widgetId<<")");
65 WrtAccessSingleton::Instance().initialize(widgetId);
66 } Catch(Commons::Exception) {
67 LoggerE("WrtAccess initialization failed");
71 void on_widget_stop_callback(int widgetId) {
72 LoggerD("[Tizen\\MessagingServiceManager] on_widget_stop_callback ("<<widgetId<<")");
74 WrtAccessSingleton::Instance().deinitialize(widgetId);
75 } Catch(Commons::Exception) {
76 LoggerE("WrtAccess deinitialization failed");
80 void on_frame_load_callback(const void * context)
82 LoggerD("[Tizen\\contact] on_frame_load_callback (" << context << ")");
83 DeviceAPI::Common::GlobalContextManager::getInstance()->addGlobalContext(static_cast<JSContextRef>(context));
86 void on_frame_unload_callback(const void * context)
88 LoggerD("[Tizen\\contact] on_frame_unload_callback (" << context << ")");
90 DeviceAPI::Common::GlobalContextManager::getInstance()->removeGlobalContext(static_cast<JSContextRef>(context));
91 DeviceAPI::Messaging::MessageAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
92 DeviceAPI::Messaging::MessageListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
96 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
97 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
99 PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
100 PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
102 PLUGIN_CLASS_MAP_BEGIN
103 PLUGIN_CLASS_MAP_ADD_CLASS(
104 WRT_JS_EXTENSION_OBJECT_TIZEN,
106 (js_class_template_getter)DeviceAPI::Messaging::JSMessagingServiceManager::getClassRef,
109 PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
111 (js_class_template_getter)DeviceAPI::Messaging::JSMessage::getClassRef,
112 (js_class_constructor_cb_t)DeviceAPI::Messaging::JSMessage::constructor,
113 &Options::MessagingInterfaceOptions)
115 PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
117 (js_class_template_getter)DeviceAPI::Messaging::JSMessageAttachment::getClassRef,
118 (js_class_constructor_cb_t)DeviceAPI::Messaging::JSMessageAttachment::constructor,
119 &Options::MessagingInterfaceOptions)