wrt-plugins-tizen_0.4.23
[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 "JSContactManager.h"
29 #include "JSContact.h"
30 #include "JSContactGroup.h"
31 #include "JSContactRef.h"
32 #include "JSContactName.h"
33 #include "JSContactOrganization.h"
34 #include "JSContactWebSite.h"
35 #include "JSContactAnniversary.h"
36 #include "JSContactAddress.h"
37 #include "JSContactPhoneNumber.h"
38 #include "JSContactEmailAddress.h"
39 #include "ContactAsyncCallbackManager.h"
40 #include "ContactListenerManager.h"
41 #include <Logger.h>
42
43 namespace DeviceAPI {
44 namespace Contact {
45
46 using namespace WrtDeviceApis;
47 using namespace WrtDeviceApis::Commons;
48
49 void on_widget_start_callback(int widgetId)
50 {
51     LoggerD("[Tizen\\contact] on_widget_start_callback (" << widgetId << ")");
52         TIME_TRACER_INIT();
53     Try
54     {
55         WrtAccessSingleton::Instance().initialize(widgetId);
56     }
57     Catch(Commons::Exception)
58     {
59         LoggerE("WrtAccess initialization failed");
60     }
61 }
62
63 void on_widget_stop_callback(int widgetId)
64 {
65     LoggerD("[Tizen\\contact] on_widget_stop_callback (" << widgetId << ")");
66         TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"Contact");
67         TIME_TRACER_RELEASE();
68     Try
69     {
70         WrtAccessSingleton::Instance().deinitialize(widgetId);
71     }
72     Catch(Commons::Exception)
73     {
74         LoggerE("WrtAccess deinitialization failed");
75     }
76 }
77
78 void on_frame_load_callback(const void * context)
79 {
80     LoggerD("[Tizen\\contact] on_frame_load_callback (" << context << ")");
81 }
82
83 void on_frame_unload_callback(const void * context)
84 {
85     LoggerD("[Tizen\\contact] on_frame_unload_callback (" << context << ")");
86
87     DeviceAPI::Contact::ContactAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
88     DeviceAPI::Contact::ContactListenerManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
89 }
90
91 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
92 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
93 PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
94 PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
95
96 PLUGIN_CLASS_MAP_BEGIN
97     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
98                                "contact",
99                                (js_class_template_getter)DeviceAPI::Contact::JSContactManager::getClassRef,
100                                NULL)
101     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
102                                "Contact",
103                                (js_class_template_getter)DeviceAPI::Contact::JSContact::getClassRef,
104                                NULL)
105     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
106                                "ContactGroup",
107                                (js_class_template_getter)DeviceAPI::Contact::JSContactGroup::getClassRef,
108                                NULL)
109     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
110                                "ContactRef",
111                                (js_class_template_getter)DeviceAPI::Contact::JSContactRef::getClassRef,
112                                NULL)
113     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
114                                "ContactName",
115                                (js_class_template_getter)DeviceAPI::Contact::JSContactName::getClassRef,
116                                NULL)
117     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
118                                "ContactOrganization",
119                                (js_class_template_getter)DeviceAPI::Contact::JSContactOrganization::getClassRef,
120                                NULL)
121     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
122                                "ContactWebSite",
123                                (js_class_template_getter)DeviceAPI::Contact::JSContactWebSite::getClassRef,
124                                NULL)
125     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
126                                "ContactAnniversary",
127                                (js_class_template_getter)DeviceAPI::Contact::JSContactAnniversary::getClassRef,
128                                NULL)
129     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
130                                "ContactAddress",
131                                (js_class_template_getter)DeviceAPI::Contact::JSContactAddress::getClassRef,
132                                NULL)
133     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
134                                "ContactPhoneNumber",
135                                (js_class_template_getter)DeviceAPI::Contact::JSContactPhoneNumber::getClassRef,
136                                NULL)
137     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
138                                "ContactEmailAddress",
139                                (js_class_template_getter)DeviceAPI::Contact::JSContactEmailAddress::getClassRef,
140                                NULL)
141 PLUGIN_CLASS_MAP_END
142
143 } // Contact
144 } // DeviceAPI
145