Update change log and spec for wrt-plugins-tizen_0.4.25-1
[platform/framework/web/wrt-plugins-tizen.git] / src / Content / JSVideo.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 500a619..4a9dec1
@@ -65,7 +65,6 @@ JSClassDefinition JSVideo::m_classInfo =
 
 JSStaticValue JSVideo::m_property[] =
 {
-//     { TIZEN_CONTENT_VIDEO_GEOLOCATION, getPropertyGeoLocation, setPropertyGeoLocation, kJSPropertyAttributeNone},
        { TIZEN_CONTENT_VIDEO_ALBUM, getPropertyAlbum, NULL, kJSPropertyAttributeReadOnly},
        { TIZEN_CONTENT_VIDEO_ARTIST, getPropertyArtist, NULL, kJSPropertyAttributeReadOnly},
        { TIZEN_CONTENT_VIDEO_DURATION, getPropertyDuration, NULL, kJSPropertyAttributeReadOnly},
@@ -79,7 +78,6 @@ JSClassRef JSVideo::m_jsClassRef = JSClassCreate(JSVideo::getClassInfo());
 
 void JSVideo::initialize(JSContextRef context, JSObjectRef object)
 {
-    LoggerD( "entered" );
     VideoPrivObject *priv = static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) );
     if (!priv)
     {
@@ -100,26 +98,21 @@ void JSVideo::initialize(JSContextRef context, JSObjectRef object)
 
 void JSVideo::finalize(JSObjectRef object)
 {
-    LoggerD( "entered" );
-       VideoPrivObject *priv =  static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) ) ;
-       if (priv != NULL)
-       {
-               delete (priv);
-               priv = NULL;
-               JSObjectSetPrivate(object, NULL);
-       }
-
-       priv = NULL;
-
+    VideoPrivObject *priv =  static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) ) ;
+    if (priv != NULL)
+    {
+        delete (priv);
+        priv = NULL;
+        JSObjectSetPrivate(object, NULL);
+    }
+    priv = NULL;
 }
 
 const JSClassRef JSVideo::getClassRef()
 {
-       LoggerD("JSVideo::getClassRef()");
-
     if (!m_jsClassRef)
     {
-            m_jsClassRef = JSClassCreate(&m_classInfo);
+        m_jsClassRef = JSClassCreate(&m_classInfo);
     }
     return m_jsClassRef;
 }
@@ -131,7 +124,6 @@ const JSClassDefinition* JSVideo::getClassInfo()
 
 MediacontentVideoPtr JSVideo::getVideoObject(JSObjectRef object)
 {
-    LoggerD("entered");
     VideoPrivObject *priv = static_cast<VideoPrivObject*>(JSObjectGetPrivate(object));
     if(!priv)
     {
@@ -151,7 +143,6 @@ JSValueRef JSVideo::getPropertyGeoLocation(
                                                                        JSStringRef propertyName,
                                                                        JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
         Converter converter(context);
@@ -173,14 +164,13 @@ bool JSVideo::setPropertyGeoLocation(
                                        JSValueRef value,
                                        JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
                Converter converter(context);
                MediacontentVideoPtr video = getVideoObject(object);
 
                DeviceAPI::Tizen::SimpleCoordinatesPtr geoLocation =
-               DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
+                   DeviceAPI::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
 
                if(geoLocation){
                        video->setVideoLatitude(geoLocation->getLatitude());
@@ -203,7 +193,6 @@ JSValueRef JSVideo::getPropertyAlbum(
                                                                JSStringRef propertyName, 
                                                                JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
                Converter converter(context);
@@ -226,28 +215,26 @@ JSValueRef JSVideo::getPropertyArtist(
                                                                JSStringRef propertyName, 
                                                                JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
-               Converter converter(context);
-               MediacontentVideoPtr video = getVideoObject(object);
-               JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
-               if (NULL == jsResult) {
-                       ThrowMsg(NullPointerException, "Could not create js array object");
-               }
-
-               for( unsigned int i=0; i < video->getVideoArtist().size(); i++) {
-                       string artist = video->getVideoArtist().at(i);
-                       LoggerD("artist : "  << artist);
-                       JSValueRef val = converter.toJSValueRef(artist);
-
-                       if(!JSSetArrayElement(context, jsResult, i, val)){
-                          ThrowMsg(NullPointerException, "Could not insert value into js array");
-                       }
-               }
-               return jsResult;
+        Converter converter(context);
+        MediacontentVideoPtr video = getVideoObject(object);
+        JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+        if (NULL == jsResult) {
+               ThrowMsg(NullPointerException, "Could not create js array object");
+        }
+
+        for( unsigned int i=0; i < video->getVideoArtist().size(); i++) {
+            string artist = video->getVideoArtist().at(i);
+            JSValueRef val = converter.toJSValueRef(artist);
+
+            if(!JSSetArrayElement(context, jsResult, i, val)){
+                ThrowMsg(NullPointerException, "Could not insert value into js array");
+            }
+        }
+        return jsResult;
     }
-       Catch(Exception){
+    Catch(Exception){
         LoggerW("trying to get incorrect value");
     }
     return JSValueMakeNull(context);
@@ -260,14 +247,13 @@ JSValueRef JSVideo::getPropertyDuration(
                                                                JSStringRef propertyName,
                                                                JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
         Converter converter(context);
         MediacontentVideoPtr video = getVideoObject(object);
-               if(video){
-                       return converter.toJSValueRef(video->getVideoDuration());
-           }
+        if(video){
+            return converter.toJSValueRef(video->getVideoDuration());
+        }
     }
     Catch(Exception)
     {
@@ -282,14 +268,14 @@ JSValueRef JSVideo::getPropertyWidth(
                                                                JSStringRef propertyName,
                                                                JSValueRef* exception)
 {
-    LoggerD("entered");
+
     Try
     {
         Converter converter(context);
         MediacontentVideoPtr video = getVideoObject(object);
-               if(video){
-                       return converter.toJSValueRef(video->getVideoWidth());
-           }
+        if(video){
+            return converter.toJSValueRef(video->getVideoWidth());
+        }
     }
     Catch(Exception)
     {
@@ -305,14 +291,13 @@ JSValueRef JSVideo::getPropertyHeight(
                                                                JSStringRef propertyName,
                                                                JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
         Converter converter(context);
         MediacontentVideoPtr video = getVideoObject(object);
-               if(video){
-                       return converter.toJSValueRef(video->getVideoHeight());
-               }
+        if(video){
+            return converter.toJSValueRef(video->getVideoHeight());
+        }
     }
     Catch(Exception)
     {
@@ -328,34 +313,33 @@ bool JSVideo::setPropertyArtists(
                                        JSValueRef value,
                                        JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
         Converter converter(context);
         MediacontentVideoPtr video = getVideoObject(object);
 
-               vector<std::string> artists;
-               if (!JSValueIsNull(context, value)) {
-
-                       if (JSIsArrayValue(context, value)){
-                               JSObjectRef jsObject = converter.toJSObjectRef(value);
-                               for (std::size_t i = 0; i < JSGetArrayLength(context, jsObject); ++i) {
-                                       JSValueRef element = JSGetArrayElement(context, jsObject, i);
-                                       artists.push_back(converter.toString(element));
-                               }
-                       }
-                       else{
-                               DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
-                       }
-                       video->setVideoArtist(artists, true);
-                       return true;
-               }
+        vector<std::string> artists;
+        if (!JSValueIsNull(context, value)) {
+
+            if (JSIsArrayValue(context, value)){
+                JSObjectRef jsObject = converter.toJSObjectRef(value);
+                for (std::size_t i = 0; i < JSGetArrayLength(context, jsObject); ++i) {
+                    JSValueRef element = JSGetArrayElement(context, jsObject, i);
+                    artists.push_back(converter.toString(element));
+                }
+            }
+            else{
+                DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
+            }
+            video->setVideoArtist(artists, true);
+            return true;
+        }
+    }
+    Catch(Exception)
+    {
+        LoggerW("trying to set incorrect value");
+        DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
     }
-       Catch(Exception)
-       {
-           LoggerW("trying to set incorrect value");
-           DeviceAPI::Common::JSTizenExceptionFactory::postException(context, exception, DeviceAPI::Common::JSTizenException::TYPE_MISMATCH_ERROR);
-       }
        return false;
 }
 
@@ -366,18 +350,17 @@ bool JSVideo::setPropertyAlbum(
                                        JSValueRef value,
                                        JSValueRef* exception)
 {
-    LoggerD("entered");
     Try
     {
         Converter converter(context);
 
         MediacontentVideoPtr video = getVideoObject(object);
         string album = converter.toString(value);
-               if(video){
-                       video->setVideoAlbum(album, true);
-                       return true;
-               }
-       }
+        if(video){
+            video->setVideoAlbum(album, true);
+            return true;
+        }
+    }
     Catch(Exception)
     {
         LoggerW("trying to set incorrect value");