Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Messaging / JSMessagingService.cpp
index 5205242..f9e32eb 100644 (file)
@@ -42,7 +42,7 @@
 #include "EventSendMessagePrivateData.h" //for send message
 #include "EventMessagingServicePrivateData.h"
 #include "MessageAsyncCallbackManager.h"
-#include "plugin_config.h"
+#include "plugin_config_impl.h"
 
 using namespace std;
 
@@ -123,9 +123,10 @@ bool JSMessagingService::hasInstance(JSContextRef context, JSObjectRef construct
     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
 }
 
-JSObjectRef JSMessagingService::createJSObject(JSContextRef context, const IMessagingServicePtr &messagingService)
+JSObjectRef JSMessagingService::createJSObject(JSContextRef context, const IMessagingServicePtr &messagingService, const DeviceAPI::Common::SecurityAccessor *securityAccessor)
 {
     JSMessagingServicePriv* priv = new JSMessagingServicePriv( context, messagingService);    //make private class.
+    priv->copyAceCheckAccessFunction(securityAccessor);
     return JSObjectMake(context, getClassRef(), priv);
 }
 
@@ -176,6 +177,7 @@ JSValueRef JSMessagingService::getProperty(JSContextRef context,
             LoggerD("type" << ": " << storagePrivObj->m_type);
 
             MessagingStoragePriv *privStorage = new MessagingStoragePriv(l_globalContext, storagePrivObj);
+            privStorage->copyAceCheckAccessFunction(priv);
 
             return JSObjectMake(l_globalContext, JSMessagingStorage::getClassRef(), privStorage);
         }
@@ -251,9 +253,8 @@ JSValueRef JSMessagingService::createMessage(JSContextRef context, JSObjectRef o
     JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));
     if (priv)
     {
-        AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-            MessagingExportedNames[MESSAGING_FUNCTION_API_CREATE_MESSAGE]);
-        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+        //check permission.
+        TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_CREATE_MESSAGE);
 
         try {
             ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
@@ -410,11 +411,6 @@ JSValueRef JSMessagingService::sendMessage(JSContextRef context,
 {
     LoggerD("Entered");
 
-    //check permission.
-    AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-        MessagingExportedNames[MESSAGING_FUNCTION_API_SEND_MESSAGE]);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
     JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));
     if (!priv) {
         LoggerE("Private object is NULL.");
@@ -422,6 +418,9 @@ JSValueRef JSMessagingService::sendMessage(JSContextRef context,
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
+    //check permission.
+    TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_SEND_MESSAGE);
+
     JSContextRef globalContext = priv->getContext();
 
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
@@ -505,11 +504,6 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
 {
     LoggerD("Entered");
 
-    //check permission.
-    AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-        MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY]);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
     JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));
     if (!priv) {
         LoggerE("Private object is NULL.");
@@ -517,6 +511,9 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
+    //check permission.
+    TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY);
+
     JSContextRef globalContext = priv->getContext(); //create global Context
 
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
@@ -611,11 +608,6 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
 {
     LoggerD("Entered");
 
-    //check permission.
-    AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-        MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT]);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
     JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));
     if (!priv) {
         LoggerE("Private object is NULL.");
@@ -623,6 +615,9 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
+    //check permission.
+    TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT);
+
     JSContextRef globalContext = priv->getContext(); //create global Context
 
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
@@ -706,11 +701,6 @@ JSValueRef JSMessagingService::sync(JSContextRef context, JSObjectRef function,
 {
     LoggerD("Entered");
 
-    //check permission.
-    AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-        MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC]);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
     JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));
     if (!priv) {
         LoggerE("Private object is NULL.");
@@ -718,6 +708,9 @@ JSValueRef JSMessagingService::sync(JSContextRef context, JSObjectRef function,
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
+    //check permission.
+    TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_SYNC);
+
     JSContextRef globalContext = priv->getContext(); //get global Context
 
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
@@ -781,11 +774,6 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func
 {
     LoggerD("Entered");
 
-    //check permission
-    AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-        MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER]);
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
     JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));
     if (!priv) {
         LoggerE("Private object is NULL.");
@@ -793,6 +781,9 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func
         return JSWebAPIErrorFactory::postException(context, exception, err);
     }
 
+    //check permission.
+    TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_SYNC_FOLDER);
+
     JSContextRef globalContext = priv->getContext(); //get global Context
 
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);