Ejemplo n.º 1
0
void cancel_passkey_agent_requests(GSList *agents, const char *path,
					bdaddr_t *addr)
{
	GSList *l, *next;

	/* First check the default agent */
	for (l = default_agent ? default_agent->pending_requests : NULL; l != NULL; l = next) {
		struct pending_agent_request *req = l->data;
		next = l->next;
		if (!strcmp(path, req->path) && (!addr || !bacmp(addr, &req->bda))) {
			send_cancel_request(req);
			default_agent->pending_requests = g_slist_remove(default_agent->pending_requests,
									req);
		}
	}

	/* and then the adapter specific agents */
	for (; agents != NULL; agents = agents->next) {
		struct passkey_agent *agent = agents->data;

		for (l = agent->pending_requests; l != NULL; l = next) {
			struct pending_agent_request *req = l->data;
			next = l->next;
			if (!strcmp(path, req->path) && (!addr || !bacmp(addr, &req->bda))) {
				send_cancel_request(req);
				agent->pending_requests = g_slist_remove(agent->pending_requests, req);
			}
		}
	}
}
Ejemplo n.º 2
0
static void cancel_all_requests(struct connman_agent *agent)
{
	GList *list;

	DBG("request %p pending %p", agent->pending, agent->queue);

	if (agent->pending) {
		if (agent->pending->call)
			send_cancel_request(agent, agent->pending);

		agent_finalize_pending(agent, NULL);
	}

	for (list = agent->queue; list; list = list->next) {
		struct connman_agent_request *request = list->data;

		if (!request)
			continue;

		request->callback(NULL, request->user_data);
		agent_request_free(request);
	}

	g_list_free(agent->queue);
	agent->queue = NULL;
}
Ejemplo n.º 3
0
static void agent_receive_message(DBusPendingCall *call, void *user_data)
{
	struct connman_agent *agent = user_data;
	DBusMessage *reply;
	int err;

	DBG("agent %p req %p", agent, agent->pending);

	reply = dbus_pending_call_steal_reply(call);
	dbus_pending_call_unref(call);
	agent->pending->call = NULL;

	if (dbus_message_is_error(reply,
			"org.freedesktop.DBus.Error.Timeout") ||
			dbus_message_is_error(reply,
			"org.freedesktop.DBus.Error.TimedOut")) {
		send_cancel_request(agent, agent->pending);
	}

	agent_finalize_pending(agent, reply);
	dbus_message_unref(reply);

	err = agent_send_next_request(agent);
	if (err < 0 && err != -EBUSY)
		DBG("send next request failed (%s/%d)", strerror(-err), -err);
}
Ejemplo n.º 4
0
static void passkey_agent_free(struct passkey_agent *agent)
{
	GSList *l;

	if (!agent)
		return;

	for (l = agent->pending_requests; l != NULL; l = l->next) {
		struct pending_agent_request *req = l->data;

		hci_send_cmd(req->dev, OGF_LINK_CTL,
				OCF_PIN_CODE_NEG_REPLY, 6, &req->bda);

		send_cancel_request(req);
	}

	if (agent->timeout)
		g_source_remove(agent->timeout);

	if (!agent->exited)
		release_agent(agent);

	g_free(agent->name);
	g_free(agent->path);
	g_free(agent->addr);

	if (agent->conn)
		dbus_connection_unref(agent->conn);

	g_slist_free(agent->pending_requests);

	g_free(agent);
}
Ejemplo n.º 5
0
void connman_agent_cancel(void *user_context)
{
	GHashTableIter iter;
	gpointer key, value;
	int err;

	DBG("context %p", user_context);

	g_hash_table_iter_init(&iter, agent_hash);
	while (g_hash_table_iter_next(&iter, &key, &value)) {
		GList *list, *next;
		struct connman_agent *agent = value;

		/*
		 * Cancel all the pending requests to a given agent and service
		 */
		list = agent->queue;
		while (list) {
			struct connman_agent_request *request = list->data;

			next = list->next;

			if (request && request->user_context &&
						request->user_context ==
								user_context) {
				DBG("cancel pending %p", request);

				agent->queue = g_list_delete_link(agent->queue,
									list);

				request->callback(NULL, request->user_data);

				agent_request_free(request);
			}

			list = next;
		}

		/*
		 * If there is a request from client to a given service,
		 * we need to cancel it.
		 */
		if (agent->pending && agent->pending->user_context &&
				agent->pending->user_context == user_context) {
			DBG("cancel request %p", agent->pending);

			if (agent->pending->call)
				send_cancel_request(agent, agent->pending);

			agent_finalize_pending(agent, NULL);

			err = agent_send_next_request(agent);
			if (err < 0 && err != -EBUSY)
				DBG("send next request failed (%s/%d)",
						strerror(-err), -err);
		}
	}
}
Ejemplo n.º 6
0
int agent_cancel(struct agent *agent)
{
	if (!agent->request)
		return -EINVAL;

	if (agent->request->call) {
		dbus_pending_call_cancel(agent->request->call);
		send_cancel_request(agent->request);
	}

	agent_request_free(agent->request, TRUE);
	agent->request = NULL;

	return 0;
}