Hi Claudio,

On 02/27/2013 02:33 PM, Claudio Takahasi wrote:
This patch registers the Handsfree Audio Card when the service level
connection is established.
---
  plugins/hfp_hf_bluez5.c | 19 +++++++++++++++++++
  1 file changed, 19 insertions(+)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 7057d71..436d98c 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,20 @@ 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) {

Please fix this according to doc/coding-style.txt Item M1 1)

+               err = errno;
+               ofono_error("RFCOMM getpeername(): %s (%d)", strerror(err), 
err);

This part seems to be over 80 characters

+               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;


Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to