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