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 ContactConverter.cpp
20 * @author Kisub Song (kisubs.song@samsung.com)
25 #ifndef _TIZEN_JS_CONTACT_CONVERTER_H_
26 #define _TIZEN_JS_CONTACT_CONVERTER_H_
28 #include <JavaScriptCore/JavaScript.h>
29 #include <CommonsJavaScript/Converter.h>
30 #include "ContactTypes.h"
31 #include "IAddressBook.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>
52 class DLL_EXPORT ContactConverter : public WrtDeviceApis::CommonsJavaScript::Converter
55 using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
57 explicit ContactConverter(JSContextRef context);
58 virtual ~ContactConverter();
60 JSValueRef toJSValueRef(const AddressBookPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
61 AddressBookPtr toAddressBook(const JSValueRef &jsValue);
63 JSValueRef toJSValueRef(const AddressBookArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
64 AddressBookArrayPtr toAddressBookArray(const JSValueRef &jsValue);
66 JSValueRef toJSValueRef(const ContactPtr &arg);
67 ContactPtr toContact(const JSValueRef &jsValue);
68 ContactPtr toContactFromInit(const JSValueRef &jsValue);
70 JSValueRef toJSValueRef(const ContactArrayPtr &arg);
71 ContactArrayPtr toContactArray(const JSValueRef &jsValue);
73 JSValueRef toJSValueRef(const ContactGroupPtr &arg);
74 ContactGroupPtr toContactGroup(const JSValueRef &jsValue);
76 JSValueRef toJSValueRef(const ContactGroupArrayPtr &arg);
77 ContactGroupArrayPtr toContactGroupArray(const JSValueRef &jsValue);
79 JSValueRef toJSValueRef(const PersonPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
80 PersonPtr toPerson(const JSValueRef &jsValue);
82 JSValueRef toJSValueRef(const PersonArrayPtr &arg, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
83 PersonArrayPtr toPersonArray(const JSValueRef &jsValue);
85 JSValueRef toJSValueRef(const ContactRefPtr &arg);
86 ContactRefPtr toContactRef(const JSValueRef &jsValue);
88 JSValueRef toJSValueRef(const ContactNamePtr &arg);
89 ContactNamePtr toContactName(const JSValueRef &jsValue);
90 ContactNamePtr toContactNameFromInit(const JSValueRef &jsValue);
92 JSValueRef toJSValueRef(const ContactOrganizationPtr &arg);
93 ContactOrganizationPtr toContactOrganization(const JSValueRef &jsValue);
94 ContactOrganizationPtr toContactOrganizationFromInit(const JSValueRef &jsValue);
96 JSValueRef toJSValueRef(const ContactOrganizationArrayPtr &arg);
97 ContactOrganizationArrayPtr toContactOrganizationArray(const JSValueRef &jsValue);
99 JSValueRef toJSValueRef(const ContactWebSitePtr &arg);
100 ContactWebSitePtr toContactWebSite(const JSValueRef &jsValue);
102 JSValueRef toJSValueRef(const ContactWebSiteArrayPtr &arg);
103 ContactWebSiteArrayPtr toContactWebSiteArray(const JSValueRef &jsValue);
105 JSValueRef toJSValueRef(const ContactAnniversaryPtr &arg);
106 ContactAnniversaryPtr toContactAnniversary(const JSValueRef &jsValue);
108 JSValueRef toJSValueRef(const ContactAnniversaryArrayPtr &arg);
109 ContactAnniversaryArrayPtr toContactAnniversaryArray(const JSValueRef &jsValue);
111 JSValueRef toJSValueRef(const ContactAddressPtr &arg);
112 ContactAddressPtr toContactAddress(const JSValueRef &jsValue);
113 ContactAddressPtr toContactAddressFromInit(const JSValueRef &jsValue);
115 JSValueRef toJSValueRef(const ContactAddressArrayPtr &arg);
116 ContactAddressArrayPtr toContactAddressArray(const JSValueRef &jsValue);
118 JSValueRef toJSValueRef(const ContactPhoneNumberPtr &arg);
119 ContactPhoneNumberPtr toContactPhoneNumber(const JSValueRef &jsValue);
121 JSValueRef toJSValueRef(const ContactPhoneNumberArrayPtr &arg);
122 ContactPhoneNumberArrayPtr toContactPhoneNumberArray(const JSValueRef &jsValue);
124 JSValueRef toJSValueRef(const ContactEmailAddressPtr &arg);
125 ContactEmailAddressPtr toContactEmailAddress(const JSValueRef &jsValue);
127 JSValueRef toJSValueRef(const ContactEmailAddressArrayPtr &arg);
128 ContactEmailAddressArrayPtr toContactEmailAddressArray(const JSValueRef &jsValue);
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);
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);
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);
148 // ContactAddressType Array
149 JSValueRef toJSValueRef(const ContactAddressTypeArrayPtr &arg);
150 ContactAddressTypeArrayPtr toContactAddressTypeArray(const JSValueRef &jsValue);
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);
158 // ContactPhoneNumberType Array
159 JSValueRef toJSValueRef(const ContactPhoneNumberTypeArrayPtr &arg);
160 ContactPhoneNumberTypeArrayPtr toContactPhoneNumberTypeArray(const JSValueRef &jsValue);
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);
168 // ContactEmailAddressType Array
169 JSValueRef toJSValueRef(const ContactEmailAddressTypeArrayPtr &arg);
170 ContactEmailAddressTypeArrayPtr toContactEmailAddressTypeArray(const JSValueRef &jsValue);
173 StringArrayPtr toStringArray(const JSValueRef &value);
174 JSValueRef toJSValueRef(const StringArrayPtr &arg);
176 // AttributesOfInterest Array - No more used
177 // JSValueRef toJSValueRefAttributesOfInterestArray(const AttributesOfInterestArrayPtr &arg);
178 // AttributesOfInterestArrayPtr toAttributesOfInterestArray(const JSValueRef &jsValue);
180 // JSValueRef toJSValueRef(const std::string &arg);
181 // std::string toAttributesOfInterest(const JSValueRef &value);
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;
191 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<ContactConverter> ContactConverterFactory;
196 #endif // _TIZEN_JS_CONTACT_CONVERTER_H_