Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Contact / JSContactProperties.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        JSContactProperties.cpp
19  * @author      Kisub Song (kisubs.song@samsung.com)
20  * @version     0.1
21  * @brief       Implementation of the JSContactProperties class
22  */
23
24 #include <dpl/log/log.h>
25 #include <dpl/shared_ptr.h>
26 #include <CommonsJavaScript/Converter.h>
27 #include <Tizen/Common/JSTizenExceptionFactory.h>
28 #include <Tizen/Common/JSTizenException.h>
29 #include "ContactConverter.h"
30 #include "JSContactProperties.h"
31
32 #define CONTACT_CLASS_NAME                                      "ContactProperties"
33 #define CONTACT_PROP_ATTR_NAME                          "name"
34 #define CONTACT_PROP_ATTR_ACCOUNT                       "account"
35 #define CONTACT_PROP_ATTR_ADDRESSES                     "addresses"
36 #define CONTACT_PROP_ATTR_PHOTO_URI                     "photoURI"
37 #define CONTACT_PROP_ATTR_PHONE_NUMBERS         "phoneNumbers"
38 #define CONTACT_PROP_ATTR_EMAILS                        "emails"
39 #define CONTACT_PROP_ATTR_BIRTHDAY                      "birthday"
40 #define CONTACT_PROP_ATTR_ANNIVERSARIES         "anniversaries"
41 #define CONTACT_PROP_ATTR_ORGANIZATION          "organization"
42 #define CONTACT_PROP_ATTR_NOTES                         "notes"
43 #define CONTACT_PROP_ATTR_URLS                          "urls"
44 #define CONTACT_PROP_ATTR_LAST_UPDATED          "lastUpdated"
45 #define CONTACT_PROP_ATTR_IS_FAVORITE           "isFavorite"
46 #define CONTACT_PROP_ATTR_RINGTONE_URI          "ringtoneURI"
47 #define CONTACT_PROP_ATTR_CATEGORIES            "categories"
48
49 namespace TizenApis {
50 namespace Tizen1_0 {
51 namespace Contact {
52
53 using namespace TizenApis::Commons;
54 using namespace TizenApis::Api::Contact;
55
56 JSClassRef JSContactProperties::m_classRef = NULL;
57
58 JSClassDefinition JSContactProperties::m_classInfo =
59 {
60         0,
61         kJSClassAttributeNone,
62         CONTACT_CLASS_NAME,
63         NULL,
64         m_property,
65         m_functions,
66         Initialize,
67         Finalize,
68         NULL, //hasProperty,
69         NULL, //GetProperty,
70         NULL, //SetProperty,
71         NULL, //DeleteProperty,
72         NULL, //getPropertyNames,
73         NULL,
74         NULL,
75         NULL,
76         NULL, //ConvertToType,
77 };
78
79 JSStaticValue JSContactProperties::m_property[] = {
80         { CONTACT_PROP_ATTR_NAME, getName, setName, kJSPropertyAttributeNone },
81         { CONTACT_PROP_ATTR_ACCOUNT, getAccount, setAccount, kJSPropertyAttributeNone },
82         { CONTACT_PROP_ATTR_ADDRESSES, getAddresses, setAddresses, kJSPropertyAttributeNone },
83         { CONTACT_PROP_ATTR_PHOTO_URI, getPhotoURI, setPhotoURI, kJSPropertyAttributeNone },
84         { CONTACT_PROP_ATTR_PHONE_NUMBERS, getPhoneNumbers, setPhoneNumbers, kJSPropertyAttributeNone },
85         { CONTACT_PROP_ATTR_EMAILS, getEmails, setEmails, kJSPropertyAttributeNone },
86         { CONTACT_PROP_ATTR_BIRTHDAY, getBirthday, setBirthday, kJSPropertyAttributeNone },
87         { CONTACT_PROP_ATTR_ANNIVERSARIES, getAnniversaries, setAnniversaries, kJSPropertyAttributeNone },
88         { CONTACT_PROP_ATTR_ORGANIZATION, getOrganization, setOrganization, kJSPropertyAttributeNone },
89         { CONTACT_PROP_ATTR_NOTES, getNotes, setNotes, kJSPropertyAttributeNone },
90         { CONTACT_PROP_ATTR_URLS, getUrls, setUrls, kJSPropertyAttributeNone },
91         { CONTACT_PROP_ATTR_IS_FAVORITE, getIsFavorite, setIsFavorite, kJSPropertyAttributeNone },
92         { CONTACT_PROP_ATTR_RINGTONE_URI, getRingtoneURI, setRingtoneURI, kJSPropertyAttributeNone },
93         { CONTACT_PROP_ATTR_CATEGORIES, getCategories, setCategories, kJSPropertyAttributeNone },
94         { 0, 0, 0, 0 }
95 };
96
97 JSStaticFunction JSContactProperties::m_functions[] =
98 {
99         { 0, 0, 0 }
100 };
101
102 JSClassRef JSContactProperties::getClassRef()
103 {
104         if (!m_classRef) {
105                 m_classRef = JSClassCreate(&m_classInfo);
106         }
107         return m_classRef;
108 }
109
110 JSValueRef JSContactProperties::createJSObject(JSContextRef context
111 // FIXME
112                 )
113 {
114         ContactPropertiesPtr privateData = ContactPropertiesPtr(new ContactProperties());
115         JSContactPropertiesPriv *priv = new JSContactPropertiesPriv(context, privateData);
116         JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
117         if (NULL == jsValueRef)
118         {
119                 LogError("object creation error");
120                 return JSValueMakeUndefined(context);
121         }
122         return jsValueRef;
123 }
124
125 bool JSContactProperties::isObjectOfClass(JSContextRef context, JSValueRef value)
126 {
127         return JSValueIsObjectOfClass(context, value, getClassRef());
128 }
129
130 ContactPropertiesPtr JSContactProperties::getContactProperties(JSContextRef context, JSValueRef value)
131 {
132         if (!isObjectOfClass(context, value)) {
133                 Throw(WrtDeviceApis::Commons::InvalidArgumentException);
134         }
135
136         JSObjectRef object = JSValueToObject(context, value, NULL);
137         if (!object) {
138                 Throw(WrtDeviceApis::Commons::InvalidArgumentException);
139         }
140
141         JSContactPropertiesPriv *priv = static_cast<JSContactPropertiesPriv*>(JSObjectGetPrivate(object));
142         if (!priv) {
143                 Throw(WrtDeviceApis::Commons::NullPointerException);
144         }
145
146         return priv->getObject();
147 }
148
149 void JSContactProperties::Initialize(JSContextRef context, JSObjectRef object)
150 {
151         assert(NULL != JSObjectGetPrivate(object));
152 }
153
154 void JSContactProperties::Finalize(JSObjectRef object)
155 {
156         //delete (JSObjectGetPrivate(object));
157 }
158
159 ContactPropertiesPtr JSContactProperties::getPrivData(JSObjectRef object)
160 {
161         //LogDebug("entered");
162         JSContactPropertiesPriv *priv = static_cast<JSContactPropertiesPriv*>(JSObjectGetPrivate(object));
163         if (!priv) {
164                 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
165         }
166
167         ContactPropertiesPtr result = priv->getObject();
168         if (!result) {
169                 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
170         }
171
172         return result;
173 }
174
175 JSValueRef JSContactProperties::getName(JSContextRef context,
176                 JSObjectRef object,
177                 JSStringRef propertyName,
178                 JSValueRef* exception)
179 {
180         //LogDebug("entered");
181         Try
182         {
183                 ContactConverterFactory::ConverterType converter =
184                                 ContactConverterFactory::getConverter(context);
185                 ContactPropertiesPtr contactProperties = getPrivData(object);
186                 return converter->toJSValueRef(contactProperties->getName());
187         }
188         Catch(WrtDeviceApis::Commons::Exception)
189         {
190                 LogWarning("trying to get incorrect value");
191         }
192
193         return JSValueMakeUndefined(context);
194 }
195
196 bool JSContactProperties::setName(JSContextRef context,
197                 JSObjectRef object,
198                 JSStringRef propertyName,
199                 JSValueRef value,
200                 JSValueRef* exception)
201 {
202         Try
203         {
204                 ContactPropertiesPtr contactProperties = getPrivData(object);
205                 ContactConverterFactory::ConverterType converter =
206                                 ContactConverterFactory::getConverter(context);
207                 contactProperties->setName(converter->toContactName(value));
208                 return true;
209         }
210         Catch(WrtDeviceApis::Commons::Exception)
211         {
212                 LogWarning("trying to set incorrect value");
213         }
214
215         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
216         return false;
217 }
218
219 JSValueRef JSContactProperties::getAccount(JSContextRef context,
220                 JSObjectRef object,
221                 JSStringRef propertyName,
222                 JSValueRef* exception)
223 {
224         //LogDebug("entered");
225         Try
226         {
227                 ContactConverterFactory::ConverterType converter =
228                                 ContactConverterFactory::getConverter(context);
229                 ContactPropertiesPtr contactProperties = getPrivData(object);
230                 return converter->toJSValueRef(contactProperties->getAccount());
231         }
232         Catch(WrtDeviceApis::Commons::Exception)
233         {
234                 LogWarning("trying to get incorrect value");
235         }
236
237         return JSValueMakeUndefined(context);
238 }
239
240 bool JSContactProperties::setAccount(JSContextRef context,
241                 JSObjectRef object,
242                 JSStringRef propertyName,
243                 JSValueRef value,
244                 JSValueRef* exception)
245 {
246         Try
247         {
248                 ContactPropertiesPtr contactProperties = getPrivData(object);
249                 ContactConverterFactory::ConverterType converter =
250                                 ContactConverterFactory::getConverter(context);
251                 contactProperties->setAccount(converter->toContactAccount(value));
252                 return true;
253         }
254         Catch(WrtDeviceApis::Commons::Exception)
255         {
256                 LogWarning("trying to set incorrect value");
257         }
258
259         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
260         return false;
261 }
262
263 JSValueRef JSContactProperties::getAddresses(JSContextRef context,
264                 JSObjectRef object,
265                 JSStringRef propertyName,
266                 JSValueRef* exception)
267 {
268         //LogDebug("entered");
269         Try
270         {
271                 ContactConverterFactory::ConverterType converter =
272                                 ContactConverterFactory::getConverter(context);
273                 ContactPropertiesPtr contactProperties = getPrivData(object);
274                 return converter->toJSValueRef(contactProperties->getAddresses());
275         }
276         Catch(WrtDeviceApis::Commons::Exception)
277         {
278                 LogWarning("trying to get incorrect value");
279         }
280
281         return JSValueMakeUndefined(context);
282 }
283
284 bool JSContactProperties::setAddresses(JSContextRef context,
285                 JSObjectRef object,
286                 JSStringRef propertyName,
287                 JSValueRef value,
288                 JSValueRef* exception)
289 {
290         Try
291         {
292                 ContactPropertiesPtr contactProperties = getPrivData(object);
293                 ContactConverterFactory::ConverterType converter =
294                                 ContactConverterFactory::getConverter(context);
295                 contactProperties->setAddresses(
296                                 converter->toContactAddressArray(value));
297                 return true;
298         }
299         Catch(WrtDeviceApis::Commons::Exception)
300         {
301                 LogWarning("trying to set incorrect value");
302         }
303
304         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
305         return false;
306 }
307
308 JSValueRef JSContactProperties::getPhotoURI(JSContextRef context,
309                 JSObjectRef object,
310                 JSStringRef propertyName,
311                 JSValueRef* exception)
312 {
313         //LogDebug("entered");
314         Try
315         {
316                 ContactConverterFactory::ConverterType converter =
317                                 ContactConverterFactory::getConverter(context);
318                 ContactPropertiesPtr contactProperties = getPrivData(object);
319                 return converter->toJSValueRef(contactProperties->getPhotoURI());
320         }
321         Catch(WrtDeviceApis::Commons::Exception)
322         {
323                 LogWarning("trying to get incorrect value");
324         }
325
326         return JSValueMakeUndefined(context);
327 }
328
329 bool JSContactProperties::setPhotoURI(JSContextRef context,
330                 JSObjectRef object,
331                 JSStringRef propertyName,
332                 JSValueRef value,
333                 JSValueRef* exception)
334 {
335         Try
336         {
337                 ContactPropertiesPtr contactProperties = getPrivData(object);
338                 ContactConverterFactory::ConverterType converter =
339                                 ContactConverterFactory::getConverter(context);
340                 contactProperties->setPhotoURI(converter->toString(value));
341                 return true;
342         }
343         Catch(WrtDeviceApis::Commons::Exception)
344         {
345                 LogWarning("trying to set incorrect value");
346         }
347
348         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
349         return false;
350 }
351
352 JSValueRef JSContactProperties::getPhoneNumbers(JSContextRef context,
353                 JSObjectRef object,
354                 JSStringRef propertyName,
355                 JSValueRef* exception)
356 {
357         //LogDebug("entered");
358         Try
359         {
360                 ContactConverterFactory::ConverterType converter =
361                                 ContactConverterFactory::getConverter(context);
362                 ContactPropertiesPtr contactProperties = getPrivData(object);
363                 return converter->toJSValueRef(contactProperties->getPhoneNumbers());
364         }
365         Catch(WrtDeviceApis::Commons::Exception)
366         {
367                 LogWarning("trying to get incorrect value");
368         }
369
370         return JSValueMakeUndefined(context);
371 }
372
373 bool JSContactProperties::setPhoneNumbers(JSContextRef context,
374                 JSObjectRef object,
375                 JSStringRef propertyName,
376                 JSValueRef value,
377                 JSValueRef* exception)
378 {
379         Try
380         {
381                 ContactPropertiesPtr contactProperties = getPrivData(object);
382                 ContactConverterFactory::ConverterType converter =
383                                 ContactConverterFactory::getConverter(context);
384                 contactProperties->setPhoneNumbers(
385                                 converter->toContactPhoneNumberArray(value));
386                 return true;
387         }
388         Catch(WrtDeviceApis::Commons::Exception)
389         {
390                 LogWarning("trying to set incorrect value");
391         }
392
393         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
394         return false;
395 }
396
397 JSValueRef JSContactProperties::getEmails(JSContextRef context,
398                 JSObjectRef object,
399                 JSStringRef propertyName,
400                 JSValueRef* exception)
401 {
402         //LogDebug("entered");
403         Try
404         {
405                 ContactConverterFactory::ConverterType converter =
406                                 ContactConverterFactory::getConverter(context);
407                 ContactPropertiesPtr contactProperties = getPrivData(object);
408                 return converter->toJSValueRef(contactProperties->getEmails());
409         }
410         Catch(WrtDeviceApis::Commons::Exception)
411         {
412                 LogWarning("trying to get incorrect value");
413         }
414
415         return JSValueMakeUndefined(context);
416 }
417
418 bool JSContactProperties::setEmails(JSContextRef context,
419                 JSObjectRef object,
420                 JSStringRef propertyName,
421                 JSValueRef value,
422                 JSValueRef* exception)
423 {
424         Try
425         {
426                 ContactPropertiesPtr contactProperties = getPrivData(object);
427                 ContactConverterFactory::ConverterType converter =
428                                 ContactConverterFactory::getConverter(context);
429                 contactProperties->setEmails(converter->toContactEmailAddressArray(value));
430                 return true;
431         }
432         Catch(WrtDeviceApis::Commons::Exception)
433         {
434                 LogWarning("trying to set incorrect value");
435         }
436
437         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
438         return false;
439 }
440
441 JSValueRef JSContactProperties::getBirthday(JSContextRef context,
442                 JSObjectRef object,
443                 JSStringRef propertyName,
444                 JSValueRef* exception)
445 {
446         //LogDebug("entered");
447         Try
448         {
449                 ContactConverterFactory::ConverterType converter =
450                                 ContactConverterFactory::getConverter(context);
451                 ContactPropertiesPtr contactProperties = getPrivData(object);
452                 if(contactProperties->getBirthdayIsSet())
453                         return converter->toJSValueRef(contactProperties->getBirthday());
454                 else
455                         return JSValueMakeNull(context);
456         }
457         Catch(WrtDeviceApis::Commons::Exception)
458         {
459                 LogWarning("trying to get incorrect value");
460         }
461
462         return JSValueMakeUndefined(context);
463 }
464
465 bool JSContactProperties::setBirthday(JSContextRef context,
466                 JSObjectRef object,
467                 JSStringRef propertyName,
468                 JSValueRef value,
469                 JSValueRef* exception)
470 {
471         Try
472         {
473                 ContactPropertiesPtr contactProperties = getPrivData(object);
474                 ContactConverterFactory::ConverterType converter =
475                                 ContactConverterFactory::getConverter(context);
476                 contactProperties->setBirthday(converter->toDateTm(value));
477                 return true;
478         }
479         Catch(WrtDeviceApis::Commons::Exception)
480         {
481                 LogWarning("trying to set incorrect value");
482         }
483
484         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
485         return false;
486 }
487
488 JSValueRef JSContactProperties::getAnniversaries(JSContextRef context,
489                 JSObjectRef object,
490                 JSStringRef propertyName,
491                 JSValueRef* exception)
492 {
493         //LogDebug("entered");
494         Try
495         {
496                 ContactConverterFactory::ConverterType converter =
497                                 ContactConverterFactory::getConverter(context);
498                 ContactPropertiesPtr contactProperties = getPrivData(object);
499                 return converter->toJSValueRef(contactProperties->getAnniversaries());
500         }
501         Catch(WrtDeviceApis::Commons::Exception)
502         {
503                 LogWarning("trying to get incorrect value");
504         }
505
506         return JSValueMakeUndefined(context);
507 }
508
509 bool JSContactProperties::setAnniversaries(JSContextRef context,
510                 JSObjectRef object,
511                 JSStringRef propertyName,
512                 JSValueRef value,
513                 JSValueRef* exception)
514 {
515         Try
516         {
517                 ContactPropertiesPtr contactProperties = getPrivData(object);
518                 ContactConverterFactory::ConverterType converter =
519                                 ContactConverterFactory::getConverter(context);
520                 contactProperties->setAnniversaries(
521                                 converter->toContactAnniversaryArray(value));
522                 return true;
523         }
524         Catch(WrtDeviceApis::Commons::Exception)
525         {
526                 LogWarning("trying to set incorrect value");
527         }
528
529         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
530         return false;
531 }
532
533 JSValueRef JSContactProperties::getOrganization(JSContextRef context,
534                 JSObjectRef object,
535                 JSStringRef propertyName,
536                 JSValueRef* exception)
537 {
538         //LogDebug("entered");
539         Try
540         {
541                 ContactConverterFactory::ConverterType converter =
542                                 ContactConverterFactory::getConverter(context);
543                 ContactPropertiesPtr contactProperties = getPrivData(object);
544                 return converter->toJSValueRef(contactProperties->getOrganization());
545         }
546         Catch(WrtDeviceApis::Commons::Exception)
547         {
548                 LogWarning("trying to get incorrect value");
549         }
550
551         return JSValueMakeUndefined(context);
552 }
553
554 bool JSContactProperties::setOrganization(JSContextRef context,
555                 JSObjectRef object,
556                 JSStringRef propertyName,
557                 JSValueRef value,
558                 JSValueRef* exception)
559 {
560         Try
561         {
562                 ContactPropertiesPtr contactProperties = getPrivData(object);
563                 ContactConverterFactory::ConverterType converter =
564                                 ContactConverterFactory::getConverter(context);
565                 contactProperties->setOrganization(converter->toContactOrganization(value));
566                 return true;
567         }
568         Catch(WrtDeviceApis::Commons::Exception)
569         {
570                 LogWarning("trying to set incorrect value");
571         }
572
573         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
574         return false;
575 }
576
577 JSValueRef JSContactProperties::getNotes(JSContextRef context,
578                 JSObjectRef object,
579                 JSStringRef propertyName,
580                 JSValueRef* exception)
581 {
582         //LogDebug("entered");
583         Try
584         {
585                 ContactConverterFactory::ConverterType converter =
586                                 ContactConverterFactory::getConverter(context);
587                 ContactPropertiesPtr contactProperties = getPrivData(object);
588                 return converter->toJSValueRef(contactProperties->getNotes());
589         }
590         Catch(WrtDeviceApis::Commons::Exception)
591         {
592                 LogWarning("trying to get incorrect value");
593         }
594
595         return JSValueMakeUndefined(context);
596 }
597
598 bool JSContactProperties::setNotes(JSContextRef context,
599                 JSObjectRef object,
600                 JSStringRef propertyName,
601                 JSValueRef value,
602                 JSValueRef* exception)
603 {
604         Try
605         {
606                 ContactPropertiesPtr contactProperties = getPrivData(object);
607                 ContactConverterFactory::ConverterType converter =
608                                 ContactConverterFactory::getConverter(context);
609                 contactProperties->setNotes(converter->toStringArray(value));
610                 return true;
611         }
612         Catch(WrtDeviceApis::Commons::Exception)
613         {
614                 LogWarning("trying to set incorrect value");
615         }
616
617         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
618         return false;
619 }
620
621 JSValueRef JSContactProperties::getUrls(JSContextRef context,
622                 JSObjectRef object,
623                 JSStringRef propertyName,
624                 JSValueRef* exception)
625 {
626         //LogDebug("entered");
627         Try
628         {
629                 ContactConverterFactory::ConverterType converter =
630                                 ContactConverterFactory::getConverter(context);
631                 ContactPropertiesPtr contactProperties = getPrivData(object);
632                 return converter->toJSValueRef(contactProperties->getUrls());
633         }
634         Catch(WrtDeviceApis::Commons::Exception)
635         {
636                 LogWarning("trying to get incorrect value");
637         }
638
639         return JSValueMakeUndefined(context);
640 }
641
642 bool JSContactProperties::setUrls(JSContextRef context,
643                 JSObjectRef object,
644                 JSStringRef propertyName,
645                 JSValueRef value,
646                 JSValueRef* exception)
647 {
648         Try
649         {
650                 ContactPropertiesPtr contactProperties = getPrivData(object);
651                 ContactConverterFactory::ConverterType converter =
652                                 ContactConverterFactory::getConverter(context);
653                 contactProperties->setUrls(converter->toContactWebSiteArray(value));
654                 return true;
655         }
656         Catch(WrtDeviceApis::Commons::Exception)
657         {
658                 LogWarning("trying to set incorrect value");
659         }
660
661         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
662         return false;
663 }
664
665 JSValueRef JSContactProperties::getIsFavorite(JSContextRef context,
666                 JSObjectRef object,
667                 JSStringRef propertyName,
668                 JSValueRef* exception)
669 {
670         //LogDebug("entered");
671         Try
672         {
673                 ContactConverterFactory::ConverterType converter =
674                                 ContactConverterFactory::getConverter(context);
675                 ContactPropertiesPtr contactProperties = getPrivData(object);
676                 return converter->toJSValueRef(contactProperties->getIsFavorite());
677         }
678         Catch(WrtDeviceApis::Commons::Exception)
679         {
680                 LogWarning("trying to get incorrect value");
681         }
682
683         return JSValueMakeUndefined(context);
684 }
685
686 bool JSContactProperties::setIsFavorite(JSContextRef context,
687                 JSObjectRef object,
688                 JSStringRef propertyName,
689                 JSValueRef value,
690                 JSValueRef* exception)
691 {
692         Try
693         {
694                 ContactPropertiesPtr contactProperties = getPrivData(object);
695                 ContactConverterFactory::ConverterType converter =
696                                 ContactConverterFactory::getConverter(context);
697                 contactProperties->setIsFavorite(converter->toBool(value));
698                 return true;
699         }
700         Catch(WrtDeviceApis::Commons::Exception)
701         {
702                 LogWarning("trying to set incorrect value");
703         }
704
705         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
706         return false;
707 }
708
709 JSValueRef JSContactProperties::getRingtoneURI(JSContextRef context,
710                 JSObjectRef object,
711                 JSStringRef propertyName,
712                 JSValueRef* exception)
713 {
714         //LogDebug("entered");
715         Try
716         {
717                 ContactConverterFactory::ConverterType converter =
718                                 ContactConverterFactory::getConverter(context);
719                 ContactPropertiesPtr contactProperties = getPrivData(object);
720                 return converter->toJSValueRef(contactProperties->getRingtoneURI());
721         }
722         Catch(WrtDeviceApis::Commons::Exception)
723         {
724                 LogWarning("trying to get incorrect value");
725         }
726
727         return JSValueMakeUndefined(context);
728 }
729
730 bool JSContactProperties::setRingtoneURI(JSContextRef context,
731                 JSObjectRef object,
732                 JSStringRef propertyName,
733                 JSValueRef value,
734                 JSValueRef* exception)
735 {
736         Try
737         {
738                 ContactPropertiesPtr contactProperties = getPrivData(object);
739                 ContactConverterFactory::ConverterType converter =
740                                 ContactConverterFactory::getConverter(context);
741                 contactProperties->setRingtoneURI(converter->toString(value));
742                 return true;
743         }
744         Catch(WrtDeviceApis::Commons::Exception)
745         {
746                 LogWarning("trying to set incorrect value");
747         }
748
749         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
750         return false;
751 }
752
753 JSValueRef JSContactProperties::getCategories(JSContextRef context,
754                 JSObjectRef object,
755                 JSStringRef propertyName,
756                 JSValueRef* exception)
757 {
758         //LogDebug("entered");
759         Try
760         {
761                 ContactConverterFactory::ConverterType converter =
762                                 ContactConverterFactory::getConverter(context);
763                 ContactPropertiesPtr contactProperties = getPrivData(object);
764                 return converter->toJSValueRef(contactProperties->getCategories());
765         }
766         Catch(WrtDeviceApis::Commons::Exception)
767         {
768                 LogWarning("trying to get incorrect value");
769         }
770
771         return JSValueMakeUndefined(context);
772 }
773
774 bool JSContactProperties::setCategories(JSContextRef context,
775                 JSObjectRef object,
776                 JSStringRef propertyName,
777                 JSValueRef value,
778                 JSValueRef* exception)
779 {
780         Try
781         {
782                 ContactPropertiesPtr contactProperties = getPrivData(object);
783                 ContactConverterFactory::ConverterType converter =
784                                 ContactConverterFactory::getConverter(context);
785                 contactProperties->setCategories(converter->toStringArray(value));
786                 return true;
787         }
788         Catch(WrtDeviceApis::Commons::Exception)
789         {
790                 LogWarning("trying to set incorrect value");
791         }
792
793         JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
794         return false;
795 }
796
797 } // Contact
798 } // Tizen1_0
799 } // TizenApis