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 "JSBluetoothClassDeviceMajor.h"
21 #include "BluetoothClassDeviceMajor.h"
25 using namespace WrtDeviceApis::Commons;
26 using namespace DeviceAPI::Common;
31 JSClassDefinition JSBluetoothClassDeviceMajor::m_classInfo = {
33 kJSClassAttributeNone,
34 "BluetoothClassDeviceMajor",
36 m_property, //StaticValues
37 NULL, //StaticFunctions
38 initialize, //Initialize
43 NULL, //DeleteProperty,
44 NULL, //GetPropertyNames,
45 NULL, //CallAsFunction,
46 NULL, //CallAsConstructor,
51 JSClassRef JSBluetoothClassDeviceMajor::m_jsClassRef = JSClassCreate(JSBluetoothClassDeviceMajor::getClassInfo());
53 JSStaticValue JSBluetoothClassDeviceMajor::m_property[] = {
54 { "MISC", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
55 { "COMPUTER", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
56 { "PHONE", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
57 { "NETWORK", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
58 { "AUDIO_VIDEO", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
59 { "PERIPHERAL", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
60 { "IMAGING", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
61 { "WEARABLE", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
62 { "TOY", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
63 { "HEALTH", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
64 { "UNCATEGORIZED", getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
69 const JSClassRef JSBluetoothClassDeviceMajor::getClassRef()
72 m_jsClassRef = JSClassCreate(&m_classInfo);
77 const JSClassDefinition* JSBluetoothClassDeviceMajor::getClassInfo()
82 JSObjectRef JSBluetoothClassDeviceMajor::createJSObject(JSContextRef context)
84 return JSObjectMake(context, getClassRef(), NULL);
87 void JSBluetoothClassDeviceMajor::initialize(JSContextRef context, JSObjectRef object)
93 void JSBluetoothClassDeviceMajor::finalize(JSObjectRef object)
99 JSValueRef JSBluetoothClassDeviceMajor::getProperty(JSContextRef context,
101 JSStringRef propertyName,
102 JSValueRef* exception)
105 std::string name = JSUtil::JSStringToString(context, propertyName);
106 return JSUtil::toJSValueRef(context, BluetoothClassDeviceMajor::getInstance()->getMajorValue(name));
107 } catch (const BasePlatformException &err) {
108 LoggerW("Getting property is failed: " << err.getMessage().c_str());