Esempio n. 1
0
static void hfp16_card_connect(struct ofono_handsfree_card *card,
					ofono_handsfree_card_connect_cb_t cb,
					void *data)
{
	struct hfp *hfp = ofono_handsfree_card_get_data(card);
	struct hfp_slc_info *info = &hfp->info;

	if (info->hf_features & HFP_HF_FEATURE_CODEC_NEGOTIATION &&
			info->ag_features & HFP_AG_FEATURE_CODEC_NEGOTIATION) {
		struct cb_data *cbd = cb_data_new(cb, data);

		cbd->user = card;
		hfp->bcc_id = g_at_chat_send(info->chat, "AT+BCC",
						none_prefix, bcc_cb,
						cbd, g_free);
		return;
	}

	/*
	 * If any side (remote or local) doesn't support codec negotiation,
	 * fallback to direct SCO connection. Calling connect_sco()
	 * hands the connection responsibility to the core, so no need
	 * to call the callback
	 */
	ofono_handsfree_card_connect_sco(card);
}
static DBusMessage *card_connect(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	struct ofono_handsfree_card *card = data;
	const struct ofono_handsfree_card_driver *driver = card->driver;
	const char *sender;
	int err;

	if (agent == NULL)
		return __ofono_error_not_available(msg);

	sender = dbus_message_get_sender(msg);

	if (!g_str_equal(sender, agent->owner))
		return __ofono_error_not_allowed(msg);

	if (card->msg)
		return __ofono_error_busy(msg);

	if (!driver || !driver->connect)
		goto fallback;

	card->msg = dbus_message_ref(msg);

	driver->connect(card, card_connect_reply_cb, card);

	return NULL;

fallback:
	/* There's no driver, fallback to direct SCO connection */
	err = ofono_handsfree_card_connect_sco(card);
	if (err < 0)
		return __ofono_error_failed(msg);

	card->msg = dbus_message_ref(msg);

	return NULL;
}