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.
18 #include <PlatformException.h>
21 #include "plugin_config.h"
22 #include "BluetoothClass.h"
23 #include "BluetoothClassDeviceMajor.h"
24 #include "BluetoothClassDeviceMinor.h"
25 #include "BluetoothClassDeviceService.h"
26 #include "JSBluetoothClassDeviceService.h"
30 using namespace DeviceAPI::Common;
35 BluetoothClass::BluetoothClass(bt_class_s bluetoothClass)
38 mMajor = BluetoothClassDeviceMajor::getInstance()->getMajorValue(bluetoothClass.major_device_class);
39 mMinor = BluetoothClassDeviceMinor::getInstance()->getMinorValue(bluetoothClass.minor_device_class);
40 mServices= BluetoothClassDeviceService::getInstance()->getServiceValues(bluetoothClass.major_service_class_mask);
43 BluetoothClass::~BluetoothClass()
48 unsigned long BluetoothClass::getMajor() const
54 unsigned long BluetoothClass::getMinor() const
60 JSValueRef BluetoothClass::getServices(JSContextRef context)
64 JSValueRef service = mLocalProperty.getProperty(context, BLUETOOTH_CLASS_SERVICES);
66 service = JSUtil::toJSValueRef_(context, mServices);
67 mLocalProperty.setProperty(context, BLUETOOTH_CLASS_SERVICES, service);
72 return JSUtil::toJSValueRef_(context, mServices);
75 bool BluetoothClass::hasService(unsigned long service)
79 for(std::vector<unsigned long>::iterator iter = mServices.begin(); iter != mServices.end(); ++iter) {
80 if((*iter) == service) {