Code synchronization with latest tizen 4.0 codes
[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_GET_BONDED_DEVICES && b != BT_GET_DISCOVERABLE_MODE)) \
46                 BT_INFO_C("Sync Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
47         else \
48                 BT_DBG("Sync Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
49         _bt_sync_send_request(a, b, format); \
50         } \
51         )
52
53 int _bt_async_send_request(int service_type, int service_function,
54                         GArray *in_param1, GArray *in_param2,
55                         GArray *in_param3, GArray *in_param4,
56                         void *callback, void *user_data);
57
58 /* The caller of this should pass #define macro/enum types as the first two params */
59 #define _bt_send_request_async(a, b, format ...) ( \
60         { \
61         if ((a != BT_CHECK_PRIVILEGE && (a == BT_BLUEZ_SERVICE || a == BT_OBEX_SERVICE)) && \
62                 (b != BT_GET_LOCAL_NAME && b != BT_GET_LOCAL_ADDRESS && \
63                  b != BT_GET_BONDED_DEVICE && b != BT_IS_DEVICE_CONNECTED && \
64                  b != BT_GET_BONDED_DEVICES && b != BT_GET_DISCOVERABLE_MODE)) \
65                 BT_INFO_C("Async Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
66         else \
67                 BT_DBG("Async Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
68         _bt_async_send_request(a, b, format); \
69         } \
70         )
71
72 void _bt_gdbus_deinit_proxys(void);
73
74 int _bt_sync_send_request_with_unix_fd_list(
75                 int service_type, int service_function,
76                 GArray *in_param1, GArray *in_param2,
77                 GArray *in_param3, GArray *in_param4,
78                 GUnixFDList *fd_list, GArray **out_param1,
79                 GUnixFDList **out_fd_list);
80 #define _bt_send_request_with_unix_fd_list(a, b, format ...) ( \
81         { \
82         BT_INFO_C("Async Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
83         _bt_sync_send_request_with_unix_fd_list(a, b, format); \
84         } \
85         )
86
87 int _bt_async_send_request_with_unix_fd_list(int service_type, int service_function,
88                         GArray *in_param1, GArray *in_param2,
89                         GArray *in_param3, GArray *in_param4,
90                         void *callback, void *user_data,
91                         GUnixFDList *fd_list, GAsyncReadyCallback __async_req_cb);
92 #define _bt_send_request_async_with_unix_fd_list(a, b, format ...) ( \
93         { \
94         BT_INFO_C("Async Request => type=%s, fn=%s(0x%x)", #a, #b, b); \
95         _bt_async_send_request_with_unix_fd_list(a, b, format); \
96         } \
97         )
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif /* _BT_REQUEST_SENDER_H_ */