Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Calendar / JSCalendarEvent.cpp
index 0969560..6ff19c7 100755 (executable)
@@ -33,6 +33,7 @@
 #include <TimeUtilConverter.h>
 #include <JSTZDate.h>
 #include <JSWebAPIErrorFactory.h>
+#include <Security.h>
 #include <SecurityExceptions.h>
 #include <GlobalContextManager.h>
 #include <TimeTracer.h>
@@ -128,6 +129,18 @@ JSObjectRef DLL_EXPORT JSCalendarEvent::constructor(JSContextRef context,
     CalendarEventPtr event(new CalendarEvent());
        JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context);
 
+    DeviceAPI::Common::SecurityAccessor *securityAccessor = NULL;
+
+    try
+    {
+        securityAccessor = DeviceAPI::Common::JSObjectGetSecurityAccessor(context, constructor);
+    }
+    catch(BasePlatformException &e)
+    {
+        event->setCalendarType(CalendarEvent::EVENT_TYPE);
+        return createJSCalendarEvent(globalContext, event, securityAccessor);
+    }
+
     Try
     {
         CalendarConverter converter(globalContext);
@@ -179,7 +192,7 @@ JSObjectRef DLL_EXPORT JSCalendarEvent::constructor(JSContextRef context,
         }
 
         event->setCalendarType(CalendarEvent::EVENT_TYPE);
-        return createJSCalendarEvent(globalContext, event);
+        return createJSCalendarEvent(globalContext, event, securityAccessor);
     }
     Catch(UnsupportedException)
     {
@@ -203,12 +216,13 @@ JSObjectRef DLL_EXPORT JSCalendarEvent::constructor(JSContextRef context,
     }
 
     event->setCalendarType(CalendarEvent::EVENT_TYPE);
-    return createJSCalendarEvent(globalContext, event);
+    return createJSCalendarEvent(globalContext, event, securityAccessor);
 }
 
-JSObjectRef JSCalendarEvent::createJSCalendarEvent(JSContextRef context, CalendarEventPtr event)
+JSObjectRef JSCalendarEvent::createJSCalendarEvent(JSContextRef context, CalendarEventPtr event, const DeviceAPI::Common::SecurityAccessor *securityAccessor)
 {
     CalendarEventPrivObject *priv = new CalendarEventPrivObject(context, event);
+    priv->copyAceCheckAccessFunction(securityAccessor);
     return JSObjectMake(context, getClassRef(), priv);
 }
 
@@ -270,9 +284,7 @@ JSValueRef JSCalendarEvent::expandRecurrence(JSContextRef context,
     CalendarEventPrivObject *privateObject =
         static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(thisObject));
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_EXPAND_RECURRENCE);
-
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_EXPAND_RECURRENCE);
 
     Try
     {
@@ -329,6 +341,7 @@ JSValueRef JSCalendarEvent::expandRecurrence(JSContextRef context,
         dplEvent->setEvent(event);
         dplEvent->setStartDate(startDate);
         dplEvent->setEndDate(endDate);
+        dplEvent->copyAceCheckAccessFunction(privateObject);
         m_calendar->expandEventRecurrence(dplEvent);
 
                TIME_TRACER_ITEM_END(__FUNCTION__, 0);