static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage *m, void *data) {
DBusMessage *r;
- const char *sender;
+ const char *sender, *card;
+ int fd;
+ uint8_t codec;
+ hf_audio_card *hfac;
hf_audio_agent_data *hfdata = data;
pa_assert(hfdata);
return r;
}
- r = dbus_message_new_error(m, "org.ofono.Error.NotImplemented", "Operation is not implemented");
+ if (dbus_message_get_args(m, NULL,
+ DBUS_TYPE_OBJECT_PATH, &card,
+ DBUS_TYPE_UNIX_FD, &fd,
+ DBUS_TYPE_BYTE, &codec,
+ DBUS_TYPE_INVALID) == FALSE) {
+ pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
+ return r;
+ }
+
+ if ( !(hfac = pa_hashmap_get(hfdata->hf_audio_cards, card)) ) {
+ pa_log_warn("New audio connection on unknown card %s (fd=%d, codec=%d)", card, fd, codec);
+ pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Unknown card"));
+ return r;
+ } else
+ pa_log_debug("New audio connection on card %s (fd=%d, codec=%d)", card, fd, codec);
+
+ hfac->fd = fd;
+ hfac->codec = codec;
+ hfac->transport->state = PA_BLUETOOTH_TRANSPORT_STATE_PLAYING;
+ pa_hook_fire(pa_bluetooth_discovery_hook(hfdata->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED), hfac->transport);
+
+ pa_assert_se(r = dbus_message_new_method_return(m));
+
return r;
}