Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / NFC / plugin_initializer.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 51521a6..e352c84
@@ -27,6 +27,9 @@
 #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;
@@ -36,13 +39,33 @@ 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,
-    NONE_NOTICE,
+    ALWAYS_NOTICE,
     USE_OVERLAYED, //ignored
-    NULL,
+    AceCheckerNfcConstructorSetter, // JSWidget::acquireGlobalContext,
     NULL,
     NULL
 };
@@ -58,6 +81,7 @@ void on_widget_start_callback(int widgetId)
     {
         LoggerE("WrtAccess initialization failed");
     }
+       INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, nfcAceCheckAccessFunction); 
 }
 
 void on_widget_stop_callback(int widgetId)
@@ -71,15 +95,16 @@ void on_widget_stop_callback(int widgetId)
     {
         LoggerE("WrtAccess deinitialization failed");
     }
+       FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); 
 }
 
-void on_frame_load_callback(const void * context)
+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)
+void on_frame_unload_callback(const void *context)
 {
        LoggerD("[Tizen\\NFC] on_frame_unload_callback (" << context << ")");
        GlobalContextManager::getInstance()->removeGlobalContext(static_cast<JSContextRef>(context));
@@ -97,7 +122,7 @@ PLUGIN_CLASS_MAP_BEGIN
 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
         "nfc",
         (js_class_template_getter)JSNFCManager::getClassRef,
-        NULL)
+        &ClassOptions)
 PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN,
         "NDEFMessage",
         (js_class_template_getter)JSNdefMessage::getClassRef,