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.
19 * @file plugin_initializer.cpp
20 * @author Karol Majewski (k.majewski@samsung.com)
25 #include <Commons/plugin_initializer_def.h>
26 #include <Commons/WrtAccess/WrtAccess.h>
27 #include <TimeTracer.h>
29 #include "JSContactManager.h"
30 #include "JSContact.h"
31 #include "JSContactGroup.h"
32 #include "JSContactRef.h"
33 #include "JSContactName.h"
34 #include "JSContactOrganization.h"
35 #include "JSContactWebSite.h"
36 #include "JSContactAnniversary.h"
37 #include "JSContactAddress.h"
38 #include "JSContactPhoneNumber.h"
39 #include "JSContactEmailAddress.h"
40 #include "ContactAsyncCallbackManager.h"
41 #include "ContactListenerManager.h"
42 #include "plugin_config.h"
48 using namespace WrtDeviceApis;
49 using namespace WrtDeviceApis::Commons;
51 AceSecurityStatus contactAceCheckAccessFunction(const char* functionName)
53 return CONTACT_CHECK_ACCESS(functionName);
56 DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
58 DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerContactSetter, ContactManagerController, gSecurityAccessor);
60 class_definition_options_t option =
66 AceCheckerContactSetter,
71 void on_widget_start_callback(int widgetId)
73 LoggerD("[Tizen\\contact] 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, contactAceCheckAccessFunction);
87 void on_widget_stop_callback(int widgetId)
89 LoggerD("[Tizen\\contact] on_widget_stop_callback (" << widgetId << ")");
90 TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"Contact");
91 TIME_TRACER_RELEASE();
94 WrtAccessSingleton::Instance().deinitialize(widgetId);
96 Catch(Commons::Exception)
98 LoggerE("WrtAccess deinitialization failed");
101 FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
104 void on_frame_load_callback(const void * context)
106 LoggerD("[Tizen\\contact] on_frame_load_callback (" << context << ")");
109 void on_frame_unload_callback(const void * context)
111 LoggerD("[Tizen\\contact] on_frame_unload_callback (" << context << ")");
113 DeviceAPI::Contact::ContactAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
114 DeviceAPI::Contact::ContactListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
117 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
118 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
119 PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
120 PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
122 PLUGIN_CLASS_MAP_BEGIN
123 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
125 (js_class_template_getter)DeviceAPI::Contact::JSContactManager::getClassRef,
127 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
129 (js_class_template_getter)DeviceAPI::Contact::JSContact::getClassRef,
131 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
133 (js_class_template_getter)DeviceAPI::Contact::JSContactGroup::getClassRef,
135 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
137 (js_class_template_getter)DeviceAPI::Contact::JSContactRef::getClassRef,
139 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
141 (js_class_template_getter)DeviceAPI::Contact::JSContactName::getClassRef,
143 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
144 "ContactOrganization",
145 (js_class_template_getter)DeviceAPI::Contact::JSContactOrganization::getClassRef,
147 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
149 (js_class_template_getter)DeviceAPI::Contact::JSContactWebSite::getClassRef,
151 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
152 "ContactAnniversary",
153 (js_class_template_getter)DeviceAPI::Contact::JSContactAnniversary::getClassRef,
155 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
157 (js_class_template_getter)DeviceAPI::Contact::JSContactAddress::getClassRef,
159 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
160 "ContactPhoneNumber",
161 (js_class_template_getter)DeviceAPI::Contact::JSContactPhoneNumber::getClassRef,
163 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
164 "ContactEmailAddress",
165 (js_class_template_getter)DeviceAPI::Contact::JSContactEmailAddress::getClassRef,