Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Contact / plugin_initializer.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        plugin_initializer.cpp
20  * @author      Karol Majewski (k.majewski@samsung.com)
21  * @version     0.1
22  * @brief
23  */
24
25 #include <Commons/plugin_initializer_def.h>
26 #include <Commons/WrtAccess/WrtAccess.h>
27 #include <TimeTracer.h>
28 #include <Security.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"
43 #include <Logger.h>
44
45 namespace DeviceAPI {
46 namespace Contact {
47
48 using namespace WrtDeviceApis;
49 using namespace WrtDeviceApis::Commons;
50
51 AceSecurityStatus contactAceCheckAccessFunction(const char* functionName)
52 {
53     return CONTACT_CHECK_ACCESS(functionName);
54 }
55
56 DEFINE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
57
58 DEFINE_SECURITY_ACCESSOR_SETTER(AceCheckerContactSetter, ContactManagerController, gSecurityAccessor);
59
60 class_definition_options_t option =
61 {
62         JS_CLASS,
63         NONE,
64         ALWAYS_NOTICE,
65         IGNORED,
66         AceCheckerContactSetter,
67         NULL,
68         NULL
69 };
70
71 void on_widget_start_callback(int widgetId)
72 {
73     LoggerD("[Tizen\\contact] on_widget_start_callback (" << widgetId << ")");
74         TIME_TRACER_INIT();
75     Try
76     {
77         WrtAccessSingleton::Instance().initialize(widgetId);
78     }
79     Catch(Commons::Exception)
80     {
81         LoggerE("WrtAccess initialization failed");
82     }
83
84     INITAILIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor, contactAceCheckAccessFunction);
85 }
86
87 void on_widget_stop_callback(int widgetId)
88 {
89     LoggerD("[Tizen\\contact] on_widget_stop_callback (" << widgetId << ")");
90         TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"Contact");
91         TIME_TRACER_RELEASE();
92     Try
93     {
94         WrtAccessSingleton::Instance().deinitialize(widgetId);
95     }
96     Catch(Commons::Exception)
97     {
98         LoggerE("WrtAccess deinitialization failed");
99     }
100
101     FINALIZE_GLOBAL_SECURITY_ACCESSOR(gSecurityAccessor);
102 }
103
104 void on_frame_load_callback(const void * context)
105 {
106     LoggerD("[Tizen\\contact] on_frame_load_callback (" << context << ")");
107 }
108
109 void on_frame_unload_callback(const void * context)
110 {
111     LoggerD("[Tizen\\contact] on_frame_unload_callback (" << context << ")");
112
113     DeviceAPI::Contact::ContactAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
114     DeviceAPI::Contact::ContactListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
115 }
116
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)
121
122 PLUGIN_CLASS_MAP_BEGIN
123     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
124                                "contact",
125                                (js_class_template_getter)DeviceAPI::Contact::JSContactManager::getClassRef,
126                                &option)
127     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
128                                "Contact",
129                                (js_class_template_getter)DeviceAPI::Contact::JSContact::getClassRef,
130                                NULL)
131     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
132                                "ContactGroup",
133                                (js_class_template_getter)DeviceAPI::Contact::JSContactGroup::getClassRef,
134                                NULL)
135     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
136                                "ContactRef",
137                                (js_class_template_getter)DeviceAPI::Contact::JSContactRef::getClassRef,
138                                NULL)
139     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
140                                "ContactName",
141                                (js_class_template_getter)DeviceAPI::Contact::JSContactName::getClassRef,
142                                NULL)
143     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
144                                "ContactOrganization",
145                                (js_class_template_getter)DeviceAPI::Contact::JSContactOrganization::getClassRef,
146                                NULL)
147     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
148                                "ContactWebSite",
149                                (js_class_template_getter)DeviceAPI::Contact::JSContactWebSite::getClassRef,
150                                NULL)
151     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
152                                "ContactAnniversary",
153                                (js_class_template_getter)DeviceAPI::Contact::JSContactAnniversary::getClassRef,
154                                NULL)
155     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
156                                "ContactAddress",
157                                (js_class_template_getter)DeviceAPI::Contact::JSContactAddress::getClassRef,
158                                NULL)
159     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
160                                "ContactPhoneNumber",
161                                (js_class_template_getter)DeviceAPI::Contact::JSContactPhoneNumber::getClassRef,
162                                NULL)
163     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
164                                "ContactEmailAddress",
165                                (js_class_template_getter)DeviceAPI::Contact::JSContactEmailAddress::getClassRef,
166                                NULL)
167 PLUGIN_CLASS_MAP_END
168
169 } // Contact
170 } // DeviceAPI
171