Open Source Telephony
 help / color / mirror / Atom feed
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH 2/3] emulator: add HFP emulator type
Date: Tue, 15 Feb 2011 16:06:32 +0100	[thread overview]
Message-ID: <1297782393-9898-3-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1297782393-9898-1-git-send-email-frederic.danis@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2913 bytes --]

---
 include/emulator.h |    1 +
 plugins/hfp_ag.c   |   17 +++++++++++++++++
 src/emulator.c     |   14 ++++++++++++--
 src/ofono.h        |    1 +
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/include/emulator.h b/include/emulator.h
index 2334e02..a080399 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -32,6 +32,7 @@ struct ofono_emulator;
 
 enum ofono_emulator_type {
 	OFONO_EMULATOR_TYPE_DUN,
+	OFONO_EMULATOR_TYPE_HFP,
 };
 
 struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
diff --git a/plugins/hfp_ag.c b/plugins/hfp_ag.c
index c43275b..a45c8c1 100644
--- a/plugins/hfp_ag.c
+++ b/plugins/hfp_ag.c
@@ -94,6 +94,10 @@ static gboolean hfp_ag_disconnect_cb(GIOChannel *io, GIOCondition cond,
 
 static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 {
+	struct ofono_modem *modem;
+	struct ofono_emulator *em;
+	int fd;
+
 	DBG("");
 
 	if (err) {
@@ -101,6 +105,19 @@ static void hfp_ag_connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 		goto failed;
 	}
 
+	/* Pick the first voicecall capable modem */
+	modem = modems->data;
+	if (modem == NULL)
+		goto failed;
+	DBG("Picked modem %p for emulator", modem);
+
+	em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP);
+	if (em == NULL)
+		goto failed;
+
+	fd = g_io_channel_unix_get_fd(io);
+	ofono_emulator_register(em, fd);
+
 	channel_watch = g_io_add_watch(io, G_IO_NVAL | G_IO_HUP | G_IO_ERR,
 					hfp_ag_disconnect_cb, NULL);
 
diff --git a/src/emulator.c b/src/emulator.c
index c49283d..232b314 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -30,6 +30,7 @@
 
 struct ofono_emulator {
 	struct ofono_atom *atom;
+	enum ofono_emulator_type type;
 	GAtServer *server;
 };
 
@@ -92,16 +93,25 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 						enum ofono_emulator_type type)
 {
 	struct ofono_emulator *em;
+	enum ofono_atom_type atom_t;
 
 	DBG("modem: %p, type: %d", modem, type);
 
+	if (type == OFONO_EMULATOR_TYPE_DUN)
+		atom_t = OFONO_ATOM_TYPE_EMULATOR_DUN;
+	else if (type == OFONO_EMULATOR_TYPE_HFP)
+		atom_t = OFONO_ATOM_TYPE_EMULATOR_HFP;
+	else
+		return NULL;
+
 	em = g_try_new0(struct ofono_emulator, 1);
 
 	if (em == NULL)
 		return NULL;
 
-	em->atom = __ofono_modem_add_atom(modem, OFONO_ATOM_TYPE_EMULATOR_DUN,
-						emulator_remove, em);
+	em->type = type;
+
+	em->atom = __ofono_modem_add_atom(modem, atom_t, emulator_remove, em);
 
 	return em;
 }
diff --git a/src/ofono.h b/src/ofono.h
index dbe1862..f52356e 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -129,6 +129,7 @@ enum ofono_atom_type {
 	OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER,
 	OFONO_ATOM_TYPE_SIM_AUTH,
 	OFONO_ATOM_TYPE_EMULATOR_DUN,
+	OFONO_ATOM_TYPE_EMULATOR_HFP,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1


  parent reply	other threads:[~2011-02-15 15:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-15 15:06 [PATCH 0/3] bluetooth: add HFP AG plugin =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-15 15:06 ` [PATCH 1/3] " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-15 17:10   ` Gustavo F. Padovan
2011-02-16  6:24   ` Denis Kenzior
2011-02-15 15:06 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis [this message]
2011-02-16  6:25   ` [PATCH 2/3] emulator: add HFP emulator type Denis Kenzior
2011-02-15 15:06 ` [PATCH 3/3] emulator: add +CIND support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1297782393-9898-3-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox