Add uuid_list of AppControl.
[framework/osp/bluetooth.git] / src / FNetBtBluetoothDevice.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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 // @file    FNetBtBluetoothDevice.cpp
18 // @brief   This is the implementation file for the BluetoothDevice class.
19 //
20
21 #include <FNetBtBluetoothTypes.h>
22 #include <FNetBtBluetoothDevice.h>
23 #include <FAppAppControl.h>
24 #include <FBaseColArrayList.h>
25 #include <FBaseColIList.h>
26 #include <FBaseColIMap.h>
27 #include <FBaseBoolean.h>
28 #include <FBaseInteger.h>
29 #include <FBaseLong.h>
30 #include <FBaseShort.h>
31 #include <FBaseSysLog.h>
32 #include "FNetBt_BluetoothDeviceImpl.h"
33
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::Base::Runtime;
37
38 namespace Tizen { namespace Net { namespace Bluetooth
39 {
40
41 // The serial port profile UUID. (00001101-0000-1000-8000-00805F9B34FB)
42 const byte BT_SVC_UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
43
44 // The LAN access profile UUID. (00001102-0000-1000-8000-00805F9B34FB)
45 const byte BT_SVC_UUID_LAP[] = {0x00, 0x00, 0x11, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
46
47 // The dial-up networking profile UUID. (00001103-0000-1000-8000-00805F9B34FB)
48 const byte BT_SVC_UUID_DUN[] = {0x00, 0x00, 0x11, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
49
50 // The synchronization profile UUID. (00001104-0000-1000-8000-00805F9B34FB)
51 const byte BT_SVC_UUID_SYNC[] = {0x00, 0x00, 0x11, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
52
53 // The object push profile UUID. (00001105-0000-1000-8000-00805F9B34FB)
54 const byte BT_SVC_UUID_OPP[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
55
56 // The file transfer profile UUID. (00001106-0000-1000-8000-00805F9B34FB)
57 const byte BT_SVC_UUID_FTP[] = {0x00, 0x00, 0x11, 0x06, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
58
59 // The synchronization profile UUID. (00001107-0000-1000-8000-00805F9B34FB)
60 const byte BT_SVC_UUID_SYNC_COMMAND[] = {0x00, 0x00, 0x11, 0x07, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
61
62 // The headset profile UUID. (00001108-0000-1000-8000-00805F9B34FB)
63 const byte BT_SVC_UUID_HSP[] = {0x00, 0x00, 0x11, 0x08, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
64
65 // The cordless telephony profile UUID. (00001109-0000-1000-8000-00805F9B34FB)
66 const byte BT_SVC_UUID_CTP[] = {0x00, 0x00, 0x11, 0x09, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
67
68 // The advanced audio distribution profile - source UUID. (0000110A-0000-1000-8000-00805F9B34FB)
69 const byte BT_SVC_UUID_A2DP_SOURCE[] = {0x00, 0x00, 0x11, 0x0A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
70
71 // The advanced audio distribution profile - sink UUID. (0000110B-0000-1000-8000-00805F9B34FB)
72 const byte BT_SVC_UUID_A2DP_SINK[] = {0x00, 0x00, 0x11, 0x0B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
73
74 // The audio/video remote control profile - target UUID. (0000110C-0000-1000-8000-00805F9B34FB)
75 const byte BT_SVC_UUID_AVRCP_TARGET[] = {0x00, 0x00, 0x11, 0x0C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
76
77 // The advanced audio distribution profile UUID. (0000110D-0000-1000-8000-00805F9B34FB)
78 const byte BT_SVC_UUID_A2DP[] = {0x00, 0x00, 0x11, 0x0D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
79
80 // The audio/video remote control profile UUID. (0000110E-0000-1000-8000-00805F9B34FB)
81 const byte BT_SVC_UUID_AVRCP[] = {0x00, 0x00, 0x11, 0x0E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
82
83 // The audio/video remote control profile - controller UUID. (0000110F-0000-1000-8000-00805F9B34FB)
84 const byte BT_SVC_UUID_AVRCP_CONTROLLER[] = {0x00, 0x00, 0x11, 0x0F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
85
86 // The intercom profile UUID. (00001110-0000-1000-8000-00805F9B34FB)
87 const byte BT_SVC_UUID_ICP[] = {0x00, 0x00, 0x11, 0x10, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
88
89 // The fax profile UUID. (00001111-0000-1000-8000-00805F9B34FB)
90 const byte BT_SVC_UUID_FAX[] = {0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
91
92 // The headset profile - audio gateway UUID. (00001112-0000-1000-8000-00805F9B34FB)
93 const byte BT_SVC_UUID_HSP_AG[] = {0x00, 0x00, 0x11, 0x12, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
94
95 // The personal area networking profile - user UUID. (00001115-0000-1000-8000-00805F9B34FB)
96 const byte BT_SVC_UUID_PAN_PANU[] = {0x00, 0x00, 0x11, 0x15, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
97
98 // The personal area networking profile - network access point UUID. (00001116-0000-1000-8000-00805F9B34FB)
99 const byte BT_SVC_UUID_PAN_NAP[] = {0x00, 0x00, 0x11, 0x16, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
100
101 // The personal area networking profile - group ad-hoc networks UUID. (00001117-0000-1000-8000-00805F9B34FB)
102 const byte BT_SVC_UUID_PAN_GN[] = {0x00, 0x00, 0x11, 0x17, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
103
104 // The basic printing profile - direct printing UUID. (00001118-0000-1000-8000-00805F9B34FB)
105 const byte BT_SVC_UUID_BPP_DIRECT_PRINTING[] = {0x00, 0x00, 0x11, 0x18, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
106
107 // The basic printing profile - reference printing UUID. (00001119-0000-1000-8000-00805F9B34FB)
108 const byte BT_SVC_UUID_BPP_REFERENCE_PRINTING[] = {0x00, 0x00, 0x11, 0x19, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
109
110 // The basic imaging profile UUID. (0000111A-0000-1000-8000-00805F9B34FB)
111 const byte BT_SVC_UUID_BIP[] = {0x00, 0x00, 0x11, 0x1A, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
112
113 // The basic imaging profile - imaging responder UUID. (0000111B-0000-1000-8000-00805F9B34FB)
114 const byte BT_SVC_UUID_BIP_RESPONDER[] = {0x00, 0x00, 0x11, 0x1B, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
115
116 // The basic imaging profile - imaging automatic archive UUID. (0000111C-0000-1000-8000-00805F9B34FB)
117 const byte BT_SVC_UUID_BIP_AUTOMATIC_ARCHIVE[] = {0x00, 0x00, 0x11, 0x1C, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
118
119 // The basic imaging profile - imaging referenced objects UUID. (0000111D-0000-1000-8000-00805F9B34FB)
120 const byte BT_SVC_UUID_BIP_REFERENCED_OBJECTS[] = {0x00, 0x00, 0x11, 0x1D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
121
122 // The hands-free profile UUID. (0000111E-0000-1000-8000-00805F9B34FB)
123 const byte BT_SVC_UUID_HFP[] = {0x00, 0x00, 0x11, 0x1E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
124
125 // The hands-free profile - audio gateway UUID. (0000111F-0000-1000-8000-00805F9B34FB)
126 const byte BT_SVC_UUID_HFP_AG[] = {0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
127
128 // The basic printing profile - direct printing referenced objects UUID. (00001120-0000-1000-8000-00805F9B34FB)
129 const byte BT_SVC_UUID_BPP_DIRECT_PRINTING_RO[] = {0x00, 0x00, 0x11, 0x20, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
130
131 // The basic printing profile - reflected UI UUID. (00001121-0000-1000-8000-00805F9B34FB)
132 const byte BT_SVC_UUID_BPP_REFLECTED_UI[] = {0x00, 0x00, 0x11, 0x21, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
133
134 // The basic printing profile - basic printing UUID. (00001122-0000-1000-8000-00805F9B34FB)
135 const byte BT_SVC_UUID_BPP_BASIC_PRINTING[] = {0x00, 0x00, 0x11, 0x22, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
136
137 // The basic printing profile - printing status UUID. (00001123-0000-1000-8000-00805F9B34FB)
138 const byte BT_SVC_UUID_BPP_PRINTING_STATUS[] = {0x00, 0x00, 0x11, 0x23, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
139
140 // The human interface device profile UUID. (00001124-0000-1000-8000-00805F9B34FB)
141 const byte BT_SVC_UUID_HID[] = {0x00, 0x00, 0x11, 0x24, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
142
143 // The hardcopy cable replacement profile UUID. (00001125-0000-1000-8000-00805F9B34FB)
144 const byte BT_SVC_UUID_HCRP[] = {0x00, 0x00, 0x11, 0x25, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
145
146 // The hardcopy cable replacement profile - print UUID. (00001126-0000-1000-8000-00805F9B34FB)
147 const byte BT_SVC_UUID_HCRP_PRINT[] = {0x00, 0x00, 0x11, 0x26, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
148
149 // The hardcopy cable replacement profile - scan UUID. (00001127-0000-1000-8000-00805F9B34FB)
150 const byte BT_SVC_UUID_HCRP_SCAN[] = {0x00, 0x00, 0x11, 0x27, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
151
152 // The SIM access profile UUID. (0000112D-0000-1000-8000-00805F9B34FB)
153 const byte BT_SVC_UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
154
155 // The phone book access - client equipment UUID. (0000112E-0000-1000-8000-00805F9B34FB)
156 const byte BT_SVC_UUID_PBAP_PCE[] = {0x00, 0x00, 0x11, 0x2E, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
157
158 // The phone book access - server equipment UUID. (0000112F-0000-1000-8000-00805F9B34FB)
159 const byte BT_SVC_UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
160
161 // The phone book access UUID. (00001130-0000-1000-8000-00805F9B34FB)
162 const byte BT_SVC_UUID_PBAP[] = {0x00, 0x00, 0x11, 0x30, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
163
164 // The headset profile - headset UUID. (00001131-0000-1000-8000-00805F9B34FB)
165 const byte BT_SVC_UUID_HSP_HS[] = {0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
166
167 // The message access profile - message access server UUID. (00001132-0000-1000-8000-00805F9B34FB)
168 const byte BT_SVC_UUID_MAP_ACCESS_SERVER[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
169
170 // The message access profile - message notification server UUID. (00001133-0000-1000-8000-00805F9B34FB)
171 const byte BT_SVC_UUID_MAP_NOTIFICATION_SERVER[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
172
173 // The message access profile - message access profile UUID. (00001134-0000-1000-8000-00805F9B34FB)
174 const byte BT_SVC_UUID_MAP_ACCESS_PROFILE[] = {0x00, 0x00, 0x11, 0x34, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
175
176 // The device identification profile - PNP information UUID. (00001200-0000-1000-8000-00805F9B34FB)
177 const byte BT_SVC_UUID_DID_PNP_INFORMATION[] = {0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
178
179 // The generic networking UUID. (00001201-0000-1000-8000-00805F9B34FB)
180 const byte BT_SVC_UUID_GENERIC_NETWORKING[] = {0x00, 0x00, 0x12, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
181
182 // The generic file transfer UUID. (00001202-0000-1000-8000-00805F9B34FB)
183 const byte BT_SVC_UUID_GENERIC_FILE_TRANSFER[] = {0x00, 0x00, 0x12, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
184
185 // The generic audio UUID. (00001203-0000-1000-8000-00805F9B34FB)
186 const byte BT_SVC_UUID_GENERIC_AUDIO[] = {0x00, 0x00, 0x12, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
187
188 // The generic telephony UUID. (00001204-0000-1000-8000-00805F9B34FB)
189 const byte BT_SVC_UUID_GENERIC_TELEPHONY[] = {0x00, 0x00, 0x12, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
190
191 // The video distribution profile - source UUID. (00001303-0000-1000-8000-00805F9B34FB)
192 const byte BT_SVC_UUID_VDP_SOURCE[] = {0x00, 0x00, 0x13, 0x03, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
193
194 // The video distribution profile - sink UUID. (00001304-0000-1000-8000-00805F9B34FB)
195 const byte BT_SVC_UUID_VDP_SINK[] = {0x00, 0x00, 0x13, 0x04, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
196
197 // The video distribution profile - distribution UUID. (00001305-0000-1000-8000-00805F9B34FB)
198 const byte BT_SVC_UUID_VDP_DISTRIBUTION[] = {0x00, 0x00, 0x13, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
199
200 // The health device profile UUID. (00001400-0000-1000-8000-00805F9B34FB)
201 const byte BT_SVC_UUID_HDP[] = {0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
202
203 // The health device profile - source UUID. (00001401-0000-1000-8000-00805F9B34FB)
204 const byte BT_SVC_UUID_HDP_SOURCE[] = {0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
205
206 // The health device profile - sink UUID. (00001402-0000-1000-8000-00805F9B34FB)
207 const byte BT_SVC_UUID_HDP_SINK[] = {0x00, 0x00, 0x14, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
208
209
210 BluetoothDevice::BluetoothDevice(void)
211         : __pImpl(null)
212 {
213         __pImpl = new (std::nothrow) _BluetoothDeviceImpl();
214         SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
215 }
216
217 BluetoothDevice::BluetoothDevice(const Tizen::Base::ByteBuffer& address, const Base::String& deviceName, BluetoothMajorDeviceClassType majorClassType, BluetoothMinorDeviceClassType minorClassType, unsigned long serviceClassList, unsigned long serviceList)
218         : __pImpl(null)
219 {
220         __pImpl = new (std::nothrow) _BluetoothDeviceImpl(address, deviceName, majorClassType, minorClassType, serviceClassList, serviceList);
221         SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
222 }
223
224 BluetoothDevice::BluetoothDevice(const BluetoothDevice& value)
225         : __pImpl(null)
226 {
227         __pImpl = new (std::nothrow) _BluetoothDeviceImpl(*value.__pImpl);
228         SysTryReturnVoidResult(NID_NET_BT, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
229 }
230
231 BluetoothDevice::~BluetoothDevice(void)
232 {
233         delete __pImpl;
234 }
235
236 BluetoothDevice&
237 BluetoothDevice::operator =(const BluetoothDevice& rhs)
238 {
239     if (this != &rhs)
240     {
241         *__pImpl = *rhs.__pImpl;
242     }
243
244         return *this;
245 }
246
247 const Tizen::Base::ByteBuffer*
248 BluetoothDevice::GetAddress(void) const
249 {
250         return __pImpl->GetAddress();
251 }
252
253 result
254 BluetoothDevice::SetAddress(const Tizen::Base::ByteBuffer& address)
255 {
256         return __pImpl->SetAddress(address);
257 }
258
259 String
260 BluetoothDevice::GetName(void) const
261 {
262         return __pImpl->GetName();
263 }
264
265 bool
266 BluetoothDevice::IsPaired(void) const
267 {
268         return __pImpl->IsPaired();
269 }
270
271 int
272 BluetoothDevice::GetRssi(void) const
273 {
274         return __pImpl->GetRssi();
275 }
276
277 BluetoothMajorDeviceClassType
278 BluetoothDevice::GetMajorDeviceClassType(void) const
279 {
280         return __pImpl->GetMajorDeviceClassType();
281 }
282
283 BluetoothMinorDeviceClassType
284 BluetoothDevice::GetMinorDeviceClassType(void) const
285 {
286         return __pImpl->GetMinorDeviceClassType();
287 }
288
289 unsigned long
290 BluetoothDevice::GetServiceClassList(void) const
291 {
292         return __pImpl->GetServiceClassList();
293 }
294
295 unsigned long
296 BluetoothDevice::GetServiceList(void) const
297 {
298         return __pImpl->GetServiceList();
299 }
300
301 const Tizen::Base::Collection::IList*
302 BluetoothDevice::GetServiceUuidList(void) const
303 {
304         return __pImpl->GetServiceUuidList();
305 }
306
307 bool
308 BluetoothDevice::Equals(const Tizen::Base::Object& obj) const
309 {
310         const BluetoothDevice* pOther = dynamic_cast <const BluetoothDevice*>(&obj);
311
312         if (pOther == null)
313         {
314                 return false;
315         }
316
317         if (pOther == this)
318         {
319                 return true;
320         }
321
322         return(__pImpl->Equals(*(pOther->__pImpl)));
323 }
324
325 int
326 BluetoothDevice::GetHashCode(void) const
327 {
328         return __pImpl->GetHashCode();
329 }
330
331 BluetoothDevice*
332 BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IList& appControlResult)
333 {
334         BluetoothDevice* pNewBtDevice = null;
335         String* pResultStrPtr = null;
336         String keywordStr;
337         String dataStr;
338         ByteBuffer btAddrBytes;
339         String deviceName;
340         long majClassType = 0;
341         long minClassType = 0;
342         long svcClassType = 0;
343         long svcType = 0;
344
345         ClearLastResult();
346
347         if (appControlResult.GetCount() != 7)
348         {
349                 goto CATCH;
350         }
351
352         pResultStrPtr = (String*) appControlResult.GetAt(0);
353         if (pResultStrPtr->Equals(String(Tizen::App::APPCONTROL_RESULT_SUCCEEDED)) == false)
354         {
355                 goto CATCH;
356         }
357
358         // Gets the address from index 1 as a String. E.g. 00-1E-2B-72-08-DB
359         pResultStrPtr = (String*) appControlResult.GetAt(1);
360         if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
361                 (keywordStr.Equals(String("addr_val:")) == false) ||
362                 (pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
363         {
364                 goto CATCH;
365         }
366
367         // Convert the type of the address to ByteBuffer
368         btAddrBytes.Construct(6);
369         if (_BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes) != E_SUCCESS)
370         {
371                 goto CATCH;
372         }
373
374         keywordStr.Clear();
375         dataStr.Clear();
376
377         // Gets the name from index 2
378         pResultStrPtr = (String*) appControlResult.GetAt(2);
379         if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
380                 (keywordStr.Equals(String("dev_name:")) == false) ||
381                 (pResultStrPtr->SubString(9, deviceName) != E_SUCCESS))
382         {
383                 goto CATCH;
384         }
385
386         keywordStr.Clear();
387
388         // Gets the major device class from index 3
389         pResultStrPtr = (String*) appControlResult.GetAt(3);
390         if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
391                 (keywordStr.Equals(String("maj_cls_type:")) == false) ||
392                 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
393         {
394                 goto CATCH;
395         }
396
397         if (Long::Decode(dataStr, majClassType) != E_SUCCESS)
398         {
399                 goto CATCH;
400         }
401
402         keywordStr.Clear();
403         dataStr.Clear();
404
405         // Gets the minor device class from index 4
406         pResultStrPtr = (String*) appControlResult.GetAt(4);
407         if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
408                 (keywordStr.Equals(String("min_cls_type:")) == false) ||
409                 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
410         {
411                 goto CATCH;
412         }
413
414         if (Long::Decode(dataStr, minClassType) != E_SUCCESS)
415         {
416                 goto CATCH;
417         }
418
419         keywordStr.Clear();
420         dataStr.Clear();
421
422         // Gets the service classes as a bit-mask from index 5
423         pResultStrPtr = (String*) appControlResult.GetAt(5);
424         if ((pResultStrPtr->SubString(0, 13, keywordStr) != E_SUCCESS) ||
425                 (keywordStr.Equals(String("svc_cls_type:")) == false) ||
426                 (pResultStrPtr->SubString(13, dataStr) != E_SUCCESS))
427         {
428                 goto CATCH;
429         }
430
431         if (Long::Decode(dataStr, svcClassType) != E_SUCCESS)
432         {
433                 goto CATCH;
434         }
435
436         keywordStr.Clear();
437         dataStr.Clear();
438
439         // Gets the service types as a bit-mask from index 6
440         pResultStrPtr = (String*) appControlResult.GetAt(6);
441         if ((pResultStrPtr->SubString(0, 9, keywordStr) != E_SUCCESS) ||
442                 (keywordStr.Equals(String("svc_type:")) == false) ||
443                 (pResultStrPtr->SubString(9, dataStr) != E_SUCCESS))
444         {
445                 goto CATCH;
446         }
447
448         if (Long::Decode(dataStr, svcType) != E_SUCCESS)
449         {
450                 goto CATCH;
451         }
452
453         // Create an instance of BluetoothDevice.
454         pNewBtDevice =
455                 new (std::nothrow) BluetoothDevice(btAddrBytes, deviceName, (BluetoothMajorDeviceClassType) majClassType,
456                                                         (BluetoothMinorDeviceClassType) minClassType, svcClassType,
457                                                         svcType);
458         if (pNewBtDevice == null)
459         {
460                 SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
461                 SetLastResult(E_OUT_OF_MEMORY);
462         }
463
464         return pNewBtDevice;
465
466 CATCH:
467
468         SysLogException(NID_NET_BT, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.");
469         SetLastResult(E_INVALID_ARG);
470
471         return null;
472 }
473
474 BluetoothDevice*
475 BluetoothDevice::GetInstanceFromAppControlResultN(const Tizen::Base::Collection::IMap& appControlResult)
476 {
477         result r = E_SUCCESS;
478         BluetoothDevice* pNewBtDevice = null;
479         _BluetoothDeviceImpl* pNewBtDeviceImpl = null;
480         String* pResultStrPtr = null;
481         String dataStr;
482         ByteBuffer btAddrBytes;
483         String deviceName;
484         int rssi = 0;
485         bool isPaired = false;
486         long majClassType = 0;
487         long minClassType = 0;
488         long svcClassType = 0;
489         long svcType = 0;
490         ArrayList* pUuidList = null;
491
492         ClearLastResult();
493
494         // Gets the address as a String. E.g. 00-1E-2B-72-08-DB
495         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/address"));
496         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
497
498         dataStr.Insert(*pResultStrPtr, 0);
499
500         // Convert the type of the address to ByteBuffer
501         btAddrBytes.Construct(6);
502         r = _BluetoothDeviceImpl::GetAddressByteBuffer(dataStr, L"-", btAddrBytes);
503         SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
504
505         dataStr.Clear();
506
507         // Gets the name
508         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/name"));
509         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
510         deviceName.Insert(*pResultStrPtr, 0);
511
512         // Gets the rssi value
513         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/rssi"));
514         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
515         dataStr.Insert(*pResultStrPtr, 0);
516
517         r = Integer::Decode(dataStr, rssi);
518         SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
519
520         dataStr.Clear();
521
522         // Gets the ispaired
523         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/is_paired"));
524         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
525         dataStr.Insert(*pResultStrPtr, 0);
526
527         isPaired = Boolean::Parse(dataStr);
528
529         dataStr.Clear();
530
531         // Gets the major device class
532         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/major_class"));
533         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
534         dataStr.Insert(*pResultStrPtr, 0);
535
536         r = Long::Decode(dataStr, majClassType);
537         SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
538
539         dataStr.Clear();
540
541         // Gets the minor device class
542         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/minor_class"));
543         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
544         dataStr.Insert(*pResultStrPtr, 0);
545
546         r = Long::Decode(dataStr, minClassType);
547         SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
548
549         dataStr.Clear();
550
551         // Gets the service classes as a bit-mask
552         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_class"));
553         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
554         dataStr.Insert(*pResultStrPtr, 0);
555
556         r = Long::Decode(dataStr, svcClassType);
557         SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
558
559         dataStr.Clear();
560
561         // Gets the service types as a bit-mask
562         pResultStrPtr = (String*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/service_type"));
563         SysTryReturn(NID_NET_BT, pResultStrPtr != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
564         dataStr.Insert(*pResultStrPtr, 0);
565
566         r = Long::Decode(dataStr, svcType);
567         SysTryReturn(NID_NET_BT, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
568
569         // Gets the service UUID list
570         pUuidList = (ArrayList*) appControlResult.GetValue(String("http://tizen.org/appcontrol/data/bluetooth/uuid_list"));
571         SysTryReturn(NID_NET_BT, pUuidList != null, null, E_INVALID_ARG, "[E_INVALID_ARG] exception occurred on parsing input data.")
572
573         // Create an instance of BluetoothDevice.
574         pNewBtDevice = new (std::nothrow) BluetoothDevice();
575         if (pNewBtDevice == null)
576         {
577                 SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] exception occurred on creating BluetoothDevice.");
578                 SetLastResult(E_OUT_OF_MEMORY);
579                 return null;
580         }
581
582         pNewBtDeviceImpl = _BluetoothDeviceImpl::GetInstance(*pNewBtDevice);
583
584         pNewBtDeviceImpl->SetAddress(btAddrBytes);
585         pNewBtDeviceImpl->SetName(deviceName);
586         pNewBtDeviceImpl->SetPaired(isPaired);
587         pNewBtDeviceImpl->SetRssi(rssi);
588         pNewBtDeviceImpl->SetMajorDeviceClassType((BluetoothMajorDeviceClassType) majClassType);
589         pNewBtDeviceImpl->SetMinorDeviceClassType((BluetoothMinorDeviceClassType) minClassType);
590         pNewBtDeviceImpl->SetServiceClassList(svcClassType);
591         pNewBtDeviceImpl->SetServiceList(svcType);
592         pNewBtDeviceImpl->SetServiceUuidList(pUuidList, true);
593
594         return pNewBtDevice;
595 }
596
597 } } } // Tizen::Net::Bluetooth