Revert "Rollback changes to submit TIZEN:COMMON project"
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / bt-oob.c
1 /*
2  * Bluetooth-frwk
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:  Hocheol Seo <hocheol.seo@samsung.com>
7  *               Girishashok Joshi <girish.joshi@samsung.com>
8  *               Chanyeol Park <chanyeol.park@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *              http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24 #include "bluetooth-api.h"
25 #include "bt-internal-types.h"
26
27 #include "bt-common.h"
28 #include "bt-request-sender.h"
29 #include "bt-event-handler.h"
30
31 BT_EXPORT_API int bluetooth_oob_read_local_data(bt_oob_data_t *local_oob_data)
32 {
33         int result;
34
35         BT_CHECK_PARAMETER(local_oob_data, return);
36         BT_CHECK_ENABLED(return);
37
38         BT_INIT_PARAMS();
39         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
40
41         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_OOB_READ_LOCAL_DATA,
42                 in_param1, in_param2, in_param3, in_param4, &out_param);
43
44         if (result == BLUETOOTH_ERROR_NONE) {
45                 *local_oob_data = g_array_index(out_param,
46                         bt_oob_data_t, 0);
47         }
48
49         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
50
51         return result;
52 }
53
54 BT_EXPORT_API int bluetooth_oob_add_remote_data(
55                         const bluetooth_device_address_t *remote_device_address,
56                         bt_oob_data_t *remote_oob_data)
57 {
58         int result;
59
60         BT_CHECK_PARAMETER(remote_device_address, return);
61         BT_CHECK_PARAMETER(remote_oob_data, return);
62         BT_CHECK_ENABLED(return);
63
64         BT_INIT_PARAMS();
65         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
66
67         g_array_append_vals(in_param1, remote_device_address,
68                                 sizeof(bluetooth_device_address_t));
69
70         g_array_append_vals(in_param2, remote_oob_data, sizeof(bt_oob_data_t));
71
72         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_OOB_ADD_REMOTE_DATA,
73                 in_param1, in_param2, in_param3, in_param4, &out_param);
74
75         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
76
77         return result;
78 }
79
80 BT_EXPORT_API int bluetooth_oob_remove_remote_data(
81                         const bluetooth_device_address_t *remote_device_address)
82 {
83         int result;
84
85         BT_CHECK_PARAMETER(remote_device_address, return);
86         BT_CHECK_ENABLED(return);
87
88         BT_INIT_PARAMS();
89         BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
90
91         g_array_append_vals(in_param1, remote_device_address,
92                                 sizeof(bluetooth_device_address_t));
93
94         result = _bt_send_request(BT_BLUEZ_SERVICE, BT_OOB_REMOVE_REMOTE_DATA,
95                 in_param1, in_param2, in_param3, in_param4, &out_param);
96
97         BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
98
99         return result;
100 }
101