summaryrefslogtreecommitdiffstats
path: root/input/device.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-05-27 19:35:53 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-05-27 19:35:53 +0000
commita7bc44bcbad838b8da5ab279a11075ae4f6f1418 (patch)
tree045f3fc30c077099b30a58614b474884c41f7aa7 /input/device.c
parentc71805ac4bd1bd85d1d0dfc31a200a26d43a9a14 (diff)
Fix user data issue when removing device
Diffstat (limited to 'input/device.c')
-rw-r--r--input/device.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/input/device.c b/input/device.c
index 0f06d095..b85f9cdb 100644
--- a/input/device.c
+++ b/input/device.c
@@ -990,12 +990,40 @@ int fake_input_register(DBusConnection *conn, bdaddr_t *src,
return err;
}
+static struct device *find_device(const bdaddr_t *src, const bdaddr_t *dst)
+{
+ GSList *list;
+
+ for (list = devices; list != NULL; list = list->next) {
+ struct device *idev = list->data;
+
+ if (!bacmp(&idev->src, src) && !bacmp(&idev->dst, dst))
+ return idev;
+ }
+
+ return NULL;
+}
+
+static struct device *find_device_by_path(const char *path)
+{
+ GSList *list;
+
+ for (list = devices; list != NULL; list = list->next) {
+ struct device *idev = list->data;
+
+ if (strcmp(idev->path, path) == 0)
+ return idev;
+ }
+
+ return NULL;
+}
+
int input_device_unregister(DBusConnection *conn, const char *path)
{
struct device *idev;
- if (!dbus_connection_get_object_user_data(conn,
- path, (void *) &idev) || !idev)
+ idev = find_device_by_path(path);
+ if (idev == NULL)
return -EINVAL;
if (idev->pending_connect) {
@@ -1018,35 +1046,18 @@ int input_device_unregister(DBusConnection *conn, const char *path)
if (idev->intr_watch) {
g_source_remove(idev->intr_watch);
dbus_connection_emit_signal(conn,
- path,
- INPUT_DEVICE_INTERFACE,
- "Disconnected",
- DBUS_TYPE_INVALID);
+ path, INPUT_DEVICE_INTERFACE,
+ "Disconnected", DBUS_TYPE_INVALID);
}
- dbus_connection_destroy_object_path(conn, path);
-
dbus_connection_emit_signal(conn, INPUT_PATH,
INPUT_MANAGER_INTERFACE, "DeviceRemoved" ,
DBUS_TYPE_STRING, &path,
DBUS_TYPE_INVALID);
- return 0;
-}
-
-static struct device *find_device(const bdaddr_t *src, const bdaddr_t *dst)
-{
- struct device *idev;
- GSList *list;
-
- for (list = devices; list != NULL; list = list->next) {
- idev = list->data;
-
- if (!bacmp(&idev->src, src) && !bacmp(&idev->dst, dst))
- return idev;
- }
+ g_dbus_unregister_interface(conn, path, INPUT_DEVICE_INTERFACE);
- return NULL;
+ return 0;
}
gboolean input_device_is_registered(bdaddr_t *src, bdaddr_t *dst)