int audio_device_cancel_authorization(struct audio_device *dev, authorization_cb cb, void *user_data) { struct dev_priv *priv = dev->priv; GSList *l, *next; for (l = priv->auths; l != NULL; l = next) { struct service_auth *auth = l->data; next = g_slist_next(l); if (cb && auth->cb != cb) continue; if (user_data && auth->user_data != user_data) continue; priv->auths = g_slist_remove(priv->auths, auth); g_free(auth); } if (g_slist_length(priv->auths) == 0) { if (priv->auth_idle_id > 0) { g_source_remove(priv->auth_idle_id); priv->auth_idle_id = 0; } else btd_cancel_authorization(&dev->src, &dev->dst); } return 0; }
static DBusMessage *cancel_authorization(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessage *reply; struct service_adapter *serv_adapter = data; struct pending_auth *auth; const gchar *sender; sender = dbus_message_get_sender(msg); auth = find_pending_by_sender(serv_adapter, sender); if (auth == NULL) return btd_error_does_not_exist(msg); btd_cancel_authorization(auth->id); reply = btd_error_not_authorized(auth->msg); dbus_message_unref(auth->msg); g_dbus_send_message(btd_get_dbus_connection(), reply); serv_adapter->pending_list = g_slist_remove(serv_adapter->pending_list, auth); g_free(auth); auth = next_pending(serv_adapter); if (auth == NULL) goto done; auth->id = btd_request_authorization(get_address(serv_adapter), &auth->dst, auth->uuid, auth_cb, serv_adapter); done: return dbus_message_new_method_return(msg); }
static gboolean auth_watch(GIOChannel *chan, GIOCondition cond, gpointer data) { struct dun_server *server = data; error("DUN client disconnected while waiting for authorization"); btd_cancel_authorization(&server->src, &server->dst); disconnect(server); return FALSE; }
static DBusMessage *cancel_authorization(DBusConnection *conn, DBusMessage *msg, void *data) { DBusMessage *reply; struct service_adapter *serv_adapter = data; struct pending_auth *auth; const gchar *sender; bdaddr_t src; sender = dbus_message_get_sender(msg); auth = find_pending_by_sender(serv_adapter, sender); if (auth == NULL) return does_not_exist(msg); if (serv_adapter->adapter) adapter_get_address(serv_adapter->adapter, &src); else bacpy(&src, BDADDR_ANY); btd_cancel_authorization(&src, &auth->dst); reply = not_authorized(auth->msg); dbus_message_unref(auth->msg); g_dbus_send_message(auth->conn, reply); dbus_connection_unref(auth->conn); serv_adapter->pending_list = g_slist_remove(serv_adapter->pending_list, auth); g_free(auth); auth = next_pending(serv_adapter); if (auth == NULL) goto done; if (serv_adapter->adapter) adapter_get_address(serv_adapter->adapter, &src); else bacpy(&src, BDADDR_ANY); btd_request_authorization(&src, &auth->dst, auth->uuid, auth_cb, serv_adapter); done: return dbus_message_new_method_return(msg); }
static void avctp_disconnected(struct avctp *session) { struct avctp_server *server; if (!session) return; if (session->browsing) avctp_channel_destroy(session->browsing); if (session->control) avctp_channel_destroy(session->control); if (session->auth_id != 0) { btd_cancel_authorization(session->auth_id); session->auth_id = 0; } if (session->key != NULL) { if (session->key->timer > 0) g_source_remove(session->key->timer); g_free(session->key); } if (session->uinput >= 0) { char address[18]; ba2str(device_get_address(session->device), address); DBG("AVCTP: closing uinput for %s", address); ioctl(session->uinput, UI_DEV_DESTROY); close(session->uinput); session->uinput = -1; } server = session->server; server->sessions = g_slist_remove(server->sessions, session); btd_device_unref(session->device); g_free(session); }
static void ext_io_destroy(gpointer p) { struct ext_io *ext_io = p; struct ext_profile *ext = ext_io->ext; if (ext_io->io_id > 0) g_source_remove(ext_io->io_id); if (ext_io->io) { g_io_channel_shutdown(ext_io->io, FALSE, NULL); g_io_channel_unref(ext_io->io); } if (ext_io->auth_id != 0) btd_cancel_authorization(ext_io->auth_id); if (ext_io->new_conn) { dbus_pending_call_cancel(ext_io->new_conn); dbus_pending_call_unref(ext_io->new_conn); ext_cancel(ext); } if (ext_io->resolving) bt_cancel_discovery(adapter_get_address(ext_io->adapter), device_get_address(ext_io->device)); if (ext_io->rec_handle) remove_record_from_server(ext_io->rec_handle); if (ext_io->adapter) btd_adapter_unref(ext_io->adapter); if (ext_io->device) btd_device_unref(ext_io->device); g_free(ext_io); }