summaryrefslogtreecommitdiff
path: root/mobile_src/Contact/JSContact.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/Contact/JSContact.cpp')
-rw-r--r--mobile_src/Contact/JSContact.cpp1250
1 files changed, 1250 insertions, 0 deletions
diff --git a/mobile_src/Contact/JSContact.cpp b/mobile_src/Contact/JSContact.cpp
new file mode 100644
index 0000000..fe85c81
--- /dev/null
+++ b/mobile_src/Contact/JSContact.cpp
@@ -0,0 +1,1250 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file JSContact.cpp
+ * @version 0.1
+ * @brief Implementation of the JSContact class
+ */
+
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Validator.h>
+#include <SecurityExceptions.h>
+#include "ContactFactory.h"
+#include "ContactConverter.h"
+#include "JSContact.h"
+#include "Contact.h"
+#include <ArgumentValidator.h>
+#include <JSWebAPIErrorFactory.h>
+#include <TimeTracer.h>
+#include <Logger.h>
+#include <Export.h>
+
+#define FILTER_CLASS_NAME "Contact"
+
+#define CONTACT_ATTR_ID "id"
+#define CONTACT_ATTR_ADDRESSBOOK_ID "addressBookId"
+#define CONTACT_ATTR_PERSON_ID "personId"
+#define CONTACT_ATTR_LAST_UPDATED "lastUpdated"
+#define CONTACT_ATTR_IS_FAVORITE "isFavorite"
+#define CONTACT_ATTR_NAME "name"
+#define CONTACT_ATTR_ADDRESSES "addresses"
+#define CONTACT_ATTR_PHOTO_URI "photoURI"
+#define CONTACT_ATTR_PHONE_NUMBERS "phoneNumbers"
+#define CONTACT_ATTR_EMAILS "emails"
+#define CONTACT_ATTR_BIRTHDAY "birthday"
+#define CONTACT_ATTR_ANNIVERSARIES "anniversaries"
+#define CONTACT_ATTR_ORGANIZATIONS "organizations"
+#define CONTACT_ATTR_NOTES "notes"
+#define CONTACT_ATTR_URLS "urls"
+#define CONTACT_ATTR_LAST_UPDATED "lastUpdated"
+#define CONTACT_ATTR_RINGTONE_URI "ringtoneURI"
+#define CONTACT_ATTR_GROUP_IDS "groupIds"
+#define CONTACT_FUNC_CONVERT_TO_STRING "convertToString"
+#define CONTACT_FUNC_CLONE "clone"
+
+namespace DeviceAPI {
+namespace Contact {
+
+using namespace DeviceAPI::Common;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassDefinition JSContact::m_classInfo =
+{
+ 0,
+ kJSClassAttributeNone,
+ FILTER_CLASS_NAME,
+ NULL,
+ m_property,
+ m_functions,
+ Initialize,
+ Finalize,
+ NULL, //hasProperty,
+ NULL, //GetProperty,
+ NULL, //SetProperty,
+ NULL, //DeleteProperty,
+ NULL, //getPropertyNames,
+ NULL, //CallAsFunction,
+ constructor, //CallAsConstructor,
+ hasInstance, //HasInstance,
+ NULL, //ConvertToType,
+};
+
+JSStaticValue JSContact::m_property[] = {
+ { CONTACT_ATTR_ID, getId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
+ { CONTACT_ATTR_ADDRESSBOOK_ID, getAddressBookId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
+ { CONTACT_ATTR_PERSON_ID, getPersonId, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
+ { CONTACT_ATTR_LAST_UPDATED, getLastUpdated, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { CONTACT_ATTR_IS_FAVORITE, getIsFavorite, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { CONTACT_ATTR_NAME, getName, setName, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_ADDRESSES, getAddresses, setAddresses, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_PHOTO_URI, getPhotoURI, setPhotoURI, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_PHONE_NUMBERS, getPhoneNumbers, setPhoneNumbers, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_EMAILS, getEmails, setEmails, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_BIRTHDAY, getBirthday, setBirthday, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_ANNIVERSARIES, getAnniversaries, setAnniversaries, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_ORGANIZATIONS, getOrganizations, setOrganizations, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_NOTES, getNotes, setNotes, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_URLS, getUrls, setUrls, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_RINGTONE_URI, getRingtoneURI, setRingtoneURI, kJSPropertyAttributeNone },
+ { CONTACT_ATTR_GROUP_IDS, getGroupIds, setGroupIds, kJSPropertyAttributeNone },
+ { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSContact::m_functions[] =
+{
+ { CONTACT_FUNC_CONVERT_TO_STRING, convertToString, kJSPropertyAttributeNone },
+ { CONTACT_FUNC_CLONE, clone, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+};
+
+JSClassRef JSContact::m_classRef = JSClassCreate(&m_classInfo);
+
+JSClassRef DLL_EXPORT JSContact::getClassRef() {
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+bool JSContact::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+ return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+ContactPtr JSContact::getContact(JSContextRef context, JSValueRef value)
+{
+ if (!isObjectOfClass(context, value)) {
+ Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+ }
+ JSObjectRef object = JSValueToObject(context, value, NULL);
+ if (!object) {
+ Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+ }
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ Throw(WrtDeviceApis::Commons::NullPointerException);
+ }
+ return priv->getObject();
+}
+
+void JSContact::Initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object))
+ {
+ ContactPtr contact = ContactFactory::getInstance().createContact();
+ JSContactPriv *priv = new JSContactPriv(context, ContactPtr(contact));
+ if (!JSObjectSetPrivate(object, priv)) {
+ delete priv;
+ }
+ }
+}
+
+void JSContact::Finalize(JSObjectRef object)
+{
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+
+ if (priv != NULL)
+ delete (priv);
+}
+
+JSObjectRef JSContact::createJSObject(JSContextRef context, ContactPtr contact)
+{
+ JSContactPriv *priv = new JSContactPriv(context, contact);
+ JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+ if (NULL == jsObjectRef) {
+ LoggerE("object creation error");
+ return NULL;
+ }
+ return jsObjectRef;
+}
+
+ContactPtr JSContact::getPrivData(JSObjectRef object)
+{
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ ContactPtr result = priv->getObject();
+ if (!result) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null.");
+ }
+ return result;
+}
+
+JSObjectRef JSContact::constructor(JSContextRef context,
+ JSObjectRef constructor,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ bool jsNoParam = false;
+ bool js1stParamIsObject = false;
+ bool js1stParamIsString = false;
+
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(constructor));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
+ if (argumentCount == 0)
+ {
+ jsNoParam = true;
+ }
+ else
+ {
+ if (JSValueIsNull(gContext, arguments[0]) || JSValueIsUndefined(gContext, arguments[0]))
+ jsNoParam = true;
+ else if (JSValueIsObject(gContext, arguments[0]))
+ js1stParamIsObject = true;
+ else if (JSValueIsString(gContext, arguments[0]))
+ js1stParamIsString = true;
+ else
+ {
+ LoggerE("Argument type mismatch : 1nd argument must be ContactInit object or string");
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
+ return NULL;
+ }
+ }
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+
+ ContactPtr contact(NULL);
+ if(js1stParamIsObject)
+ {
+ Try {
+ contact = converter->toContactFromInit(arguments[0]);
+
+ } Catch(ConversionException) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactInit object'");
+ return NULL;
+ } Catch(Exception) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ return NULL;
+ }
+ }
+ else if(js1stParamIsString)
+ {
+ Try {
+ std::string stringRepresentation; // vCard string
+
+ stringRepresentation = converter->toString(arguments[0]);
+
+ contact = ContactFactory::getInstance().createContact();
+ contact->setContactFromString(stringRepresentation);
+
+ } Catch(ConversionException) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
+ return NULL;
+ } Catch(InvalidArgumentException) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "1st argument must be vCard string");
+ return NULL;
+ } Catch(UnsupportedException) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
+ return NULL;
+ } Catch(Exception) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ return NULL;
+ }
+ }
+ else
+ {
+ Try {
+ contact = ContactFactory::getInstance().createContact();
+ } Catch(Exception) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ return NULL;
+ }
+ }
+
+ JSObjectRef jsobject;
+
+ Try {
+ jsobject = createJSObject(gContext, contact);
+ } Catch(Exception) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+// *exception = JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ return NULL;
+ }
+
+ return jsobject;
+}
+
+bool JSContact::hasInstance(JSContextRef context,
+ JSObjectRef constructor,
+ JSValueRef possibleInstance,
+ JSValueRef* exception)
+{
+ return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSContact::getId(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+
+ if(!contact->getIdIsSet())
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contact->getId());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+ return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSContact::getAddressBookId(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+ if(!contact->getAddressBookIdIsSet())
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contact->getAddressBookId());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+ return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSContact::getPersonId(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+ if(!contact->getPersonIdIsSet())
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contact->getPersonId());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+ return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSContact::getLastUpdated(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+ if(!contact->getLastUpdatedIsSet())
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contact->getLastUpdated());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSContact::getIsFavorite(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+ return converter->toJSValueRef(contact->getIsFavorite());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSContact::getName(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+ ContactNamePtr contactName = contact->getName();
+ if(contactName == NULL)
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contactName);
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setName(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
+ if(validator->isNullOrUndefined(value))
+ return true;//contact->unsetName();
+ else
+ contact->setName(converter->toContactName(value));
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getAddresses(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->addressesJSObjIsSet()){
+ return newContactT->getAddressesJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getAddressesJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getAddresses());
+
+ JSObjectRef convertedJSObject = newContactT->getAddressesJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setAddressesJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setAddresses(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ contact->setAddresses(converter->toContactAddressArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetAddressesJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getPhotoURI(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+ if(!contact->getPhotoURIIsSet())
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contact->getPhotoURI());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setPhotoURI(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ BasicValidator validator =
+ BasicValidatorFactory::getValidator(context, exception);
+/* if(validator->isNullOrUndefined(value))
+ return true;//contact->unsetPhotoURI();
+ else*/
+ contact->setPhotoURI(converter->toString(value));
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getPhoneNumbers(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->numbersJSObjIsSet()){
+ return newContactT->getNumbersJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getNumbersJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getPhoneNumbers());
+
+ JSObjectRef convertedJSObject = newContactT->getNumbersJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setNumbersJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setPhoneNumbers(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ contact->setPhoneNumbers(converter->toContactPhoneNumberArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetNumbersJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getEmails(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->EmailsJSObjIsSet()){
+ return newContactT->getEmailsJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getEmailsJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getEmails());
+
+ JSObjectRef convertedJSObject = newContactT->getEmailsJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setEmailsJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setEmails(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ contact->setEmails(converter->toContactEmailAddressArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetEmailsJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getBirthday(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+ if(!contact->getBirthdayIsSet())
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contact->getBirthday());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setBirthday(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ BasicValidator validator =
+ BasicValidatorFactory::getValidator(context, exception);
+/* if(validator->isNullOrUndefined(value))
+ return true;//contact->unsetBirthday();
+ else*/
+ contact->setBirthday(converter->toDateTm(value));
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getAnniversaries(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->anniversariesJSObjIsSet()){
+ return newContactT->getAnniversariesJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getAnniversariesJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getAnniversaries());
+
+ JSObjectRef convertedJSObject = newContactT->getAnniversariesJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setAnniversariesJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setAnniversaries(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ contact->setAnniversaries(converter->toContactAnniversaryArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetAnniversariesJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getOrganizations(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->organizationsJSObjIsSet()){
+ return newContactT->getOrganizationsJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getOrganizationsJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getOrganizations());
+
+ JSObjectRef convertedJSObject = newContactT->getOrganizationsJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setOrganizationsJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setOrganizations(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ contact->setOrganizations(converter->toContactOrganizationArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetOrganizationsJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getNotes(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->notesJSObjIsSet()){
+ return newContactT->getNotesJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getNotesJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getNotes());
+
+ JSObjectRef convertedJSObject = newContactT->getNotesJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setNotesJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setNotes(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+ ContactPtr contact = getPrivData(object);
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ contact->setNotes(converter->toStringArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetNotesJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getUrls(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ if(newContactT->urlsJSObjIsSet()){
+ return newContactT->getUrlsJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getUrlsJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getUrls());
+
+ JSObjectRef convertedJSObject = newContactT->getUrlsJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setUrlsJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setUrls(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ contact->setUrls(converter->toContactWebSiteArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetUrlsJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getRingtoneURI(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ ContactPtr contact = getPrivData(object);
+ if(!contact->getRingtoneURIIsSet())
+ return JSValueMakeNull(context);
+ else
+ return converter->toJSValueRef(contact->getRingtoneURI());
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setRingtoneURI(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(context);
+ BasicValidator validator =
+ BasicValidatorFactory::getValidator(context, exception);
+/* if(validator->isNullOrUndefined(value))
+ return true;//contact->unsetRingtoneURI();
+ else*/
+ contact->setRingtoneURI(converter->toString(value));
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::getGroupIds(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ Try
+ {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+
+ ContactConverterFactory::ConverterType converter =
+ ContactConverterFactory::getConverter(gContext);
+ ContactPtr contact = getPrivData(object);
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+
+ if(newContactT->groupIdsJSObjIsSet()){
+ return newContactT->getGroupIdsJSObj();
+ }else{
+ JSValueRef tempJSValue = newContactT->getGroupIdsJSValue();
+ tempJSValue = converter->toJSValueRef(newContactT->getGroupIds());
+
+ JSObjectRef convertedJSObject = newContactT->getGroupIdsJSObj();
+ convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+ newContactT->setGroupIdsJSObj(true, convertedJSObject);
+
+ JSValueProtect(gContext, convertedJSObject);
+ newContactT->setContext(gContext);
+ return tempJSValue;
+ }
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to get incorrect value");
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+bool JSContact::setGroupIds(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ Try
+ {
+ ContactPtr contact = getPrivData(object);
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ contact->setGroupIds(converter->toStringArray(value));
+ DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
+ newContactT->resetGroupIdsJSObj();
+ }
+ Catch(WrtDeviceApis::Commons::Exception)
+ {
+ LoggerW("trying to set incorrect value");
+// JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mismatch");
+ }
+
+ return true;
+}
+
+JSValueRef JSContact::convertToString(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("entered");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ ContactPtr contact(NULL);
+
+ Try {
+ contact = getPrivData(thisObject);
+ if (contact == NULL) {
+ ThrowMsg(InvalidArgumentException, "No private object.");
+ }
+ } Catch(Exception) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object");
+ }
+
+// AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+// CONTACT_FUNCTION_API_CONVERT_TO_STRING);
+// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ std::string format;
+ if(argumentCount > 0){
+ ArgumentValidator validator(context, argumentCount, arguments);
+ try {
+ format = validator.toString(0, false);
+ if(format == "null")
+ format = "VCARD_30";
+ } catch (const TypeMismatchException& err ) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch(const BasePlatformException& err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch(const ConversionException& err) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+ } catch(const NullPointerException& err) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+ }
+ }else{
+ format = "VCARD_30";
+ }
+
+ std::string vCard;
+ Try {
+ vCard = contact->convertToString(format);
+ } Catch(ConversionException) {
+ LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactTextFormat string'");
+ } Catch(UnsupportedException) {
+ LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
+ } Catch(Exception) {
+ LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ }
+
+ ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
+ JSValueRef result;
+ Try {
+ result = converter->toJSValueRef(vCard);
+ } Catch(Exception) {
+ LoggerE("Error on conversion : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ }
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ return result;
+}
+
+JSValueRef JSContact::clone(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("entered");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ ContactPtr contact(NULL);
+
+ Try {
+ contact = getPrivData(thisObject);
+ if (contact == NULL) {
+ ThrowMsg(InvalidArgumentException, "No private object.");
+ }
+ } Catch(Exception) {
+ LoggerE("Argument type mismatch : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Wrong object");
+ }
+
+// AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+// CONTACT_FUNCTION_API_CONVERT_TO_STRING);
+// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ ContactPtr clonedContact(NULL);
+ Try {
+ clonedContact = contact->clone();
+ } Catch(Exception) {
+ LoggerE("Error on conversion : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ }
+
+ JSValueRef result;
+ Try {
+ JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+ }
+ JSContextRef gContext = priv->getContext();
+ result = createJSObject(gContext, clonedContact);
+ } Catch(Exception) {
+ LoggerE("Error on conversion : " << _rethrown_exception.GetMessage());
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Internal error");
+ }
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ return result;
+}
+
+} // Contact
+} // DeviceAPI