Code Sync [Tizen3.0]: Merged the tizen_2.4 Spin code to tizen.org
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / include / bt-service-gap-agent.h
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 #ifndef SC_CORE_AGENT_H
25 #define SC_CORE_AGENT_H
26
27 #include <stdint.h>
28 #include <glib.h>
29 #include <dbus/dbus-glib.h>
30 #include <dbus/dbus-glib-lowlevel.h>
31
32 #define BLUEZ_DEVICE_INTERFACE  "org.bluez.Device"
33
34 #define GAP_TYPE_AGENT (gap_agent_get_type())
35 #define GAP_GET_AGENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GAP_TYPE_AGENT, GapAgent))
36 #define GAP_IS_AGENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GAP_TYPE_AGENT))
37
38 #define GAP_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), GAP_TYPE_AGENT, \
39                                                                                 GapAgentClass))
40 #define GAP_GET_AGENT_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GAP_TYPE_AGENT, \
41                                                                                 GapAgentClass))
42 #define GAP_IS_AGENT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), GAP_TYPE_AGENT))
43
44 #define GAP_AGENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GAP_TYPE_AGENT, \
45                                                                         GapAgentPrivate))
46
47 typedef struct _GapAgent GapAgent;
48 typedef struct _GapAgentClass GapAgentClass;
49
50 typedef gboolean(*GapAgentPasskeyFunc) (GapAgent *agent,
51                                                         DBusGProxy *device);
52 typedef gboolean(*GapAgentDisplayFunc) (GapAgent *agent, DBusGProxy *device,
53                                                                 guint passkey);
54 typedef gboolean(*GapAgentConfirmFunc) (GapAgent *agent, DBusGProxy *device,
55                                                                 guint passkey);
56 typedef gboolean(*GapAgentAuthorizeFunc) (GapAgent *agent,
57                                                 DBusGProxy *device,
58                                                 const char *uuid);
59 typedef gboolean(*GapAgentConfirmModeFunc) (GapAgent *agent,
60                                         const char *mode, const char *sender,
61                                         gboolean need_popup, void *data);
62 typedef gboolean(*GapAgentCancelFunc) (GapAgent *agent,
63                                                         const char *address);
64 typedef gboolean(*GapAgentIgnoreAutoPairingFunc) (const char *address);
65 typedef uint8_t bool_t;
66
67 typedef struct {
68         GapAgentPasskeyFunc pincode_func;
69         GapAgentDisplayFunc display_func;
70         GapAgentPasskeyFunc passkey_func;
71         GapAgentConfirmFunc confirm_func;
72         GapAgentAuthorizeFunc authorize_func;
73         GapAgentCancelFunc pairing_cancel_func;
74         GapAgentCancelFunc authorization_cancel_func;
75 } GAP_AGENT_FUNC_CB;
76
77 typedef enum {
78         GAP_AGENT_ACCEPT,
79         GAP_AGENT_REJECT,
80         GAP_AGENT_CANCEL,
81         GAP_AGENT_TIMEOUT,
82         GAP_AGENT_ACCEPT_ALWAYS,
83 } GAP_AGENT_ACCEPT_TYPE_T;
84
85 struct _GapAgent {
86         GObject parent;
87 };
88
89 struct _GapAgentClass {
90         GObjectClass parent_class;
91 };
92
93 GapAgent *_gap_agent_new(void);
94 void _gap_agent_setup_dbus(GapAgent *agent, GAP_AGENT_FUNC_CB *func_cb,
95                                         const char *path, DBusGProxy *adapter);
96 gboolean _gap_agent_register(GapAgent *agent);
97 void _gap_agent_reset_dbus(GapAgent *agent);
98
99 gboolean gap_agent_reply_pin_code(GapAgent *agent, const guint accept,
100                                                 const char *pin_code,
101                                                 DBusGMethodInvocation *context);
102 gboolean gap_agent_reply_passkey(GapAgent *agent, const guint accept,
103                                                 const char *passkey,
104                                                 DBusGMethodInvocation *context);
105 gboolean gap_agent_reply_confirmation(GapAgent *agent, const guint accept,
106                                           DBusGMethodInvocation *context);
107 gboolean gap_agent_reply_authorize(GapAgent *agent, const guint accept,
108                                        DBusGMethodInvocation *context);
109
110 gboolean _gap_agent_exist_osp_server(GapAgent *agent, int type, char *uuid);
111
112 bt_agent_osp_server_t *_gap_agent_get_osp_server(GapAgent *agent, int type,
113                                         char *uuid);
114
115 gchar* _gap_agent_get_path(GapAgent *agent);
116
117 gboolean _gap_agent_is_canceled(GapAgent *agent);
118
119 void _gap_agent_set_canceled(GapAgent *agent, gboolean value);
120
121 gboolean _gap_agent_register_osp_server(GapAgent *agent,
122                                                 const gint type,
123                                                 const char *uuid,
124                                                 const char *path,
125                                                 int fd);
126
127 gboolean _gap_agent_unregister_osp_server(GapAgent *agent,
128                                                 const gint type,
129                                                 const char *uuid);
130
131 #endif