Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Bluetooth / plugin_config.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License. 
15  */
16
17
18 #include <map>
19 #include <utility>
20 #include <Commons/FunctionDefinition.h>
21 #include <Commons/FunctionDeclaration.h>
22 #include <Commons/Exception.h>
23 #include "plugin_config.h"
24
25 #define BLUETOOTH_FEATURE_API "http://tizen.org/api/bluetooth"
26 #define BLUETOOTH_FEATURE_API_GAP "http://tizen.org/api/bluetooth.gap"
27 #define BLUETOOTH_FEATURE_API_SPP "http://tizen.org/api/bluetooth.spp"
28
29 #define BLUETOOTH_DEVICE_CAP_GAP "bluetooth.gap"
30 #define BLUETOOTH_DEVICE_CAP_SPP "bluetooth.spp"
31
32 namespace TizenApis {
33 namespace Tizen1_0 {
34
35 const char* bluetoothExportedNames[] = 
36 {
37         "adapter",
38         "setPowered",
39         "setVisible",
40         "setName",
41         "discoverDevices",
42         "stopDiscovery",
43         "getKnownDevices",
44         "getDevice",
45         "createBonding",
46         "destroyBonding",
47         "registerRFCOMMServiceByUUID",
48         "unregisterRFCOMMService",
49         "connectToServiceByUUID",
50         "setSocketNotifier",
51         "writeData",
52         "readData",
53         "close",
54         "hasService"
55 };
56
57 static WrtDeviceApis::Commons::FunctionMapping createBluetoothFunctions();
58
59 static WrtDeviceApis::Commons::FunctionMapping BluetoothFunctions =
60     createBluetoothFunctions();
61
62 DEFINE_FUNCTION_GETTER(Bluetooth, BluetoothFunctions);
63
64 static WrtDeviceApis::Commons::FunctionMapping createBluetoothFunctions()
65 {
66     using namespace WrtDeviceApis::Commons;
67
68     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_GAP, BLUETOOTH_DEVICE_CAP_GAP);
69     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_SPP, BLUETOOTH_DEVICE_CAP_SPP);
70
71     ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
72
73     ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_GAP);
74     ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_GAP, DEVICE_CAP_BLUETOOTH_GAP);
75
76     ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_SPP);
77     ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_SPP, DEVICE_CAP_BLUETOOTH_SPP);
78
79     ACE_CREATE_FEATURE(FEATURE_BLUETOOTH, BLUETOOTH_FEATURE_API);
80     ACE_CREATE_FEATURE(FEATURE_GAP, BLUETOOTH_FEATURE_API_GAP);
81     ACE_CREATE_FEATURE(FEATURE_SPP, BLUETOOTH_FEATURE_API_SPP);
82
83     ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP);
84     ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_BLUETOOTH);
85     ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_GAP);
86     ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_SPP);
87
88     ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_GAP);
89     ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_BLUETOOTH);
90     ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_GAP);
91
92     ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP);
93     ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_BLUETOOTH);
94     ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_SPP);
95
96
97     FunctionMapping BluetoothFunctions;
98
99     AceFunction adapter = ACE_CREATE_FUNCTION(
100             FUNCTION_ADAPTER,
101             bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER],
102             BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP,
103             EMPTY_DEVICE_LIST);
104
105     BluetoothFunctions.insert(std::make_pair(
106                         bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER],
107                         adapter));
108
109         for (int index = BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED; 
110                 index <= BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER_RFCOMM; index++)
111         {
112             AceFunction gapLoopFunc = ACE_CREATE_FUNCTION(
113                 FUNCTION_GAP_DUMMY_FUNC_ID,
114                 bluetoothExportedNames[index],
115                 BLUETOOTH_FEATURES_BLUETOOTH_GAP,
116                 DEVICE_LIST_BLUETOOTH_GAP);
117
118                 BluetoothFunctions.insert(std::make_pair(
119                         bluetoothExportedNames[index],
120                         gapLoopFunc));
121         }
122
123         for (int index = BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE; 
124                 index <= BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE; index++)
125         {
126                 AceFunction sppLoopFunc = ACE_CREATE_FUNCTION(
127                         FUNCTION_SPP_DUMMY_FUNC_ID,
128                         bluetoothExportedNames[index],
129                         BLUETOOTH_FEATURES_BLUETOOTH_SPP,
130                         DEVICE_LIST_BLUETOOTH_SPP);
131
132                 BluetoothFunctions.insert(std::make_pair(
133                         bluetoothExportedNames[index],
134                         sppLoopFunc));
135         }
136
137     return BluetoothFunctions;
138 }
139
140 }
141
142 #undef BLUETOOTH_FEATURE_API 
143 #undef BLUETOOTH_FEATURE_API_GAP 
144 #undef BLUETOOTH_FEATURE_API_SPP 
145 #undef BLUETOOTH_DEVICE_CAP_GAP 
146 #undef BLUETOOTH_DEVICE_CAP_SPP