mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-17 09:14:32 +08:00
Keep the device structure local
This commit is contained in:
parent
1f6bcd79a3
commit
e3aec1dd41
@ -61,6 +61,29 @@
|
|||||||
|
|
||||||
#define UPDOWN_ENABLED 1
|
#define UPDOWN_ENABLED 1
|
||||||
|
|
||||||
|
struct pending_connect {
|
||||||
|
DBusConnection *conn;
|
||||||
|
DBusMessage *msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct fake_input {
|
||||||
|
GIOChannel *io;
|
||||||
|
int rfcomm; /* RFCOMM socket */
|
||||||
|
int uinput; /* uinput socket */
|
||||||
|
uint8_t ch; /* RFCOMM channel number */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct device {
|
||||||
|
bdaddr_t src;
|
||||||
|
bdaddr_t dst;
|
||||||
|
char *name;
|
||||||
|
uint8_t major;
|
||||||
|
uint8_t minor;
|
||||||
|
struct hidp_connadd_req hidp; /* FIXME: Use dynamic alloc? */
|
||||||
|
struct fake_input *fake;
|
||||||
|
struct pending_connect *pending_connect;
|
||||||
|
};
|
||||||
|
|
||||||
static struct device *device_new(bdaddr_t *src, bdaddr_t *dst)
|
static struct device *device_new(bdaddr_t *src, bdaddr_t *dst)
|
||||||
{
|
{
|
||||||
struct device *idev;
|
struct device *idev;
|
||||||
@ -1086,6 +1109,13 @@ int fake_input_register(DBusConnection *conn, bdaddr_t *src,
|
|||||||
int input_device_unregister(DBusConnection *conn, const char *path)
|
int input_device_unregister(DBusConnection *conn, const char *path)
|
||||||
{
|
{
|
||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
|
struct device *idev;
|
||||||
|
|
||||||
|
if (!dbus_connection_get_object_path_data(conn,
|
||||||
|
path, (void *) &idev))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
del_stored_device_info(&idev->src, &idev->dst);
|
||||||
|
|
||||||
if (!dbus_connection_unregister_object_path(conn, path)) {
|
if (!dbus_connection_unregister_object_path(conn, path)) {
|
||||||
error("Input device path unregister failed");
|
error("Input device path unregister failed");
|
||||||
@ -1105,3 +1135,21 @@ int input_device_unregister(DBusConnection *conn, const char *path)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int input_device_get_bdaddr(DBusConnection *conn, const char *path,
|
||||||
|
bdaddr_t *src, bdaddr_t *dst)
|
||||||
|
{
|
||||||
|
struct device *idev;
|
||||||
|
|
||||||
|
if (!dbus_connection_get_object_path_data(conn, path,
|
||||||
|
(void *) &idev))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!idev)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
bacpy(src, &idev->src);
|
||||||
|
bacpy(dst, &idev->dst);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -21,31 +21,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct fake_input {
|
|
||||||
GIOChannel *io;
|
|
||||||
int rfcomm; /* RFCOMM socket */
|
|
||||||
int uinput; /* uinput socket */
|
|
||||||
uint8_t ch; /* RFCOMM channel number */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pending_connect {
|
|
||||||
DBusConnection *conn;
|
|
||||||
DBusMessage *msg;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct device {
|
|
||||||
bdaddr_t src;
|
|
||||||
bdaddr_t dst;
|
|
||||||
char *name;
|
|
||||||
uint8_t major;
|
|
||||||
uint8_t minor;
|
|
||||||
struct hidp_connadd_req hidp; /* FIXME: Use dynamic alloc? */
|
|
||||||
struct fake_input *fake;
|
|
||||||
struct pending_connect *pending_connect;
|
|
||||||
};
|
|
||||||
|
|
||||||
int input_device_register(DBusConnection *conn, bdaddr_t *src, bdaddr_t *dst,
|
int input_device_register(DBusConnection *conn, bdaddr_t *src, bdaddr_t *dst,
|
||||||
struct hidp_connadd_req *hidp, const char **ppath);
|
struct hidp_connadd_req *hidp, const char **ppath);
|
||||||
int fake_input_register(DBusConnection *conn, bdaddr_t *src,
|
int fake_input_register(DBusConnection *conn, bdaddr_t *src,
|
||||||
bdaddr_t *dst, uint8_t ch, const char **ppath);
|
bdaddr_t *dst, uint8_t ch, const char **ppath);
|
||||||
int input_device_unregister(DBusConnection *conn, const char *path);
|
int input_device_unregister(DBusConnection *conn, const char *path);
|
||||||
|
|
||||||
|
int input_device_get_bdaddr(DBusConnection *conn, const char *path,
|
||||||
|
bdaddr_t *src, bdaddr_t *dst);
|
||||||
|
@ -115,20 +115,6 @@ static void pending_req_free(struct pending_req *pr)
|
|||||||
g_free(pr);
|
g_free(pr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int path_bdaddr_cmp(const char *path, const bdaddr_t *bdaddr)
|
|
||||||
{
|
|
||||||
struct device *idev;
|
|
||||||
|
|
||||||
if (!dbus_connection_get_object_path_data(connection, path,
|
|
||||||
(void *) &idev))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (!idev)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return bacmp(&idev->dst, bdaddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get_record(struct pending_req *pr, uint32_t handle,
|
static int get_record(struct pending_req *pr, uint32_t handle,
|
||||||
DBusPendingCallNotifyFunction cb)
|
DBusPendingCallNotifyFunction cb)
|
||||||
{
|
{
|
||||||
@ -637,6 +623,16 @@ done:
|
|||||||
dbus_pending_call_unref(call);
|
dbus_pending_call_unref(call);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int path_bdaddr_cmp(const char *path, const bdaddr_t *bdaddr)
|
||||||
|
{
|
||||||
|
bdaddr_t src, dst;
|
||||||
|
|
||||||
|
if (input_device_get_bdaddr(connection, path, &src, &dst) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return bacmp(&dst, bdaddr);
|
||||||
|
}
|
||||||
|
|
||||||
static DBusHandlerResult create_device(DBusConnection *conn,
|
static DBusHandlerResult create_device(DBusConnection *conn,
|
||||||
DBusMessage *msg, void *data)
|
DBusMessage *msg, void *data)
|
||||||
{
|
{
|
||||||
@ -710,7 +706,6 @@ static DBusHandlerResult create_device(DBusConnection *conn,
|
|||||||
static DBusHandlerResult remove_device(DBusConnection *conn,
|
static DBusHandlerResult remove_device(DBusConnection *conn,
|
||||||
DBusMessage *msg, void *data)
|
DBusMessage *msg, void *data)
|
||||||
{
|
{
|
||||||
struct device *idev;
|
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
DBusError derr;
|
DBusError derr;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
@ -736,12 +731,6 @@ static DBusHandlerResult remove_device(DBusConnection *conn,
|
|||||||
g_free(l->data);
|
g_free(l->data);
|
||||||
device_paths = g_slist_remove(device_paths, l->data);
|
device_paths = g_slist_remove(device_paths, l->data);
|
||||||
|
|
||||||
if (!dbus_connection_get_object_path_data(connection,
|
|
||||||
path, (void *) &idev))
|
|
||||||
return err_does_not_exist(conn, msg, "Input doesn't exist");
|
|
||||||
|
|
||||||
del_stored_device_info(&idev->src, &idev->dst);
|
|
||||||
|
|
||||||
if (input_device_unregister(conn, path) < 0) {
|
if (input_device_unregister(conn, path) < 0) {
|
||||||
dbus_message_unref(reply);
|
dbus_message_unref(reply);
|
||||||
return err_failed(conn, msg, "D-Bus path unregistration failed");
|
return err_failed(conn, msg, "D-Bus path unregistration failed");
|
||||||
|
Loading…
Reference in New Issue
Block a user