All of lore.kernel.org
 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] emulator: fix indicator notification
Date: Wed, 27 Jul 2011 17:12:15 +0200	[thread overview]
Message-ID: <1311779535-13909-1-git-send-email-frederic.danis@linux.intel.com> (raw)

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

unsollicited event can not occurs during a command, so defer indicator
notification after 'final' has been sent
---
 src/emulator.c  |   50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 src/voicecall.c |   11 -----------
 2 files changed, 48 insertions(+), 13 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index deb4780..2edddfe 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -52,6 +52,8 @@ struct ofono_emulator {
 	gboolean clip;
 	gboolean ccwa;
 	int pns_id;
+	gboolean inprogress;
+	guint deferred_source;
 };
 
 struct indicator {
@@ -59,6 +61,7 @@ struct indicator {
 	int value;
 	int min;
 	int max;
+	gboolean deferred;
 };
 
 static void emulator_debug(const char *str, void *data)
@@ -345,6 +348,35 @@ static struct ofono_call *find_call_with_status(struct ofono_emulator *em,
 	return __ofono_voicecall_find_call_with_status(vc, status);
 }
 
+static gboolean notify_deferred_indicators(void *user_data)
+{
+	struct ofono_emulator *em = user_data;
+	int i = 0;
+	char buf[20];
+	GSList *l;
+	struct indicator *ind;
+
+	if (em->events_mode != 3 || !em->events_ind || !em->slc)
+		goto end;
+
+	for (l = em->indicators; l; l = l->next) {
+		ind = l->data;
+
+		if (ind->deferred) {
+			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
+			g_at_server_send_unsolicited(em->server, buf);
+			ind->deferred = FALSE;
+		}
+
+		i++;
+	}
+
+end:
+	em->deferred_source = 0;
+
+	return FALSE;
+}
+
 static gboolean notify_ccwa(void *user_data)
 {
 	struct ofono_emulator *em = user_data;
@@ -790,6 +822,11 @@ static void emulator_unregister(struct ofono_atom *atom)
 		em->callsetup_source = 0;
 	}
 
+	if (em->deferred_source) {
+		g_source_remove(em->deferred_source);
+		em->deferred_source = 0;
+	}
+
 	for (l = em->indicators; l; l = l->next) {
 		struct indicator *ind = l->data;
 
@@ -961,6 +998,10 @@ failure:
 		g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
 		break;
 	};
+
+	em->inprogress = FALSE;
+	em->deferred_source = g_timeout_add_seconds(0,
+					notify_deferred_indicators, em);
 }
 
 void ofono_emulator_send_unsolicited(struct ofono_emulator *em,
@@ -1021,6 +1062,8 @@ static void handler_proxy(GAtServer *server, GAtServerRequestType type,
 	g_at_result_iter_init(&req.iter, result);
 	g_at_result_iter_next(&req.iter, "");
 
+	h->em->inprogress = TRUE;
+
 	h->cb(h->em, &req, h->data);
 }
 
@@ -1124,8 +1167,11 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 		notify_ccwa(em);
 
 	if (em->events_mode == 3 && em->events_ind && em->slc) {
-		sprintf(buf, "+CIEV: %d,%d", i, ind->value);
-		g_at_server_send_unsolicited(em->server, buf);
+		if (!em->inprogress) {
+			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
+			g_at_server_send_unsolicited(em->server, buf);
+		} else
+			ind->deferred = TRUE;
 	}
 
 	/*
diff --git a/src/voicecall.c b/src/voicecall.c
index 23976af..168ce96 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -700,9 +700,6 @@ static void emulator_call_status_cb(struct ofono_atom *atom, void *data)
 	struct ofono_emulator *em = __ofono_atom_get_data(atom);
 	struct emulator_status *s = data;
 
-	if (em == s->vc->pending_em)
-		return;
-
 	ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALL, s->status);
 }
 
@@ -711,9 +708,6 @@ static void emulator_callsetup_status_cb(struct ofono_atom *atom, void *data)
 	struct ofono_emulator *em = __ofono_atom_get_data(atom);
 	struct emulator_status *s = data;
 
-	if (em == s->vc->pending_em)
-		return;
-
 	ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
 					s->status);
 }
@@ -723,9 +717,6 @@ static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data)
 	struct ofono_emulator *em = __ofono_atom_get_data(atom);
 	struct emulator_status *s = data;
 
-	if (em == s->vc->pending_em)
-		return;
-
 	ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLHELD,
 					s->status);
 }
@@ -3210,8 +3201,6 @@ static void emulator_dial_callback(const struct ofono_error *error, void *data)
 
 	vc->pending_em = NULL;
 
-	notify_emulator_call_status(vc);
-
 	if (need_to_emit)
 		voicecalls_emit_call_added(vc, v);
 }
-- 
1.7.1


                 reply	other threads:[~2011-07-27 15:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1311779535-13909-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.