* [PATCH v2 0/8] *** SUBJECT HERE ***
@ 2011-04-07 16:33 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:33 ` [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (8 more replies)
0 siblings, 9 replies; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 661 bytes --]
*** BLURB HERE ***
Frédéric Danis (8):
emulator: add defines for call, callsetup and callheld indicators
emulator: add call, callsetup and callheld indicators
emulator: add RING for HFP AG
emulator: add incoming call API
emulator: add +CLIP support for HFP AG
voicecall: add ATA support for HFP emulator
voicecall: add +CHUP support for HFP emulator
emulator: add +CCWA support for HFP AG
include/emulator.h | 15 +++
src/emulator.c | 244 +++++++++++++++++++++++++++++++++++++++---
src/voicecall.c | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 552 insertions(+), 13 deletions(-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:33 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:57 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 2/8] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (7 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 843 bytes --]
---
include/emulator.h | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/include/emulator.h b/include/emulator.h
index 71b7c24..5cd894b 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -36,6 +36,18 @@ extern "C" {
#define OFONO_EMULATOR_IND_SERVICE "service"
#define OFONO_EMULATOR_IND_SIGNAL "signal"
+#define OFONO_EMULATOR_CALL_INACTIVE 0
+#define OFONO_EMULATOR_CALL_ACTIVE 1
+
+#define OFONO_EMULATOR_CALLSETUP_INACTIVE 0
+#define OFONO_EMULATOR_CALLSETUP_INCOMING 1
+#define OFONO_EMULATOR_CALLSETUP_OUTGOING 2
+#define OFONO_EMULATOR_CALLSETUP_ALERTING 3
+
+#define OFONO_EMULATOR_CALLHELD_NONE 0
+#define OFONO_EMULATOR_CALLHELD_MULTIPLE 1
+#define OFONO_EMULATOR_CALLHELD_ON_HOLD 2
+
struct ofono_emulator;
struct ofono_emulator_request;
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 2/8] emulator: add call, callsetup and callheld indicators
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:33 ` [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:33 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:57 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 3/8] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (6 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6256 bytes --]
---
src/emulator.c | 5 ++
src/voicecall.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 136 insertions(+), 0 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index c84f0a9..2707592 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -455,6 +455,11 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
if (em->type == OFONO_EMULATOR_TYPE_HFP) {
emulator_add_indicator(em, OFONO_EMULATOR_IND_SERVICE, 0, 1, 0);
+ emulator_add_indicator(em, OFONO_EMULATOR_IND_CALL, 0, 1, 0);
+ emulator_add_indicator(em, OFONO_EMULATOR_IND_CALLSETUP, 0, 3,
+ 0);
+ emulator_add_indicator(em, OFONO_EMULATOR_IND_CALLHELD, 0, 2,
+ 0);
emulator_add_indicator(em, OFONO_EMULATOR_IND_SIGNAL, 0, 5, 0);
emulator_add_indicator(em, OFONO_EMULATOR_IND_ROAMING, 0, 1, 0);
emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
diff --git a/src/voicecall.c b/src/voicecall.c
index 469b939..a3ea6de 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -59,6 +59,7 @@ struct ofono_voicecall {
struct dial_request *dial_req;
GQueue *toneq;
guint tone_source;
+ unsigned int hfp_watch;
};
struct voicecall {
@@ -689,6 +690,107 @@ static void voicecall_emit_multiparty(struct voicecall *call, gboolean mpty)
&val);
}
+static void emulator_call_status_cb(struct ofono_atom *atom, void *data)
+{
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+ ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALL,
+ GPOINTER_TO_INT(data));
+}
+
+static void emulator_callsetup_status_cb(struct ofono_atom *atom, void *data)
+{
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+ ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLSETUP,
+ GPOINTER_TO_INT(data));
+}
+
+static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data)
+{
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+ ofono_emulator_set_indicator(em, OFONO_EMULATOR_IND_CALLHELD,
+ GPOINTER_TO_INT(data));
+}
+
+static void notify_emulator_call_status(struct ofono_voicecall *vc)
+{
+ struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
+ int status;
+ gboolean call = FALSE;
+ gboolean held = FALSE;
+ gboolean incoming = FALSE;
+ gboolean dialing = FALSE;
+ gboolean alerting = FALSE;
+ gboolean waiting = FALSE;
+ GSList *l;
+ struct voicecall *v;
+
+ for (l = vc->call_list; l; l = l->next) {
+ v = l->data;
+
+ switch (v->call->status) {
+ case CALL_STATUS_ACTIVE:
+ call = TRUE;
+ break;
+
+ case CALL_STATUS_HELD:
+ held = TRUE;
+ break;
+
+ case CALL_STATUS_DIALING:
+ dialing = TRUE;
+ break;
+
+ case CALL_STATUS_ALERTING:
+ alerting = TRUE;
+ break;
+
+ case CALL_STATUS_INCOMING:
+ incoming = TRUE;
+ break;
+
+ case CALL_STATUS_WAITING:
+ waiting = TRUE;
+ break;
+ }
+ }
+
+ status = call || held ? OFONO_EMULATOR_CALL_ACTIVE :
+ OFONO_EMULATOR_CALL_INACTIVE;
+
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_call_status_cb,
+ GINT_TO_POINTER(status));
+
+ if (incoming || waiting)
+ status = OFONO_EMULATOR_CALLSETUP_INCOMING;
+ else if (dialing)
+ status = OFONO_EMULATOR_CALLSETUP_OUTGOING;
+ else if (alerting)
+ status = OFONO_EMULATOR_CALLSETUP_ALERTING;
+ else
+ status = OFONO_EMULATOR_CALLSETUP_INACTIVE;
+
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_callsetup_status_cb,
+ GINT_TO_POINTER(status));
+
+ if (held)
+ status = call ? OFONO_EMULATOR_CALLHELD_MULTIPLE :
+ OFONO_EMULATOR_CALLHELD_ON_HOLD;
+ else
+ status = OFONO_EMULATOR_CALLHELD_NONE;
+
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_callheld_status_cb,
+ GINT_TO_POINTER(status));
+}
+
static void voicecall_set_call_status(struct voicecall *call, int status)
{
DBusConnection *conn = ofono_dbus_get_connection();
@@ -711,6 +813,8 @@ static void voicecall_set_call_status(struct voicecall *call, int status)
"State", DBUS_TYPE_STRING,
&status_str);
+ notify_emulator_call_status(call->vc);
+
if (status == CALL_STATUS_ACTIVE &&
(old_status == CALL_STATUS_INCOMING ||
old_status == CALL_STATUS_DIALING ||
@@ -1040,6 +1144,8 @@ static void voicecalls_emit_call_added(struct ofono_voicecall *vc,
DBusMessageIter dict;
const char *path;
+ notify_emulator_call_status(vc);
+
path = __ofono_atom_get_path(vc->atom);
signal = dbus_message_new_signal(path,
@@ -2203,6 +2309,19 @@ static void voicecall_unregister(struct ofono_atom *atom)
const char *path = __ofono_atom_get_path(atom);
GSList *l;
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_call_status_cb, 0);
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_callsetup_status_cb,
+ 0);
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_callheld_status_cb, 0);
+
+ __ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
+
if (vc->sim_watch) {
__ofono_modem_remove_atom_watch(modem, vc->sim_watch);
vc->sim_watch = 0;
@@ -2378,6 +2497,14 @@ static void sim_watch(struct ofono_atom *atom,
sim_state_watch(ofono_sim_get_state(sim), vc);
}
+static void emulator_hfp_watch(struct ofono_atom *atom,
+ enum ofono_atom_watch_condition cond,
+ void *data)
+{
+ if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED)
+ notify_emulator_call_status(data);
+}
+
void ofono_voicecall_register(struct ofono_voicecall *vc)
{
DBusConnection *conn = ofono_dbus_get_connection();
@@ -2408,6 +2535,10 @@ void ofono_voicecall_register(struct ofono_voicecall *vc)
sim_watch, vc, NULL);
__ofono_atom_register(vc->atom, voicecall_unregister);
+
+ vc->hfp_watch = __ofono_modem_add_atom_watch(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_hfp_watch, vc, NULL);
}
void ofono_voicecall_remove(struct ofono_voicecall *vc)
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 3/8] emulator: add RING for HFP AG
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:33 ` [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:33 ` [PATCH v2 2/8] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:33 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:51 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 4/8] emulator: add incoming call API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (5 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3748 bytes --]
---
src/emulator.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 73 insertions(+), 13 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index 2707592..f1ccfb3 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -37,6 +37,8 @@
#define DUN_DNS_SERVER_1 "10.10.10.10"
#define DUN_DNS_SERVER_2 "10.10.10.11"
+#define RING_TIMEOUT 3
+
struct ofono_emulator {
struct ofono_atom *atom;
enum ofono_emulator_type type;
@@ -49,6 +51,7 @@ struct ofono_emulator {
int events_mode;
gboolean events_ind;
GSList *indicators;
+ guint ring;
};
struct indicator {
@@ -177,6 +180,42 @@ error:
g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
}
+static struct indicator *find_indicator(struct ofono_emulator *em,
+ const char *name, int *index)
+{
+ GSList *l;
+ int i;
+
+ for (i = 1, l = em->indicators; l; l = l->next, i++) {
+ struct indicator *ind = l->data;
+
+ if (g_str_equal(ind->name, name) == TRUE) {
+ if (index)
+ *index = i;
+
+ return ind;
+ }
+ }
+
+ return NULL;
+}
+
+static gboolean ring_cb(gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ struct indicator *call_ind;
+
+ if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE)
+ return TRUE;
+
+ call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
+
+ if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
+ g_at_server_send_unsolicited(em->server, "RING");
+
+ return TRUE;
+}
+
static void brsf_cb(GAtServer *server, GAtServerRequestType type,
GAtResult *result, gpointer user_data)
{
@@ -418,6 +457,11 @@ static void emulator_unregister(struct ofono_atom *atom)
em->source = 0;
}
+ if (em->ring) {
+ g_source_remove(em->ring);
+ em->ring = 0;
+ }
+
for (l = em->indicators; l; l = l->next) {
struct indicator *ind = l->data;
@@ -681,27 +725,43 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
void ofono_emulator_set_indicator(struct ofono_emulator *em,
const char *name, int value)
{
- GSList *l;
int i;
char buf[20];
+ struct indicator *ind;
+ struct indicator *call_ind;
- for (i = 1, l = em->indicators; l; l = l->next, i++) {
- struct indicator *ind = l->data;
+ ind = find_indicator(em, name, &i);
- if (g_str_equal(ind->name, name) == FALSE)
- continue;
+ if (ind == NULL || ind->value == value || value < ind->min
+ || value > ind->max)
+ return;
- if (ind->value == value || value < ind->min
- || value > ind->max)
- return;
+ ind->value = value;
- ind->value = value;
+ call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
- if (em->events_mode == 3 && em->events_ind && em->slc) {
- sprintf(buf, "+CIEV: %d,%d", i, ind->value);
- g_at_server_send_info(em->server, buf, TRUE);
- }
+ if (em->events_mode == 3 && em->events_ind && em->slc) {
+ sprintf(buf, "+CIEV: %d,%d", i, ind->value);
+ g_at_server_send_info(em->server, buf, TRUE);
+ }
+ /*
+ * Ring timer should be started when callsetup indicator is set to
+ * Incoming
+ * If there is no active call, a first RING should be sent just after
+ * the +CIEV
+ * It should be stopped for all other values of callsetup
+ */
+ if (g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP) == FALSE)
return;
+
+ if (value == OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring == 0) {
+ if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
+ ring_cb(em);
+
+ em->ring = g_timeout_add_seconds(RING_TIMEOUT, ring_cb, em);
+ } else if (value != OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) {
+ g_source_remove(em->ring);
+ em->ring = 0;
}
}
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 4/8] emulator: add incoming call API
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (2 preceding siblings ...)
2011-04-07 16:33 ` [PATCH v2 3/8] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:33 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:52 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 5/8] emulator: add +CLIP support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (4 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 564 bytes --]
---
include/emulator.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/include/emulator.h b/include/emulator.h
index 5cd894b..55e3b9c 100644
--- a/include/emulator.h
+++ b/include/emulator.h
@@ -105,6 +105,9 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
void ofono_emulator_set_indicator(struct ofono_emulator *em,
const char *name, int value);
+void ofono_emulator_incoming_call(struct ofono_emulator *em,
+ struct ofono_call *call);
+
#ifdef __cplusplus
}
#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 5/8] emulator: add +CLIP support for HFP AG
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (3 preceding siblings ...)
2011-04-07 16:33 ` [PATCH v2 4/8] emulator: add incoming call API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:33 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:56 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 6/8] voicecall: add ATA support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (3 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5648 bytes --]
---
src/emulator.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/voicecall.c | 17 +++++++++++-
2 files changed, 88 insertions(+), 3 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index f1ccfb3..7559d07 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -29,6 +29,7 @@
#include <glib.h>
#include "ofono.h"
+#include "common.h"
#include "gatserver.h"
#include "gatppp.h"
@@ -52,6 +53,13 @@ struct ofono_emulator {
gboolean events_ind;
GSList *indicators;
guint ring;
+ struct ofono_call *incoming;
+ gboolean clip;
+ /*
+ * '+CLIP: "+",' or '+CCWA: "+",' + phone number
+ * + phone type on 3 digits max + terminating null
+ */
+ char incoming_str[OFONO_MAX_PHONE_NUMBER_LENGTH + 14 + 1];
};
struct indicator {
@@ -200,6 +208,24 @@ static struct indicator *find_indicator(struct ofono_emulator *em,
return NULL;
}
+static void notify_ring(struct ofono_emulator *em)
+{
+ const char *phone;
+
+ g_at_server_send_unsolicited(em->server, "RING");
+
+ if (em->incoming &&
+ em->incoming->clip_validity == CLIP_VALIDITY_VALID &&
+ em->incoming_str[0] == '\0') {
+ phone = phone_number_to_string(&em->incoming->phone_number);
+ sprintf(em->incoming_str, "+CLIP: \"%s\",%d", phone,
+ em->incoming->phone_number.type);
+ }
+
+ if (em->clip && em->incoming_str[0] != '\0')
+ g_at_server_send_unsolicited(em->server, em->incoming_str);
+}
+
static gboolean ring_cb(gpointer user_data)
{
struct ofono_emulator *em = user_data;
@@ -211,7 +237,7 @@ static gboolean ring_cb(gpointer user_data)
call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
- g_at_server_send_unsolicited(em->server, "RING");
+ notify_ring(em);
return TRUE;
}
@@ -426,6 +452,42 @@ fail:
}
}
+static void clip_cb(GAtServer *server, GAtServerRequestType type,
+ GAtResult *result, gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ GAtResultIter iter;
+ int val;
+
+ if (em->slc == FALSE)
+ goto fail;
+
+ switch (type) {
+ case G_AT_SERVER_REQUEST_TYPE_SET:
+ g_at_result_iter_init(&iter, result);
+ g_at_result_iter_next(&iter, "");
+
+ if (!g_at_result_iter_next_number(&iter, &val))
+ goto fail;
+
+ if (val != 0 && val != 1)
+ goto fail;
+
+ /* check this is last parameter */
+ if (g_at_result_iter_skip_next(&iter))
+ goto fail;
+
+ em->clip = val;
+
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ default:
+fail:
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+ };
+}
+
static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
int min, int max, int dflt)
{
@@ -511,6 +573,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
+ g_at_server_register(em->server, "+CLIP", clip_cb, em, NULL);
}
__ofono_atom_register(em->atom, emulator_unregister);
@@ -554,6 +617,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
/* TODO: Check real local features */
em->l_features = 32;
em->events_mode = 3; /* default mode is forwarding events */
+ em->incoming_str[0] = '\0';
em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
emulator_remove, em);
@@ -763,5 +827,13 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
} else if (value != OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) {
g_source_remove(em->ring);
em->ring = 0;
+ em->incoming = NULL;
+ em->incoming_str[0] = '\0';
}
}
+
+void ofono_emulator_incoming_call(struct ofono_emulator *em,
+ struct ofono_call *call)
+{
+ em->incoming = call;
+}
diff --git a/src/voicecall.c b/src/voicecall.c
index a3ea6de..8e68243 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -714,6 +714,13 @@ static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data)
GPOINTER_TO_INT(data));
}
+static void emulator_incoming_cb(struct ofono_atom *atom, void *data)
+{
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+ ofono_emulator_incoming_call(em, data);
+}
+
static void notify_emulator_call_status(struct ofono_voicecall *vc)
{
struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
@@ -726,6 +733,7 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
gboolean waiting = FALSE;
GSList *l;
struct voicecall *v;
+ struct ofono_call *caller = NULL;
for (l = vc->call_list; l; l = l->next) {
v = l->data;
@@ -749,10 +757,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
case CALL_STATUS_INCOMING:
incoming = TRUE;
+ caller = v->call;
break;
case CALL_STATUS_WAITING:
waiting = TRUE;
+ caller = v->call;
break;
}
}
@@ -765,9 +775,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
emulator_call_status_cb,
GINT_TO_POINTER(status));
- if (incoming || waiting)
+ if (incoming || waiting) {
status = OFONO_EMULATOR_CALLSETUP_INCOMING;
- else if (dialing)
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_incoming_cb, caller);
+ } else if (dialing)
status = OFONO_EMULATOR_CALLSETUP_OUTGOING;
else if (alerting)
status = OFONO_EMULATOR_CALLSETUP_ALERTING;
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 6/8] voicecall: add ATA support for HFP emulator
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (4 preceding siblings ...)
2011-04-07 16:33 ` [PATCH v2 5/8] emulator: add +CLIP support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:33 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 16:00 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 7/8] voicecall: add +CHUP " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (2 subsequent siblings)
8 siblings, 1 reply; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2649 bytes --]
---
src/voicecall.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/src/voicecall.c b/src/voicecall.c
index 8e68243..cf02bb6 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2314,6 +2314,13 @@ void ofono_voicecall_driver_unregister(const struct ofono_voicecall_driver *d)
g_drivers = g_slist_remove(g_drivers, (void *) d);
}
+static void emulator_remove_handler(struct ofono_atom *atom, void *data)
+{
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+ ofono_emulator_remove_handler(em, data);
+}
+
static void voicecall_unregister(struct ofono_atom *atom)
{
DBusConnection *conn = ofono_dbus_get_connection();
@@ -2333,6 +2340,11 @@ static void voicecall_unregister(struct ofono_atom *atom)
OFONO_ATOM_TYPE_EMULATOR_HFP,
emulator_callheld_status_cb, 0);
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_remove_handler,
+ "A");
+
__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
if (vc->sim_watch) {
@@ -2510,12 +2522,54 @@ static void sim_watch(struct ofono_atom *atom,
sim_state_watch(ofono_sim_get_state(sim), vc);
}
+static void emulator_generic_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_emulator *em = data;
+ struct ofono_error result;
+
+ result.type = error->type;
+
+ ofono_emulator_send_final(em, &result);
+}
+
+static void emulator_ata_cb(struct ofono_emulator *em,
+ struct ofono_emulator_request *req, void *userdata)
+{
+ struct ofono_voicecall *vc = userdata;
+ struct ofono_error result;
+
+ result.error = 0;
+
+ switch (ofono_emulator_request_get_type(req)) {
+ case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
+ if (!voicecalls_have_incoming(vc))
+ goto fail;
+
+ if (vc->driver->answer == NULL)
+ goto fail;
+
+ vc->driver->answer(vc, emulator_generic_cb, em);
+ break;
+
+ default:
+fail:
+ result.type = OFONO_ERROR_TYPE_FAILURE;
+ ofono_emulator_send_final(em, &result);
+ };
+}
+
static void emulator_hfp_watch(struct ofono_atom *atom,
enum ofono_atom_watch_condition cond,
void *data)
{
- if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED)
- notify_emulator_call_status(data);
+ struct ofono_emulator *em = __ofono_atom_get_data(atom);
+
+ if (cond != OFONO_ATOM_WATCH_CONDITION_REGISTERED)
+ return;
+
+ notify_emulator_call_status(data);
+
+ ofono_emulator_add_handler(em, "A", emulator_ata_cb, data, NULL);
}
void ofono_voicecall_register(struct ofono_voicecall *vc)
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 7/8] voicecall: add +CHUP support for HFP emulator
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (5 preceding siblings ...)
2011-04-07 16:33 ` [PATCH v2 6/8] voicecall: add ATA support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:33 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 16:13 ` Denis Kenzior
2011-04-07 16:34 ` [PATCH v2 8/8] emulator: add +CCWA support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:39 ` [PATCH v2 0/8] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
8 siblings, 1 reply; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4316 bytes --]
---
src/voicecall.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/src/voicecall.c b/src/voicecall.c
index cf02bb6..8aec0a0 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -60,6 +60,7 @@ struct ofono_voicecall {
GQueue *toneq;
guint tone_source;
unsigned int hfp_watch;
+ GSList *hfp_release_list;
};
struct voicecall {
@@ -95,6 +96,11 @@ struct tone_queue_entry {
int id;
};
+struct emulator_release {
+ struct ofono_voicecall *vc;
+ struct ofono_emulator *em;
+};
+
static const char *default_en_list[] = { "911", "112", NULL };
static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
"08", "000", NULL };
@@ -102,6 +108,7 @@ static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
static void generic_callback(const struct ofono_error *error, void *data);
static void multirelease_callback(const struct ofono_error *err, void *data);
static gboolean tone_request_run(gpointer user_data);
+static void emulator_release_next(struct emulator_release *er);
static gint call_compare_by_id(gconstpointer a, gconstpointer b)
{
@@ -2344,6 +2351,10 @@ static void voicecall_unregister(struct ofono_atom *atom)
OFONO_ATOM_TYPE_EMULATOR_HFP,
emulator_remove_handler,
"A");
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_remove_handler,
+ "+CHUP");
__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
@@ -2558,6 +2569,102 @@ fail:
};
}
+static void emulator_multirelease_callback(const struct ofono_error *error,
+ void *data)
+{
+ struct emulator_release *er = data;
+ struct ofono_voicecall *vc = er->vc;
+
+ if (vc->hfp_release_list != NULL) {
+ emulator_release_next(er);
+ return;
+ }
+
+ emulator_generic_cb(error, er->em);
+
+ g_free(er);
+}
+
+static void emulator_release_next(struct emulator_release *er)
+{
+ struct ofono_voicecall *vc;
+ struct voicecall *call;
+
+ vc = er->vc;
+
+ call = vc->hfp_release_list->data;
+
+ vc->hfp_release_list = g_slist_remove(vc->hfp_release_list, call);
+
+ vc->driver->release_specific(vc, call->call->id,
+ emulator_multirelease_callback, er);
+}
+
+static void emulator_chup_cb(struct ofono_emulator *em,
+ struct ofono_emulator_request *req, void *userdata)
+{
+ struct ofono_voicecall *vc = userdata;
+ struct ofono_error result;
+ struct emulator_release *er;
+ GSList *l;
+ struct voicecall *call;
+
+ result.error = 0;
+
+ switch (ofono_emulator_request_get_type(req)) {
+ case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
+ if (vc->driver->release_specific == NULL &&
+ vc->driver->hangup_active == NULL)
+ goto fail;
+
+ if (vc->driver->hangup_active) {
+ vc->driver->hangup_active(vc, emulator_generic_cb, em);
+ goto done;
+ }
+
+ /* if there is already a CHUP pending we return an error */
+ if (vc->hfp_release_list)
+ goto fail;
+
+ er = g_try_new0(struct emulator_release, 1);
+ if (er == NULL) {
+ ofono_error("Unable to allocate release structure");
+ goto fail;
+ }
+
+ er->vc = vc;
+ er->em = em;
+
+ for (l = vc->call_list; l; l = l->next) {
+ call = l->data;
+
+ if (call->call->status == CALL_STATUS_WAITING ||
+ call->call->status == CALL_STATUS_HELD)
+ continue;
+
+ vc->hfp_release_list = g_slist_prepend(
+ vc->hfp_release_list,
+ l->data);
+ }
+
+ if (vc->hfp_release_list == NULL) {
+ g_free(er);
+ goto fail;
+ }
+
+ emulator_release_next(er);
+
+done:
+ dial_request_user_cancel(vc, NULL);
+ break;
+
+ default:
+fail:
+ result.type = OFONO_ERROR_TYPE_FAILURE;
+ ofono_emulator_send_final(em, &result);
+ };
+}
+
static void emulator_hfp_watch(struct ofono_atom *atom,
enum ofono_atom_watch_condition cond,
void *data)
@@ -2570,6 +2677,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
notify_emulator_call_status(data);
ofono_emulator_add_handler(em, "A", emulator_ata_cb, data, NULL);
+ ofono_emulator_add_handler(em, "+CHUP", emulator_chup_cb, data, NULL);
}
void ofono_voicecall_register(struct ofono_voicecall *vc)
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 8/8] emulator: add +CCWA support for HFP AG
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (6 preceding siblings ...)
2011-04-07 16:33 ` [PATCH v2 7/8] voicecall: add +CHUP " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:34 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:39 ` [PATCH v2 0/8] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
8 siblings, 0 replies; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4337 bytes --]
---
src/emulator.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 82 insertions(+), 1 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index 7559d07..00588b5 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -60,6 +60,7 @@ struct ofono_emulator {
* + phone type on 3 digits max + terminating null
*/
char incoming_str[OFONO_MAX_PHONE_NUMBER_LENGTH + 14 + 1];
+ gboolean ccwa;
};
struct indicator {
@@ -208,6 +209,28 @@ static struct indicator *find_indicator(struct ofono_emulator *em,
return NULL;
}
+static void notify_ccwa(struct ofono_emulator *em)
+{
+ const char *phone;
+
+ if (em->incoming &&
+ em->incoming->clip_validity == CLIP_VALIDITY_VALID &&
+ em->incoming_str[0] == '\0') {
+ phone = phone_number_to_string(&em->incoming->phone_number);
+ sprintf(em->incoming_str, "+CCWA: \"%s\",%d", phone,
+ em->incoming->phone_number.type);
+ }
+
+ if (em->ccwa) {
+ if (em->incoming_str[0] == '\0')
+ g_at_server_send_unsolicited(em->server,
+ "+CCWA: \"\",128");
+ else
+ g_at_server_send_unsolicited(em->server,
+ em->incoming_str);
+ }
+}
+
static void notify_ring(struct ofono_emulator *em)
{
const char *phone;
@@ -238,6 +261,8 @@ static gboolean ring_cb(gpointer user_data)
if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
notify_ring(em);
+ else
+ notify_ccwa(em);
return TRUE;
}
@@ -488,6 +513,42 @@ fail:
};
}
+static void ccwa_cb(GAtServer *server, GAtServerRequestType type,
+ GAtResult *result, gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ GAtResultIter iter;
+ int val;
+
+ if (em->slc == FALSE)
+ goto fail;
+
+ switch (type) {
+ case G_AT_SERVER_REQUEST_TYPE_SET:
+ g_at_result_iter_init(&iter, result);
+ g_at_result_iter_next(&iter, "");
+
+ if (!g_at_result_iter_next_number(&iter, &val))
+ goto fail;
+
+ if (val != 0 && val != 1)
+ goto fail;
+
+ /* check this is last parameter */
+ if (g_at_result_iter_skip_next(&iter))
+ goto fail;
+
+ em->ccwa = val;
+
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ default:
+fail:
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+ };
+}
+
static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
int min, int max, int dflt)
{
@@ -574,6 +635,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
g_at_server_register(em->server, "+CLIP", clip_cb, em, NULL);
+ g_at_server_register(em->server, "+CCWA", ccwa_cb, em, NULL);
}
__ofono_atom_register(em->atom, emulator_unregister);
@@ -793,6 +855,7 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
char buf[20];
struct indicator *ind;
struct indicator *call_ind;
+ gboolean callsetup;
ind = find_indicator(em, name, &i);
@@ -802,8 +865,26 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
ind->value = value;
+ /*
+ * When call indicator goes to inactive, force to re-generate
+ * incoming call (+CLIP or +CCWA) string
+ */
+ if (g_str_equal(name, OFONO_EMULATOR_IND_CALL) == TRUE &&
+ value == OFONO_EMULATOR_CALL_INACTIVE)
+ em->incoming_str[0] = '\0';
+
call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
+ callsetup = g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP);
+
+ /*
+ * When callsetup indicator goes to Incoming and there is an active call
+ * a +CCWA should be sent before +CIEV
+ */
+ if (callsetup && value == OFONO_EMULATOR_CALLSETUP_INCOMING &&
+ call_ind->value == OFONO_EMULATOR_CALL_ACTIVE)
+ ring_cb(em);
+
if (em->events_mode == 3 && em->events_ind && em->slc) {
sprintf(buf, "+CIEV: %d,%d", i, ind->value);
g_at_server_send_info(em->server, buf, TRUE);
@@ -816,7 +897,7 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
* the +CIEV
* It should be stopped for all other values of callsetup
*/
- if (g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP) == FALSE)
+ if (!callsetup)
return;
if (value == OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring == 0) {
--
1.7.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 0/8] emulator: add simple incoming call support
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
` (7 preceding siblings ...)
2011-04-07 16:34 ` [PATCH v2 8/8] emulator: add +CCWA support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-07 16:39 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
8 siblings, 0 replies; 20+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-04-07 16:39 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 802 bytes --]
Add call related indicators, +CLIP, +CCWA, RING to signal incoming call,
ATA to allow reception and AT+CHUP to reject or finish
of an incoming call in HFP AG
Frédéric Danis (8):
emulator: add defines for call, callsetup and callheld indicators
emulator: add call, callsetup and callheld indicators
emulator: add RING for HFP AG
emulator: add incoming call API
emulator: add +CLIP support for HFP AG
voicecall: add ATA support for HFP emulator
voicecall: add +CHUP support for HFP emulator
emulator: add +CCWA support for HFP AG
include/emulator.h | 15 +++
src/emulator.c | 244 +++++++++++++++++++++++++++++++++++++++---
src/voicecall.c | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 552 insertions(+), 13 deletions(-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/8] emulator: add RING for HFP AG
2011-04-07 16:33 ` [PATCH v2 3/8] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-11 15:51 ` Denis Kenzior
2011-04-11 16:09 ` Frederic Danis
0 siblings, 1 reply; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 15:51 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4697 bytes --]
Hi Frédéric,
On 04/07/2011 11:33 AM, Frédéric Danis wrote:
> ---
> src/emulator.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--------
> 1 files changed, 73 insertions(+), 13 deletions(-)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index 2707592..f1ccfb3 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -37,6 +37,8 @@
> #define DUN_DNS_SERVER_1 "10.10.10.10"
> #define DUN_DNS_SERVER_2 "10.10.10.11"
>
> +#define RING_TIMEOUT 3
> +
> struct ofono_emulator {
> struct ofono_atom *atom;
> enum ofono_emulator_type type;
> @@ -49,6 +51,7 @@ struct ofono_emulator {
> int events_mode;
> gboolean events_ind;
> GSList *indicators;
> + guint ring;
Please name this callsetup_source.
> };
>
> struct indicator {
> @@ -177,6 +180,42 @@ error:
> g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
> }
>
> +static struct indicator *find_indicator(struct ofono_emulator *em,
> + const char *name, int *index)
> +{
> + GSList *l;
> + int i;
> +
> + for (i = 1, l = em->indicators; l; l = l->next, i++) {
> + struct indicator *ind = l->data;
> +
> + if (g_str_equal(ind->name, name) == TRUE) {
> + if (index)
> + *index = i;
> +
> + return ind;
> + }
To avoid nesting, this might be better written as:
if (g_str_equal(ind->name, name) == FALSE)
continue;
if (index)
...
> + }
> +
> + return NULL;
> +}
> +
> +static gboolean ring_cb(gpointer user_data)
Please name this something like: send_callsetup_indicators
> +{
> + struct ofono_emulator *em = user_data;
> + struct indicator *call_ind;
> +
> + if (em->type == OFONO_EMULATOR_TYPE_HFP && em->slc == FALSE)
> + return TRUE;
> +
> + call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
> +
> + if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
> + g_at_server_send_unsolicited(em->server, "RING");
> +
> + return TRUE;
> +}
> +
> static void brsf_cb(GAtServer *server, GAtServerRequestType type,
> GAtResult *result, gpointer user_data)
> {
> @@ -418,6 +457,11 @@ static void emulator_unregister(struct ofono_atom *atom)
> em->source = 0;
> }
>
> + if (em->ring) {
> + g_source_remove(em->ring);
> + em->ring = 0;
> + }
> +
> for (l = em->indicators; l; l = l->next) {
> struct indicator *ind = l->data;
>
> @@ -681,27 +725,43 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
> void ofono_emulator_set_indicator(struct ofono_emulator *em,
> const char *name, int value)
> {
> - GSList *l;
> int i;
> char buf[20];
> + struct indicator *ind;
> + struct indicator *call_ind;
>
> - for (i = 1, l = em->indicators; l; l = l->next, i++) {
> - struct indicator *ind = l->data;
> + ind = find_indicator(em, name, &i);
>
> - if (g_str_equal(ind->name, name) == FALSE)
> - continue;
> + if (ind == NULL || ind->value == value || value < ind->min
> + || value > ind->max)
> + return;
>
> - if (ind->value == value || value < ind->min
> - || value > ind->max)
> - return;
> + ind->value = value;
>
> - ind->value = value;
> + call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
>
> - if (em->events_mode == 3 && em->events_ind && em->slc) {
> - sprintf(buf, "+CIEV: %d,%d", i, ind->value);
> - g_at_server_send_info(em->server, buf, TRUE);
> - }
> + if (em->events_mode == 3 && em->events_ind && em->slc) {
> + sprintf(buf, "+CIEV: %d,%d", i, ind->value);
> + g_at_server_send_info(em->server, buf, TRUE);
Reminds me, this should be g_at_server_send_unsolicited
> + }
>
> + /*
> + * Ring timer should be started when callsetup indicator is set to
> + * Incoming
> + * If there is no active call, a first RING should be sent just after
> + * the +CIEV
> + * It should be stopped for all other values of callsetup
> + */
> + if (g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP) == FALSE)
> return;
> +
> + if (value == OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring == 0) {
> + if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
> + ring_cb(em);
> +
> + em->ring = g_timeout_add_seconds(RING_TIMEOUT, ring_cb, em);
> + } else if (value != OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) {
> + g_source_remove(em->ring);
> + em->ring = 0;
Do you really need to check for em->ring here? You already return if
the value of the indicator is already the same. Also, it sounds like
you should just start a timer and always call ring_cb when callsetup ==
callsetup_incoming. The CCWA/RING determination should be done in that
function.
> }
> }
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 4/8] emulator: add incoming call API
2011-04-07 16:33 ` [PATCH v2 4/8] emulator: add incoming call API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-11 15:52 ` Denis Kenzior
0 siblings, 0 replies; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 15:52 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 841 bytes --]
Hi Frédéric,
On 04/07/2011 11:33 AM, Frédéric Danis wrote:
> ---
> include/emulator.h | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/include/emulator.h b/include/emulator.h
> index 5cd894b..55e3b9c 100644
> --- a/include/emulator.h
> +++ b/include/emulator.h
> @@ -105,6 +105,9 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
> void ofono_emulator_set_indicator(struct ofono_emulator *em,
> const char *name, int value);
>
> +void ofono_emulator_incoming_call(struct ofono_emulator *em,
> + struct ofono_call *call);
> +
I don't like this. I'd rather we add
struct ofono_call *__ofono_voicecall_find_call_with_status(struct
ofono_voicecall *vc, int status) to ofono.h/voiecall.c
> #ifdef __cplusplus
> }
> #endif
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 5/8] emulator: add +CLIP support for HFP AG
2011-04-07 16:33 ` [PATCH v2 5/8] emulator: add +CLIP support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-11 15:56 ` Denis Kenzior
0 siblings, 0 replies; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 15:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6294 bytes --]
Hi Frédéric,
On 04/07/2011 11:33 AM, Frédéric Danis wrote:
> ---
> src/emulator.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> src/voicecall.c | 17 +++++++++++-
> 2 files changed, 88 insertions(+), 3 deletions(-)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index f1ccfb3..7559d07 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -29,6 +29,7 @@
> #include <glib.h>
>
> #include "ofono.h"
> +#include "common.h"
> #include "gatserver.h"
> #include "gatppp.h"
>
> @@ -52,6 +53,13 @@ struct ofono_emulator {
> gboolean events_ind;
> GSList *indicators;
> guint ring;
> + struct ofono_call *incoming;
> + gboolean clip;
> + /*
> + * '+CLIP: "+",' or '+CCWA: "+",' + phone number
> + * + phone type on 3 digits max + terminating null
> + */
> + char incoming_str[OFONO_MAX_PHONE_NUMBER_LENGTH + 14 + 1];
You can probably get rid of incoming_str and incoming if you use
__ofono_voicecall_find_call_with_type...
> };
>
> struct indicator {
> @@ -200,6 +208,24 @@ static struct indicator *find_indicator(struct ofono_emulator *em,
> return NULL;
> }
>
> +static void notify_ring(struct ofono_emulator *em)
> +{
> + const char *phone;
> +
> + g_at_server_send_unsolicited(em->server, "RING");
> +
> + if (em->incoming &&
> + em->incoming->clip_validity == CLIP_VALIDITY_VALID &&
> + em->incoming_str[0] == '\0') {
> + phone = phone_number_to_string(&em->incoming->phone_number);
> + sprintf(em->incoming_str, "+CLIP: \"%s\",%d", phone,
> + em->incoming->phone_number.type);
> + }
> +
> + if (em->clip && em->incoming_str[0] != '\0')
> + g_at_server_send_unsolicited(em->server, em->incoming_str);
Keep this simple, I really wouldn't try to optimize a strcpy operation.
> +}
> +
> static gboolean ring_cb(gpointer user_data)
> {
> struct ofono_emulator *em = user_data;
> @@ -211,7 +237,7 @@ static gboolean ring_cb(gpointer user_data)
> call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
>
> if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
> - g_at_server_send_unsolicited(em->server, "RING");
> + notify_ring(em);
>
> return TRUE;
> }
> @@ -426,6 +452,42 @@ fail:
> }
> }
>
> +static void clip_cb(GAtServer *server, GAtServerRequestType type,
> + GAtResult *result, gpointer user_data)
> +{
> + struct ofono_emulator *em = user_data;
> + GAtResultIter iter;
> + int val;
> +
> + if (em->slc == FALSE)
> + goto fail;
> +
> + switch (type) {
> + case G_AT_SERVER_REQUEST_TYPE_SET:
> + g_at_result_iter_init(&iter, result);
> + g_at_result_iter_next(&iter, "");
> +
> + if (!g_at_result_iter_next_number(&iter, &val))
> + goto fail;
> +
> + if (val != 0 && val != 1)
> + goto fail;
> +
> + /* check this is last parameter */
> + if (g_at_result_iter_skip_next(&iter))
> + goto fail;
> +
> + em->clip = val;
> +
> + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> + break;
> +
> + default:
> +fail:
> + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
> + };
> +}
> +
> static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
> int min, int max, int dflt)
> {
> @@ -511,6 +573,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
> g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
> g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
> g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
> + g_at_server_register(em->server, "+CLIP", clip_cb, em, NULL);
> }
>
> __ofono_atom_register(em->atom, emulator_unregister);
> @@ -554,6 +617,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
> /* TODO: Check real local features */
> em->l_features = 32;
> em->events_mode = 3; /* default mode is forwarding events */
> + em->incoming_str[0] = '\0';
>
> em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
> emulator_remove, em);
> @@ -763,5 +827,13 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
> } else if (value != OFONO_EMULATOR_CALLSETUP_INCOMING && em->ring) {
> g_source_remove(em->ring);
> em->ring = 0;
> + em->incoming = NULL;
> + em->incoming_str[0] = '\0';
> }
> }
> +
> +void ofono_emulator_incoming_call(struct ofono_emulator *em,
> + struct ofono_call *call)
> +{
> + em->incoming = call;
> +}
> diff --git a/src/voicecall.c b/src/voicecall.c
> index a3ea6de..8e68243 100644
> --- a/src/voicecall.c
> +++ b/src/voicecall.c
> @@ -714,6 +714,13 @@ static void emulator_callheld_status_cb(struct ofono_atom *atom, void *data)
> GPOINTER_TO_INT(data));
> }
>
> +static void emulator_incoming_cb(struct ofono_atom *atom, void *data)
> +{
> + struct ofono_emulator *em = __ofono_atom_get_data(atom);
> +
> + ofono_emulator_incoming_call(em, data);
> +}
> +
> static void notify_emulator_call_status(struct ofono_voicecall *vc)
> {
> struct ofono_modem *modem = __ofono_atom_get_modem(vc->atom);
> @@ -726,6 +733,7 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
> gboolean waiting = FALSE;
> GSList *l;
> struct voicecall *v;
> + struct ofono_call *caller = NULL;
>
> for (l = vc->call_list; l; l = l->next) {
> v = l->data;
> @@ -749,10 +757,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
>
> case CALL_STATUS_INCOMING:
> incoming = TRUE;
> + caller = v->call;
> break;
>
> case CALL_STATUS_WAITING:
> waiting = TRUE;
> + caller = v->call;
> break;
> }
> }
> @@ -765,9 +775,12 @@ static void notify_emulator_call_status(struct ofono_voicecall *vc)
> emulator_call_status_cb,
> GINT_TO_POINTER(status));
>
> - if (incoming || waiting)
> + if (incoming || waiting) {
> status = OFONO_EMULATOR_CALLSETUP_INCOMING;
> - else if (dialing)
> + __ofono_modem_foreach_registered_atom(modem,
> + OFONO_ATOM_TYPE_EMULATOR_HFP,
> + emulator_incoming_cb, caller);
> + } else if (dialing)
> status = OFONO_EMULATOR_CALLSETUP_OUTGOING;
> else if (alerting)
> status = OFONO_EMULATOR_CALLSETUP_ALERTING;
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators
2011-04-07 16:33 ` [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-11 15:57 ` Denis Kenzior
0 siblings, 0 replies; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 15:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
Hi Frédéric,
On 04/07/2011 11:33 AM, Frédéric Danis wrote:
> ---
> include/emulator.h | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
>
This patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 2/8] emulator: add call, callsetup and callheld indicators
2011-04-07 16:33 ` [PATCH v2 2/8] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-11 15:57 ` Denis Kenzior
0 siblings, 0 replies; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 15:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
Hi Frédéric,
On 04/07/2011 11:33 AM, Frédéric Danis wrote:
> ---
> src/emulator.c | 5 ++
> src/voicecall.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 136 insertions(+), 0 deletions(-)
>
I broke this patch up into two and applied it. Thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 6/8] voicecall: add ATA support for HFP emulator
2011-04-07 16:33 ` [PATCH v2 6/8] voicecall: add ATA support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-11 16:00 ` Denis Kenzior
0 siblings, 0 replies; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 16:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3184 bytes --]
Hi Frédéric,
On 04/07/2011 11:33 AM, Frédéric Danis wrote:
> ---
> src/voicecall.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 56 insertions(+), 2 deletions(-)
>
> diff --git a/src/voicecall.c b/src/voicecall.c
> index 8e68243..cf02bb6 100644
> --- a/src/voicecall.c
> +++ b/src/voicecall.c
> @@ -2314,6 +2314,13 @@ void ofono_voicecall_driver_unregister(const struct ofono_voicecall_driver *d)
> g_drivers = g_slist_remove(g_drivers, (void *) d);
> }
>
> +static void emulator_remove_handler(struct ofono_atom *atom, void *data)
> +{
> + struct ofono_emulator *em = __ofono_atom_get_data(atom);
> +
> + ofono_emulator_remove_handler(em, data);
> +}
> +
> static void voicecall_unregister(struct ofono_atom *atom)
> {
> DBusConnection *conn = ofono_dbus_get_connection();
> @@ -2333,6 +2340,11 @@ static void voicecall_unregister(struct ofono_atom *atom)
> OFONO_ATOM_TYPE_EMULATOR_HFP,
> emulator_callheld_status_cb, 0);
>
> + __ofono_modem_foreach_registered_atom(modem,
> + OFONO_ATOM_TYPE_EMULATOR_HFP,
> + emulator_remove_handler,
> + "A");
> +
Can you move this into its own function, e.g.
unregister_emulator_handlers or something like that. There will be lots
of these and I don't want to clutter up voicecall_unregister too much.
> __ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
>
> if (vc->sim_watch) {
> @@ -2510,12 +2522,54 @@ static void sim_watch(struct ofono_atom *atom,
> sim_state_watch(ofono_sim_get_state(sim), vc);
> }
>
> +static void emulator_generic_cb(const struct ofono_error *error, void *data)
> +{
> + struct ofono_emulator *em = data;
> + struct ofono_error result;
> +
> + result.type = error->type;
> +
> + ofono_emulator_send_final(em, &result);
> +}
> +
> +static void emulator_ata_cb(struct ofono_emulator *em,
> + struct ofono_emulator_request *req, void *userdata)
> +{
> + struct ofono_voicecall *vc = userdata;
> + struct ofono_error result;
> +
> + result.error = 0;
> +
> + switch (ofono_emulator_request_get_type(req)) {
> + case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
> + if (!voicecalls_have_incoming(vc))
> + goto fail;
> +
> + if (vc->driver->answer == NULL)
> + goto fail;
> +
> + vc->driver->answer(vc, emulator_generic_cb, em);
> + break;
> +
> + default:
> +fail:
> + result.type = OFONO_ERROR_TYPE_FAILURE;
> + ofono_emulator_send_final(em, &result);
> + };
> +}
> +
> static void emulator_hfp_watch(struct ofono_atom *atom,
> enum ofono_atom_watch_condition cond,
> void *data)
> {
> - if (cond == OFONO_ATOM_WATCH_CONDITION_REGISTERED)
> - notify_emulator_call_status(data);
> + struct ofono_emulator *em = __ofono_atom_get_data(atom);
> +
> + if (cond != OFONO_ATOM_WATCH_CONDITION_REGISTERED)
> + return;
> +
> + notify_emulator_call_status(data);
> +
> + ofono_emulator_add_handler(em, "A", emulator_ata_cb, data, NULL);
> }
>
> void ofono_voicecall_register(struct ofono_voicecall *vc)
Otherwise looks good, but does not apply. Could you please rebase &
resubmit?
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/8] emulator: add RING for HFP AG
2011-04-11 15:51 ` Denis Kenzior
@ 2011-04-11 16:09 ` Frederic Danis
0 siblings, 0 replies; 20+ messages in thread
From: Frederic Danis @ 2011-04-11 16:09 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5922 bytes --]
Hello Denis,
Le 11/04/2011 17:51, Denis Kenzior a écrit :
> Hi Frédéric,
>
> On 04/07/2011 11:33 AM, Frédéric Danis wrote:
>> ---
>> src/emulator.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--------
>> 1 files changed, 73 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/emulator.c b/src/emulator.c
>> index 2707592..f1ccfb3 100644
>> --- a/src/emulator.c
>> +++ b/src/emulator.c
>> @@ -37,6 +37,8 @@
>> #define DUN_DNS_SERVER_1 "10.10.10.10"
>> #define DUN_DNS_SERVER_2 "10.10.10.11"
>>
>> +#define RING_TIMEOUT 3
>> +
>> struct ofono_emulator {
>> struct ofono_atom *atom;
>> enum ofono_emulator_type type;
>> @@ -49,6 +51,7 @@ struct ofono_emulator {
>> int events_mode;
>> gboolean events_ind;
>> GSList *indicators;
>> + guint ring;
>
> Please name this callsetup_source.
>
>> };
>>
>> struct indicator {
>> @@ -177,6 +180,42 @@ error:
>> g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
>> }
>>
>> +static struct indicator *find_indicator(struct ofono_emulator *em,
>> + const char *name, int *index)
>> +{
>> + GSList *l;
>> + int i;
>> +
>> + for (i = 1, l = em->indicators; l; l = l->next, i++) {
>> + struct indicator *ind = l->data;
>> +
>> + if (g_str_equal(ind->name, name) == TRUE) {
>> + if (index)
>> + *index = i;
>> +
>> + return ind;
>> + }
>
> To avoid nesting, this might be better written as:
>
> if (g_str_equal(ind->name, name) == FALSE)
> continue;
>
> if (index)
> ...
>
>> + }
>> +
>> + return NULL;
>> +}
>> +
>> +static gboolean ring_cb(gpointer user_data)
>
> Please name this something like: send_callsetup_indicators
>
>> +{
>> + struct ofono_emulator *em = user_data;
>> + struct indicator *call_ind;
>> +
>> + if (em->type == OFONO_EMULATOR_TYPE_HFP&& em->slc == FALSE)
>> + return TRUE;
>> +
>> + call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
>> +
>> + if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
>> + g_at_server_send_unsolicited(em->server, "RING");
>> +
>> + return TRUE;
>> +}
>> +
>> static void brsf_cb(GAtServer *server, GAtServerRequestType type,
>> GAtResult *result, gpointer user_data)
>> {
>> @@ -418,6 +457,11 @@ static void emulator_unregister(struct ofono_atom *atom)
>> em->source = 0;
>> }
>>
>> + if (em->ring) {
>> + g_source_remove(em->ring);
>> + em->ring = 0;
>> + }
>> +
>> for (l = em->indicators; l; l = l->next) {
>> struct indicator *ind = l->data;
>>
>> @@ -681,27 +725,43 @@ enum ofono_emulator_request_type ofono_emulator_request_get_type(
>> void ofono_emulator_set_indicator(struct ofono_emulator *em,
>> const char *name, int value)
>> {
>> - GSList *l;
>> int i;
>> char buf[20];
>> + struct indicator *ind;
>> + struct indicator *call_ind;
>>
>> - for (i = 1, l = em->indicators; l; l = l->next, i++) {
>> - struct indicator *ind = l->data;
>> + ind = find_indicator(em, name,&i);
>>
>> - if (g_str_equal(ind->name, name) == FALSE)
>> - continue;
>> + if (ind == NULL || ind->value == value || value< ind->min
>> + || value> ind->max)
>> + return;
>>
>> - if (ind->value == value || value< ind->min
>> - || value> ind->max)
>> - return;
>> + ind->value = value;
>>
>> - ind->value = value;
>> + call_ind = find_indicator(em, OFONO_EMULATOR_IND_CALL, NULL);
>>
>> - if (em->events_mode == 3&& em->events_ind&& em->slc) {
>> - sprintf(buf, "+CIEV: %d,%d", i, ind->value);
>> - g_at_server_send_info(em->server, buf, TRUE);
>> - }
>> + if (em->events_mode == 3&& em->events_ind&& em->slc) {
>> + sprintf(buf, "+CIEV: %d,%d", i, ind->value);
>> + g_at_server_send_info(em->server, buf, TRUE);
>
> Reminds me, this should be g_at_server_send_unsolicited
>
>> + }
>>
>> + /*
>> + * Ring timer should be started when callsetup indicator is set to
>> + * Incoming
>> + * If there is no active call, a first RING should be sent just after
>> + * the +CIEV
>> + * It should be stopped for all other values of callsetup
>> + */
>> + if (g_str_equal(name, OFONO_EMULATOR_IND_CALLSETUP) == FALSE)
>> return;
>> +
>> + if (value == OFONO_EMULATOR_CALLSETUP_INCOMING&& em->ring == 0) {
>> + if (call_ind->value == OFONO_EMULATOR_CALL_INACTIVE)
>> + ring_cb(em);
>> +
>> + em->ring = g_timeout_add_seconds(RING_TIMEOUT, ring_cb, em);
>> + } else if (value != OFONO_EMULATOR_CALLSETUP_INCOMING&& em->ring) {
>> + g_source_remove(em->ring);
>> + em->ring = 0;
>
> Do you really need to check for em->ring here? You already return if
> the value of the indicator is already the same. Also, it sounds like
> you should just start a timer and always call ring_cb when callsetup ==
> callsetup_incoming. The CCWA/RING determination should be done in that
> function.
>
I agree with you that check of em->ring when callsetup becomes INCOMING
is useless.
I thought that the second one, when callsetup is no more INCOMING,
should be kept to stop the timer as soon as callsetup change states.
>> }
>> }
>
> Regards,
> -Denis
Regards
Fred
--
Frederic Danis Open Source Technology Centre
frederic.danis(a)intel.com Intel Corporation
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 7/8] voicecall: add +CHUP support for HFP emulator
2011-04-07 16:33 ` [PATCH v2 7/8] voicecall: add +CHUP " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-04-11 16:13 ` Denis Kenzior
2011-04-11 16:44 ` Frederic Danis
0 siblings, 1 reply; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 16:13 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5273 bytes --]
Hi Frédéric,
On 04/07/2011 11:33 AM, Frédéric Danis wrote:
> ---
> src/voicecall.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 108 insertions(+), 0 deletions(-)
>
> diff --git a/src/voicecall.c b/src/voicecall.c
> index cf02bb6..8aec0a0 100644
> --- a/src/voicecall.c
> +++ b/src/voicecall.c
> @@ -60,6 +60,7 @@ struct ofono_voicecall {
> GQueue *toneq;
> guint tone_source;
> unsigned int hfp_watch;
> + GSList *hfp_release_list;
I'd rather not do this, you're not really avoiding a race condition with
MPTY hangups or HangupAll here. I'd rather we re-use release_queue but
add additional sanity checking. Perhaps adding a callback parameter to
voicecalls_release_next might make this easy. In general we need to
think some more about how to avoid clashes between the D-Bus API and the
emulator.
> };
>
> struct voicecall {
> @@ -95,6 +96,11 @@ struct tone_queue_entry {
> int id;
> };
>
> +struct emulator_release {
> + struct ofono_voicecall *vc;
> + struct ofono_emulator *em;
> +};
> +
> static const char *default_en_list[] = { "911", "112", NULL };
> static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
> "08", "000", NULL };
> @@ -102,6 +108,7 @@ static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
> static void generic_callback(const struct ofono_error *error, void *data);
> static void multirelease_callback(const struct ofono_error *err, void *data);
> static gboolean tone_request_run(gpointer user_data);
> +static void emulator_release_next(struct emulator_release *er);
>
> static gint call_compare_by_id(gconstpointer a, gconstpointer b)
> {
> @@ -2344,6 +2351,10 @@ static void voicecall_unregister(struct ofono_atom *atom)
> OFONO_ATOM_TYPE_EMULATOR_HFP,
> emulator_remove_handler,
> "A");
> + __ofono_modem_foreach_registered_atom(modem,
> + OFONO_ATOM_TYPE_EMULATOR_HFP,
> + emulator_remove_handler,
> + "+CHUP");
>
> __ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
>
> @@ -2558,6 +2569,102 @@ fail:
> };
> }
>
> +static void emulator_multirelease_callback(const struct ofono_error *error,
> + void *data)
> +{
> + struct emulator_release *er = data;
> + struct ofono_voicecall *vc = er->vc;
> +
> + if (vc->hfp_release_list != NULL) {
> + emulator_release_next(er);
> + return;
> + }
> +
> + emulator_generic_cb(error, er->em);
> +
> + g_free(er);
> +}
> +
> +static void emulator_release_next(struct emulator_release *er)
> +{
> + struct ofono_voicecall *vc;
> + struct voicecall *call;
> +
> + vc = er->vc;
> +
> + call = vc->hfp_release_list->data;
> +
> + vc->hfp_release_list = g_slist_remove(vc->hfp_release_list, call);
> +
> + vc->driver->release_specific(vc, call->call->id,
> + emulator_multirelease_callback, er);
> +}
> +
> +static void emulator_chup_cb(struct ofono_emulator *em,
> + struct ofono_emulator_request *req, void *userdata)
> +{
> + struct ofono_voicecall *vc = userdata;
> + struct ofono_error result;
> + struct emulator_release *er;
> + GSList *l;
> + struct voicecall *call;
> +
> + result.error = 0;
> +
> + switch (ofono_emulator_request_get_type(req)) {
> + case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
> + if (vc->driver->release_specific == NULL &&
> + vc->driver->hangup_active == NULL)
> + goto fail;
> +
> + if (vc->driver->hangup_active) {
> + vc->driver->hangup_active(vc, emulator_generic_cb, em);
> + goto done;
> + }
> +
> + /* if there is already a CHUP pending we return an error */
> + if (vc->hfp_release_list)
> + goto fail;
Why are you checking this here? Shouldn't you check this before
potentially sending a hangup_active?
> +
> + er = g_try_new0(struct emulator_release, 1);
For simple structures (e.g. under 1k or so) it is fine to simply use g_new0
> + if (er == NULL) {
> + ofono_error("Unable to allocate release structure");
> + goto fail;
> + }
> +
> + er->vc = vc;
> + er->em = em;
> +
> + for (l = vc->call_list; l; l = l->next) {
> + call = l->data;
> +
> + if (call->call->status == CALL_STATUS_WAITING ||
> + call->call->status == CALL_STATUS_HELD)
> + continue;
> +
> + vc->hfp_release_list = g_slist_prepend(
> + vc->hfp_release_list,
> + l->data);
> + }
> +
> + if (vc->hfp_release_list == NULL) {
> + g_free(er);
> + goto fail;
> + }
> +
> + emulator_release_next(er);
> +
> +done:
> + dial_request_user_cancel(vc, NULL);
> + break;
> +
> + default:
> +fail:
> + result.type = OFONO_ERROR_TYPE_FAILURE;
> + ofono_emulator_send_final(em, &result);
> + };
> +}
> +
> static void emulator_hfp_watch(struct ofono_atom *atom,
> enum ofono_atom_watch_condition cond,
> void *data)
> @@ -2570,6 +2677,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
> notify_emulator_call_status(data);
>
> ofono_emulator_add_handler(em, "A", emulator_ata_cb, data, NULL);
> + ofono_emulator_add_handler(em, "+CHUP", emulator_chup_cb, data, NULL);
> }
>
> void ofono_voicecall_register(struct ofono_voicecall *vc)
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 7/8] voicecall: add +CHUP support for HFP emulator
2011-04-11 16:13 ` Denis Kenzior
@ 2011-04-11 16:44 ` Frederic Danis
2011-04-11 16:50 ` Denis Kenzior
0 siblings, 1 reply; 20+ messages in thread
From: Frederic Danis @ 2011-04-11 16:44 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5926 bytes --]
Hello Denis,
Le 11/04/2011 18:13, Denis Kenzior a écrit :
> Hi Frédéric,
>
> On 04/07/2011 11:33 AM, Frédéric Danis wrote:
>> ---
>> src/voicecall.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 1 files changed, 108 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/voicecall.c b/src/voicecall.c
>> index cf02bb6..8aec0a0 100644
>> --- a/src/voicecall.c
>> +++ b/src/voicecall.c
>> @@ -60,6 +60,7 @@ struct ofono_voicecall {
>> GQueue *toneq;
>> guint tone_source;
>> unsigned int hfp_watch;
>> + GSList *hfp_release_list;
>
> I'd rather not do this, you're not really avoiding a race condition with
> MPTY hangups or HangupAll here. I'd rather we re-use release_queue but
> add additional sanity checking. Perhaps adding a callback parameter to
> voicecalls_release_next might make this easy. In general we need to
> think some more about how to avoid clashes between the D-Bus API and the
> emulator.
>
>> };
>>
>> struct voicecall {
>> @@ -95,6 +96,11 @@ struct tone_queue_entry {
>> int id;
>> };
>>
>> +struct emulator_release {
>> + struct ofono_voicecall *vc;
>> + struct ofono_emulator *em;
>> +};
>> +
>> static const char *default_en_list[] = { "911", "112", NULL };
>> static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
>> "08", "000", NULL };
>> @@ -102,6 +108,7 @@ static const char *default_en_list_no_sim[] = { "119", "118", "999", "110",
>> static void generic_callback(const struct ofono_error *error, void *data);
>> static void multirelease_callback(const struct ofono_error *err, void *data);
>> static gboolean tone_request_run(gpointer user_data);
>> +static void emulator_release_next(struct emulator_release *er);
>>
>> static gint call_compare_by_id(gconstpointer a, gconstpointer b)
>> {
>> @@ -2344,6 +2351,10 @@ static void voicecall_unregister(struct ofono_atom *atom)
>> OFONO_ATOM_TYPE_EMULATOR_HFP,
>> emulator_remove_handler,
>> "A");
>> + __ofono_modem_foreach_registered_atom(modem,
>> + OFONO_ATOM_TYPE_EMULATOR_HFP,
>> + emulator_remove_handler,
>> + "+CHUP");
>>
>> __ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
>>
>> @@ -2558,6 +2569,102 @@ fail:
>> };
>> }
>>
>> +static void emulator_multirelease_callback(const struct ofono_error *error,
>> + void *data)
>> +{
>> + struct emulator_release *er = data;
>> + struct ofono_voicecall *vc = er->vc;
>> +
>> + if (vc->hfp_release_list != NULL) {
>> + emulator_release_next(er);
>> + return;
>> + }
>> +
>> + emulator_generic_cb(error, er->em);
>> +
>> + g_free(er);
>> +}
>> +
>> +static void emulator_release_next(struct emulator_release *er)
>> +{
>> + struct ofono_voicecall *vc;
>> + struct voicecall *call;
>> +
>> + vc = er->vc;
>> +
>> + call = vc->hfp_release_list->data;
>> +
>> + vc->hfp_release_list = g_slist_remove(vc->hfp_release_list, call);
>> +
>> + vc->driver->release_specific(vc, call->call->id,
>> + emulator_multirelease_callback, er);
>> +}
>> +
>> +static void emulator_chup_cb(struct ofono_emulator *em,
>> + struct ofono_emulator_request *req, void *userdata)
>> +{
>> + struct ofono_voicecall *vc = userdata;
>> + struct ofono_error result;
>> + struct emulator_release *er;
>> + GSList *l;
>> + struct voicecall *call;
>> +
>> + result.error = 0;
>> +
>> + switch (ofono_emulator_request_get_type(req)) {
>> + case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
>> + if (vc->driver->release_specific == NULL&&
>> + vc->driver->hangup_active == NULL)
>> + goto fail;
>> +
>> + if (vc->driver->hangup_active) {
>> + vc->driver->hangup_active(vc, emulator_generic_cb, em);
>> + goto done;
>> + }
>> +
>> + /* if there is already a CHUP pending we return an error */
>> + if (vc->hfp_release_list)
>> + goto fail;
>
> Why are you checking this here? Shouldn't you check this before
> potentially sending a hangup_active?
As far as I understand AT+CHUP, it releases all active calls (active +
incoming + dialing + alerting), so we do not need a call list and are
not able to know that we already perform one.
Is it correct ?
>
>> +
>> + er = g_try_new0(struct emulator_release, 1);
>
> For simple structures (e.g. under 1k or so) it is fine to simply use g_new0
>
>> + if (er == NULL) {
>> + ofono_error("Unable to allocate release structure");
>> + goto fail;
>> + }
>> +
>> + er->vc = vc;
>> + er->em = em;
>> +
>> + for (l = vc->call_list; l; l = l->next) {
>> + call = l->data;
>> +
>> + if (call->call->status == CALL_STATUS_WAITING ||
>> + call->call->status == CALL_STATUS_HELD)
>> + continue;
>> +
>> + vc->hfp_release_list = g_slist_prepend(
>> + vc->hfp_release_list,
>> + l->data);
>> + }
>> +
>> + if (vc->hfp_release_list == NULL) {
>> + g_free(er);
>> + goto fail;
>> + }
>> +
>> + emulator_release_next(er);
>> +
>> +done:
>> + dial_request_user_cancel(vc, NULL);
>> + break;
>> +
>> + default:
>> +fail:
>> + result.type = OFONO_ERROR_TYPE_FAILURE;
>> + ofono_emulator_send_final(em,&result);
>> + };
>> +}
>> +
>> static void emulator_hfp_watch(struct ofono_atom *atom,
>> enum ofono_atom_watch_condition cond,
>> void *data)
>> @@ -2570,6 +2677,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
>> notify_emulator_call_status(data);
>>
>> ofono_emulator_add_handler(em, "A", emulator_ata_cb, data, NULL);
>> + ofono_emulator_add_handler(em, "+CHUP", emulator_chup_cb, data, NULL);
>> }
>>
>> void ofono_voicecall_register(struct ofono_voicecall *vc)
>
> Regards,
> -Denis
Regards
Fred
--
Frederic Danis Open Source Technology Centre
frederic.danis(a)intel.com Intel Corporation
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 7/8] voicecall: add +CHUP support for HFP emulator
2011-04-11 16:44 ` Frederic Danis
@ 2011-04-11 16:50 ` Denis Kenzior
0 siblings, 0 replies; 20+ messages in thread
From: Denis Kenzior @ 2011-04-11 16:50 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]
Hi Frédéric,
>>> + switch (ofono_emulator_request_get_type(req)) {
>>> + case OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY:
>>> + if (vc->driver->release_specific == NULL&&
>>> + vc->driver->hangup_active == NULL)
>>> + goto fail;
>>> +
>>> + if (vc->driver->hangup_active) {
>>> + vc->driver->hangup_active(vc, emulator_generic_cb, em);
>>> + goto done;
>>> + }
>>> +
>>> + /* if there is already a CHUP pending we return an error */
>>> + if (vc->hfp_release_list)
>>> + goto fail;
>>
>> Why are you checking this here? Shouldn't you check this before
>> potentially sending a hangup_active?
> As far as I understand AT+CHUP, it releases all active calls (active +
> incoming + dialing + alerting), so we do not need a call list and are
> not able to know that we already perform one.
>
> Is it correct ?
Yes you're right. I jumped ahead slightly. Since I'd like to re-use
release_queue, it would be safer to check for the release list prior to
issuing any driver commands (just in case the release_list was set by
something else.)
Regards,
-Denis
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2011-04-11 16:50 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-07 16:33 [PATCH v2 0/8] *** SUBJECT HERE *** =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:33 ` [PATCH v2 1/8] emulator: add defines for call, callsetup and callheld indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:57 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 2/8] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:57 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 3/8] emulator: add RING for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:51 ` Denis Kenzior
2011-04-11 16:09 ` Frederic Danis
2011-04-07 16:33 ` [PATCH v2 4/8] emulator: add incoming call API =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:52 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 5/8] emulator: add +CLIP support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 15:56 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 6/8] voicecall: add ATA support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 16:00 ` Denis Kenzior
2011-04-07 16:33 ` [PATCH v2 7/8] voicecall: add +CHUP " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-11 16:13 ` Denis Kenzior
2011-04-11 16:44 ` Frederic Danis
2011-04-11 16:50 ` Denis Kenzior
2011-04-07 16:34 ` [PATCH v2 8/8] emulator: add +CCWA support for HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-07 16:39 ` [PATCH v2 0/8] emulator: add simple incoming call support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
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.