2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include <Commons/plugin_initializer_def.h>
19 #include <Commons/WrtAccess/WrtAccess.h>
20 #include <Commons/Exception.h>
21 #include <TimeTracer.h>
22 #include "JSAlarmManager.h"
23 #include "JSAlarmAbsolute.h"
24 #include "JSAlarmRelative.h"
27 #include "plugin_config.h"
29 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
34 using namespace WrtDeviceApis;
35 using namespace WrtDeviceApis::Commons;
36 using namespace WrtDeviceApis::CommonsJavaScript;
38 AceSecurityStatus alarmAceCheckAccessFunction(const char* functionName)
40 return ALARM_CHECK_ACCESS(functionName);
43 DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
45 DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerAlarmSetter,
46 DeviceAPI::Common::SecurityAccessor,
49 class_definition_options_t ClassOptions =
55 AceCheckerAlarmSetter,
60 class_definition_options_t ConstructorClassOptions =
65 USE_OVERLAYED, //ignored
71 void on_widget_start_callback(int widgetId)
73 LoggerI("[Tizen\\AlarmManager ] on_widget_start_callback (" << widgetId << ")");
77 WrtAccessSingleton::Instance().initialize(widgetId);
79 Catch(Commons::Exception)
81 LoggerE("WrtAccess initialization failed");
84 INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, alarmAceCheckAccessFunction);
87 void on_widget_stop_callback(int widgetId)
89 LoggerI("[Tizen\\AlarmManager ] on_widget_stop_callback (" << widgetId << ")");
92 TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"Alarm");
93 TIME_TRACER_RELEASE();
94 WrtAccessSingleton::Instance().deinitialize(widgetId);
96 Catch(Commons::Exception)
98 LoggerE("WrtAccess deinitialization failed");
101 FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
104 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
105 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
107 PLUGIN_CLASS_MAP_BEGIN
108 PLUGIN_CLASS_MAP_ADD_CLASS(
109 WRT_JS_EXTENSION_OBJECT_TIZEN,
111 (js_class_template_getter)DeviceAPI::Alarm::JSAlarmManager::getClassRef,
113 PLUGIN_CLASS_MAP_ADD_INTERFACE(
114 WRT_JS_EXTENSION_OBJECT_TIZEN,
115 TIZEN_ALARM_ABSOLUTE_INTERFACE,
116 (js_class_template_getter)DeviceAPI::Alarm::JSAlarmAbsolute::getClassRef,
117 reinterpret_cast<js_class_constructor_cb_t>(DeviceAPI::Alarm::JSAlarmAbsolute::constructor),
118 &ConstructorClassOptions)
119 PLUGIN_CLASS_MAP_ADD_INTERFACE(
120 WRT_JS_EXTENSION_OBJECT_TIZEN,
121 TIZEN_ALARM_RELATIVE_INTERFACE,
122 (js_class_template_getter)DeviceAPI::Alarm::JSAlarmRelative::getClassRef,
123 reinterpret_cast<js_class_constructor_cb_t>(DeviceAPI::Alarm::JSAlarmRelative::constructor),
124 &ConstructorClassOptions)