Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / Contact / JSContactEmailAddress.cpp
index e143e9a..af4fc69 100755 (executable)
@@ -347,10 +347,29 @@ JSValueRef JSContactEmailAddress::getTypes(JSContextRef context,
 {
        Try
        {
-               ContactConverterFactory::ConverterType converter =
-                               ContactConverterFactory::getConverter(context);
+               JSContactEmailAddressPriv *priv = static_cast<JSContactEmailAddressPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+               }
+               JSContextRef gContext = priv->getContext();
+
+               ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
                ContactEmailAddressPtr emailAddress = getPrivData(object);
-               return JSContactEmailAddressTypeArray::createArray(context, emailAddress->getTypes());
+
+               if(emailAddress->IsTypesSetJSArray()){
+                       return emailAddress->getTypesJSObj();
+               }else{
+                       JSValueRef tempJSValue = emailAddress->getTypesJSArray();
+                       tempJSValue = converter->toJSValueRef(emailAddress->getTypes());
+
+                       JSObjectRef convertedJSObject = emailAddress->getTypesJSObj();
+                       convertedJSObject = JSValueToObject( gContext, tempJSValue, NULL );
+                       emailAddress->setTypesJSArray(true, convertedJSObject);
+
+                       JSValueProtect(gContext, convertedJSObject);
+                       emailAddress->setContext(gContext);
+                       return tempJSValue;
+               }
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {