2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 #include "plugin_config.h"
20 #include "JSBluetoothClassDeviceService.h"
21 #include "BluetoothClassDeviceService.h"
25 using namespace WrtDeviceApis::Commons;
26 using namespace DeviceAPI::Common;
31 JSClassDefinition JSBluetoothClassDeviceService::m_classInfo = {
33 kJSClassAttributeNone,
34 "BluetoothClassDeviceService",
36 m_property, //StaticValues
37 NULL, //StaticFunctions
38 initialize, //Initialize
43 NULL, //DeleteProperty,
44 NULL, //GetPropertyNames,
45 NULL, //CallAsFunction,
46 NULL, //CallAsConstructor,
53 JSClassRef JSBluetoothClassDeviceService::m_jsClassRef = JSClassCreate(JSBluetoothClassDeviceService::getClassInfo());
55 JSStaticValue JSBluetoothClassDeviceService::m_property[] = {
56 { "LIMITED_DISCOVERABILITY", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
57 { "POSITIONING", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
58 { "NETWORKING", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
59 { "RENDERING", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
60 { "CAPTURING", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
61 { "OBJECT_TRANSFER", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
62 { "AUDIO", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
63 { "TELEPHONY", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
64 { "INFORMATION", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
68 const JSClassRef JSBluetoothClassDeviceService::getClassRef()
71 m_jsClassRef = JSClassCreate(&m_classInfo);
76 const JSClassDefinition* JSBluetoothClassDeviceService::getClassInfo()
81 JSObjectRef JSBluetoothClassDeviceService::createJSObject(JSContextRef context)
83 return JSObjectMake(context, getClassRef(), NULL);
86 void JSBluetoothClassDeviceService::initialize(JSContextRef context, JSObjectRef object)
91 void JSBluetoothClassDeviceService::finalize(JSObjectRef object)
96 JSValueRef JSBluetoothClassDeviceService::getProperty(JSContextRef context,
98 JSStringRef propertyName,
99 JSValueRef* exception)
102 std::string name = JSUtil::JSStringToString(context, propertyName);
103 return JSUtil::toJSValueRef(context, BluetoothClassDeviceService::getInstance()->getServiceValue(name));
104 } catch (const BasePlatformException &err) {
105 LoggerW("Getting property is failed: " << err.getMessage().c_str());