4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hocheol Seo <hocheol.seo@samsung.com>
7 * Girishashok Joshi <girish.joshi@samsung.com>
8 * Chanyeol Park <chanyeol.park@samsung.com>
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
14 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #ifndef _BLUETOOTH_API_COMMON_H_
26 #define _BLUETOOTH_API_COMMON_H_
32 #include <sys/types.h>
34 #include <dbus/dbus-glib-lowlevel.h>
35 #include <dbus/dbus-glib.h>
36 #include <dbus/dbus.h>
40 #include <vconf-keys.h>
42 #include "bluetooth-api.h"
44 #define BT_FRWK "BT_FRWK"
47 #define BT_EXPORT_API __attribute__((visibility("default")))
50 #define PRT(level, fmt, function, args...) \
51 SLOG(LOG_DEBUG, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
52 #define DBG(fmt, args...) \
53 SLOG(LOG_DEBUG, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
54 #define ERR(fmt, args...) \
55 SLOG(LOG_ERROR, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
56 #define AST(fmt, args...) \
57 SLOG(LOG_ERROR, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
59 #define BT_STORE_PREFIX "db/bluetooth/"
60 #define BT_STORE_VISIBILITY_PATH BT_STORE_PREFIX"visibility"
61 #define BT_STORE_VISIBILITY_TIME_PATH BT_STORE_PREFIX"visibility_time"
62 #define BT_MEMORY_KEY_RESTRICTION "memory/bluetooth/restriction"
63 #define BT_SETTING_DEVICE_NAME "db/setting/device_name"
65 #define BT_SYSPOPUP_NAME "bt-syspopup"
66 #define BT_SECURITY_EVENT "bt-security"
67 #define BT_SECURITY_DISABLED "disabled"
69 #define BLUEZ_NAME "org.bluez"
70 #define BLUEZ_ADAPTER_NAME "org.bluez.Adapter"
72 #define HCI_SCAN_ENABLE_NO_SCAN 0x00
73 #define HCI_SCAN_ENABLE_INQUIRY_ONLY 0x01
74 #define HCI_SCAN_ENABLE_PAGE_ONLY 0x02
75 #define HCI_SCAN_ENABLE_PAGE_AND_INQUIRY 0x03
77 #define BT_ADDRESS_STRING_SIZE 18
78 #define BT_128_UUID_LEN 36
79 #define BT_ADAPTER_OBJECT_PATH_MAX 50
81 #define RFKILL_NODE "/dev/rfkill"
83 #define BLUETOOTH_UUID_POSTFIX "0000-1000-8000-00805f9b34fb"
85 #define RFKILL_EVENT_SIZE 8
87 #define BT_PHONE_NUM_LEN 50
88 #define BT_FILE_BUFFER_MAX 256
98 BT_STORE_DISCOVERABLE_MODE,
105 RFKILL_TYPE_BLUETOOTH,
124 unsigned short match_uuid16;
125 const char *match_name;
126 unsigned int match_handle;
130 match_entries_t *search_match_ptr;
131 bluetooth_device_address_t remote_device_addr;
132 int success_search_index;
133 } bt_info_for_searching_support_service_t;
137 * This structure has information about BT
141 pid_t application_pid; /**< Application process id */
142 bluetooth_cb_func_ptr bt_cb_ptr; /**< Function pointer for
143 responsing event to application */
145 DBusGConnection *conn; /**< DBUS bus connection for bluez ipc */
146 DBusConnection *sys_conn;
147 DBusGProxy *dbus_proxy; /**< DBUS proxy */
148 DBusGProxy *manager_proxy; /**< bluez manager ipc proxy */
149 DBusGProxy *adapter_proxy; /**< bluez adapter ipc proxy */
150 DBusGProxy *agent_proxy; /**< Agent ipc proxy */
151 DBusGProxy *network_server_proxy;
152 char adapter_path[BT_ADAPTER_OBJECT_PATH_MAX]; /*bluez adapter path*/
153 GList *device_proxy_list; /**< bluez device ipc proxy list */
155 bluetooth_adapter_state_t bt_adapter_state; /*Current bluetooth state*/
156 guint bt_change_state_timer; /**< g_timeout for checking timeout
157 of BT status change */
158 bluetooth_device_name_t bt_local_name; /*Local bluetooth device name*/
160 guint bt_discovery_req_timer; /**< g_timeout for checking timeout of
161 BT discovery request */
162 gboolean is_discovery_req; /**< application request discovery or not*/
163 gboolean is_discovering; /**< Currently discovery state */
164 gboolean is_discovery_cancel; /**< discovery cancel is requested */
166 guint bt_bonding_req_timer; /**< g_timeout for checking timeout of
167 BT discovery request */
168 gboolean is_bonding_req; /*application request bonding or not*/
169 gboolean is_headset_bonding;
170 char bt_bonding_req_addrstr[BT_ADDRESS_STRING_SIZE]; /**< bluetooth device address which
171 currently bonding is requested to */
172 gboolean is_headset_pin_req; /*application request bonding or not*/
173 bt_info_for_searching_support_service_t info_for_searching_support_service; /**< Service
174 Seaching Session Infomation */
176 gboolean is_service_req; /**< Request to discover device services */
181 bt_info_t *_bluetooth_internal_get_information(void);
182 void _bluetooth_internal_event_cb(int event, int result, void *param_data);
184 void _bluetooth_internal_session_init(void);
186 bool _bluetooth_internal_is_adapter_enabled(void);
188 DBusGProxy *_bluetooth_internal_find_device_by_path(const char *dev_path);
189 DBusGProxy *_bluetooth_internal_add_device(const char *path);
191 void _bluetooth_change_uuids_to_sdp_info(GValue *value, bt_sdp_info_t *sdp_data);
193 void _bluetooth_internal_print_bluetooth_device_address_t(const bluetooth_device_address_t *addr);
194 void _bluetooth_internal_convert_addr_string_to_addr_type(bluetooth_device_address_t *addr,
195 const char *address);
196 void _bluetooth_internal_addr_type_to_addr_string(char *address,
197 const bluetooth_device_address_t *addr);
198 void _bluetooth_internal_divide_device_class(bluetooth_device_class_t *device_class,
200 void _bluetooth_internal_device_path_to_address(const char *device_path,
201 char *device_address);
203 int _bluetooth_internal_get_value(bt_store_key_t key);
204 int _bluetooth_internal_set_value(bt_store_key_t key);
206 int _bluetooth_get_default_adapter_name(bluetooth_device_name_t *dev_name, int size);
208 int _bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path);
213 #endif /* __cplusplus */
217 #endif /* __cplusplus */
218 #endif /*_BLUETOOTH_API_COMMON_H_*/