upload tizen1.0 source
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Bluetooth / JSBluetoothSocket.cpp
index c0b58b2..282b9cf 100644 (file)
@@ -72,9 +72,9 @@ JSStaticValue JSBluetoothSocket::m_properties[] =
        {"protocol", getProperty, NULL, kJSPropertyAttributeReadOnly},
        {"state", getProperty, NULL, kJSPropertyAttributeReadOnly},
        {"peer", getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {"onError", NULL, setProperty, kJSPropertyAttributeNone},
-       {"onMessage", NULL, setProperty, kJSPropertyAttributeNone},
-       {"onClose", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onerror", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onmessage", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onclose", NULL, setProperty, kJSPropertyAttributeNone},
        {0, 0, 0, 0}
 };
 
@@ -270,7 +270,7 @@ JSValueRef JSBluetoothSocket::getProperty(JSContextRef context,
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(WrtDeviceApis::Commons::UnknownException);        
+                       Throw(WrtDeviceApis::Commons::ConversionException);     
                }
 
                if(JSStringIsEqualToUTF8CString(propertyName, "uuid")) 
@@ -345,17 +345,16 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object
                if (priv == NULL) 
                {
                        LogError("priv null");
-                       Throw(WrtDeviceApis::Commons::UnknownException);                                
+                       Throw(WrtDeviceApis::Commons::ConversionException);                             
                }
 
-               if (argumentCount < 1 || JSValueIsNull(context, arguments[0]) == true)
+               if (argumentCount < 1)
                {
                        LogError("argument wrong");
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);                                
+                       Throw(WrtDeviceApis::Commons::ConversionException);                             
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
                        bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_WRITE_DATA]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
@@ -367,7 +366,7 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object
                if (data.size() == 0)
                {
                        LogError("size 0 array passed");
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);                                
+                       Throw(WrtDeviceApis::Commons::ConversionException);                             
                }
 
         DPL::ScopedArray<char> buffer(new char[data.size()]);
@@ -402,7 +401,7 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -435,7 +434,6 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, JSObjectRef object,
                IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
                        bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_READ_DATA]);
                
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
@@ -473,7 +471,7 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, JSObjectRef object,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -507,12 +505,18 @@ JSValueRef JSBluetoothSocket::close(JSContextRef context, JSObjectRef object,
                LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_CLOSE]);
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
                        bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_CLOSE]);
 
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
+               if (BluetoothSocketManager->close() != BT_ERROR_NONE)
+               {
+                       Throw(WrtDeviceApis::Commons::UnknownException);        
+               }
+
+               return JSValueMakeNull(context);
+
        }
        Catch (WrtDeviceApis::Commons::SecurityException) 
        {
@@ -531,7 +535,7 @@ JSValueRef JSBluetoothSocket::close(JSContextRef context, JSObjectRef object,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {