Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Bluetooth / BluetoothClass.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 #include <PlatformException.h>
19 #include <JSUtil.h>
20
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"
27
28 #include <Logger.h>
29
30 using namespace DeviceAPI::Common;
31
32 namespace DeviceAPI {
33 namespace Bluetooth {
34
35 BluetoothClass::BluetoothClass(bt_class_s bluetoothClass)    
36 {
37         Common::SecurityAccessor();
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);
41 }
42
43 BluetoothClass::~BluetoothClass()
44 {
45 }
46
47 unsigned long BluetoothClass::getMajor() const
48 {
49     return mMajor;
50 }
51
52 unsigned long BluetoothClass::getMinor() const
53 {
54     return mMinor;
55 }
56
57 JSValueRef BluetoothClass::getServices(JSContextRef context)
58 {
59 /*   
60     JSValueRef service = mLocalProperty.getProperty(context, BLUETOOTH_CLASS_SERVICES);
61     if(service == NULL) {
62         service = JSUtil::toJSValueRef_(context, mServices);
63         mLocalProperty.setProperty(context, BLUETOOTH_CLASS_SERVICES, service);
64     }
65
66     return service;
67 */
68     return JSUtil::toJSValueRef_(context, mServices);
69 }
70
71 bool BluetoothClass::hasService(unsigned long service)
72 {
73     for(std::vector<unsigned long>::iterator iter = mServices.begin(); iter != mServices.end(); ++iter) {
74         if((*iter) == service) {
75             return true;
76         }
77     }
78     return false;
79 }
80
81
82 } // Bluetooth
83 } // DeviceAPI