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>
20 #include "BluetoothClassDeviceService.h"
27 BluetoothClassDeviceService::BluetoothClassDeviceService()
31 mServiceStringMap.insert(std::pair<std::string, unsigned long>("LIMITED_DISCOVERABILITY", 0x0001));
32 mServiceStringMap.insert(std::pair<std::string, unsigned long>("POSITIONING", 0x0008));
33 mServiceStringMap.insert(std::pair<std::string, unsigned long>("NETWORKING", 0x0010));
34 mServiceStringMap.insert(std::pair<std::string, unsigned long>("RENDERING", 0x0020));
35 mServiceStringMap.insert(std::pair<std::string, unsigned long>("CAPTURING", 0x0040));
36 mServiceStringMap.insert(std::pair<std::string, unsigned long>("OBJECT_TRANSFER", 0x0080));
37 mServiceStringMap.insert(std::pair<std::string, unsigned long>("AUDIO", 0x0100));
38 mServiceStringMap.insert(std::pair<std::string, unsigned long>("TELEPHONY", 0x0200));
39 mServiceStringMap.insert(std::pair<std::string, unsigned long>("INFORMATION", 0x0400));
41 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE, 0x0001));
42 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_POSITIONING, 0x0008));
43 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_NETWORKING, 0x0010));
44 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_RENDERING, 0x0020));
45 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_CAPTURING, 0x0040));
46 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_OBJECT_TRANSFER, 0x0080));
47 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_AUDIO, 0x0100));
48 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_TELEPHONY, 0x0200));
49 mServiceEnumMap.insert(std::pair<bt_major_service_class_e, unsigned long>(BT_MAJOR_SERVICE_CLASS_INFORMATION, 0x0400));
52 BluetoothClassDeviceService::~BluetoothClassDeviceService()
57 BluetoothClassDeviceService* BluetoothClassDeviceService::getInstance()
60 static BluetoothClassDeviceService instance;
64 unsigned long BluetoothClassDeviceService::getServiceValue(std::string service)
67 return mServiceStringMap.find(service)->second;
70 unsigned long BluetoothClassDeviceService::getServiceValue(bt_major_service_class_e service)
73 return mServiceEnumMap.find(service)->second;
76 std::vector<unsigned long> BluetoothClassDeviceService::getServiceValues(int serviceMask)
80 std::vector<unsigned long> ret;
81 for(std::map<bt_major_service_class_e, unsigned long>::iterator iter = mServiceEnumMap.begin(); iter != mServiceEnumMap.end(); iter++) {
82 if(iter->first & serviceMask) {
83 ret.push_back(iter->second);