Lines Matching full:iconn
119 struct input_conn *iconn = l->data;
121 if (!strcasecmp(iconn->uuid, pattern))
122 return iconn;
124 if (!strcasecmp(iconn->alias, pattern))
125 return iconn;
131 static void input_conn_free(struct input_conn *iconn)
133 if (iconn->pending_connect)
134 dbus_message_unref(iconn->pending_connect);
136 if (iconn->ctrl_watch)
137 g_source_remove(iconn->ctrl_watch);
139 if (iconn->intr_watch)
140 g_source_remove(iconn->intr_watch);
142 if (iconn->intr_io)
143 g_io_channel_unref(iconn->intr_io);
145 if (iconn->ctrl_io)
146 g_io_channel_unref(iconn->ctrl_io);
148 g_free(iconn->uuid);
149 g_free(iconn->alias);
150 g_free(iconn->fake);
151 g_free(iconn);
351 struct input_conn *iconn = user_data;
352 struct input_device *idev = iconn->idev;
353 struct fake_input *fake = iconn->fake;
357 reply = connection_attempt_failed(iconn->pending_connect,
371 reply = connection_attempt_failed(iconn->pending_connect,
382 reply = dbus_message_new_method_return(iconn->pending_connect);
385 dbus_message_unref(iconn->pending_connect);
386 iconn->pending_connect = NULL;
392 dbus_message_unref(iconn->pending_connect);
393 iconn->pending_connect = NULL;
396 static gboolean rfcomm_connect(struct input_conn *iconn, GError **err)
398 struct input_device *idev = iconn->idev;
401 io = bt_io_connect(BT_IO_RFCOMM, rfcomm_connect_cb, iconn,
416 struct input_conn *iconn = data;
417 struct input_device *idev = iconn->idev;
423 if ((cond & (G_IO_HUP | G_IO_ERR)) && iconn->ctrl_watch)
432 iconn->intr_watch = 0;
434 g_io_channel_unref(iconn->intr_io);
435 iconn->intr_io = NULL;
438 if (iconn->ctrl_io && !(cond & G_IO_NVAL))
439 g_io_channel_shutdown(iconn->ctrl_io, TRUE, NULL);
446 struct input_conn *iconn = data;
451 if ((cond & (G_IO_HUP | G_IO_ERR)) && iconn->intr_watch)
454 iconn->ctrl_watch = 0;
456 g_io_channel_unref(iconn->ctrl_io);
457 iconn->ctrl_io = NULL;
460 if (iconn->intr_io && !(cond & G_IO_NVAL))
461 g_io_channel_shutdown(iconn->intr_io, TRUE, NULL);
466 static gboolean fake_hid_connect(struct input_conn *iconn, GError **err)
468 struct fake_hid *fhid = iconn->fake->priv;
470 return fhid->connect(iconn->fake, err);
473 static int fake_hid_disconnect(struct input_conn *iconn)
475 struct fake_hid *fhid = iconn->fake->priv;
477 return fhid->disconnect(iconn->fake);
606 const struct input_conn *iconn)
616 req->ctrl_sock = g_io_channel_unix_get_fd(iconn->ctrl_io);
617 req->intr_sock = g_io_channel_unix_get_fd(iconn->intr_io);
619 req->idle_to = iconn->timeout;
643 err = fake_hid_connadd(fake, iconn->intr_io, fake_hid);
664 int sk = g_io_channel_unix_get_fd(iconn->ctrl_io);
678 static int is_connected(struct input_conn *iconn)
680 struct input_device *idev = iconn->idev;
681 struct fake_input *fake = iconn->fake;
709 static int connection_disconnect(struct input_conn *iconn, uint32_t flags)
711 struct input_device *idev = iconn->idev;
712 struct fake_input *fake = iconn->fake;
719 err = fake->disconnect(iconn);
726 if (iconn->intr_io)
727 g_io_channel_shutdown(iconn->intr_io, TRUE, NULL);
728 if (iconn->ctrl_io)
729 g_io_channel_shutdown(iconn->ctrl_io, TRUE, NULL);
768 struct input_conn *iconn = NULL;
772 iconn = l->data;
774 if (is_connected(iconn))
778 if (!iconn)
781 return connection_disconnect(iconn, flags);
798 struct input_conn *iconn)
803 if (iconn->intr_io == NULL || iconn->ctrl_io == NULL)
806 err = hidp_add_connection(idev, iconn);
810 iconn->intr_watch = g_io_add_watch(iconn->intr_io,
812 intr_watch_cb, iconn);
813 iconn->ctrl_watch = g_io_add_watch(iconn->ctrl_io,
815 ctrl_watch_cb, iconn);
830 struct input_conn *iconn = user_data;
831 struct input_device *idev = iconn->idev;
838 g_io_channel_unref(iconn->intr_io);
839 iconn->intr_io = NULL;
843 err = input_device_connected(idev, iconn);
850 g_dbus_send_reply(idev->conn, iconn->pending_connect, DBUS_TYPE_INVALID);
852 dbus_message_unref(iconn->pending_connect);
853 iconn->pending_connect = NULL;
859 reply = connection_attempt_failed(iconn->pending_connect, err_msg);
862 if (iconn->ctrl_io)
863 g_io_channel_shutdown(iconn->ctrl_io, FALSE, NULL);
865 if (iconn->intr_io) {
867 g_io_channel_shutdown(iconn->intr_io, FALSE, NULL);
868 g_io_channel_unref(iconn->intr_io);
869 iconn->intr_io = NULL;
876 struct input_conn *iconn = user_data;
877 struct input_device *idev = iconn->idev;
884 reply = connection_attempt_failed(iconn->pending_connect,
890 io = bt_io_connect(BT_IO_L2CAP, interrupt_connect_cb, iconn,
898 reply = connection_attempt_failed(iconn->pending_connect,
905 iconn->intr_io = io;
911 dbus_message_unref(iconn->pending_connect);
912 iconn->pending_connect = NULL;
915 static int fake_disconnect(struct input_conn *iconn)
917 struct fake_input *fake = iconn->fake;
942 struct input_conn *iconn;
947 iconn = find_connection(idev->connections, "HID");
948 if (!iconn)
951 if (iconn->pending_connect)
954 if (is_connected(iconn))
957 iconn->pending_connect = dbus_message_ref(msg);
958 fake = iconn->fake;
962 if (fake->connect(iconn, &err))
968 io = bt_io_connect(BT_IO_L2CAP, control_connect_cb, iconn,
974 iconn->ctrl_io = io;
981 dbus_message_unref(iconn->pending_connect);
982 iconn->pending_connect = NULL;
1020 struct input_conn *iconn = a;
1022 return !is_connected(iconn);
1108 struct input_conn *iconn;
1110 iconn = g_new0(struct input_conn, 1);
1111 iconn->timeout = timeout;
1112 iconn->uuid = g_strdup(uuid);
1113 iconn->alias = g_strdup(alias);
1114 iconn->idev = idev;
1116 return iconn;
1125 struct input_conn *iconn;
1135 iconn = input_conn_new(idev, uuid, "hid", timeout);
1136 if (!iconn)
1139 idev->connections = g_slist_append(idev->connections, iconn);
1149 struct input_conn *iconn;
1159 iconn = input_conn_new(idev, uuid, "hsp", 0);
1160 if (!iconn)
1163 iconn->fake = g_new0(struct fake_input, 1);
1164 iconn->fake->ch = channel;
1165 iconn->fake->connect = rfcomm_connect;
1166 iconn->fake->disconnect = fake_disconnect;
1168 idev->connections = g_slist_append(idev->connections, iconn);
1191 struct input_conn *iconn;
1197 iconn = find_connection(idev->connections, uuid);
1198 if (iconn == NULL)
1201 if (iconn->pending_connect) {
1206 idev->connections = g_slist_remove(idev->connections, iconn);
1207 input_conn_free(iconn);
1217 struct input_conn *iconn)
1221 err = input_device_connected(idev, iconn);
1228 if (iconn->ctrl_io) {
1229 g_io_channel_shutdown(iconn->ctrl_io, FALSE, NULL);
1230 g_io_channel_unref(iconn->ctrl_io);
1231 iconn->ctrl_io = NULL;
1233 if (iconn->intr_io) {
1234 g_io_channel_shutdown(iconn->intr_io, FALSE, NULL);
1235 g_io_channel_unref(iconn->intr_io);
1236 iconn->intr_io = NULL;
1246 struct input_conn *iconn;
1251 iconn = find_connection(idev->connections, "hid");
1252 if (!iconn)
1257 if (iconn->ctrl_io)
1259 iconn->ctrl_io = g_io_channel_ref(io);
1262 if (iconn->intr_io)
1264 iconn->intr_io = g_io_channel_ref(io);
1268 if (iconn->intr_io && iconn->ctrl_io)
1269 input_device_connadd(idev, iconn);
1277 struct input_conn *iconn;
1282 iconn = find_connection(idev->connections, "hid");
1283 if (!iconn)
1286 if (iconn->intr_io)
1287 g_io_channel_shutdown(iconn->intr_io, TRUE, NULL);
1289 if (iconn->ctrl_io)
1290 g_io_channel_shutdown(iconn->ctrl_io, TRUE, NULL);