* [PATCH] voicecall: add +VTS support for HFP emulator
@ 2011-05-16 10:13 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
2011-05-19 16:42 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau @ 2011-05-16 10:13 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2166 bytes --]
---
src/voicecall.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/src/voicecall.c b/src/voicecall.c
index d46f463..846c1c4 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2421,6 +2421,10 @@ static void emulator_hfp_unregister(struct ofono_atom *atom)
OFONO_ATOM_TYPE_EMULATOR_HFP,
emulator_remove_handler,
"+CHLD");
+ __ofono_modem_foreach_registered_atom(modem,
+ OFONO_ATOM_TYPE_EMULATOR_HFP,
+ emulator_remove_handler,
+ "+VTS");
__ofono_modem_remove_atom_watch(modem, vc->hfp_watch);
}
@@ -2866,6 +2870,44 @@ fail:
ofono_emulator_send_final(em, &result);
}
+static void vts_tone_cb(int error, void *data)
+{
+ struct ofono_emulator *em = data;
+ struct ofono_error result;
+
+ result.error = 0;
+ result.type = error ? OFONO_ERROR_TYPE_FAILURE :
+ OFONO_ERROR_TYPE_NO_ERROR;
+
+ ofono_emulator_send_final(em, &result);
+}
+
+static void emulator_vts_cb(struct ofono_emulator *em,
+ struct ofono_emulator_request *req, void *userdata)
+{
+ struct ofono_voicecall *vc = userdata;
+ struct ofono_error result;
+ const char *str;
+
+ switch (ofono_emulator_request_get_type(req)) {
+ case OFONO_EMULATOR_REQUEST_TYPE_SET:
+ str = ofono_emulator_request_get_raw(req);
+
+ if (__ofono_voicecall_tone_send(vc, str, vts_tone_cb, em) < 0)
+ break;
+
+ return;
+
+ default:
+ break;
+ }
+
+ result.error = 0;
+ 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)
@@ -2881,6 +2923,7 @@ static void emulator_hfp_watch(struct ofono_atom *atom,
ofono_emulator_add_handler(em, "+CHUP", emulator_chup_cb, data, NULL);
ofono_emulator_add_handler(em, "+CLCC", emulator_clcc_cb, data, NULL);
ofono_emulator_add_handler(em, "+CHLD", emulator_chld_cb, data, NULL);
+ ofono_emulator_add_handler(em, "+VTS", emulator_vts_cb, data, NULL);
}
void ofono_voicecall_register(struct ofono_voicecall *vc)
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] voicecall: add +VTS support for HFP emulator
2011-05-16 10:13 [PATCH] voicecall: add +VTS support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
@ 2011-05-19 16:42 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2011-05-19 16:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 971 bytes --]
Hi Frédéric,
> +static void emulator_vts_cb(struct ofono_emulator *em,
> + struct ofono_emulator_request *req, void *userdata)
> +{
> + struct ofono_voicecall *vc = userdata;
> + struct ofono_error result;
> + const char *str;
> +
> + switch (ofono_emulator_request_get_type(req)) {
> + case OFONO_EMULATOR_REQUEST_TYPE_SET:
> + str = ofono_emulator_request_get_raw(req);
> +
> + if (__ofono_voicecall_tone_send(vc, str, vts_tone_cb, em) < 0)
> + break;
This looks wrong. The VTS command takes a single ascii character, not a
string. So you need to validate that. +VTS also does not accept P/p
characters, so you need to make sure to filter these out as well.
> +
> + return;
> +
> + default:
> + break;
> + }
> +
I'd do this like this:
if (__tone_send() == 0)
return;
> + result.error = 0;
> + result.type = OFONO_ERROR_TYPE_FAILURE;
> +
> + ofono_emulator_send_final(em, &result);
> +}
> +
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-19 16:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-16 10:13 [PATCH] voicecall: add +VTS support for HFP emulator =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Dalleau
2011-05-19 16:42 ` Denis Kenzior
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.