diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-06-22 19:14:38 +0000 |
---|---|---|
committer | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2007-06-22 19:14:38 +0000 |
commit | 7fb02908be38aaa273643ac6b78c5d72e40ae545 (patch) | |
tree | 8f103fe3a56f07d682fc27909efaace24a8533a9 /input | |
parent | a47211b0097fe3612b96246f08bf37dccd15fd61 (diff) |
input: fixed CreateDevice - verify the src and the dst address to discover if the device already exists
Diffstat (limited to 'input')
-rw-r--r-- | input/device.c | 27 | ||||
-rw-r--r-- | input/device.h | 3 | ||||
-rw-r--r-- | input/manager.c | 16 |
3 files changed, 11 insertions, 35 deletions
diff --git a/input/device.c b/input/device.c index 69b7a482..d9dfbec4 100644 --- a/input/device.c +++ b/input/device.c @@ -1140,24 +1140,6 @@ int input_device_unregister(DBusConnection *conn, const char *path) 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_user_data(conn, path, - (void *) &idev)) - return -1; - - if (!idev) - return -1; - - bacpy(src, &idev->src); - bacpy(dst, &idev->dst); - - return 0; -} - int l2cap_connect(bdaddr_t *src, bdaddr_t *dst, unsigned short psm, GIOFunc cb, void *data) { @@ -1236,6 +1218,15 @@ static struct device *find_device(bdaddr_t *src, bdaddr_t *dst) return NULL; } +gboolean input_device_is_registered(bdaddr_t *src, bdaddr_t *dst) +{ + struct device *idev = find_device(src, dst); + if (!idev) + return FALSE; + else + return TRUE; +} + int input_device_set_channel(bdaddr_t *src, bdaddr_t *dst, int psm, int nsk) { struct device *idev = find_device(src, dst); diff --git a/input/device.h b/input/device.h index fdf7f90f..86b593f5 100644 --- a/input/device.h +++ b/input/device.h @@ -30,8 +30,7 @@ int fake_input_register(DBusConnection *conn, bdaddr_t *src, bdaddr_t *dst, uint8_t ch, const char **ppath); 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); +gboolean input_device_is_registered(bdaddr_t *src, bdaddr_t *dst); int input_device_set_channel(bdaddr_t *src, bdaddr_t *dst, int psm, int nsk); diff --git a/input/manager.c b/input/manager.c index 666c0e44..74654893 100644 --- a/input/manager.c +++ b/input/manager.c @@ -778,23 +778,12 @@ done: dbus_message_unref(reply); } -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, DBusMessage *msg, void *data) { struct pending_req *pr; DBusError derr; const char *addr; - GSList *l; bdaddr_t src, dst; uint32_t cls = 0; int dev_id; @@ -821,10 +810,7 @@ static DBusHandlerResult create_device(DBusConnection *conn, } str2ba(addr, &dst); - - l = g_slist_find_custom(device_paths, &dst, - (GCompareFunc) path_bdaddr_cmp); - if (l) + if (input_device_is_registered(&src, &dst)) return err_already_exists(conn, msg, "Input Already exists"); if (read_device_class(&src, &dst, &cls) < 0) { |