static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data) { struct input_device *idev = data; char address[18]; ba2str(&idev->dst, address); DBG("Device %s disconnected", address); /* Checking for ctrl_watch avoids a double g_io_channel_shutdown since * it's likely that ctrl_watch_cb has been queued for dispatching in * this mainloop iteration */ if ((cond & (G_IO_HUP | G_IO_ERR)) && idev->ctrl_watch) g_io_channel_shutdown(chan, TRUE, NULL); device_remove_disconnect_watch(idev->device, idev->dc_id); idev->dc_id = 0; idev->intr_watch = 0; if (idev->intr_io) { g_io_channel_unref(idev->intr_io); idev->intr_io = NULL; } /* Close control channel */ if (idev->ctrl_io && !(cond & G_IO_NVAL)) g_io_channel_shutdown(idev->ctrl_io, TRUE, NULL); /* Enter the auto-reconnect mode if needed */ input_device_enter_reconnect_mode(idev); return FALSE; }
static gboolean intr_watch_cb(GIOChannel *chan, GIOCondition cond, gpointer data) { struct input_conn *iconn = data; struct input_device *idev = iconn->idev; gboolean connected = FALSE; DBG(""); /* Checking for ctrl_watch avoids a double g_io_channel_shutdown since * it's likely that ctrl_watch_cb has been queued for dispatching in * this mainloop iteration */ if ((cond & (G_IO_HUP | G_IO_ERR)) && iconn->ctrl_watch) g_io_channel_shutdown(chan, TRUE, NULL); emit_property_changed(idev->conn, idev->path, INPUT_DEVICE_INTERFACE, "Connected", DBUS_TYPE_BOOLEAN, &connected); device_remove_disconnect_watch(idev->device, idev->dc_id); idev->dc_id = 0; iconn->intr_watch = 0; g_io_channel_unref(iconn->intr_io); iconn->intr_io = NULL; /* Close control channel */ if (iconn->ctrl_io) g_io_channel_shutdown(iconn->ctrl_io, TRUE, NULL); /* Enter the auto-reconnect mode if needed */ input_device_enter_reconnect_mode(idev); return FALSE; }