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-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 BT_SERVICE_AGENT_H
25 #define BT_SERVICE_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 #include <unistd.h>
33 #include <dlog.h>
34
35 #include <stdio.h>
36
37 #include <dbus/dbus-glib.h>
38
39 #undef LOG_TAG
40 #define LOG_TAG "BLUETOOTH_FRWK_SERVICE"
41 #define ERR(fmt, args...) SLOGE(fmt, ##args)
42
43 #define BT_AGENT_PADDING_SIZE 4096
44 #define BT_MAX_SERVICES_FOR_DEVICE      20     /**< This specifies maximum number of services a
45                                                 device can support */
46 #define BT_MAX_EVENT_STR_LENGTH 50
47 #define BT_AGENT_ADDR_SIZE      18
48
49 /* Define Error type */
50 #define BT_AGENT_FAIL -1
51 #define BT_AGENT_ERROR_NONE 0
52
53 #ifndef TIZEN_WEARABLE
54 #define BT_FILE_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time"
55 #endif
56
57 typedef enum {
58         HS_PROFILE_UUID = ((unsigned short)0x1108),             /**<HS*/
59         AUDIO_SOURCE_UUID = ((unsigned short)0x110A),           /**<AUDIO SOURCE*/
60         AUDIO_SINK_UUID = ((unsigned short)0x110B),             /**<AUDIO SINK*/
61         AV_REMOTE_CONTROL_TARGET_UUID = ((unsigned short)0x110C),/**<AV REMOTE CONTROL TARGET*/
62         ADVANCED_AUDIO_PROFILE_UUID = ((unsigned short)0x110D), /**<A2DP*/
63         AV_REMOTE_CONTROL_UUID = ((unsigned short)0x110E),      /**<AV REMOTE CONTROL UUID*/
64         HF_PROFILE_UUID = ((unsigned short)0x111E),             /**<HF*/
65 } bt_agent_service_uuid_list_t;
66
67 typedef enum {
68         BT_AGENT_EVENT_PIN_REQUEST = 0x0001,
69         BT_AGENT_EVENT_PASSKEY_CONFIRM_REQUEST = 0x0002,
70         BT_AGENT_EVENT_PASSKEY_REQUEST = 0x0004,
71         BT_AGENT_EVENT_PASSKEY_DISPLAY_REQUEST = 0x0008,
72         BT_AGENT_EVENT_AUTHORIZE_REQUEST = 0x0010,
73         BT_AGENT_EVENT_CONFIRM_MODE_REQUEST = 0x0020,
74         BT_AGENT_EVENT_APP_CONFIRM_REQUEST = 0x0040,
75         BT_AGENT_EVENT_FILE_RECEIVED = 0x0080,
76         BT_AGENT_EVENT_KEYBOARD_PASSKEY_REQUEST = 0x0100,
77         BT_AGENT_EVENT_SECURITY = 0x0200,
78         BT_AGENT_EVENT_TERMINATE = 0x0400,
79         BT_AGENT_EVENT_EXCHANGE_REQUEST = 0x0800,
80         BT_AGENT_EVENT_PBAP_REQUEST = 0x1000,
81         BT_AGENT_EVENT_MAP_REQUEST = 0x2000,
82         BT_AGENT_EVENT_SYSTEM_RESET_REQUEST = 0x4000,
83         BT_AGENT_EVENT_LEGACY_PAIR_FAILED_FROM_REMOTE = 0x8000,
84 } bt_agent_event_type_t;
85
86 typedef enum {
87         BT_AGENT_CHANGED_MODE_ENABLE,
88         BT_AGENT_CHANGED_MODE_DISABLE,
89 } bt_agent_changed_mode_type_t;
90
91 typedef enum {
92         BT_AGENT_RUN_STATUS_NO_CHANGE = 0x00,   /* No Change BT status*/
93         BT_AGENT_RUN_STATUS_ACTIVATE = 0x01,    /* BT Activate*/
94         BT_AGENT_RUN_STATUS_DEACTIVATE = 0x02,  /* BT Deactivate*/
95         BT_AGENT_RUN_STATUS_SEARCH_TEST = 0x03, /* BT Search Test*/
96         BT_AGENT_RUN_STATUS_TERMINATE = 0x04,   /* BT Terminate*/
97         BT_AGENT_RUN_STATUS_MAX = 0x05, /* Max val*/
98 } bt_agent_run_status_t;
99
100 typedef enum {
101         BT_AGENT_ON_CURRENTVIEW = 0x00, /* Run BT on current view*/
102         BT_AGENT_ON_FOREGROUND = 0x01,  /* Run BT on foreground*/
103         BT_AGENT_ON_BACKGROUND = 0x02,  /* Run BT on background*/
104 } bt_agent_on_t;
105
106 typedef enum {
107         BT_AGENT_OBEX_SERVER = 0x00,
108         BT_AGENT_RFCOMM_SERVER = 0x01,
109 } bt_agent_osp_server_type_t;
110
111 typedef struct {
112         int type;
113         char *uuid;
114         char *path;
115         int fd;
116 } bt_agent_osp_server_t;
117
118 typedef struct {
119         unsigned int service_list_array[BT_MAX_SERVICES_FOR_DEVICE];
120         int service_index;
121 } bt_agent_sdp_info_t;
122
123 void* _bt_create_agent(const char *path, gboolean adapter);
124
125 void _bt_destroy_agent(void *agent);
126
127 gboolean _bt_agent_is_canceled(void);
128 void _bt_agent_set_canceled(gboolean value);
129
130 gboolean _bt_agent_register_osp_server(const gint type,
131                 const char *uuid, char *path, int fd);
132
133 gboolean _bt_agent_unregister_osp_server(const gint type, const char *uuid);
134
135 gboolean _bt_agent_reply_authorize(gboolean accept);
136
137 int _bt_agent_reply_cancellation(void);
138
139 int _bt_launch_system_popup(bt_agent_event_type_t event_type,
140                                                         const char *device_name,
141                                                         char *passkey,
142                                                         const char *filename,
143                                                         const char *agent_path);
144 #endif