summaryrefslogtreecommitdiffstats
path: root/input/device.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-06-22 18:39:50 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-06-22 18:39:50 +0000
commitb4427e24489d4aaf6768041cbb3b90353a285cfe (patch)
tree7ed87b6df8132167a55c2146e74bbf6f1c98df6d /input/device.c
parent0762886602369f99a473dc95cc288def7b6e363c (diff)
input: missing Disconnected signal when RemoveDevice is called
Diffstat (limited to 'input/device.c')
-rw-r--r--input/device.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/input/device.c b/input/device.c
index 99c462c8..69b7a482 100644
--- a/input/device.c
+++ b/input/device.c
@@ -80,6 +80,7 @@ struct device {
char *path;
int ctrl_sk;
int intr_sk;
+ guint watch;
};
GSList *devices = NULL;
@@ -512,24 +513,29 @@ static gboolean connection_event(GIOChannel *chan, GIOCondition cond, gpointer d
ret = FALSE;
}
- if (ret == FALSE)
+ if (ret == FALSE) {
dbus_connection_emit_signal(idev->conn,
idev->path,
INPUT_DEVICE_INTERFACE,
"Disconnected",
DBUS_TYPE_INVALID);
+ idev->watch = 0;
+ }
return ret;
}
-static void create_watch(int sk, struct device *idev)
+static guint create_watch(int sk, struct device *idev)
{
+ guint id;
GIOChannel *io;
io = g_io_channel_unix_new(sk);
- g_io_add_watch(io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- connection_event, idev);
+ id = g_io_add_watch(io, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ connection_event, idev);
g_io_channel_unref(io);
+
+ return id;
}
static int hidp_connadd(bdaddr_t *src, bdaddr_t *dst, int ctrl_sk, int intr_sk, const char *name)
@@ -623,7 +629,7 @@ static gboolean interrupt_connect_cb(GIOChannel *chan,
if (err < 0)
goto failed;
- create_watch(idev->ctrl_sk, idev);
+ idev->watch = create_watch(idev->ctrl_sk, idev);
dbus_connection_emit_signal(idev->conn,
idev->path,
INPUT_DEVICE_INTERFACE,
@@ -1109,6 +1115,21 @@ int input_device_unregister(DBusConnection *conn, const char *path)
devices = g_slist_remove(devices, idev);
+ /*
+ * Workaround: if connected, the watch will not be able
+ * to access the D-Bus data assigned to this path
+ * because the object path data was destroyed.
+ */
+ if (idev->watch) {
+ g_source_remove(idev->watch);
+ idev->watch = 0;
+ dbus_connection_emit_signal(conn,
+ path,
+ INPUT_DEVICE_INTERFACE,
+ "Disconnected",
+ DBUS_TYPE_INVALID);
+ }
+
dbus_connection_destroy_object_path(conn, path);
dbus_connection_emit_signal(conn, INPUT_PATH,
@@ -1271,7 +1292,7 @@ int input_device_connadd(bdaddr_t *src, bdaddr_t *dst)
return err;
}
- create_watch(idev->ctrl_sk, idev);
+ idev->watch = create_watch(idev->ctrl_sk, idev);
dbus_connection_emit_signal(idev->conn,
idev->path,
INPUT_DEVICE_INTERFACE,