summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2013-02-28 13:01:05 -0300
committerDenis Kenzior <denkenz@gmail.com>2013-02-28 10:09:33 -0600
commit4ef4d620e4567af6f029c74e4021468d86417a0d (patch)
tree79baf8cada3a1b8455d9a8044165e2baebacc322 /plugins
parentc7a3f3990ae90057abfd0db2e9577b720cd32f2b (diff)
downloadofono-4ef4d620e4567af6f029c74e4021468d86417a0d.tar.bz2
hfp_hf_bluez5: Add registering Audio Card
This patch registers the Handsfree Audio Card when the service level connection is established.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hfp_hf_bluez5.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 7057d71f..87d7e91b 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -46,6 +46,7 @@
#include <ofono/netreg.h>
#include <ofono/voicecall.h>
#include <ofono/call-volume.h>
+#include <ofono/handsfree-audio.h>
#include <ofono/handsfree.h>
#include <drivers/hfpmodem/slc.h>
@@ -61,6 +62,7 @@
struct hfp {
struct hfp_slc_info info;
DBusMessage *msg;
+ struct ofono_handsfree_card *card;
};
static GDBusClient *bluez = NULL;
@@ -88,6 +90,8 @@ static void slc_established(gpointer userdata)
hfp->msg = NULL;
ofono_info("Service level connection established");
+
+ ofono_handsfree_card_register(hfp->card);
}
static void slc_failed(gpointer userdata)
@@ -315,8 +319,11 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
{
struct hfp *hfp;
struct ofono_modem *modem;
+ struct sockaddr_rc saddr;
+ socklen_t optlen;
DBusMessageIter entry;
const char *device;
+ char remote[18];
int fd, err;
DBG("Profile handler NewConnection");
@@ -353,8 +360,22 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
"Not enough resources");
}
+ memset(&saddr, 0, sizeof(saddr));
+ optlen = sizeof(saddr);
+
+ if (getpeername(fd, (struct sockaddr *) &saddr, &optlen) < 0) {
+ err = errno;
+ ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err),
+ err);
+ close(fd);
+ goto invalid;
+ }
+
+ bt_ba2str(&saddr.rc_bdaddr, remote);
+
hfp = ofono_modem_get_data(modem);
hfp->msg = dbus_message_ref(msg);
+ hfp->card = ofono_handsfree_card_create(remote, NULL);
return NULL;