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>
35 #include <dbus/dbus-glib-lowlevel.h>
36 #include <dbus/dbus-glib.h>
37 #include <dbus/dbus.h>
41 #include <vconf-keys.h>
43 #include "bluetooth-api.h"
45 #define BT_FRWK "BT_FRWK"
48 #define BT_EXPORT_API __attribute__((visibility("default")))
51 #define PRT(level, fmt, function, args...) \
52 SLOG(LOG_DEBUG, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
53 #define DBG(fmt, args...) \
54 SLOG(LOG_DEBUG, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
55 #define ERR(fmt, args...) \
56 SLOG(LOG_ERROR, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
57 #define AST(fmt, args...) \
58 SLOG(LOG_ERROR, BT_FRWK, "%s():%d "fmt, __func__, __LINE__, ##args)
60 #define BT_SETTING_DEVICE_NAME "db/setting/device_name"
61 #define BT_MEMORY_OBEX_NO_AGENT "memory/private/libbluetooth-frwk-0/obex_no_agent"
62 #define BT_MEMORY_RFCOMM_UUID "memory/private/libbluetooth-frwk-0/uuid"
63 #define BT_FILE_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time"
65 #define BLUEZ_SERVICE_NAME "org.bluez"
66 #define BLUEZ_MANAGER_OBJ_PATH "/"
67 #define BLUEZ_MANAGER_INTERFACE "org.bluez.Manager"
69 #define BLUEZ_ADAPTER_INTERFACE "org.bluez.Adapter"
70 #define BLUEZ_DEVICE_INTERFACE "org.bluez.Device"
72 #define BT_AGENT_INTERFACE "User.Bluetooth.agent"
74 #define HCI_SCAN_ENABLE_NO_SCAN 0x00
75 #define HCI_SCAN_ENABLE_INQUIRY_ONLY 0x01
76 #define HCI_SCAN_ENABLE_PAGE_ONLY 0x02
77 #define HCI_SCAN_ENABLE_PAGE_AND_INQUIRY 0x03
79 #define BT_ADDRESS_STRING_SIZE 18
80 #define BT_128_UUID_LEN 36
81 #define BT_ADAPTER_OBJECT_PATH_MAX 50
82 #define BT_DISCOVERY_FINISHED_DELAY 200
84 #define RFKILL_NODE "/dev/rfkill"
86 #define BLUETOOTH_UUID_POSTFIX "0000-1000-8000-00805f9b34fb"
88 #define BT_COMMON_PKG "ug-setting-bluetooth-efl"
90 #define BT_STR_DISABLED_RESTRICTS \
91 dgettext(BT_COMMON_PKG, "IDS_BT_BODY_SECURITY_POLICY_RESTRICTS_USE_OF_BLUETOOTH_CONNECTION")
93 #define BT_STR_HANDS_FREE_RESTRICTS \
94 dgettext(BT_COMMON_PKG, "IDS_BT_BODY_SECURITY_POLICY_RESTRICTS_USE_OF_BLUETOOTH_CONNECTION_TO_HANDS_FREE_FEATURES_ONLY")
96 #define RFKILL_EVENT_SIZE 8
98 #define BT_PHONE_NUM_LEN 50
99 #define BT_FILE_BUFFER_MAX 256
101 #define SLEEP_TIME 50000 /* 50 ms */
102 #define BLOCK_MAX_TIMEOUT 2000000 /* 2 seconds */
112 BT_STORE_DISCOVERABLE_MODE,
119 RFKILL_TYPE_BLUETOOTH,
145 unsigned short match_uuid16;
146 const char *match_name;
147 unsigned int match_handle;
151 match_entries_t *search_match_ptr;
152 bluetooth_device_address_t remote_device_addr;
153 int success_search_index;
154 } bt_info_for_searching_support_service_t;
158 * This structure has information about BT
162 pid_t application_pid; /**< Application process id */
163 bluetooth_cb_func_ptr bt_cb_ptr; /**< Function pointer for
164 responsing event to application */
166 DBusGConnection *conn; /**< DBUS bus connection for bluez ipc */
167 DBusConnection *sys_conn;
168 DBusGProxy *dbus_proxy; /**< DBUS proxy */
169 DBusGProxy *manager_proxy; /**< bluez manager ipc proxy */
170 DBusGProxy *adapter_proxy; /**< bluez adapter ipc proxy */
171 DBusGProxy *agent_proxy; /**< Agent ipc proxy */
172 DBusGProxy *network_server_proxy;
173 DBusGProxy *rfcomm_proxy;
174 char adapter_path[BT_ADAPTER_OBJECT_PATH_MAX]; /*bluez adapter path*/
175 char *connecting_uuid;
176 GList *device_proxy_list; /**< bluez device ipc proxy list */
178 bluetooth_adapter_state_t bt_adapter_state; /*Current bluetooth state*/
179 guint bt_change_state_timer; /**< g_timeout for checking timeout
180 of BT status change */
181 bluetooth_device_name_t bt_local_name; /*Local bluetooth device name*/
183 guint bt_discovery_req_timer; /**< g_timeout for checking timeout of
184 BT discovery request */
185 guint bt_discovery_res_timer;
186 gboolean is_discovery_req; /**< application request discovery or not*/
187 gboolean is_discovering; /**< Currently discovery state */
188 gboolean is_discovery_cancel; /**< discovery cancel is requested */
190 guint bt_bonding_req_timer; /**< g_timeout for checking timeout of
191 BT discovery request */
192 gboolean is_bonding_req; /*application request bonding or not*/
193 gboolean is_headset_bonding;
194 char bt_bonding_req_addrstr[BT_ADDRESS_STRING_SIZE]; /**< bluetooth device address which
195 currently bonding is requested to */
196 gboolean is_headset_pin_req; /*application request bonding or not*/
197 bt_info_for_searching_support_service_t info_for_searching_support_service; /**< Service
198 Seaching Session Infomation */
200 gboolean is_service_req; /**< Request to discover device services */
205 bt_info_t *_bluetooth_internal_get_information(void);
206 void _bluetooth_internal_event_cb(int event, int result, void *param_data);
208 void _bluetooth_internal_session_init(void);
210 bool _bluetooth_internal_is_adapter_enabled(void);
212 DBusGProxy *_bluetooth_internal_find_device_by_path(const char *dev_path);
213 DBusGProxy *_bluetooth_internal_add_device(const char *path);
215 void _bluetooth_change_uuids_to_sdp_info(GValue *value, bt_sdp_info_t *sdp_data);
217 void _bluetooth_internal_print_bluetooth_device_address_t(const bluetooth_device_address_t *addr);
218 void _bluetooth_internal_convert_addr_string_to_addr_type(bluetooth_device_address_t *addr,
219 const char *address);
220 void _bluetooth_internal_addr_type_to_addr_string(char *address,
221 const bluetooth_device_address_t *addr);
222 void _bluetooth_internal_divide_device_class(bluetooth_device_class_t *device_class,
224 void _bluetooth_internal_device_path_to_address(const char *device_path,
225 char *device_address);
227 int _bluetooth_get_default_adapter_name(bluetooth_device_name_t *dev_name, int size);
229 int _bluetooth_internal_get_adapter_path(DBusGConnection *conn, char *path);
231 DBusGProxy *_bluetooth_internal_get_adapter_proxy(DBusGConnection *conn);
235 #endif /* __cplusplus */
239 #endif /* __cplusplus */
240 #endif /*_BLUETOOTH_API_COMMON_H_*/