Mesh: added message response on Node Role
[platform/core/connectivity/bluetooth-frwk.git] / bt-api / include / bt-request-sender.h
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 #ifndef _BT_REQUEST_SENDER_H_
19 #define _BT_REQUEST_SENDER_H_
20
21 #include <sys/types.h>
22 #include <glib.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 typedef struct {
29         int service_function;
30         void *cb;
31         void *user_data;
32 } bt_req_info_t;
33
34 int _bt_sync_send_request(int service_type, int service_function,
35                         GArray *in_param1, GArray *in_param2,
36                         GArray *in_param3, GArray *in_param4,
37                         GArray **out_param1);
38
39 /* The caller of this should pass #define macro/enum types as the first two params */
40 #define _bt_send_request(a, b, format ...) ( \
41         { \
42         if ((a != BT_CHECK_PRIVILEGE && (a == BT_BLUEZ_SERVICE || a == BT_OBEX_SERVICE)) && \
43                 (b != BT_GET_LOCAL_NAME && b != BT_GET_LOCAL_ADDRESS && \
44                  b != BT_GET_BONDED_DEVICE && b != BT_IS_DEVICE_CONNECTED && \
45                  b != BT_RFCOMM_SEND_RX_DETAILS && b != BT_RFCOMM_SEND_TX_DETAILS && \
46                  b != BT_AVRCP_SET_PROPERTY && b != BT_BATTERY_READ_DATA && \
47                  b != BT_GET_BONDED_DEVICES && b != BT_GET_DISCOVERABLE_MODE)) \
48                 BT_INFO_C("Sync Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
49         else \
50                 BT_DBG("Sync Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
51         _bt_sync_send_request(a, b, format); \
52         } \
53         )
54
55 int _bt_async_send_request(int service_type, int service_function,
56                         GArray *in_param1, GArray *in_param2,
57                         GArray *in_param3, GArray *in_param4,
58                         void *callback, void *user_data);
59
60 /* The caller of this should pass #define macro/enum types as the first two params */
61 #define _bt_send_request_async(a, b, format ...) ( \
62         { \
63         if ((a != BT_CHECK_PRIVILEGE && (a == BT_BLUEZ_SERVICE || a == BT_OBEX_SERVICE)) && \
64                 (b != BT_GET_LOCAL_NAME && b != BT_GET_LOCAL_ADDRESS && \
65                  b != BT_GET_BONDED_DEVICE && b != BT_IS_DEVICE_CONNECTED && \
66                  b != BT_GET_BONDED_DEVICES && b != BT_GET_DISCOVERABLE_MODE)) \
67                 BT_INFO_C("Async Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
68         else \
69                 BT_DBG("Async Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
70         _bt_async_send_request(a, b, format); \
71         } \
72         )
73
74 void _bt_gdbus_deinit_proxys(void);
75
76 int _bt_sync_send_request_with_unix_fd_list(
77                 int service_type, int service_function,
78                 GArray *in_param1, GArray *in_param2,
79                 GArray *in_param3, GArray *in_param4,
80                 GUnixFDList *fd_list, GArray **out_param1,
81                 GUnixFDList **out_fd_list);
82 #define _bt_send_request_with_unix_fd_list(a, b, format ...) ( \
83         { \
84         BT_INFO_C("Sync Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
85         _bt_sync_send_request_with_unix_fd_list(a, b, format); \
86         } \
87         )
88
89 int _bt_async_send_request_with_unix_fd_list(int service_type, int service_function,
90                         GArray *in_param1, GArray *in_param2,
91                         GArray *in_param3, GArray *in_param4,
92                         void *callback, void *user_data,
93                         GUnixFDList *fd_list, GAsyncReadyCallback __async_req_cb);
94 #define _bt_send_request_async_with_unix_fd_list(a, b, format ...) ( \
95         { \
96         BT_INFO_C("Async Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
97         _bt_async_send_request_with_unix_fd_list(a, b, format); \
98         } \
99         )
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif /* _BT_REQUEST_SENDER_H_ */