resolved the code rule warnings
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-gap-agent.h
1 /*
2  * BLUETOOTH HAL
3  *
4  * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:  Anupam Roy <anupam.r@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __BT_HAL_GAP_AGENT_H__
23 #define _BT_HAL_GAP_AGENT_H__
24
25 #include <stdint.h>
26 #include <glib.h>
27 #include <gio/gio.h>
28
29 #ifdef TIZEN_BT_HAL
30 typedef struct {
31         unsigned int type;
32         /* TODO: Add more elements If and when required */
33 } bt_hal_agent_osp_server_t;
34 #endif
35
36 typedef enum {
37         GAP_AGENT_EXEC_NO_OPERATION,
38         GAP_AGENT_EXEC_PAIRING,
39         GAP_AGENT_EXEC_AUTHORZATION,
40         GAP_AGENT_EXEC_CONFIRM_MODE,
41 } GapAgentExecType;
42
43 typedef struct _GapAgentPrivate GapAgentPrivate;
44
45 typedef gboolean(*GapAgentPasskeyFunc) (GapAgentPrivate *agent,
46                 GDBusProxy *device);
47 typedef gboolean(*GapAgentDisplayFunc) (GapAgentPrivate *agent, GDBusProxy *device,
48                 guint passkey);
49 typedef gboolean(*GapAgentConfirmFunc) (GapAgentPrivate *agent, GDBusProxy *device,
50                 guint passkey);
51 typedef gboolean(*GapAgentAuthorizeFunc) (GapAgentPrivate *agent,
52                 GDBusProxy *device, const char *uuid);
53 typedef gboolean(*GapAgentConfirmModeFunc) (GapAgentPrivate *agent,
54                 const char *mode, const char *sender,
55                 gboolean need_popup, void *data);
56 typedef gboolean(*GapAgentCancelFunc) (GapAgentPrivate *agent,
57                 const char *address);
58
59 typedef uint8_t bool_t;
60
61 typedef struct {
62         GapAgentPasskeyFunc pincode_func;
63         GapAgentDisplayFunc display_func;
64         GapAgentPasskeyFunc passkey_func;
65         GapAgentConfirmFunc confirm_func;
66         GapAgentAuthorizeFunc authorize_func;
67         GapAgentCancelFunc pairing_cancel_func;
68         GapAgentCancelFunc authorization_cancel_func;
69 } GAP_AGENT_FUNC_CB;
70
71 typedef enum {
72         GAP_AGENT_ACCEPT,
73         GAP_AGENT_REJECT,
74         GAP_AGENT_CANCEL,
75         GAP_AGENT_TIMEOUT,
76         GAP_AGENT_ACCEPT_ALWAYS,
77 } GAP_AGENT_ACCEPT_TYPE_T;
78
79 struct _GapAgentPrivate {
80         gchar *busname;
81         gchar *path;
82         GDBusProxy *adapter;
83         GDBusProxy *agent_manager;
84         GDBusProxy *dbus_proxy;
85         GapAgentExecType exec_type;
86         GDBusMethodInvocation *reply_context;
87
88         char pairing_addr[18];
89         char authorize_addr[18];
90
91         GSList *osp_servers;
92         GAP_AGENT_FUNC_CB cb;
93         gboolean canceled;
94 };
95
96 void _gap_agent_setup_dbus(GapAgentPrivate *agent, GAP_AGENT_FUNC_CB *func_cb,
97                 const char *path, GDBusProxy *adapter);
98
99 gboolean _gap_agent_register(GapAgentPrivate *agent);
100
101 void _gap_agent_reset_dbus(GapAgentPrivate *agent);
102
103 gchar* _gap_agent_get_path(GapAgentPrivate *agent);
104
105 gboolean _gap_agent_is_canceled(GapAgentPrivate *agent);
106
107 void _gap_agent_set_canceled(GapAgentPrivate *agent, gboolean value);
108
109 gboolean gap_agent_reply_pin_code(GapAgentPrivate *agent, const guint accept,
110                 const char *pin_code,
111                 GDBusMethodInvocation *context);
112 gboolean gap_agent_reply_passkey(GapAgentPrivate *agent, const guint accept,
113                 const char *passkey,
114                 GDBusMethodInvocation *context);
115 gboolean gap_agent_reply_confirmation(GapAgentPrivate *agent, const guint accept,
116                 GDBusMethodInvocation *context);
117
118 gboolean gap_agent_reply_authorize(GapAgentPrivate *agent, const guint accept,
119                 GDBusMethodInvocation *context);
120
121 #ifdef TIZEN_BT_HAL
122 bt_hal_agent_osp_server_t *_bt_hal_gap_agent_find_osp_server_by_type(GSList *servers, unsigned int type);
123
124 gboolean _bt_hal_gap_agent_register_osp_server(GapAgentPrivate *agent, unsigned int type);
125
126 gboolean _bt_hal_gap_agent_unregister_osp_server(GapAgentPrivate *agent, unsigned int type);
127 #endif
128 #endif //_BT_HAL_GAP_AGENT_H__