This patch adds the SCO GIOChannel tracking. This is the initial step to
manage transport objects state changes and transport acquire.
---
 plugins/hfp_hf_bluez5.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 6a0f4a2..38643c6 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -60,6 +60,8 @@
 
 struct hfp {
        struct hfp_slc_info info;
+       GIOChannel *sco_io;
+       guint sco_watch;
        DBusMessage *msg;
 };
 
@@ -228,6 +230,12 @@ static void hfp_remove(struct ofono_modem *modem)
 
        g_at_chat_unref(info->chat);
 
+       if (hfp->sco_watch > 0)
+               g_source_remove(hfp->sco_watch);
+
+       if (hfp->sco_io)
+               g_io_channel_unref(hfp->sco_io);
+
        g_free(hfp);
 
        ofono_modem_set_data(modem, NULL);
@@ -374,10 +382,27 @@ static const GDBusMethodTable profile_methods[] = {
        { }
 };
 
+static gboolean sco_channel_watch(GIOChannel *io, GIOCondition cond,
+                                                       gpointer user_data)
+{
+       struct hfp *hfp = user_data;
+
+       hfp->sco_watch = 0;
+
+       g_io_channel_unref(hfp->sco_io);
+       hfp->sco_io = NULL;
+
+       /* TODO: Change transport state */
+
+       return FALSE;
+}
+
 static gboolean sco_accept(GIOChannel *io, GIOCondition cond,
                                                        gpointer user_data)
 {
        struct sockaddr_sco saddr;
+       struct ofono_modem *modem;
+       struct hfp *hfp;
        GSList *l;
        socklen_t alen;
        char remote[18];
@@ -404,7 +429,11 @@ static gboolean sco_accept(GIOChannel *io, GIOCondition 
cond,
                return TRUE;
        }
 
-       /* TODO: Store the SCO reference to update the Media Transports */
+       modem = l->data;
+       hfp = ofono_modem_get_data(modem);
+       hfp->sco_io = io;
+       hfp->sco_watch = g_io_add_watch(io, G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                                               sco_channel_watch, hfp);
 
        return TRUE;
 }
-- 
1.7.11.7

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to