722ae5549a757d3dee47021c525f8362bea94d92
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Contact / ContactConverter.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file        ContactConverter.cpp
19  * @author      Kisub Song (kisubs.song@samsung.com)
20  * @version     0.1
21  * @brief
22  */
23
24 #include <dpl/log/log.h>
25 #include <CommonsJavaScript/Validator.h>
26 #include <CommonsJavaScript/ScopedJSStringRef.h>
27 #include <CommonsJavaScript/JSUtils.h>
28 #include <Commons/RegexUtils.h>
29
30 #include "ContactConverter.h"
31 #include "AddressBookController.h"
32 #include "JSAddressBook.h"
33 #include "JSAddressBookArray.h"
34 #include "JSAttributesOfInterestArray.h"
35 #include "JSContact.h"
36 #include "JSContactArray.h"
37 #include "JSContactProperties.h"
38 #include "JSContactName.h"
39 #include "JSContactAccount.h"
40 #include "JSContactAnniversary.h"
41 #include "JSContactAnniversaryArray.h"
42 #include "JSContactAddress.h"
43 #include "JSContactAddressArray.h"
44 #include "JSContactAddressTypeArray.h"
45 #include "JSContactManager.h"
46 #include "JSContactPhoneNumber.h"
47 #include "JSContactPhoneNumberArray.h"
48 #include "JSContactPhoneNumberTypeArray.h"
49 #include "JSContactEmailAddress.h"
50 #include "JSContactEmailAddressArray.h"
51 #include "JSContactEmailAddressTypeArray.h"
52 #include "JSContactOrganization.h"
53 #include "JSContactOrganizationArray.h"
54 #include "JSContactWebSite.h"
55 #include "JSContactWebSiteArray.h"
56 #include "JSStringArray.h"
57
58 #define CONTACT_ATTRIBUTE_ACCOUNT "account"
59 #define CONTACT_ATTRIBUTE_ACCOUNT_ID "accountId"
60 #define CONTACT_ATTRIBUTE_ADDITIONAL_INFORMATION "additionalInformation"
61 #define CONTACT_ATTRIBUTE_ADDRESSES "addresses"
62 #define CONTACT_ATTRIBUTE_ANNIVERSARIES "anniversaries"
63 #define CONTACT_ATTRIBUTE_ATTRIBUTES_OF_INTEREST "attributesOfInterest"
64 #define CONTACT_ATTRIBUTE_BIRTHDAY "birthday"
65 #define CONTACT_ATTRIBUTE_CATEGORIES "categories"
66 #define CONTACT_ATTRIBUTE_CITY "city"
67 #define CONTACT_ATTRIBUTE_CONTACT_ID "contactId"
68 #define CONTACT_ATTRIBUTE_CONTACT_URI "contactURI"
69 #define CONTACT_ATTRIBUTE_COUNTRY "country"
70 #define CONTACT_ATTRIBUTE_COUNTY "county"
71 #define CONTACT_ATTRIBUTE_DATE "date"
72 #define CONTACT_ATTRIBUTE_DEPARTMENT "department"
73 #define CONTACT_ATTRIBUTE_DISPLAY_NAME "displayName"
74 #define CONTACT_ATTRIBUTE_EMAIL "email"
75 #define CONTACT_ATTRIBUTE_EMAILS "emails"
76 #define CONTACT_ATTRIBUTE_FIRST_NAME "firstName"
77 #define CONTACT_ATTRIBUTE_ID "id"
78 #define CONTACT_ATTRIBUTE_IS_FAVORITE "isFavorite"
79 #define CONTACT_ATTRIBUTE_LABEL "label"
80 #define CONTACT_ATTRIBUTE_LAST_NAME "lastName"
81 #define CONTACT_ATTRIBUTE_LAST_UPDATED "lastUpdated"
82 #define CONTACT_ATTRIBUTE_LOGO_URI "logoURI"
83 #define CONTACT_ATTRIBUTE_MIDDLE_NAME "middleName"
84 #define CONTACT_ATTRIBUTE_NAME "name"
85 #define CONTACT_ATTRIBUTE_NICKNAMES "nicknames"
86 #define CONTACT_ATTRIBUTE_NOTES "notes"
87 #define CONTACT_ATTRIBUTE_NUMBER "number"
88 #define CONTACT_ATTRIBUTE_OFFICE "office"
89 #define CONTACT_ATTRIBUTE_ORGANIZATION "organization"
90 #define CONTACT_ATTRIBUTE_PHONE_NUMBERS "phoneNumbers"
91 #define CONTACT_ATTRIBUTE_PHONETIC_NAME "phoneticName"
92 #define CONTACT_ATTRIBUTE_PHOTO_URI  "photoURI"
93 #define CONTACT_ATTRIBUTE_POSITION "position"
94 #define CONTACT_ATTRIBUTE_POSTAL_CODE "postalCode"
95 #define CONTACT_ATTRIBUTE_PREFIX "prefix"
96 #define CONTACT_ATTRIBUTE_READ_ONLY "readOnly"
97 #define CONTACT_ATTRIBUTE_REGION "region"
98 #define CONTACT_ATTRIBUTE_RINGTONE_URI "ringtoneURI"
99 #define CONTACT_ATTRIBUTE_ROLE "role"
100 #define CONTACT_ATTRIBUTE_STREET_ADDRESS "streetAddress"
101 #define CONTACT_ATTRIBUTE_TITLE "title"
102 #define CONTACT_ATTRIBUTE_TYPE "type"
103 #define CONTACT_ATTRIBUTE_TYPES "types"
104 #define CONTACT_ATTRIBUTE_URL "url"
105 #define CONTACT_ATTRIBUTE_URLS "urls"
106
107 #define STR_CONTACT_EMAIL_TYPE_WORK "WORK"
108 #define STR_CONTACT_EMAIL_TYPE_PREF "PREF"
109 #define STR_CONTACT_EMAIL_TYPE_HOME "HOME"
110
111 #define STR_CONTACT_PHONE_NUMBER_TYPE_WORK "WORK"
112 #define STR_CONTACT_PHONE_NUMBER_TYPE_PREF "PREF"
113 #define STR_CONTACT_PHONE_NUMBER_TYPE_HOME "HOME"
114 #define STR_CONTACT_PHONE_NUMBER_TYPE_VOICE "VOICE"
115 #define STR_CONTACT_PHONE_NUMBER_TYPE_FAX "FAX"
116 #define STR_CONTACT_PHONE_NUMBER_TYPE_MSG "MSG"
117 #define STR_CONTACT_PHONE_NUMBER_TYPE_CELL "CELL"
118 #define STR_CONTACT_PHONE_NUMBER_TYPE_PAGER "PAGER"
119 #define STR_CONTACT_PHONE_NUMBER_TYPE_BBS "BBS"
120 #define STR_CONTACT_PHONE_NUMBER_TYPE_MODEM "MODEM"
121 #define STR_CONTACT_PHONE_NUMBER_TYPE_CAR "CAR"
122 #define STR_CONTACT_PHONE_NUMBER_TYPE_ISDN "ISDN"
123 #define STR_CONTACT_PHONE_NUMBER_TYPE_VIDEO "VIDEO"
124 #define STR_CONTACT_PHONE_NUMBER_TYPE_PCS "PCS"
125
126 #define STR_CONTACT_ADDRESS_TYPE_WORK "WORK"
127 #define STR_CONTACT_ADDRESS_TYPE_PREF "PREF"
128 #define STR_CONTACT_ADDRESS_TYPE_HOME "HOME"
129
130 #define STR_WEBSITE_TYPE_HOMEPAGE "HOMEPAGE"
131 #define STR_WEBSITE_TYPE_BLOG "BLOG"
132
133 namespace TizenApis {
134 namespace Tizen1_0 {
135 namespace Contact {
136
137 using namespace TizenApis::Api::Contact;
138 using namespace WrtDeviceApis::Commons;
139 using namespace WrtDeviceApis::CommonsJavaScript;
140
141 std::vector<std::string> ContactConverter::m_allowedAddressBookProperties;
142 std::vector<std::string> ContactConverter::m_allowedContactProperties;
143 std::vector<std::string> ContactConverter::m_allowedContactPropertiesProperties;
144 std::vector<std::string> ContactConverter::m_allowedContactNameProperties;
145 std::vector<std::string> ContactConverter::m_allowedContactAccountProperties;
146 std::vector<std::string> ContactConverter::m_allowedContactOrganizationProperties;
147 std::vector<std::string> ContactConverter::m_allowedContactWebSiteProperties;
148 std::vector<std::string> ContactConverter::m_allowedContactAnniversaryProperties;
149 std::vector<std::string> ContactConverter::m_allowedContactAddressProperties;
150 std::vector<std::string> ContactConverter::m_allowedContactPhoneNumberProperties;
151 std::vector<std::string> ContactConverter::m_allowedContactEmailAddressProperties;
152
153 ContactConverter::ContactConverter(JSContextRef context) : Converter(context)
154 {
155 //    //LogDebug("entered");
156     static bool init = initializeAllowedProperties();
157     (void) init;
158 }
159
160 ContactConverter::~ContactConverter()
161 {
162 //    //LogDebug("entered");
163 }
164
165 StringArrayPtr ContactConverter::toStringArray(const JSValueRef &jsValue)
166 {
167         if(JSStringArray::isObjectOfClass(m_context, jsValue))
168                 return JSStringArray::getStringArray(m_context, jsValue);
169
170         StringArrayPtr result = StringArrayPtr(new StringArray());
171         JSObjectRef jsObject = toJSObjectRef(jsValue);
172     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
173         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
174         result->push_back(toString(element));
175     }
176     return result;
177 }
178
179 JSValueRef ContactConverter::toJSValueRef(const StringArrayPtr &arg)
180 {
181         return JSStringArray::createArray(m_context, arg);
182 }
183
184 // types converters
185 ContactEmailAddressType ContactConverter::toContactEmailAddressType(const std::string &arg)
186 {
187 //      //LogDebug("entered");
188         if (arg == STR_CONTACT_EMAIL_TYPE_WORK) {
189                 return CONTACT_EMAIL_TYPE_WORK;
190         } else if (arg == STR_CONTACT_EMAIL_TYPE_PREF) {
191                 return CONTACT_EMAIL_TYPE_PREF;
192         } else if (arg == STR_CONTACT_EMAIL_TYPE_HOME) {
193                 return CONTACT_EMAIL_TYPE_HOME;
194         } else {
195                 Throw(WrtDeviceApis::Commons::ConversionException);
196         }
197         return CONTACT_EMAIL_TYPE_PREF;
198 }
199
200 std::string ContactConverter::toContactEmailAddressTypeStr(ContactEmailAddressType arg)
201 {
202 //      //LogDebug("entered");
203         if (arg == CONTACT_EMAIL_TYPE_WORK) {
204                 return STR_CONTACT_EMAIL_TYPE_WORK;
205         } else if (arg == CONTACT_EMAIL_TYPE_PREF) {
206                 return STR_CONTACT_EMAIL_TYPE_PREF;
207         } else if (arg == CONTACT_EMAIL_TYPE_HOME) {
208                 return STR_CONTACT_EMAIL_TYPE_HOME;
209         } else {
210                 Throw(WrtDeviceApis::Commons::ConversionException);
211         }
212         return STR_CONTACT_EMAIL_TYPE_PREF;
213 }
214
215 ContactEmailAddressType ContactConverter::toContactEmailAddressType(const JSValueRef &value)
216 {
217         return toContactEmailAddressType(toString(value));
218 }
219
220 JSValueRef ContactConverter::toJSValueRef(ContactEmailAddressType arg)
221 {
222         return toJSValueRef(toContactEmailAddressTypeStr(arg));
223 }
224
225 ContactPhoneNumberType ContactConverter::toContactPhoneNumberType(const std::string &arg)
226 {
227 //      //LogDebug("entered");
228         if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_WORK) {
229                 return CONTACT_PHONE_NUMBER_TYPE_WORK;
230         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_PREF) {
231                 return CONTACT_PHONE_NUMBER_TYPE_PREF;
232         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_HOME) {
233                 return CONTACT_PHONE_NUMBER_TYPE_HOME;
234         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_VOICE) {
235                 return CONTACT_PHONE_NUMBER_TYPE_VOICE;
236         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_FAX) {
237                 return CONTACT_PHONE_NUMBER_TYPE_FAX;
238         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_MSG) {
239                 return CONTACT_PHONE_NUMBER_TYPE_MSG;
240         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_CELL) {
241                 return CONTACT_PHONE_NUMBER_TYPE_CELL;
242         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_PAGER) {
243                 return CONTACT_PHONE_NUMBER_TYPE_PAGER;
244         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_BBS) {
245                 return CONTACT_PHONE_NUMBER_TYPE_BBS;
246         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_MODEM) {
247                 return CONTACT_PHONE_NUMBER_TYPE_MODEM;
248         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_CAR) {
249                 return CONTACT_PHONE_NUMBER_TYPE_CAR;
250         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_ISDN) {
251                 return CONTACT_PHONE_NUMBER_TYPE_ISDN;
252         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_VIDEO) {
253                 return CONTACT_PHONE_NUMBER_TYPE_VIDEO;
254         } else if (arg == STR_CONTACT_PHONE_NUMBER_TYPE_PCS) {
255                 return CONTACT_PHONE_NUMBER_TYPE_PCS;
256         } else {
257                 Throw(WrtDeviceApis::Commons::ConversionException);
258         }
259         return CONTACT_PHONE_NUMBER_TYPE_WORK;
260 }
261
262 std::string ContactConverter::toContactPhoneNumberTypeStr(ContactPhoneNumberType arg)
263 {
264 //      //LogDebug("entered");
265         if (arg == CONTACT_PHONE_NUMBER_TYPE_WORK) {
266                 return STR_CONTACT_PHONE_NUMBER_TYPE_WORK;
267         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_PREF) {
268                 return STR_CONTACT_PHONE_NUMBER_TYPE_PREF;
269         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_HOME) {
270                 return STR_CONTACT_PHONE_NUMBER_TYPE_HOME;
271         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_VOICE) {
272                 return STR_CONTACT_PHONE_NUMBER_TYPE_VOICE;
273         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_FAX) {
274                 return STR_CONTACT_PHONE_NUMBER_TYPE_FAX;
275         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_MSG) {
276                 return STR_CONTACT_PHONE_NUMBER_TYPE_MSG;
277         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_CELL) {
278                 return STR_CONTACT_PHONE_NUMBER_TYPE_CELL;
279         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_PAGER) {
280                 return STR_CONTACT_PHONE_NUMBER_TYPE_PAGER;
281         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_BBS) {
282                 return STR_CONTACT_PHONE_NUMBER_TYPE_BBS;
283         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_MODEM) {
284                 return STR_CONTACT_PHONE_NUMBER_TYPE_MODEM;
285         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_CAR) {
286                 return STR_CONTACT_PHONE_NUMBER_TYPE_CAR;
287         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_ISDN) {
288                 return STR_CONTACT_PHONE_NUMBER_TYPE_ISDN;
289         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_VIDEO) {
290                 return STR_CONTACT_PHONE_NUMBER_TYPE_VIDEO;
291         } else if (arg == CONTACT_PHONE_NUMBER_TYPE_PCS) {
292                 return STR_CONTACT_PHONE_NUMBER_TYPE_PCS;
293         } else {
294                 Throw(WrtDeviceApis::Commons::ConversionException);
295         }
296         return STR_CONTACT_PHONE_NUMBER_TYPE_WORK;
297 }
298
299 ContactPhoneNumberType ContactConverter::toContactPhoneNumberType(const JSValueRef &value)
300 {
301         return toContactPhoneNumberType(toString(value));
302 }
303
304 JSValueRef ContactConverter::toJSValueRef(ContactPhoneNumberType arg)
305 {
306         return toJSValueRef(toContactPhoneNumberTypeStr(arg));
307 }
308
309 ContactAddressType ContactConverter::toContactAddressType(const std::string &arg)
310 {
311 //      //LogDebug("entered");
312         if (arg == STR_CONTACT_ADDRESS_TYPE_WORK) {
313                 return CONTACT_ADDRESS_TYPE_WORK;
314         } else if (arg == STR_CONTACT_ADDRESS_TYPE_PREF) {
315                 return CONTACT_ADDRESS_TYPE_PREF;
316         } else if (arg == STR_CONTACT_ADDRESS_TYPE_HOME) {
317                 return CONTACT_ADDRESS_TYPE_HOME;
318         } else {
319                 Throw(WrtDeviceApis::Commons::ConversionException);
320         }
321         return CONTACT_ADDRESS_TYPE_PREF;
322 }
323 std::string ContactConverter::toContactAddressTypeStr(ContactAddressType arg)
324 {
325 //      //LogDebug("entered");
326         if (arg == CONTACT_ADDRESS_TYPE_WORK) {
327                 return STR_CONTACT_ADDRESS_TYPE_WORK;
328         } else if (arg == CONTACT_ADDRESS_TYPE_PREF) {
329                 return STR_CONTACT_ADDRESS_TYPE_PREF;
330         } else if (arg == CONTACT_ADDRESS_TYPE_HOME) {
331                 return STR_CONTACT_ADDRESS_TYPE_HOME;
332         } else {
333                 Throw(WrtDeviceApis::Commons::ConversionException);
334         }
335         return STR_CONTACT_ADDRESS_TYPE_PREF;
336 }
337
338 ContactAddressType ContactConverter::toContactAddressType(const JSValueRef &value)
339 {
340         return toContactAddressType(toString(value));
341 }
342
343 JSValueRef ContactConverter::toJSValueRef(ContactAddressType arg)
344 {
345         return toJSValueRef(toContactAddressTypeStr(arg));
346 }
347
348 ContactWebSiteType ContactConverter::toContactWebSiteType(const std::string &arg)
349 {
350         //LogDebug("entered");
351         if (arg == STR_WEBSITE_TYPE_HOMEPAGE) {
352                 return WEBSITE_TYPE_HOMEPAGE;
353         } else if (arg == STR_WEBSITE_TYPE_BLOG) {
354                 return WEBSITE_TYPE_BLOG;
355         } else {
356                 Throw(WrtDeviceApis::Commons::ConversionException);
357         }
358         return WEBSITE_TYPE_HOMEPAGE;
359 }
360
361 std::string ContactConverter::toContactWebSiteTypeStr(ContactWebSiteType arg)
362 {
363         //LogDebug("entered");
364         if (arg == WEBSITE_TYPE_HOMEPAGE) {
365                 return STR_WEBSITE_TYPE_HOMEPAGE;
366         } else if (arg == WEBSITE_TYPE_BLOG) {
367                 return STR_WEBSITE_TYPE_BLOG;
368         } else {
369                 Throw(WrtDeviceApis::Commons::ConversionException);
370         }
371         return STR_WEBSITE_TYPE_HOMEPAGE;
372 }
373
374 ContactWebSiteType ContactConverter::toContactWebSiteType(const JSValueRef &value)
375 {
376         return toContactWebSiteType(toString(value));
377 }
378
379 JSValueRef ContactConverter::toJSValueRef(ContactWebSiteType arg)
380 {
381         return toJSValueRef(toContactWebSiteTypeStr(arg));
382 }
383
384 ContactCapabilityType ContactConverter::toContactCapabilityType(const JSValueRef &value)
385 {
386         int result = toInt(value);
387         if(HAS_VIDEO_CAPABILITY != result &&
388                         HAS_VOICE_CAPABILITY != result &&
389                         HAS_CAMERA_CAPABILITY != result)
390                 Throw(WrtDeviceApis::Commons::ConversionException);
391
392         return static_cast<ContactCapabilityType>(result);
393 }
394
395 std::string ContactConverter::toAttributesOfInterest(const JSValueRef &value)
396 {
397         // TODO validate
398         return toString(value);
399 }
400
401 JSValueRef ContactConverter::toJSValueRef(const IAddressBookPtr &arg)
402 {
403         //LogDebug("entered");
404         AddressBookController *priv = new AddressBookController(m_context, arg);
405         return JSObjectMake(m_context, JSAddressBook::getClassRef(), priv);
406 }
407
408 IAddressBookPtr ContactConverter::toAddressBook(const JSValueRef &jsValue)
409 {
410         if(!JSAddressBook::isObjectOfClass(m_context, jsValue))
411                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
412
413         return JSAddressBook::getAddressBook(m_context, jsValue);
414 }
415
416 JSValueRef ContactConverter::toJSValueRef(const IAddressBookArrayPtr &arg)
417 {
418         int size = arg->size();
419         if(size == 0)
420                 return JSValueMakeNull(m_context);
421
422         JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
423         if (!resultObject)
424                 ThrowMsg(ConversionException, "Can not create array object.");
425
426         for(int i = 0; i < size; i++)
427         {
428                 JSValueRef jsvalue = toJSValueRef(arg->at(i));
429                 if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
430                         ThrowMsg(ConversionException, "Can not fill address book array.");
431         }
432
433         return static_cast<JSValueRef>(resultObject);
434 }
435
436 IAddressBookArrayPtr ContactConverter::toAddressBookArray(const JSValueRef &jsValue)
437 {
438         if(JSAddressBookArray::isObjectOfClass(m_context, jsValue))
439                 return JSAddressBookArray::getAddressBookArray(m_context, jsValue);
440
441         IAddressBookArrayPtr result(new IAddressBookArray());
442
443         JSObjectRef jsObject = toJSObjectRef(jsValue);
444     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
445         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
446         result->push_back(toAddressBook(element));
447     }
448     return result;
449 }
450
451 JSValueRef ContactConverter::toJSValueRef(const ContactPtr &arg)
452 {
453         //LogDebug("entered");
454         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContact::getClassRef(), arg);
455 }
456
457 ContactPtr ContactConverter::toContact(const JSValueRef &jsValue)
458 {
459         if(!JSContact::isObjectOfClass(m_context, jsValue))
460                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
461
462         return JSContact::getContact(m_context, jsValue);
463 }
464
465 JSValueRef ContactConverter::toJSValueRef(const ContactArrayPtr &arg)
466 {
467         //LogDebug("entered");
468         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactArray::getClassRef(), arg);
469 }
470
471 ContactArrayPtr ContactConverter::toContactArray(const JSValueRef &jsValue)
472 {
473         if(JSContactArray::isObjectOfClass(m_context, jsValue))
474                 return JSContactArray::getContactArray(m_context, jsValue);
475
476         ContactArrayPtr result = ContactArrayPtr(new ContactArray());
477
478         JSObjectRef jsObject = toJSObjectRef(jsValue);
479     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
480         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
481         result->push_back(toContact(element));
482     }
483     return result;
484 }
485
486 JSValueRef ContactConverter::toJSValueRef(const ContactPropertiesPtr &arg)
487 {
488         // TODO make user object
489         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactProperties::getClassRef(), arg);
490 }
491
492 ContactPropertiesPtr ContactConverter::toContactProperties(const JSValueRef &jsValue)
493 {
494         if(JSContactProperties::isObjectOfClass(m_context, jsValue))
495                 return JSContactProperties::getContactProperties(m_context, jsValue);
496
497         Validator validator(m_context);
498         if (!validator.checkArrayKeys(m_allowedContactPropertiesProperties, jsValue)) {
499                 LogError("invalid properties in contact object");
500                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
501         }
502
503         const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NAME));
504         const ScopedJSStringRef accountStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ACCOUNT));
505         const ScopedJSStringRef addressesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ADDRESSES));
506         const ScopedJSStringRef photoURIStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHOTO_URI));
507         const ScopedJSStringRef phoneNumbersStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHONE_NUMBERS));
508         const ScopedJSStringRef emailsStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_EMAILS));
509         const ScopedJSStringRef birthdayStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_BIRTHDAY));
510         const ScopedJSStringRef anniversariesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ANNIVERSARIES));
511         const ScopedJSStringRef organizationStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ORGANIZATION));
512         const ScopedJSStringRef notesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NOTES));
513         const ScopedJSStringRef urlsStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_URLS));
514         const ScopedJSStringRef isFavoriteStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_IS_FAVORITE));
515         const ScopedJSStringRef ringtoneURIStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_RINGTONE_URI));
516         const ScopedJSStringRef categoriesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_CATEGORIES));
517
518         JSObjectRef jsObject = toJSObjectRef(jsValue);
519
520         JSValueRef nameData = JSObjectGetProperty(m_context, jsObject, nameStr.get(), NULL);
521         JSValueRef accountData = JSObjectGetProperty(m_context, jsObject, accountStr.get(), NULL);
522         JSValueRef addressesData = JSObjectGetProperty(m_context, jsObject, addressesStr.get(), NULL);
523         JSValueRef photoURIData = JSObjectGetProperty(m_context, jsObject, photoURIStr.get(), NULL);
524         JSValueRef phoneNumbersData = JSObjectGetProperty(m_context, jsObject, phoneNumbersStr.get(), NULL);
525         JSValueRef emailsData = JSObjectGetProperty(m_context, jsObject, emailsStr.get(), NULL);
526         JSValueRef birthdayData = JSObjectGetProperty(m_context, jsObject, birthdayStr.get(), NULL);
527         JSValueRef anniversariesData = JSObjectGetProperty(m_context, jsObject, anniversariesStr.get(), NULL);
528         JSValueRef organizationData = JSObjectGetProperty(m_context, jsObject, organizationStr.get(), NULL);
529         JSValueRef notesData = JSObjectGetProperty(m_context, jsObject, notesStr.get(), NULL);
530         JSValueRef urlsData = JSObjectGetProperty(m_context, jsObject, urlsStr.get(), NULL);
531         JSValueRef isFavoriteData = JSObjectGetProperty(m_context, jsObject, isFavoriteStr.get(), NULL);
532         JSValueRef ringtoneURIData = JSObjectGetProperty(m_context, jsObject, ringtoneURIStr.get(), NULL);
533         JSValueRef categoriesData = JSObjectGetProperty(m_context, jsObject, categoriesStr.get(), NULL);
534
535         ContactNamePtr name;
536         ContactAccountPtr account;
537         ContactAddressArrayPtr addresses;
538         std::string photoURI;
539         ContactPhoneNumberArrayPtr phoneNumbers;
540         ContactEmailAddressArrayPtr emails;
541         tm birthday;
542         ContactAnniversaryArrayPtr anniversaries;
543         ContactOrganizationPtr organization;
544         StringArrayPtr notes;
545         ContactWebSiteArrayPtr urls;
546         bool isFavorite;
547         std::string ringtoneURI;
548         StringArrayPtr categories;
549
550         ContactPropertiesPtr result = ContactPropertiesPtr(new ContactProperties());
551         if (!result) {
552                 Throw(WrtDeviceApis::Commons::ConversionException);
553         }
554
555         if (!JSValueIsUndefined(m_context, nameData)) {
556                 name = toContactName(nameData);
557                 result->setName(name);
558         }
559
560         if (!JSValueIsUndefined(m_context, accountData)) {
561                 account = toContactAccount(accountData);
562                 result->setAccount(account);
563         }
564
565         if (!JSValueIsUndefined(m_context, addressesData)) {
566                 addresses = toContactAddressArray(addressesData);
567                 result->setAddresses(addresses);
568         }
569
570         if (!JSValueIsUndefined(m_context, photoURIData)) {
571                 photoURI = toString(photoURIData);
572                 result->setPhotoURI(photoURI);
573         }
574
575         if (!JSValueIsUndefined(m_context, phoneNumbersData)) {
576                 phoneNumbers = toContactPhoneNumberArray(phoneNumbersData);
577                 result->setPhoneNumbers(phoneNumbers);
578         }
579
580         if (!JSValueIsUndefined(m_context, emailsData)) {
581                 emails = toContactEmailAddressArray(emailsData);
582                 result->setEmails(emails);
583         }
584
585         if (!JSValueIsUndefined(m_context, birthdayData)) {
586                 birthday = toDateTm(birthdayData);
587                 result->setBirthday(birthday);
588         }
589
590         if (!JSValueIsUndefined(m_context, anniversariesData)) {
591                 anniversaries = toContactAnniversaryArray(anniversariesData);
592                 result->setAnniversaries(anniversaries);
593         }
594
595         if (!JSValueIsUndefined(m_context, organizationData)) {
596                 organization = toContactOrganization(organizationData);
597                 result->setOrganization(organization);
598         }
599
600         if (!JSValueIsUndefined(m_context, notesData)) {
601                 notes = toStringArray(notesData);
602                 result->setNotes(notes);
603         }
604
605         if (!JSValueIsUndefined(m_context, urlsData)) {
606                 urls = toContactWebSiteArray(urlsData);
607                 result->setUrls(urls);
608         }
609
610         if (!JSValueIsUndefined(m_context, isFavoriteData)) {
611                 isFavorite = toBool(isFavoriteData);
612                 result->setIsFavorite(isFavorite);
613         }
614
615         if (!JSValueIsUndefined(m_context, ringtoneURIData)) {
616                 ringtoneURI = toString(ringtoneURIData);
617                 result->setRingtoneURI(ringtoneURI);
618         }
619
620         if (!JSValueIsUndefined(m_context, categoriesData)) {
621                 categories = toStringArray(categoriesData);
622                 result->setCategories(categories);
623         }
624
625         return result;
626 }
627
628 JSValueRef ContactConverter::toJSValueRef(const ContactPropertiesArrayPtr &arg)
629 {
630         //LogDebug("entered");
631         int size = arg->size();
632         if(size == 0)
633                 return JSValueMakeNull(m_context);
634
635         JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
636         if (!resultObject)
637                 ThrowMsg(ConversionException, "Can not create array object.");
638
639         for(int i = 0; i < size; i++)
640         {
641                 JSValueRef jsvalue = toJSValueRef(arg->at(i));
642                 if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
643                         ThrowMsg(ConversionException, "Can not fill contact properties array.");
644         }
645
646         return static_cast<JSValueRef>(resultObject);
647 }
648
649 ContactPropertiesArrayPtr ContactConverter::toContactPropertiesArray(const JSValueRef &jsValue)
650 {
651         ContactPropertiesArrayPtr result = ContactPropertiesArrayPtr(new ContactPropertiesArray());
652
653         JSObjectRef jsObject = toJSObjectRef(jsValue);
654     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
655         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
656         result->push_back(toContactProperties(element));
657     }
658     return result;
659 }
660
661 JSValueRef ContactConverter::toJSValueRef(const ContactNamePtr &arg)
662 {
663         // TODO make user object
664         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactName::getClassRef(), arg);
665 }
666
667 ContactNamePtr ContactConverter::toContactName(const JSValueRef &jsValue)
668 {
669         if(JSContactName::isObjectOfClass(m_context, jsValue))
670                 return JSContactName::getContactName(m_context, jsValue);
671
672         Validator validator(m_context);
673         if (!validator.checkArrayKeys(m_allowedContactNameProperties, jsValue)) {
674                 LogError("invalid properties in contact object");
675                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
676         }
677
678         const ScopedJSStringRef prefixStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PREFIX));
679         const ScopedJSStringRef firstNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_FIRST_NAME));
680         const ScopedJSStringRef middleNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_MIDDLE_NAME));
681         const ScopedJSStringRef lastNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_LAST_NAME));
682         const ScopedJSStringRef nicknamesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NICKNAMES));
683         const ScopedJSStringRef phoneticNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PHONETIC_NAME));
684         const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_DISPLAY_NAME));
685
686         JSObjectRef jsObject = toJSObjectRef(jsValue);
687
688         JSValueRef prefixData = JSObjectGetProperty(m_context, jsObject, prefixStr.get(), NULL);
689         JSValueRef firstNameData = JSObjectGetProperty(m_context, jsObject, firstNameStr.get(), NULL);
690         JSValueRef middleNameData = JSObjectGetProperty(m_context, jsObject, middleNameStr.get(), NULL);
691         JSValueRef lastNameData = JSObjectGetProperty(m_context, jsObject, lastNameStr.get(), NULL);
692         JSValueRef nicknamesData = JSObjectGetProperty(m_context, jsObject, nicknamesStr.get(), NULL);
693         JSValueRef phoneticNameData = JSObjectGetProperty(m_context, jsObject, phoneticNameStr.get(), NULL);
694         JSValueRef displayNameData = JSObjectGetProperty(m_context, jsObject, displayNameStr.get(), NULL);
695
696         std::string prefix;
697         std::string firstName;
698         std::string middleName;
699         std::string lastName;
700         StringArrayPtr nicknames;
701         std::string phoneticName;
702         std::string displayName;
703
704         ContactNamePtr result = ContactNamePtr(new ContactName());
705         if (!result) {
706                 Throw(WrtDeviceApis::Commons::ConversionException);
707         }
708
709         if (!JSValueIsUndefined(m_context, prefixData)) {
710                 prefix = toString(prefixData);
711                 result->setPrefix(prefix);
712         }
713
714         if (!JSValueIsUndefined(m_context, firstNameData)) {
715                 firstName = toString(firstNameData);
716                 result->setFirstName(firstName);
717         }
718
719         if (!JSValueIsUndefined(m_context, middleNameData)) {
720                 middleName = toString(middleNameData);
721                 result->setMiddleName(middleName);
722         }
723
724         if (!JSValueIsUndefined(m_context, lastNameData)) {
725                 lastName = toString(lastNameData);
726                 result->setLastName(lastName);
727         }
728
729         if (!JSValueIsUndefined(m_context, nicknamesData)) {
730                 nicknames = toStringArray(nicknamesData);
731                 result->setNicknames(nicknames);
732         }
733
734         if (!JSValueIsUndefined(m_context, phoneticNameData)) {
735                 phoneticName = toString(phoneticNameData);
736                 result->setPhoneticName(phoneticName);
737         }
738
739         if (!JSValueIsUndefined(m_context, displayNameData)) {
740                 displayName = toString(displayNameData);
741                 result->setDisplayName(displayName);
742         }
743
744         return result;
745 }
746
747 JSValueRef ContactConverter::toJSValueRef(const ContactAccountPtr &arg)
748 {
749         //LogDebug("entered");
750         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactAccount::getClassRef(), arg);
751 }
752
753 ContactAccountPtr ContactConverter::toContactAccount(const JSValueRef &jsValue)
754 {
755         if(JSContactAccount::isObjectOfClass(m_context, jsValue))
756                 return JSContactAccount::getContactAccount(m_context, jsValue);
757
758         Validator validator(m_context);
759         if (!validator.checkArrayKeys(m_allowedContactAccountProperties, jsValue)) {
760                 LogError("invalid properties in contact object");
761                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
762         }
763
764         const ScopedJSStringRef accountIdStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ACCOUNT_ID));
765         const ScopedJSStringRef contactURIStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_CONTACT_URI));
766
767         JSObjectRef jsObject = toJSObjectRef(jsValue);
768
769         JSValueRef accountIdData = JSObjectGetProperty(m_context, jsObject, accountIdStr.get(), NULL);
770         JSValueRef contactURIData = JSObjectGetProperty(m_context, jsObject, contactURIStr.get(), NULL);
771
772         std::string accountId;
773         std::string contactURI;
774
775         ContactAccountPtr result(new ContactAccount());
776         if (!result) {
777                 Throw(WrtDeviceApis::Commons::ConversionException);
778         }
779
780         if (!JSValueIsUndefined(m_context, accountIdData)) {
781                 accountId = toString(accountIdData);
782                 result->setAccountId(accountId);
783         }
784
785         if (!JSValueIsUndefined(m_context, contactURIData)) {
786                 contactURI = toString(contactURIData);
787                 result->setContactURI(contactURI);
788         }
789
790         return result;
791 }
792
793 JSValueRef ContactConverter::toJSValueRef(const ContactAnniversaryPtr &arg)
794 {
795         //LogDebug("entered");
796         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactAnniversary::getClassRef(), arg);
797 }
798
799 ContactAnniversaryPtr ContactConverter::toContactAnniversary(const JSValueRef &jsValue)
800 {
801         if(JSContactAnniversary::isObjectOfClass(m_context, jsValue))
802                 return JSContactAnniversary::getContactAnniversary(m_context, jsValue);
803
804         Validator validator(m_context);
805         if (!validator.checkArrayKeys(m_allowedContactAnniversaryProperties, jsValue)) {
806                 LogError("invalid properties in contact object");
807                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
808         }
809
810         const ScopedJSStringRef dateStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_DATE));
811         const ScopedJSStringRef labelStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_LABEL));
812
813         JSObjectRef jsObject = toJSObjectRef(jsValue);
814
815         JSValueRef dateData = JSObjectGetProperty(m_context, jsObject, dateStr.get(), NULL);
816         JSValueRef labelData = JSObjectGetProperty(m_context, jsObject, labelStr.get(), NULL);
817
818         std::tm date;
819         std::string label;
820
821         ContactAnniversaryPtr result(new ContactAnniversary());
822         if (!result) {
823                 Throw(WrtDeviceApis::Commons::ConversionException);
824         }
825
826         if (!JSValueIsUndefined(m_context, dateData)) {
827                 date = toDateTm(dateData);
828                 result->setDate(date);
829         }
830
831         if (!JSValueIsUndefined(m_context, labelData)) {
832                 label = toString(labelData);
833                 result->setLabel(label);
834         }
835
836         return result;
837 }
838
839 JSValueRef ContactConverter::toJSValueRef(const ContactAnniversaryArrayPtr &arg)
840 {
841         //LogDebug("entered");
842         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactAnniversaryArray::getClassRef(), arg);
843 }
844
845 ContactAnniversaryArrayPtr ContactConverter::toContactAnniversaryArray(const JSValueRef &jsValue)
846 {
847         if(JSContactAnniversaryArray::isObjectOfClass(m_context, jsValue))
848                 return JSContactAnniversaryArray::getContactAnniversaryArray(m_context, jsValue);
849
850         ContactAnniversaryArrayPtr result(new ContactAnniversaryArray());
851
852         JSObjectRef jsObject = toJSObjectRef(jsValue);
853     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
854         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
855         result->push_back(toContactAnniversary(element));
856     }
857     return result;
858 }
859
860 JSValueRef ContactConverter::toJSValueRefAttributesOfInterestArray(const AttributesOfInterestArrayPtr &arg)
861 {
862         //LogDebug("entered");
863         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSAttributesOfInterestArray::getClassRef(), arg);
864 }
865
866 AttributesOfInterestArrayPtr ContactConverter::toAttributesOfInterestArray(const JSValueRef &jsValue)
867 {
868         if(JSAttributesOfInterestArray::isObjectOfClass(m_context, jsValue))
869                 return JSAttributesOfInterestArray::getAttributesOfInterestArray(m_context, jsValue);
870
871         AttributesOfInterestArrayPtr result(new AttributesOfInterestArray());
872
873         JSObjectRef jsObject = toJSObjectRef(jsValue);
874     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
875         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
876         result->push_back(toAttributesOfInterest(element));
877     }
878     return result;
879 }
880
881 JSValueRef ContactConverter::toJSValueRef(const ContactAddressPtr &arg)
882 {
883         //LogDebug("entered");
884         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactAddress::getClassRef(), arg);
885 }
886
887 ContactAddressPtr ContactConverter::toContactAddress(const JSValueRef &jsValue)
888 {
889         if(JSContactAddress::isObjectOfClass(m_context, jsValue))
890                 return JSContactAddress::getContactAddress(m_context, jsValue);
891
892         Validator validator(m_context);
893         if (!validator.checkArrayKeys(m_allowedContactAddressProperties, jsValue)) {
894                 LogError("invalid properties in contact object");
895                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
896         }
897
898         const ScopedJSStringRef countryStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_COUNTRY));
899         const ScopedJSStringRef regionStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_REGION));
900         const ScopedJSStringRef cityStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_CITY));
901         const ScopedJSStringRef streetAddressStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_STREET_ADDRESS));
902         const ScopedJSStringRef additionalInformationStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ADDITIONAL_INFORMATION));
903         const ScopedJSStringRef postalCodeStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_POSTAL_CODE));
904         const ScopedJSStringRef typesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TYPES));
905
906         JSObjectRef jsObject = toJSObjectRef(jsValue);
907
908         JSValueRef countryData = JSObjectGetProperty(m_context, jsObject, countryStr.get(), NULL);
909         JSValueRef regionData = JSObjectGetProperty(m_context, jsObject, regionStr.get(), NULL);
910         JSValueRef cityData = JSObjectGetProperty(m_context, jsObject, cityStr.get(), NULL);
911         JSValueRef streetAddressData = JSObjectGetProperty(m_context, jsObject, streetAddressStr.get(), NULL);
912         JSValueRef additionalInformationData = JSObjectGetProperty(m_context, jsObject, additionalInformationStr.get(), NULL);
913         JSValueRef postalCodeData = JSObjectGetProperty(m_context, jsObject, postalCodeStr.get(), NULL);
914         JSValueRef typesData = JSObjectGetProperty(m_context, jsObject, typesStr.get(), NULL);
915
916         std::string country;
917         std::string region;
918         std::string city;
919         std::string streetAddress;
920         std::string additionalInformation;
921         std::string postalCode;
922         ContactAddressTypeArrayPtr types;
923
924         ContactAddressPtr result(new ContactAddress());
925         if (!result) {
926                 Throw(WrtDeviceApis::Commons::ConversionException);
927         }
928
929         if (!JSValueIsUndefined(m_context, countryData)) {
930                 country = toString(countryData);
931                 result->setCountry(country);
932         }
933
934         if (!JSValueIsUndefined(m_context, regionData)) {
935                 region = toString(regionData);
936                 result->setRegion(region);
937         }
938
939         if (!JSValueIsUndefined(m_context, cityData)) {
940                 city = toString(cityData);
941                 result->setCity(city);
942         }
943
944         if (!JSValueIsUndefined(m_context, streetAddressData)) {
945                 streetAddress = toString(streetAddressData);
946                 result->setStreetAddress(streetAddress);
947         }
948
949         if (!JSValueIsUndefined(m_context, additionalInformationData)) {
950                 additionalInformation = toString(additionalInformationData);
951                 result->setAdditionalInformation(additionalInformation);
952         }
953
954         if (!JSValueIsUndefined(m_context, postalCodeData)) {
955                 postalCode = toString(postalCodeData);
956                 result->setPostalCode(postalCode);
957         }
958
959         if (!JSValueIsUndefined(m_context, typesData)) {
960                 types = toContactAddressTypeArray(typesData);
961                 result->setTypes(types);
962         }
963
964         return result;
965 }
966
967 JSValueRef ContactConverter::toJSValueRef(const ContactAddressArrayPtr &arg)
968 {
969         //LogDebug("entered");
970         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactAddressArray::getClassRef(), arg);
971 }
972
973 ContactAddressArrayPtr ContactConverter::toContactAddressArray(const JSValueRef &jsValue)
974 {
975         if(JSContactAddressArray::isObjectOfClass(m_context, jsValue))
976                 return JSContactAddressArray::getContactAddressArray(m_context, jsValue);
977
978         ContactAddressArrayPtr result(new ContactAddressArray());
979
980         JSObjectRef jsObject = toJSObjectRef(jsValue);
981     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
982         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
983         result->push_back(toContactAddress(element));
984     }
985     return result;
986 }
987
988 JSValueRef ContactConverter::toJSValueRef(const ContactAddressTypeArrayPtr &arg)
989 {
990         //LogDebug("entered");
991         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactAddressTypeArray::getClassRef(), arg);
992 }
993
994 ContactAddressTypeArrayPtr ContactConverter::toContactAddressTypeArray(const JSValueRef &jsValue)
995 {
996         if(JSContactAddressTypeArray::isObjectOfClass(m_context, jsValue))
997                 return JSContactAddressTypeArray::getContactAddressTypeArray(m_context, jsValue);
998
999         ContactAddressTypeArrayPtr result(new ContactAddressTypeArray());
1000
1001         JSObjectRef jsObject = toJSObjectRef(jsValue);
1002     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1003         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1004         result->push_back(toContactAddressType(element));
1005     }
1006     return result;
1007 }
1008
1009 //JSValueRef ContactConverter::toJSValueRef(const ContactCapabilityTypeArrayPtr &arg)
1010 //{
1011 //      //LogDebug("entered");
1012 //      return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactCapabilityTypeArray::getClassRef(), arg);
1013 //}
1014 //
1015 //ContactCapabilityTypeArrayPtr ContactConverter::toContactCapabilityTypeArray(const JSValueRef &jsValue)
1016 //{
1017 //      if(JSContactCapabilityTypeArray::isObjectOfClass(m_context, jsValue))
1018 //              return JSContactCapabilityTypeArray::getContactCapabilityTypeArray(m_context, jsValue);
1019 //
1020 //      ContactCapabilityTypeArrayPtr result(new ContactCapabilityTypeArray());
1021 //
1022 //      JSObjectRef jsObject = toJSObjectRef(jsValue);
1023 //    for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1024 //        JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1025 //        result->push_back(toContactCapabilityType(element));
1026 //    }
1027 //    return result;
1028 //}
1029
1030 JSValueRef ContactConverter::toJSValueRef(const ContactPhoneNumberPtr &arg)
1031 {
1032         //LogDebug("entered");
1033         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactPhoneNumber::getClassRef(), arg);
1034 }
1035
1036 ContactPhoneNumberPtr ContactConverter::toContactPhoneNumber(const JSValueRef &jsValue)
1037 {
1038         if(JSContactPhoneNumber::isObjectOfClass(m_context, jsValue))
1039                 return JSContactPhoneNumber::getContactPhoneNumber(m_context, jsValue);
1040
1041         Validator validator(m_context);
1042         if (!validator.checkArrayKeys(m_allowedContactPhoneNumberProperties, jsValue)) {
1043                 LogError("invalid properties in contact object");
1044                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
1045         }
1046
1047         const ScopedJSStringRef numberStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NUMBER));
1048         const ScopedJSStringRef typesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TYPES));
1049
1050         JSObjectRef jsObject = toJSObjectRef(jsValue);
1051
1052         JSValueRef numberData = JSObjectGetProperty(m_context, jsObject, numberStr.get(), NULL);
1053         JSValueRef typesData = JSObjectGetProperty(m_context, jsObject, typesStr.get(), NULL);
1054
1055         std::string number;
1056         StringArrayPtr types;
1057
1058         ContactPhoneNumberPtr result(new ContactPhoneNumber());
1059         if (!result) {
1060                 Throw(WrtDeviceApis::Commons::ConversionException);
1061         }
1062
1063         if (!JSValueIsUndefined(m_context, numberData)) {
1064                 number = toString(numberData);
1065                 result->setNumber(number);
1066         }
1067
1068         if (!JSValueIsUndefined(m_context, typesData)) {
1069                 types = toStringArray(typesData);
1070                 result->setTypes(types);
1071         } else {
1072                 result->addType("VOICE");
1073         }
1074
1075         return result;
1076 }
1077
1078 JSValueRef ContactConverter::toJSValueRef(const ContactPhoneNumberArrayPtr &arg)
1079 {
1080         //LogDebug("entered");
1081         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactPhoneNumberArray::getClassRef(), arg);
1082 }
1083
1084 ContactPhoneNumberArrayPtr ContactConverter::toContactPhoneNumberArray(const JSValueRef &jsValue)
1085 {
1086         if(JSContactPhoneNumberArray::isObjectOfClass(m_context, jsValue))
1087                 return JSContactPhoneNumberArray::getContactPhoneNumberArray(m_context, jsValue);
1088
1089         ContactPhoneNumberArrayPtr result(new ContactPhoneNumberArray());
1090
1091         JSObjectRef jsObject = toJSObjectRef(jsValue);
1092     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1093         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1094         result->push_back(toContactPhoneNumber(element));
1095     }
1096     return result;
1097 }
1098
1099 JSValueRef ContactConverter::toJSValueRef(const ContactPhoneNumberTypeArrayPtr &arg)
1100 {
1101         //LogDebug("entered");
1102         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactPhoneNumberTypeArray::getClassRef(), arg);
1103 }
1104
1105 ContactPhoneNumberTypeArrayPtr ContactConverter::toContactPhoneNumberTypeArray(const JSValueRef &jsValue)
1106 {
1107         if(JSContactPhoneNumberTypeArray::isObjectOfClass(m_context, jsValue))
1108                 return JSContactPhoneNumberTypeArray::getContactPhoneNumberTypeArray(m_context, jsValue);
1109
1110         ContactPhoneNumberTypeArrayPtr result(new ContactPhoneNumberTypeArray());
1111
1112         JSObjectRef jsObject = toJSObjectRef(jsValue);
1113     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1114         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1115         result->push_back(toContactPhoneNumberType(element));
1116     }
1117     return result;
1118 }
1119
1120 JSValueRef ContactConverter::toJSValueRef(const ContactEmailAddressPtr &arg)
1121 {
1122         //LogDebug("entered");
1123         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactEmailAddress::getClassRef(), arg);
1124 }
1125
1126 ContactEmailAddressPtr ContactConverter::toContactEmailAddress(const JSValueRef &jsValue)
1127 {
1128         if(JSContactEmailAddress::isObjectOfClass(m_context, jsValue))
1129                 return JSContactEmailAddress::getContactEmailAddress(m_context, jsValue);
1130
1131         Validator validator(m_context);
1132         if (!validator.checkArrayKeys(m_allowedContactEmailAddressProperties, jsValue)) {
1133                 LogError("invalid properties in contact object");
1134                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
1135         }
1136
1137         const ScopedJSStringRef emailStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_EMAIL));
1138         const ScopedJSStringRef typesStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TYPES));
1139
1140         JSObjectRef jsObject = toJSObjectRef(jsValue);
1141
1142
1143         JSValueRef emailData = JSObjectGetProperty(m_context, jsObject, emailStr.get(), NULL);
1144         JSValueRef typesData = JSObjectGetProperty(m_context, jsObject, typesStr.get(), NULL);
1145
1146
1147         std::string email;
1148         ContactEmailAddressTypeArrayPtr types;
1149
1150         ContactEmailAddressPtr result(new ContactEmailAddress());
1151         if (!result) {
1152                 Throw(WrtDeviceApis::Commons::ConversionException);
1153         }
1154
1155         if (!JSValueIsUndefined(m_context, emailData)) {
1156                 email = toString(emailData);
1157                 result->setEmail(email);
1158         }
1159
1160         if (!JSValueIsUndefined(m_context, typesData)) {
1161                 types = toContactEmailAddressTypeArray(typesData);
1162                 result->setTypes(types);
1163         } else {
1164                 result->addType(CONTACT_EMAIL_TYPE_PREF);
1165         }
1166         return result;
1167 }
1168
1169 JSValueRef ContactConverter::toJSValueRef(const ContactEmailAddressArrayPtr &arg)
1170 {
1171         //LogDebug("entered");
1172         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactEmailAddressArray::getClassRef(), arg);
1173 }
1174
1175 ContactEmailAddressArrayPtr ContactConverter::toContactEmailAddressArray(const JSValueRef &jsValue)
1176 {
1177         if(JSContactEmailAddressArray::isObjectOfClass(m_context, jsValue))
1178                 return JSContactEmailAddressArray::getContactEmailAddressArray(m_context, jsValue);
1179
1180         ContactEmailAddressArrayPtr result(new ContactEmailAddressArray());
1181
1182         JSObjectRef jsObject = toJSObjectRef(jsValue);
1183     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1184         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1185         result->push_back(toContactEmailAddress(element));
1186     }
1187     return result;
1188 }
1189
1190 JSValueRef ContactConverter::toJSValueRef(const ContactEmailAddressTypeArrayPtr &arg)
1191 {
1192         //LogDebug("entered");
1193         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactEmailAddressTypeArray::getClassRef(), arg);
1194 }
1195
1196 ContactEmailAddressTypeArrayPtr ContactConverter::toContactEmailAddressTypeArray(const JSValueRef &jsValue)
1197 {
1198         if(JSContactEmailAddressTypeArray::isObjectOfClass(m_context, jsValue))
1199                 return JSContactEmailAddressTypeArray::getContactEmailAddressTypeArray(m_context, jsValue);
1200
1201         ContactEmailAddressTypeArrayPtr result(new ContactEmailAddressTypeArray());
1202
1203         JSObjectRef jsObject = toJSObjectRef(jsValue);
1204     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1205         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1206         result->push_back(toContactEmailAddressType(element));
1207     }
1208     return result;
1209 }
1210
1211 JSValueRef ContactConverter::toJSValueRef(const ContactOrganizationPtr &arg)
1212 {
1213         //LogDebug("entered");
1214         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactOrganization::getClassRef(), arg);
1215 }
1216
1217 ContactOrganizationPtr ContactConverter::toContactOrganization(const JSValueRef &jsValue)
1218 {
1219         if(JSContactOrganization::isObjectOfClass(m_context, jsValue))
1220                 return JSContactOrganization::getContactOrganization(m_context, jsValue);
1221
1222         Validator validator(m_context);
1223         if (!validator.checkArrayKeys(m_allowedContactOrganizationProperties, jsValue)) {
1224                 LogError("invalid properties in contact object");
1225                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
1226         }
1227
1228         const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NAME));
1229         const ScopedJSStringRef departmentStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_DEPARTMENT));
1230         const ScopedJSStringRef titleStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TITLE));
1231         const ScopedJSStringRef roleStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ROLE));
1232
1233         JSObjectRef jsObject = toJSObjectRef(jsValue);
1234
1235         JSValueRef nameData = JSObjectGetProperty(m_context, jsObject, nameStr.get(), NULL);
1236         JSValueRef departmentData = JSObjectGetProperty(m_context, jsObject, departmentStr.get(), NULL);
1237         JSValueRef titleData = JSObjectGetProperty(m_context, jsObject, titleStr.get(), NULL);
1238         JSValueRef roleData = JSObjectGetProperty(m_context, jsObject, roleStr.get(), NULL);
1239
1240         std::string name;
1241         std::string department;
1242         std::string title;
1243         std::string role;
1244
1245         ContactOrganizationPtr result(new ContactOrganization());
1246         if (!result) {
1247                 Throw(WrtDeviceApis::Commons::ConversionException);
1248         }
1249
1250         if (!JSValueIsUndefined(m_context, nameData)) {
1251                 name = toString(nameData);
1252                 result->setName(name);
1253         }
1254
1255         if (!JSValueIsUndefined(m_context, departmentData)) {
1256                 department = toString(departmentData);
1257                 result->setDepartment(department);
1258         }
1259
1260         if (!JSValueIsUndefined(m_context, titleData)) {
1261                 title = toString(titleData);
1262                 result->setTitle(title);
1263         }
1264
1265         if (!JSValueIsUndefined(m_context, roleData)) {
1266                 role = toString(roleData);
1267                 result->setRole(role);
1268         }
1269
1270         return result;
1271 }
1272
1273 JSValueRef ContactConverter::toJSValueRef(const ContactOrganizationArrayPtr &arg)
1274 {
1275         //LogDebug("entered");
1276         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactOrganizationArray::getClassRef(), arg);
1277 }
1278
1279 ContactOrganizationArrayPtr ContactConverter::toContactOrganizationArray(const JSValueRef &jsValue)
1280 {
1281         if(JSContactOrganizationArray::isObjectOfClass(m_context, jsValue))
1282                 return JSContactOrganizationArray::getContactOrganizationArray(m_context, jsValue);
1283
1284         ContactOrganizationArrayPtr result(new ContactOrganizationArray());
1285
1286         JSObjectRef jsObject = toJSObjectRef(jsValue);
1287     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1288         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1289         result->push_back(toContactOrganization(element));
1290     }
1291     return result;
1292 }
1293
1294 JSValueRef ContactConverter::toJSValueRef(const ContactWebSitePtr &arg)
1295 {
1296         //LogDebug("entered");
1297         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactWebSite::getClassRef(), arg);
1298 }
1299
1300 ContactWebSitePtr ContactConverter::toContactWebSite(const JSValueRef &jsValue)
1301 {
1302         if(JSContactWebSite::isObjectOfClass(m_context, jsValue))
1303                 return JSContactWebSite::getContactWebSite(m_context, jsValue);
1304
1305         Validator validator(m_context);
1306         if (!validator.checkArrayKeys(m_allowedContactWebSiteProperties, jsValue)) {
1307                 LogError("invalid properties in contact object");
1308                 ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
1309         }
1310
1311         const ScopedJSStringRef urlStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_URL));
1312         const ScopedJSStringRef typeStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_TYPE));
1313
1314         JSObjectRef jsObject = toJSObjectRef(jsValue);
1315
1316         JSValueRef urlData = JSObjectGetProperty(m_context, jsObject, urlStr.get(), NULL);
1317         JSValueRef typeData = JSObjectGetProperty(m_context, jsObject, typeStr.get(), NULL);
1318
1319         std::string url;
1320         ContactWebSiteType type;
1321
1322         ContactWebSitePtr result(new ContactWebSite());
1323         if (!result) {
1324                 Throw(WrtDeviceApis::Commons::ConversionException);
1325         }
1326
1327         if (!JSValueIsUndefined(m_context, urlData)) {
1328                 url = toString(urlData);
1329                 result->setUrl(url);
1330         }
1331
1332         if (!JSValueIsUndefined(m_context, typeData)) {
1333                 type = toContactWebSiteType(typeData);
1334                 result->setType(type);
1335         }
1336
1337         return result;
1338 }
1339
1340 JSValueRef ContactConverter::toJSValueRef(const ContactWebSiteArrayPtr &arg)
1341 {
1342         //LogDebug("entered");
1343         return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSContactWebSiteArray::getClassRef(), arg);
1344 }
1345
1346 ContactWebSiteArrayPtr ContactConverter::toContactWebSiteArray(const JSValueRef &jsValue)
1347 {
1348         if(JSContactWebSiteArray::isObjectOfClass(m_context, jsValue))
1349                 return JSContactWebSiteArray::getContactWebSiteArray(m_context, jsValue);
1350
1351         ContactWebSiteArrayPtr result(new ContactWebSiteArray());
1352
1353         JSObjectRef jsObject = toJSObjectRef(jsValue);
1354     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
1355         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
1356         result->push_back(toContactWebSite(element));
1357     }
1358     return result;
1359 }
1360
1361 bool ContactConverter::initializeAllowedProperties()
1362 {
1363         m_allowedAddressBookProperties.push_back(CONTACT_ATTRIBUTE_NAME);
1364
1365         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_ID);
1366         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_READ_ONLY);
1367         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_LAST_UPDATED);
1368         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_NAME);
1369         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_ACCOUNT);
1370         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_ADDRESSES);
1371         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_PHOTO_URI );
1372         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_PHONE_NUMBERS);
1373         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_EMAILS);
1374         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_BIRTHDAY);
1375         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_ANNIVERSARIES);
1376         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_ORGANIZATION);
1377         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_NOTES);
1378         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_URLS);
1379         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_IS_FAVORITE);
1380         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_RINGTONE_URI);
1381         m_allowedContactProperties.push_back(CONTACT_ATTRIBUTE_CATEGORIES);
1382
1383         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_NAME);
1384         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_ACCOUNT);
1385         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_ADDRESSES);
1386         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_PHOTO_URI );
1387         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_PHONE_NUMBERS);
1388         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_EMAILS);
1389         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_BIRTHDAY);
1390         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_ANNIVERSARIES);
1391         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_ORGANIZATION);
1392         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_NOTES);
1393         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_URLS);
1394         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_IS_FAVORITE);
1395         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_RINGTONE_URI);
1396         m_allowedContactPropertiesProperties.push_back(CONTACT_ATTRIBUTE_CATEGORIES);
1397
1398         m_allowedContactNameProperties.push_back(CONTACT_ATTRIBUTE_PREFIX);
1399         m_allowedContactNameProperties.push_back(CONTACT_ATTRIBUTE_FIRST_NAME);
1400         m_allowedContactNameProperties.push_back(CONTACT_ATTRIBUTE_MIDDLE_NAME);
1401         m_allowedContactNameProperties.push_back(CONTACT_ATTRIBUTE_LAST_NAME);
1402         m_allowedContactNameProperties.push_back(CONTACT_ATTRIBUTE_NICKNAMES);
1403         m_allowedContactNameProperties.push_back(CONTACT_ATTRIBUTE_PHONETIC_NAME);
1404         m_allowedContactNameProperties.push_back(CONTACT_ATTRIBUTE_DISPLAY_NAME);
1405
1406         m_allowedContactAccountProperties.push_back(CONTACT_ATTRIBUTE_ACCOUNT_ID);
1407         m_allowedContactAccountProperties.push_back(CONTACT_ATTRIBUTE_CONTACT_URI);
1408
1409         m_allowedContactOrganizationProperties.push_back(CONTACT_ATTRIBUTE_NAME);
1410         m_allowedContactOrganizationProperties.push_back(CONTACT_ATTRIBUTE_DEPARTMENT);
1411         m_allowedContactOrganizationProperties.push_back(CONTACT_ATTRIBUTE_OFFICE);
1412         m_allowedContactOrganizationProperties.push_back(CONTACT_ATTRIBUTE_TITLE);
1413         m_allowedContactOrganizationProperties.push_back(CONTACT_ATTRIBUTE_ROLE);
1414         m_allowedContactOrganizationProperties.push_back(CONTACT_ATTRIBUTE_LOGO_URI);
1415
1416         m_allowedContactWebSiteProperties.push_back(CONTACT_ATTRIBUTE_URL);
1417         m_allowedContactWebSiteProperties.push_back(CONTACT_ATTRIBUTE_TYPE);
1418
1419         m_allowedContactAnniversaryProperties.push_back(CONTACT_ATTRIBUTE_DATE);
1420         m_allowedContactAnniversaryProperties.push_back(CONTACT_ATTRIBUTE_LABEL);
1421
1422         m_allowedContactAddressProperties.push_back(CONTACT_ATTRIBUTE_COUNTRY);
1423         m_allowedContactAddressProperties.push_back(CONTACT_ATTRIBUTE_REGION);
1424         m_allowedContactAddressProperties.push_back(CONTACT_ATTRIBUTE_CITY);
1425         m_allowedContactAddressProperties.push_back(CONTACT_ATTRIBUTE_STREET_ADDRESS);
1426         m_allowedContactAddressProperties.push_back(CONTACT_ATTRIBUTE_ADDITIONAL_INFORMATION);
1427         m_allowedContactAddressProperties.push_back(CONTACT_ATTRIBUTE_POSTAL_CODE);
1428         m_allowedContactAddressProperties.push_back(CONTACT_ATTRIBUTE_TYPES);
1429
1430         m_allowedContactPhoneNumberProperties.push_back(CONTACT_ATTRIBUTE_NUMBER);
1431         m_allowedContactPhoneNumberProperties.push_back(CONTACT_ATTRIBUTE_TYPES);
1432
1433         m_allowedContactEmailAddressProperties.push_back(CONTACT_ATTRIBUTE_EMAIL);
1434         m_allowedContactEmailAddressProperties.push_back(CONTACT_ATTRIBUTE_TYPES);
1435
1436         return true;
1437 }
1438
1439 } // Contact
1440 } // Tizen1_0
1441 } // TizenApis