edb21bcc8a67555d4a8c54ce03e4976408960fa2
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / include / bt-service-gap-agent.h
1 /*
2  * bluetooth-frwk
3  *
4  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *              http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef SC_CORE_AGENT_H
21 #define SC_CORE_AGENT_H
22
23 #include <stdint.h>
24 #include <glib.h>
25 #include <dbus/dbus-glib.h>
26 #include <dbus/dbus-glib-lowlevel.h>
27
28 #define BLUEZ_DEVICE_INTERFACE  "org.bluez.Device"
29
30 #define GAP_TYPE_AGENT (gap_agent_get_type())
31 #define GAP_GET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GAP_TYPE_AGENT, GapAgent))
32 #define GAP_IS_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GAP_TYPE_AGENT))
33
34 #define GAP_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), GAP_TYPE_AGENT, \
35                                                                                 GapAgentClass))
36 #define GAP_GET_AGENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GAP_TYPE_AGENT, \
37                                                                                 GapAgentClass))
38 #define GAP_IS_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), GAP_TYPE_AGENT))
39
40 #define GAP_AGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GAP_TYPE_AGENT, \
41                                                                         GapAgentPrivate))
42
43 typedef struct _GapAgent GapAgent;
44 typedef struct _GapAgentClass GapAgentClass;
45
46 typedef gboolean(*GapAgentPasskeyFunc) (GapAgent *agent,
47                                                         DBusGProxy *device);
48 typedef gboolean(*GapAgentDisplayFunc) (GapAgent *agent, DBusGProxy *device,
49                                                                 guint passkey);
50 typedef gboolean(*GapAgentConfirmFunc) (GapAgent *agent, DBusGProxy *device,
51                                                                 guint passkey);
52 typedef gboolean(*GapAgentAuthorizeFunc) (GapAgent *agent,
53                                                 DBusGProxy *device,
54                                                 const char *uuid);
55 typedef gboolean(*GapAgentConfirmModeFunc) (GapAgent *agent,
56                                         const char *mode, const char *sender,
57                                         gboolean need_popup, void *data);
58 typedef gboolean(*GapAgentCancelFunc) (GapAgent *agent,
59                                                         const char *address);
60 typedef gboolean(*GapAgentIgnoreAutoPairingFunc) (const char *address);
61 typedef uint8_t bool_t;
62
63 typedef struct {
64         GapAgentPasskeyFunc pincode_func;
65         GapAgentDisplayFunc display_func;
66         GapAgentPasskeyFunc passkey_func;
67         GapAgentConfirmFunc confirm_func;
68         GapAgentAuthorizeFunc authorize_func;
69         GapAgentCancelFunc pairing_cancel_func;
70         GapAgentCancelFunc authorization_cancel_func;
71 } GAP_AGENT_FUNC_CB;
72
73 typedef enum {
74         GAP_AGENT_ACCEPT,
75         GAP_AGENT_REJECT,
76         GAP_AGENT_CANCEL,
77         GAP_AGENT_TIMEOUT,
78 } GAP_AGENT_ACCEPT_TYPE_T;
79
80 struct _GapAgent {
81         GObject parent;
82 };
83
84 struct _GapAgentClass {
85         GObjectClass parent_class;
86 };
87
88 GapAgent *_gap_agent_new(void);
89 void _gap_agent_setup_dbus(GapAgent *agent, GAP_AGENT_FUNC_CB *func_cb,
90                                         const char *path);
91 gboolean _gap_agent_register(GapAgent *agent);
92 void _gap_agent_reset_dbus(GapAgent *agent);
93
94 gboolean gap_agent_reply_pin_code(GapAgent *agent, const guint accept,
95                                                 const char *pin_code,
96                                                 DBusGMethodInvocation *context);
97 gboolean gap_agent_reply_passkey(GapAgent *agent, const guint accept,
98                                                 const char *passkey,
99                                                 DBusGMethodInvocation *context);
100 gboolean gap_agent_reply_confirmation(GapAgent *agent, const guint accept,
101                                           DBusGMethodInvocation *context);
102 gboolean gap_agent_reply_authorize(GapAgent *agent, const guint accept,
103                                        DBusGMethodInvocation *context);
104
105 gboolean _gap_agent_exist_osp_server(GapAgent *agent, int type, char *uuid);
106
107 gchar* _gap_agent_get_path(GapAgent *agent);
108
109 gboolean _gap_agent_is_canceled(GapAgent *agent);
110
111 gboolean _gap_agent_register_osp_server(GapAgent *agent,
112                                                 const gint type,
113                                                 const char *uuid);
114
115 gboolean _gap_agent_unregister_osp_server(GapAgent *agent,
116                                                 const gint type,
117                                                 const char *uuid);
118
119 #endif