summaryrefslogtreecommitdiff
path: root/mobile_src/NFC/plugin_initializer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/NFC/plugin_initializer.cpp')
-rwxr-xr-xmobile_src/NFC/plugin_initializer.cpp154
1 files changed, 154 insertions, 0 deletions
diff --git a/mobile_src/NFC/plugin_initializer.cpp b/mobile_src/NFC/plugin_initializer.cpp
new file mode 100755
index 0000000..e352c84
--- /dev/null
+++ b/mobile_src/NFC/plugin_initializer.cpp
@@ -0,0 +1,154 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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.
+//
+
+#include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+#include <GlobalContextManager.h>
+#include "JSNFCManager.h"
+#include "JSNdefMessage.h"
+#include "JSNdefRecord.h"
+#include "JSNdefRecordText.h"
+#include "JSNdefRecordURI.h"
+#include "JSNdefRecordMedia.h"
+#include "NFCAsyncCallbackManager.h"
+#include "NFCListenerManager.h"
+#include "NFCDefaultAdapter.h"
+#include "plugin_config.h"
+#include <Security.h>
+#include <JSStringRefWrapper.h>
+#include <Logger.h>
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace NFC {
+
+AceSecurityStatus nfcAceCheckAccessFunction(const char* functionName)
+{
+ return NFC_CHECK_ACCESS(functionName);
+}
+
+DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
+DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerNfcSetter, NFCManagerPrivObject, gSecurityAccessor);
+DEFINE_JSOBJECT_SECURITY_ACCESSOR_SETTER(AceCheckerNfcConstructorSetter, gSecurityAccessor);
+
+class_definition_options_t ClassOptions =
+{
+ JS_CLASS,
+ CREATE_INSTANCE,
+ ALWAYS_NOTICE,
+ USE_OVERLAYED, //ignored
+ AceCheckerNfcSetter,
+ NULL
+};
+
+
+class_definition_options_t ConstructorClassOptions =
+{
+ JS_INTERFACE,
+ CREATE_INSTANCE,
+ ALWAYS_NOTICE,
+ USE_OVERLAYED, //ignored
+ AceCheckerNfcConstructorSetter, // JSWidget::acquireGlobalContext,
+ NULL,
+ NULL
+};
+
+void on_widget_start_callback(int widgetId)
+{
+ LoggerD("[TIZEN\\NFC ] on_widget_start_callback (" << widgetId << ")");
+ Try
+ {
+ WrtAccessSingleton::Instance().initialize(widgetId);
+ }
+ Catch(Commons::Exception)
+ {
+ LoggerE("WrtAccess initialization failed");
+ }
+ INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, nfcAceCheckAccessFunction);
+}
+
+void on_widget_stop_callback(int widgetId)
+{
+ LoggerD("[TIZEN\\NFC ] on_widget_stop_callback (" << widgetId << ")");
+ Try
+ {
+ WrtAccessSingleton::Instance().deinitialize(widgetId);
+ }
+ Catch(Commons::Exception)
+ {
+ LoggerE("WrtAccess deinitialization failed");
+ }
+ FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
+}
+
+void on_frame_load_callback(const void *context)
+{
+ LoggerD("[Tizen\\NFC] on_frame_load_callback (" << context << ")");
+ GlobalContextManager::getInstance()->addGlobalContext(static_cast<JSContextRef>(context));
+}
+
+void on_frame_unload_callback(const void *context)
+{
+ LoggerD("[Tizen\\NFC] on_frame_unload_callback (" << context << ")");
+ GlobalContextManager::getInstance()->removeGlobalContext(static_cast<JSContextRef>(context));
+ DeviceAPI::NFC::NFCAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
+ DeviceAPI::NFC::NFCListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
+ DeviceAPI::NFC::NFCDefaultAdapterSingleton::Instance().unsetExclusiveMode();
+}
+
+PLUGIN_ON_WIDGET_START(on_widget_start_callback)
+PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
+PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
+
+PLUGIN_CLASS_MAP_BEGIN
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ "nfc",
+ (js_class_template_getter)JSNFCManager::getClassRef,
+ &ClassOptions)
+PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ "NDEFMessage",
+ (js_class_template_getter)JSNdefMessage::getClassRef,
+ reinterpret_cast<js_class_constructor_cb_t>(JSNdefMessage::constructor),
+ &ConstructorClassOptions)
+PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ "NDEFRecord",
+ (js_class_template_getter)JSNdefRecord::getClassRef,
+ reinterpret_cast<js_class_constructor_cb_t>(JSNdefRecord::constructor),
+ &ConstructorClassOptions)
+PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ "NDEFRecordText",
+ (js_class_template_getter)JSNdefRecordText::getClassRef,
+ reinterpret_cast<js_class_constructor_cb_t>(JSNdefRecordText::constructor),
+ &ConstructorClassOptions)
+PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ "NDEFRecordURI",
+ (js_class_template_getter)JSNdefRecordURI::getClassRef,
+ reinterpret_cast<js_class_constructor_cb_t>(JSNdefRecordURI::constructor),
+ &ConstructorClassOptions)
+PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ "NDEFRecordMedia",
+ (js_class_template_getter)JSNdefRecordMedia::getClassRef,
+ reinterpret_cast<js_class_constructor_cb_t>(JSNdefRecordMedia::constructor),
+ &ConstructorClassOptions)
+PLUGIN_CLASS_MAP_END
+
+} // NFC
+} // DeviceAPI