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 BT_INTERFACES_ADDED "InterfacesAdded"
79 #define BT_INTERFACES_REMOVED "InterfacesRemoved"
80 #define BT_PROPERTY_CHANGED "PropertiesChanged"
82 #define BLUEZ_MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport1"
83 #define BLUEZ_MEDIA_ENDPOINT_INTERFACE "org.bluez.MediaEndpoint1"
84 #define BLUEZ_DEVICE_INTERFACE "org.bluez.Device1"
85 #define A2DP_SOURCE_ENDPOINT "/MediaEndpoint/A2DPSource"
87 #define BT_ADDRESS_STRING_SIZE 18
88 #define BT_ADAPTER_OBJECT_PATH_MAX 50
89 #define BT_HID_DATA_BUF_SIZE 1024
91 #define BT_ERROR_INTERNAL "InternalError"
92 #define BT_ERROR_NOT_AVAILABLE "NotAvailable"
93 #define BT_ERROR_NOT_CONNECTED "NotConnected"
94 #define BT_ERROR_NOT_CONNECTION_FAILED "ConnectionFailed"
95 #define BT_ERROR_BUSY "InProgress"
96 #define BT_ERROR_INVALID_PARAM "InvalidArguments"
97 #define BT_ERROR_ALREADY_EXIST "AlreadyExists"
98 #define BT_ERROR_ALREADY_CONNECTED "Already Connected"
99 #define BT_ERROR_NO_MEMORY "No memory"
100 #define BT_ERROR_NO_DATA "No data"
101 #define BT_ERROR_I_O_ERROR "I/O error"
102 #define BT_ERROR_OPERATION_NOT_AVAILABLE "Operation currently not available"
103 #define BT_ERROR_OPERATION_NOT_ALLOWED "Operation not allowed"
104 #define BT_ERROR_OPERATION_NOT_SUPPORTED "Operation not supported"
105 #define BT_ERROR_INVALID_FILE_DESCRIPTOR "Invalid File Descriptor"
107 #define ret_if(expr) \
110 ERR("(%s) return", #expr); \
116 BT_HID_AGENT_ERROR_NONE,
117 BT_HID_AGENT_ERROR_INTERNAL,
118 BT_HID_AGENT_ERROR_NOT_AVAILABLE,
119 BT_HID_AGENT_ERROR_NOT_CONNECTED,
120 BT_HID_AGENT_ERROR_CONNECTION_FAILED,
121 BT_HID_AGENT_ERROR_BUSY,
122 BT_HID_AGENT_ERROR_INVALID_PARAM,
123 BT_HID_AGENT_ERROR_ALREADY_EXIST,
124 BT_HID_AGENT_ERROR_ALREADY_CONNECTED,
125 BT_HID_AGENT_ERROR_NO_MEMORY,
126 BT_HID_AGENT_ERROR_NO_DATA,
127 BT_HID_AGENT_ERROR_I_O_ERROR,
128 BT_HID_AGENT_ERROR_APPLICATION,
129 BT_HID_AGENT_ERROR_NOT_ALLOWED,
130 BT_HID_AGENT_ERROR_NOT_SUPPORTED,
131 BT_HID_AGENT_ERROR_INVALID_FILE_DESCRIPTOR,
132 } bt_hid_agent_error_t;
135 BT_HID_STATE_UNAVAILABLE,
136 BT_HID_STATE_DISCONNECTED,
137 BT_HID_STATE_CONNECTING,
138 BT_HID_STATE_CONNECTED,
139 BT_HID_STATE_DISCONNECTING,
144 char remote_addr[BT_ADDRESS_STRING_SIZE];
146 GDBusMethodInvocation *context;
148 } bt_hid_agent_info_t;
152 } __attribute__((packed)) bdaddr_t;
154 /* Remote socket address */
155 struct sockaddr_remote {
157 bdaddr_t remote_bdaddr;
161 bt_hid_agent_error_t _bt_hid_disconnect_profile(void);
163 #endif /* __DEF_BT_HID_AGENT_H_ */