Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Contact / ContactConverter.h
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        ContactConverter.cpp
20  * @author      Kisub Song (kisubs.song@samsung.com)
21  * @version     0.1
22  * @brief
23  */
24
25 #ifndef _TIZEN_JS_CONTACT_CONVERTER_H_
26 #define _TIZEN_JS_CONTACT_CONVERTER_H_
27
28 #include <JavaScriptCore/JavaScript.h>
29 #include <CommonsJavaScript/Converter.h>
30 #include "ContactTypes.h"
31 #include "IAddressBook.h"
32 #include "IContact.h"
33 #include "IPerson.h"
34 #include "ContactGroup.h"
35 #include "ContactRef.h"
36 #include "ContactName.h"
37 #include "ContactOrganization.h"
38 #include "ContactWebSite.h"
39 #include "ContactAnniversary.h"
40 #include "ContactAddress.h"
41 #include "ContactPhoneNumber.h"
42 #include "ContactEmailAddress.h"
43 #include <ArgumentValidator.h>
44 #include <JSWebAPIErrorFactory.h>
45 #include <Security.h>
46 #include <JSUtil.h>
47 #include <Export.h>
48
49 namespace DeviceAPI {
50 namespace Contact {
51
52 class DLL_EXPORT ContactConverter : public WrtDeviceApis::CommonsJavaScript::Converter
53 {
54 public:
55         using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
56
57         explicit ContactConverter(JSContextRef context);
58         virtual ~ContactConverter();
59
60         JSValueRef toJSValueRef(const AddressBookPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
61         AddressBookPtr toAddressBook(const JSValueRef &jsValue);
62
63         JSValueRef toJSValueRef(const AddressBookArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
64         AddressBookArrayPtr toAddressBookArray(const JSValueRef &jsValue);
65
66         JSValueRef toJSValueRef(const ContactPtr &arg);
67         ContactPtr toContact(const JSValueRef &jsValue);
68         ContactPtr toContactFromInit(const JSValueRef &jsValue);
69
70         JSValueRef toJSValueRef(const ContactArrayPtr &arg);
71         ContactArrayPtr toContactArray(const JSValueRef &jsValue);
72
73         JSValueRef toJSValueRef(const ContactGroupPtr &arg);
74         ContactGroupPtr toContactGroup(const JSValueRef &jsValue);
75
76         JSValueRef toJSValueRef(const ContactGroupArrayPtr &arg);
77         ContactGroupArrayPtr toContactGroupArray(const JSValueRef &jsValue);
78
79         JSValueRef toJSValueRef(const PersonPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
80         PersonPtr toPerson(const JSValueRef &jsValue);
81
82         JSValueRef toJSValueRef(const PersonArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
83         PersonArrayPtr toPersonArray(const JSValueRef &jsValue);
84
85         JSValueRef toJSValueRef(const ContactRefPtr &arg);
86         ContactRefPtr toContactRef(const JSValueRef &jsValue);
87
88         JSValueRef toJSValueRef(const ContactNamePtr &arg);
89         ContactNamePtr toContactName(const JSValueRef &jsValue);
90         ContactNamePtr toContactNameFromInit(const JSValueRef &jsValue);
91
92         JSValueRef toJSValueRef(const ContactOrganizationPtr &arg);
93         ContactOrganizationPtr toContactOrganization(const JSValueRef &jsValue);
94         ContactOrganizationPtr toContactOrganizationFromInit(const JSValueRef &jsValue);
95
96         JSValueRef toJSValueRef(const ContactOrganizationArrayPtr &arg);
97         ContactOrganizationArrayPtr toContactOrganizationArray(const JSValueRef &jsValue);
98
99         JSValueRef toJSValueRef(const ContactWebSitePtr &arg);
100         ContactWebSitePtr toContactWebSite(const JSValueRef &jsValue);
101
102         JSValueRef toJSValueRef(const ContactWebSiteArrayPtr &arg);
103         ContactWebSiteArrayPtr toContactWebSiteArray(const JSValueRef &jsValue);
104
105         JSValueRef toJSValueRef(const ContactAnniversaryPtr &arg);
106         ContactAnniversaryPtr toContactAnniversary(const JSValueRef &jsValue);
107
108         JSValueRef toJSValueRef(const ContactAnniversaryArrayPtr &arg);
109         ContactAnniversaryArrayPtr toContactAnniversaryArray(const JSValueRef &jsValue);
110
111         JSValueRef toJSValueRef(const ContactAddressPtr &arg);
112         ContactAddressPtr toContactAddress(const JSValueRef &jsValue);
113         ContactAddressPtr toContactAddressFromInit(const JSValueRef &jsValue);
114
115         JSValueRef toJSValueRef(const ContactAddressArrayPtr &arg);
116         ContactAddressArrayPtr toContactAddressArray(const JSValueRef &jsValue);
117
118         JSValueRef toJSValueRef(const ContactPhoneNumberPtr &arg);
119         ContactPhoneNumberPtr toContactPhoneNumber(const JSValueRef &jsValue);
120
121         JSValueRef toJSValueRef(const ContactPhoneNumberArrayPtr &arg);
122         ContactPhoneNumberArrayPtr toContactPhoneNumberArray(const JSValueRef &jsValue);
123
124         JSValueRef toJSValueRef(const ContactEmailAddressPtr &arg);
125         ContactEmailAddressPtr toContactEmailAddress(const JSValueRef &jsValue);
126
127         JSValueRef toJSValueRef(const ContactEmailAddressArrayPtr &arg);
128         ContactEmailAddressArrayPtr toContactEmailAddressArray(const JSValueRef &jsValue);
129
130         // ContactWebSiteType
131         ContactWebSiteType toContactWebSiteType(const std::string &arg);
132         std::string toContactWebSiteTypeStr(ContactWebSiteType arg);
133         ContactWebSiteType toContactWebSiteType(const JSValueRef &value);
134         JSValueRef toJSValueRef(ContactWebSiteType arg);
135
136         // ContactOrganizationType
137         ContactOrganizationType toContactOrganizationType(const std::string &arg);
138         std::string toContactOrganizationTypeStr(ContactOrganizationType arg);
139         ContactOrganizationType toContactOrganizationType(const JSValueRef &value);
140         JSValueRef toJSValueRef(ContactOrganizationType arg);
141
142         // ContactAddressType
143         ContactAddressType toContactAddressType(const std::string &arg);
144         std::string toContactAddressTypeStr(ContactAddressType arg);
145         ContactAddressType toContactAddressType(const JSValueRef &value);
146         JSValueRef toJSValueRef(ContactAddressType arg);
147
148         // ContactAddressType Array
149         JSValueRef toJSValueRef(const ContactAddressTypeArrayPtr &arg);
150         ContactAddressTypeArrayPtr toContactAddressTypeArray(const JSValueRef &jsValue);
151
152         // ContactPhoneNumberType
153         ContactPhoneNumberType toContactPhoneNumberType(const std::string &arg);
154         std::string toContactPhoneNumberTypeStr(ContactPhoneNumberType arg);
155         ContactPhoneNumberType toContactPhoneNumberType(const JSValueRef &value);
156         JSValueRef toJSValueRef(ContactPhoneNumberType arg);
157
158         // ContactPhoneNumberType Array
159         JSValueRef toJSValueRef(const ContactPhoneNumberTypeArrayPtr &arg);
160         ContactPhoneNumberTypeArrayPtr toContactPhoneNumberTypeArray(const JSValueRef &jsValue);
161
162         // ContactEmailAddressType
163         ContactEmailAddressType toContactEmailAddressType(const std::string &arg);
164         std::string toContactEmailAddressTypeStr(ContactEmailAddressType arg);
165         ContactEmailAddressType toContactEmailAddressType(const JSValueRef &value);
166         JSValueRef toJSValueRef(ContactEmailAddressType arg);
167
168         // ContactEmailAddressType Array
169         JSValueRef toJSValueRef(const ContactEmailAddressTypeArrayPtr &arg);
170         ContactEmailAddressTypeArrayPtr toContactEmailAddressTypeArray(const JSValueRef &jsValue);
171
172         // String Array
173         StringArrayPtr toStringArray(const JSValueRef &value);
174         JSValueRef toJSValueRef(const StringArrayPtr &arg);
175
176         // AttributesOfInterest Array - No more used
177 //      JSValueRef toJSValueRefAttributesOfInterestArray(const AttributesOfInterestArrayPtr &arg);
178 //      AttributesOfInterestArrayPtr toAttributesOfInterestArray(const JSValueRef &jsValue);
179
180 //      JSValueRef toJSValueRef(const std::string &arg);
181 //      std::string toAttributesOfInterest(const JSValueRef &value);
182
183 private:
184         bool initializeAllowedProperties();
185         static std::vector<std::string> m_allowedContactInit;
186         static std::vector<std::string> m_allowedContactNameInit;
187         static std::vector<std::string> m_allowedContactOrganizationInit;
188         static std::vector<std::string> m_allowedContactAddressInit;
189 };
190
191 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<ContactConverter> ContactConverterFactory;
192
193 } // Contact
194 } // DeviceAPI
195
196 #endif // _TIZEN_JS_CONTACT_CONVERTER_H_