From: Kisub Song Date: Tue, 15 Oct 2013 08:56:40 +0000 (+0900) Subject: Update change log and spec for wrt-plugins-tizen_0.4.70 X-Git-Tag: accepted/tizen/20131028.214051~6^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fc2fe44e63ed2fe699feaa2f7b8d70d928fd1e1;p=platform%2Fframework%2Fweb%2Fwrt-plugins-tizen.git Update change log and spec for wrt-plugins-tizen_0.4.70 Change-Id: I258e459023eec5ec84a86a6cef40ffc2f265f8ba --- diff --git a/packaging/wrt-plugins-tizen.spec b/packaging/wrt-plugins-tizen.spec index 3fe43df..c69135c 100755 --- a/packaging/wrt-plugins-tizen.spec +++ b/packaging/wrt-plugins-tizen.spec @@ -1,6 +1,6 @@ Name: wrt-plugins-tizen Summary: JavaScript plugins for WebRuntime -Version: 0.4.69 +Version: 0.4.70 Release: 0 Group: Development/Libraries License: Apache License, Version 2.0 diff --git a/pkgconfigs/wrt-plugins-tizen-application.pc.in b/pkgconfigs/wrt-plugins-tizen-application.pc.in index d90c038..4558d9b 100644 --- a/pkgconfigs/wrt-plugins-tizen-application.pc.in +++ b/pkgconfigs/wrt-plugins-tizen-application.pc.in @@ -9,5 +9,5 @@ Name: wrt-plugins-tizen-${module_name} Description: wrt-plugins-tizen-${module_name} Version: @CMAKE_PROJECT_VERSION@ Requires: capi-appfw-app-manager capi-appfw-application capi-appfw-package-manager pkgmgr pkgmgr-info -Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-contact.pc.in b/pkgconfigs/wrt-plugins-tizen-contact.pc.in index c54a2f3..2612c20 100755 --- a/pkgconfigs/wrt-plugins-tizen-contact.pc.in +++ b/pkgconfigs/wrt-plugins-tizen-contact.pc.in @@ -9,5 +9,5 @@ Name: wrt-plugins-tizen-${module_name} Description: wrt-plugins-tizen-${module_name} Version: @CMAKE_PROJECT_VERSION@ Requires: contacts-service2 libpcrecpp -Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl Cflags: -I${includedir}/${module_name} \ No newline at end of file diff --git a/pkgconfigs/wrt-plugins-tizen-filesystem.pc.in b/pkgconfigs/wrt-plugins-tizen-filesystem.pc.in index 3deb9e4..0db60de 100755 --- a/pkgconfigs/wrt-plugins-tizen-filesystem.pc.in +++ b/pkgconfigs/wrt-plugins-tizen-filesystem.pc.in @@ -9,5 +9,5 @@ Name: wrt-plugins-tizen-${module_name} Description: wrt-plugins-tizen-${module_name} Version: @CMAKE_PROJECT_VERSION@ Requires: -Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl -lwrt-plugins-tizen-${module_name}-config -Cflags: -I${includedir}/${module_name} \ No newline at end of file +Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}-impl +Cflags: -I${includedir}/${module_name} diff --git a/src/Alarm/CMakeLists.txt b/src/Alarm/CMakeLists.txt index e3ce625..39ab2c7 100644 --- a/src/Alarm/CMakeLists.txt +++ b/src/Alarm/CMakeLists.txt @@ -49,7 +49,6 @@ ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_IMPL_NAME} - "-Wl,--no-as-needed" ${application_config} ) INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) diff --git a/src/Alarm/JSAlarmAbsolute.cpp b/src/Alarm/JSAlarmAbsolute.cpp index e0f8507..2d0baa0 100644 --- a/src/Alarm/JSAlarmAbsolute.cpp +++ b/src/Alarm/JSAlarmAbsolute.cpp @@ -33,12 +33,13 @@ #include #include -#include "plugin_config.h" #include "JSAlarmAbsolute.h" #include "JSAlarmManager.h" #include #include +#define ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE "getNextScheduledDate" + namespace DeviceAPI { namespace Alarm { diff --git a/src/Alarm/JSAlarmManager.cpp b/src/Alarm/JSAlarmManager.cpp index e572cc4..8a98586 100644 --- a/src/Alarm/JSAlarmManager.cpp +++ b/src/Alarm/JSAlarmManager.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -39,7 +40,7 @@ #include -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "AlarmConverter.h" #include "JSAlarmAbsolute.h" #include "AlarmAbsolute.h" @@ -123,10 +124,15 @@ JSContextRef JSAlarmManager::gContext = NULL; void JSAlarmManager::initialize(JSContextRef ctx, JSObjectRef object) { gContext = ctx; + + SecurityAccessor *priv = new SecurityAccessor(); + JSObjectSetPrivate(object, static_cast(priv)); } void JSAlarmManager::finalize(JSObjectRef object) { + SecurityAccessor *priv = static_cast(JSObjectGetPrivate(object)); + delete priv; } JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) @@ -139,9 +145,14 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef std::string applicationId; std::string page; + SecurityAccessor *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + if (!thisPriv) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(ctx, exception, + JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); + } TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0); - AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_ADD); - TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + TIZEN_CHECK_ACCESS(ctx, exception, thisPriv, ALARM_FUNCTION_API_ADD); TIME_TRACER_ITEM_END("(add)ace_check", 0); try { @@ -273,9 +284,14 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); + SecurityAccessor *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + if (!thisPriv) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(ctx, exception, + JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); + } TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0); - AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE); - TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + TIZEN_CHECK_ACCESS(ctx, exception, thisPriv, ALARM_FUNCTION_API_REMOVE); TIME_TRACER_ITEM_END("(add)ace_check", 0); try { @@ -312,9 +328,14 @@ JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObject JSValueRef JSAlarmManager::removeAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); + SecurityAccessor *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + if (!thisPriv) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(ctx, exception, + JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); + } TIME_TRACER_ITEM_BEGIN("(add)ace_check", 0); - AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE_ALL); - TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception); + TIZEN_CHECK_ACCESS(ctx, exception, thisPriv, ALARM_FUNCTION_API_REMOVE_ALL); TIME_TRACER_ITEM_END("(add)ace_check", 0); TIME_TRACER_ITEM_BEGIN("(removeAll)alarm_cancel_all", 0); diff --git a/src/Alarm/JSAlarmRelative.cpp b/src/Alarm/JSAlarmRelative.cpp index e345cca..1f509c9 100644 --- a/src/Alarm/JSAlarmRelative.cpp +++ b/src/Alarm/JSAlarmRelative.cpp @@ -26,8 +26,6 @@ #include #include -#include "plugin_config.h" - #include "AlarmRelative.h" #include "AlarmConverter.h" #include "JSAlarmRelative.h" @@ -41,6 +39,8 @@ #include #include +#define ALARM_FUNCTION_API_GET_REMAINING_SECONDS "getRemainingSeconds" + namespace DeviceAPI { namespace Alarm { diff --git a/src/Alarm/plugin_config.cpp b/src/Alarm/plugin_config.cpp index 856b58a..8c41500 100755 --- a/src/Alarm/plugin_config.cpp +++ b/src/Alarm/plugin_config.cpp @@ -23,6 +23,7 @@ #include #include +#include "plugin_config_impl.h" #include "plugin_config.h" #define ALARM_FEATURE_API "http://tizen.org/privilege/alarm" @@ -39,12 +40,8 @@ static FunctionMapping createAlarmFunctions(); static FunctionMapping AlarmFunctions = createAlarmFunctions(); -#pragma GCC visibility push(default) - DEFINE_FUNCTION_GETTER(Alarm, AlarmFunctions); -#pragma GCC visibility pop - static FunctionMapping createAlarmFunctions() { /** diff --git a/src/Alarm/plugin_config.h b/src/Alarm/plugin_config.h index 796e37b..3bc1f15 100755 --- a/src/Alarm/plugin_config.h +++ b/src/Alarm/plugin_config.h @@ -1,44 +1,36 @@ -// -// 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. -// - -#ifndef _ALARM_PLUGIN_CONFIG_H_ -#define _ALARM_PLUGIN_CONFIG_H_ - -#include -#include - -#define ALARM_FUNCTION_API_GET_ALL "getAll" -#define ALARM_FUNCTION_API_GET "get" -#define ALARM_FUNCTION_API_ADD "add" -#define ALARM_FUNCTION_API_REMOVE "remove" -#define ALARM_FUNCTION_API_REMOVE_ALL "removeAll" -#define ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE "getNextScheduledDate" -#define ALARM_FUNCTION_API_GET_REMAINING_SECONDS "getRemainingSeconds" - -namespace DeviceAPI { -namespace Alarm { - -DECLARE_FUNCTION_GETTER(Alarm); - -#define ALARM_CHECK_ACCESS(functionName) \ - aceCheckAccess >( \ - getAlarmFunctionData, \ - functionName) -} -} -#endif - +// +// 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. +// + +#ifndef _ALARM_PLUGIN_CONFIG_H_ +#define _ALARM_PLUGIN_CONFIG_H_ + +#include +#include + +namespace DeviceAPI { +namespace Alarm { + +DECLARE_FUNCTION_GETTER(Alarm); + +#define ALARM_CHECK_ACCESS(functionName) \ + aceCheckAccess >( \ + getAlarmFunctionData, \ + functionName) +} +} +#endif + diff --git a/src/Alarm/plugin_config_impl.h b/src/Alarm/plugin_config_impl.h new file mode 100755 index 0000000..3849162 --- /dev/null +++ b/src/Alarm/plugin_config_impl.h @@ -0,0 +1,29 @@ +// +// 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. +// + +#ifndef _ALARM_PLUGIN_CONFIG_IMPL_H_ +#define _ALARM_PLUGIN_CONFIG_IMPL_H_ + +#define ALARM_FUNCTION_API_GET_ALL "getAll" +#define ALARM_FUNCTION_API_GET "get" +#define ALARM_FUNCTION_API_ADD "add" +#define ALARM_FUNCTION_API_REMOVE "remove" +#define ALARM_FUNCTION_API_REMOVE_ALL "removeAll" +#define ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE "getNextScheduledDate" +#define ALARM_FUNCTION_API_GET_REMAINING_SECONDS "getRemainingSeconds" + +#endif diff --git a/src/Alarm/plugin_initializer.cpp b/src/Alarm/plugin_initializer.cpp index 2951641..91022f0 100644 --- a/src/Alarm/plugin_initializer.cpp +++ b/src/Alarm/plugin_initializer.cpp @@ -23,6 +23,8 @@ #include "JSAlarmAbsolute.h" #include "JSAlarmRelative.h" #include +#include +#include "plugin_config.h" #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen" @@ -33,6 +35,28 @@ using namespace WrtDeviceApis; using namespace WrtDeviceApis::Commons; using namespace WrtDeviceApis::CommonsJavaScript; +AceSecurityStatus alarmAceCheckAccessFunction(const char* functionName) +{ + return ALARM_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerAlarmSetter, + DeviceAPI::Common::SecurityAccessor, + gSecurityAccessor); + +class_definition_options_t ClassOptions = +{ + JS_CLASS, + NONE, + ALWAYS_NOTICE, + IGNORED, + AceCheckerAlarmSetter, + NULL, + NULL +}; + class_definition_options_t ConstructorClassOptions = { JS_INTERFACE, @@ -56,6 +80,8 @@ void on_widget_start_callback(int widgetId) { LoggerE("WrtAccess initialization failed"); } + + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, alarmAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) @@ -71,6 +97,8 @@ void on_widget_stop_callback(int widgetId) { LoggerE("WrtAccess deinitialization failed"); } + + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } PLUGIN_ON_WIDGET_START(on_widget_start_callback) @@ -81,7 +109,7 @@ PLUGIN_CLASS_MAP_ADD_CLASS( WRT_JS_EXTENSION_OBJECT_TIZEN, "alarm", (js_class_template_getter)DeviceAPI::Alarm::JSAlarmManager::getClassRef, - NULL) + &ClassOptions) PLUGIN_CLASS_MAP_ADD_INTERFACE( WRT_JS_EXTENSION_OBJECT_TIZEN, TIZEN_ALARM_ABSOLUTE_INTERFACE, diff --git a/src/Application/AppManagerWrapper.cpp b/src/Application/AppManagerWrapper.cpp index 27e8bcf..48146fa 100644 --- a/src/Application/AppManagerWrapper.cpp +++ b/src/Application/AppManagerWrapper.cpp @@ -152,6 +152,7 @@ void AppManagerWrapper::appListChangedCallback(app_manger_event_type_e event_typ ret = package_info_foreach_app_from_package(package_info, PACKAGE_INFO_ALLAPP, app_callback, user_data); if (ret != PACKAGE_MANAGER_ERROR_NONE) { LoggerE("failed while getting appids"); + package_info_destroy(package_info); return; } diff --git a/src/Application/ApplicationController.cpp b/src/Application/ApplicationController.cpp index daef6f2..ad7d281 100644 --- a/src/Application/ApplicationController.cpp +++ b/src/Application/ApplicationController.cpp @@ -45,6 +45,7 @@ ApplicationController::ApplicationController(JSContextRef context, IApplicationM EventApplicationGetAppsContextEventAnswerReceiver(ThreadEnum::NULL_THREAD), EventApplicationGetAppsInfoEventAnswerReceiver(ThreadEnum::NULL_THREAD), EventApplicationAppInfoEventListenerListener(ThreadEnum::NULL_THREAD), + SecurityAccessor(), ApplicationPrivObject(context, application) { if (!application) { diff --git a/src/Application/ApplicationController.h b/src/Application/ApplicationController.h index 32bccb6..452e99a 100755 --- a/src/Application/ApplicationController.h +++ b/src/Application/ApplicationController.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "IApplicationManager.h" namespace DeviceAPI { @@ -58,6 +59,7 @@ class ApplicationController : public EventApplicationGetAppsContextEventAnswerReceiver, public EventApplicationGetAppsInfoEventAnswerReceiver, public EventApplicationAppInfoEventListenerListener, + public DeviceAPI::Common::SecurityAccessor, public ApplicationPrivObject { public: diff --git a/src/Application/ApplicationManager.cpp b/src/Application/ApplicationManager.cpp index f13f930..9e69946 100644 --- a/src/Application/ApplicationManager.cpp +++ b/src/Application/ApplicationManager.cpp @@ -829,9 +829,18 @@ ApplicationCertArrayPtr ApplicationManager::getAppCerts(const std::string id) TIME_TRACER_ITEM_END("(getAppCerts)package_info_foreach_cert_info", 0); if ((result != PACKAGE_MANAGER_ERROR_NONE) && (result != PACKAGE_MANAGER_ERROR_IO_ERROR)) { + package_info_destroy(pkg_info); ThrowMsg(UnknownException, "Can not get package cert info"); } + TIME_TRACER_ITEM_BEGIN("(getAppCerts)package_info_destroy", 0); + result = package_info_destroy(pkg_info); + TIME_TRACER_ITEM_END("(getAppCerts)package_info_destroy", 0); + if (result != PACKAGE_MANAGER_ERROR_NONE) + { + LoggerE("Failed to destroy package_info"); + } + return certArray; } diff --git a/src/Application/CMakeLists.txt b/src/Application/CMakeLists.txt index 78b69ff..3439b0b 100644 --- a/src/Application/CMakeLists.txt +++ b/src/Application/CMakeLists.txt @@ -1,7 +1,6 @@ SET(TARGET_NAME ${application_target}) SET(DESTINATION_NAME ${application_dest}) SET(TARGET_IMPL_NAME ${application_impl}) -SET(TARGET_CONFIG_NAME ${application_config}) PKG_CHECK_MODULES(platform_pkgs_application REQUIRED capi-appfw-app-manager @@ -64,17 +63,8 @@ TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} ${platform_pkgs_application_LIBRARIES} ) -SET(SRCS_CONFIG - plugin_config.cpp -) - -ADD_LIBRARY(${TARGET_CONFIG_NAME} SHARED ${SRCS_CONFIG}) - -TARGET_LINK_LIBRARIES(${TARGET_CONFIG_NAME} - ${LIBS_COMMON} -) - SET(SRCS + plugin_config.cpp plugin_initializer.cpp ) @@ -82,10 +72,9 @@ ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_IMPL_NAME} - ${TARGET_CONFIG_NAME} ) -INSTALL(TARGETS ${TARGET_NAME} ${TARGET_CONFIG_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/application diff --git a/src/Application/JSApplicationManager.cpp b/src/Application/JSApplicationManager.cpp index 943c343..c26b44a 100644 --- a/src/Application/JSApplicationManager.cpp +++ b/src/Application/JSApplicationManager.cpp @@ -35,7 +35,7 @@ #include #include "ApplicationFactory.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "ApplicationController.h" #include "JSApplicationManager.h" #include "ApplicationConverter.h" @@ -51,6 +51,7 @@ #include #include #include +#include #include @@ -178,11 +179,6 @@ JSValueRef JSApplicationManager::launch(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); TIME_TRACER_ITEM_BEGIN("launch(async)", 0); - TIME_TRACER_ITEM_BEGIN("launch(ACE)", 0); - AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - TIME_TRACER_ITEM_END("launch(ACE)", 0); - try { IApplicationManagerPtr appmgr; JSContextRef gContext; @@ -195,6 +191,10 @@ JSValueRef JSApplicationManager::launch(JSContextRef context, appmgr = controller->getObject(); gContext = controller->getContext(); + TIME_TRACER_ITEM_BEGIN("launch(ACE)", 0); + TIZEN_CHECK_ACCESS(context, exception, controller, APPLICATION_FUNCTION_API_LAUNCH); + TIME_TRACER_ITEM_END("launch(ACE)", 0); + EventApplicationLaunchPtr event(new EventApplicationLaunch()); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); @@ -242,11 +242,6 @@ JSValueRef JSApplicationManager::kill(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); TIME_TRACER_ITEM_BEGIN("kill(async)", 0); - TIME_TRACER_ITEM_BEGIN("kill(ACE)", 0); - AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_KILL); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - TIME_TRACER_ITEM_END("kill(ACE)", 0); - try { IApplicationManagerPtr appmgr; JSContextRef gContext; @@ -259,6 +254,10 @@ JSValueRef JSApplicationManager::kill(JSContextRef context, appmgr = controller->getObject(); gContext = controller->getContext(); + TIME_TRACER_ITEM_BEGIN("kill(ACE)", 0); + TIZEN_CHECK_ACCESS(context, exception, controller, APPLICATION_FUNCTION_API_KILL); + TIME_TRACER_ITEM_END("kill(ACE)", 0); + EventApplicationKillPtr event(new EventApplicationKill()); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); ArgumentValidator validator(context, argumentCount, arguments); @@ -338,11 +337,6 @@ JSValueRef JSApplicationManager::launchAppControl(JSContextRef context, TIME_TRACER_ITEM_BEGIN("launchAppControl(async)", 0); TIME_TRACER_ITEM_BEGIN("launchAppControlReply(async)", 0); - TIME_TRACER_ITEM_BEGIN("launchAppControl(ACE)", 0); - AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - TIME_TRACER_ITEM_END("launchAppControl(ACE)", 0); - try { IApplicationManagerPtr appmgr; JSContextRef gContext; @@ -355,6 +349,9 @@ JSValueRef JSApplicationManager::launchAppControl(JSContextRef context, appmgr = controller->getObject(); gContext = controller->getContext(); + TIME_TRACER_ITEM_BEGIN("launchAppControl(ACE)", 0); + TIZEN_CHECK_ACCESS(context, exception, controller, APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL); + TIME_TRACER_ITEM_END("launchAppControl(ACE)", 0); EventApplicationLaunchAppControlPtr event(new EventApplicationLaunchAppControl()); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext); @@ -819,12 +816,17 @@ JSValueRef JSApplicationManager::getAppCerts(JSContextRef context, { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - TIME_TRACER_ITEM_BEGIN("(getAppCerts)ACE", 0); - AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_CERTS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - TIME_TRACER_ITEM_END("(getAppCerts)ACE", 0); - try { + ApplicationController *controller; + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + throw TypeMismatchException("No private object."); + } + + TIME_TRACER_ITEM_BEGIN("getAppCerts(ACE)", 0); + TIZEN_CHECK_ACCESS(context, exception, controller, APPLICATION_FUNCTION_API_GET_APP_CERTS); + TIME_TRACER_ITEM_END("getAppCerts(ACE)", 0); + ArgumentValidator validator(context, argumentCount, arguments); ApplicationCertArrayPtr result = ApplicationManager::getAppCerts(validator.toString(0, true, "")); @@ -881,12 +883,17 @@ JSValueRef JSApplicationManager::getAppMetaData(JSContextRef context, { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - TIME_TRACER_ITEM_BEGIN("(getAppMetaData)ACE", 0); - AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_META_DATA); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - TIME_TRACER_ITEM_END("(getAppMetaData)ACE", 0); - try { + ApplicationController *controller; + controller = static_cast(JSObjectGetPrivate(thisObject)); + if (!controller) { + throw TypeMismatchException("No private object."); + } + + TIME_TRACER_ITEM_BEGIN("getAppMetaData(ACE)", 0); + TIZEN_CHECK_ACCESS(context, exception, controller, APPLICATION_FUNCTION_API_GET_APP_META_DATA); + TIME_TRACER_ITEM_END("getAppMetaData(ACE)", 0); + ArgumentValidator validator(context, argumentCount, arguments); ApplicationMetaDataArrayPtr result = ApplicationManager::getAppMetaData(validator.toString(0, true, "")); diff --git a/src/Application/JSApplicationManager.h b/src/Application/JSApplicationManager.h index 873be7c..bb298d5 100644 --- a/src/Application/JSApplicationManager.h +++ b/src/Application/JSApplicationManager.h @@ -27,9 +27,6 @@ namespace Application { #define TIZEN_INTERFACE_APPLICATION_MANAGER "ApplicationManager" -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject - JSApplicationManagerPriv; - class JSApplicationManager { public: static const JSClassDefinition* getClassInfo(); diff --git a/src/Application/plugin_config.cpp b/src/Application/plugin_config.cpp index 636a017..e4ffab8 100755 --- a/src/Application/plugin_config.cpp +++ b/src/Application/plugin_config.cpp @@ -54,12 +54,8 @@ static FunctionMapping createApplicationFunctions(); static FunctionMapping ApplicationFunctions = createApplicationFunctions(); -#pragma GCC visibility push(default) - DEFINE_FUNCTION_GETTER(Application, ApplicationFunctions); -#pragma GCC visibility pop - static FunctionMapping createApplicationFunctions() { /** diff --git a/src/Application/plugin_config.h b/src/Application/plugin_config.h index 0cfd8fb..fa36426 100755 --- a/src/Application/plugin_config.h +++ b/src/Application/plugin_config.h @@ -1,66 +1,39 @@ -// -// 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. -// - - -#ifndef _APPLICATOIN_PLUGIN_CONFIG_H_ -#define _APPLICATOIN_PLUGIN_CONFIG_H_ - -#include -#include - -// feature : launch -#define APPLICATION_FUNCTION_API_LAUNCH "launch" -#define APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL "launchAppControl" - -// feature : kill - public candidate -#define APPLICATION_FUNCTION_API_KILL "kill" - -// feature : certificate - public candidate -#define APPLICATION_FUNCTION_API_GET_APP_CERTS "getAppCerts" - -// no feature required -#define APPLICATION_FUNCTION_API_GET_APPS_INFO "getAppsInfo" -#define APPLICATION_FUNCTION_API_GET_APP_INFO "getAppInfo" -#define APPLICATION_FUNCTION_API_GET_APPS_CONTEXT "getAppsContext" -#define APPLICATION_FUNCTION_API_GET_APP_CONTEXT "getAppContext" -#define APPLICATION_FUNCTION_API_FIND_APP_CONTROL "findAppControl" -#define APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER "addAppInfoEventListener" -#define APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER "removeAppInfoEventListener" -#define APPLICATION_FUNCTION_API_GET_CURRENT_APP "getCurrentApplication" -#define APPLICATION_FUNCTION_API_GET_REQUESTED_APP_CONTROL "getRequestedAppControl" -#define APPLICATION_FUNCTION_API_EXIT "exit" -#define APPLICATION_FUNCTION_API_HIDE "hide" -#define APPLICATION_FUNCTION_API_REPLY_RESULT "replyResult" -#define APPLICATION_FUNCTION_API_REPLY_FAILURE "replyFailure" -#define APPLICATION_FUNCTION_API_GET_APP_SHARED_URI "getAppSharedURI" -#define APPLICATION_FUNCTION_API_GET_APP_META_DATA "getAppMetaData" -#define APPLICATION_FUNCTION_API_SET_USER_AGENT "setUserAgent" - -namespace DeviceAPI { -namespace Application { - -DECLARE_FUNCTION_GETTER(Application); - -#define APPLICATION_CHECK_ACCESS(functionName) \ - aceCheckAccess >( \ - getApplicationFunctionData, \ - functionName) - -} -} -#endif - +// +// 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. +// + + +#ifndef _APPLICATOIN_PLUGIN_CONFIG_H_ +#define _APPLICATOIN_PLUGIN_CONFIG_H_ + +#include +#include +#include "plugin_config_impl.h" + +namespace DeviceAPI { +namespace Application { + +DECLARE_FUNCTION_GETTER(Application); + +#define APPLICATION_CHECK_ACCESS(functionName) \ + aceCheckAccess >( \ + getApplicationFunctionData, \ + functionName) + +} +} +#endif + diff --git a/src/Application/plugin_config_impl.h b/src/Application/plugin_config_impl.h new file mode 100755 index 0000000..c47b181 --- /dev/null +++ b/src/Application/plugin_config_impl.h @@ -0,0 +1,51 @@ +// +// 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. +// + + +#ifndef _APPLICATOIN_PLUGIN_CONFIG_IMPL_H_ +#define _APPLICATOIN_PLUGIN_CONFIG_IMPL_H_ + +// feature : launch +#define APPLICATION_FUNCTION_API_LAUNCH "launch" +#define APPLICATION_FUNCTION_API_LAUNCH_APP_CONTROL "launchAppControl" + +// feature : kill - public candidate +#define APPLICATION_FUNCTION_API_KILL "kill" + +// feature : certificate - public candidate +#define APPLICATION_FUNCTION_API_GET_APP_CERTS "getAppCerts" + +// no feature required +#define APPLICATION_FUNCTION_API_GET_APPS_INFO "getAppsInfo" +#define APPLICATION_FUNCTION_API_GET_APP_INFO "getAppInfo" +#define APPLICATION_FUNCTION_API_GET_APPS_CONTEXT "getAppsContext" +#define APPLICATION_FUNCTION_API_GET_APP_CONTEXT "getAppContext" +#define APPLICATION_FUNCTION_API_FIND_APP_CONTROL "findAppControl" +#define APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER "addAppInfoEventListener" +#define APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER "removeAppInfoEventListener" +#define APPLICATION_FUNCTION_API_GET_CURRENT_APP "getCurrentApplication" +#define APPLICATION_FUNCTION_API_GET_REQUESTED_APP_CONTROL "getRequestedAppControl" +#define APPLICATION_FUNCTION_API_EXIT "exit" +#define APPLICATION_FUNCTION_API_HIDE "hide" +#define APPLICATION_FUNCTION_API_REPLY_RESULT "replyResult" +#define APPLICATION_FUNCTION_API_REPLY_FAILURE "replyFailure" +#define APPLICATION_FUNCTION_API_GET_APP_SHARED_URI "getAppSharedURI" +#define APPLICATION_FUNCTION_API_GET_APP_META_DATA "getAppMetaData" +#define APPLICATION_FUNCTION_API_SET_USER_AGENT "setUserAgent" + +#endif + diff --git a/src/Application/plugin_initializer.cpp b/src/Application/plugin_initializer.cpp index 49c7a2f..ec3177c 100644 --- a/src/Application/plugin_initializer.cpp +++ b/src/Application/plugin_initializer.cpp @@ -23,12 +23,14 @@ #include #include #include +#include #include "JSApplicationManager.h" #include "JSApplicationControl.h" #include "ApplicationAsyncCallbackManager.h" #include "ApplicationListenerManager.h" #include "AppManagerWrapper.h" +#include "plugin_config.h" #include using namespace WrtDeviceApis; @@ -37,8 +39,28 @@ using namespace WrtDeviceApis::Commons; namespace DeviceAPI { namespace Application { +AceSecurityStatus applicationAceCheckAccessFunction(const char* functionName) +{ + return APPLICATION_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerApplicationSetter, ApplicationController, gSecurityAccessor); + class_definition_options_t ApplicationOptions = { + JS_CLASS, + NONE, + ALWAYS_NOTICE, + IGNORED, + AceCheckerApplicationSetter, + NULL, + NULL +}; + +class_definition_options_t ApplicationConstructorOptions = +{ JS_INTERFACE, CREATE_INSTANCE, NONE_NOTICE, @@ -60,6 +82,8 @@ void on_widget_start_callback(int widgetId) { } Catch(WrtDeviceApis::Commons::Exception) { LoggerE("WrtAccess initialization failed"); } + + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, applicationAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) { @@ -73,6 +97,8 @@ void on_widget_stop_callback(int widgetId) { } Catch(WrtDeviceApis::Commons::Exception) { LoggerE("WrtAccess deinitialization failed"); } + + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } void on_frame_load_callback(const void * context) @@ -98,21 +124,21 @@ PLUGIN_CLASS_MAP_BEGIN WRT_JS_EXTENSION_OBJECT_TIZEN, "application", (js_class_template_getter)DeviceAPI::Application::JSApplicationManager::getClassRef, - NULL) + &ApplicationOptions) PLUGIN_CLASS_MAP_ADD_INTERFACE( WRT_JS_EXTENSION_OBJECT_TIZEN, TIZEN_INTERFACE_APPLICATION_CONTROL, (js_class_template_getter)DeviceAPI::Application::JSApplicationControl::getClassRef, reinterpret_cast(JSApplicationControl::constructor), - &ApplicationOptions) + &ApplicationConstructorOptions) PLUGIN_CLASS_MAP_ADD_INTERFACE( WRT_JS_EXTENSION_OBJECT_TIZEN, TIZEN_INTERFACE_APPLICATION_CONTROL_DATA, (js_class_template_getter)DeviceAPI::Application::JSApplicationControlData::getClassRef, reinterpret_cast(JSApplicationControlData::constructor), - &ApplicationOptions) + &ApplicationConstructorOptions) PLUGIN_CLASS_MAP_END diff --git a/src/Bluetooth/BluetoothAdapter.cpp b/src/Bluetooth/BluetoothAdapter.cpp index ba9a1a5..bd5436f 100644 --- a/src/Bluetooth/BluetoothAdapter.cpp +++ b/src/Bluetooth/BluetoothAdapter.cpp @@ -21,7 +21,7 @@ #include #include #include - +#include "plugin_config_impl.h" #include "BluetoothAdapter.h" #include "BluetoothCallbackUtil.h" #include "JSBluetoothDevice.h" @@ -310,6 +310,7 @@ void BluetoothAdapter::onDiscoveryStateChangedCB(int result, bt_adapter_device_d if(result == BT_ERROR_NONE) { // create BluetoothDevice BluetoothDeviceSharedPtr device(new BluetoothDevice(discoveryInfo)); + device->copyAceCheckAccessFunction(getInstance()); JSContextRef context = callback->getContext(); JSObjectRef deviceObj = JSBluetoothDevice::createJSObject(context, device); object->mFoundDevices.push_back(device); @@ -367,6 +368,7 @@ bool BluetoothAdapter::foreachBondedDevicesCB(bt_device_info_s *deviceInfo, void if(iter == adapter->knownDevices.end()) { BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo)); + device->copyAceCheckAccessFunction(getInstance()); adapter->knownDevices.push_back(device); } @@ -397,6 +399,7 @@ void BluetoothAdapter::onBondCreatedCB(int result, bt_device_info_s *deviceInfo, if(result == BT_ERROR_NONE && deviceInfo != NULL) { if(callback) { BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo)); + device->copyAceCheckAccessFunction(getInstance()); JSContextRef context = callback->getContext(); JSObjectRef deviceObj = JSBluetoothDevice::createJSObject(context, device); callback->invokeCallback("success", deviceObj); @@ -495,7 +498,7 @@ void BluetoothAdapter::onSocketConnected(int result, bt_socket_connection_state_ service->setConnectionState(true); // Call BluetoothServiceHandler.onconnect - BluetoothSocketPtr socket = new BluetoothSocket(connection); + BluetoothSocketPtr socket = new BluetoothSocket(connection, getInstance()); MultiCallbackUserDataPtr callback = service->getOnConnect(); JSContextRef context = callback->getContext(); JSObjectRef socketObj = JSBluetoothSocket::createJSObject(context, socket); @@ -559,7 +562,8 @@ void BluetoothAdapter::onSocketConnected(int result, bt_socket_connection_state_ if(result == BT_ERROR_NONE) { // Update mConnectedSocket - BluetoothSocketPtr socket = new BluetoothSocket(connection); + BluetoothSocketPtr socket = new BluetoothSocket(connection, getInstance()); + object->mConnectedSocket.insert(std::pair(connection->socket_fd, socket)); bt_socket_set_data_received_cb(onSocketReceivedCB, userData); @@ -655,6 +659,8 @@ void BluetoothAdapter::onSocketReceivedCB(bt_socket_received_data_s *data, void BluetoothAdapter::BluetoothAdapter(): mEnabled(false), mVisible(false) { + Common::SecurityAccessor(); + bt_adapter_state_e state; if (bt_adapter_get_state(&state) == BT_ERROR_NONE) { if (state == BT_ADAPTER_ENABLED) { @@ -706,6 +712,8 @@ BluetoothAdapter::~BluetoothAdapter() mConnReqMap.clear(); mFoundDevices.clear(); mConnectedSocket.clear(); + + } void BluetoothAdapter::unloadFrame(JSContextRef context) @@ -1414,11 +1422,12 @@ void BluetoothAdapter::returnKnownDevices(Common::MultiCallbackUserDataPtr userD knownDevices = mFoundDevices; if(bt_adapter_foreach_bonded_device(foreachBondedDevicesCB, this) == BT_ERROR_NONE) { if(knownDevices.size() > 0) { // There are found devices - LoggerD("There are found devices"); + int num = knownDevices.size(); + LoggerD("There are found devices " << num); JSObjectRef devices[num]; for(int i = 0; i < num; i++) { - JSObjectRef deviceObj = JSBluetoothDevice::createJSObject(userData->getContext(), knownDevices[i]); + JSObjectRef deviceObj = JSBluetoothDevice::createJSObject(userData->getContext(), knownDevices[i]); devices[i] = deviceObj; } @@ -1462,6 +1471,7 @@ void BluetoothAdapter::returnDevice(std::string &address, Common::MultiCallbackU deviceInfo != NULL) { TIME_TRACER_ITEM_END("returnDevice::bt_adapter_get_bonded_device_info", 1); BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo)); + device->copyAceCheckAccessFunction(getInstance()); bt_adapter_free_device_info(deviceInfo); LoggerD("invoke successCallback"); @@ -1541,6 +1551,7 @@ void BluetoothAdapter::returnRegisteredService(std::string &uuid, std::string &n bt_socket_set_connection_state_changed_cb(onSocketConnected, this); BluetoothServiceHandlerPtr serviceHandler = new BluetoothServiceHandler(uuid, name, socket); + serviceHandler->copyAceCheckAccessFunction(getInstance()); mRegisteredUUID.insert(std::pair(uuid, serviceHandler)); JSObjectRef serviceObj = JSBluetoothServiceHandler::createJSObject(userData->getContext(), serviceHandler); @@ -1606,5 +1617,8 @@ void BluetoothAdapter::unsetChangeListener() } + + + } // Bluetooth } // DeviceAPI diff --git a/src/Bluetooth/BluetoothAdapter.h b/src/Bluetooth/BluetoothAdapter.h index 8b573e0..731b81e 100644 --- a/src/Bluetooth/BluetoothAdapter.h +++ b/src/Bluetooth/BluetoothAdapter.h @@ -23,10 +23,9 @@ #include #include - +#include #include #include - #include "BluetoothDevice.h" #include "BluetoothServiceHandler.h" #include "BluetoothSocket.h" @@ -48,7 +47,7 @@ public: }; typedef BluetoothConnReq* BluetoothConnReqPtr; -class BluetoothAdapter +class BluetoothAdapter : public Common::SecurityAccessor { public: enum adapterAsyncE @@ -93,7 +92,6 @@ public: static bool isValidAddress(std::string &address); static bool isValidUUID(std::string &uuid); void unloadFrame(JSContextRef context); - private: BluetoothAdapter(); virtual ~BluetoothAdapter(); @@ -128,6 +126,7 @@ private: std::vector mFoundDevices; std::vector knownDevices; Common::MultiCallbackUserDataPtr mChangeListener; + }; typedef BluetoothAdapter* BluetoothAdapterPtr; diff --git a/src/Bluetooth/BluetoothClass.cpp b/src/Bluetooth/BluetoothClass.cpp index 8998d66..6486574 100644 --- a/src/Bluetooth/BluetoothClass.cpp +++ b/src/Bluetooth/BluetoothClass.cpp @@ -34,6 +34,7 @@ namespace Bluetooth { BluetoothClass::BluetoothClass(bt_class_s bluetoothClass) { + Common::SecurityAccessor(); mMajor = BluetoothClassDeviceMajor::getInstance()->getMajorValue(bluetoothClass.major_device_class); mMinor = BluetoothClassDeviceMinor::getInstance()->getMinorValue(bluetoothClass.minor_device_class); mServices= BluetoothClassDeviceService::getInstance()->getServiceValues(bluetoothClass.major_service_class_mask); diff --git a/src/Bluetooth/BluetoothClass.h b/src/Bluetooth/BluetoothClass.h index f685247..d1d18dd 100644 --- a/src/Bluetooth/BluetoothClass.h +++ b/src/Bluetooth/BluetoothClass.h @@ -23,14 +23,14 @@ #include #include - +#include #include #include namespace DeviceAPI { namespace Bluetooth { -class BluetoothClass +class BluetoothClass : public Common::SecurityAccessor { public: BluetoothClass(bt_class_s bluetoothClass); diff --git a/src/Bluetooth/BluetoothDevice.cpp b/src/Bluetooth/BluetoothDevice.cpp index 1331a84..c87d099 100644 --- a/src/Bluetooth/BluetoothDevice.cpp +++ b/src/Bluetooth/BluetoothDevice.cpp @@ -32,6 +32,7 @@ namespace Bluetooth { BluetoothDevice::BluetoothDevice(bt_adapter_device_discovery_info_s *discoveryInfo) { + Common::SecurityAccessor(); mName = std::string(discoveryInfo->remote_name); mAddress = std::string(discoveryInfo->remote_address); mDeviceClass = BluetoothClassSharedPtr(new BluetoothClass(discoveryInfo->bt_class)); @@ -43,9 +44,11 @@ BluetoothDevice::BluetoothDevice(bt_adapter_device_discovery_info_s *discoveryIn BluetoothDevice::BluetoothDevice(bt_device_info_s *deviceInfo) { + Common::SecurityAccessor(); mName = std::string(deviceInfo->remote_name); mAddress = std::string(deviceInfo->remote_address); mDeviceClass = BluetoothClassSharedPtr(new BluetoothClass(deviceInfo->bt_class)); + for(int i = 0; i < deviceInfo->service_count; i++) { mUUIDs.push_back(std::string(deviceInfo->service_uuid[i])); } @@ -77,6 +80,12 @@ std::string BluetoothDevice::getAddress() const return mAddress; } +void BluetoothDevice::copyAceCheckAccessFunction(const Common::SecurityAccessor *securityAccessor) +{ + Common::SecurityAccessor::copyAceCheckAccessFunction(securityAccessor); + mDeviceClass->copyAceCheckAccessFunction(securityAccessor); +} + JSValueRef BluetoothDevice::getDeviceClass(JSContextRef context) { /* diff --git a/src/Bluetooth/BluetoothDevice.h b/src/Bluetooth/BluetoothDevice.h index 1c83925..e434bbc 100644 --- a/src/Bluetooth/BluetoothDevice.h +++ b/src/Bluetooth/BluetoothDevice.h @@ -25,13 +25,13 @@ #include #include #include - +#include #include "BluetoothClass.h" namespace DeviceAPI { namespace Bluetooth { -class BluetoothDevice +class BluetoothDevice : public Common::SecurityAccessor { public: BluetoothDevice(bt_adapter_device_discovery_info_s *discoveryInfo); @@ -46,7 +46,7 @@ public: bool isTrusted() const; bool isConnected() const; JSValueRef getUUIDs(JSContextRef context); - + void copyAceCheckAccessFunction(const Common::SecurityAccessor *securityAccessor); private: std::string mName; std::string mAddress; diff --git a/src/Bluetooth/BluetoothHealthApplication.cpp b/src/Bluetooth/BluetoothHealthApplication.cpp index b54176d..8fb9d5d 100644 --- a/src/Bluetooth/BluetoothHealthApplication.cpp +++ b/src/Bluetooth/BluetoothHealthApplication.cpp @@ -29,6 +29,7 @@ namespace Bluetooth { BluetoothHealthApplication::BluetoothHealthApplication(std::string appID, std::string name, unsigned short dataType) { + Common::SecurityAccessor(); mAppID = appID; mName = name; mDataType = dataType; diff --git a/src/Bluetooth/BluetoothHealthApplication.h b/src/Bluetooth/BluetoothHealthApplication.h index c15c0d9..f823bea 100644 --- a/src/Bluetooth/BluetoothHealthApplication.h +++ b/src/Bluetooth/BluetoothHealthApplication.h @@ -25,11 +25,12 @@ #include #include +#include namespace DeviceAPI { namespace Bluetooth { -class BluetoothHealthApplication +class BluetoothHealthApplication : public Common::SecurityAccessor { public: BluetoothHealthApplication(std::string appID, std::string name, unsigned short dataType); diff --git a/src/Bluetooth/BluetoothHealthChannel.cpp b/src/Bluetooth/BluetoothHealthChannel.cpp index 9303206..f038d33 100644 --- a/src/Bluetooth/BluetoothHealthChannel.cpp +++ b/src/Bluetooth/BluetoothHealthChannel.cpp @@ -32,6 +32,7 @@ namespace Bluetooth { BluetoothHealthChannel::BluetoothHealthChannel(unsigned int channel, BluetoothDeviceSharedPtr remoteDevice, bt_hdp_channel_type_e type, BluetoothHealthApplicationSharedPtr application) { + Common::SecurityAccessor(); mChannel = channel; mRemoteDevice = remoteDevice; if(type == BT_HDP_CHANNEL_TYPE_RELIABLE) { diff --git a/src/Bluetooth/BluetoothHealthChannel.h b/src/Bluetooth/BluetoothHealthChannel.h index b348b04..87ea7b4 100644 --- a/src/Bluetooth/BluetoothHealthChannel.h +++ b/src/Bluetooth/BluetoothHealthChannel.h @@ -21,7 +21,7 @@ #include #include #include - +#include #include #include "BluetoothDevice.h" #include "BluetoothHealthApplication.h" @@ -29,7 +29,7 @@ namespace DeviceAPI { namespace Bluetooth { -class BluetoothHealthChannel +class BluetoothHealthChannel : public Common::SecurityAccessor { public: BluetoothHealthChannel(unsigned int channel, BluetoothDeviceSharedPtr remoteDevice, bt_hdp_channel_type_e type, BluetoothHealthApplicationSharedPtr application); diff --git a/src/Bluetooth/BluetoothHealthProfileHandler.cpp b/src/Bluetooth/BluetoothHealthProfileHandler.cpp index 834e8fa..8299baa 100644 --- a/src/Bluetooth/BluetoothHealthProfileHandler.cpp +++ b/src/Bluetooth/BluetoothHealthProfileHandler.cpp @@ -71,10 +71,13 @@ void BluetoothHealthProfileHandler::onConnected(int result, const char *remote_a if(bt_adapter_get_bonded_device_info(remote_address, &deviceInfo) == BT_ERROR_NONE && deviceInfo != NULL) { BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo)); + // need to check + device->copyAceCheckAccessFunction(getInstance()); bt_adapter_free_device_info(deviceInfo); LoggerD("invoke BluetoothHealthApplication.onconnect"); healthChannel = new BluetoothHealthChannel(channel, device, type, application); + healthChannel->copyAceCheckAccessFunction(getInstance()); object->mConnectedSocketMap.insert(std::pair(channel, healthChannel)); isChannelInserted = true; callback->invokeCallback("onconnect", JSBluetoothHealthChannel::createJSObject(callback->getContext(), healthChannel)); @@ -97,6 +100,7 @@ void BluetoothHealthProfileHandler::onConnected(int result, const char *remote_a if(result == BT_ERROR_NONE) { if(isChannelInserted == false) { healthChannel = new BluetoothHealthChannel(channel, i->second->mRemoteDevice, type, application); + healthChannel->copyAceCheckAccessFunction(getInstance()); object->mConnectedSocketMap.insert(std::pair(channel, healthChannel)); } callback->invokeCallback("success", JSBluetoothHealthChannel::createJSObject(callback->getContext(), healthChannel)); @@ -194,6 +198,8 @@ BluetoothHealthProfileHandler* BluetoothHealthProfileHandler::getInstance() BluetoothHealthProfileHandler::BluetoothHealthProfileHandler() { + Common::SecurityAccessor(); + if(bt_hdp_set_connection_state_changed_cb(onConnected, onDisconnected, this) != BT_ERROR_NONE) { LoggerE("bt_hdp_set_connection_state_changed_cb() failed"); } @@ -203,6 +209,7 @@ BluetoothHealthProfileHandler::BluetoothHealthProfileHandler() } } + BluetoothHealthProfileHandler::~BluetoothHealthProfileHandler() { // unset platform callback @@ -235,6 +242,8 @@ void BluetoothHealthProfileHandler::returnRegisteringSinkAppResult(unsigned shor std::string appID(app_id); //free(app_id); BluetoothHealthApplicationSharedPtr application(new BluetoothHealthApplication(appID, name, dataType)); + application->copyAceCheckAccessFunction(getInstance()); + mRegisteredHealthAppMap.insert(std::pair(appID, application)); if(callback) callback->invokeCallback("success", JSBluetoothHealthApplication::createJSObject(callback->getContext(), application)); diff --git a/src/Bluetooth/BluetoothHealthProfileHandler.h b/src/Bluetooth/BluetoothHealthProfileHandler.h index 3e9bb8d..9573473 100644 --- a/src/Bluetooth/BluetoothHealthProfileHandler.h +++ b/src/Bluetooth/BluetoothHealthProfileHandler.h @@ -15,7 +15,7 @@ // limitations under the License. // -#ifndef __TIZEN_BLUETOOTH_ADAPTER_H__ +#ifndef __TIZEN_HEALTH_PROFILE_HANDLER_H__ #define __TIZEN_HEALTH_PROFILE_HANDLER_H__ #include @@ -50,7 +50,7 @@ public: }; typedef HealthConnReq* HealthConnReqPtr; -class BluetoothHealthProfileHandler +class BluetoothHealthProfileHandler : public Common::SecurityAccessor { public: static BluetoothHealthProfileHandler* getInstance(); @@ -61,7 +61,7 @@ public: void unregisterApp(std::string appID, Common::MultiCallbackUserDataPtr callback); void returnUnregisteringAppResult(std::string appID, Common::MultiCallbackUserDataPtr callback); void connectToSource(JSObjectRef remoteDeviceObj, JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback); - + private: BluetoothHealthProfileHandler(); virtual ~BluetoothHealthProfileHandler(); @@ -74,7 +74,8 @@ private: typedef std::map HealthConnReqMapT; typedef std::map HealthConnectedSocketMapT; // typedef std::map RegisteredHealthAppMapT; // - + + HealthConnReqMapT mHealthConnReqMap; HealthConnectedSocketMapT mConnectedSocketMap; RegisteredHealthAppMapT mRegisteredHealthAppMap; diff --git a/src/Bluetooth/BluetoothServiceHandler.cpp b/src/Bluetooth/BluetoothServiceHandler.cpp index 7995611..d325b37 100644 --- a/src/Bluetooth/BluetoothServiceHandler.cpp +++ b/src/Bluetooth/BluetoothServiceHandler.cpp @@ -33,6 +33,8 @@ namespace Bluetooth { BluetoothServiceHandler::BluetoothServiceHandler(std::string uuid, std::string name, int registeredSocket) { + Common::SecurityAccessor(); + mUUID = uuid; mName = name; mRegisteredSocket = registeredSocket; diff --git a/src/Bluetooth/BluetoothServiceHandler.h b/src/Bluetooth/BluetoothServiceHandler.h index 189f5a2..fd30b1a 100644 --- a/src/Bluetooth/BluetoothServiceHandler.h +++ b/src/Bluetooth/BluetoothServiceHandler.h @@ -24,11 +24,12 @@ //#include #include #include +#include namespace DeviceAPI { namespace Bluetooth { -class BluetoothServiceHandler +class BluetoothServiceHandler : public Common::SecurityAccessor { public: BluetoothServiceHandler(std::string uuid, std::string name, int registeredSocket); diff --git a/src/Bluetooth/BluetoothSocket.cpp b/src/Bluetooth/BluetoothSocket.cpp index 6e64919..78b8596 100644 --- a/src/Bluetooth/BluetoothSocket.cpp +++ b/src/Bluetooth/BluetoothSocket.cpp @@ -31,15 +31,19 @@ using namespace DeviceAPI::Common; namespace DeviceAPI { namespace Bluetooth { -BluetoothSocket::BluetoothSocket(bt_socket_connection_s *connection) +BluetoothSocket::BluetoothSocket(bt_socket_connection_s *connection, Common::SecurityAccessor* accessor) { + Common::SecurityAccessor(); + Common::SecurityAccessor::copyAceCheckAccessFunction(accessor); + mConnectedSocket = connection->socket_fd; mUUID = std::string(connection->service_uuid); mIsConnected = true; - + bt_device_info_s *deviceInfo = NULL; if(bt_adapter_get_bonded_device_info(connection->remote_address, &deviceInfo) == BT_ERROR_NONE && deviceInfo != NULL) { BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo)); + device->copyAceCheckAccessFunction(accessor); mPeer = device; bt_adapter_free_device_info(deviceInfo); } diff --git a/src/Bluetooth/BluetoothSocket.h b/src/Bluetooth/BluetoothSocket.h index d7d9d25..4ff9c38 100644 --- a/src/Bluetooth/BluetoothSocket.h +++ b/src/Bluetooth/BluetoothSocket.h @@ -25,16 +25,16 @@ //#include #include #include - +#include #include "BluetoothDevice.h" namespace DeviceAPI { namespace Bluetooth { -class BluetoothSocket +class BluetoothSocket : public Common::SecurityAccessor { public: - BluetoothSocket(bt_socket_connection_s *connection); + BluetoothSocket(bt_socket_connection_s *connection, Common::SecurityAccessor* accessor); virtual ~BluetoothSocket(); std::string getUUID() const; diff --git a/src/Bluetooth/JSBluetoothAdapter.cpp b/src/Bluetooth/JSBluetoothAdapter.cpp index e5168dd..2e492a2 100644 --- a/src/Bluetooth/JSBluetoothAdapter.cpp +++ b/src/Bluetooth/JSBluetoothAdapter.cpp @@ -24,12 +24,13 @@ #include "plugin_config.h" #include "JSBluetoothAdapter.h" #include "BluetoothAdapter.h" +#include "BluetoothHealthProfileHandler.h" #include "JSBluetoothHealthProfileHandler.h" #include #include #include - +#include "plugin_config_impl.h" using namespace WrtDeviceApis::Commons; using namespace DeviceAPI::Common; @@ -150,9 +151,9 @@ JSValueRef JSBluetoothAdapter::setName(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("setName::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_SET_NAME); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_SET_NAME); TIME_TRACER_ITEM_END("setName::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { ArgumentValidator validator(context, argumentCount, arguments); @@ -196,9 +197,8 @@ JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("setPowered::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_SET_POWERED); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_SET_POWERED); TIME_TRACER_ITEM_END("setPowered::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); try { // Check whether BT is supported or not @@ -255,9 +255,9 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("setVisible::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_SET_VISIBLE); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_SET_VISIBLE); TIME_TRACER_ITEM_END("setVisible::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Validate arguments @@ -303,9 +303,9 @@ JSValueRef JSBluetoothAdapter::discoverDevices(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("discoverDevices::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_DISCOVER_DEVICES); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_DISCOVER_DEVICES); TIME_TRACER_ITEM_END("discoverDevices::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { TIME_TRACER_ITEM_BEGIN("discoverDevices::parameter", 1); @@ -381,9 +381,9 @@ JSValueRef JSBluetoothAdapter::stopDiscovery(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("stopDiscovery::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_STOP_DISCOVERY); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_STOP_DISCOVERY); TIME_TRACER_ITEM_END("stopDiscovery::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Validate arguments @@ -425,9 +425,9 @@ JSValueRef JSBluetoothAdapter::getKnownDevices(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("getKnownDevices::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_GET_KNOWN_DEVICES); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_GET_KNOWN_DEVICES); TIME_TRACER_ITEM_END("getKnownDevices::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Validate arguments @@ -469,9 +469,9 @@ JSValueRef JSBluetoothAdapter::getDevice(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("getDevice::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_GET_DEVICE); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_GET_DEVICE); TIME_TRACER_ITEM_END("getDevice::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Validate arguments @@ -514,9 +514,9 @@ JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("createBonding::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_CREATE_BONDING); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_CREATE_BONDING); TIME_TRACER_ITEM_END("createBonding::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Validate arguments @@ -559,9 +559,9 @@ JSValueRef JSBluetoothAdapter::destroyBonding(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("destroyBonding::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_DESTROY_BONDING); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_DESTROY_BONDING); TIME_TRACER_ITEM_END("destroyBonding::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Validate arguments @@ -604,9 +604,9 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context, // Access Check TIME_TRACER_ITEM_BEGIN("registerRFCOMMServiceByUUID::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_REGISTER_RFCOMMSERVICE_BY_UUID); + TIZEN_CHECK_ACCESS(context, exception, BluetoothAdapter::getInstance(), BLUETOOTH_ADAPTER_API_REGISTER_RFCOMMSERVICE_BY_UUID); TIME_TRACER_ITEM_END("registerRFCOMMServiceByUUID::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Validate arguments @@ -659,6 +659,8 @@ JSValueRef JSBluetoothAdapter::getBluetoothProfileHandler(JSContextRef context, bool isCorrectParameter = false; if(type.compare("HEALTH") == 0) { isCorrectParameter = true; + BluetoothHealthProfileHandler::getInstance()->copyAceCheckAccessFunction(BluetoothAdapter::getInstance()); + profileHandler = JSBluetoothHealthProfileHandler::createJSObject(context); } TIME_TRACER_ITEM_END(__FUNCTION__, 1); diff --git a/src/Bluetooth/JSBluetoothAdapter.h b/src/Bluetooth/JSBluetoothAdapter.h index 72c56e9..5306888 100644 --- a/src/Bluetooth/JSBluetoothAdapter.h +++ b/src/Bluetooth/JSBluetoothAdapter.h @@ -19,6 +19,7 @@ #define __TIZEN_JS_BLUETOOTH_ADAPTER_H__ #include +#include namespace DeviceAPI { namespace Bluetooth { diff --git a/src/Bluetooth/JSBluetoothClass.cpp b/src/Bluetooth/JSBluetoothClass.cpp index ecc8168..22c04ba 100644 --- a/src/Bluetooth/JSBluetoothClass.cpp +++ b/src/Bluetooth/JSBluetoothClass.cpp @@ -139,18 +139,19 @@ JSValueRef JSBluetoothClass::hasService(JSContextRef context, { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); - // Access Check - TIME_TRACER_ITEM_BEGIN("hasService::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_CLASS_API_HAS_SERVICE); - TIME_TRACER_ITEM_END("hasService::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - try { // Private Object BluetoothClassHolderPtr priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { throw TypeMismatchException("Private object is NULL."); } + + // Access Check + BluetoothClass* btclass = priv->mClass.get(); + TIME_TRACER_ITEM_BEGIN("hasService::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, btclass, BLUETOOTH_CLASS_API_HAS_SERVICE); + TIME_TRACER_ITEM_END("hasService::ACE", 1); + ArgumentValidator validator(context, argumentCount, arguments); unsigned long service = validator.toULong(0); // uuid diff --git a/src/Bluetooth/JSBluetoothClass.h b/src/Bluetooth/JSBluetoothClass.h index c188e54..ff5a646 100644 --- a/src/Bluetooth/JSBluetoothClass.h +++ b/src/Bluetooth/JSBluetoothClass.h @@ -24,10 +24,10 @@ namespace DeviceAPI { namespace Bluetooth { -class BluetoothClassHolder +class BluetoothClassHolder { public: - BluetoothClassHolder(BluetoothClassSharedPtr bluetoothClass) {mClass = bluetoothClass;} + BluetoothClassHolder(BluetoothClassSharedPtr bluetoothClass) { mClass = bluetoothClass;} BluetoothClassSharedPtr mClass; }; typedef BluetoothClassHolder* BluetoothClassHolderPtr; diff --git a/src/Bluetooth/JSBluetoothDevice.cpp b/src/Bluetooth/JSBluetoothDevice.cpp index 8b5a4aa..61e43fb 100644 --- a/src/Bluetooth/JSBluetoothDevice.cpp +++ b/src/Bluetooth/JSBluetoothDevice.cpp @@ -161,12 +161,6 @@ JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); - - // Access Check - TIME_TRACER_ITEM_BEGIN("connectToServiceByUUID::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_DEVICE_API_CONNECT_TO_SERVICE_BY_UUID); - TIME_TRACER_ITEM_END("connectToServiceByUUID::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); try { // Private Object @@ -174,6 +168,10 @@ JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, if (!priv) { throw TypeMismatchException("Private object is NULL."); } + // Access Check + TIME_TRACER_ITEM_BEGIN("connectToServiceByUUID::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, priv->mDevice.get(), BLUETOOTH_DEVICE_API_CONNECT_TO_SERVICE_BY_UUID); + TIME_TRACER_ITEM_END("connectToServiceByUUID::ACE", 1); ArgumentValidator validator(context, argumentCount, arguments); std::string uuid = validator.toString(0); // uuid diff --git a/src/Bluetooth/JSBluetoothDevice.h b/src/Bluetooth/JSBluetoothDevice.h index d14630c..cede559 100644 --- a/src/Bluetooth/JSBluetoothDevice.h +++ b/src/Bluetooth/JSBluetoothDevice.h @@ -19,16 +19,15 @@ #define __TIZEN_JS_BLUETOOTH_DEVICE_H__ #include - #include "BluetoothDevice.h" namespace DeviceAPI { namespace Bluetooth { -class BluetoothDeviceHolder +class BluetoothDeviceHolder { public: - BluetoothDeviceHolder(BluetoothDeviceSharedPtr device) {mDevice = device;} + BluetoothDeviceHolder(BluetoothDeviceSharedPtr device) : mDevice(device) {} BluetoothDeviceSharedPtr mDevice; }; typedef BluetoothDeviceHolder* BluetoothDeviceHolderPtr; diff --git a/src/Bluetooth/JSBluetoothHealthApplication.cpp b/src/Bluetooth/JSBluetoothHealthApplication.cpp index a12226a..f31ad8f 100644 --- a/src/Bluetooth/JSBluetoothHealthApplication.cpp +++ b/src/Bluetooth/JSBluetoothHealthApplication.cpp @@ -198,16 +198,16 @@ JSValueRef JSBluetoothHealthApplication::unregister(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); // Access Check - TIME_TRACER_ITEM_BEGIN("unregister::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER); - TIME_TRACER_ITEM_END("unregister::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { BluetoothHealthApplicationHolderPtr priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { throw TypeMismatchException("Private object is NULL"); } + TIME_TRACER_ITEM_BEGIN("unregister::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, priv->mApp.get(), BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER); + TIME_TRACER_ITEM_END("unregister::ACE", 1); ArgumentValidator validator(context, argumentCount, arguments); JSObjectRef successCallback = validator.toFunction(0, true); // successCallback diff --git a/src/Bluetooth/JSBluetoothHealthApplication.h b/src/Bluetooth/JSBluetoothHealthApplication.h index 27bdf21..375e738 100644 --- a/src/Bluetooth/JSBluetoothHealthApplication.h +++ b/src/Bluetooth/JSBluetoothHealthApplication.h @@ -19,16 +19,15 @@ #define __TIZEN_JS_BLUETOOTH_HEALTH_APPLICATION_H__ #include - #include "BluetoothHealthApplication.h" namespace DeviceAPI { namespace Bluetooth { -class BluetoothHealthApplicationHolder +class BluetoothHealthApplicationHolder { public: - BluetoothHealthApplicationHolder(BluetoothHealthApplicationSharedPtr app) {mApp = app;} + BluetoothHealthApplicationHolder(BluetoothHealthApplicationSharedPtr app){mApp = app;} BluetoothHealthApplicationSharedPtr mApp; }; typedef BluetoothHealthApplicationHolder* BluetoothHealthApplicationHolderPtr; diff --git a/src/Bluetooth/JSBluetoothHealthChannel.cpp b/src/Bluetooth/JSBluetoothHealthChannel.cpp index e1a683c..3ee4bf3 100644 --- a/src/Bluetooth/JSBluetoothHealthChannel.cpp +++ b/src/Bluetooth/JSBluetoothHealthChannel.cpp @@ -148,19 +148,17 @@ JSValueRef JSBluetoothHealthChannel::sendData(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);; - // Access Check - TIME_TRACER_ITEM_BEGIN("sendData::ACE", 1);; - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA); - TIME_TRACER_ITEM_END("sendData::ACE", 1);; - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - try { // Private Object BluetoothHealthChannelPtr priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { throw DeviceAPI::Common::UnknownException("Private object is NULL."); } - + // Access Check + TIME_TRACER_ITEM_BEGIN("sendData::ACE", 1);; + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA); + TIME_TRACER_ITEM_END("sendData::ACE", 1);; + ArgumentValidator validator(context, argumentCount, arguments); JSObjectRef dataArrayObj = validator.toArrayObject(0); // data @@ -193,13 +191,9 @@ JSValueRef JSBluetoothHealthChannel::close(JSContextRef context, { LoggerD("Enter"); - TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);; + TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); - // Access Check - TIME_TRACER_ITEM_BEGIN("close::ACE", 1);; - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_CLOSE); - TIME_TRACER_ITEM_END("close::ACE", 1);; - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Private Object @@ -207,6 +201,10 @@ JSValueRef JSBluetoothHealthChannel::close(JSContextRef context, if (!priv) { throw DeviceAPI::Common::UnknownException("Private object is NULL."); } + // Access Check + TIME_TRACER_ITEM_BEGIN("close::ACE", 1);; + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_HEALTH_CHANNEL_API_CLOSE); + TIME_TRACER_ITEM_END("close::ACE", 1);; priv->close(); TIME_TRACER_ITEM_END(__FUNCTION__, 1);; @@ -231,11 +229,7 @@ JSValueRef JSBluetoothHealthChannel::setListener(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);; - // Access Check - TIME_TRACER_ITEM_BEGIN("setListener::ACE", 1);; - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER); - TIME_TRACER_ITEM_END("setListener::ACE", 1);; - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Private Object @@ -244,6 +238,12 @@ JSValueRef JSBluetoothHealthChannel::setListener(JSContextRef context, throw DeviceAPI::Common::UnknownException("Private object is NULL."); } + // Access Check + TIME_TRACER_ITEM_BEGIN("setListener::ACE", 1);; + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER); + TIME_TRACER_ITEM_END("setListener::ACE", 1);; + + // Validate arguments ArgumentValidator validator(context, argumentCount, arguments); @@ -294,11 +294,6 @@ JSValueRef JSBluetoothHealthChannel::unsetListener(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);; - // Access Check - TIME_TRACER_ITEM_BEGIN("unsetListener::ACE", 1);; - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER); - TIME_TRACER_ITEM_END("unsetListener::ACE", 1);; - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); try { // Private Object @@ -306,6 +301,11 @@ JSValueRef JSBluetoothHealthChannel::unsetListener(JSContextRef context, if (!priv) { throw DeviceAPI::Common::UnknownException("Private object is NULL."); } + // Access Check + TIME_TRACER_ITEM_BEGIN("unsetListener::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER); + TIME_TRACER_ITEM_END("unsetListener::ACE", 1); + priv->unsetListener(); TIME_TRACER_ITEM_END(__FUNCTION__, 1);; diff --git a/src/Bluetooth/JSBluetoothHealthProfileHandler.cpp b/src/Bluetooth/JSBluetoothHealthProfileHandler.cpp index a185fe0..343ee45 100644 --- a/src/Bluetooth/JSBluetoothHealthProfileHandler.cpp +++ b/src/Bluetooth/JSBluetoothHealthProfileHandler.cpp @@ -104,12 +104,11 @@ JSValueRef JSBluetoothHealthProfileHandler::registerSinkApplication(JSContextRef LoggerD("Enter"); TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); - - // Access Check - TIME_TRACER_ITEM_BEGIN("registerSinkApplication::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION); - TIME_TRACER_ITEM_END("registerSinkApplication::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + // Access Check + TIME_TRACER_ITEM_BEGIN("registerSinkApplication::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, BluetoothHealthProfileHandler::getInstance(), BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION); + TIME_TRACER_ITEM_END("registerSinkApplication::ACE", 1); + try { ArgumentValidator validator(context, argumentCount, arguments); @@ -154,10 +153,10 @@ JSValueRef JSBluetoothHealthProfileHandler::connectToSource(JSContextRef context TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); // Access Check - TIME_TRACER_ITEM_BEGIN("setName::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE); - TIME_TRACER_ITEM_END("setName::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIME_TRACER_ITEM_BEGIN("connectToSource::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, BluetoothHealthProfileHandler::getInstance(), BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE); + TIME_TRACER_ITEM_END("connectToSource::ACE", 1); + try { ArgumentValidator validator(context, argumentCount, arguments); diff --git a/src/Bluetooth/JSBluetoothManager.cpp b/src/Bluetooth/JSBluetoothManager.cpp index fcc0d60..b0a1422 100644 --- a/src/Bluetooth/JSBluetoothManager.cpp +++ b/src/Bluetooth/JSBluetoothManager.cpp @@ -24,7 +24,7 @@ #include #include -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "JSBluetoothManager.h" #include "JSBluetoothClassDeviceMajor.h" #include "JSBluetoothClassDeviceMinor.h" @@ -90,38 +90,42 @@ const JSClassDefinition* JSBluetoothManager::getClassInfo() void JSBluetoothManager::initialize(JSContextRef context, JSObjectRef object) { + LoggerD("initialize"); + if (!JSObjectGetPrivate(object)) { - PropertyBag *priv = new PropertyBag(); - if(priv) { - // deviceMajor - priv->setProperty(context, BLUETOOTH_MANAGER_DEVICE_MAJOR, - JSBluetoothClassDeviceMajor::createJSObject(context)); - - // deviceMinor - priv->setProperty(context, BLUETOOTH_MANAGER_DEVICE_MINOR, - JSBluetoothClassDeviceMinor::createJSObject(context)); - - // deviceService - priv->setProperty(context, BLUETOOTH_MANAGER_DEVICE_SERVICE, - JSBluetoothClassDeviceService::createJSObject(context)); - - if (!JSObjectSetPrivate(object, static_cast(priv))) { - LoggerW("Failed to set private data"); - delete priv; - } - } - else { - LoggerW("Failed to create private data"); - } - } - else { - LoggerW("Private data already exists"); - } + JSBluetoothManagerPriv* priv = new JSBluetoothManagerPriv(); + + if(priv) { + // deviceMajor + priv->setProperty(context, BLUETOOTH_MANAGER_DEVICE_MAJOR, + JSBluetoothClassDeviceMajor::createJSObject(context)); + + // deviceMinor + priv->setProperty(context, BLUETOOTH_MANAGER_DEVICE_MINOR, + JSBluetoothClassDeviceMinor::createJSObject(context)); + + // deviceService + priv->setProperty(context, BLUETOOTH_MANAGER_DEVICE_SERVICE, + JSBluetoothClassDeviceService::createJSObject(context)); + + if (!JSObjectSetPrivate(object, static_cast(priv))) { + LoggerW("Failed to set private data"); + delete priv; + } + LoggerD("Private creation ok"); + } + else { + LoggerW("Failed to create private data"); + } + } + else { + LoggerW("already has private data"); + } } void JSBluetoothManager::finalize(JSObjectRef object) { - PropertyBag *priv = static_cast(JSObjectGetPrivate(object)); + JSBluetoothManagerPriv *priv = static_cast(JSObjectGetPrivate(object)); if (priv) { JSObjectSetPrivate(object, NULL); delete priv; @@ -129,7 +133,7 @@ void JSBluetoothManager::finalize(JSObjectRef object) } JSValueRef JSBluetoothManager::getReadOnlyProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { - PropertyBag *priv = static_cast(JSObjectGetPrivate(object)); + JSBluetoothManagerPriv *priv = static_cast(JSObjectGetPrivate(object)); if(!priv) { LoggerW("There is no private data"); return NULL; @@ -146,20 +150,27 @@ JSValueRef JSBluetoothManager::getDefaultAdapter(JSContextRef context, const JSValueRef arguments[], JSValueRef* exception) { + JSBluetoothManagerPriv *priv = static_cast(JSObjectGetPrivate(thisObject)); + + if (!priv) + { + DeviceAPI::Common::TypeMismatchException err("Private Object is null"); + return JSWebAPIErrorFactory::postException(context, exception, err); + } + TIME_TRACER_ITEM_BEGIN("getDefaultAdapter", 1); - - // Access Check - TIME_TRACER_ITEM_BEGIN("getDefaultAdapter::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_MANAGER_API_GET_DEFAULT_ADAPTER); + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_MANAGER_API_GET_DEFAULT_ADAPTER); TIME_TRACER_ITEM_END("getDefaultAdapter::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { - JSObjectRef adapter = JSBluetoothAdapter::createJSObject(context); - + if(bt_initialize() != BT_ERROR_NONE) { LoggerE("bt_initialize() failed"); } + + BluetoothAdapter::getInstance()->copyAceCheckAccessFunction(priv); + JSObjectRef adapter = JSBluetoothAdapter::createJSObject(context); TIME_TRACER_ITEM_END("getDefaultAdapter", 1); return adapter; diff --git a/src/Bluetooth/JSBluetoothManager.h b/src/Bluetooth/JSBluetoothManager.h index 99e579e..87c8b75 100644 --- a/src/Bluetooth/JSBluetoothManager.h +++ b/src/Bluetooth/JSBluetoothManager.h @@ -19,9 +19,26 @@ #define __TIZEN_JS_BLUETOOTH_MANAGER_H__ #include +#include +#include +#include namespace DeviceAPI { namespace Bluetooth { + + +class JSBluetoothManagerPriv : + public DeviceAPI::Common::SecurityAccessor, + public DeviceAPI::Common::PropertyBag +{ +public: + JSBluetoothManagerPriv() : + DeviceAPI::Common::SecurityAccessor(), + DeviceAPI::Common::PropertyBag() + { + } + virtual ~JSBluetoothManagerPriv() {} +}; class JSBluetoothManager { diff --git a/src/Bluetooth/JSBluetoothServiceHandler.cpp b/src/Bluetooth/JSBluetoothServiceHandler.cpp index 828d35b..68d70d0 100644 --- a/src/Bluetooth/JSBluetoothServiceHandler.cpp +++ b/src/Bluetooth/JSBluetoothServiceHandler.cpp @@ -180,11 +180,7 @@ JSValueRef JSBluetoothServiceHandler::unregister(JSContextRef context, { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); - // Access Check - TIME_TRACER_ITEM_BEGIN("unregister::ACE", 1); - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SERVICE_HANDLER_API_UNREGISTER); - TIME_TRACER_ITEM_END("unregister::ACE", 1); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + try { // Private Object @@ -193,6 +189,12 @@ JSValueRef JSBluetoothServiceHandler::unregister(JSContextRef context, throw TypeMismatchException("Private object is NULL."); } + // Access Check + TIME_TRACER_ITEM_BEGIN("unregister::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_SERVICE_HANDLER_API_UNREGISTER); + TIME_TRACER_ITEM_END("unregister::ACE", 1); + + ArgumentValidator validator(context, argumentCount, arguments); JSObjectRef successCallback = validator.toFunction(0, true); // successCallback JSObjectRef errorCallback = validator.toFunction(1, true); // errorCallback diff --git a/src/Bluetooth/JSBluetoothSocket.cpp b/src/Bluetooth/JSBluetoothSocket.cpp index 6bfb9ef..f8b3a0a 100644 --- a/src/Bluetooth/JSBluetoothSocket.cpp +++ b/src/Bluetooth/JSBluetoothSocket.cpp @@ -239,13 +239,7 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, const JSValueRef arguments[], JSValueRef* exception) { - TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);; - - // Access Check - TIME_TRACER_ITEM_BEGIN("writeData::ACE", 1);; - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SOCKET_API_WRITE_DATA); - TIME_TRACER_ITEM_END("writeData::ACE", 1);; - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); try { // Private Object @@ -253,7 +247,12 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, if (!priv) { throw DeviceAPI::Common::UnknownException("Private object is NULL."); } - + + // Access Check + TIME_TRACER_ITEM_BEGIN("writeData::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_SOCKET_API_WRITE_DATA); + TIME_TRACER_ITEM_END("writeData::ACE", 1); + ArgumentValidator validator(context, argumentCount, arguments); JSObjectRef dataArrayObj = validator.toArrayObject(0); // data @@ -284,13 +283,8 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, const JSValueRef arguments[], JSValueRef* exception) { - TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);; - - // Access Check - TIME_TRACER_ITEM_BEGIN("readData::ACE", 1);; - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SOCKET_API_READ_DATA); - TIME_TRACER_ITEM_END("readData::ACE", 1);; - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); + try { // Private Object @@ -298,9 +292,15 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, if (!priv) { throw DeviceAPI::Common::UnknownException("Private object is NULL."); } + + // Access Check + TIME_TRACER_ITEM_BEGIN("readData::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_SOCKET_API_READ_DATA); + TIME_TRACER_ITEM_END("readData::ACE", 1); + std::vector data = priv->readData(); - TIME_TRACER_ITEM_END(__FUNCTION__, 1);; + TIME_TRACER_ITEM_END(__FUNCTION__, 1); return JSUtil::toJSValueRef_(context, data); } catch (const BasePlatformException &err) { @@ -319,12 +319,6 @@ JSValueRef JSBluetoothSocket::close(JSContextRef context, JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);; - - // Access Check - TIME_TRACER_ITEM_BEGIN("close::ACE", 1);; - AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SOCKET_API_CLOSE); - TIME_TRACER_ITEM_END("close::ACE", 1);; - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); try { // Private Object @@ -333,6 +327,12 @@ JSValueRef JSBluetoothSocket::close(JSContextRef context, throw DeviceAPI::Common::UnknownException("Private object is NULL."); } + // Access Check + TIME_TRACER_ITEM_BEGIN("close::ACE", 1); + TIZEN_CHECK_ACCESS(context, exception, priv, BLUETOOTH_SOCKET_API_CLOSE); + TIME_TRACER_ITEM_END("close::ACE", 1); + + priv->close(); TIME_TRACER_ITEM_END(__FUNCTION__, 1);; diff --git a/src/Bluetooth/plugin_config.h b/src/Bluetooth/plugin_config.h index 5f346a8..a44485a 100644 --- a/src/Bluetooth/plugin_config.h +++ b/src/Bluetooth/plugin_config.h @@ -20,78 +20,11 @@ #define _BLUETOOTH_PLUGIN_CONFIG_H_ #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace Bluetooth { -// attributes -#define BLUETOOTH_MANAGER_DEVICE_MAJOR "deviceMajor" -#define BLUETOOTH_MANAGER_DEVICE_MINOR "deviceMinor" -#define BLUETOOTH_MANAGER_DEVICE_SERVICE "deviceService" -#define BLUETOOTH_ADAPTER_NAME "name" -#define BLUETOOTH_ADAPTER_ADDRESS "address" -#define BLUETOOTH_ADAPTER_POWERED "powered" -#define BLUETOOTH_ADAPTER_VISIBLE "visible" -#define BLUETOOTH_DEVICE_NAME "name" -#define BLUETOOTH_DEVICE_ADDRESS "address" -#define BLUETOOTH_DEVICE_DEVICE_CLASS "deviceClass" -#define BLUETOOTH_DEVICE_IS_BONDED "isBonded" -#define BLUETOOTH_DEVICE_IS_TRUSTED "isTrusted" -#define BLUETOOTH_DEVICE_IS_CONNECTED "isConnected" -#define BLUETOOTH_DEVICE_UUIDS "uuids" -#define BLUETOOTH_SOCKET_UUID "uuid" -#define BLUETOOTH_SOCKET_STATE "state" -#define BLUETOOTH_SOCKET_PEER "peer" -#define BLUETOOTH_SOCKET_ONMESSAGE "onmessage" -#define BLUETOOTH_SOCKET_ONCLOSE "onclose" -#define BLUETOOTH_SOCKET_ONERROR "onerror" -#define BLUETOOTH_CLASS_MAJOR "major" -#define BLUETOOTH_CLASS_MINOR "minor" -#define BLUETOOTH_CLASS_SERVICES "services" -#define BLUETOOTH_SERVICE_HANDLER_UUID "uuid" -#define BLUETOOTH_SERVICE_HANDLER_NAME "name" -#define BLUETOOTH_SERVICE_HANDLER_IS_CONNECTED "isConnected" -#define BLUETOOTH_SERVICE_HANDLER_ONCONNECT "onconnect" -#define BLUETOOTH_PROFILE_TYPE "profileType" -#define BLUETOOTH_HEALTH_APPLICATION_DATA_TYPE "dataType" -#define BLUETOOTH_HEALTH_APPLICATION_NAME "name" -#define BLUETOOTH_HEALTH_APPLICATION_ONCONNECT "onconnect" -#define BLUETOOTH_HEALTH_CHANNEL_PEER "peer" -#define BLUETOOTH_HEALTH_CHANNEL_TYPE "channelType" -#define BLUETOOTH_HEALTH_CHANNEL_APP "application" -#define BLUETOOTH_HEALTH_CHANNEL_IS_CONNECTED "isConnected" - - -// functions -#define BLUETOOTH_MANAGER_API_GET_DEFAULT_ADAPTER "getDefaultAdapter" -#define BLUETOOTH_ADAPTER_API_SET_NAME "setName" -#define BLUETOOTH_ADAPTER_API_SET_POWERED "setPowered" -#define BLUETOOTH_ADAPTER_API_SET_VISIBLE "setVisible" -#define BLUETOOTH_ADAPTER_API_DISCOVER_DEVICES "discoverDevices" -#define BLUETOOTH_ADAPTER_API_STOP_DISCOVERY "stopDiscovery" -#define BLUETOOTH_ADAPTER_API_GET_KNOWN_DEVICES "getKnownDevices" -#define BLUETOOTH_ADAPTER_API_GET_DEVICE "getDevice" -#define BLUETOOTH_ADAPTER_API_CREATE_BONDING "createBonding" -#define BLUETOOTH_ADAPTER_API_DESTROY_BONDING "destroyBonding" -#define BLUETOOTH_ADAPTER_API_REGISTER_RFCOMMSERVICE_BY_UUID "registerRFCOMMServiceByUUID" -#define BLUETOOTH_ADAPTER_API_GET_BLUETOOTH_PROFILE_HANDLER "getBluetoothProfileHandler" -#define BLUETOOTH_ADAPTER_API_SET_CHANGE_LISTENER "setChangeListener" -#define BLUETOOTH_ADAPTER_API_UNSET_CHANGE_LISTENER "unsetChangeListener" -#define BLUETOOTH_DEVICE_API_CONNECT_TO_SERVICE_BY_UUID "connectToServiceByUUID" -#define BLUETOOTH_SOCKET_API_WRITE_DATA "writeData" -#define BLUETOOTH_SOCKET_API_READ_DATA "readData" -#define BLUETOOTH_SOCKET_API_CLOSE "close" -#define BLUETOOTH_CLASS_API_HAS_SERVICE "hasService" -#define BLUETOOTH_SERVICE_HANDLER_API_UNREGISTER "unregister" -#define BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION "registerSinkApplication" -#define BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER "healthUnregister" -#define BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE "connectToSource" -#define BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA "sendData" -#define BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER "setListener" -#define BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER "unsetListener" -#define BLUETOOTH_HEALTH_CHANNEL_API_CLOSE "healthClose" - - DECLARE_FUNCTION_GETTER(Bluetooth); #define BLUETOOTH_CHECK_ACCESS(functionName) \ diff --git a/src/Bluetooth/plugin_config_impl.h b/src/Bluetooth/plugin_config_impl.h new file mode 100644 index 0000000..4d7668a --- /dev/null +++ b/src/Bluetooth/plugin_config_impl.h @@ -0,0 +1,75 @@ +#ifndef _BLUETOOTH_PLUGIN_CONFIG_IMPL_H_ +#define _BLUETOOTH_PLUGIN_CONFIG_IMPL_H_ + +namespace DeviceAPI { +namespace Bluetooth { + +// attributes +#define BLUETOOTH_MANAGER_DEVICE_MAJOR "deviceMajor" +#define BLUETOOTH_MANAGER_DEVICE_MINOR "deviceMinor" +#define BLUETOOTH_MANAGER_DEVICE_SERVICE "deviceService" +#define BLUETOOTH_ADAPTER_NAME "name" +#define BLUETOOTH_ADAPTER_ADDRESS "address" +#define BLUETOOTH_ADAPTER_POWERED "powered" +#define BLUETOOTH_ADAPTER_VISIBLE "visible" +#define BLUETOOTH_DEVICE_NAME "name" +#define BLUETOOTH_DEVICE_ADDRESS "address" +#define BLUETOOTH_DEVICE_DEVICE_CLASS "deviceClass" +#define BLUETOOTH_DEVICE_IS_BONDED "isBonded" +#define BLUETOOTH_DEVICE_IS_TRUSTED "isTrusted" +#define BLUETOOTH_DEVICE_IS_CONNECTED "isConnected" +#define BLUETOOTH_DEVICE_UUIDS "uuids" +#define BLUETOOTH_SOCKET_UUID "uuid" +#define BLUETOOTH_SOCKET_STATE "state" +#define BLUETOOTH_SOCKET_PEER "peer" +#define BLUETOOTH_SOCKET_ONMESSAGE "onmessage" +#define BLUETOOTH_SOCKET_ONCLOSE "onclose" +#define BLUETOOTH_SOCKET_ONERROR "onerror" +#define BLUETOOTH_CLASS_MAJOR "major" +#define BLUETOOTH_CLASS_MINOR "minor" +#define BLUETOOTH_CLASS_SERVICES "services" +#define BLUETOOTH_SERVICE_HANDLER_UUID "uuid" +#define BLUETOOTH_SERVICE_HANDLER_NAME "name" +#define BLUETOOTH_SERVICE_HANDLER_IS_CONNECTED "isConnected" +#define BLUETOOTH_SERVICE_HANDLER_ONCONNECT "onconnect" +#define BLUETOOTH_PROFILE_TYPE "profileType" +#define BLUETOOTH_HEALTH_APPLICATION_DATA_TYPE "dataType" +#define BLUETOOTH_HEALTH_APPLICATION_NAME "name" +#define BLUETOOTH_HEALTH_APPLICATION_ONCONNECT "onconnect" +#define BLUETOOTH_HEALTH_CHANNEL_PEER "peer" +#define BLUETOOTH_HEALTH_CHANNEL_TYPE "channelType" +#define BLUETOOTH_HEALTH_CHANNEL_APP "application" +#define BLUETOOTH_HEALTH_CHANNEL_IS_CONNECTED "isConnected" + + +// functions +#define BLUETOOTH_MANAGER_API_GET_DEFAULT_ADAPTER "getDefaultAdapter" +#define BLUETOOTH_ADAPTER_API_SET_NAME "setName" +#define BLUETOOTH_ADAPTER_API_SET_POWERED "setPowered" +#define BLUETOOTH_ADAPTER_API_SET_VISIBLE "setVisible" +#define BLUETOOTH_ADAPTER_API_DISCOVER_DEVICES "discoverDevices" +#define BLUETOOTH_ADAPTER_API_STOP_DISCOVERY "stopDiscovery" +#define BLUETOOTH_ADAPTER_API_GET_KNOWN_DEVICES "getKnownDevices" +#define BLUETOOTH_ADAPTER_API_GET_DEVICE "getDevice" +#define BLUETOOTH_ADAPTER_API_CREATE_BONDING "createBonding" +#define BLUETOOTH_ADAPTER_API_DESTROY_BONDING "destroyBonding" +#define BLUETOOTH_ADAPTER_API_REGISTER_RFCOMMSERVICE_BY_UUID "registerRFCOMMServiceByUUID" +#define BLUETOOTH_ADAPTER_API_GET_BLUETOOTH_PROFILE_HANDLER "getBluetoothProfileHandler" +#define BLUETOOTH_ADAPTER_API_SET_CHANGE_LISTENER "setChangeListener" +#define BLUETOOTH_ADAPTER_API_UNSET_CHANGE_LISTENER "unsetChangeListener" +#define BLUETOOTH_DEVICE_API_CONNECT_TO_SERVICE_BY_UUID "connectToServiceByUUID" +#define BLUETOOTH_SOCKET_API_WRITE_DATA "writeData" +#define BLUETOOTH_SOCKET_API_READ_DATA "readData" +#define BLUETOOTH_SOCKET_API_CLOSE "close" +#define BLUETOOTH_CLASS_API_HAS_SERVICE "hasService" +#define BLUETOOTH_SERVICE_HANDLER_API_UNREGISTER "unregister" +#define BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION "registerSinkApplication" +#define BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER "healthUnregister" +#define BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE "connectToSource" +#define BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA "sendData" +#define BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER "setListener" +#define BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER "unsetListener" +#define BLUETOOTH_HEALTH_CHANNEL_API_CLOSE "healthClose" +} +} +#endif diff --git a/src/Bluetooth/plugin_initializer.cpp b/src/Bluetooth/plugin_initializer.cpp index e98bb1f..d0270f5 100644 --- a/src/Bluetooth/plugin_initializer.cpp +++ b/src/Bluetooth/plugin_initializer.cpp @@ -18,9 +18,9 @@ #include #include - +#include #include - +#include "plugin_config.h" #include "JSBluetoothManager.h" #include "BluetoothAdapter.h" @@ -33,6 +33,25 @@ using namespace DeviceAPI::Common; namespace DeviceAPI { namespace Bluetooth { + +AceSecurityStatus bluetoothAceCheckAccessFunction(const char* functionName) +{ + return BLUETOOTH_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerBluetoothSetter, JSBluetoothManagerPriv, gSecurityAccessor); + +class_definition_options_t BluetoothOptions = +{ + JS_CLASS, + CREATE_INSTANCE, + ALWAYS_NOTICE, + USE_OVERLAYED, + AceCheckerBluetoothSetter, + NULL +}; + void on_widget_start_callback(int widgetId) @@ -44,6 +63,7 @@ void on_widget_start_callback(int widgetId) } catch (...) { LoggerE("WrtAccess initialization failed"); } + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, bluetoothAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) @@ -56,6 +76,7 @@ void on_widget_stop_callback(int widgetId) } catch (...) { LoggerE("WrtAccess deinitialization failed"); } + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } void on_frame_load_callback(const void *context) @@ -80,7 +101,7 @@ PLUGIN_CLASS_MAP_BEGIN PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "bluetooth", (js_class_template_getter)JSBluetoothManager::getClassRef, - NULL) + &BluetoothOptions) PLUGIN_CLASS_MAP_END } // Bluetooth diff --git a/src/Calendar/CMakeLists.txt b/src/Calendar/CMakeLists.txt index b242e51..56bb9b6 100755 --- a/src/Calendar/CMakeLists.txt +++ b/src/Calendar/CMakeLists.txt @@ -71,7 +71,6 @@ ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_IMPL_NAME} - "-Wl,--no-as-needed" ${contact_config} ) INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) diff --git a/src/Calendar/CalendarConverter.cpp b/src/Calendar/CalendarConverter.cpp index d2e015e..90909eb 100755 --- a/src/Calendar/CalendarConverter.cpp +++ b/src/Calendar/CalendarConverter.cpp @@ -45,9 +45,18 @@ const int DEFAULT_EVENT_INTERVAL = 1; namespace DeviceAPI { namespace Calendar { -CalendarConverter::CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType) : Converter(context) +CalendarConverter::CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType, + DeviceAPI::Common::SecurityAccessor *securityAccessor) : Converter(context) { m_calendarType = calendarType; + m_securityAccessor = securityAccessor; +} + +CalendarConverter::CalendarConverter(JSContextRef context, DeviceAPI::Common::SecurityAccessor *securityAccessor, + CalendarEvent::CalendarType calendarType) : Converter(context) +{ + m_securityAccessor = securityAccessor; + m_calendarType = calendarType; } CalendarConverter::~CalendarConverter() @@ -56,12 +65,18 @@ CalendarConverter::~CalendarConverter() JSValueRef CalendarConverter::toJSValueRefEvent(const CalendarEventPtr& arg) { - return JSUtils::makeObject(m_context, JSCalendarEvent::getClassRef(), arg); + CalendarEventPrivObject *priv = new CalendarEventPrivObject(m_context, arg); + if(m_securityAccessor != NULL) + priv->copyAceCheckAccessFunction(m_securityAccessor); + return JSObjectMake(m_context, JSCalendarEvent::getClassRef(), priv); } JSValueRef CalendarConverter::toJSValueRefTask(const CalendarEventPtr& arg) { - return JSUtils::makeObject(m_context, JSCalendarTask::getClassRef(), arg); + CalendarTaskPrivObject *priv = new CalendarTaskPrivObject(m_context, arg); + if(m_securityAccessor != NULL) + priv->copyAceCheckAccessFunction(m_securityAccessor); + return JSObjectMake(m_context, JSCalendarTask::getClassRef(), priv); } JSValueRef CalendarConverter::toJSValueRefEventArray(const CalendarEventListPtr &arg) @@ -77,6 +92,8 @@ JSValueRef CalendarConverter::toJSValueRefTaskArray(const CalendarEventListPtr & JSValueRef CalendarConverter::toJSValueRefCalendar(const ICalendarPtr& arg) { CalendarPrivObject *priv = new CalendarPrivObject(m_context, arg); + if(m_securityAccessor != NULL) + priv->copyAceCheckAccessFunction(m_securityAccessor); return JSObjectMake(m_context, JSCalendar::getClassRef(), priv); } diff --git a/src/Calendar/CalendarConverter.h b/src/Calendar/CalendarConverter.h index 2092edb..283d343 100755 --- a/src/Calendar/CalendarConverter.h +++ b/src/Calendar/CalendarConverter.h @@ -26,6 +26,7 @@ #include "EventAlarm.h" #include #include +#include namespace DeviceAPI { namespace Calendar { @@ -35,7 +36,10 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter public: using Converter::toJSValueRef; public: - explicit CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE); + explicit CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE, + DeviceAPI::Common::SecurityAccessor *securityAccessor=NULL); + explicit CalendarConverter(JSContextRef context, DeviceAPI::Common::SecurityAccessor *securityAccessor, + CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE); virtual ~CalendarConverter(); CalendarEventPtr toItem(const JSValueRef value, bool updateMode); @@ -103,6 +107,7 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter private: CalendarEvent::CalendarType m_calendarType; + DeviceAPI::Common::SecurityAccessor* m_securityAccessor; }; } diff --git a/src/Calendar/CalendarMultiCallback.h b/src/Calendar/CalendarMultiCallback.h index 6a0710f..38d1588 100755 --- a/src/Calendar/CalendarMultiCallback.h +++ b/src/Calendar/CalendarMultiCallback.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "CalendarEvent.h" @@ -81,7 +82,9 @@ struct CalendarChangeCallback { { } }; -class CalendarChangeCallbackPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +class CalendarChangeCallbackPrivateData : + public WrtDeviceApis::Commons::IEventPrivateData, + public DeviceAPI::Common::SecurityAccessor { public: CalendarChangeCallbackPrivateData(const JSCallbackManagerPtr& onAdded, diff --git a/src/Calendar/CalendarResponseDispatcher.cpp b/src/Calendar/CalendarResponseDispatcher.cpp index d5522f7..23264d2 100755 --- a/src/Calendar/CalendarResponseDispatcher.cpp +++ b/src/Calendar/CalendarResponseDispatcher.cpp @@ -70,7 +70,7 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventGetCalendarsPtr &e Try { if (event->getResult()) { - CalendarConverter converter(cbm->getContext()); + CalendarConverter converter(cbm->getContext(), event.Get()); const std::vector &results = event->getCalendars(); LoggerD("found calendars: " << results.size()); JSValueRef result = converter.toJSValueRef(results); @@ -104,7 +104,7 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventAddEventsPtr &even if (event->getResult()) { LoggerD("result success"); - CalendarConverter converter(cbm->getContext()); + CalendarConverter converter(cbm->getContext(), event.Get()); JSValueRef result; if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { @@ -194,7 +194,7 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventFindEventsPtr &eve Try { if (event->getResult()) { - CalendarConverter converter(cbm->getContext()); + CalendarConverter converter(cbm->getContext(), event.Get()); JSValueRef result; if (CalendarEvent::TASK_TYPE==event->getCalendarType()) { @@ -245,7 +245,7 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventExpandEventRecurre } if (event->getResult()) { - CalendarConverter converter(cbm->getContext()); + CalendarConverter converter(cbm->getContext(), event.Get()); cbm->callOnSuccess(converter.toJSValueRefEventArray(event->getExpandedEventList())); return; } else { @@ -279,7 +279,7 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even DPL::StaticPointerCast(event->getPrivateData()); JSContextRef context = multiCallbacks->getOnAdded()->getContext(); - CalendarConverter converter(context); + CalendarConverter converter(context, multiCallbacks.Get()); JSValueRef result; Try diff --git a/src/Calendar/IEventAddEvents.h b/src/Calendar/IEventAddEvents.h index f235214..33462c7 100755 --- a/src/Calendar/IEventAddEvents.h +++ b/src/Calendar/IEventAddEvents.h @@ -22,11 +22,12 @@ #include #include "CalendarEvent.h" #include +#include namespace DeviceAPI { namespace Calendar { -class IEventAddEvents : public WrtDeviceApis::Commons::IEvent +class IEventAddEvents : public WrtDeviceApis::Commons::IEvent, public DeviceAPI::Common::SecurityAccessor { CalendarEventListPtr m_events; bool m_result; diff --git a/src/Calendar/IEventExpandEventRecurrence.h b/src/Calendar/IEventExpandEventRecurrence.h index 84c6543..deed454 100755 --- a/src/Calendar/IEventExpandEventRecurrence.h +++ b/src/Calendar/IEventExpandEventRecurrence.h @@ -22,11 +22,12 @@ #include #include "CalendarEvent.h" #include +#include namespace DeviceAPI { namespace Calendar { -class IEventExpandEventRecurrence : public WrtDeviceApis::Commons::IEvent +class IEventExpandEventRecurrence : public WrtDeviceApis::Commons::IEvent, public DeviceAPI::Common::SecurityAccessor { CalendarEventListPtr m_expandedEventList; //output bool m_result; // ouput diff --git a/src/Calendar/IEventFindEvents.h b/src/Calendar/IEventFindEvents.h index b340b43..c0c9461 100755 --- a/src/Calendar/IEventFindEvents.h +++ b/src/Calendar/IEventFindEvents.h @@ -25,11 +25,12 @@ #include #include #include +#include namespace DeviceAPI { namespace Calendar { -class IEventFindEvents : public WrtDeviceApis::Commons::IEvent +class IEventFindEvents : public WrtDeviceApis::Commons::IEvent, public DeviceAPI::Common::SecurityAccessor { /* user is responsible to free objects inside list */ CalendarEventListPtr m_events; diff --git a/src/Calendar/IEventGetCalendars.h b/src/Calendar/IEventGetCalendars.h index 47308a8..79601a9 100755 --- a/src/Calendar/IEventGetCalendars.h +++ b/src/Calendar/IEventGetCalendars.h @@ -23,11 +23,12 @@ #include #include "ICalendar.h" #include +#include namespace DeviceAPI { namespace Calendar { -class IEventGetCalendars : public WrtDeviceApis::Commons::IEvent +class IEventGetCalendars : public WrtDeviceApis::Commons::IEvent, public DeviceAPI::Common::SecurityAccessor { std::vector m_calendars; bool m_result; diff --git a/src/Calendar/JSCalendar.cpp b/src/Calendar/JSCalendar.cpp index 55e6efc..ee8328c 100755 --- a/src/Calendar/JSCalendar.cpp +++ b/src/Calendar/JSCalendar.cpp @@ -151,9 +151,8 @@ JSValueRef JSCalendar::add(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_ADD); Try { @@ -232,9 +231,7 @@ JSValueRef JSCalendar::addBatch(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD_BATCH); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_ADD_BATCH); Try { @@ -277,6 +274,7 @@ JSValueRef JSCalendar::addBatch(JSContextRef context, dplEvent->setEvents(events); dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + dplEvent->copyAceCheckAccessFunction(privateObject); calendar->addEvents(dplEvent); TIME_TRACER_ITEM_END(__FUNCTION__, 0); @@ -315,9 +313,7 @@ JSValueRef JSCalendar::update(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_UPDATE); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_UPDATE); Try { @@ -403,9 +399,7 @@ JSValueRef JSCalendar::updateBatch(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_UPDATE_BATCH); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_UPDATE_BATCH); Try { @@ -499,9 +493,7 @@ JSValueRef JSCalendar::remove(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_REMOVE); Try { @@ -593,9 +585,7 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE_BATCH); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_REMOVE_BATCH); Try { @@ -708,9 +698,7 @@ JSValueRef JSCalendar::find(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_FIND); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_FIND); Try { @@ -749,6 +737,7 @@ JSValueRef JSCalendar::find(JSContextRef context, dplEvent->setCalendarType(calendar->getType()); dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + dplEvent->copyAceCheckAccessFunction(privateObject); if (argumentCount>=3) { if (JSValueIsObject(context, arguments[2])) { @@ -815,9 +804,7 @@ JSValueRef JSCalendar::get(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_GET); Try { @@ -866,9 +853,9 @@ JSValueRef JSCalendar::get(JSContextRef context, if (CalendarEvent::EVENT_TYPE==calendar->getType()) { TIME_TRACER_ITEM_END(__FUNCTION__, 0); // Use global context for the expandRecurrence api in event. - return JSCalendarEvent::createJSCalendarEvent(globalContext, dplEvent->getItem()); + return JSCalendarEvent::createJSCalendarEvent(globalContext, dplEvent->getItem(), privateObject); } else if (CalendarEvent::TASK_TYPE==calendar->getType()) { - return JSCalendarTask::createJSCalendarTask(context, dplEvent->getItem()); + return JSCalendarTask::createJSCalendarTask(context, dplEvent->getItem(), privateObject); } else { ThrowMsg(UnknownException, "Wrong calendar type."); } @@ -918,9 +905,7 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER); Try { @@ -978,6 +963,7 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context, CalendarChangeCallbackPrivateDataPtr privData(new CalendarChangeCallbackPrivateData( onAddedCbm, onUpdatedCbm, onDeletedCbm)); + privData->copyAceCheckAccessFunction(privateObject); OnEventsChangedEmitterPtr emitter(new OnEventsChangedEmitter()); emitter->setListener(&CalendarResponseDispatcher::getInstance()); emitter->setEventPrivateData(DPL::StaticPointerCast(privData)); @@ -1035,9 +1021,7 @@ JSValueRef JSCalendar::removeChangeListener(JSContextRef context, CalendarPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER); Try { diff --git a/src/Calendar/JSCalendar.h b/src/Calendar/JSCalendar.h index ee2486b..03895f4 100755 --- a/src/Calendar/JSCalendar.h +++ b/src/Calendar/JSCalendar.h @@ -25,6 +25,7 @@ #include #include "ICalendar.h" #include +#include namespace DeviceAPI { namespace Calendar { @@ -34,7 +35,23 @@ namespace Calendar { #define TIZEN_CALENDAR_PROPERTY_ID "id" typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarPrivObject; + WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarPrivObjectBase; + +class CalendarPrivObject : + public CalendarPrivObjectBase, + public DeviceAPI::Common::SecurityAccessor +{ +public: + CalendarPrivObject(JSContextRef context, ICalendarPtr calendar) : + CalendarPrivObjectBase(context, calendar), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~CalendarPrivObject() + { + } +}; class JSCalendar { diff --git a/src/Calendar/JSCalendarEvent.cpp b/src/Calendar/JSCalendarEvent.cpp index 0969560..6ff19c7 100755 --- a/src/Calendar/JSCalendarEvent.cpp +++ b/src/Calendar/JSCalendarEvent.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -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(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); diff --git a/src/Calendar/JSCalendarEvent.h b/src/Calendar/JSCalendarEvent.h index 9dd4bb4..1f224bf 100755 --- a/src/Calendar/JSCalendarEvent.h +++ b/src/Calendar/JSCalendarEvent.h @@ -23,7 +23,9 @@ #include "CalendarEvent.h" #include "ICalendar.h" #include "CalendarFactory.h" +#include "JSCalendarItemProperties.h" #include +#include namespace DeviceAPI { namespace Calendar { @@ -36,8 +38,7 @@ namespace Calendar { #define TIZEN_CALENDAR_EVENT_AVAILABILITY "availability" #define TIZEN_CALENDAR_EVENT_RECURRENCE_RULE "recurrenceRule" -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarEventPrivObject; +typedef CalendarItemPropertiesPrivObject CalendarEventPrivObject; class JSCalendarEvent { @@ -53,7 +54,7 @@ class JSCalendarEvent JSContextRef ctx, const JSObjectRef object); - static JSObjectRef createJSCalendarEvent(JSContextRef context, CalendarEventPtr event); + static JSObjectRef createJSCalendarEvent(JSContextRef context, CalendarEventPtr event, const DeviceAPI::Common::SecurityAccessor *securityAccessor); static JSObjectRef constructor(JSContextRef context, JSObjectRef constructor, diff --git a/src/Calendar/JSCalendarItemProperties.cpp b/src/Calendar/JSCalendarItemProperties.cpp index 834bc95..0391201 100755 --- a/src/Calendar/JSCalendarItemProperties.cpp +++ b/src/Calendar/JSCalendarItemProperties.cpp @@ -196,9 +196,7 @@ JSValueRef JSCalendarItemProperties::convertToString(JSContextRef context, CalendarItemPropertiesPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_CONVERT_TO_STRING); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_CONVERT_TO_STRING); Try { @@ -276,9 +274,7 @@ JSValueRef JSCalendarItemProperties::clone(JSContextRef context, CalendarItemPropertiesPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_CLONE); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_CLONE); Try { @@ -301,11 +297,11 @@ JSValueRef JSCalendarItemProperties::clone(JSContextRef context, if (CalendarEvent::TASK_TYPE==clonedItem->getCalendarType()) { TIME_TRACER_ITEM_END("clone(TASK)", 0); - return JSCalendarTask::createJSCalendarTask(context, clonedItem); + return JSCalendarTask::createJSCalendarTask(context, clonedItem, privateObject); } else if (CalendarEvent::EVENT_TYPE==clonedItem->getCalendarType()) { TIME_TRACER_ITEM_END("clone(EVENT)", 0); // Use global context for potential async api invocation. - return JSCalendarEvent::createJSCalendarEvent(globalContext, clonedItem); + return JSCalendarEvent::createJSCalendarEvent(globalContext, clonedItem, privateObject); } else { ThrowMsg(ConversionException, "Wrong object type."); } diff --git a/src/Calendar/JSCalendarItemProperties.h b/src/Calendar/JSCalendarItemProperties.h index 6ac2c6f..3865088 100755 --- a/src/Calendar/JSCalendarItemProperties.h +++ b/src/Calendar/JSCalendarItemProperties.h @@ -22,6 +22,7 @@ #include #include "CalendarEvent.h" #include +#include namespace DeviceAPI { namespace Calendar { @@ -45,7 +46,23 @@ namespace Calendar { #define TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE "lastModificationDate" typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarItemPropertiesPrivObject; + WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarItemPropertiesPrivObjectBase; + +class CalendarItemPropertiesPrivObject : + public CalendarItemPropertiesPrivObjectBase, + public DeviceAPI::Common::SecurityAccessor +{ +public: + CalendarItemPropertiesPrivObject(JSContextRef context, CalendarEventPtr calendarEvent) : + CalendarItemPropertiesPrivObjectBase(context, calendarEvent), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~CalendarItemPropertiesPrivObject() + { + } +}; class JSCalendarItemProperties { diff --git a/src/Calendar/JSCalendarManager.cpp b/src/Calendar/JSCalendarManager.cpp index 27cb03c..86dbe9d 100755 --- a/src/Calendar/JSCalendarManager.cpp +++ b/src/Calendar/JSCalendarManager.cpp @@ -115,9 +115,7 @@ JSValueRef JSCalendarManager::getCalendars(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_CALENDARS); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_GET_CALENDARS); Try { if (!privateObject) { @@ -151,6 +149,7 @@ JSValueRef JSCalendarManager::getCalendars(JSContextRef context, dplEvent->setType(calendarType); dplEvent->setPrivateData(DPL::StaticPointerCast(cbm)); dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance()); + dplEvent->copyAceCheckAccessFunction(privateObject); privateObject->getObject()->getCalendars(dplEvent); TIME_TRACER_ITEM_END(__FUNCTION__, 0); @@ -188,9 +187,7 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR); Try { if (!privateObject) { @@ -200,7 +197,7 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context, // Global context should be passed to the calendar object. JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context); - CalendarConverter converter(globalContext); + CalendarConverter converter(globalContext, privateObject); CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE; if (argumentCount>=1) { calendarType = converter.toCalendarType(converter.toString(arguments[0])); @@ -264,9 +261,7 @@ JSValueRef JSCalendarManager::getUnifiedCalendar(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR); Try { if (!privateObject) { @@ -276,7 +271,7 @@ JSValueRef JSCalendarManager::getUnifiedCalendar(JSContextRef context, // Global context should be passed to the calendar object. JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context); - CalendarConverter converter(globalContext); + CalendarConverter converter(globalContext, privateObject); CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE; if (argumentCount>=1) { calendarType = converter.toCalendarType(converter.toString(arguments[0])); @@ -340,9 +335,7 @@ JSValueRef JSCalendarManager::getCalendar(JSContextRef context, TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); CalendarManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(thisObject)); - AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_CALENDAR); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CALENDAR_FUNCTION_API_GET_CALENDAR); Try { if (!privateObject) { @@ -352,7 +345,7 @@ JSValueRef JSCalendarManager::getCalendar(JSContextRef context, // Global context should be passed to the calendar object. JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context); - CalendarConverter converter(globalContext); + CalendarConverter converter(globalContext, privateObject); CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE; if (argumentCount>=1) { diff --git a/src/Calendar/JSCalendarManager.h b/src/Calendar/JSCalendarManager.h index 0fa49d9..207ed61 100755 --- a/src/Calendar/JSCalendarManager.h +++ b/src/Calendar/JSCalendarManager.h @@ -21,6 +21,7 @@ #include #include +#include #include "ICalendarManager.h" #include "ICalendar.h" @@ -28,7 +29,21 @@ namespace DeviceAPI { namespace Calendar { typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarManagerPrivObject; + WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarManagerPrivObjectBase; + +class CalendarManagerPrivObject : public CalendarManagerPrivObjectBase, public DeviceAPI::Common::SecurityAccessor +{ +public: + CalendarManagerPrivObject(JSContextRef context, ICalendarManagerPtr calendarManager) : + CalendarManagerPrivObjectBase(context, calendarManager), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~CalendarManagerPrivObject() + { + } +}; #define TIZEN_CALENDAR_PROPERTY_VCALENDAR_20_FORMAT "ICALENDAR_20" #define TIZEN_CALENDAR_PROPERTY_VCALENDAR_10_FORMAT "VCALENDAR_10" diff --git a/src/Calendar/JSCalendarTask.cpp b/src/Calendar/JSCalendarTask.cpp index 27f6c87..b48ec11 100755 --- a/src/Calendar/JSCalendarTask.cpp +++ b/src/Calendar/JSCalendarTask.cpp @@ -23,13 +23,13 @@ #include "ICalendar.h" #include "CalendarFactory.h" #include "JSCalendarTask.h" -#include "JSCalendarItemProperties.h" #include "CalendarConverter.h" #include "JSCalendarEventId.h" #include #include #include #include +#include #include #include @@ -113,6 +113,17 @@ JSObjectRef DLL_EXPORT JSCalendarTask::constructor(JSContextRef context, JSValueRef* exception) { CalendarEventPtr task(new CalendarEvent()); + DeviceAPI::Common::SecurityAccessor *securityAccessor = NULL; + + try + { + securityAccessor = DeviceAPI::Common::JSObjectGetSecurityAccessor(context, constructor); + } + catch(BasePlatformException &e) + { + task->setCalendarType(CalendarEvent::TASK_TYPE); + return createJSCalendarTask(context, task, securityAccessor); + } Try { @@ -166,7 +177,7 @@ JSObjectRef DLL_EXPORT JSCalendarTask::constructor(JSContextRef context, } task->setCalendarType(CalendarEvent::TASK_TYPE); - return createJSCalendarTask(context, task); + return createJSCalendarTask(context, task, securityAccessor); } Catch(UnsupportedException) { @@ -190,12 +201,13 @@ JSObjectRef DLL_EXPORT JSCalendarTask::constructor(JSContextRef context, } task->setCalendarType(CalendarEvent::TASK_TYPE); - return createJSCalendarTask(context, task); + return createJSCalendarTask(context, task, securityAccessor); } -JSObjectRef JSCalendarTask::createJSCalendarTask(JSContextRef context, CalendarEventPtr task) +JSObjectRef JSCalendarTask::createJSCalendarTask(JSContextRef context, CalendarEventPtr task, const DeviceAPI::Common::SecurityAccessor *securityAccessor) { CalendarTaskPrivObject *priv = new CalendarTaskPrivObject(context, task); + priv->copyAceCheckAccessFunction(securityAccessor); return JSObjectMake(context, getClassRef(), priv); } diff --git a/src/Calendar/JSCalendarTask.h b/src/Calendar/JSCalendarTask.h index 9abfbff..e33e57a 100755 --- a/src/Calendar/JSCalendarTask.h +++ b/src/Calendar/JSCalendarTask.h @@ -21,6 +21,7 @@ #include #include "CalendarEvent.h" +#include "JSCalendarItemProperties.h" #include namespace DeviceAPI { @@ -33,8 +34,7 @@ namespace Calendar { #define TIZEN_CALENDAR_TASK_COMPLETED_DATE "completedDate" #define TIZEN_CALENDAR_TASK_PROGRESS "progress" -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject CalendarTaskPrivObject; +typedef CalendarItemPropertiesPrivObject CalendarTaskPrivObject; class JSCalendarTask { @@ -50,7 +50,7 @@ class JSCalendarTask JSContextRef ctx, const JSObjectRef object); - static JSObjectRef createJSCalendarTask(JSContextRef context, CalendarEventPtr task); + static JSObjectRef createJSCalendarTask(JSContextRef context, CalendarEventPtr task, const DeviceAPI::Common::SecurityAccessor *securityAccessor); static JSObjectRef constructor(JSContextRef context, JSObjectRef constructor, diff --git a/src/Calendar/plugin_config.cpp b/src/Calendar/plugin_config.cpp index f6518fe..2a89106 100755 --- a/src/Calendar/plugin_config.cpp +++ b/src/Calendar/plugin_config.cpp @@ -40,12 +40,8 @@ static FunctionMapping createCalendarFunctions(); static FunctionMapping CalendarFunctions = createCalendarFunctions(); -#pragma GCC visibility push(default) - DEFINE_FUNCTION_GETTER(Calendar, CalendarFunctions); -#pragma GCC visibility pop - static FunctionMapping createCalendarFunctions() { /** diff --git a/src/Calendar/plugin_config.h b/src/Calendar/plugin_config.h index f553673..c4dc578 100755 --- a/src/Calendar/plugin_config.h +++ b/src/Calendar/plugin_config.h @@ -21,31 +21,11 @@ #include #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace Calendar { -// Functions from calendar manager -#define CALENDAR_FUNCTION_API_GET_CALENDARS "getCalendars" -#define CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR "getDefaultCalendar" -#define CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR "getUnifiedCalendar" -#define CALENDAR_FUNCTION_API_GET_CALENDAR "getCalendar" - -// Functions from calendar -#define CALENDAR_FUNCTION_API_ADD "add" -#define CALENDAR_FUNCTION_API_ADD_BATCH "addBatch" -#define CALENDAR_FUNCTION_API_UPDATE "update" -#define CALENDAR_FUNCTION_API_UPDATE_BATCH "updateBatch" -#define CALENDAR_FUNCTION_API_REMOVE "remove" -#define CALENDAR_FUNCTION_API_REMOVE_BATCH "removeBatch" -#define CALENDAR_FUNCTION_API_FIND "find" -#define CALENDAR_FUNCTION_API_CONVERT_TO_STRING "convertToString" -#define CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER "addChangeListener" -#define CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER "removeChangeListener" -#define CALENDAR_FUNCTION_API_EXPAND_RECURRENCE "expandRecurrence" -#define CALENDAR_FUNCTION_API_GET "get" -#define CALENDAR_FUNCTION_API_CLONE "clone" - DECLARE_FUNCTION_GETTER(Calendar); #define CALENDAR_CHECK_ACCESS(functionName) \ diff --git a/src/Calendar/plugin_config_impl.h b/src/Calendar/plugin_config_impl.h new file mode 100755 index 0000000..8b73606 --- /dev/null +++ b/src/Calendar/plugin_config_impl.h @@ -0,0 +1,43 @@ +// +// 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. +// + + +#ifndef _CALENDAR_PLUGIN_CONFIG_IMPL_H_ +#define _CALENDAR_PLUGIN_CONFIG_IMPL_H_ + +// Functions from calendar manager +#define CALENDAR_FUNCTION_API_GET_CALENDARS "getCalendars" +#define CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR "getDefaultCalendar" +#define CALENDAR_FUNCTION_API_GET_UNIFIED_CALENDAR "getUnifiedCalendar" +#define CALENDAR_FUNCTION_API_GET_CALENDAR "getCalendar" + +// Functions from calendar +#define CALENDAR_FUNCTION_API_ADD "add" +#define CALENDAR_FUNCTION_API_ADD_BATCH "addBatch" +#define CALENDAR_FUNCTION_API_UPDATE "update" +#define CALENDAR_FUNCTION_API_UPDATE_BATCH "updateBatch" +#define CALENDAR_FUNCTION_API_REMOVE "remove" +#define CALENDAR_FUNCTION_API_REMOVE_BATCH "removeBatch" +#define CALENDAR_FUNCTION_API_FIND "find" +#define CALENDAR_FUNCTION_API_CONVERT_TO_STRING "convertToString" +#define CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER "addChangeListener" +#define CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER "removeChangeListener" +#define CALENDAR_FUNCTION_API_EXPAND_RECURRENCE "expandRecurrence" +#define CALENDAR_FUNCTION_API_GET "get" +#define CALENDAR_FUNCTION_API_CLONE "clone" + +#endif // _CALENDAR_PLUGIN_CONFIG_IMPL_H_ diff --git a/src/Calendar/plugin_initializer.cpp b/src/Calendar/plugin_initializer.cpp index 9d3f423..da0e489 100755 --- a/src/Calendar/plugin_initializer.cpp +++ b/src/Calendar/plugin_initializer.cpp @@ -30,36 +30,50 @@ #include #include +#include +#include #include +#include "plugin_config.h" + +namespace DeviceAPI { +namespace Calendar { + +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + +AceSecurityStatus calendarAceCheckAccessFunction(const char* functionName) +{ + return CALENDAR_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerCalendarSetter, CalendarManagerPrivObject, gSecurityAccessor); +DEFINE_JSOBJECT_SECURITY_ACCESSOR_SETTER(AceCheckerCalendarConstructorSetter, gSecurityAccessor); + namespace Options{ class_definition_options_t CalendarOptions = { JS_CLASS, CREATE_INSTANCE, - NONE_NOTICE, + ALWAYS_NOTICE, USE_OVERLAYED, //ignored - NULL, + AceCheckerCalendarSetter, NULL }; class_definition_options_t CalendarInterfaceOptions = { JS_INTERFACE, CREATE_INSTANCE, - NONE_NOTICE, + ALWAYS_NOTICE, USE_OVERLAYED, //ignored - NULL, // JSWidget::acquireGlobalContext, + AceCheckerCalendarConstructorSetter, // JSWidget::acquireGlobalContext, NULL, NULL }; } -namespace DeviceAPI { -namespace Calendar { - -using namespace WrtDeviceApis; -using namespace WrtDeviceApis::Commons; - void on_widget_start_callback(int widgetId) { LoggerD("[Tizen\\Calendar] on_widget_start_callback (" << widgetId << ")"); @@ -69,6 +83,8 @@ void on_widget_start_callback(int widgetId) } Catch (Exception) { LoggerE("WrtAccess initialization failed"); } + + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, calendarAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) @@ -81,6 +97,8 @@ void on_widget_stop_callback(int widgetId) } Catch (Exception) { LoggerE("WrtAccess deinitialization failed"); } + + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } void on_frame_load_callback(const void * context) diff --git a/src/Callhistory/CMakeLists.txt b/src/Callhistory/CMakeLists.txt index aa894d4..7172ede 100755 --- a/src/Callhistory/CMakeLists.txt +++ b/src/Callhistory/CMakeLists.txt @@ -5,6 +5,8 @@ SET(TARGET_IMPL_NAME ${callhistory_impl}) IF(ENABLE_OPTIONAL_CALL_HISTORY) PKG_CHECK_MODULES(platform_pkgs_callhistory REQUIRED contacts-service2 glib-2.0 libpcrecpp) +ADD_DEFINITIONS("-fvisibility=hidden") + INCLUDE_DIRECTORIES( ${INCLUDE_COMMON} ${TOP}/Tizen diff --git a/src/Callhistory/CallHistoryAsyncCallbackManager.cpp b/src/Callhistory/CallHistoryAsyncCallbackManager.cpp index 01cb59b..fbd5eff 100755 --- a/src/Callhistory/CallHistoryAsyncCallbackManager.cpp +++ b/src/Callhistory/CallHistoryAsyncCallbackManager.cpp @@ -16,14 +16,11 @@ // #include "CallHistoryAsyncCallbackManager.h" -#include - - - -IMPLEMENT_SINGLETON(DeviceAPI::CallHistory::CallHistoryAsyncCallbackManager) namespace DeviceAPI { namespace CallHistory { +SINGLETON_IMPLEMENTATION(CallHistoryAsyncCallbackManager) + } // Tizen1_0 } // TizenApis diff --git a/src/Callhistory/CallHistoryAsyncCallbackManager.h b/src/Callhistory/CallHistoryAsyncCallbackManager.h index dca7c9c..b950335 100755 --- a/src/Callhistory/CallHistoryAsyncCallbackManager.h +++ b/src/Callhistory/CallHistoryAsyncCallbackManager.h @@ -18,7 +18,6 @@ #ifndef _TIZEN_CALLHISTORY_ASYNC_CALLBACK_MANAGER_H_ #define _TIZEN_CALLHISTORY_ASYNC_CALLBACK_MANAGER_H_ -#include #include namespace DeviceAPI { @@ -38,7 +37,7 @@ public: friend class DPL::Singleton; }; -typedef DPL::Singleton CallHistoryAsyncCallbackManagerSingleton; +SINGLETON_DEFINITION(CallHistoryAsyncCallbackManager) } // Tizen1_0 } // TizenApis diff --git a/src/Callhistory/CallHistoryListenerManager.cpp b/src/Callhistory/CallHistoryListenerManager.cpp index 437fbde..9283ac9 100755 --- a/src/Callhistory/CallHistoryListenerManager.cpp +++ b/src/Callhistory/CallHistoryListenerManager.cpp @@ -16,14 +16,11 @@ // #include "CallHistoryListenerManager.h" -#include - - - -IMPLEMENT_SINGLETON(DeviceAPI::CallHistory::CallHistoryListenerManager) namespace DeviceAPI { namespace CallHistory { +SINGLETON_IMPLEMENTATION(CallHistoryListenerManager) + } // Tizen1_0 } // TizenApis diff --git a/src/Callhistory/CallHistoryListenerManager.h b/src/Callhistory/CallHistoryListenerManager.h index bf756af..357a335 100644 --- a/src/Callhistory/CallHistoryListenerManager.h +++ b/src/Callhistory/CallHistoryListenerManager.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "JSCallHistory.h" #include @@ -40,7 +39,7 @@ public: { } }; -typedef DPL::Singleton CallHistoryListenerManagerSingleton; +SINGLETON_DEFINITION(CallHistoryListenerManager) class CallHistoryListenerCanceller : public DeviceAPI::Common::IListenerItem { diff --git a/src/Callhistory/JSCallHistory.cpp b/src/Callhistory/JSCallHistory.cpp index ee4a63c..05274f5 100755 --- a/src/Callhistory/JSCallHistory.cpp +++ b/src/Callhistory/JSCallHistory.cpp @@ -40,7 +40,7 @@ #include "CallHistoryMultiCallback.h" #include "ResponseDispatcher.h" #include "Converter.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "CallHistoryAsyncCallbackManager.h" #include "CallHistoryListenerManager.h" #include "CallHistoryFilterConverter.h" @@ -95,7 +95,7 @@ JSStaticFunction JSCallHistory::m_function[] = { 0, 0, 0 } }; -const JSClassRef JSCallHistory::getClassRef() { +const JSClassRef DLL_EXPORT JSCallHistory::getClassRef() { if (!m_jsClassRef) { m_jsClassRef = JSClassCreate(&m_classInfo); } @@ -142,14 +142,6 @@ bool JSCallHistory::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( - CALL_HISTORY_FUNCTION_API_FIND); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - if (argumentCount < 1) { - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); - } JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); @@ -157,6 +149,12 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); } + TIZEN_CHECK_ACCESS(context, exception, priv, CALL_HISTORY_FUNCTION_API_FIND); + + if (argumentCount < 1) { + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + JSContextRef gContext = priv->getContext(); WrtDeviceApis::CommonsJavaScript::Converter converter(context); Validator check(context, exception); @@ -256,26 +254,24 @@ JSValueRef JSCallHistory::remove(JSContextRef context, JSObjectRef object, JSObj const JSValueRef arguments[], JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( - CALL_HISTORY_FUNCTION_API_REMOVE); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); try{ ArgumentValidator validator(context, argumentCount, arguments); - JSObjectRef entryObj = validator.toObject(0); - - if (argumentCount < 1) { - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); - } - JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); if (!priv) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); } + TIZEN_CHECK_ACCESS(context, exception, priv, CALL_HISTORY_FUNCTION_API_REMOVE); + + JSObjectRef entryObj = validator.toObject(0); + + if (argumentCount < 1) { + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + Converter converter(context); if (!JSValueIsObjectOfClass(context, arguments[0], JSCallHistoryEntry::getClassRef())) { @@ -307,14 +303,6 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object, const JSValueRef arguments[], JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( - CALL_HISTORY_FUNCTION_API_REMOVE_BATCH); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - if (argumentCount < 1) { - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); - } JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); @@ -322,6 +310,12 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); } + TIZEN_CHECK_ACCESS(context, exception, priv, CALL_HISTORY_FUNCTION_API_REMOVE_BATCH); + + if (argumentCount < 1) { + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + JSContextRef gContext = priv->getContext(); Converter converter(context); @@ -384,10 +378,6 @@ JSValueRef JSCallHistory::removeAll(JSContextRef context, JSObjectRef object, JS const JSValueRef arguments[], JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( - CALL_HISTORY_FUNCTION_API_REMOVE_ALL); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); @@ -395,6 +385,8 @@ JSValueRef JSCallHistory::removeAll(JSContextRef context, JSObjectRef object, JS return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); } + TIZEN_CHECK_ACCESS(context, exception, priv, CALL_HISTORY_FUNCTION_API_REMOVE_ALL); + JSContextRef gContext = priv->getContext(); Converter converter(context); @@ -438,26 +430,23 @@ JSValueRef JSCallHistory::removeAll(JSContextRef context, JSObjectRef object, JS JSValueRef JSCallHistory::addChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { - AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( - CALL_HISTORY_FUNCTION_API_ADDLISTENER); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - try{ ArgumentValidator validator(context, argumentCount, arguments); JSObjectRef observerObj = validator.toCallbackObject(0, false,"onadded","onchanged","onremoved",NULL); - if (argumentCount < 1) { - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); - } - JSCallHistoryPriv *priv = static_cast (JSObjectGetPrivate(thisObject)); if (!priv) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); } + TIZEN_CHECK_ACCESS(context, exception, priv, CALL_HISTORY_FUNCTION_API_ADDLISTENER); + + if (argumentCount < 1) { + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); + } + JSContextRef gContext = priv->getContext(); Converter converter(context); @@ -494,10 +483,6 @@ JSValueRef JSCallHistory::addChangeListener(JSContextRef context, JSObjectRef ob JSValueRef JSCallHistory::removeChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { - AceSecurityStatus status = CALLHISTORY_CHECK_ACCESS( - CALL_HISTORY_FUNCTION_API_REMOVELISTENER); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); long handle = 0; try{ @@ -511,6 +496,8 @@ JSValueRef JSCallHistory::removeChangeListener(JSContextRef context, JSObjectRef return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer"); } + TIZEN_CHECK_ACCESS(context, exception, priv, CALL_HISTORY_FUNCTION_API_REMOVELISTENER); + JSContextRef gContext = priv->getContext(); if (handle != 0) { diff --git a/src/Callhistory/JSCallHistory.h b/src/Callhistory/JSCallHistory.h index 540a36b..072fc3a 100755 --- a/src/Callhistory/JSCallHistory.h +++ b/src/Callhistory/JSCallHistory.h @@ -21,12 +21,32 @@ #include #include +#include #include "ICallHistory.h" +using namespace WrtDeviceApis::Commons; +using namespace WrtDeviceApis::CommonsJavaScript; + namespace DeviceAPI { namespace CallHistory { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSCallHistoryPriv; +typedef PrivateObject JSCallHistoryPrivObject; + +class JSCallHistoryPriv : + public JSCallHistoryPrivObject, + public DeviceAPI::Common::SecurityAccessor +{ +public: + JSCallHistoryPriv(JSContextRef context, ICallHistoryPtr callHistory) : + JSCallHistoryPrivObject(context, callHistory), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~JSCallHistoryPriv() + { + } +}; class JSCallHistory { diff --git a/src/Callhistory/JSCallHistoryEntry.cpp b/src/Callhistory/JSCallHistoryEntry.cpp index 535f107..42a7a23 100755 --- a/src/Callhistory/JSCallHistoryEntry.cpp +++ b/src/Callhistory/JSCallHistoryEntry.cpp @@ -69,7 +69,7 @@ JSStaticValue JSCallHistoryEntry::m_property[] = { { 0, 0, 0, 0 } }; -const JSClassRef JSCallHistoryEntry::getClassRef() +const JSClassRef DLL_EXPORT JSCallHistoryEntry::getClassRef() { if (!m_jsClassRef) { m_jsClassRef = JSClassCreate(&m_classInfo); diff --git a/src/Callhistory/ResponseDispatcher.cpp b/src/Callhistory/ResponseDispatcher.cpp index c11a9c2..7bf70aa 100755 --- a/src/Callhistory/ResponseDispatcher.cpp +++ b/src/Callhistory/ResponseDispatcher.cpp @@ -21,7 +21,6 @@ #include #include #include -#include "JSCallHistory.h" #include "Converter.h" #include "CallHistoryAsyncCallbackManager.h" #include diff --git a/src/Callhistory/plugin_config.cpp b/src/Callhistory/plugin_config.cpp index 5f09245..53de37a 100755 --- a/src/Callhistory/plugin_config.cpp +++ b/src/Callhistory/plugin_config.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "plugin_config.h" #define CALL_HISTORY_FEATURE_API_READ "http://tizen.org/privilege/callhistory.read" #define CALL_HISTORY_FEATURE_API_WRITE "http://tizen.org/privilege/callhistory.write" @@ -32,24 +33,13 @@ namespace CallHistory { const char* CALL_HISTORY_DEVICE_CAP_READ = "callhistory.read"; const char* CALL_HISTORY_DEVICE_CAP_WRITE = "callhistory.write"; -const char* CALL_HISTORY_FUNCTION_API_FIND = "find"; -const char* CALL_HISTORY_FUNCTION_API_REMOVE = "remove"; -const char* CALL_HISTORY_FUNCTION_API_REMOVE_BATCH = "removeBatch"; -const char* CALL_HISTORY_FUNCTION_API_REMOVE_ALL = "removeAll"; -const char* CALL_HISTORY_FUNCTION_API_ADDLISTENER = "addListener"; -const char* CALL_HISTORY_FUNCTION_API_REMOVELISTENER = "removeListener"; - static WrtDeviceApis::Commons::FunctionMapping createCallHistoryFunctions(); static WrtDeviceApis::Commons::FunctionMapping CallHistoryFunctions = createCallHistoryFunctions(); -#pragma GCC visibility push(default) - DEFINE_FUNCTION_GETTER(CallHistory, CallHistoryFunctions); -#pragma GCC visibility pop - static WrtDeviceApis::Commons::FunctionMapping createCallHistoryFunctions() { using namespace WrtDeviceApis::Commons; diff --git a/src/Callhistory/plugin_config.h b/src/Callhistory/plugin_config.h index 327ce5d..cd206c0 100755 --- a/src/Callhistory/plugin_config.h +++ b/src/Callhistory/plugin_config.h @@ -20,25 +20,13 @@ #define _CALLHISTORY_PLUGIN_CONFIG_H_ #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace CallHistory { -extern const char* CALL_HISTORY_FUNCTION_API_FIND; -extern const char* CALL_HISTORY_FUNCTION_API_REMOVE; -extern const char* CALL_HISTORY_FUNCTION_API_REMOVE_BATCH; -extern const char* CALL_HISTORY_FUNCTION_API_REMOVE_ALL; -extern const char* CALL_HISTORY_FUNCTION_API_ADDLISTENER; -extern const char* CALL_HISTORY_FUNCTION_API_REMOVELISTENER; - DECLARE_FUNCTION_GETTER(CallHistory); -} -} - -namespace WrtDeviceApis { -namespace Commons { - #define CALLHISTORY_CHECK_ACCESS(functionName) \ WrtDeviceApis::Commons::aceCheckAccess >( \ diff --git a/src/Callhistory/plugin_config_impl.h b/src/Callhistory/plugin_config_impl.h new file mode 100755 index 0000000..ac3a3de --- /dev/null +++ b/src/Callhistory/plugin_config_impl.h @@ -0,0 +1,29 @@ +// +// 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. +// + + +#ifndef _CALLHISTORY_PLUGIN_CONFIG_IMPL_H_ +#define _CALLHISTORY_PLUGIN_CONFIG_IMPL_H_ + +#define CALL_HISTORY_FUNCTION_API_FIND "find" +#define CALL_HISTORY_FUNCTION_API_REMOVE "remove" +#define CALL_HISTORY_FUNCTION_API_REMOVE_BATCH "removeBatch" +#define CALL_HISTORY_FUNCTION_API_REMOVE_ALL "removeAll" +#define CALL_HISTORY_FUNCTION_API_ADDLISTENER "addListener" +#define CALL_HISTORY_FUNCTION_API_REMOVELISTENER "removeListener" + +#endif // _CALLHISTORY_PLUGIN_CONFIG_IMPL_H_ diff --git a/src/Callhistory/plugin_initializer.cpp b/src/Callhistory/plugin_initializer.cpp index 85d7500..0f9a7fd 100755 --- a/src/Callhistory/plugin_initializer.cpp +++ b/src/Callhistory/plugin_initializer.cpp @@ -19,6 +19,8 @@ #include #include #include +#include +#include "plugin_config.h" #include "JSCallHistory.h" #include "CallHistoryAsyncCallbackManager.h" #include "CallHistoryListenerManager.h" @@ -32,6 +34,28 @@ namespace CallHistory { using namespace WrtDeviceApis::Commons; using namespace WrtDeviceApis::CommonsJavaScript; +AceSecurityStatus callhistoryAceCheckAccessFunction(const char* functionName) +{ + return CALLHISTORY_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerCallhistorySetter, + JSCallHistoryPriv, + gSecurityAccessor); + +class_definition_options_t option = +{ + JS_CLASS, + NONE, + ALWAYS_NOTICE, + IGNORED, + AceCheckerCallhistorySetter, + NULL, + NULL +}; + void on_widget_start_callback(int widgetId) { LoggerD("[Tizen\\callhistory] on_widget_start_callback"); TIME_TRACER_INIT(); @@ -40,6 +64,7 @@ void on_widget_start_callback(int widgetId) { } catch(WrtDeviceApis::Commons::Exception) { LoggerE("WrtAccess initialization failed"); } + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, callhistoryAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) { @@ -51,6 +76,7 @@ void on_widget_stop_callback(int widgetId) { } catch(WrtDeviceApis::Commons::Exception) { LoggerE("WrtAccess deinitialization failed"); } + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } void on_frame_load_callback(const void * context) @@ -76,7 +102,7 @@ PLUGIN_CLASS_MAP_BEGIN WRT_JS_EXTENSION_OBJECT_TIZEN, CALLHISTORY, (js_class_template_getter)DeviceAPI::CallHistory::JSCallHistory::getClassRef, - NULL) + &option) PLUGIN_CLASS_MAP_END } // CallHistory diff --git a/src/Contact/AddressBookController.cpp b/src/Contact/AddressBookController.cpp index 0bde2fc..30ae6c4 100644 --- a/src/Contact/AddressBookController.cpp +++ b/src/Contact/AddressBookController.cpp @@ -44,6 +44,7 @@ AddressBookController::AddressBookController(JSContextRef context, AddressBookPt EventAddressBookRemoveBatchEventAnswerReceiver(ThreadEnum::NULL_THREAD), EventAddressBookFindEventAnswerReceiver(ThreadEnum::NULL_THREAD), EventAddressBookChangeListenerListener(ThreadEnum::NULL_THREAD), + DeviceAPI::Common::SecurityAccessor(), AddressBookPrivObject(context, addressBook) { LoggerD("AddressBookController constructed : " << this); diff --git a/src/Contact/AddressBookController.h b/src/Contact/AddressBookController.h index 7cbc8b7..75c5bc1 100755 --- a/src/Contact/AddressBookController.h +++ b/src/Contact/AddressBookController.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "IAddressBook.h" namespace DeviceAPI { @@ -51,6 +52,7 @@ class AddressBookController : public EventAddressBookRemoveBatchEventAnswerReceiver, public EventAddressBookFindEventAnswerReceiver, public EventAddressBookChangeListenerListener, + public DeviceAPI::Common::SecurityAccessor, public AddressBookPrivObject { public: diff --git a/src/Contact/CMakeLists.txt b/src/Contact/CMakeLists.txt index 5dc9cae..b4b8634 100755 --- a/src/Contact/CMakeLists.txt +++ b/src/Contact/CMakeLists.txt @@ -1,7 +1,6 @@ SET(TARGET_NAME ${contact_target}) SET(DESTINATION_NAME ${contact_dest}) SET(TARGET_IMPL_NAME ${contact_impl}) -SET(TARGET_CONFIG_NAME ${contact_config}) PKG_CHECK_MODULES(platform_pkgs_contact REQUIRED contacts-service2 libpcrecpp) @@ -80,17 +79,8 @@ TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} ${platform_pkgs_contact_LIBRARIES} ) -SET(SRCS_CONFIG - plugin_config.cpp -) - -ADD_LIBRARY(${TARGET_CONFIG_NAME} SHARED ${SRCS_CONFIG}) - -TARGET_LINK_LIBRARIES(${TARGET_CONFIG_NAME} - ${LIBS_COMMON} -) - SET(SRCS + plugin_config.cpp plugin_initializer.cpp ) @@ -98,10 +88,9 @@ ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_IMPL_NAME} - ${TARGET_CONFIG_NAME} ) -INSTALL(TARGETS ${TARGET_NAME} ${TARGET_CONFIG_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/contact diff --git a/src/Contact/ContactConverter.cpp b/src/Contact/ContactConverter.cpp index be05585..795c371 100755 --- a/src/Contact/ContactConverter.cpp +++ b/src/Contact/ContactConverter.cpp @@ -160,10 +160,11 @@ ContactConverter::~ContactConverter() { } -JSValueRef ContactConverter::toJSValueRef(const AddressBookPtr &arg) +JSValueRef ContactConverter::toJSValueRef(const AddressBookPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor) { // It may not used AddressBookController *priv = new AddressBookController(m_context, arg); + priv->copyAceCheckAccessFunction(securityAccessor); return JSObjectMake(m_context, JSAddressBook::getClassRef(), priv); } @@ -175,7 +176,7 @@ AddressBookPtr ContactConverter::toAddressBook(const JSValueRef &jsValue) return JSAddressBook::getAddressBook(m_context, jsValue); } -JSValueRef ContactConverter::toJSValueRef(const AddressBookArrayPtr &arg) +JSValueRef ContactConverter::toJSValueRef(const AddressBookArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor) { int size = arg->size(); @@ -185,7 +186,7 @@ JSValueRef ContactConverter::toJSValueRef(const AddressBookArrayPtr &arg) for(int i = 0; i < size; i++) { - JSValueRef jsvalue = toJSValueRef(arg->at(i)); + JSValueRef jsvalue = toJSValueRef(arg->at(i), securityAccessor); if (!JSSetArrayElement(m_context, resultObject, i, jsvalue)) ThrowMsg(ConversionException, "Can not fill address book array."); } @@ -483,9 +484,11 @@ ContactArrayPtr ContactConverter::toContactArray(const JSValueRef &jsValue) return result; } -JSValueRef ContactConverter::toJSValueRef(const PersonPtr &arg) +JSValueRef ContactConverter::toJSValueRef(const PersonPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor) { - return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSPerson::getClassRef(), arg); + JSPersonPriv *priv = new JSPersonPriv(m_context, arg); + priv->copyAceCheckAccessFunction(securityAccessor); + return JSObjectMake(m_context, JSPerson::getClassRef(), priv); } PersonPtr ContactConverter::toPerson(const JSValueRef &jsValue) @@ -499,7 +502,7 @@ PersonPtr ContactConverter::toPerson(const JSValueRef &jsValue) return JSPerson::getPerson(m_context, jsValue); } -JSValueRef ContactConverter::toJSValueRef(const PersonArrayPtr &arg) +JSValueRef ContactConverter::toJSValueRef(const PersonArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor) { int size = arg->size(); @@ -509,7 +512,7 @@ JSValueRef ContactConverter::toJSValueRef(const PersonArrayPtr &arg) for(int i = 0; i < size; i++) { - JSValueRef jsvalue = toJSValueRef(arg->at(i)); + JSValueRef jsvalue = toJSValueRef(arg->at(i), securityAccessor); if (!JSSetArrayElement(m_context, resultObject, i, jsvalue)) ThrowMsg(ConversionException, "Can not add object to array."); } diff --git a/src/Contact/ContactConverter.h b/src/Contact/ContactConverter.h index 2a9811e..2c94377 100755 --- a/src/Contact/ContactConverter.h +++ b/src/Contact/ContactConverter.h @@ -42,6 +42,7 @@ #include "ContactEmailAddress.h" #include #include +#include #include #include @@ -56,10 +57,10 @@ public: explicit ContactConverter(JSContextRef context); virtual ~ContactConverter(); - JSValueRef toJSValueRef(const AddressBookPtr &arg); + JSValueRef toJSValueRef(const AddressBookPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor); AddressBookPtr toAddressBook(const JSValueRef &jsValue); - JSValueRef toJSValueRef(const AddressBookArrayPtr &arg); + JSValueRef toJSValueRef(const AddressBookArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor); AddressBookArrayPtr toAddressBookArray(const JSValueRef &jsValue); JSValueRef toJSValueRef(const ContactPtr &arg); @@ -75,10 +76,10 @@ public: JSValueRef toJSValueRef(const ContactGroupArrayPtr &arg); ContactGroupArrayPtr toContactGroupArray(const JSValueRef &jsValue); - JSValueRef toJSValueRef(const PersonPtr &arg); + JSValueRef toJSValueRef(const PersonPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor); PersonPtr toPerson(const JSValueRef &jsValue); - JSValueRef toJSValueRef(const PersonArrayPtr &arg); + JSValueRef toJSValueRef(const PersonArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor); PersonArrayPtr toPersonArray(const JSValueRef &jsValue); JSValueRef toJSValueRef(const ContactRefPtr &arg); diff --git a/src/Contact/ContactManagerController.cpp b/src/Contact/ContactManagerController.cpp index 9589896..18dd887 100644 --- a/src/Contact/ContactManagerController.cpp +++ b/src/Contact/ContactManagerController.cpp @@ -44,6 +44,7 @@ ContactManagerController::ContactManagerController(JSContextRef context, Contact EventContactManagerRemoveBatchAnswerReceiver(ThreadEnum::NULL_THREAD), EventContactManagerFindAnswerReceiver(ThreadEnum::NULL_THREAD), EventContactManagerChangeListenerListener(ThreadEnum::NULL_THREAD), + SecurityAccessor(), ContactManagerPrivObject(context, contactManager) { LoggerD("ContactManagerController constructed : " << this); @@ -54,7 +55,7 @@ ContactManagerController::~ContactManagerController() LoggerD("ContactManagerController destructed : " << this); } -void ContactManagerAsyncAnswerHandler::getAddressBooks(const EventContactManagerGetAddressBooksPtr &event) +void ContactManagerAsyncAnswerHandler::getAddressBooks(const EventContactManagerGetAddressBooksPtr &event, SecurityAccessor *securityAccessor) { LoggerD("entered"); JSCallbackManagerPtr callbackManager = @@ -103,7 +104,7 @@ void ContactManagerAsyncAnswerHandler::getAddressBooks(const EventContactManager ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext); AddressBookArrayPtr addressBooks = event->getAddressBooks(); - JSValueRef result = converter->toJSValueRef(addressBooks); + JSValueRef result = converter->toJSValueRef(addressBooks, securityAccessor); callbackManager->callOnSuccess(result); return; @@ -224,7 +225,7 @@ void ContactManagerAsyncAnswerHandler::removeBatch(const EventContactManagerRemo callbackManager->callOnSuccess(); } -void ContactManagerAsyncAnswerHandler::find(const EventContactManagerFindPtr &event) +void ContactManagerAsyncAnswerHandler::find(const EventContactManagerFindPtr &event, SecurityAccessor *securityAccessor) { LoggerD("entered"); JSCallbackManagerPtr callbackManager = @@ -274,7 +275,7 @@ void ContactManagerAsyncAnswerHandler::find(const EventContactManagerFindPtr &ev ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext); PersonArrayPtr contacts = event->getPersons(); - JSValueRef result = converter->toJSValueRef(contacts); + JSValueRef result = converter->toJSValueRef(contacts, securityAccessor); callbackManager->callOnSuccess(result); return; @@ -309,7 +310,7 @@ void ContactManagerAsyncAnswerHandler::changeListenerError(const EventContactMan cbm->callOnError(errorObject); } -void ContactManagerAsyncAnswerHandler::changeListenerPersonAdded(const EventContactManagerChangeListenerPtr &event) +void ContactManagerAsyncAnswerHandler::changeListenerPersonAdded(const EventContactManagerChangeListenerPtr &event, SecurityAccessor *securityAccessor) { LoggerD("entered"); JSContactManagerChangeCallbackManagerPtr cbm = @@ -340,7 +341,7 @@ void ContactManagerAsyncAnswerHandler::changeListenerPersonAdded(const EventCont JSValueRef contacts; Try { - contacts = converter->toJSValueRef(eventInfo->getPersons()); + contacts = converter->toJSValueRef(eventInfo->getPersons(), securityAccessor); } Catch (Exception) { LoggerE("Conversion error"); return; @@ -349,7 +350,7 @@ void ContactManagerAsyncAnswerHandler::changeListenerPersonAdded(const EventCont cbm->callOnPersonsAdded(contacts); } -void ContactManagerAsyncAnswerHandler::changeListenerPersonUpdated(const EventContactManagerChangeListenerPtr &event) +void ContactManagerAsyncAnswerHandler::changeListenerPersonUpdated(const EventContactManagerChangeListenerPtr &event, SecurityAccessor *securityAccessor) { LoggerD("entered"); JSContactManagerChangeCallbackManagerPtr cbm = @@ -380,7 +381,7 @@ void ContactManagerAsyncAnswerHandler::changeListenerPersonUpdated(const EventCo JSValueRef contacts; Try { - contacts = converter->toJSValueRef(eventInfo->getPersons()); + contacts = converter->toJSValueRef(eventInfo->getPersons(), securityAccessor); } Catch (Exception) { LoggerE("Conversion error"); return; @@ -430,7 +431,7 @@ void ContactManagerAsyncAnswerHandler::changeListenerPersonRemoved(const EventCo void ContactManagerController::OnAnswerReceived(const EventContactManagerGetAddressBooksPtr &event) { - ContactManagerAsyncAnswerHandler::getAddressBooks(event); + ContactManagerAsyncAnswerHandler::getAddressBooks(event, this); } void ContactManagerController::OnAnswerReceived(const EventContactManagerUpdateBatchPtr &event) @@ -445,7 +446,7 @@ void ContactManagerController::OnAnswerReceived(const EventContactManagerRemoveB void ContactManagerController::OnAnswerReceived(const EventContactManagerFindPtr &event) { - ContactManagerAsyncAnswerHandler::find(event); + ContactManagerAsyncAnswerHandler::find(event, this); } void ContactManagerController::onAnswerReceived(const EventContactManagerChangeListenerPtr &event) @@ -459,9 +460,9 @@ void ContactManagerController::onAnswerReceived(const EventContactManagerChangeL EventInfoContactManagerChange::CallbackType type = eventInfo->getCallbackType(); if(type == EventInfoContactManagerChange::OnPersonsAdded) - ContactManagerAsyncAnswerHandler::changeListenerPersonAdded(event); + ContactManagerAsyncAnswerHandler::changeListenerPersonAdded(event, this); else if(type == EventInfoContactManagerChange::OnPersonsUpdated) - ContactManagerAsyncAnswerHandler::changeListenerPersonUpdated(event); + ContactManagerAsyncAnswerHandler::changeListenerPersonUpdated(event, this); else if(type == EventInfoContactManagerChange::OnPersonsRemoved) ContactManagerAsyncAnswerHandler::changeListenerPersonRemoved(event); else if(type == EventInfoContactManagerChange::OnError) diff --git a/src/Contact/ContactManagerController.h b/src/Contact/ContactManagerController.h index 0b9e9d4..e9b7fbf 100755 --- a/src/Contact/ContactManagerController.h +++ b/src/Contact/ContactManagerController.h @@ -28,6 +28,7 @@ #include #include #include +#include #include "IContactManager.h" namespace DeviceAPI { @@ -48,6 +49,7 @@ class ContactManagerController : public EventContactManagerRemoveBatchAnswerReceiver, public EventContactManagerFindAnswerReceiver, public EventContactManagerChangeListenerListener, + public DeviceAPI::Common::SecurityAccessor, public ContactManagerPrivObject { private: @@ -72,13 +74,13 @@ typedef DPL::SharedPtr ContactManagerControllerPtr; class ContactManagerAsyncAnswerHandler { public: - static void getAddressBooks(const EventContactManagerGetAddressBooksPtr &event); + static void getAddressBooks(const EventContactManagerGetAddressBooksPtr &event, DeviceAPI::Common::SecurityAccessor *securityAccessor); static void updateBatch(const EventContactManagerUpdateBatchPtr &event); static void removeBatch(const EventContactManagerRemoveBatchPtr &event); - static void find(const EventContactManagerFindPtr &event); + static void find(const EventContactManagerFindPtr &event, DeviceAPI::Common::SecurityAccessor *securityAccessor); static void changeListenerError(const EventContactManagerChangeListenerPtr &event); - static void changeListenerPersonAdded(const EventContactManagerChangeListenerPtr &event); - static void changeListenerPersonUpdated(const EventContactManagerChangeListenerPtr &event); + static void changeListenerPersonAdded(const EventContactManagerChangeListenerPtr &event, DeviceAPI::Common::SecurityAccessor *securityAccessor); + static void changeListenerPersonUpdated(const EventContactManagerChangeListenerPtr &event, DeviceAPI::Common::SecurityAccessor *securityAccessor); static void changeListenerPersonRemoved(const EventContactManagerChangeListenerPtr &event); }; diff --git a/src/Contact/JSAddressBook.cpp b/src/Contact/JSAddressBook.cpp index e6bd7ed..3fac6f4 100755 --- a/src/Contact/JSAddressBook.cpp +++ b/src/Contact/JSAddressBook.cpp @@ -36,7 +36,7 @@ #include "EventAddressBookFind.h" #include "EventAddressBookChangeListener.h" #include "EventAddressBookRemoveBatch.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "JSAddressBook.h" #include "JSContact.h" #include "JSContactGroup.h" @@ -50,6 +50,7 @@ #include #include #include +#include #include #include "ContactUtility.h" @@ -291,8 +292,7 @@ JSValueRef JSAddressBook::get(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_GET); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_GET); string id; @@ -384,8 +384,7 @@ JSValueRef JSAddressBook::add(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -472,8 +471,7 @@ JSValueRef JSAddressBook::addBatch(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_BATCH); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_BATCH); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -562,8 +560,7 @@ JSValueRef JSAddressBook::update(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -654,8 +651,7 @@ JSValueRef JSAddressBook::updateBatch(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_BATCH); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_BATCH); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -743,8 +739,7 @@ JSValueRef JSAddressBook::remove(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE); ArgumentValidator validator(context, argumentCount, arguments); string contactId; @@ -825,8 +820,7 @@ JSValueRef JSAddressBook::removeBatch(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_BATCH); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_BATCH); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -919,8 +913,7 @@ JSValueRef JSAddressBook::find(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_FIND); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_FIND); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -1031,8 +1024,7 @@ JSValueRef JSAddressBook::addChangeListener(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_CHANGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_CHANGE_LISTENER); BasicValidator validator = BasicValidatorFactory::getValidator(context, exception); try { @@ -1170,8 +1162,7 @@ JSValueRef JSAddressBook::removeChangeListener(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER); long watchId = 0; string id; @@ -1251,8 +1242,7 @@ JSValueRef JSAddressBook::getGroup(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUP); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUP); string id; @@ -1349,8 +1339,7 @@ JSValueRef JSAddressBook::addGroup(JSContextRef context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_GROUP); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_GROUP); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -1436,8 +1425,7 @@ JSValueRef JSAddressBook::updateGroup(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_GROUP); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_GROUP); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -1527,8 +1515,7 @@ JSValueRef JSAddressBook::removeGroup(JSContextRef context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_GROUP); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_GROUP); string groupId; @@ -1612,8 +1599,7 @@ JSValueRef JSAddressBook::getGroups(JSContextRef context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUPS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUPS); string id; diff --git a/src/Contact/JSContact.cpp b/src/Contact/JSContact.cpp index 92616f5..07baef3 100755 --- a/src/Contact/JSContact.cpp +++ b/src/Contact/JSContact.cpp @@ -26,7 +26,6 @@ #include #include #include "ContactFactory.h" -#include "plugin_config.h" #include "ContactConverter.h" #include "JSContact.h" #include "Contact.h" diff --git a/src/Contact/JSContactManager.cpp b/src/Contact/JSContactManager.cpp index 601d06d..3961ae6 100755 --- a/src/Contact/JSContactManager.cpp +++ b/src/Contact/JSContactManager.cpp @@ -34,7 +34,7 @@ #include #include "ContactFactory.h" #include "ContactTypes.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "ContactManagerController.h" #include "ContactAsyncCallbackManager.h" #include "ContactListenerManager.h" @@ -158,8 +158,7 @@ JSValueRef JSContactManager::getAddressBooks(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOKS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOKS); BasicValidator validator = BasicValidatorFactory::getValidator(context, exception); try { @@ -225,8 +224,7 @@ JSValueRef JSContactManager::getDefaultAddressBook(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_DEFAULT_ADDRESS_BOOK); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, priv, CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_DEFAULT_ADDRESS_BOOK); ContactManagerPtr contactManager; JSContextRef gContext; @@ -275,7 +273,7 @@ JSValueRef JSContactManager::getDefaultAddressBook(JSContextRef context, JSValueRef resultValue; Try { - resultValue = converter->toJSValueRef(defaultAddressBook); + resultValue = converter->toJSValueRef(defaultAddressBook, priv); } Catch(Exception){ LoggerE("Conversion error."); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error"); @@ -301,8 +299,7 @@ JSValueRef JSContactManager::getUnifiedAddressBook(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_UNIFIED_ADDRESS_BOOK); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, priv, CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_UNIFIED_ADDRESS_BOOK); ContactManagerPtr contactManager; JSContextRef gContext; @@ -351,7 +348,7 @@ JSValueRef JSContactManager::getUnifiedAddressBook(JSContextRef context, JSValueRef resultValue; Try { - resultValue = converter->toJSValueRef(unifiedAddressBook); + resultValue = converter->toJSValueRef(unifiedAddressBook, priv); } Catch(Exception){ LoggerE("Conversion error."); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error"); @@ -377,8 +374,7 @@ JSValueRef JSContactManager::getAddressBook(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOK); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, priv, CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOK); ContactManagerPtr contactManager; JSContextRef gContext; @@ -442,7 +438,7 @@ JSValueRef JSContactManager::getAddressBook(JSContextRef context, JSValueRef resultValue; Try { - resultValue = converter->toJSValueRef(addressBook); + resultValue = converter->toJSValueRef(addressBook, priv); } Catch(Exception){ LoggerE("Conversion error."); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error"); @@ -475,8 +471,7 @@ JSValueRef JSContactManager::get(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_GET); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_GET); std::string id; @@ -533,7 +528,7 @@ JSValueRef JSContactManager::get(JSContextRef context, JSValueRef result; Try { - result = converter->toJSValueRef(person); + result = converter->toJSValueRef(person, controller); } Catch(Exception) { LoggerE("Error on conversion : " << _rethrown_exception.GetMessage()); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error"); @@ -566,8 +561,7 @@ JSValueRef JSContactManager::update(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -658,8 +652,7 @@ JSValueRef JSContactManager::updateBatch(JSContextRef context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE_BATCH); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE_BATCH); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -747,8 +740,7 @@ JSValueRef JSContactManager::remove(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE); std::string personId; @@ -836,8 +828,7 @@ JSValueRef JSContactManager::removeBatch(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_BATCH); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_BATCH); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -929,8 +920,7 @@ JSValueRef JSContactManager::find(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_FIND); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_FIND); try { ArgumentValidator validator(context, argumentCount, arguments); @@ -1041,8 +1031,7 @@ JSValueRef JSContactManager::addChangeListener(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_ADD_CHANGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_ADD_CHANGE_LISTENER); BasicValidator validator = BasicValidatorFactory::getValidator(context, exception); try { @@ -1181,8 +1170,7 @@ JSValueRef JSContactManager::removeChangeListener(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_CHANGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, controller, CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_CHANGE_LISTENER); ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context); diff --git a/src/Contact/JSPerson.cpp b/src/Contact/JSPerson.cpp index 33ea99f..3b88f36 100755 --- a/src/Contact/JSPerson.cpp +++ b/src/Contact/JSPerson.cpp @@ -26,7 +26,7 @@ #include #include #include "ContactFactory.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "ContactConverter.h" #include "JSPerson.h" #include @@ -485,11 +485,16 @@ JSValueRef JSPerson::link(JSContextRef context, { LoggerD("entered"); TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); + JSPersonPriv *priv = NULL; PersonPtr person(NULL); Try { - person = getPrivData(thisObject); + priv = static_cast(JSObjectGetPrivate(thisObject)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + person = priv->getObject(); if (person == NULL) ThrowMsg(InvalidArgumentException, "No private object."); } @@ -500,8 +505,7 @@ JSValueRef JSPerson::link(JSContextRef context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_PERSON_LINK); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, priv, CONTACT_FUNCTION_API_PERSON_LINK); ArgumentValidator validator(context, argumentCount, arguments); std::string personId; @@ -577,11 +581,16 @@ JSValueRef JSPerson::unlink(JSContextRef context, { LoggerD("entered"); TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); + JSPersonPriv *priv = NULL; PersonPtr person(NULL); Try { - person = getPrivData(thisObject); + priv = static_cast(JSObjectGetPrivate(thisObject)); + if (!priv) { + ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null"); + } + person = priv->getObject(); if (person == NULL) ThrowMsg(InvalidArgumentException, "No private object."); } @@ -592,8 +601,7 @@ JSValueRef JSPerson::unlink(JSContextRef context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); } - AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_PERSON_UNLINK); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, priv, CONTACT_FUNCTION_API_PERSON_UNLINK); ArgumentValidator validator(context, argumentCount, arguments); std::string contactId; @@ -668,7 +676,7 @@ JSValueRef JSPerson::unlink(JSContextRef context, JSValueRef result; Try { - result = converter->toJSValueRef(unlinkedPerson); + result = converter->toJSValueRef(unlinkedPerson, priv); } Catch(Exception) { diff --git a/src/Contact/JSPerson.h b/src/Contact/JSPerson.h index 68e7fd6..109f1d6 100755 --- a/src/Contact/JSPerson.h +++ b/src/Contact/JSPerson.h @@ -29,12 +29,29 @@ #include #include #include +#include #include "IPerson.h" namespace DeviceAPI { namespace Contact { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSPersonPriv; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject JSPersonPrivObject; + +class JSPersonPriv : + public DeviceAPI::Common::SecurityAccessor, + public JSPersonPrivObject +{ +public: + JSPersonPriv(JSContextRef context, PersonPtr person) : + DeviceAPI::Common::SecurityAccessor(), + JSPersonPrivObject(context, person) + { + } + + virtual ~JSPersonPriv() + { + } +}; class JSPerson { public: diff --git a/src/Contact/plugin_config.cpp b/src/Contact/plugin_config.cpp index c2aaeac..83b46a6 100755 --- a/src/Contact/plugin_config.cpp +++ b/src/Contact/plugin_config.cpp @@ -41,12 +41,8 @@ static FunctionMapping createContactFunctions(); static FunctionMapping ContactFunctions = createContactFunctions(); -#pragma GCC visibility push(default) - DEFINE_FUNCTION_GETTER(Contact, ContactFunctions); -#pragma GCC visibility pop - static FunctionMapping createContactFunctions() { /** diff --git a/src/Contact/plugin_config.h b/src/Contact/plugin_config.h index f0c729e..59717bb 100755 --- a/src/Contact/plugin_config.h +++ b/src/Contact/plugin_config.h @@ -21,40 +21,11 @@ #include #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace Contact { -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOKS "ContactManager.getAddressBooks" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_DEFAULT_ADDRESS_BOOK "ContactManager.getDefaultAddressBook" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_UNIFIED_ADDRESS_BOOK "ContactManager.getUnifiedAddressBook" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOK "ContactManager.getAddressBook" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET "ContactManager.get" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE "ContactManager.update" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE_BATCH "ContactManager.updateBatch" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE "ContactManager.remove" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_BATCH "ContactManager.removeBatch" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_FIND "ContactManager.find" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_ADD_CHANGE_LISTENER "ContactManager.addChangeListener" -#define CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_CHANGE_LISTENER "ContactManager.removeChangeListener" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_GET "AddressBook.get" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD "AddressBook.add" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_BATCH "AddressBook.addBatch" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE "AddressBook.update" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_BATCH "AddressBook.updateBatch" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE "AddressBook.remove" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_BATCH "AddressBook.removeBatch" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_FIND "AddressBook.find" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_CHANGE_LISTENER "AddressBook.addChangeListener" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER "AddressBook.removeChangeListener" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUP "AddressBook.getGroup" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_GROUP "AddressBook.addGroup" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_GROUP "AddressBook.updateGroup" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_GROUP "AddressBook.removeGroup" -#define CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUPS "AddressBook.getGroups" -#define CONTACT_FUNCTION_API_PERSON_LINK "AddressBook.link" -#define CONTACT_FUNCTION_API_PERSON_UNLINK "AddressBook.unlink" - DECLARE_FUNCTION_GETTER(Contact); #define CONTACT_CHECK_ACCESS(functionName) \ diff --git a/src/Contact/plugin_config_impl.h b/src/Contact/plugin_config_impl.h new file mode 100755 index 0000000..e86c262 --- /dev/null +++ b/src/Contact/plugin_config_impl.h @@ -0,0 +1,52 @@ +// +// 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. +// + + +#ifndef _CONTACT_PLUGIN_CONFIG_IMPL_H_ +#define _CONTACT_PLUGIN_CONFIG_IMPL_H_ + +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOKS "ContactManager.getAddressBooks" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_DEFAULT_ADDRESS_BOOK "ContactManager.getDefaultAddressBook" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_UNIFIED_ADDRESS_BOOK "ContactManager.getUnifiedAddressBook" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET_ADDRESS_BOOK "ContactManager.getAddressBook" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_GET "ContactManager.get" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE "ContactManager.update" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_UPDATE_BATCH "ContactManager.updateBatch" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE "ContactManager.remove" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_BATCH "ContactManager.removeBatch" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_FIND "ContactManager.find" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_ADD_CHANGE_LISTENER "ContactManager.addChangeListener" +#define CONTACT_FUNCTION_API_CONTACT_MANAGER_REMOVE_CHANGE_LISTENER "ContactManager.removeChangeListener" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_GET "AddressBook.get" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD "AddressBook.add" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_BATCH "AddressBook.addBatch" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE "AddressBook.update" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_BATCH "AddressBook.updateBatch" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE "AddressBook.remove" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_BATCH "AddressBook.removeBatch" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_FIND "AddressBook.find" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_CHANGE_LISTENER "AddressBook.addChangeListener" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER "AddressBook.removeChangeListener" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUP "AddressBook.getGroup" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_ADD_GROUP "AddressBook.addGroup" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_UPDATE_GROUP "AddressBook.updateGroup" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_REMOVE_GROUP "AddressBook.removeGroup" +#define CONTACT_FUNCTION_API_ADDRESS_BOOK_GET_GROUPS "AddressBook.getGroups" +#define CONTACT_FUNCTION_API_PERSON_LINK "AddressBook.link" +#define CONTACT_FUNCTION_API_PERSON_UNLINK "AddressBook.unlink" + +#endif // _CONTACT_PLUGIN_CONFIG_IMPL_H_ diff --git a/src/Contact/plugin_initializer.cpp b/src/Contact/plugin_initializer.cpp index f1b519e..31c9b12 100644 --- a/src/Contact/plugin_initializer.cpp +++ b/src/Contact/plugin_initializer.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "JSContactManager.h" #include "JSContact.h" #include "JSContactGroup.h" @@ -38,6 +39,7 @@ #include "JSContactEmailAddress.h" #include "ContactAsyncCallbackManager.h" #include "ContactListenerManager.h" +#include "plugin_config.h" #include namespace DeviceAPI { @@ -46,6 +48,26 @@ namespace Contact { using namespace WrtDeviceApis; using namespace WrtDeviceApis::Commons; +AceSecurityStatus contactAceCheckAccessFunction(const char* functionName) +{ + return CONTACT_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerContactSetter, ContactManagerController, gSecurityAccessor); + +class_definition_options_t option = +{ + JS_CLASS, + NONE, + ALWAYS_NOTICE, + IGNORED, + AceCheckerContactSetter, + NULL, + NULL +}; + void on_widget_start_callback(int widgetId) { LoggerD("[Tizen\\contact] on_widget_start_callback (" << widgetId << ")"); @@ -58,6 +80,8 @@ void on_widget_start_callback(int widgetId) { LoggerE("WrtAccess initialization failed"); } + + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, contactAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) @@ -73,6 +97,8 @@ void on_widget_stop_callback(int widgetId) { LoggerE("WrtAccess deinitialization failed"); } + + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } void on_frame_load_callback(const void * context) @@ -97,7 +123,7 @@ PLUGIN_CLASS_MAP_BEGIN PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "contact", (js_class_template_getter)DeviceAPI::Contact::JSContactManager::getClassRef, - NULL) + &option) PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "Contact", (js_class_template_getter)DeviceAPI::Contact::JSContact::getClassRef, diff --git a/src/Content/JSContentManager.cpp b/src/Content/JSContentManager.cpp index a5d864b..a52042e 100755 --- a/src/Content/JSContentManager.cpp +++ b/src/Content/JSContentManager.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "JSUtil.h" #include "ContentFactory.h" @@ -43,7 +44,7 @@ #include "JSVideo.h" #include "JSAudio.h" #include "ContentConverter.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "ContentAsyncCallbackManager.h" #include "ContentListener.h" #include "ContentVideo.h" @@ -113,8 +114,8 @@ JSValueRef JSMediacontentManager::getFolders( { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - MediacontentManagerPrivObject *privateObject; - privateObject = static_cast(JSObjectGetPrivate(thisObject)); + MediacontentManagerPriv *privateObject; + privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { DeviceAPI::Common::UnknownException err("Content's private object is NULL."); return JSWebAPIErrorFactory::postException(context, exception, err); @@ -203,16 +204,14 @@ JSValueRef JSMediacontentManager::findItems( TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - MediacontentManagerPrivObject *privateObject; - privateObject = static_cast(JSObjectGetPrivate(thisObject)); + MediacontentManagerPriv *privateObject; + privateObject = static_cast(JSObjectGetPrivate(thisObject)); if(!privateObject) { DeviceAPI::Common::UnknownException err("Content's private object is NULL."); return JSWebAPIErrorFactory::postException(context, exception, err); } - AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_FIND_ITEMS); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_FIND_ITEMS); JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context); @@ -344,16 +343,15 @@ JSValueRef JSMediacontentManager::updateItemsBatch(JSContextRef context, JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - MediacontentManagerPrivObject *privateObject; - privateObject = static_cast(JSObjectGetPrivate(thisObject)); + MediacontentManagerPriv *privateObject; + privateObject = static_cast(JSObjectGetPrivate(thisObject)); if(!privateObject) { DeviceAPI::Common::UnknownException err("Content's private object is NULL."); return JSWebAPIErrorFactory::postException(context, exception, err); } JSContextRef globalContext = GlobalContextManager::getInstance()->getGlobalContext(context); - AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH); JSCallbackManagerPtr cbm(NULL); MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context); @@ -448,15 +446,14 @@ JSValueRef JSMediacontentManager::updateItem( TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - MediacontentManagerPrivObject *privateObject; - privateObject = static_cast(JSObjectGetPrivate(thisObject)); + MediacontentManagerPriv *privateObject; + privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { DeviceAPI::Common::UnknownException err("Content's private object is NULL."); return JSWebAPIErrorFactory::postException(context, exception, err); } - AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_UPDATE_ITEM); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_UPDATE_ITEM); Try { @@ -599,15 +596,14 @@ JSValueRef JSMediacontentManager::scanFile( { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - MediacontentManagerPrivObject *privateObject; - privateObject = static_cast(JSObjectGetPrivate(thisObject)); + MediacontentManagerPriv *privateObject; + privateObject = static_cast(JSObjectGetPrivate(thisObject)); if(!privateObject) { DeviceAPI::Common::UnknownException err("Content's private object is NULL."); return JSWebAPIErrorFactory::postException(context, exception, err); } - AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_SCAN_FILE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_SCAN_FILE); string path; CallbackUserData *callback = NULL; @@ -686,15 +682,14 @@ JSValueRef JSMediacontentManager::setChangeListener( { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - MediacontentManagerPrivObject *privateObject; - privateObject = static_cast(JSObjectGetPrivate(thisObject)); + MediacontentManagerPriv *privateObject; + privateObject = static_cast(JSObjectGetPrivate(thisObject)); if(!privateObject) { DeviceAPI::Common::UnknownException err("Content's private object is NULL."); return JSWebAPIErrorFactory::postException(context, exception, err); } - AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_SET_CHANGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_SET_CHANGE_LISTENER); try{ ArgumentValidator argValidator(context, argumentCount, arguments); @@ -727,15 +722,14 @@ JSValueRef JSMediacontentManager::unsetChangeListener( JSValueRef* exception) { TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - MediacontentManagerPrivObject *privateObject; - privateObject = static_cast(JSObjectGetPrivate(thisObject)); + MediacontentManagerPriv *privateObject; + privateObject = static_cast(JSObjectGetPrivate(thisObject)); if(!privateObject) { DeviceAPI::Common::UnknownException err("Content's private object is NULL."); return JSWebAPIErrorFactory::postException(context, exception, err); } - AceSecurityStatus status = CONTENT_CHECK_ACCESS(CONTENT_FUNCTION_API_SET_CHANGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, CONTENT_FUNCTION_API_SET_CHANGE_LISTENER); try{ // perform @@ -771,11 +765,11 @@ const JSClassDefinition* JSMediacontentManager::getClassInfo() void JSMediacontentManager::initialize(JSContextRef context, JSObjectRef object) { - MediacontentManagerPrivObject *privateObject = static_cast(JSObjectGetPrivate(object)); + MediacontentManagerPriv *privateObject = static_cast(JSObjectGetPrivate(object)); if (NULL == privateObject) { IMediacontentManagerPtr contentManager = MediacontentFactory::getInstance().createMediacontentManagerObject(); - privateObject = new MediacontentManagerPrivObject(context, contentManager); + privateObject = new MediacontentManagerPriv(context, contentManager); if (!JSObjectSetPrivate(object, static_cast(privateObject))) { delete privateObject; @@ -786,7 +780,7 @@ void JSMediacontentManager::initialize(JSContextRef context, JSObjectRef object) void JSMediacontentManager::finalize(JSObjectRef object) { - MediacontentManagerPrivObject* priv = static_cast (JSObjectGetPrivate(object)); + MediacontentManagerPriv* priv = static_cast (JSObjectGetPrivate(object)); if(priv != NULL) { delete priv; @@ -801,7 +795,7 @@ IMediacontentManagerPtr JSMediacontentManager::getContentManagerPrivObject( const JSObjectRef object, JSValueRef* exception) { - MediacontentManagerPrivObject *priv = static_cast(JSObjectGetPrivate(object)); + MediacontentManagerPriv *priv = static_cast(JSObjectGetPrivate(object)); if (priv) { return priv->getObject(); diff --git a/src/Content/JSContentManager.h b/src/Content/JSContentManager.h index 73599a8..c7f118f 100755 --- a/src/Content/JSContentManager.h +++ b/src/Content/JSContentManager.h @@ -33,6 +33,22 @@ namespace Content { typedef PrivateObject MediacontentManagerPrivObject; +class MediacontentManagerPriv : + public MediacontentManagerPrivObject, + public DeviceAPI::Common::SecurityAccessor +{ +public: + MediacontentManagerPriv(JSContextRef context, IMediacontentManagerPtr contentManager) : + MediacontentManagerPrivObject(context, contentManager), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~MediacontentManagerPriv() + { + } +}; + class JSMediacontentManager { public: diff --git a/src/Content/plugin_config.h b/src/Content/plugin_config.h index 6eb9188..f08bd6e 100755 --- a/src/Content/plugin_config.h +++ b/src/Content/plugin_config.h @@ -21,23 +21,11 @@ #include #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace Content { -// Functions from content manager -#define CONTENT_FUNCTION_API_GET_LOCAL_MEDIASOURCE "getLocalMediaSource" - -// Functions from content -#define CONTENT_FUNCTION_API_FIND_ITEMS "find" -#define CONTENT_FUNCTION_API_GET_FOLDERS "getDirectories" -#define CONTENT_FUNCTION_API_UPDATE_ITEM "update" -#define CONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH "updateBatch" -#define CONTENT_FUNCTION_API_SCAN_FILE "scanFile" -#define CONTENT_FUNCTION_API_SET_CHANGE_LISTENER "setChangeListener" -#define CONTENT_FUNCTION_API_UNSET_CHANGE_LISTENER "unsetChangeListener" - - DECLARE_FUNCTION_GETTER(Content); #define CONTENT_CHECK_ACCESS(functionName) \ diff --git a/src/Content/plugin_config_impl.h b/src/Content/plugin_config_impl.h new file mode 100755 index 0000000..85b6eb2 --- /dev/null +++ b/src/Content/plugin_config_impl.h @@ -0,0 +1,32 @@ +// +// 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. +// + + +#ifndef _CONTENT_PLUGIN_CONFIG_IMPL_H_ +#define _CONTENT_PLUGIN_CONFIG_IMPL_H_ + +#define CONTENT_FUNCTION_API_GET_LOCAL_MEDIASOURCE "getLocalMediaSource" +#define CONTENT_FUNCTION_API_FIND_ITEMS "find" +#define CONTENT_FUNCTION_API_GET_FOLDERS "getDirectories" +#define CONTENT_FUNCTION_API_UPDATE_ITEM "update" +#define CONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH "updateBatch" +#define CONTENT_FUNCTION_API_SCAN_FILE "scanFile" +#define CONTENT_FUNCTION_API_SET_CHANGE_LISTENER "setChangeListener" +#define CONTENT_FUNCTION_API_UNSET_CHANGE_LISTENER "unsetChangeListener" + + +#endif // _CONTENT_PLUGIN_CONFIG_IMPL_H_ diff --git a/src/Content/plugin_initializer.cpp b/src/Content/plugin_initializer.cpp index 44ac0e9..2a0bf08 100755 --- a/src/Content/plugin_initializer.cpp +++ b/src/Content/plugin_initializer.cpp @@ -20,7 +20,8 @@ #include #include #include - +#include +#include "plugin_config.h" #include "JSContentManager.h" #include "ContentAsyncCallbackManager.h" #include @@ -33,6 +34,28 @@ using namespace WrtDeviceApis::CommonsJavaScript; namespace DeviceAPI { namespace Content { +AceSecurityStatus contentAceCheckAccessFunction(const char* functionName) +{ + return CONTENT_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerContentSetter, + MediacontentManagerPriv, + gSecurityAccessor); + +class_definition_options_t option = +{ + JS_CLASS, + NONE, + ALWAYS_NOTICE, + IGNORED, + AceCheckerContentSetter, + NULL, + NULL +}; + void on_frame_load_callback(const void * context) { LoggerD("[Tizen\\content] on_frame_load_callback (" << context << ")"); @@ -60,6 +83,7 @@ void on_widget_start_callback(int widgetId) LoggerE("WrtAccess intialization failed"); } + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, contentAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) @@ -75,6 +99,7 @@ void on_widget_stop_callback(int widgetId) { LoggerE("WrtAccess deinitialization failed"); } + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } PLUGIN_ON_WIDGET_START(on_widget_start_callback) @@ -86,7 +111,7 @@ PLUGIN_CLASS_MAP_BEGIN PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "content", (js_class_template_getter)JSMediacontentManager::getClassRef, - NULL) + &option) PLUGIN_CLASS_MAP_END } diff --git a/src/Download/CMakeLists.txt b/src/Download/CMakeLists.txt index 47f1a5b..ab14067 100755 --- a/src/Download/CMakeLists.txt +++ b/src/Download/CMakeLists.txt @@ -43,7 +43,6 @@ ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_IMPL_NAME} - "-Wl,--no-as-needed" ${filesystem_config} ) INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) diff --git a/src/Filesystem/CMakeLists.txt b/src/Filesystem/CMakeLists.txt index 3b67e79..234660b 100755 --- a/src/Filesystem/CMakeLists.txt +++ b/src/Filesystem/CMakeLists.txt @@ -1,7 +1,6 @@ SET(TARGET_NAME ${filesystem_target}) SET(DESTINATION_NAME ${filesystem_dest}) SET(TARGET_IMPL_NAME ${filesystem_impl}) -SET(TARGET_CONFIG_NAME ${filesystem_config}) PKG_CHECK_MODULES(platform_pkgs_filesystem REQUIRED capi-appfw-application libpcrecpp ecore) @@ -19,6 +18,10 @@ SET(CMAKE_INSTALL_RPATH ) SET(SRCS_IMPL + JSFilesystemManager.cpp + JSFile.cpp + JSFilestream.cpp + JSStorage.cpp IManager.cpp IPath.cpp IStream.cpp @@ -43,10 +46,6 @@ SET(SRCS_IMPL Stream.cpp NodeFilterMatcher.cpp Utils.cpp - JSFilesystemManager.cpp - JSFile.cpp - JSFilestream.cpp - JSStorage.cpp Converter.cpp EventGetNodeData.cpp Encodings.cpp @@ -66,17 +65,8 @@ TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} ${platform_pkgs_filesystem_LIBRARIES} ) -SET(SRCS_CONFIG - plugin_config.cpp -) - -ADD_LIBRARY(${TARGET_CONFIG_NAME} SHARED ${SRCS_CONFIG}) - -TARGET_LINK_LIBRARIES(${TARGET_CONFIG_NAME} - ${LIBS_COMMON} -) - SET(SRCS + plugin_config.cpp plugin_initializer.cpp ) @@ -87,7 +77,7 @@ TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_CONFIG_NAME} ) -INSTALL(TARGETS ${TARGET_NAME} ${TARGET_CONFIG_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) +INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) INSTALL( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/filesystem diff --git a/src/Filesystem/Converter.cpp b/src/Filesystem/Converter.cpp index 2a9e833..1c8e65a 100755 --- a/src/Filesystem/Converter.cpp +++ b/src/Filesystem/Converter.cpp @@ -67,7 +67,7 @@ Converter::Converter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::C JSValueRef Converter::toJSValueRef( const NodeList& arg, const JSFile::PrivateObjectDef::PermissionList &parentPermissions, - JSContextRef context) + JSContextRef context, DeviceAPI::Common::SecurityAccessor *securityAccessor) { JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL); if (!jsResult) { @@ -84,6 +84,10 @@ JSValueRef Converter::toJSValueRef( JSFile::PrivateObject* privateObject = new JSFile::PrivateObject( context, privData); + + if (securityAccessor) + privateObject->copyAceCheckAccessFunction(securityAccessor); + JSObjectRef jsObject = JSObjectMake(m_context, JSFile::getClassRef(), privateObject); diff --git a/src/Filesystem/Converter.h b/src/Filesystem/Converter.h index 70bd4cb..78726a9 100755 --- a/src/Filesystem/Converter.h +++ b/src/Filesystem/Converter.h @@ -24,6 +24,7 @@ #include #include #include +#include #include "Enums.h" #include "IPath.h" #include "INodeTypes.h" @@ -46,7 +47,7 @@ public: JSValueRef toJSValueRef( const NodeList& arg, const JSFile::PrivateObjectDef::PermissionList &parentPermissions, - JSContextRef context); + JSContextRef context, DeviceAPI::Common::SecurityAccessor *securityAccessor); JSValueRef toJSValueRef(unsigned char* data, std::size_t num); JSValueRef toJSValueRef(unsigned long long arg); diff --git a/src/Filesystem/EventCopy.h b/src/Filesystem/EventCopy.h index bd12cfb..884cdd1 100755 --- a/src/Filesystem/EventCopy.h +++ b/src/Filesystem/EventCopy.h @@ -21,12 +21,15 @@ #include #include +#include #include "IPath.h" #include "INode.h" namespace DeviceAPI { namespace Filesystem { -class EventCopy : public WrtDeviceApis::Commons::IEvent +class EventCopy : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { public: /** diff --git a/src/Filesystem/EventGetStorage.h b/src/Filesystem/EventGetStorage.h index abd8dac..7581dd5 100755 --- a/src/Filesystem/EventGetStorage.h +++ b/src/Filesystem/EventGetStorage.h @@ -22,12 +22,14 @@ #include #include #include +#include #include "StorageProperties.h" namespace DeviceAPI { namespace Filesystem { -class EventGetStorage : public WrtDeviceApis::Commons::IEvent< - EventGetStorage> +class EventGetStorage : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { private: std::string label; @@ -44,4 +46,4 @@ typedef DPL::SharedPtr EventGetStoragePtr; } // Filesystem } // TizenApis -#endif //TIZENAPIS_API_FILESYSTEM_EVENT_GET_STORAGE_H_ \ No newline at end of file +#endif //TIZENAPIS_API_FILESYSTEM_EVENT_GET_STORAGE_H_ diff --git a/src/Filesystem/EventListNodes.h b/src/Filesystem/EventListNodes.h index 383bc1e..49f8a51 100755 --- a/src/Filesystem/EventListNodes.h +++ b/src/Filesystem/EventListNodes.h @@ -21,12 +21,15 @@ #include #include +#include #include "INodeTypes.h" #include "NodeFilter.h" namespace DeviceAPI { namespace Filesystem { -class EventListNodes : public WrtDeviceApis::Commons::IEvent +class EventListNodes : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { public: /** @@ -76,4 +79,4 @@ typedef DPL::SharedPtr EventListNodesPtr; } // Filesystem } // TizenApis -#endif // TIZENAPIS_FILESYSTEM_EVENTLISTNODES_H_ \ No newline at end of file +#endif // TIZENAPIS_FILESYSTEM_EVENTLISTNODES_H_ diff --git a/src/Filesystem/EventListStorages.h b/src/Filesystem/EventListStorages.h index 8fd5bf9..286702f 100755 --- a/src/Filesystem/EventListStorages.h +++ b/src/Filesystem/EventListStorages.h @@ -22,12 +22,14 @@ #include #include #include +#include #include "StorageProperties.h" namespace DeviceAPI { namespace Filesystem { -class EventListStorages : public WrtDeviceApis::Commons::IEvent< - EventListStorages> +class EventListStorages : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { private: std::vector storages; @@ -41,4 +43,4 @@ typedef DPL::SharedPtr EventListStoragesPtr; } } -#endif \ No newline at end of file +#endif diff --git a/src/Filesystem/EventMove.h b/src/Filesystem/EventMove.h index 742c7f6..8afa2a9 100755 --- a/src/Filesystem/EventMove.h +++ b/src/Filesystem/EventMove.h @@ -21,12 +21,15 @@ #include #include +#include #include "IPath.h" #include "INode.h" namespace DeviceAPI { namespace Filesystem { -class EventMove : public WrtDeviceApis::Commons::IEvent +class EventMove : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { public: /** @@ -85,4 +88,4 @@ typedef DPL::SharedPtr EventMovePtr; } // Filesystem } // TizenApis -#endif // TIZENAPIS_FILESYSTEM_EVENTMOVE_H_ \ No newline at end of file +#endif // TIZENAPIS_FILESYSTEM_EVENTMOVE_H_ diff --git a/src/Filesystem/EventOpen.h b/src/Filesystem/EventOpen.h index ad8cc58..d67f65d 100755 --- a/src/Filesystem/EventOpen.h +++ b/src/Filesystem/EventOpen.h @@ -21,11 +21,14 @@ #include #include +#include #include "IStream.h" namespace DeviceAPI { namespace Filesystem { -class EventOpen : public WrtDeviceApis::Commons::IEvent +class EventOpen : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { public: /** @@ -65,4 +68,4 @@ typedef DPL::SharedPtr EventOpenPtr; } // Filesystem } // TizenApis -#endif // TIZENAPIS_FILESYSTEM_EVENTOPEN_H_ \ No newline at end of file +#endif // TIZENAPIS_FILESYSTEM_EVENTOPEN_H_ diff --git a/src/Filesystem/EventReadText.h b/src/Filesystem/EventReadText.h index fa70a96..17b6b86 100755 --- a/src/Filesystem/EventReadText.h +++ b/src/Filesystem/EventReadText.h @@ -22,11 +22,14 @@ #include #include #include +#include #include "IPath.h" namespace DeviceAPI { namespace Filesystem { -class EventReadText : public WrtDeviceApis::Commons::IEvent +class EventReadText : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { public: /** @@ -52,4 +55,4 @@ typedef DPL::SharedPtr EventReadTextPtr; } // Filesystem } // TizenApis -#endif // TIZENAPIS_FILESYSTEM_EVENTREADTEXT_H_ \ No newline at end of file +#endif // TIZENAPIS_FILESYSTEM_EVENTREADTEXT_H_ diff --git a/src/Filesystem/EventRemove.h b/src/Filesystem/EventRemove.h index b8ccb79..ccb310a 100755 --- a/src/Filesystem/EventRemove.h +++ b/src/Filesystem/EventRemove.h @@ -21,12 +21,15 @@ #include #include +#include #include "INode.h" #include "Enums.h" namespace DeviceAPI { namespace Filesystem { -class EventRemove : public WrtDeviceApis::Commons::IEvent +class EventRemove : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { public: /** @@ -63,4 +66,4 @@ typedef DPL::SharedPtr EventRemovePtr; } // Filesystem } // TizenApis -#endif // TIZENAPIS_FILESYSTEM_EVENTREMOVE_H_ \ No newline at end of file +#endif // TIZENAPIS_FILESYSTEM_EVENTREMOVE_H_ diff --git a/src/Filesystem/EventResolve.h b/src/Filesystem/EventResolve.h index 0f61331..70ed979 100755 --- a/src/Filesystem/EventResolve.h +++ b/src/Filesystem/EventResolve.h @@ -21,12 +21,16 @@ #include #include +#include + #include "IPath.h" #include "INode.h" namespace DeviceAPI { namespace Filesystem { -class EventResolve : public WrtDeviceApis::Commons::IEvent +class EventResolve : + public WrtDeviceApis::Commons::IEvent, + public DeviceAPI::Common::SecurityAccessor { public: /** diff --git a/src/Filesystem/JSFile.cpp b/src/Filesystem/JSFile.cpp index 37da3aa..152b5fb 100755 --- a/src/Filesystem/JSFile.cpp +++ b/src/Filesystem/JSFile.cpp @@ -17,6 +17,7 @@ #include "JSFile.h" +#include "plugin_config_impl.h" #include #include @@ -46,7 +47,6 @@ #include "Converter.h" #include "plugin_config.h" #include "Encodings.h" -#include "JSFilestream.h" #include "ResponseDispatcher.h" #include "FilesystemAsyncCallbackManager.h" #include @@ -198,9 +198,13 @@ JSValueRef JSFile::getProperty(JSContextRef context, { parent->setPermissions(perms.back()); perms.pop_back(); - PrivateObjectDefPtr privData(new PrivateObjectDef(parent, perms)); + PrivateObjectDefPtr privDefData(new PrivateObjectDef(parent, perms)); + JSFile::PrivateObject* privData = new JSFile::PrivateObject(globalContext, privDefData); + privData->copyAceCheckAccessFunction(privateObject); + + JSObjectRef object = JSObjectMake(globalContext, JSFile::getClassRef(), privData); - return JSUtils::makeObject(privateObject->getContext(), getClassRef(), privData); + return object; } return JSValueMakeNull(context); } @@ -356,13 +360,10 @@ JSValueRef JSFile::toUri(JSContextRef context, LoggerE("Private object is not set."); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_TO_URI); Converter converter(context); - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_TO_URI); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - try { int widgetId = WrtAccessSingleton::Instance().getWidgetId(); TIME_TRACER_ITEM_END(__FUNCTION__, 0); @@ -393,6 +394,8 @@ JSValueRef JSFile::listFiles(JSContextRef context, LoggerD("OK"); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_LIST_FILES); + // argument validation with new validator try { ArgumentValidator validator(context, argc, argv); @@ -414,8 +417,6 @@ JSValueRef JSFile::listFiles(JSContextRef context, try { - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_LIST_FILES); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); for (index = 0; index < 3; index++) { @@ -454,6 +455,7 @@ JSValueRef JSFile::listFiles(JSContextRef context, event->setPrivateData(DPL::StaticPointerCast(privData)); event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); + event->copyAceCheckAccessFunction(privateObject); privateObject->getObject()->getNode()->getChildNodes(event); FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); @@ -485,6 +487,8 @@ JSValueRef JSFile::openStream(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_OPEN_STREAM); + // argument validation with new validator try { ArgumentValidator validator(context, argumentCount, arguments); @@ -504,9 +508,6 @@ JSValueRef JSFile::openStream(JSContextRef context, size_t index = 0; JSValueRef reserveArguments[4]; - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_OPEN_STREAM); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - try { @@ -547,15 +548,12 @@ JSValueRef JSFile::openStream(JSContextRef context, std::string path = privateObject->getObject()->getNode()->getPath()->getFullPath(); std::string vpath = Utils::toVirtualPath(globalContext, path); - AccessModeInfo am = AccessModeInfo(mode, vpath); - status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_OPEN_STREAM, am); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - EventOpenPtr event(new EventOpen(mode)); event->setPrivateData(DPL::StaticPointerCast(cbm)); event->setCharSet(encoding); event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); + event->copyAceCheckAccessFunction(privateObject); + FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); privateObject->getObject()->getNode()->open(event); @@ -587,6 +585,7 @@ JSValueRef JSFile::readAsText(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_READ_AS_TEXT); // argument validation with new validator try { @@ -603,8 +602,7 @@ JSValueRef JSFile::readAsText(JSContextRef context, JSContextRef globalContext = privateObject->getContext(); - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_READ_AS_TEXT); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + size_t index = 0; JSValueRef reserveArguments[3]; @@ -679,13 +677,13 @@ JSValueRef JSFile::copyTo(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject,FILESYSTEM_FUNCTION_API_COPY_TO); + JSContextRef globalContext = privateObject->getContext(); size_t index = 0; JSValueRef reserveArguments[5]; JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext); - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_COPY_TO); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); // argument validation with new validator try { @@ -740,12 +738,6 @@ JSValueRef JSFile::copyTo(JSContextRef context, } std::string virtualDestPath = Utils::toVirtualPath(globalContext, dest->getFullPath()); - AccessModeInfo amode = AccessModeInfo(AM_WRITE, virtualDestPath); - status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS( - FILESYSTEM_FUNCTION_API_COPY_TO, - amode); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); EventCopyPtr event(new EventCopy(src, dest)); @@ -758,6 +750,8 @@ JSValueRef JSFile::copyTo(JSContextRef context, JSCallbackManager>( cbm)); event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); + event->copyAceCheckAccessFunction(privateObject); + FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); IManager::getInstance().copy(event); @@ -790,6 +784,8 @@ JSValueRef JSFile::moveTo(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_MOVE_TO); + JSContextRef globalContext = privateObject->getContext(); LoggerD("OK"); @@ -811,8 +807,6 @@ JSValueRef JSFile::moveTo(JSContextRef context, JSValueRef reserveArguments[5]; JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext); - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_MOVE_TO); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); try { @@ -850,11 +844,6 @@ JSValueRef JSFile::moveTo(JSContextRef context, std::string virtualDestPath = Utils::toVirtualPath(globalContext, dest->getFullPath()); - AccessModeInfo amode = AccessModeInfo(AM_WRITE, virtualDestPath); - AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_MOVE_TO, amode); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - EventMovePtr event(new EventMove(src, dest)); if (overwrite) { event->setOptions(OPT_OVERWRITE); @@ -862,6 +851,8 @@ JSValueRef JSFile::moveTo(JSContextRef context, event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); event->setPrivateData(DPL::StaticPointerCast (cbm)); + event->copyAceCheckAccessFunction(privateObject); + FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); IManager::getInstance().move(event); @@ -895,9 +886,7 @@ JSValueRef JSFile::createDirectory(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_CREATE_DIR); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_CREATE_DIR); Converter converter(context); try { @@ -913,11 +902,16 @@ JSValueRef JSFile::createDirectory(JSContextRef context, INodePtr node(privateObject->getObject()->getNode()->createChild(path, NT_DIRECTORY, OPT_RECURSIVE)); node->setPermissions(privateObject->getObject()->getNode()->getPermissions()); - PrivateObjectDefPtr privData(new PrivateObjectDef(node, privateObject->getObject()->getParentPermissions())); - privData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions()); + PrivateObjectDefPtr privDefData(new PrivateObjectDef(node, privateObject->getObject()->getParentPermissions())); + privDefData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions()); + JSFile::PrivateObject* privData = new JSFile::PrivateObject(privateObject->getContext(), privDefData); + privData->copyAceCheckAccessFunction(privateObject); TIME_TRACER_ITEM_END(__FUNCTION__, 0); - return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(privateObject->getContext(), getClassRef(), privData); + + + JSObjectRef object = JSObjectMake(privateObject->getContext(), JSFile::getClassRef(), privData); + return object; } catch (const WrtDeviceApis::Commons::SecurityException& ex) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage()); } @@ -947,9 +941,7 @@ JSValueRef JSFile::createFile(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_CREATE_FILE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_CREATE_FILE); Converter converter(context); try { @@ -965,10 +957,17 @@ JSValueRef JSFile::createFile(JSContextRef context, IPathPtr path = converter.toPath(argv[0]); INodePtr node = privateObject->getObject()->getNode()->createChild(path, NT_FILE); - PrivateObjectDefPtr privData(new PrivateObjectDef(node, privateObject->getObject()->getParentPermissions())); - privData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions()); + PrivateObjectDefPtr privDefData(new PrivateObjectDef(node, privateObject->getObject()->getParentPermissions())); + privDefData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions()); + + JSFile::PrivateObject* privData = new JSFile::PrivateObject(privateObject->getContext(), privDefData); + privData->copyAceCheckAccessFunction(privateObject); + + JSObjectRef object = JSObjectMake(privateObject->getContext(), JSFile::getClassRef(), privData); + TIME_TRACER_ITEM_END(__FUNCTION__, 0); - return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(privateObject->getContext(), getClassRef(), privData); + return object; + } catch (const WrtDeviceApis::Commons::SecurityException& ex) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, ex.GetMessage()); @@ -999,8 +998,7 @@ JSValueRef JSFile::resolve(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_RESOLVE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_RESOLVE); if (privateObject->getObject()->getNode()->getType() != NT_DIRECTORY) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::IO_ERROR, "IO error"); @@ -1016,16 +1014,15 @@ JSValueRef JSFile::resolve(JSContextRef context, IPathPtr path = converter.toPath(argv[0]); INodePtr node = privateObject->getObject()->getNode()->getChild(path); node->setPermissions(privateObject->getObject()->getNode()->getPermissions()); - PrivateObjectDefPtr privData(new PrivateObjectDef(node, privateObject->getObject()->getParentPermissions())); - privData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions()); + PrivateObjectDefPtr privDefData(new PrivateObjectDef(node, privateObject->getObject()->getParentPermissions())); + privDefData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions()); + + JSFile::PrivateObject* privData = new JSFile::PrivateObject(privateObject->getContext(), privDefData); + privData->copyAceCheckAccessFunction(privateObject); TIME_TRACER_ITEM_END(__FUNCTION__, 0); - return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(privateObject->getContext(), getClassRef(), privData); - /* - IPathPtr path = converter.toPath(argv[0]); - INodePtr node = privateObject->getObject()->getNode()->getChild(path); - node->setPermissions(privateObject->getObject()->getNode()->getPermissions()); - return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node); - */ + + JSObjectRef object = JSObjectMake(privateObject->getContext(), JSFile::getClassRef(), privData); + return object; } catch (const WrtDeviceApis::Commons::PlatformException& ex) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::IO_ERROR, ex.GetMessage()); } catch(const WrtDeviceApis::Commons::ConversionException& ex) { @@ -1053,9 +1050,9 @@ JSValueRef JSFile::deleteDirectory(JSContextRef context, if (!privateObject) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } + - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_DELETE_DIR); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject,FILESYSTEM_FUNCTION_API_DELETE_DIR); if (argc < 2) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); @@ -1149,6 +1146,8 @@ JSValueRef JSFile::deleteDirectory(JSContextRef context, eventRemove->setForAsynchronousCall(&ResponseDispatcher::getInstance()); eventRemove->setPrivateData(DPL::StaticPointerCast (cbm)); + eventRemove->copyAceCheckAccessFunction(privateObject); + FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); IManager::getInstance().remove(eventRemove); @@ -1185,9 +1184,13 @@ JSValueRef JSFile::deleteFile(JSContextRef context, PrivateObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); + if (!privateObject) { return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } + + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_DELETE_FILE); + // argument validation with new validator try { ArgumentValidator validator(context, argc, argv); @@ -1207,10 +1210,6 @@ JSValueRef JSFile::deleteFile(JSContextRef context, JSValueRef reserveArguments[3]; JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext); - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_DELETE_FILE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - try { for (index = 0; index < 3; index++) { if (index < argc) @@ -1276,6 +1275,8 @@ JSValueRef JSFile::deleteFile(JSContextRef context, EventRemovePtr eventRemove(new EventRemove(path)); eventRemove->setForAsynchronousCall(&ResponseDispatcher::getInstance()); eventRemove->setPrivateData(DPL::StaticPointerCast (cbm)); + eventRemove->copyAceCheckAccessFunction(privateObject); + FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); IManager::getInstance().remove(eventRemove); diff --git a/src/Filesystem/JSFile.h b/src/Filesystem/JSFile.h index 162a7bb..d8d4288 100755 --- a/src/Filesystem/JSFile.h +++ b/src/Filesystem/JSFile.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "INode.h" namespace DeviceAPI { @@ -104,8 +105,24 @@ public: }; typedef DPL::SharedPtr ListFilesPrivateDataPtr; - typedef DPL::SharedPtr PrivateObjectDefPtr; - typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type PrivateObject; + typedef DPL::SharedPtr PrivateObjectDefPtr; + typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type PrivateObjectSecurity; + + class PrivateObject : + public DeviceAPI::Common::SecurityAccessor, + public PrivateObjectSecurity + { + public : + PrivateObject (JSContextRef context, PrivateObjectDefPtr privDef) : + DeviceAPI::Common::SecurityAccessor(), + PrivateObjectSecurity(context, privDef) + { + } + + virtual ~PrivateObject() + { + } + }; public: static const JSClassDefinition* getClassInfo(); diff --git a/src/Filesystem/JSFilestream.cpp b/src/Filesystem/JSFilestream.cpp index 95e2ad6..641753d 100644 --- a/src/Filesystem/JSFilestream.cpp +++ b/src/Filesystem/JSFilestream.cpp @@ -197,9 +197,7 @@ JSValueRef JSFilestream::close(JSContextRef context, } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_CLOSE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_CLOSE); Try { privateObject->getObject()->close(); @@ -226,9 +224,9 @@ JSValueRef JSFilestream::read(JSContextRef context, } Converter converter(context); + - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_READ); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_READ); try { JSValueRef undefinedValue = JSValueMakeUndefined(context); @@ -284,9 +282,7 @@ JSValueRef JSFilestream::readBytes(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_READ_BYTES); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_READ_BYTES); Converter converter(context); Try { @@ -330,8 +326,7 @@ JSValueRef JSFilestream::readBase64(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_READ_BASE64); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_READ_BASE64); Converter converter(context); try { @@ -376,9 +371,7 @@ JSValueRef JSFilestream::write(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_WRITE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_WRITE); Converter converter(context); try { @@ -417,9 +410,7 @@ JSValueRef JSFilestream::writeBytes(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_WRITE_BYTES); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_WRITE_BYTES); Converter converter(context); Try { @@ -459,8 +450,7 @@ JSValueRef JSFilestream::writeBase64(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch error"); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_WRITE_BASE64); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_WRITE_BASE64); Converter converter(context); try { diff --git a/src/Filesystem/JSFilestream.h b/src/Filesystem/JSFilestream.h index 6fc278e..4ed2e54 100755 --- a/src/Filesystem/JSFilestream.h +++ b/src/Filesystem/JSFilestream.h @@ -21,15 +21,34 @@ #include #include +#include #include "IStream.h" namespace DeviceAPI { namespace Filesystem { + + class JSFilestream { public: - typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type PrivateObject; - + typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type PrivateObjectSecurity; + + class PrivateObject : + public DeviceAPI::Common::SecurityAccessor, + public PrivateObjectSecurity + { + public : + PrivateObject (JSContextRef context, IStreamPtr stream) : + DeviceAPI::Common::SecurityAccessor(), + PrivateObjectSecurity(context, stream) + { + } + + virtual ~PrivateObject() + { + } + }; + public: static const JSClassDefinition* getClassInfo(); @@ -169,4 +188,4 @@ private: } } -#endif \ No newline at end of file +#endif diff --git a/src/Filesystem/JSFilesystemManager.cpp b/src/Filesystem/JSFilesystemManager.cpp index c88b13a..f8e736a 100644 --- a/src/Filesystem/JSFilesystemManager.cpp +++ b/src/Filesystem/JSFilesystemManager.cpp @@ -17,6 +17,7 @@ #include "JSFilesystemManager.h" +#include "plugin_config_impl.h" #include #include "EventResolve.h" #include "IManager.h" @@ -194,8 +195,7 @@ JSValueRef JSFilesystemManager::getStorage(JSContextRef context, return JSValueMakeUndefined(context); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_GET_STORAGE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_GET_STORAGE); // argument validation with new validator try { @@ -268,8 +268,7 @@ JSValueRef JSFilesystemManager::getStorageList(JSContextRef context, return JSValueMakeUndefined(context); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_LIST_STORAGE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_LIST_STORAGE); // argument validation with new validator try { @@ -340,9 +339,8 @@ JSValueRef JSFilesystemManager::addStorageStateListener(JSContextRef context, return JSValueMakeUndefined(context); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - + + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER); // argument validation with new validator try { @@ -351,7 +349,6 @@ JSValueRef JSFilesystemManager::addStorageStateListener(JSContextRef context, validator.toFunction(1, true); } catch (const BasePlatformException &err) { - LogDebug("Exception"); return JSWebAPIErrorFactory::postException(context, exception, err); } catch (...) { DeviceAPI::Common::UnknownException err(""); @@ -414,10 +411,8 @@ JSValueRef JSFilesystemManager::removeStorageStateListener(JSContextRef context, return JSValueMakeUndefined(context); } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER); - LogDebug("a"); // argument validation with new validator try { @@ -486,8 +481,8 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context, } - AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, privateObject, FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID); + LoggerD("<<<" << std::hex << privateObject); // argument validation with new validator try { @@ -508,9 +503,6 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context, return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error"); } - LogDebug("resolve"); - - JSContextRef globalContext = privateObject->getContext(); @@ -596,18 +588,12 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context, return JSValueMakeUndefined(context); } - PermissionsAccessInfo perms(permissions, virtualPath); - AceSecurityStatus status = FILESYSTEM_PERMISSION_CHECK_ACCESS( - FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID, - perms); - - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - EventGetNodeDataPtr data(new EventGetNodeData(permissions, cbm)); EventResolvePtr event(new EventResolve(path)); event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); event->setMode(perm); event->setPrivateData(DPL::StaticPointerCast (data)); + event->copyAceCheckAccessFunction(privateObject); FilesystemAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, globalContext); IManager::getInstance().getNode(event); diff --git a/src/Filesystem/JSFilesystemManager.h b/src/Filesystem/JSFilesystemManager.h index ba00d49..d18466d 100755 --- a/src/Filesystem/JSFilesystemManager.h +++ b/src/Filesystem/JSFilesystemManager.h @@ -21,14 +21,34 @@ #include #include +#include namespace DeviceAPI { namespace Filesystem { + + + + class JSFilesystemManager { public: - typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type PrivateObject; - + typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type PrivateObjectSecurity; + + class PrivateObject : + public DeviceAPI::Common::SecurityAccessor, + public PrivateObjectSecurity + { + public: + PrivateObject(JSContextRef context) : + DeviceAPI::Common::SecurityAccessor(), + PrivateObjectSecurity(context) + { + } + + virtual ~PrivateObject() + { + } + }; public: static const JSClassDefinition* getClassInfo(); @@ -121,4 +141,4 @@ class JSFilesystemManager } } -#endif \ No newline at end of file +#endif diff --git a/src/Filesystem/JSStorage.h b/src/Filesystem/JSStorage.h index 37c96e0..59bd7e6 100755 --- a/src/Filesystem/JSStorage.h +++ b/src/Filesystem/JSStorage.h @@ -21,10 +21,12 @@ #include #include +#include #include "StorageProperties.h" namespace DeviceAPI { namespace Filesystem { + typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSStoragePriv; class JSStorage diff --git a/src/Filesystem/ResponseDispatcher.cpp b/src/Filesystem/ResponseDispatcher.cpp index 9f98ff2..16f3fad 100644 --- a/src/Filesystem/ResponseDispatcher.cpp +++ b/src/Filesystem/ResponseDispatcher.cpp @@ -67,13 +67,17 @@ void ResponseDispatcher::OnAnswerReceived(const EventResolvePtr& event) if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) { event->getResult()->setPermissions(data->getPerms()); - JSFile::PrivateObjectDefPtr privData(new JSFile::PrivateObjectDef(event->getResult(), JSFile::PrivateObjectDef::PermissionList())); + + JSFile::PrivateObjectDefPtr privDefData(new JSFile::PrivateObjectDef(event->getResult(), JSFile::PrivateObjectDef::PermissionList())); + JSFile::PrivateObject* privData = new JSFile::PrivateObject(data->getCallbackManager()->getContext(), privDefData); + privData->copyAceCheckAccessFunction(event.Get()); + try { INodePtr parent = event->getResult()->getParent(); if (parent) { - privData->pushParentPermissions(data->getPerms()); + privDefData->pushParentPermissions(data->getPerms()); } } catch (...) @@ -81,7 +85,7 @@ void ResponseDispatcher::OnAnswerReceived(const EventResolvePtr& event) LoggerD("no parent"); } - JSObjectRef object = JSUtils::makeObject(data->getCallbackManager()->getContext(), JSFile::getClassRef(), privData); + JSObjectRef object = JSObjectMake(data->getCallbackManager()->getContext(), JSFile::getClassRef(), privData); data->getCallbackManager()->callOnSuccess(object); } else { JSObjectRef jsException; @@ -112,7 +116,7 @@ void ResponseDispatcher::OnAnswerReceived(const EventListNodesPtr& event) if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) { Converter converter(data->getContext()); Try { - JSValueRef result = converter.toJSValueRef(event->getResult(), privData->getParentPermissions(), data->getContext()); + JSValueRef result = converter.toJSValueRef(event->getResult(), privData->getParentPermissions(), data->getContext(), event.Get()); data->callOnSuccess(result); } Catch(WrtDeviceApis::Commons::ConversionException) { @@ -134,7 +138,10 @@ void ResponseDispatcher::OnAnswerReceived(const EventOpenPtr& event) FilesystemAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(data); if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) { - JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFilestream::getClassRef(), event->getResult()); + JSFilestream::PrivateObject* privData = new JSFilestream::PrivateObject(data->getContext(), event->getResult()); + privData->copyAceCheckAccessFunction(event.Get()); + + JSObjectRef object = JSObjectMake(data->getContext(), JSFilestream::getClassRef(), privData); data->callOnSuccess(object); } else { JSObjectRef jsException; @@ -161,11 +168,11 @@ void ResponseDispatcher::OnAnswerReceived(const EventCopyPtr& event) FilesystemAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(data); if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) { - JSFile::PrivateObjectDefPtr privData(new JSFile::PrivateObjectDef( - event->getResult(), - JSFile::PrivateObjectDef::PermissionList())); + JSFile::PrivateObjectDefPtr privDefData(new JSFile::PrivateObjectDef(event->getResult(),JSFile::PrivateObjectDef::PermissionList())); + JSFile::PrivateObject* privData = new JSFile::PrivateObject(data->getContext(), privDefData); + privData->copyAceCheckAccessFunction(event.Get()); - JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFile::getClassRef(), privData); + JSObjectRef object = JSObjectMake(data->getContext(), JSFile::getClassRef(), privData); data->callOnSuccess(object); } else { JSObjectRef jsException = NULL; @@ -191,12 +198,11 @@ void ResponseDispatcher::OnAnswerReceived(const EventMovePtr& event) FilesystemAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(data); if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) { - JSFile::PrivateObjectDefPtr privData(new JSFile::PrivateObjectDef( - event->getResult(), - JSFile::PrivateObjectDef::PermissionList())); - JSObjectRef object = JSUtils::makeObject(data->getContext(), - JSFile::getClassRef(), - privData); + JSFile::PrivateObjectDefPtr privDefData(new JSFile::PrivateObjectDef(event->getResult(), JSFile::PrivateObjectDef::PermissionList())); + JSFile::PrivateObject* privData = new JSFile::PrivateObject(data->getContext(), privDefData); + privData->copyAceCheckAccessFunction(event.Get()); + + JSObjectRef object = JSObjectMake(data->getContext(), JSFile::getClassRef(), privData); data->callOnSuccess(object); } else { JSObjectRef jsException = NULL; diff --git a/src/Filesystem/plugin_config.cpp b/src/Filesystem/plugin_config.cpp index e0ca0b2..a1cf475 100755 --- a/src/Filesystem/plugin_config.cpp +++ b/src/Filesystem/plugin_config.cpp @@ -18,7 +18,7 @@ #include #include - +#include "plugin_config.h" #include #include #include @@ -30,39 +30,7 @@ namespace DeviceAPI { namespace Filesystem { -#pragma GCC visibility push(default) - -const char* FILESYSTEM_PARAM_LOCATION = "param:location"; -const char* FILESYSTEM_DEVICE_CAP_READ = "filesystem.read"; -const char* FILESYSTEM_DEVICE_CAP_WRITE = "filesystem.write"; - -const char* FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID = "manager_resolve"; -const char* FILESYSTEM_FUNCTION_API_MGR_RESOLVE = "resolve"; - -const char* FILESYSTEM_FUNCTION_API_GET_STORAGE = "getStorage"; -const char* FILESYSTEM_FUNCTION_API_LIST_STORAGE = "listStorage"; -const char* FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER = "addStorageStateChangeListener"; -const char* FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER = "removeStorageStateChangeListener"; - -const char* FILESYSTEM_FUNCTION_API_RESOLVE = "resolve"; -const char* FILESYSTEM_FUNCTION_API_TO_URI = "toURI"; -const char* FILESYSTEM_FUNCTION_API_LIST_FILES = "listFiles"; -const char* FILESYSTEM_FUNCTION_API_OPEN_STREAM = "openStream"; -const char* FILESYSTEM_FUNCTION_API_READ_AS_TEXT = "readAsText"; -const char* FILESYSTEM_FUNCTION_API_COPY_TO = "copyTo"; -const char* FILESYSTEM_FUNCTION_API_MOVE_TO = "moveTo"; -const char* FILESYSTEM_FUNCTION_API_CREATE_DIR = "createDirectory"; -const char* FILESYSTEM_FUNCTION_API_CREATE_FILE = "createFile"; -const char* FILESYSTEM_FUNCTION_API_DELETE_DIR = "deleteDirectory"; -const char* FILESYSTEM_FUNCTION_API_DELETE_FILE = "deleteFile"; - -const char* FILESYSTEM_FUNCTION_API_CLOSE = "close"; -const char* FILESYSTEM_FUNCTION_API_READ = "read"; -const char* FILESYSTEM_FUNCTION_API_READ_BYTES = "readBytes"; -const char* FILESYSTEM_FUNCTION_API_READ_BASE64 = "readBase64"; -const char* FILESYSTEM_FUNCTION_API_WRITE = "write"; -const char* FILESYSTEM_FUNCTION_API_WRITE_BYTES = "writeBytes"; -const char* FILESYSTEM_FUNCTION_API_WRITE_BASE64 = "writeBase64"; + static WrtDeviceApis::Commons::FunctionMapping createFilesystemFunctions(); @@ -351,86 +319,5 @@ static WrtDeviceApis::Commons::FunctionMapping createFilesystemFunctions() return FilesystemMapping; } -void setFilesystemPermDevCaps(int permissions, - const std::string& path, - WrtDeviceApis::Commons::AceFunction* outFunction) -{ - using namespace WrtDeviceApis::Commons; - AceDeviceCapParam paramLocation = AceDeviceCapParam( - FILESYSTEM_PARAM_LOCATION, path); - - AceDeviceCaps devCaps; - - if (permissions & Filesystem::PERM_READ) { - AceDeviceCapability devCapRead = AceDeviceCapability( - FILESYSTEM_DEVICE_CAP_READ, - AceDeviceCapParams()); - devCaps.push_back(devCapRead); - - ACE_ADD_DEV_CAP_PARAM( - devCaps, - FILESYSTEM_DEVICE_CAP_READ, - paramLocation); - } - - if (permissions & Filesystem::PERM_WRITE) { - AceDeviceCapability devCapWrite = AceDeviceCapability( - FILESYSTEM_DEVICE_CAP_WRITE, - AceDeviceCapParams()); - - devCaps.push_back(devCapWrite); - - ACE_ADD_DEV_CAP_PARAM( - devCaps, - FILESYSTEM_DEVICE_CAP_WRITE, - paramLocation); - } - - outFunction->deviceCapabilities = devCaps; -} - -void setFilesystemAccessModeDevCaps(int accessMode, - const std::string& path, - WrtDeviceApis::Commons::AceFunction - *outFunction) -{ - using namespace WrtDeviceApis::Commons; - - AceDeviceCapParam paramLocation = AceDeviceCapParam( - FILESYSTEM_PARAM_LOCATION, - path); - AceDeviceCaps devCaps; - - if (accessMode & Filesystem::AM_READ) { - AceDeviceCapability devCapRead = AceDeviceCapability( - FILESYSTEM_DEVICE_CAP_READ, - AceDeviceCapParams()); - - devCaps.push_back(devCapRead); - - ACE_ADD_DEV_CAP_PARAM( - devCaps, - FILESYSTEM_DEVICE_CAP_READ, - paramLocation); - } - - if ((accessMode & Filesystem::AM_WRITE) || - (accessMode & Filesystem::AM_APPEND)) { - AceDeviceCapability devCapWrite = AceDeviceCapability( - FILESYSTEM_DEVICE_CAP_WRITE, - AceDeviceCapParams()); - - devCaps.push_back(devCapWrite); - - ACE_ADD_DEV_CAP_PARAM( - devCaps, - FILESYSTEM_DEVICE_CAP_WRITE, - paramLocation); - } - outFunction->deviceCapabilities = devCaps; -} - -#pragma GCC visibility pop - } } diff --git a/src/Filesystem/plugin_config.h b/src/Filesystem/plugin_config.h index 756ab0a..6d874ff 100755 --- a/src/Filesystem/plugin_config.h +++ b/src/Filesystem/plugin_config.h @@ -20,131 +20,20 @@ #define _FILESYSTEM_PLUGIN_CONFIG_H_ #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace Filesystem { -extern const char* FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID; -extern const char* FILESYSTEM_FUNCTION_API_GET_STORAGE; -extern const char* FILESYSTEM_FUNCTION_API_LIST_STORAGE; -extern const char* FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER; -extern const char* FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER; - -extern const char* FILESYSTEM_FUNCTION_API_RESOLVE; -extern const char* FILESYSTEM_FUNCTION_API_TO_URI; -extern const char* FILESYSTEM_FUNCTION_API_LIST_FILES; -extern const char* FILESYSTEM_FUNCTION_API_OPEN_STREAM; -extern const char* FILESYSTEM_FUNCTION_API_READ_AS_TEXT; -extern const char* FILESYSTEM_FUNCTION_API_COPY_TO; -extern const char* FILESYSTEM_FUNCTION_API_MOVE_TO; -extern const char* FILESYSTEM_FUNCTION_API_CREATE_DIR; -extern const char* FILESYSTEM_FUNCTION_API_CREATE_FILE; -extern const char* FILESYSTEM_FUNCTION_API_DELETE_DIR; -extern const char* FILESYSTEM_FUNCTION_API_DELETE_FILE; - -extern const char* FILESYSTEM_FUNCTION_API_CLOSE; -extern const char* FILESYSTEM_FUNCTION_API_READ; -extern const char* FILESYSTEM_FUNCTION_API_READ_BYTES; -extern const char* FILESYSTEM_FUNCTION_API_READ_BASE64; -extern const char* FILESYSTEM_FUNCTION_API_WRITE; -extern const char* FILESYSTEM_FUNCTION_API_WRITE_BYTES; -extern const char* FILESYSTEM_FUNCTION_API_WRITE_BASE64; DECLARE_FUNCTION_GETTER(Filesystem); -void setFilesystemPermDevCaps(int permissions, - const std::string& path, - WrtDeviceApis::Commons::AceFunction* outFunction); - -void setFilesystemAccessModeDevCaps(int accessMode, - const std::string& path, - WrtDeviceApis::Commons::AceFunction* - outFunction); - -struct PermissionsAccessInfo -{ - PermissionsAccessInfo(int perms, - const std::string& fpath) : - permissions(perms), - path(fpath) - { - } - - int permissions; - const std::string path; -}; - -struct AccessModeInfo -{ - AccessModeInfo(int amode, - const std::string& fpath) : - accessMode(amode), - path(fpath) - { - } - - int accessMode; - const std::string path; -}; - -} -} - -namespace WrtDeviceApis { -namespace Commons { - -/** - * template specialization for security access basing on permissions - */ -template <> -class DefaultArgsVerifier -{ - public: - void operator()(AceFunction& aceFunction, - const DeviceAPI::Filesystem::PermissionsAccessInfo& permInfo) const - { - DeviceAPI::Filesystem::setFilesystemPermDevCaps(permInfo.permissions, - permInfo.path, - &aceFunction); - } -}; - -/** - * template specialization for security access basing on access mode - */ -template <> -class DefaultArgsVerifier -{ - public: - void operator()(AceFunction& aceFunction, - const DeviceAPI::Filesystem::AccessModeInfo& accessInfo) const - { - DeviceAPI::Filesystem::setFilesystemAccessModeDevCaps(accessInfo.accessMode, - accessInfo.path, - &aceFunction); - } -}; - #define FILESYSTEM_CHECK_ACCESS(functionName) \ WrtDeviceApis::Commons::aceCheckAccess >( \ getFilesystemFunctionData, \ functionName) -#define FILESYSTEM_PERMISSION_CHECK_ACCESS(functionName, perm) \ - WrtDeviceApis::Commons::aceCheckAccess >( \ - getFilesystemFunctionData, \ - functionName, \ - perm) - -#define FILESYSTEM_ACCESSMODE_CHECK_ACCESS(functionName, amode) \ - WrtDeviceApis::Commons::aceCheckAccess >( \ - getFilesystemFunctionData, \ - functionName, \ - amode) } } - #endif diff --git a/src/Filesystem/plugin_config_impl.h b/src/Filesystem/plugin_config_impl.h new file mode 100755 index 0000000..17cb2af --- /dev/null +++ b/src/Filesystem/plugin_config_impl.h @@ -0,0 +1,54 @@ +// +// 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. +// + + +#ifndef _FILESYSTEM_PLUGIN_CONFIG_IMPL_H_ +#define _FILESYSTEM_PLUGIN_CONFIG_IMPL_H_ + +#define FILESYSTEM_PARAM_LOCATION "param:location" +#define FILESYSTEM_DEVICE_CAP_READ "filesystem.read" +#define FILESYSTEM_DEVICE_CAP_WRITE "filesystem.write" + +#define FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID "manager_resolve" +#define FILESYSTEM_FUNCTION_API_MGR_RESOLVE "resolve" + +#define FILESYSTEM_FUNCTION_API_GET_STORAGE "getStorage" +#define FILESYSTEM_FUNCTION_API_LIST_STORAGE "listStorage" +#define FILESYSTEM_FUNCTION_API_ADD_STORAGE_LISTENER "addStorageStateChangeListener" +#define FILESYSTEM_FUNCTION_API_REMOVE_STORAGE_LISTENER "removeStorageStateChangeListener" + +#define FILESYSTEM_FUNCTION_API_RESOLVE "resolve" +#define FILESYSTEM_FUNCTION_API_TO_URI "toURI" +#define FILESYSTEM_FUNCTION_API_LIST_FILES "listFiles" +#define FILESYSTEM_FUNCTION_API_OPEN_STREAM "openStream" +#define FILESYSTEM_FUNCTION_API_READ_AS_TEXT "readAsText" +#define FILESYSTEM_FUNCTION_API_COPY_TO "copyTo" +#define FILESYSTEM_FUNCTION_API_MOVE_TO "moveTo" +#define FILESYSTEM_FUNCTION_API_CREATE_DIR "createDirectory" +#define FILESYSTEM_FUNCTION_API_CREATE_FILE "createFile" +#define FILESYSTEM_FUNCTION_API_DELETE_DIR "deleteDirectory" +#define FILESYSTEM_FUNCTION_API_DELETE_FILE "deleteFile" + +#define FILESYSTEM_FUNCTION_API_CLOSE "close" +#define FILESYSTEM_FUNCTION_API_READ "read" +#define FILESYSTEM_FUNCTION_API_READ_BYTES "readBytes" +#define FILESYSTEM_FUNCTION_API_READ_BASE64 "readBase64" +#define FILESYSTEM_FUNCTION_API_WRITE "write" +#define FILESYSTEM_FUNCTION_API_WRITE_BYTES "writeBytes" +#define FILESYSTEM_FUNCTION_API_WRITE_BASE64 "writeBase64" + +#endif diff --git a/src/Filesystem/plugin_initializer.cpp b/src/Filesystem/plugin_initializer.cpp index 16b2b46..fc64952 100644 --- a/src/Filesystem/plugin_initializer.cpp +++ b/src/Filesystem/plugin_initializer.cpp @@ -18,11 +18,14 @@ #include #include #include +#include #include "JSFilesystemManager.h" #include "JSFile.h" #include "JSFilestream.h" #include "FilesystemAsyncCallbackManager.h" #include "FilesystemListenerManager.h" +#include "plugin_config.h" + #include using namespace WrtDeviceApis; @@ -31,6 +34,26 @@ using namespace WrtDeviceApis::Commons; namespace DeviceAPI { namespace Filesystem { +AceSecurityStatus filesystemAceCheckAccessFunction(const char* functionName) +{ + return FILESYSTEM_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerFilesystemSetter, JSFilesystemManager::PrivateObject, gSecurityAccessor); +DEFINE_JSOBJECT_SECURITY_ACCESSOR_SETTER(AceCheckerFilesystemConstructorSetter, gSecurityAccessor); + +class_definition_options_t FilesystemOptions = +{ + JS_CLASS, + CREATE_INSTANCE, + ALWAYS_NOTICE, + USE_OVERLAYED, //ignored + AceCheckerFilesystemSetter, + NULL +}; + void on_widget_start_callback(int widgetId) { TIME_TRACER_INIT(); @@ -39,6 +62,7 @@ void on_widget_start_callback(int widgetId) } Catch (Commons::Exception) { LoggerE("WrtAccess initialization failed"); } + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, filesystemAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) @@ -50,6 +74,7 @@ void on_widget_stop_callback(int widgetId) } Catch (Commons::Exception) { LoggerE("WrtAccess deinitialization failed"); } + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } void on_frame_unload_callback(const void * context) @@ -75,7 +100,7 @@ PLUGIN_CLASS_MAP_BEGIN PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "filesystem", (js_class_template_getter)DeviceAPI::Filesystem::JSFilesystemManager::getClassRef, - NULL) + &FilesystemOptions) PLUGIN_CLASS_MAP_END #undef FILESYSTEM diff --git a/src/Messaging/AttachmentFactory.cpp b/src/Messaging/AttachmentFactory.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/Attachments.cpp b/src/Messaging/Attachments.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/BinarySms.cpp b/src/Messaging/BinarySms.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/CMakeLists.txt b/src/Messaging/CMakeLists.txt index db14749..1725dc0 100755 --- a/src/Messaging/CMakeLists.txt +++ b/src/Messaging/CMakeLists.txt @@ -149,7 +149,6 @@ ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_IMPL_NAME} - "-Wl,--no-as-needed" ${filesystem_config} ) INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) diff --git a/src/Messaging/CallbackNumber.cpp b/src/Messaging/CallbackNumber.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/ConversationFilterValidator.cpp b/src/Messaging/ConversationFilterValidator.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/ConversationQueryGenerator.cpp b/src/Messaging/ConversationQueryGenerator.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/DBus/Connection.cpp b/src/Messaging/DBus/Connection.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/EmailUtils.cpp b/src/Messaging/EmailUtils.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/EventGetMessagingService.h b/src/Messaging/EventGetMessagingService.h index b162748..3d5a60f 100755 --- a/src/Messaging/EventGetMessagingService.h +++ b/src/Messaging/EventGetMessagingService.h @@ -22,13 +22,14 @@ #include #include #include +#include #include "IMessagingService.h" #include "IMessagingTypes.h" namespace DeviceAPI { namespace Messaging { -class EventGetMessagingService: public WrtDeviceApis::Commons::IEvent +class EventGetMessagingService: public WrtDeviceApis::Commons::IEvent, public DeviceAPI::Common::SecurityAccessor { public: @@ -105,4 +106,4 @@ typedef DPL::SharedPtr EventGetMessagingServicePtr; } // Messaging } // DeviceAPI -#endif //WRTPLUGINS_API_GET_MESSAGING_SERVICE_EVENT_MESSAGING_H_ \ No newline at end of file +#endif //WRTPLUGINS_API_GET_MESSAGING_SERVICE_EVENT_MESSAGING_H_ diff --git a/src/Messaging/FolderQueryGenerator.cpp b/src/Messaging/FolderQueryGenerator.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/IAttachment.cpp b/src/Messaging/IAttachment.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/IBinarySms.cpp b/src/Messaging/IBinarySms.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/IEmail.cpp b/src/Messaging/IEmail.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/IMessage.cpp b/src/Messaging/IMessage.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/IMessagingService.cpp b/src/Messaging/IMessagingService.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/IMms.cpp b/src/Messaging/IMms.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/ISms.cpp b/src/Messaging/ISms.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/JSConversation.cpp b/src/Messaging/JSConversation.cpp old mode 100644 new mode 100755 diff --git a/src/Messaging/JSMessage.h b/src/Messaging/JSMessage.h old mode 100644 new mode 100755 diff --git a/src/Messaging/JSMessagingService.cpp b/src/Messaging/JSMessagingService.cpp index 5205242..f9e32eb 100644 --- a/src/Messaging/JSMessagingService.cpp +++ b/src/Messaging/JSMessagingService.cpp @@ -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(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(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(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(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(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(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); diff --git a/src/Messaging/JSMessagingService.h b/src/Messaging/JSMessagingService.h index 831cd18..7b52f16 100755 --- a/src/Messaging/JSMessagingService.h +++ b/src/Messaging/JSMessagingService.h @@ -20,12 +20,29 @@ #include #include +#include #include "IMessagingService.h" namespace DeviceAPI { namespace Messaging { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSMessagingServicePriv; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSMessagingServicePrivObject; + +class JSMessagingServicePriv : + public JSMessagingServicePrivObject, + public DeviceAPI::Common::SecurityAccessor +{ +public: + JSMessagingServicePriv(JSContextRef context, IMessagingServicePtr messagingService) : + JSMessagingServicePrivObject(context, messagingService), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~JSMessagingServicePriv() + { + } +}; class JSMessagingService { @@ -33,7 +50,7 @@ public : static const JSClassDefinition* getClassInfo(); static const JSClassRef getClassRef(); - static JSObjectRef createJSObject(JSContextRef context, const IMessagingServicePtr &messagingService); + static JSObjectRef createJSObject(JSContextRef context, const IMessagingServicePtr &messagingService, const DeviceAPI::Common::SecurityAccessor *securityAccessor); private : diff --git a/src/Messaging/JSMessagingServiceManager.cpp b/src/Messaging/JSMessagingServiceManager.cpp index a64a316..62ff869 100644 --- a/src/Messaging/JSMessagingServiceManager.cpp +++ b/src/Messaging/JSMessagingServiceManager.cpp @@ -182,6 +182,7 @@ JSValueRef JSMessagingServiceManager::getMessagingServices(JSContextRef context, event->setEventType(EventGetMessagingService::MESSAGING_SERVICE_MANAGER_EVENT_TYPE_ALL); event->setMessagingServiceType(messagingType); + event->copyAceCheckAccessFunction(priv); messagingServiceManager->getMessagingServiceManager(event); //call postEvent MessageAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, gContext); diff --git a/src/Messaging/JSMessagingServiceManager.h b/src/Messaging/JSMessagingServiceManager.h index 80e2ee8..9b8f65d 100755 --- a/src/Messaging/JSMessagingServiceManager.h +++ b/src/Messaging/JSMessagingServiceManager.h @@ -20,12 +20,29 @@ #include #include +#include #include "IMessagingServiceManager.h" namespace DeviceAPI { namespace Messaging { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSMessagingServiceManagerPriv; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type JSMessagingServiceManagerPrivObject; + +class JSMessagingServiceManagerPriv : + public JSMessagingServiceManagerPrivObject, + public DeviceAPI::Common::SecurityAccessor +{ +public: + JSMessagingServiceManagerPriv(JSContextRef context, IMessagingServiceManagerPtr messagingServiceManager) : + JSMessagingServiceManagerPrivObject(context, messagingServiceManager), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~JSMessagingServiceManagerPriv() + { + } +}; class JSMessagingServiceManager { public: diff --git a/src/Messaging/JSMessagingStorage.cpp b/src/Messaging/JSMessagingStorage.cpp index 6ea7dd9..35a82d4 100644 --- a/src/Messaging/JSMessagingStorage.cpp +++ b/src/Messaging/JSMessagingStorage.cpp @@ -43,7 +43,7 @@ #include "MessagingErrorMsg.h" #include "MessageAsyncCallbackManager.h" #include "MessageFilterConverter.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" using namespace std; @@ -181,11 +181,6 @@ JSValueRef JSMessagingStorage::addDraftMessage(JSContextRef context, JSObjectRef { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -193,6 +188,9 @@ JSValueRef JSMessagingStorage::addDraftMessage(JSContextRef context, JSObjectRef return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -279,11 +277,6 @@ JSValueRef JSMessagingStorage::findMessages(JSContextRef context, JSObjectRef ob LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_MESSAGES]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -291,6 +284,9 @@ JSValueRef JSMessagingStorage::findMessages(JSContextRef context, JSObjectRef ob return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_FIND_MESSAGES); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -401,11 +397,6 @@ JSValueRef JSMessagingStorage::removeMessages(JSContextRef context, JSObjectRef { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_MESSAGES]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -413,6 +404,9 @@ JSValueRef JSMessagingStorage::removeMessages(JSContextRef context, JSObjectRef return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_REMOVE_MESSAGES); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -506,11 +500,6 @@ JSValueRef JSMessagingStorage::updateMessages(JSContextRef context, JSObjectRef LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_UPDATE_MESSAGES]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -518,6 +507,9 @@ JSValueRef JSMessagingStorage::updateMessages(JSContextRef context, JSObjectRef return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_UPDATE_MESSAGES); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -611,11 +603,6 @@ JSValueRef JSMessagingStorage::findConversations(JSContextRef context, JSObjectR { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_CONVERSATIONS]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -623,6 +610,9 @@ JSValueRef JSMessagingStorage::findConversations(JSContextRef context, JSObjectR return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_FIND_CONVERSATIONS); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -733,11 +723,6 @@ JSValueRef JSMessagingStorage::removeConversations(JSContextRef context, JSObjec { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -745,6 +730,9 @@ JSValueRef JSMessagingStorage::removeConversations(JSContextRef context, JSObjec return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -838,11 +826,6 @@ JSValueRef JSMessagingStorage::findFolders(JSContextRef context, JSObjectRef obj { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_FOLDERS]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -850,6 +833,9 @@ JSValueRef JSMessagingStorage::findFolders(JSContextRef context, JSObjectRef obj return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_FIND_FOLDERS); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -940,11 +926,6 @@ JSValueRef JSMessagingStorage::addMessagesChangeListener(JSContextRef context, J LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -952,6 +933,9 @@ JSValueRef JSMessagingStorage::addMessagesChangeListener(JSContextRef context, J return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -1073,11 +1057,6 @@ JSValueRef JSMessagingStorage::addConversationsChangeListener(JSContextRef conte { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -1085,6 +1064,9 @@ JSValueRef JSMessagingStorage::addConversationsChangeListener(JSContextRef conte return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -1209,11 +1191,6 @@ JSValueRef JSMessagingStorage::addFoldersChangeListener(JSContextRef context, JS { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -1221,6 +1198,9 @@ JSValueRef JSMessagingStorage::addFoldersChangeListener(JSContextRef context, JS return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); @@ -1342,11 +1322,6 @@ JSValueRef JSMessagingStorage::removeChangeListener(JSContextRef context, JSObje { LoggerD("Entered"); - //check permission. - AceSecurityStatus status = MESSAGING_CHECK_ACCESS( - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER]); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - MessagingStoragePriv* priv = static_cast(JSObjectGetPrivate(thisObject)); if (!priv) { LoggerE("Private object is NULL."); @@ -1354,6 +1329,9 @@ JSValueRef JSMessagingStorage::removeChangeListener(JSContextRef context, JSObje return JSWebAPIErrorFactory::postException(context, exception, err); } + //check permission. + TIZEN_CHECK_ACCESS(context, exception, priv, MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER); + MessagingStoragePrivObjPtr objectPriv = priv->getObject(); if (!objectPriv) { LoggerE("objectPriv is NULL."); diff --git a/src/Messaging/JSMessagingStorage.h b/src/Messaging/JSMessagingStorage.h index 6ebaac6..39f05a4 100755 --- a/src/Messaging/JSMessagingStorage.h +++ b/src/Messaging/JSMessagingStorage.h @@ -20,6 +20,7 @@ #include #include +#include #include "MessagingListener.h" @@ -47,7 +48,23 @@ int getType() const typedef DPL::SharedPtr MessagingStoragePrivObjPtr; -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject MessagingStoragePriv; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT::Type MessagingStoragePrivObject; + +class MessagingStoragePriv : + public MessagingStoragePrivObject, + public DeviceAPI::Common::SecurityAccessor +{ +public: + MessagingStoragePriv(JSContextRef context, MessagingStoragePrivObjPtr messageStorage) : + MessagingStoragePrivObject(context, messageStorage), + DeviceAPI::Common::SecurityAccessor() + { + } + + virtual ~MessagingStoragePriv() + { + } +}; class JSMessagingStorage { public: diff --git a/src/Messaging/MessagingController.cpp b/src/Messaging/MessagingController.cpp index 36f7a72..a28ac1c 100644 --- a/src/Messaging/MessagingController.cpp +++ b/src/Messaging/MessagingController.cpp @@ -84,7 +84,7 @@ void MessagingController::OnAnswerReceived(const EventGetMessagingServicePtr &ev for (index = 0; index < count; index++) { - jsMessagingServiceObject[index] = JSMessagingService::createJSObject(callbackManager->getContext(), messagingServices[index] ); + jsMessagingServiceObject[index] = JSMessagingService::createJSObject(callbackManager->getContext(), messagingServices[index], event.Get() ); } JSObjectRef result = JSObjectMakeArray(callbackManager->getContext(), count, jsMessagingServiceObject, NULL); diff --git a/src/Messaging/config.xml b/src/Messaging/config.xml index cccb790..1ea152e 100755 --- a/src/Messaging/config.xml +++ b/src/Messaging/config.xml @@ -3,6 +3,9 @@ libwrt-plugins-tizen-messaging.so messaging.install.uri + SAMSUNG plugin group + SAMSUNG certificate authority + AAAABBBBCCCCDDDEEEE0000 diff --git a/src/Messaging/log.h b/src/Messaging/log.h old mode 100644 new mode 100755 diff --git a/src/Messaging/plugin_config.cpp b/src/Messaging/plugin_config.cpp index f7c0bd6..7ccef86 100755 --- a/src/Messaging/plugin_config.cpp +++ b/src/Messaging/plugin_config.cpp @@ -36,39 +36,11 @@ namespace Messaging { using namespace WrtDeviceApis::Commons; -#pragma GCC visibility push(default) - -const char* MessagingExportedNames[] = -{ - "getMessageServices", - "createMessage", - "sendMessage", - "loadMessageBody", - "loadMessageAttachment", - "sync", - "syncFolder", - "cancelOperation", - "addDraftMessage", - "findMessages", - "removeMessages", - "updateMessages", - "findConversations", - "removeConversations", - "findFolders", - "addMessagesChangeListener", - "addConversationsChangeListener", - "addFoldersChangeListener", - "removeChangeListener" -}; - static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions(); static WrtDeviceApis::Commons::FunctionMapping MessagingFunctions = createMessagingFunctions(); - DEFINE_FUNCTION_GETTER(Messaging, MessagingFunctions); -#pragma GCC visibility pop - static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions() { /** @@ -140,12 +112,12 @@ static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions() //get Message Service AceFunction getMessagingServiceFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE], + MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE, MESSAGING_FEATURES_MESSAGING_READ_SEND_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert(std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE], + MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE, getMessagingServiceFunc)); /** Read **/ @@ -153,82 +125,82 @@ static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions() AceFunction cancelOpFolderFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_CANCEL_OPERATION], + MESSAGING_FUNCTION_API_CANCEL_OPERATION, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_CANCEL_OPERATION], + MESSAGING_FUNCTION_API_CANCEL_OPERATION, cancelOpFolderFunc)); AceFunction findMessagesFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_MESSAGES], + MESSAGING_FUNCTION_API_FIND_MESSAGES, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_MESSAGES], + MESSAGING_FUNCTION_API_FIND_MESSAGES, findMessagesFunc)); AceFunction findConversationsFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_CONVERSATIONS], + MESSAGING_FUNCTION_API_FIND_CONVERSATIONS, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_CONVERSATIONS], + MESSAGING_FUNCTION_API_FIND_CONVERSATIONS, findConversationsFunc)); AceFunction findFoldersFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_FOLDERS], + MESSAGING_FUNCTION_API_FIND_FOLDERS, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_FOLDERS], + MESSAGING_FUNCTION_API_FIND_FOLDERS, findFoldersFunc)); AceFunction addMessagesChangeListenerFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER], + MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER], + MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER, addMessagesChangeListenerFunc)); AceFunction addConversationsChangeListenerFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER], + MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER], + MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER, addConversationsChangeListenerFunc)); AceFunction addFoldersChangeListenerFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER], + MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER], + MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER, addFoldersChangeListenerFunc)); AceFunction removeChangeListenerFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER], + MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER, MESSAGING_FEATURES_MESSAGING_READ, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER], + MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER, removeChangeListenerFunc)); @@ -236,116 +208,116 @@ static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions() //create Message AceFunction createMessageFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_CREATE_MESSAGE], + MESSAGING_FUNCTION_API_CREATE_MESSAGE, MESSAGING_FEATURES_MESSAGING_SEND, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_CREATE_MESSAGE], + MESSAGING_FUNCTION_API_CREATE_MESSAGE, createMessageFunc)); // before sendMessage move to write privilege start AceFunction sendMessageFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_SEND_MESSAGE], + MESSAGING_FUNCTION_API_SEND_MESSAGE, MESSAGING_FEATURES_MESSAGING_SEND_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_SEND_MESSAGE], + MESSAGING_FUNCTION_API_SEND_MESSAGE, sendMessageFunc)); // before sendMessage move to write privilege end /** Write **/ AceFunction loadMessageBodyFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY], + MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY], + MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY, loadMessageBodyFunc)); AceFunction loadMessageAttachmentFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT], + MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT], + MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT, loadMessageAttachmentFunc)); AceFunction syncFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC], + MESSAGING_FUNCTION_API_SYNC, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC], + MESSAGING_FUNCTION_API_SYNC, syncFunc)); AceFunction syncFolderFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER], + MESSAGING_FUNCTION_API_SYNC_FOLDER, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER], + MESSAGING_FUNCTION_API_SYNC_FOLDER, syncFolderFunc)); AceFunction addDraftMessageFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE], + MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE], + MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE, addDraftMessageFunc)); AceFunction removeMessagesFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_MESSAGES], + MESSAGING_FUNCTION_API_REMOVE_MESSAGES, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_MESSAGES], + MESSAGING_FUNCTION_API_REMOVE_MESSAGES, removeMessagesFunc)); AceFunction removeConversationsFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS], + MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS], + MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS, removeConversationsFunc)); AceFunction updateMessagesFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_UPDATE_MESSAGES], + MESSAGING_FUNCTION_API_UPDATE_MESSAGES, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_UPDATE_MESSAGES], + MESSAGING_FUNCTION_API_UPDATE_MESSAGES, updateMessagesFunc)); // before sendMessage move to write privilege start /* AceFunction sendMessageFunc = ACE_CREATE_FUNCTION( FUNCTION_GET_MGR_SERVICE, - MessagingExportedNames[MESSAGING_FUNCTION_API_SEND_MESSAGE], + MESSAGING_FUNCTION_API_SEND_MESSAGE, MESSAGING_FEATURES_MESSAGING_WRITE, EMPTY_DEVICE_LIST); MessagingFunctions.insert( std::make_pair( - MessagingExportedNames[MESSAGING_FUNCTION_API_SEND_MESSAGE], + MESSAGING_FUNCTION_API_SEND_MESSAGE, sendMessageFunc)); */ // before sendMessage move to write privilege end diff --git a/src/Messaging/plugin_config.h b/src/Messaging/plugin_config.h index 546d379..0163eea 100755 --- a/src/Messaging/plugin_config.h +++ b/src/Messaging/plugin_config.h @@ -19,35 +19,11 @@ #define _MESSAGING_PLUGIN_CONFIG_H_ #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace Messaging { -typedef enum -{ -MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE = 0, -MESSAGING_FUNCTION_API_CREATE_MESSAGE, -MESSAGING_FUNCTION_API_SEND_MESSAGE, -MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY, -MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT, -MESSAGING_FUNCTION_API_SYNC, -MESSAGING_FUNCTION_API_SYNC_FOLDER, -MESSAGING_FUNCTION_API_CANCEL_OPERATION, -MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE, -MESSAGING_FUNCTION_API_FIND_MESSAGES, -MESSAGING_FUNCTION_API_REMOVE_MESSAGES, -MESSAGING_FUNCTION_API_UPDATE_MESSAGES, -MESSAGING_FUNCTION_API_FIND_CONVERSATIONS, -MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS, -MESSAGING_FUNCTION_API_FIND_FOLDERS, -MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER, -MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER, -MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER, -MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER -} MessagingFuncNames; - -extern const char* MessagingExportedNames[]; - DECLARE_FUNCTION_GETTER(Messaging); #define MESSAGING_CHECK_ACCESS(functionName) \ @@ -58,5 +34,4 @@ DECLARE_FUNCTION_GETTER(Messaging); } } -#endif //MESSAGING_PLUGIN_CONFIG_H_ - +#endif // _MESSAGING_PLUGIN_CONFIG_H_ diff --git a/src/Messaging/plugin_config_impl.h b/src/Messaging/plugin_config_impl.h new file mode 100755 index 0000000..ff8657b --- /dev/null +++ b/src/Messaging/plugin_config_impl.h @@ -0,0 +1,41 @@ +// +// 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. +// + +#ifndef _MESSAGING_PLUGIN_CONFIG_IMPL_H_ +#define _MESSAGING_PLUGIN_CONFIG_IMPL_H_ + +#define MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE "getMessageServices" +#define MESSAGING_FUNCTION_API_CREATE_MESSAGE "createMessage" +#define MESSAGING_FUNCTION_API_SEND_MESSAGE "sendMessage" +#define MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY "loadMessageBody" +#define MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT "loadMessageAttachment" +#define MESSAGING_FUNCTION_API_SYNC "sync" +#define MESSAGING_FUNCTION_API_SYNC_FOLDER "syncFolder" +#define MESSAGING_FUNCTION_API_CANCEL_OPERATION "cancelOperation" +#define MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE "addDraftMessage" +#define MESSAGING_FUNCTION_API_FIND_MESSAGES "findMessages" +#define MESSAGING_FUNCTION_API_REMOVE_MESSAGES "removeMessages" +#define MESSAGING_FUNCTION_API_UPDATE_MESSAGES "updateMessages" +#define MESSAGING_FUNCTION_API_FIND_CONVERSATIONS "findConversations" +#define MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS "removeConversations" +#define MESSAGING_FUNCTION_API_FIND_FOLDERS "findFolders" +#define MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER "addMessagesChangeListener" +#define MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER "addConversationsChangeListener" +#define MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER "addFoldersChangeListener" +#define MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER "removeChangeListener" + +#endif // _MESSAGING_PLUGIN_CONFIG_IMPL_H_ diff --git a/src/Messaging/plugin_initializer.cpp b/src/Messaging/plugin_initializer.cpp old mode 100644 new mode 100755 index 016421e..ede803d --- a/src/Messaging/plugin_initializer.cpp +++ b/src/Messaging/plugin_initializer.cpp @@ -23,6 +23,7 @@ #include "JSMessageAttachment.h" #include "MessageAsyncCallbackManager.h" #include "MessageListenerManager.h" +#include "plugin_config.h" #include #include @@ -32,14 +33,27 @@ namespace DeviceAPI { namespace Messaging { +using namespace WrtDeviceApis; +using namespace WrtDeviceApis::Commons; + +AceSecurityStatus messagingAceCheckAccessFunction(const char* functionName) +{ + return MESSAGING_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerMessagingSetter, JSMessagingServiceManagerPriv, gSecurityAccessor); + namespace Options{ class_definition_options_t MessagingOptions = { JS_CLASS, CREATE_INSTANCE, - NONE_NOTICE, + ALWAYS_NOTICE, USE_OVERLAYED, //ignored + AceCheckerMessagingSetter, NULL, NULL }; @@ -56,9 +70,6 @@ class_definition_options_t MessagingInterfaceOptions = { } -using namespace WrtDeviceApis; -using namespace WrtDeviceApis::Commons; - void on_widget_start_callback(int widgetId) { LoggerD("[Tizen\\MessagingServiceManager] on_widget_start_callback ("< #include #include +#include namespace DeviceAPI { namespace NFC { -class EventNFCChangedPrivateData : public WrtDeviceApis::Commons::IEventPrivateData +class EventNFCChangedPrivateData : public WrtDeviceApis::Commons::IEventPrivateData, + public DeviceAPI::Common::SecurityAccessor { public: EventNFCChangedPrivateData(const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr& callbackManager, diff --git a/src/NFC/JSNFCAdapter.cpp b/src/NFC/JSNFCAdapter.cpp index 5805a85..8f4cf70 100755 --- a/src/NFC/JSNFCAdapter.cpp +++ b/src/NFC/JSNFCAdapter.cpp @@ -40,7 +40,7 @@ #include "NFCListenerManager.h" #include "NFCFactory.h" #include "EventNFCChanged.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include using namespace std; @@ -108,7 +108,7 @@ void JSNFCAdapter::finalize(JSObjectRef object) JSObjectSetPrivate(object, NULL); } -JSObjectRef JSNFCAdapter::createJSObject(JSContextRef context) { +JSObjectRef JSNFCAdapter::createJSObject(JSContextRef context, NFCManagerPrivObject *nfcManagerPriv) { LoggerD("entered"); INFCAdapterPtr nfcAdapter(NFCFactory::getInstance().createNFCAdapterObject()); @@ -118,6 +118,7 @@ JSObjectRef JSNFCAdapter::createJSObject(JSContextRef context) { ThrowMsg(NullPointerException, "Can not new a NFCTag object"); } + priv->copyAceCheckAccessFunction(nfcManagerPriv); return JSObjectMake(context, getClassRef(), priv); } @@ -173,9 +174,15 @@ JSValueRef JSNFCAdapter::setTagListener (JSContextRef context, JSObjectRef objec JSValueRef* exception) { LoggerD("JSNFCAdapter::setTagListener Enter"); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); + NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); + if (!privateObject) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); + } + + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_TAG_FUNCS); + Try { ArgumentValidator validator(context, argumentCount, arguments); NFCChangedCallback callbacks; @@ -184,7 +191,8 @@ JSValueRef JSNFCAdapter::setTagListener (JSContextRef context, JSObjectRef objec callbacks = nfcConverter.toNFCChangedCallback(arguments[0]); std::vector filterValue = validator.toStringVector(1, true); - + + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, callbacks.onattach, NULL, true, true); JSCallbackManagerPtr detachedCallbackManager = JSCallbackManager::createObject(global_context, callbacks.ondetach, NULL); TagFilterPtr tagFilter(new TagFilter()); @@ -195,18 +203,14 @@ JSValueRef JSNFCAdapter::setTagListener (JSContextRef context, JSObjectRef objec LoggerD("tag_types.at(i): " << filterValue.at(i)); } - NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); - if (!privateObject) { - LoggerE("private object is null"); - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); - } - INFCAdapterPtr nfcAdapter(privateObject->getObject()); EventNFCChangedPrivateDataPtr privateData( new EventNFCChangedPrivateData(callbackManager, detachedCallbackManager) ); + privateData->copyAceCheckAccessFunction(privateObject); + EventNFCChangedEmitterPtr emitter(new EventNFCChangedEmitter); emitter->setListener(&NFCStaticController::getInstance()); emitter->setEventPrivateData(DPL::StaticPointerCast(privateData)); @@ -241,10 +245,14 @@ JSValueRef JSNFCAdapter::setPeerListener (JSContextRef context, JSObjectRef obje JSValueRef* exception) { LoggerD("JSNFCAdapter::setPeerListener Enter"); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); + if (!privateObject) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); + } - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_P2P_FUNCS); Try { ArgumentValidator validator(context, argumentCount, arguments); @@ -254,16 +262,11 @@ JSValueRef JSNFCAdapter::setPeerListener (JSContextRef context, JSObjectRef obje if (validator.toObject(0)) callbacks = nfcConverter.toNFCChangedCallback(arguments[0]); - + + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, callbacks.onattach, NULL, true, true); JSCallbackManagerPtr detachedCallbackManager = JSCallbackManager::createObject(global_context, callbacks.ondetach, NULL); - NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); - if (!privateObject) { - LoggerE("private object is null"); - return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); - } - INFCAdapterPtr nfcAdapter(privateObject->getObject()); EventNFCChangedPrivateDataPtr privateData( @@ -271,6 +274,7 @@ JSValueRef JSNFCAdapter::setPeerListener (JSContextRef context, JSObjectRef obje detachedCallbackManager) ); + privateData->copyAceCheckAccessFunction(privateObject); EventNFCChangedEmitterPtr emitter(new EventNFCChangedEmitter); emitter->setListener(&NFCStaticController::getInstance()); emitter->setEventPrivateData(DPL::StaticPointerCast(privateData)); @@ -303,15 +307,15 @@ JSValueRef JSNFCAdapter::unsetTagListener(JSContextRef context, JSObjectRef obje size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LoggerD("JSNFCAdapter::unsetNFCTagListener Enter"); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_TAG_FUNCS); + Try { INFCAdapterPtr nfcAdapter(privateObject->getObject()); @@ -337,17 +341,16 @@ JSValueRef JSNFCAdapter::unsetPeerListener(JSContextRef context, JSObjectRef obj size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { LoggerD("JSNFCAdapter::unsetPeerListener Enter"); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_P2P_FUNCS); Try { - INFCAdapterPtr nfcAdapter( privateObject->getObject() ); + INFCAdapterPtr nfcAdapter( privateObject->getObject()); nfcAdapter->unsetPeerListener(); @@ -372,21 +375,22 @@ JSValueRef JSNFCAdapter::getCachedMessage (JSContextRef context, JSObjectRef obj JSValueRef* exception) { LoggerD("JSNFCAdapter::getCachedMessage Enter"); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_COMMON_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_COMMON_FUNCS); + Try { INFCAdapterPtr nfcAdapter(privateObject->getObject()); void *cachedMessage = nfcAdapter->getCachedMessage(); - if (cachedMessage != NULL) + if (cachedMessage != NULL) { + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); return JSNdefMessage::createJSObject(global_context, cachedMessage); + } return JSValueMakeNull(context); } Catch (WrtDeviceApis::Commons::UnknownException) { LoggerE("Exception: " << _rethrown_exception.GetMessage()); @@ -407,18 +411,16 @@ JSValueRef JSNFCAdapter::setPowered (JSContextRef context, JSObjectRef object, JSValueRef* exception) { LoggerD("Enter"); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_ADMIN_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCAdapterPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } - INFCAdapterPtr nfcAdapter(privateObject->getObject()); + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_ADMIN_FUNCS); + + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, NULL, NULL, true, true); Try { @@ -433,12 +435,11 @@ JSValueRef JSNFCAdapter::setPowered (JSContextRef context, JSObjectRef object, if (validator.toFunction(2, true)) callbackManager->setOnError(arguments[2]); - NFCConverter nfcConverter(context); - EventNFCChangedSetPoweredPtr event(new EventNFCChangedSetPowered(state)); - event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); + event->setPrivateData(DPL::StaticPointerCast(callbackManager) ); event->setForAsynchronousCall(&NFCStaticController::getInstance()); callbackManager->setObject(thisObject); + INFCAdapterPtr nfcAdapter(privateObject->getObject()); nfcAdapter->setPowered(event); NFCAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, global_context); return JSValueMakeUndefined(context); diff --git a/src/NFC/JSNFCAdapter.h b/src/NFC/JSNFCAdapter.h index f910f18..bf71a72 100755 --- a/src/NFC/JSNFCAdapter.h +++ b/src/NFC/JSNFCAdapter.h @@ -22,12 +22,30 @@ #include #include +#include #include "INFCAdapter.h" +#include "JSNFCManager.h" namespace DeviceAPI { namespace NFC { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCAdapterPrivObject; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCAdapterPrivObjectBase; +class NFCAdapterPrivObject : + public DeviceAPI::Common::SecurityAccessor, + public NFCAdapterPrivObjectBase +{ +public: + NFCAdapterPrivObject(JSContextRef context, INFCAdapterPtr adapter) : + DeviceAPI::Common::SecurityAccessor(), + NFCAdapterPrivObjectBase(context, adapter) + { + } + + virtual ~ NFCAdapterPrivObject() + { + } +}; + class JSNFCAdapter { public: @@ -36,7 +54,7 @@ public: static const JSClassRef getClassRef(); - static JSObjectRef createJSObject(JSContextRef context); + static JSObjectRef createJSObject(JSContextRef context, NFCManagerPrivObject *nfcManagerPriv); private: /** * This member variable contains the values which has to be passed when diff --git a/src/NFC/JSNFCManager.cpp b/src/NFC/JSNFCManager.cpp index 7869f67..1264ed0 100755 --- a/src/NFC/JSNFCManager.cpp +++ b/src/NFC/JSNFCManager.cpp @@ -27,7 +27,7 @@ #include "JSNFCAdapter.h" #include "NFCConverter.h" #include "NFCFactory.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "NFCDefaultAdapter.h" #include @@ -184,15 +184,16 @@ JSValueRef JSNFCManager::getDefaultAdapter (JSContextRef context, JSObjectRef ob LoggerD("Enter"); Try { - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_COMMON_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - NFCManagerPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { LoggerE("private object is null"); ThrowMsg(UnsupportedException, "private object is null"); } - return JSNFCAdapter::createJSObject(GlobalContextManager::getInstance()->getGlobalContext(context)); + + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_COMMON_FUNCS); + + return JSNFCAdapter::createJSObject(GlobalContextManager::getInstance()->getGlobalContext(context), privateObject); } Catch (UnsupportedException) { LoggerE("UnsupportedException: " << _rethrown_exception.GetMessage()); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, "Not Supported"); @@ -222,18 +223,20 @@ JSValueRef JSNFCManager::setExclusiveMode (JSContextRef context, JSObjectRef obj LoggerD("Enter"); Try { - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_COMMON_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - ArgumentValidator validator(context, argumentCount, arguments); - // mode - bool mode = validator.toBool(0); - LoggerD("mode : " << mode); NFCManagerPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (!privateObject) { LoggerE("private object is null"); throw TypeMismatchException("private object is null"); } + + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_COMMON_FUNCS); + + ArgumentValidator validator(context, argumentCount, arguments); + // mode + bool mode = validator.toBool(0); + LoggerD("mode : " << mode); + NFCDefaultAdapterSingleton::Instance().setExclusiveMode(mode); return JSValueMakeUndefined(context); } Catch (BasePlatformException) { diff --git a/src/NFC/JSNFCManager.h b/src/NFC/JSNFCManager.h index f8eae26..c5082b3 100755 --- a/src/NFC/JSNFCManager.h +++ b/src/NFC/JSNFCManager.h @@ -22,12 +22,29 @@ #include #include +#include #include "INFCAdapter.h" namespace DeviceAPI { namespace NFC { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCManagerPrivObject; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCManagerPrivObjectBase; +class NFCManagerPrivObject : + public DeviceAPI::Common::SecurityAccessor, + public NFCManagerPrivObjectBase +{ +public: + NFCManagerPrivObject(JSContextRef context) : + DeviceAPI::Common::SecurityAccessor(), + NFCManagerPrivObjectBase(context) + { + } + + virtual ~NFCManagerPrivObject() + { + } +}; + class JSNFCManager { public: diff --git a/src/NFC/JSNFCTag.cpp b/src/NFC/JSNFCTag.cpp index 62dc324..128eae6 100755 --- a/src/NFC/JSNFCTag.cpp +++ b/src/NFC/JSNFCTag.cpp @@ -34,7 +34,7 @@ #include "NFCFactory.h" #include "EventTagAction.h" #include "NFCAsyncCallbackManager.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include using namespace DeviceAPI::Common; @@ -99,7 +99,7 @@ JSStaticFunction JSNFCTag::m_function[] = { JSClassRef JSNFCTag::m_jsClassRef = JSClassCreate(JSNFCTag::getClassInfo()); -JSObjectRef JSNFCTag::createJSObject(JSContextRef context, void *tagHandle) { +JSObjectRef JSNFCTag::createJSObject(JSContextRef context, void *tagHandle, EventNFCChangedPrivateDataPtr eventNFCChangedPriv) { LoggerD("entered"); INFCTagPtr nfcTag = NFCFactory::getInstance().createNFCTagObject(tagHandle); @@ -110,6 +110,7 @@ JSObjectRef JSNFCTag::createJSObject(JSContextRef context, void *tagHandle) { ThrowMsg(NullPointerException, "Can not new a NFCTag object"); } + priv->copyAceCheckAccessFunction(eventNFCChangedPriv.Get()); return JSObjectMake(context, getClassRef(), priv); } @@ -199,18 +200,16 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context, { LoggerD("Entered "); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCTagPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (NULL == privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } - INFCTagPtr nfcTag(privateObject->getObject()); + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_TAG_FUNCS); + + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, NULL, NULL, true, true); Try { @@ -224,9 +223,10 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context, callbackManager->setOnError(arguments[1]); EventTagActionReadPtr event(new EventTagActionRead()); - event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); + event->setPrivateData(DPL::StaticPointerCast(callbackManager) ); event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance()); callbackManager->setObject(thisObject); + INFCTagPtr nfcTag(privateObject->getObject()); nfcTag->readNdef(event); NFCAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, global_context); return JSValueMakeUndefined(context); @@ -266,18 +266,16 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context, { LoggerD("Entered "); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCTagPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (NULL == privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } - INFCTagPtr nfcTag(privateObject->getObject()); + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_TAG_FUNCS); + + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, NULL, NULL, true, true); Try { ArgumentValidator validator(context, argumentCount, arguments); @@ -292,8 +290,6 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context, callbackManager->setOnError(arguments[2]); EventTagActionWritePtr event(new EventTagActionWrite()); - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCConverter convert(global_context); void *messageHandle = NULL; try { NdefMessagePrivObject* ndefMessagePrivateObj = static_cast(JSObjectGetPrivate(ndefMessageObj)); @@ -303,6 +299,7 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context, } INdefMessagePtr ndefMessage(ndefMessagePrivateObj->getObject()); JSValueRef recordsValue = (ndefMessage->mLocalProperty).getProperty(global_context, TIZEN_NDEFMESSAGE_RECORDS); + NFCConverter convert(global_context); std::vector records = convert.toVectorOfRecordHandles(recordsValue); messageHandle = ndefMessage->makeNdefMessageHandle(records); } catch (WrtDeviceApis::Commons::Exception& err) { @@ -313,9 +310,10 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context, ThrowMsg(InvalidArgumentException, "Invalid NDEF Message"); event->writeNdef(messageHandle); - event->setPrivateData( DPL::StaticPointerCast(callbackManager)); + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance()); callbackManager->setObject(thisObject); + INFCTagPtr nfcTag(privateObject->getObject()); nfcTag->writeNdef(event); NFCAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, global_context); return JSValueMakeUndefined(context); @@ -355,18 +353,16 @@ JSValueRef JSNFCTag::transceive(JSContextRef context, { LoggerD("Entered "); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCTagPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (NULL == privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } - INFCTagPtr nfcTag(privateObject->getObject()); + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_TAG_FUNCS); + + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, NULL, NULL, true, true); Try { ArgumentValidator validator(context, argumentCount, arguments); @@ -382,14 +378,16 @@ JSValueRef JSNFCTag::transceive(JSContextRef context, callbackManager->setOnError(arguments[2]); EventTagActionTransceivePtr event(new EventTagActionTransceive()); - NFCConverter convert(context); std::vector data; - if (dataObj) + if (dataObj) { + NFCConverter convert(context); data= convert.toVectorOfOctets(arguments[0]); + } event->transceive(data); event->setPrivateData( DPL::StaticPointerCast(callbackManager) ); event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance()); callbackManager->setObject(thisObject); + INFCTagPtr nfcTag(privateObject->getObject()); nfcTag->transceive(event); NFCAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, global_context); return JSValueMakeUndefined(context); diff --git a/src/NFC/JSNFCTag.h b/src/NFC/JSNFCTag.h index 6f50bef..393693a 100755 --- a/src/NFC/JSNFCTag.h +++ b/src/NFC/JSNFCTag.h @@ -22,12 +22,30 @@ #include #include +#include #include "INFCTag.h" +#include "EventNFCChangedPrivateData.h" + namespace DeviceAPI { namespace NFC { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCTagPrivObject; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCTagPrivObjectBase; +class NFCTagPrivObject : + public DeviceAPI::Common::SecurityAccessor, + public NFCTagPrivObjectBase +{ +public: + NFCTagPrivObject(JSContextRef context, INFCTagPtr nfcTag) : + DeviceAPI::Common::SecurityAccessor(), + NFCTagPrivObjectBase(context, nfcTag) + { + } + + virtual ~NFCTagPrivObject() + { + } +}; class JSNFCTag { @@ -37,7 +55,7 @@ public: static const JSClassRef getClassRef(); - static JSObjectRef createJSObject(JSContextRef context, void *tagHandle); + static JSObjectRef createJSObject(JSContextRef context, void *tagHandle, EventNFCChangedPrivateDataPtr eventNFCChangedPriv); private: /** diff --git a/src/NFC/JSNFCTarget.cpp b/src/NFC/JSNFCTarget.cpp index c1eaa88..b00b6c4 100755 --- a/src/NFC/JSNFCTarget.cpp +++ b/src/NFC/JSNFCTarget.cpp @@ -36,7 +36,7 @@ #include "NFCListenerManager.h" #include "NFCFactory.h" #include "EventTargetAction.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include @@ -90,7 +90,7 @@ JSStaticFunction JSNFCTarget::m_function[] = { JSClassRef JSNFCTarget::m_jsClassRef = JSClassCreate(JSNFCTarget::getClassInfo()); -JSObjectRef JSNFCTarget::createJSObject(JSContextRef context, void *tagHandle) { +JSObjectRef JSNFCTarget::createJSObject(JSContextRef context, void *tagHandle, EventNFCChangedPrivateDataPtr eventNFCChangedPriv) { LoggerD("entered"); INFCTargetPtr nfcTarget = NFCFactory::getInstance().createNFCTargetObject(tagHandle); @@ -101,6 +101,7 @@ JSObjectRef JSNFCTarget::createJSObject(JSContextRef context, void *tagHandle) { ThrowMsg(NullPointerException, "Can not new a NFCTarget object"); } + priv->copyAceCheckAccessFunction(eventNFCChangedPriv.Get()); return JSObjectMake(context, getClassRef(), priv); } @@ -179,18 +180,14 @@ JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context, { LoggerD("Entered "); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCTargetPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (NULL == privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } - - INFCTargetPtr nfcTarget(privateObject->getObject()); + + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_P2P_FUNCS); Try { ArgumentValidator validator(context, argumentCount, arguments); @@ -199,11 +196,13 @@ JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context, if (validator.toFunction(0)) onSuccessForCbm = arguments[0]; + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, onSuccessForCbm, NULL, true, true); EventTargetActionReceiveEmitterPtr emitter(new EventTargetActionReceiveEmitter); emitter->setListener(&NFCResponseDispatcher::getInstance()); emitter->setEventPrivateData(DPL::StaticPointerCast(callbackManager)); + INFCTargetPtr nfcTarget(privateObject->getObject()); nfcTarget->setReceiveNDEFListener(emitter); NFCListenerCancellerPtr canceller = NFCListenerCancellerPtr(new NFCListenerCanceller(global_context, thisObject, static_cast(ID_NFCPEER_RECEIVENDEF_LISTENER))); @@ -238,20 +237,19 @@ JSValueRef JSNFCTarget::unsetReceiveNDEFListener(JSContextRef context, { LoggerD("Entered "); Try { - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCTargetPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (NULL == privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_P2P_FUNCS); + INFCTargetPtr nfcTarget(privateObject->getObject()); nfcTarget->unsetReceiveNDEFListener(); + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); NFCListenerCancellerPtr canceller = NFCListenerCancellerPtr(new NFCListenerCanceller(global_context, thisObject, static_cast(ID_NFCPEER_RECEIVENDEF_LISTENER))); IListenerItemPtr listenerItem = DPL::StaticPointerCast(canceller); NFCListenerManagerSingleton::Instance().unregisterListener(listenerItem); @@ -281,20 +279,17 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context, { LoggerD("Entered "); - AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); - - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - - NFCConverter convert(context); - NFCTargetPrivObject* privateObject = static_cast(JSObjectGetPrivate(thisObject)); if (NULL == privateObject) { LoggerE("private object is null"); return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type Mismatch"); } - INFCTargetPtr nfcTarget(privateObject->getObject()); + TIZEN_CHECK_ACCESS(context, exception, privateObject, + NFC_FUNCTION_API_P2P_FUNCS); + + JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); + JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, NULL, NULL, true, true); Try { ArgumentValidator validator(context, argumentCount, arguments); @@ -308,8 +303,6 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context, if (validator.toFunction(2, true)) callbackManager->setOnError(arguments[2]); - JSContextRef global_context = GlobalContextManager::getInstance()->getGlobalContext(context); - NFCConverter convert(global_context); void *messageHandle = NULL; try { NdefMessagePrivObject* ndefMessagePrivateObj = static_cast(JSObjectGetPrivate(ndefMessageObj)); @@ -319,6 +312,7 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context, } INdefMessagePtr ndefMessage(ndefMessagePrivateObj->getObject()); JSValueRef recordsValue = (ndefMessage->mLocalProperty).getProperty(global_context, TIZEN_NDEFMESSAGE_RECORDS); + NFCConverter convert(global_context); std::vector records = convert.toVectorOfRecordHandles(recordsValue); messageHandle = ndefMessage->makeNdefMessageHandle(records); } catch (WrtDeviceApis::Commons::Exception& err) { @@ -330,8 +324,9 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context, EventTargetActionSendPtr event(new EventTargetActionSend(messageHandle)); callbackManager->setObject(thisObject); - event->setPrivateData( DPL::StaticPointerCast(callbackManager)); + event->setPrivateData(DPL::StaticPointerCast(callbackManager)); event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance()); + INFCTargetPtr nfcTarget(privateObject->getObject()); nfcTarget->sendNDEF(event); NFCAsyncCallbackManagerSingleton::Instance().registerCallbackManager(callbackManager, global_context); return JSValueMakeUndefined(context); diff --git a/src/NFC/JSNFCTarget.h b/src/NFC/JSNFCTarget.h index 482b0eb..7f3d17d 100755 --- a/src/NFC/JSNFCTarget.h +++ b/src/NFC/JSNFCTarget.h @@ -22,12 +22,29 @@ #include #include +#include +#include "EventNFCChangedPrivateData.h" #include "INFCTarget.h" namespace DeviceAPI { namespace NFC { -typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCTargetPrivObject; +typedef WrtDeviceApis::CommonsJavaScript::PrivateObject NFCTargetPrivObjectBase; +class NFCTargetPrivObject : + public DeviceAPI::Common::SecurityAccessor, + public NFCTargetPrivObjectBase +{ +public: + NFCTargetPrivObject(JSContextRef context, INFCTargetPtr nfcTarget) : + DeviceAPI::Common::SecurityAccessor(), + NFCTargetPrivObjectBase(context, nfcTarget) + { + } + + virtual ~NFCTargetPrivObject() + { + } +}; class JSNFCTarget { @@ -37,7 +54,7 @@ public: static const JSClassRef getClassRef(); - static JSObjectRef createJSObject(JSContextRef context, void *tagHandle); + static JSObjectRef createJSObject(JSContextRef context, void *tagHandle, EventNFCChangedPrivateDataPtr eventNFCChangedPriv); private: /** diff --git a/src/NFC/JSNdefMessage.cpp b/src/NFC/JSNdefMessage.cpp index da8e5a0..9020dd0 100755 --- a/src/NFC/JSNdefMessage.cpp +++ b/src/NFC/JSNdefMessage.cpp @@ -31,7 +31,6 @@ #include #include "NFCFactory.h" -#include "plugin_config.h" #include using namespace DeviceAPI::Common; diff --git a/src/NFC/JSNdefRecord.cpp b/src/NFC/JSNdefRecord.cpp index 2608aea..3a1abde 100755 --- a/src/NFC/JSNdefRecord.cpp +++ b/src/NFC/JSNdefRecord.cpp @@ -28,7 +28,6 @@ #include "NFCFactory.h" #include "JSNdefRecord.h" -#include "plugin_config.h" #include "NFCConverter.h" #include diff --git a/src/NFC/NFCStaticController.cpp b/src/NFC/NFCStaticController.cpp index dbdf43a..38c6d98 100755 --- a/src/NFC/NFCStaticController.cpp +++ b/src/NFC/NFCStaticController.cpp @@ -67,9 +67,9 @@ void NFCStaticController::onAnswerReceived(const EventNFCChangedPtr& event) { JSContextRef context = callbackManager->getContext(); if (event->getNFCType() == NFC_TAG_TYPE) - nfcObj = JSNFCTag::createJSObject(context, nfcProp); + nfcObj = JSNFCTag::createJSObject(context, nfcProp, privateData); else - nfcObj = JSNFCTarget::createJSObject(context, nfcProp); + nfcObj = JSNFCTarget::createJSObject(context, nfcProp, privateData); LoggerD("callOnSuccess"); callbackManager->callOnSuccess(static_cast(nfcObj)); } else { diff --git a/src/NFC/plugin_config.cpp b/src/NFC/plugin_config.cpp index 31d1ca2..fda5f11 100755 --- a/src/NFC/plugin_config.cpp +++ b/src/NFC/plugin_config.cpp @@ -39,23 +39,13 @@ namespace DeviceAPI { namespace NFC { -const char* NFC_FUNCTION_API_COMMON_FUNCS = "NFCCommonFunctions"; -const char* NFC_FUNCTION_API_ADMIN_FUNCS = "NFCAdminFunctions"; -const char* NFC_FUNCTION_API_TAG_FUNCS = "NFCTagFunctions"; -const char* NFC_FUNCTION_API_P2P_FUNCS = "NFCP2PFunctions"; -const char* NFC_FUNCTION_API_CARDEMULATION_FUNCS = "NFCCardEmulationFunctions"; - static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions(); static WrtDeviceApis::Commons::FunctionMapping NFCFunctions = createNFCFunctions(); -#pragma GCC visibility push(default) - DEFINE_FUNCTION_GETTER(NFC, NFCFunctions); -#pragma GCC visibility pop - static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions() { using namespace WrtDeviceApis::Commons; diff --git a/src/NFC/plugin_config.h b/src/NFC/plugin_config.h index 7f4190f..5388f9d 100755 --- a/src/NFC/plugin_config.h +++ b/src/NFC/plugin_config.h @@ -20,15 +20,11 @@ #define _NFC_PLUGIN_CONFIG_H_ #include +#include "plugin_config_impl.h" namespace DeviceAPI { namespace NFC { -extern const char* NFC_FUNCTION_API_COMMON_FUNCS; -extern const char* NFC_FUNCTION_API_ADMIN_FUNCS; -extern const char* NFC_FUNCTION_API_TAG_FUNCS; -extern const char* NFC_FUNCTION_API_P2P_FUNCS; -extern const char* NFC_FUNCTION_API_CARDEMULATION_FUNCS; DECLARE_FUNCTION_GETTER(NFC); diff --git a/src/NFC/plugin_config_impl.h b/src/NFC/plugin_config_impl.h new file mode 100755 index 0000000..1d8f572 --- /dev/null +++ b/src/NFC/plugin_config_impl.h @@ -0,0 +1,29 @@ +// +// 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. +// + + +#ifndef _NFC_PLUGIN_CONFIG_IMPL_H_ +#define _NFC_PLUGIN_CONFIG_IMPL_H_ + +#define NFC_FUNCTION_API_COMMON_FUNCS "NFCCommonFunctions" +#define NFC_FUNCTION_API_ADMIN_FUNCS "NFCAdminFunctions" +#define NFC_FUNCTION_API_TAG_FUNCS "NFCTagFunctions" +#define NFC_FUNCTION_API_P2P_FUNCS "NFCP2PFunctions" +#define NFC_FUNCTION_API_CARDEMULATION_FUNCS "NFCCardEmulationFunctions" + + +#endif // _NFC_PLUGIN_CONFIG_IMPL_H_ \ No newline at end of file diff --git a/src/NFC/plugin_initializer.cpp b/src/NFC/plugin_initializer.cpp old mode 100644 new mode 100755 index 51521a6..e352c84 --- a/src/NFC/plugin_initializer.cpp +++ b/src/NFC/plugin_initializer.cpp @@ -27,6 +27,9 @@ #include "NFCAsyncCallbackManager.h" #include "NFCListenerManager.h" #include "NFCDefaultAdapter.h" +#include "plugin_config.h" +#include +#include #include 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(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(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, diff --git a/src/Notification/CMakeLists.txt b/src/Notification/CMakeLists.txt index 01c523e..b72610c 100755 --- a/src/Notification/CMakeLists.txt +++ b/src/Notification/CMakeLists.txt @@ -51,8 +51,6 @@ TARGET_LINK_LIBRARIES(${TARGET_NAME} ${TARGET_IMPL_NAME} ${tizen_impl} ${timeutil_impl} - "-Wl,--no-as-needed" ${application_config} - "-Wl,--no-as-needed" ${filesystem_config} ) INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) diff --git a/src/Package/PackageManager.cpp b/src/Package/PackageManager.cpp index 25a5ecc..a90141a 100644 --- a/src/Package/PackageManager.cpp +++ b/src/Package/PackageManager.cpp @@ -207,6 +207,7 @@ static int get_current_pkg_id(char** pkg_id) ret = app_info_get_package(handle, pkg_id); if ((ret != APP_MANAGER_ERROR_NONE) || (*pkg_id == NULL)) { LoggerE("Fail to get pkg_id"); + app_info_destroy(handle); return ret; } diff --git a/src/Power/JSPowerManager.cpp b/src/Power/JSPowerManager.cpp old mode 100644 new mode 100755 index b5c292b..8bd5a57 --- a/src/Power/JSPowerManager.cpp +++ b/src/Power/JSPowerManager.cpp @@ -16,14 +16,13 @@ // #include -#include #include #include #include #include #include "JSPowerManager.h" -#include "plugin_config.h" +#include "plugin_config_impl.h" #include "PowerManager.h" #include @@ -73,15 +72,19 @@ JSClassRef JSPowerManager::m_jsClassRef = JSClassCreate(JSPowerManager::getClass void JSPowerManager::initialize(JSContextRef context, JSObjectRef object) { + LoggerD("entered"); + PowerManagerPriv *priv = new PowerManagerPriv(GlobalContextManager::getInstance()->getGlobalContext(context)); + JSObjectSetPrivate(object, static_cast(priv)); } void JSPowerManager::finalize(JSObjectRef object) { - CallbackUserData *callback = static_cast(JSObjectGetPrivate(object)); - if( callback != NULL ){ - PowerManager::getInstance()->removeScreenStateChangedCallback(callback); + LoggerD("entered"); + PowerManagerPriv *priv = static_cast(JSObjectGetPrivate(object)); + if( priv != NULL ){ + PowerManager::getInstance()->removeScreenStateChangedCallback(priv); JSObjectSetPrivate(object, NULL); - delete callback; + delete priv; } } @@ -106,10 +109,14 @@ JSValueRef JSPowerManager::request(JSContextRef context, JSValueRef* exception) { LoggerD("entered"); - TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = POWER_CHECK_ACCESS(POWER_FUNCTION_API_REQUEST); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + PowerManagerPriv *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + if (!thisPriv) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); + } + TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); + TIZEN_CHECK_ACCESS(context, exception, thisPriv, POWER_FUNCTION_API_REQUEST); try{ ArgumentValidator validator(context, argumentCount, arguments); @@ -163,13 +170,9 @@ JSValueRef JSPowerManager::setScreenStateChangeListener(JSContextRef context, try{ ArgumentValidator validator(context, argumentCount, arguments); JSObjectRef func = validator.toFunction(0); - CallbackUserData *callback = static_cast(JSObjectGetPrivate(thisObject)); - if( callback == NULL ){ - callback = new CallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)); - JSObjectSetPrivate(thisObject, callback); - } - callback->setSuccessCallback(func); - PowerManager::getInstance()->addScreenStateChangedCallback(callback); + PowerManagerPriv *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + thisPriv->setSuccessCallback(func); + PowerManager::getInstance()->addScreenStateChangedCallback(thisPriv); }catch(const BasePlatformException& err){ return JSWebAPIErrorFactory::postException(context, exception, err); @@ -191,12 +194,8 @@ JSValueRef JSPowerManager::unsetScreenStateChangeListener(JSContextRef context, LoggerD("entered"); TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - CallbackUserData *callback = static_cast(JSObjectGetPrivate(thisObject)); - if( callback != NULL ){ - PowerManager::getInstance()->removeScreenStateChangedCallback(callback); - JSObjectSetPrivate(thisObject, NULL); - delete callback; - } + PowerManagerPriv *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + TIME_TRACER_ITEM_END(__FUNCTION__, 0); return JSValueMakeUndefined(context); } @@ -228,9 +227,15 @@ JSValueRef JSPowerManager::setScreenBrightness(JSContextRef context, JSValueRef* exception) { LoggerD("entered"); + + PowerManagerPriv *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + if (!thisPriv) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); + } TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = POWER_CHECK_ACCESS(POWER_FUNCTION_API_RELEASE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, thisPriv, POWER_FUNCTION_API_SET_SCREEN_BRIGHTNESS); + try{ ArgumentValidator validator(context, argumentCount, arguments); @@ -290,9 +295,14 @@ JSValueRef JSPowerManager::turnScreenOn(JSContextRef context, JSValueRef* exception) { LoggerD("entered"); + + PowerManagerPriv *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + if (!thisPriv) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); + } TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = POWER_CHECK_ACCESS(POWER_FUNCTION_API_RELEASE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, thisPriv, POWER_FUNCTION_API_TURN_SCREEN_ON); try{ PowerManager::getInstance()->setScreenState(true); @@ -311,9 +321,13 @@ JSValueRef JSPowerManager::turnScreenOff(JSContextRef context, JSValueRef* exception) { LoggerD("entered"); + PowerManagerPriv *thisPriv = static_cast(JSObjectGetPrivate(thisObject)); + if (!thisPriv) { + LoggerE("private object is null"); + return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object"); + } TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0); - AceSecurityStatus status = POWER_CHECK_ACCESS(POWER_FUNCTION_API_RELEASE); - TIZEN_SYNC_ACCESS_HANDLER(status, context, exception); + TIZEN_CHECK_ACCESS(context, exception, thisPriv, POWER_FUNCTION_API_TURN_SCREEN_OFF); try{ PowerManager::getInstance()->setScreenState(false); diff --git a/src/Power/JSPowerManager.h b/src/Power/JSPowerManager.h index 04c2834..64d1292 100755 --- a/src/Power/JSPowerManager.h +++ b/src/Power/JSPowerManager.h @@ -20,10 +20,19 @@ #include #include +#include +#include namespace DeviceAPI { namespace Power { +class PowerManagerPriv : public DeviceAPI::Common::CallbackUserData, public DeviceAPI::Common::SecurityAccessor +{ +public: + PowerManagerPriv(JSContextRef ctx) : DeviceAPI::Common::CallbackUserData(ctx), DeviceAPI::Common::SecurityAccessor() {} + virtual ~PowerManagerPriv() {} +}; + class JSPowerManager { public: diff --git a/src/Power/plugin_config.cpp b/src/Power/plugin_config.cpp index fb97251..4fd7c1e 100755 --- a/src/Power/plugin_config.cpp +++ b/src/Power/plugin_config.cpp @@ -19,6 +19,7 @@ #include #include +#include "plugin_config_impl.h" #include "plugin_config.h" #define POWER_FEATURE_API "http://tizen.org/privilege/power" @@ -35,12 +36,8 @@ static FunctionMapping createPowerFunctions(); static FunctionMapping PowerFunctions = createPowerFunctions(); -#pragma GCC visibility push(default) - DEFINE_FUNCTION_GETTER(Power, PowerFunctions); -#pragma GCC visibility pop - static FunctionMapping createPowerFunctions() { /** diff --git a/src/Power/plugin_config.h b/src/Power/plugin_config.h index b528cce..9efd699 100755 --- a/src/Power/plugin_config.h +++ b/src/Power/plugin_config.h @@ -24,18 +24,6 @@ namespace DeviceAPI { namespace Power { -// Functions from power manager -#define POWER_FUNCTION_API_REQUEST "request" -#define POWER_FUNCTION_API_RELEASE "release" -#define POWER_FUNCTION_API_SET_SCREEN_STATE_CHANGE_LISTENER "setScreenStateChangeListener" -#define POWER_FUNCTION_API_UNSET_SCREEN_STATE_CHANGE_LISTENER "unsetScreenStateChangeListener" -#define POWER_FUNCTION_API_GET_SCREEN_BRIGHTNESS "getScreenBrightness" -#define POWER_FUNCTION_API_SET_SCREEN_BRIGHTNESS "setScreenBrightness" -#define POWER_FUNCTION_API_IS_SCREEN_ON "isScreenOn" -#define POWER_FUNCTION_API_RESTORE_SCREEN_BRIGHTNESS "restoreScreenBrightness" -#define POWER_FUNCTION_API_TURN_SCREEN_ON "turnScreenOn" -#define POWER_FUNCTION_API_TURN_SCREEN_OFF "turnScreenOff" - DECLARE_FUNCTION_GETTER(Power); #define POWER_CHECK_ACCESS(functionName) \ diff --git a/src/Power/plugin_config_impl.h b/src/Power/plugin_config_impl.h new file mode 100755 index 0000000..7e8ab4f --- /dev/null +++ b/src/Power/plugin_config_impl.h @@ -0,0 +1,32 @@ +// +// 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. +// + +#ifndef _POWER_PLUGIN_CONFIG_IMPL_H_ +#define _POWER_PLUGIN_CONFIG_IMPL_H_ + +#define POWER_FUNCTION_API_REQUEST "request" +#define POWER_FUNCTION_API_RELEASE "release" +#define POWER_FUNCTION_API_SET_SCREEN_STATE_CHANGE_LISTENER "setScreenStateChangeListener" +#define POWER_FUNCTION_API_UNSET_SCREEN_STATE_CHANGE_LISTENER "unsetScreenStateChangeListener" +#define POWER_FUNCTION_API_GET_SCREEN_BRIGHTNESS "getScreenBrightness" +#define POWER_FUNCTION_API_SET_SCREEN_BRIGHTNESS "setScreenBrightness" +#define POWER_FUNCTION_API_IS_SCREEN_ON "isScreenOn" +#define POWER_FUNCTION_API_RESTORE_SCREEN_BRIGHTNESS "restoreScreenBrightness" +#define POWER_FUNCTION_API_TURN_SCREEN_ON "turnScreenOn" +#define POWER_FUNCTION_API_TURN_SCREEN_OFF "turnScreenOff" + +#endif diff --git a/src/Power/plugin_initializer.cpp b/src/Power/plugin_initializer.cpp old mode 100644 new mode 100755 index 2e9cdb3..be0e6a3 --- a/src/Power/plugin_initializer.cpp +++ b/src/Power/plugin_initializer.cpp @@ -23,6 +23,8 @@ #include "JSPowerManager.h" #include #include +#include +#include "plugin_config.h" namespace DeviceAPI { namespace Power { @@ -31,6 +33,28 @@ using namespace WrtDeviceApis; using namespace WrtDeviceApis::Commons; using namespace DeviceAPI::Common; +AceSecurityStatus powerAceCheckAccessFunction(const char* functionName) +{ + return POWER_CHECK_ACCESS(functionName); +} + +DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); + +DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerPowerSetter, + DeviceAPI::Power::PowerManagerPriv, + gSecurityAccessor); + +class_definition_options_t ClassOptions = +{ + JS_CLASS, + NONE, + ALWAYS_NOTICE, + IGNORED, + AceCheckerPowerSetter, + NULL, + NULL +}; + void on_widget_start_callback(int widgetId) { LoggerD("[Tizen\\Power] on_widget_start_callback (" << widgetId << ")"); @@ -41,6 +65,8 @@ void on_widget_start_callback(int widgetId) } Catch (Exception) { LoggerE("WrtAccess initialization failed"); } + + INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, powerAceCheckAccessFunction); } void on_widget_stop_callback(int widgetId) @@ -54,6 +80,8 @@ void on_widget_stop_callback(int widgetId) } Catch (Exception) { LoggerE("WrtAccess deinitialization failed"); } + + FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor); } void on_frame_load_callback(const void * context) @@ -78,7 +106,7 @@ PLUGIN_CLASS_MAP_BEGIN PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "power", (js_class_template_getter)JSPowerManager::getClassRef, - NULL) + &ClassOptions) PLUGIN_CLASS_MAP_END } diff --git a/src/Power/test/CMakeLists.txt b/src/Power/test/CMakeLists.txt deleted file mode 100755 index 740aedc..0000000 --- a/src/Power/test/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -SET(TARGET_NAME ${power_target}_test) - -include_directories( - ${TOP}/Common - ${TOP}/Power - ${TOP}/Common/StandaloneConsole -) - -set(CMAKE_INSTALL_RPATH - ${CMAKE_INSTALL_RPATH} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${power_dest} -) - -set(SRCS - main.cpp -) - - -ADD_EXECUTABLE(${TARGET_NAME} ${SRCS}) - -target_link_libraries(${TARGET_NAME} - ${power_impl} - ${LIBS_COMMON} - ${LIBS_TEST} -) - - diff --git a/src/Power/test/TestEngine.js b/src/Power/test/TestEngine.js deleted file mode 100755 index 0942267..0000000 --- a/src/Power/test/TestEngine.js +++ /dev/null @@ -1,1020 +0,0 @@ -/* -* wrt-plugins -* -* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. -* -* Contact: Seung Mo Cho -* -* This library is free software; you can redistribute it and/or modify it under -* the terms of the GNU Lesser General Public License as published by the -* Free Software Foundation; either version 2.1 of the License, or (at your -* option) any later version. -* -* This library is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -* License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this library; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -*/ -/** - * This file contains the implementation of test engine class. - * - * @author Wojciech Bielawski(w.bielawski@samsung.com) - * @author Pawel Misiak (p.misiak@samsung.com) - * @version 0.1 - */ -var jsPrint = console.log; -var logFail = console.log; -var logError = console.log; - -var TestEngine = { - logText : "", - testCaseTimeout : 10 * 1000, //in miliseconds - currentCaseTimeout : 10 * 1000, - timer : null, - countOK : 0, - countErr : 0, - countException : 0, - callbackMutex : 0, - callbackMethodName : "", - currentTestCase : 0, - countAllPassed : 0, - countAllFailed : 0, - testCasesFailedCount : 0, - testCasesPassedCount : 0, - testCasesFailed : [], - testList : [], - finalLog : "\n", - testSuccessCallback : null, - testErrorCallback : null, - testSuiteName : null, - testSuiteStats : [], - resultLogger : new HTMLTestResultLogger('log'), - summaryRenderer : new HTMLTestSummaryRenderer('summary'), - - stepsArray : null, - stepTimeout : null, - currentStep : null, - errorType : null, - errorField : null, - - /* - * Values used only as types representations. - */ - STRING : '', - NUMBER : 0, - OBJECT : {}, - ARRAY : [], - DATE : new Date(), - BOOL : false, - FUNCTION : function() { - }, - /* - * Error test possible results. - */ - ERROR_TEST_RESULT : { - NOT_RUN : -4, - NOT_THROWN : -3, - BAD_TYPE : -2, - BAD_VALUE : -1, - OK : 0 - }, - - /** - * Prints specified object in a TreeView like structure. - * @param obj Object to print. - * @param indent Must be undefined (don't pass anything). - */ - dumpObject : function(obj, indent) { - if(indent === undefined) - indent = ''; - else - indent += ' '; - var prefix = (indent.length == 0 ? indent : indent + '|--'); - for(var i in obj) { - if( typeof (obj[i]) == "object") { - TestEngine.log(prefix + i + ":"); - TestEngine.dumpObject(obj[i], indent); - } else - TestEngine.log(prefix + i + ": " + obj[i]); - } - }, - addTest : function(enabled, testFunc, testName, testPrereq) { - if(null == testName) { - testName = "unnamed test" - } - jsPrint("Add test: " + testName) - var data = new Object(); - data.enabled = enabled; - data.testFunc = testFunc; - data.testName = testName; - data.testPrereq = testPrereq; - data.testSuite = TestEngine.testSuiteName; - data.failMessage = ""; - // this.testList.push(testFunc) - this.testList.push(data); - }, - setTestSuiteName : function(name, timeout) { - this.testSuiteName = name; - this.testSuiteStats[name] = new Object(); - this.testSuiteStats[name].passed = 0; - this.testSuiteStats[name].failed = 0; - this.testSuiteStats[name].assertsOK = 0; - this.testSuiteStats[name].assertsErr = 0; - TestEngine.currentCaseTimeout = (timeout === undefined) ? TestEngine.testCaseTimeout : timeout; - }, - log : function(text) { - try { - jsPrint(text); - this.logText += text + "
"; - this.finalLog += text + "\n"; - // document.getElementById(TestEngine.currentTestSuite).innerHTML += text + "
"; - //document.getElementById('log').innerHTML += text + "
"; - } catch(err) { - this.countException++; - logError(" TestEngine.log failure: " + err.message); - } - }, - logException : function(text) { - try { - logFail(text); - TestEngine.countException++; - TestEngine.log("[EXCEPTION] " + text); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.logErr failure: " + err.message); - } - }, - logErr : function(text) { - try { - TestEngine.countErr++; - TestEngine.log("[FAILED] " + text); - logFail("[FAILED] " + text); - - TestEngine.testList[TestEngine.currentTestCase-1].failMessage = text; - - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.logErr failure: " + err.message); - } - }, - logOK : function(text) { - try { - TestEngine.countOK++; - TestEngine.log("[OK] " + text); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.logOK failure: " + err.message); - } - }, - test : function(text, value) { - try { - if( typeof (value) == "undefined") { - TestEngine.logErr("value not defined for test: '" + text + "'"); - } else if(!value) { - TestEngine.logErr(text); - } else { - TestEngine.logOK(text); - return true; - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.test failure: " + err.message); - } - return false; - }, - assertEqual : function(text, value1, value2){ - try { - if( typeof (value1) == "undefined") { - TestEngine.logErr("value1 not defined for test: '" + text + "'"); - } else if( typeof (value2) == "undefined") { - TestEngine.logErr("value2 not defined for test: '" + text + "'"); - }else if(value1 == value2) { - TestEngine.logOK(text +" (value1:[" + value1 + "] value2:[" + value2 + "])"); - } else { - TestEngine.logErr(text + " (expected value1:[" + value1 + "] but value2:[" + value2 + "])"); - return true; - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.test failure: " + err.message); - } - return false; - }, - - /** - * Sets error type used in every typePresetError check. - * @param type Type of an error/exception. - */ - setErrorType : function(type) { - TestEngine.errorType = type; - }, - /** - * Sets error field used in every typePresetError check. - * @param field Name of the field in error structure to check its value. - */ - setErrorField : function(field) { - TestEngine.errorField = field; - }, - /** - * Checks if specified expression throws a specified error. - * Expression must be enclosed in a function. Use setErrorType and - * setErrorField to set what error to look for. - * Error type must be set but if error field is left unset (i.e. null) - * then whole exception object is compared to specified value. - * @param msg Text to display for this test. - * @param fn Function eclosing the expression one wants to verify. - * @param value Value of an error/exception one looks for. - */ - testPresetError : function(msg, fn, value) { - if(TestEngine.errorType === null) { - TestEngine.logException("testPresetError skipped. Set error type first."); - return; - } - - return TestEngine.testError(msg, fn, TestEngine.errorType, TestEngine.errorField, value); - }, - /** - * Checks if specified expression throws a specified error. - * This is a more general version of testPresetError function. - * Expression must be enclosed in a function. - * Error type must be set but if error field is left unset (i.e. null) - * then whole exception object is compared to specified value. - * @param msg Text to display for this test. - * @param fn Function eclosing the expression one wants to verify. - * @param errType Type of desired error/exception. - * @param errField Property from exception structure to look for exception - * value. - * @param errValue Value of an error/exception one looks for. - */ - testError : function(msg, fn, errType, errField, errValue) { - if(errType === null) { - TestEngine.logException("testError skipped. Error type can't be null."); - return TestEngine.ERROR_TEST_RESULT.NOT_RUN; - } - - try { - fn(); - TestEngine.logErr(msg + ' Exception has not been thrown.'); - return TestEngine.ERROR_TEST_RESULT.NOT_THROWN; - } catch (ex) { - if( ex instanceof errType) { - var exValue = (errField !== null ? ex[errField] : ex); - if(exValue === errValue) { - TestEngine.logOK(msg + ' [' + errValue + ']'); - return TestEngine.ERROR_TEST_RESULT.OK; - } else { - TestEngine.logErr(msg + ' Exception is not of value ' + errValue); - return TestEngine.ERROR_TEST_RESULT.BAD_VALUE; - } - } else { - TestEngine.logErr(msg + ' Exception is of wrong type.'); - return TestEngine.ERROR_TEST_RESULT.BAD_TYPE; - } - } - }, - testPresence : function(text, object) { - try { - if(object === undefined) { - TestEngine.logErr("value not defined. Name: " + text); - } else { - TestEngine.logOK("object " + text + " present"); - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.testPresence failure: " + err.message); - } - }, - /** - * Checks whether object implements given property. - * In addition it also checks whether any exception (e.g. "Not Supported") - * is thrown. - * @param object Object to check property for. - * @param property Property to look for. - * @return True if object implements such property, false otherwise. - */ - testPresence2 : function(object, property) { - var result = property in object; - if(result) { - TestEngine.logOK("property " + property + " present"); - } else { - TestEngine.logErr("property " + property + " absent"); - } - return result; - }, - /** - * Checks whether mainObj object equals templateObj object, property by - * property. - * Runs recursively through all the properties of templateObj object and - * checks if they exist and are equal to those in mainObj object. - * mainObj has to implement no less properties than templateObj. - * @param mainObj Object to check for properties implementation. - * @param templateObj Object to verify properties against. - * @return True if mainObj has at least the same properties as templateObj, - * false otherwise. - */ - checkObjectsEqual : function(mainObj, templateObj) { - try { - if((!mainObj && templateObj) || ( typeof (mainObj) != typeof (templateObj))) { - return false; - } else if(isNumber(templateObj) || isString(templateObj) || isBoolean(templateObj)) { - return (mainObj === templateObj); - } else if(isDate(templateObj)) { - return (mainObj.valueOf() === templateObj.valueOf()); - } else { - for(var i in templateObj) { - if(!TestEngine.checkObjectsEqual(mainObj[i], templateObj[i])) { - return false; - } - } - } - } catch(err) { - TestEngine.logException("TestEngine.checkObjectsEqual failure: " + err.message); - return false; - } - return true; - }, - // test properties of given object. Steps: - // - check name presence - // - check default value (if not null value passed) - // - check if name is writable - // - // description of properties array: - // [0] - property name - // [1] - default value - check if property equals given value - // undefined or null - disable check - // [2] - value to do writability test - try to write given value - // undefined or null - don't check writability - // [3] - indicates if property should be read-only - // [4] - assumed type, undefined value skips this check - testProperties : function(object, props) { - var result = new Object(); - try { - for(var i in props) { - var name = props[i][0]; - var defaultVal = props[i][1]; - var setVal = props[i][2]; - var isReadonly = props[i][3]; - var type = props[i][4]; - var errors = TestEngine.countErr + TestEngine.countException; - - if(( typeof (name) != "string") || (name == "")) { - TestEngine.logException("Property name not defined, skipping it."); - continue; - } - - result[name] = false; - if(TestEngine.testPresence2(object, name)) { - if((defaultVal != null) && (defaultVal !== undefined)) { - var isObjectEqual = TestEngine.checkObjectsEqual(object[name], defaultVal); - TestEngine.test(name + " default value", isObjectEqual); - } - - if((setVal != null) && (setVal !== undefined)) { - // try-catch is needed when SetProperty returns 'false' - if(setVal === defaultVal) { - TestEngine.logException("Default value and set value are equal"); - continue; - } - try { - object[name] = setVal; - } catch (e) { - } - if( typeof (isReadonly) == "undefined") { - TestEngine.test(name + " writability, reason: isReadonly not specified", false); - } - if(isReadonly) { - TestEngine.test(name + " writability", object[name] != setVal); - } else { - var isObjectEqual = TestEngine.checkObjectsEqual(object[name], setVal); - TestEngine.test(name + " writability", isObjectEqual); - } - } - - if(type !== undefined) { - var isType = ( typeof (object[name]) == typeof (type)); - if( typeof (type) == 'object') { - if(isArray(type)) { - isType = isArray(object[name]); - } else if(isDate(type)) { - isType = isDate(object[name]); - } - } - TestEngine.test(name + " type check.", isType); - } - } - if(errors == TestEngine.countErr + TestEngine.countException) { - result[name] = true; - } - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.testProperties failure: " + err.message); - } - return result; - }, - startTestCase : function() { - try { - TestEngine.countOK = 0; - TestEngine.countErr = 0; - TestEngine.countException = 0; - TestEngine.timer = setTimeout(TestEngine.timeout, TestEngine.currentCaseTimeout); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.startTestCase failure: " + err.message); - } - - }, - endTestCase : function(testCase) { - try { - if(this.timer === null) { - return; - } - - clearTimeout(this.timer); - this.log(""); - var failed = this.countErr || ((this.countOK + this.countErr) < 1) || this.countException; - this.log("Test case " + ( failed ? "FAILED" : "PASSED")); - this.log("Passed: " + this.countOK); - this.log("Failed: " + this.countErr); - if(this.countException) { - this.log("Exception occured!"); - } - - this.countAllPassed += this.countOK; - this.countAllFailed += this.countErr; - this.testSuiteStats[testCase.testSuite].assertsOK += this.countOK; - this.testSuiteStats[testCase.testSuite].assertsErr += this.countErr; - - if(failed) { - TestEngine.testCasesFailedCount++; - this.testSuiteStats[testCase.testSuite].failed++; - if(isVerbose()) { - TestEngine.testCasesFailed.push(testCase.testName + ":" + testCase.failMessage); - } - TestEngine.resultLogger.logFail(testCase.testName + ":" + testCase.failMessage); - } else { - TestEngine.testCasesPassedCount++; - this.testSuiteStats[testCase.testSuite].passed++; - TestEngine.resultLogger.logPass(testCase.testName); - } - TestEngine.summaryRenderer.render(TestEngine); - } catch(err) { - this.countException++; - logError(" TestEngine.endTestCase failure:" + err.message); - } - }, - timeout : function() { - try { - TestEngine.callbackMutex = 0; - TestEngine.logErr("Widget run timeout.", false); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.timeout failure:" + err.message); - } - }, - /** - * Registers callbacks for asynchronous function. - * - * To avoid finish test case before callbacks will execute it's necessary - * to register callbacks in the engine. - * - * @param methodName Testcase name, suggested asynchronous function name. - * @param testSuccessCallback Callback that will be executed on success. - * @param testErrorCallback Callback that will be executed on failure. - * @param callbacksCount number of callbacks to register. - * @return An object with defined functions "successCallback" and "errorCallback" you - * need to pass as arguments to asynchronous function e.g. - * - * function success() { } - * function failure() { } - * - * { - * var obj = TestEngine.registerCallback("myAsyncFunc", success, failure); - * myAsyncFunc(obj.successCallback, obj.errorCallback); - * } - */ - registerCallback : function(methodName, testSuccessCallback, testErrorCallback, callbacksCount) { - try { - if(callbacksCount !== undefined && callbacksCount > 0) { - TestEngine.callbackMutex += callbacksCount; - } else { - TestEngine.callbackMutex++; - } - TestEngine.callbackMethodName = methodName; - TestEngine.testSuccessCallback = testSuccessCallback; - TestEngine.testErrorCallback = testErrorCallback; - - var retObj = new Object(); - retObj.callbackMethodName = methodName; - retObj.testSuccessCallback = testSuccessCallback; - retObj.successCallback = function(param) { - try { - if(( typeof retObj.testSuccessCallback != "undefined") && (retObj.testSuccessCallback !== null)) { - retObj.testSuccessCallback(param); - } else { - TestEngine.logOK(retObj.callbackMethodName + " succeed"); - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.this.successCallback failure:" + err.message); - } - TestEngine.callbackMutex--; - }; - - retObj.testErrorCallback = testErrorCallback; - retObj.errorCallback = function(param) { - try { - if(( typeof retObj.testErrorCallback != "undefined") && (retObj.testErrorCallback !== null)) { - retObj.testErrorCallback(param); - } else { - TestEngine.logErr(retObj.callbackMethodName + " failed"); - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.retObj.errorCallback failure:" + err.message); - } - TestEngine.callbackMutex--; - }; - return retObj; - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.registerCallback failure:" + err.message); - } - }, - successCallback : function(params) { - TestEngine.log("[Warning] Function TestEngine.successCallback deprecated"); - try { - TestEngine.callbackMutex--; - if( typeof TestEngine.testSuccessCallback != "undefined") { - TestEngine.testSuccessCallback(params); - } else { - TestEngine.logOK(TestEngine.callbackMethodName + " succeed"); - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.successCallback failure:" + err.message); - } - }, - errorCallback : function(params) { - TestEngine.log("[Warning] Function TestEngine.errorCallback deprecated"); - try { - TestEngine.callbackMutex--; - if( typeof TestEngine.testErrorCallback != "undefined") { - TestEngine.testErrorCallback(params); - } else { - TestEngine.logErr(TestEngine.callbackMethodName + " failed"); - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.errorCallback failure:" + err.message); - } - }, - waitForCallback : function() { - try { - // while( TestEngine.callbackMutex ) - { - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.waitForCallback failure:" + err.message); - } - }, - /* - * code - error code which is expected - * object - object which will be used to call method - * functionName - method name to call - * restArguments - rest arguments which will be passed to callback (max arguments = 10) - * - * example: - * TestEngine.catchError(10001, bondi.messaging, findSMSs, succCallback, null, filter) - */ - catchError : function(code, object, functionName, restArguments /* , ... */ ) { - try { - TestEngine.log("TestEngine.catchError is DEPRECATED. Please use TestEngine.catchErrorType."); - var error; - try { - var newArgs = [] - for(var i = 3; i < arguments.length; i++) { - newArgs.push(arguments[i]) - } - var retVal = null; - //no args - if(arguments.length == 3) { - retVal = object[functionName](); - } - //1 arg - if(arguments.length == 4) { - retVal = object[functionName](newArgs[0]); - } - //2 args - if(arguments.length == 5) { - retVal = object[functionName](newArgs[0], newArgs[1]); - } - //3 args - if(arguments.length == 6) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2]); - } - // 4 args - if(arguments.length == 7) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3]); - } - // 5 args - if(arguments.length == 8) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4]); - } - // 6 args - if(arguments.length == 9) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5]); - } - // 7 args - if(arguments.length == 10) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6]); - } - // 8 args - if(arguments.length == 11) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6], newArgs[7]); - } - // 9 args - if(arguments.length == 12) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6], newArgs[7], newArgs[8]); - } - // 10 args - if(arguments.length == 13) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6], newArgs[7], newArgs[8], newArgs[9]); - } - - TestEngine.logErr(functionName + " no error thrown"); - return retVal; - } catch(error) { - TestEngine.testPresence("", error.code); - TestEngine.test("Error number", error.code == code); - return; - } - TestEngine.logErr("Function " + functionName + " desn't throw"); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.testError failure:" + err.message); - } - }, - /* - * errorTypeName - attribute name of catched exception to compare with code - * code - error code which is expected - * object - object which will be used to call method - * functionName - method name to call - * restArguments - rest arguments which will be passed to callback (max arguments = 10) - * - * example: - * TestEngine.catchErrorType("code", 10001, bondi.messaging, findSMSs, succCallback, null, filter) - */ - catchErrorType : function(errorTypeName, code, object, functionName, restArguments /* , ... */ ) { - try { - var error; - try { - var newArgs = [] - for(var i = 4; i < arguments.length; i++) { - newArgs.push(arguments[i]) - } - var retVal = null; - if(arguments.length < 4) { - TestEngine.logErr("Wrong catchErrorType usage."); - return retVal; - } - //no args - if(arguments.length == 4) { - retVal = object[functionName](); - } - //1 arg - if(arguments.length == 5) { - retVal = object[functionName](newArgs[0]); - } - //2 args - if(arguments.length == 6) { - retVal = object[functionName](newArgs[0], newArgs[1]); - } - //3 args - if(arguments.length == 7) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2]); - } - // 4 args - if(arguments.length == 8) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3]); - } - // 5 args - if(arguments.length == 9) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4]); - } - // 6 args - if(arguments.length == 10) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5]); - } - // 7 args - if(arguments.length == 11) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6]); - } - // 8 args - if(arguments.length == 12) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6], newArgs[7]); - } - // 9 args - if(arguments.length == 13) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6], newArgs[7], newArgs[8]); - } - // 10 args - if(arguments.length == 14) { - retVal = object[functionName](newArgs[0], newArgs[1], newArgs[2], newArgs[3], newArgs[4], newArgs[5], newArgs[6], newArgs[7], newArgs[8], newArgs[9]); - } - - TestEngine.logErr(functionName + " no error thrown"); - return retVal; - } catch(error) { - TestEngine.testPresence("", error[errorTypeName]); - TestEngine.test("Error number", error[errorTypeName] == code); - return; - } - TestEngine.logErr("Function " + functionName + " desn't throw"); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.testError failure:" + err.message); - } - }, - /* - * code - error type which is expected - * object - object which will be used to call method - * functionName - method name to call - * restArguments - rest arguments which will be passed to callback (max arguments = 10) - * - * example: - * TestEngine.catchErrorJil("INVALID_ARGUMENT", Widget.Telephony, "getCallRecord", null, null) - */ - catchErrorJil : function(code, object, functionName, restArguments /* , ... */ ) { - try { - TestEngine.logErr("TestEngine.catchErrorJil is DEPRECATED. Please use TestEngine.catchErrorType."); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.testError failure:" + err.message); - } - }, - // Executes step by step functions passed in steps array - // and waits after every execution time defined in timeInterval - executeSteps : function(steps, timeInterval) { - try { - if( typeof (timeInterval) == "undefined") { - timeInterval = 100; - //default value - } - - TestEngine.stepsArray = steps; - TestEngine.stepTimeout = timeInterval; - TestEngine.currentStep = 0; - TestEngine.executeNextStep(); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.executeSteps failure:" + err.message); - } - }, - executeNextStep : function() { - try { - if(TestEngine.stepsArray && (TestEngine.currentStep < TestEngine.stepsArray.length)) { - if(isArray(TestEngine.stepsArray[TestEngine.currentStep])) { - TestEngine.stepsArray[ TestEngine.currentStep ][0](); - setTimeout(TestEngine.executeNextStep, TestEngine.stepsArray[ TestEngine.currentStep ][1]); - - } else { - TestEngine.stepsArray[ TestEngine.currentStep ](); - setTimeout(TestEngine.executeNextStep, TestEngine.stepTimeout); - } - TestEngine.currentStep++; - } else { - TestEngine.currentStep = null; - TestEngine.stepTimeout = null; - TestEngine.stepsArray = null; - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.executeNextStep failure:" + err.message); - jsPrint(" Current step:" + TestEngine.currentStep); - - TestEngine.currentStep = null; - TestEngine.stepTimeout = null; - TestEngine.stepsArray = null; - } - }, - enumerate : function(obj, level) { - try { - if( typeof level == "undefined") { - TestEngine.log(obj + ":"); - level = ""; - } - for(i in obj) { - if(!( typeof obj[i] == "object" || typeof obj[i] == "array")) { - TestEngine.log(level + i + " = " + obj[i]); - } else { - TestEngine.log(level + i + " = "); - TestEngine.enumerate(obj[i], level + "----"); - } - } - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.enumerate failure:" + err.message); - } - }, - doTests : function() { - try { - TestEngine.testCasesFailed = []; - TestEngine.doNextTestCase(); - } catch(err) { - TestEngine.countException++; - logError(" TestEngine.doTests failure:" + err.message); - } - }, - showSuitesStats : function() { - try { - jsPrint("============ Test suites:"); - for(var i in this.testSuiteStats) { - jsPrint(i + " - " + this.testSuiteStats[i].passed + " passed, " + this.testSuiteStats[i].failed + " failed," + " asserts: " + this.testSuiteStats[i].assertsOK + " passed, " + this.testSuiteStats[i].assertsErr + " failed"); - } - } catch(err) { - logError(" TestEngine.showSuitesStats failure:" + err.message); - } - }, - doNextTestCase : function() { - try { - if(TestEngine.stepsArray !== null || (TestEngine.callbackMutex > 0)) { - setTimeout(TestEngine.doNextTestCase, 100); - return; - } - - if(TestEngine.currentTestCase) { - TestEngine.endTestCase(TestEngine.testList[TestEngine.currentTestCase - 1]); - } - - if(TestEngine.testList.length == TestEngine.currentTestCase) { - jsPrint("============"); - jsPrint(TestEngine.finalLog); - TestEngine.showSuitesStats(); - jsPrint("============ Summary:"); - jsPrint("Test cases all: " + TestEngine.testList.length); - jsPrint("Test cases passed: " + TestEngine.testCasesPassedCount); - jsPrint("Test cases failed: " + TestEngine.testCasesFailedCount); - jsPrint("Asserts passed: " + TestEngine.countAllPassed); - jsPrint("Asserts failed: " + TestEngine.countAllFailed); - if(isVerbose()) { - jsPrint("============ Failing test cases:"); - for( i = 0; i < TestEngine.testCasesFailed.length; ++i) { - logError(TestEngine.testCasesFailed[i]); - } - } - TestEngine.summaryRenderer.render(TestEngine); - return; - } - - var i = TestEngine.currentTestCase++; - try { - TestEngine.log(""); - TestEngine.log("==== Test case: " + TestEngine.testList[i].testName); - TestEngine.startTestCase(); - var testPrereq = true; - if(TestEngine.testList[i].testPrereq !== undefined) { - testPrereq = TestEngine.testList[i].testPrereq(); - } - if(testPrereq) { - if(TestEngine.testList[i].enabled) { - TestEngine.testList[i].testFunc(); - } else { - TestEngine.logErr("Test disabled"); - } - - } else { - TestEngine.logException("Test case prerequisites unfulfilled. Skipping it."); - } - } catch(err) { - TestEngine.countException++; - TestEngine.log(" Test case '" + TestEngine.testList[i].testName + "' failed:" + err.message); - } - setTimeout(TestEngine.doNextTestCase, 100); - } catch(err) { - logError(" TestEngine.doNextTestCase failure:" + err.message); - } - } -}; - -function isUndefined(val) { - if( typeof val == "undefined") { - return true; - } - return false; -} - -function isNull(val) { - return val === null; -} - -function isString(val) { - if( typeof val == typeof "") { - return true; - } - return false; -} - -function isNumber(val) { - if( typeof val == typeof 0) { - return true - } - return false; -} - -function isDate(val) { - return ( val instanceof Date); -} - -function isFunction(val) { - return ( typeof (val) == 'function'); -} - -function isBoolean(val) { - if( typeof val == typeof true) { - return true - } - return false; -} - -function isArray(val) { - return ( val instanceof Array); -} - -function isObject(val) { - return ( val ); -} - -function isVerbose() { - return (( typeof (VERBOSE) != "undefined") && (VERBOSE === 1)); -} - -/** - * Tests results logger. - */ -function HTMLTestResultLogger(sinkId) { - - /** - * Logs a message. - * @param message Message to log. - * @param status Status of the message (PASSED, FAILED, EXCEPTION). - * By default status is set to PASSED. - */ - this.log = function(message, status) { - if(arguments.length < 2) - throw "Not enough number of arguments."; - console.log("["+status+"]:"+message); - } - /** - * Helper functions. - */ - this.logPass = function(message) { - if(arguments.length < 1) - throw "Not enough number of arguments."; - this.log(message, HTMLTestResultLogger.PASSED); - } - - this.logFail = function(message) { - if(arguments.length < 1) - throw "Not enough number of arguments."; - this.log(message, HTMLTestResultLogger.FAILED); - } - - var createLogEntry = function(message, status) { - var entry = '
'; - entry += message.toString(); - entry += '
'; - return entry; - } - var id = sinkId; - var sink = null; -} - -HTMLTestResultLogger.PASSED = "passed"; -HTMLTestResultLogger.FAILED = "failed"; -HTMLTestResultLogger.EXCEPTION = "exception"; - -/** - * Tests summary renderer. - */ -function HTMLTestSummaryRenderer(summaryId) { - - this.render = function(engine) { - } - - var isSuiteStarted = function(stats) { - return (stats.passed + stats.failed != 0); - } - var renderSuite = function(name, stats) { - } - var setupSummary = function(summary) { - } - var id = summaryId; - var summary = null; -} diff --git a/src/Power/test/TestPower.js b/src/Power/test/TestPower.js deleted file mode 100755 index 1e1c227..0000000 --- a/src/Power/test/TestPower.js +++ /dev/null @@ -1,310 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2013 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. -// - -var TYPE_MISMATCH_ERR = 'TypeMismatchError'; -var INVALID_VALUES_ERR = 'InvalidValuesError'; -var NOT_SUPPORTED_ERR = 'NotSupportedError'; -var NOT_FOUND_ERR = 'NotFoundError'; -//var UNKNOWN_ERR = 'UnknownError'; -//var PERMISSION_DENIED_ERR = 'PermissionDeniedError'; - -var ERROR_STR = "GG"; - -function UTC_power_module_presence_P_001() -{ - TestEngine.log("UTC_power_module_presence_P_001"); - - TestEngine.test("Power manager presence", power); - TestEngine.testPresence("request presence", power.request); - TestEngine.testPresence("release presence", power.release); - TestEngine.testPresence("setScreenStateChangeListener presence", power.setScreenStateChangeListener); - TestEngine.testPresence("unsetScreenStateChangeListener presence", power.unsetScreenStateChangeListener); - TestEngine.testPresence("getScreenBrightness presence", power.getScreenBrightness); - TestEngine.testPresence("setScreenBrightness presence", power.setScreenBrightness); - TestEngine.testPresence("isScreenOn presence", power.isScreenOn); - TestEngine.testPresence("restoreScreenBrightness presence", power.restoreScreenBrightness); - TestEngine.testPresence("turnScreenOn presence", power.turnScreenOn); - TestEngine.testPresence("turnScreenOff presence", power.turnScreenOff); -} - -function UTC_power_request_P_001() -{ - TestEngine.log("UTC_power_request_P_001"); - - testNoExceptionWithMessage("test request display", - function(){ - power.request("SCREEN", "SCREEN_DIM"); - power.request("SCREEN", "SCREEN_NORMAL"); - power.request("SCREEN", "SCREEN_BRIGHT"); - } - ); - - testNoExceptionWithMessage("test request cpu", - function(){ - power.request("CPU", "CPU_AWAKE"); - } - ); - - testNoExceptionWithMessage("test request additional", - function(){ - power.request("SCREEN", "SCREEN_BRIGHT", ERROR_STR); - } - ); -} - -function UTC_power_request_N_001() -{ - TestEngine.log("UTC_power_request_N_001"); - - TestEngine.log("First parameter check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request", ERROR_STR); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request", null); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request", undefined); - - TestEngine.log("Second parameter check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request", "SCREEN", ERROR_STR); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request", "SCREEN", null); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request", "SCREEN", undefined); - - TestEngine.log("Invalid number of parameters check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request"); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "request", "SCREEN"); -} - -function UTC_power_release_P_001() -{ - TestEngine.log("UTC_power_release_P_001"); - - testNoExceptionWithMessage("test release display", - function(){ - power.release("SCREEN"); - } - ); - - testNoExceptionWithMessage("test release display additional", - function(){ - power.release("SCREEN", 1); - } - ); -} - -function UTC_power_release_N_001() -{ - TestEngine.log("UTC_power_release_N_001"); - - TestEngine.log("First parameter check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "release", ERROR_STR); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "release", null); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "release", undefined); - - TestEngine.log("Invalid number of parameters check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "release"); -} - -function onChanged(previousState, changedState) { - TestEngine.log("State changed." + ", previousState: " + previousState + ", changedState: " + changedState); -} - -function UTC_power_setScreenStateChangeListener_P_001() -{ - TestEngine.log("UTC_power_setScreenStateChangeListener_P_001"); - - testNoExceptionWithMessage("test setScreenStateChangeListener", - function(){ - power.setScreenStateChangeListener(onChanged); - } - ); - - testNoExceptionWithMessage("test setScreenStateChangeListener additional", - function(){ - power.setScreenStateChangeListener(onChanged, ERROR_STR); - } - ); -} - -function UTC_power_setScreenStateChangeListener_N_001() -{ - TestEngine.log("UTC_power_setScreenStateChangeListener_N_001"); - - TestEngine.log("First parameter check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "setScreenStateChangeListener", ERROR_STR); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "setScreenStateChangeListener", null); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "setScreenStateChangeListener", undefined); - - TestEngine.log("Invalid number of parameters check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "setScreenStateChangeListener"); -} - -function UTC_power_unsetScreenStateChangeListener_P_001() -{ - TestEngine.log("UTC_power_unsetScreenStateChangeListener_P_001"); - - testNoExceptionWithMessage("test unsetScreenStateChangeListener", - function(){ - power.unsetScreenStateChangeListener(); - } - ); - - testNoExceptionWithMessage("test request additional", - function(){ - power.unsetScreenStateChangeListener(ERROR_STR); - } - ); -} - -function UTC_power_getScreenBrightness_P_001() -{ - TestEngine.log("UTC_power_getScreenBrightness_P_001"); - - testNoExceptionWithMessage("test getScreenBrightness", - function(){ - power.getScreenBrightness(); - } - ); - - testNoExceptionWithMessage("test getScreenBrightness additional", - function(){ - power.getScreenBrightness(ERROR_STR); - } - ); -} - -function UTC_power_setScreenBrightness_P_001() -{ - TestEngine.log("UTC_power_setScreenBrightness_P_001"); - - testNoExceptionWithMessage("test setScreenBrightness", - function(){ - power.setScreenBrightness(0.5); - } - ); - - testNoExceptionWithMessage("test setScreenBrightness additional", - function(){ - power.setScreenBrightness(0.1, ERROR_STR); - } - ); -} - -function UTC_power_setScreenBrightness_N_001() -{ - TestEngine.log("UTC_power_setScreenBrightness_N_001"); - - TestEngine.log("First parameter check."); - TestEngine.catchErrorType("name", TYPE_MISMATCH_ERR, power, "setScreenBrightness", ERROR_STR); -} - -function UTC_power_isScreenOn_P_001() -{ - TestEngine.log("UTC_power_isScreenOn_P_001"); - - testNoExceptionWithMessage("test isScreenOn", - function(){ - power.isScreenOn(); - } - ); - - testNoExceptionWithMessage("test isScreenOn additional", - function(){ - power.isScreenOn(ERROR_STR); - } - ); -} - -function UTC_power_restoreScreenBrightness_P_001() -{ - TestEngine.log("UTC_power_restoreScreenBrightness_P_001"); - - testNoExceptionWithMessage("test restoreScreenBrightness", - function(){ - power.restoreScreenBrightness(); - } - ); - - testNoExceptionWithMessage("test restoreScreenBrightness additional", - function(){ - power.restoreScreenBrightness(ERROR_STR); - } - ); -} - -function UTC_power_turnScreenOff_P_001() -{ - TestEngine.log("UTC_power_turnScreenOff_P_001"); - - testNoExceptionWithMessage("test turnScreenOff", - function(){ - power.turnScreenOff(); - } - ); - - testNoExceptionWithMessage("test turnScreenOff additional", - function(){ - power.turnScreenOff(ERROR_STR); - } - ); -} - -function UTC_power_turnScreenOn_P_001() -{ - TestEngine.log("UTC_power_turnScreenOn_P_001"); - - testNoExceptionWithMessage("test turnScreenOn", - function(){ - power.turnScreenOn(); - } - ); - - testNoExceptionWithMessage("test turnScreenOn additional", - function(){ - power.turnScreenOn(ERROR_STR); - } - ); -} - -//============================================================================= -TestEngine.setTestSuiteName("[Tizen][Power]", 30 * 1000); -TestEngine.addTest(true, UTC_power_module_presence_P_001, "[Tizen][Power] UTC_power_module_presence_P_001"); -TestEngine.addTest(true, UTC_power_request_P_001, "[Tizen][Power] UTC_power_request_P_001"); -TestEngine.addTest(true, UTC_power_request_N_001, "[Tizen][Power] UTC_power_request_N_001"); -TestEngine.addTest(true, UTC_power_release_N_001, "[Tizen][Power] UTC_power_release_N_001"); -TestEngine.addTest(true, UTC_power_release_P_001, "[Tizen][Power] UTC_power_release_P_001"); -TestEngine.addTest(true, UTC_power_setScreenStateChangeListener_P_001, "[Tizen][Power] UTC_power_setScreenStateChangeListener_P_001"); -TestEngine.addTest(true, UTC_power_setScreenStateChangeListener_N_001, "[Tizen][Power] UTC_power_setScreenStateChangeListener_N_001"); -TestEngine.addTest(true, UTC_power_unsetScreenStateChangeListener_P_001, "[Tizen][Power] UTC_power_unsetScreenStateChangeListener_P_001"); -TestEngine.addTest(true, UTC_power_getScreenBrightness_P_001, "[Tizen][Power] UTC_power_getScreenBrightness_P_001"); -TestEngine.addTest(true, UTC_power_setScreenBrightness_P_001, "[Tizen][Power] UTC_power_setScreenBrightness_P_001"); -TestEngine.addTest(true, UTC_power_setScreenBrightness_N_001, "[Tizen][Power] UTC_power_setScreenBrightness_N_001"); -TestEngine.addTest(true, UTC_power_isScreenOn_P_001, "[Tizen][Power] UTC_power_isScreenOn_P_001"); -TestEngine.addTest(true, UTC_power_restoreScreenBrightness_P_001, "[Tizen][Power] UTC_power_restoreScreenBrightness_P_001"); -TestEngine.addTest(true, UTC_power_turnScreenOff_P_001, "[Tizen][Power] UTC_power_turnScreenOff_P_001"); -TestEngine.addTest(true, UTC_power_turnScreenOn_P_001, "[Tizen][Power] UTC_power_turnScreenOn_P_001"); -//============================================================================= - -function testNoExceptionWithMessage(message, fun) { - var testResult = true; - try - { - fun(); - } - catch (e) - { - testResult = false; - } - TestEngine.test(message, testResult); -} - diff --git a/src/Power/test/main.cpp b/src/Power/test/main.cpp deleted file mode 100755 index 385b7b6..0000000 --- a/src/Power/test/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2013 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 -#include -#include -#include "StandaloneConsole.h" -#include -#include -#include - -#include -#include -#include - -using namespace std; -using namespace DeviceAPI::Test; -using namespace DeviceAPI::Common; -using namespace DeviceAPI::Power; -using namespace WrtDeviceApis::Commons; - - -namespace DeviceAPI{ -namespace Power{ -AceFunction getPowerFunctionData(const std::string & functionId){ - return AceFunction(); -} -} -} - -void loopQuit(void *data, Ecore_Thread *thread){ - ecore_main_loop_quit(); -} - -void threadRun(void *data, Ecore_Thread *thread){ - StandaloneConsole *console = (StandaloneConsole*)data; - StandaloneConsole::commandline(console); -} - -int main(int argc, char** argv){ - - if (!ecore_init()) - { - printf("ERROR: Cannot init Ecore!\n"); - return -1; - } - ecore_main_loop_glib_integrate(); - - DPL::Log::LogSystemSingleton::Instance().SetTag("STANDALONE"); - //DPL::Event::GetMainEventDispatcherInstance().ResetCrossEventCallHandler(); - try{ - WrtAccessSingleton::Instance().initialize(0); - }catch(...){ - printf("ERROR: Cannot init WrtAccessSingleton\n"); - return -1; - } - - - StandaloneConsole console; - console.initialize(); - GlobalContextManager::getInstance()->addGlobalContext(console.getGlobalContext()); - console.registModule("power", JSPowerManager::getClassRef(), NULL); - - if( argc > 1 ){ - for(unsigned int i = 1 ; i< (unsigned int)argc; i++){ - console.RunScript(argv[i]); - } - } - - ecore_thread_run(threadRun, loopQuit, NULL, &console); - - ecore_main_loop_begin(); - ecore_shutdown(); - return 0; -} diff --git a/src/Push/CMakeLists.txt b/src/Push/CMakeLists.txt index b782951..bd40cb2 100644 --- a/src/Push/CMakeLists.txt +++ b/src/Push/CMakeLists.txt @@ -32,7 +32,6 @@ TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} ${LIBS_COMMON} ${tizen_impl} ${application_impl} - "-Wl,--no-as-needed" ${application_config} ${platform_pkgs_push_LIBRARIES} ) diff --git a/src/SystemSetting/CMakeLists.txt b/src/SystemSetting/CMakeLists.txt index fad59ee..a96597c 100644 --- a/src/SystemSetting/CMakeLists.txt +++ b/src/SystemSetting/CMakeLists.txt @@ -34,7 +34,6 @@ ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_COMMON} ${filesystem_impl} - "-Wl,--no-as-needed" ${filesystem_config} ${platform_pkgs_systemsetting_LIBRARIES} )