4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #ifndef __DEF_BT_HID_AGENT_H_
21 #define __DEF_BT_HID_AGENT_H_
22 #define FUNCTION_TRACE
27 #include <sys/socket.h>
29 #include <gio/gunixfdlist.h>
33 #define LOG_TAG "BLUETOOTH_HID_AGENT"
35 #define LOG_COLOR_RESET "\033[0m"
36 #define LOG_COLOR_RED "\033[31m"
37 #define LOG_COLOR_YELLOW "\033[33m"
38 #define LOG_COLOR_GREEN "\033[32m"
39 #define LOG_COLOR_BLUE "\033[36m"
40 #define LOG_COLOR_PURPLE "\033[35m"
42 #define DBG(fmt, args...) SLOGD(fmt, ##args)
43 #define INFO(fmt, args...) SLOGI(fmt, ##args)
44 #define ERR(fmt, args...) SLOGE(fmt, ##args)
45 #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
46 #define INFO_SECURE(fmt, args...) SECURE_SLOGI(fmt, ##args)
47 #define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args)
48 #define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args)
49 #define INFO_C(fmt, arg...) \
50 SLOGI_IF(TRUE, LOG_COLOR_BLUE" "fmt" "LOG_COLOR_RESET, ##arg)
51 #define ERR_C(fmt, arg...) \
52 SLOGI_IF(TRUE, LOG_COLOR_RED" "fmt" "LOG_COLOR_RESET, ##arg)
55 #define FN_START DBG("[ENTER FUNC]")
56 #define FN_END DBG("[EXIT FUNC]")
62 #define BT_HID_SERVICE_NAME "org.bluez.hid_agent"
63 #define BT_HID_AGENT_OBJECT_PATH "/org/bluez/hid_agent"
64 #define BT_HID_SERVICE_INTERFACE "org.tizen.HidApp"
65 #define BT_HID_AGENT_ERROR (__bt_hid_agent_error_quark())
67 #define BT_HID_BLUEZ_OBJECT_PATH "/org/tizen/hid"
68 #define BT_HID_BLUEZ_INTERFACE "org.bluez.HidAgent"
70 #define BLUEZ_SERVICE_NAME "org.bluez"
71 #define BLUEZ_HID_INTERFACE_NAME "org.bluez.hid_device"
73 #define BLUEZ_PROFILE_MGMT_INTERFACE "org.bluez.ProfileManager1"
74 #define BT_MANAGER_INTERFACE "org.freedesktop.DBus.ObjectManager"
75 #define BT_ADAPTER_INTERFACE "org.bluez.Adapter1"
77 #define BT_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
78 #define BLUEZ_MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1"
79 #define BLUEZ_MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1"
80 #define BLUEZ_DEVICE_INTERFACE "org.bluez.Device1"
81 #define A2DP_SOURCE_ENDPOINT "/MediaEndpoint/A2DPSource"
83 #define BT_ADDRESS_STRING_SIZE 18
84 #define BT_ADAPTER_OBJECT_PATH_MAX 50
85 #define BT_HID_DATA_BUF_SIZE 1024
87 #define BT_ERROR_INTERNAL "InternalError"
88 #define BT_ERROR_NOT_AVAILABLE "NotAvailable"
89 #define BT_ERROR_NOT_CONNECTED "NotConnected"
90 #define BT_ERROR_NOT_CONNECTION_FAILED "ConnectionFailed"
91 #define BT_ERROR_BUSY "InProgress"
92 #define BT_ERROR_INVALID_PARAM "InvalidArguments"
93 #define BT_ERROR_ALREADY_EXIST "AlreadyExists"
94 #define BT_ERROR_ALREADY_CONNECTED "Already Connected"
95 #define BT_ERROR_NO_MEMORY "No memory"
96 #define BT_ERROR_NO_DATA "No data"
97 #define BT_ERROR_I_O_ERROR "I/O error"
98 #define BT_ERROR_OPERATION_NOT_AVAILABLE "Operation currently not available"
99 #define BT_ERROR_OPERATION_NOT_ALLOWED "Operation not allowed"
100 #define BT_ERROR_OPERATION_NOT_SUPPORTED "Operation not supported"
101 #define BT_ERROR_INVALID_FILE_DESCRIPTOR "Invalid File Descriptor"
103 #define ret_if(expr) \
106 ERR("(%s) return", #expr); \
112 BT_HID_AGENT_ERROR_NONE,
113 BT_HID_AGENT_ERROR_INTERNAL,
114 BT_HID_AGENT_ERROR_NOT_AVAILABLE,
115 BT_HID_AGENT_ERROR_NOT_CONNECTED,
116 BT_HID_AGENT_ERROR_CONNECTION_FAILED,
117 BT_HID_AGENT_ERROR_BUSY,
118 BT_HID_AGENT_ERROR_INVALID_PARAM,
119 BT_HID_AGENT_ERROR_ALREADY_EXIST,
120 BT_HID_AGENT_ERROR_ALREADY_CONNECTED,
121 BT_HID_AGENT_ERROR_NO_MEMORY,
122 BT_HID_AGENT_ERROR_NO_DATA,
123 BT_HID_AGENT_ERROR_I_O_ERROR,
124 BT_HID_AGENT_ERROR_APPLICATION,
125 BT_HID_AGENT_ERROR_NOT_ALLOWED,
126 BT_HID_AGENT_ERROR_NOT_SUPPORTED,
127 BT_HID_AGENT_ERROR_INVALID_FILE_DESCRIPTOR,
128 } bt_hid_agent_error_t;
131 BT_HID_STATE_UNAVAILABLE,
132 BT_HID_STATE_DISCONNECTED,
133 BT_HID_STATE_CONNECTING,
134 BT_HID_STATE_CONNECTED,
135 BT_HID_STATE_DISCONNECTING,
140 char remote_addr[BT_ADDRESS_STRING_SIZE];
142 GDBusMethodInvocation *context;
144 } bt_hid_agent_info_t;
148 } __attribute__((packed)) bdaddr_t;
150 /* Remote socket address */
151 struct sockaddr_remote {
153 bdaddr_t remote_bdaddr;
157 void _bt_hid_set_profile_state(bt_hid_state_t new_state);
158 bt_hid_agent_error_t _bt_hid_register_application(gboolean register_flag,
159 const char *sender_name);
161 bt_hid_agent_error_t __bt_hid_disconnect_profile(void);
163 #endif /* __DEF_BT_HID_AGENT_H_ */