Pairing and selection issues patch
[profile/ivi/wrt-plugins-ivi-bt.git] / src / BluetoothClassDeviceMajor.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
20 #include "BluetoothClassDeviceMajor.h"
21
22 #include <Logger.h>
23
24 namespace DeviceAPI {
25 namespace Bluetooth {
26
27 BluetoothClassDeviceMajor::BluetoothClassDeviceMajor()
28 {
29     mMajorStringMap.insert(std::pair<std::string, unsigned long>("MISC", 0x00));
30     mMajorStringMap.insert(std::pair<std::string, unsigned long>("COMPUTER", 0x01));
31     mMajorStringMap.insert(std::pair<std::string, unsigned long>("PHONE", 0x02));
32     mMajorStringMap.insert(std::pair<std::string, unsigned long>("NETWORK", 0x03));
33     mMajorStringMap.insert(std::pair<std::string, unsigned long>("AUDIO_VIDEO", 0x04));
34     mMajorStringMap.insert(std::pair<std::string, unsigned long>("PERIPHERAL", 0x05));
35     mMajorStringMap.insert(std::pair<std::string, unsigned long>("IMAGING", 0x06));
36     mMajorStringMap.insert(std::pair<std::string, unsigned long>("WEARABLE", 0x07));
37     mMajorStringMap.insert(std::pair<std::string, unsigned long>("TOY", 0x08));
38     mMajorStringMap.insert(std::pair<std::string, unsigned long>("HEALTH", 0x09));
39     mMajorStringMap.insert(std::pair<std::string, unsigned long>("UNCATEGORIZED", 0x1F));
40
41     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_MISC, 0x00));
42     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_COMPUTER, 0x01));
43     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_PHONE, 0x02));
44     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_LAN_NETWORK_ACCESS_POINT, 0x03));
45     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_AUDIO_VIDEO, 0x04));
46     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_PERIPHERAL, 0x05));
47     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_IMAGING, 0x06));
48     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_WEARABLE, 0x07));
49     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_TOY, 0x08));
50     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_HEALTH, 0x09));
51     mMajorEnumMap.insert(std::pair<bt_major_device_class_e, unsigned long>(BT_MAJOR_DEVICE_CLASS_UNCATEGORIZED, 0x1F));
52 }
53
54 BluetoothClassDeviceMajor::~BluetoothClassDeviceMajor()
55 {
56 }
57
58 BluetoothClassDeviceMajor* BluetoothClassDeviceMajor::getInstance()
59 {
60     static BluetoothClassDeviceMajor instance;
61     return &instance;
62 }
63
64 unsigned long BluetoothClassDeviceMajor::getMajorValue(std::string major)
65 {
66     return mMajorStringMap.find(major)->second;
67 }
68
69 unsigned long BluetoothClassDeviceMajor::getMajorValue(bt_major_device_class_e major)
70 {
71     return mMajorEnumMap.find(major)->second;
72 }
73
74
75 } // Bluetooth
76 } // DeviceAPI